2 * Driver for the Conexant CX23885/7/8 PCIe bridge
4 * Various common ioctl() support functions
6 * Copyright (c) 2009 Andy Walls <awalls@md.metrocast.net>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
21 #include "cx23885-ioctl.h"
23 #ifdef CONFIG_VIDEO_ADV_DEBUG
24 int cx23885_g_chip_info(struct file
*file
, void *fh
,
25 struct v4l2_dbg_chip_info
*chip
)
27 struct cx23885_dev
*dev
= video_drvdata(file
);
29 if (chip
->match
.addr
> 1)
31 if (chip
->match
.addr
== 1) {
32 if (dev
->v4l_device
== NULL
)
34 strlcpy(chip
->name
, "cx23417", sizeof(chip
->name
));
36 strlcpy(chip
->name
, dev
->v4l2_dev
.name
, sizeof(chip
->name
));
41 static int cx23417_g_register(struct cx23885_dev
*dev
,
42 struct v4l2_dbg_register
*reg
)
46 if (dev
->v4l_device
== NULL
)
49 if ((reg
->reg
& 0x3) != 0 || reg
->reg
>= 0x10000)
52 if (mc417_register_read(dev
, (u16
) reg
->reg
, &value
))
53 return -EINVAL
; /* V4L2 spec, but -EREMOTEIO really */
60 int cx23885_g_register(struct file
*file
, void *fh
,
61 struct v4l2_dbg_register
*reg
)
63 struct cx23885_dev
*dev
= video_drvdata(file
);
65 if (reg
->match
.addr
> 1)
68 return cx23417_g_register(dev
, reg
);
70 if ((reg
->reg
& 0x3) != 0 || reg
->reg
>= pci_resource_len(dev
->pci
, 0))
74 reg
->val
= cx_read(reg
->reg
);
78 static int cx23417_s_register(struct cx23885_dev
*dev
,
79 const struct v4l2_dbg_register
*reg
)
81 if (dev
->v4l_device
== NULL
)
84 if ((reg
->reg
& 0x3) != 0 || reg
->reg
>= 0x10000)
87 if (mc417_register_write(dev
, (u16
) reg
->reg
, (u32
) reg
->val
))
88 return -EINVAL
; /* V4L2 spec, but -EREMOTEIO really */
92 int cx23885_s_register(struct file
*file
, void *fh
,
93 const struct v4l2_dbg_register
*reg
)
95 struct cx23885_dev
*dev
= video_drvdata(file
);
97 if (reg
->match
.addr
> 1)
100 return cx23417_s_register(dev
, reg
);
102 if ((reg
->reg
& 0x3) != 0 || reg
->reg
>= pci_resource_len(dev
->pci
, 0))
105 cx_write(reg
->reg
, reg
->val
);