1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Driver for the Conexant CX23885/7/8 PCIe bridge
5 * Various common ioctl() support functions
7 * Copyright (c) 2009 Andy Walls <awalls@md.metrocast.net>
11 #include "cx23885-ioctl.h"
13 #ifdef CONFIG_VIDEO_ADV_DEBUG
14 int cx23885_g_chip_info(struct file
*file
, void *fh
,
15 struct v4l2_dbg_chip_info
*chip
)
17 struct cx23885_dev
*dev
= video_drvdata(file
);
19 if (chip
->match
.addr
> 1)
21 if (chip
->match
.addr
== 1) {
22 if (dev
->v4l_device
== NULL
)
24 strscpy(chip
->name
, "cx23417", sizeof(chip
->name
));
26 strscpy(chip
->name
, dev
->v4l2_dev
.name
, sizeof(chip
->name
));
31 static int cx23417_g_register(struct cx23885_dev
*dev
,
32 struct v4l2_dbg_register
*reg
)
36 if (dev
->v4l_device
== NULL
)
39 if ((reg
->reg
& 0x3) != 0 || reg
->reg
>= 0x10000)
42 if (mc417_register_read(dev
, (u16
) reg
->reg
, &value
))
43 return -EINVAL
; /* V4L2 spec, but -EREMOTEIO really */
50 int cx23885_g_register(struct file
*file
, void *fh
,
51 struct v4l2_dbg_register
*reg
)
53 struct cx23885_dev
*dev
= video_drvdata(file
);
55 if (reg
->match
.addr
> 1)
58 return cx23417_g_register(dev
, reg
);
60 if ((reg
->reg
& 0x3) != 0 || reg
->reg
>= pci_resource_len(dev
->pci
, 0))
64 reg
->val
= cx_read(reg
->reg
);
68 static int cx23417_s_register(struct cx23885_dev
*dev
,
69 const struct v4l2_dbg_register
*reg
)
71 if (dev
->v4l_device
== NULL
)
74 if ((reg
->reg
& 0x3) != 0 || reg
->reg
>= 0x10000)
77 if (mc417_register_write(dev
, (u16
) reg
->reg
, (u32
) reg
->val
))
78 return -EINVAL
; /* V4L2 spec, but -EREMOTEIO really */
82 int cx23885_s_register(struct file
*file
, void *fh
,
83 const struct v4l2_dbg_register
*reg
)
85 struct cx23885_dev
*dev
= video_drvdata(file
);
87 if (reg
->match
.addr
> 1)
90 return cx23417_s_register(dev
, reg
);
92 if ((reg
->reg
& 0x3) != 0 || reg
->reg
>= pci_resource_len(dev
->pci
, 0))
95 cx_write(reg
->reg
, reg
->val
);