aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx18
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/cx18')
-rw-r--r--drivers/media/video/cx18/cx18-fileops.c6
-rw-r--r--drivers/media/video/cx18/cx18-fileops.h4
-rw-r--r--drivers/media/video/cx18/cx18-i2c.c28
-rw-r--r--drivers/media/video/cx18/cx18-i2c.h1
-rw-r--r--drivers/media/video/cx18/cx18-ioctl.c49
-rw-r--r--drivers/media/video/cx18/cx18-ioctl.h2
-rw-r--r--drivers/media/video/cx18/cx18-streams.c13
7 files changed, 28 insertions, 75 deletions
diff --git a/drivers/media/video/cx18/cx18-fileops.c b/drivers/media/video/cx18/cx18-fileops.c
index 425271a29517..055f6e004b2d 100644
--- a/drivers/media/video/cx18/cx18-fileops.c
+++ b/drivers/media/video/cx18/cx18-fileops.c
@@ -552,7 +552,7 @@ void cx18_stop_capture(struct cx18_open_id *id, int gop_end)
552 } 552 }
553} 553}
554 554
555int cx18_v4l2_close(struct inode *inode, struct file *filp) 555int cx18_v4l2_close(struct file *filp)
556{ 556{
557 struct cx18_open_id *id = filp->private_data; 557 struct cx18_open_id *id = filp->private_data;
558 struct cx18 *cx = id->cx; 558 struct cx18 *cx = id->cx;
@@ -650,12 +650,12 @@ static int cx18_serialized_open(struct cx18_stream *s, struct file *filp)
650 return 0; 650 return 0;
651} 651}
652 652
653int cx18_v4l2_open(struct inode *inode, struct file *filp) 653int cx18_v4l2_open(struct file *filp)
654{ 654{
655 int res, x, y = 0; 655 int res, x, y = 0;
656 struct cx18 *cx = NULL; 656 struct cx18 *cx = NULL;
657 struct cx18_stream *s = NULL; 657 struct cx18_stream *s = NULL;
658 int minor = iminor(inode); 658 int minor = video_devdata(filp)->minor;
659 659
660 /* Find which card this open was on */ 660 /* Find which card this open was on */
661 spin_lock(&cx18_cards_lock); 661 spin_lock(&cx18_cards_lock);
diff --git a/drivers/media/video/cx18/cx18-fileops.h b/drivers/media/video/cx18/cx18-fileops.h
index 46da0282fc7d..92e2d5dab936 100644
--- a/drivers/media/video/cx18/cx18-fileops.h
+++ b/drivers/media/video/cx18/cx18-fileops.h
@@ -22,12 +22,12 @@
22 */ 22 */
23 23
24/* Testing/Debugging */ 24/* Testing/Debugging */
25int cx18_v4l2_open(struct inode *inode, struct file *filp); 25int cx18_v4l2_open(struct file *filp);
26ssize_t cx18_v4l2_read(struct file *filp, char __user *buf, size_t count, 26ssize_t cx18_v4l2_read(struct file *filp, char __user *buf, size_t count,
27 loff_t *pos); 27 loff_t *pos);
28ssize_t cx18_v4l2_write(struct file *filp, const char __user *buf, size_t count, 28ssize_t cx18_v4l2_write(struct file *filp, const char __user *buf, size_t count,
29 loff_t *pos); 29 loff_t *pos);
30int cx18_v4l2_close(struct inode *inode, struct file *filp); 30int cx18_v4l2_close(struct file *filp);
31unsigned int cx18_v4l2_enc_poll(struct file *filp, poll_table *wait); 31unsigned int cx18_v4l2_enc_poll(struct file *filp, poll_table *wait);
32int cx18_start_capture(struct cx18_open_id *id); 32int cx18_start_capture(struct cx18_open_id *id);
33void cx18_stop_capture(struct cx18_open_id *id, int gop_end); 33void cx18_stop_capture(struct cx18_open_id *id, int gop_end);
diff --git a/drivers/media/video/cx18/cx18-i2c.c b/drivers/media/video/cx18/cx18-i2c.c
index 8941f58bed7f..83e1c6333126 100644
--- a/drivers/media/video/cx18/cx18-i2c.c
+++ b/drivers/media/video/cx18/cx18-i2c.c
@@ -242,7 +242,7 @@ int cx18_call_i2c_client(struct cx18 *cx, int addr, unsigned cmd, void *arg)
242 return retval; 242 return retval;
243 } 243 }
244 } 244 }
245 if (cmd != VIDIOC_G_CHIP_IDENT) 245 if (cmd != VIDIOC_DBG_G_CHIP_IDENT)
246 CX18_ERR("i2c addr 0x%02x not found for cmd 0x%x!\n", 246 CX18_ERR("i2c addr 0x%02x not found for cmd 0x%x!\n",
247 addr, cmd); 247 addr, cmd);
248 return -ENODEV; 248 return -ENODEV;
@@ -268,17 +268,6 @@ static int cx18_i2c_id_addr(struct cx18 *cx, u32 id)
268 return retval; 268 return retval;
269} 269}
270 270
271/* Find the i2c device name matching the DRIVERID */
272static const char *cx18_i2c_id_name(u32 id)
273{
274 int i;
275
276 for (i = 0; i < ARRAY_SIZE(hw_driverids); i++)
277 if (hw_driverids[i] == id)
278 return hw_devicenames[i];
279 return "unknown device";
280}
281
282/* Find the i2c device name matching the CX18_HW_ flag */ 271/* Find the i2c device name matching the CX18_HW_ flag */
283static const char *cx18_i2c_hw_name(u32 hw) 272static const char *cx18_i2c_hw_name(u32 hw)
284{ 273{
@@ -326,21 +315,6 @@ int cx18_i2c_hw(struct cx18 *cx, u32 hw, unsigned int cmd, void *arg)
326 return cx18_call_i2c_client(cx, addr, cmd, arg); 315 return cx18_call_i2c_client(cx, addr, cmd, arg);
327} 316}
328 317
329/* Calls i2c device based on I2C driver ID. */
330int cx18_i2c_id(struct cx18 *cx, u32 id, unsigned int cmd, void *arg)
331{
332 int addr;
333
334 addr = cx18_i2c_id_addr(cx, id);
335 if (addr < 0) {
336 if (cmd != VIDIOC_G_CHIP_IDENT)
337 CX18_ERR("i2c ID 0x%08x (%s) not found for cmd 0x%x!\n",
338 id, cx18_i2c_id_name(id), cmd);
339 return addr;
340 }
341 return cx18_call_i2c_client(cx, addr, cmd, arg);
342}
343
344/* broadcast cmd for all I2C clients and for the gpio subsystem */ 318/* broadcast cmd for all I2C clients and for the gpio subsystem */
345void cx18_call_i2c_clients(struct cx18 *cx, unsigned int cmd, void *arg) 319void cx18_call_i2c_clients(struct cx18 *cx, unsigned int cmd, void *arg)
346{ 320{
diff --git a/drivers/media/video/cx18/cx18-i2c.h b/drivers/media/video/cx18/cx18-i2c.h
index 113c3f9a2cc0..4869739013bd 100644
--- a/drivers/media/video/cx18/cx18-i2c.h
+++ b/drivers/media/video/cx18/cx18-i2c.h
@@ -23,7 +23,6 @@
23 23
24int cx18_i2c_hw_addr(struct cx18 *cx, u32 hw); 24int cx18_i2c_hw_addr(struct cx18 *cx, u32 hw);
25int cx18_i2c_hw(struct cx18 *cx, u32 hw, unsigned int cmd, void *arg); 25int cx18_i2c_hw(struct cx18 *cx, u32 hw, unsigned int cmd, void *arg);
26int cx18_i2c_id(struct cx18 *cx, u32 id, unsigned int cmd, void *arg);
27int cx18_call_i2c_client(struct cx18 *cx, int addr, unsigned cmd, void *arg); 26int cx18_call_i2c_client(struct cx18 *cx, int addr, unsigned cmd, void *arg);
28void cx18_call_i2c_clients(struct cx18 *cx, unsigned int cmd, void *arg); 27void cx18_call_i2c_clients(struct cx18 *cx, unsigned int cmd, void *arg);
29int cx18_i2c_register(struct cx18 *cx, unsigned idx); 28int cx18_i2c_register(struct cx18 *cx, unsigned idx);
diff --git a/drivers/media/video/cx18/cx18-ioctl.c b/drivers/media/video/cx18/cx18-ioctl.c
index e6087486f889..7086aaba77d6 100644
--- a/drivers/media/video/cx18/cx18-ioctl.c
+++ b/drivers/media/video/cx18/cx18-ioctl.c
@@ -254,30 +254,24 @@ static int cx18_s_fmt_sliced_vbi_cap(struct file *file, void *fh,
254} 254}
255 255
256static int cx18_g_chip_ident(struct file *file, void *fh, 256static int cx18_g_chip_ident(struct file *file, void *fh,
257 struct v4l2_chip_ident *chip) 257 struct v4l2_dbg_chip_ident *chip)
258{ 258{
259 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; 259 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
260 260
261 chip->ident = V4L2_IDENT_NONE; 261 chip->ident = V4L2_IDENT_NONE;
262 chip->revision = 0; 262 chip->revision = 0;
263 if (chip->match_type == V4L2_CHIP_MATCH_HOST) { 263 if (v4l2_chip_match_host(&chip->match)) {
264 if (v4l2_chip_match_host(chip->match_type, chip->match_chip)) 264 chip->ident = V4L2_IDENT_CX23418;
265 chip->ident = V4L2_IDENT_CX23418;
266 return 0; 265 return 0;
267 } 266 }
268 if (chip->match_type == V4L2_CHIP_MATCH_I2C_DRIVER) 267 cx18_call_i2c_clients(cx, VIDIOC_DBG_G_CHIP_IDENT, chip);
269 return cx18_i2c_id(cx, chip->match_chip, VIDIOC_G_CHIP_IDENT, 268 return 0;
270 chip);
271 if (chip->match_type == V4L2_CHIP_MATCH_I2C_ADDR)
272 return cx18_call_i2c_client(cx, chip->match_chip,
273 VIDIOC_G_CHIP_IDENT, chip);
274 return -EINVAL;
275} 269}
276 270
277#ifdef CONFIG_VIDEO_ADV_DEBUG 271#ifdef CONFIG_VIDEO_ADV_DEBUG
278static int cx18_cxc(struct cx18 *cx, unsigned int cmd, void *arg) 272static int cx18_cxc(struct cx18 *cx, unsigned int cmd, void *arg)
279{ 273{
280 struct v4l2_register *regs = arg; 274 struct v4l2_dbg_register *regs = arg;
281 unsigned long flags; 275 unsigned long flags;
282 276
283 if (!capable(CAP_SYS_ADMIN)) 277 if (!capable(CAP_SYS_ADMIN))
@@ -286,6 +280,7 @@ static int cx18_cxc(struct cx18 *cx, unsigned int cmd, void *arg)
286 return -EINVAL; 280 return -EINVAL;
287 281
288 spin_lock_irqsave(&cx18_cards_lock, flags); 282 spin_lock_irqsave(&cx18_cards_lock, flags);
283 regs->size = 4;
289 if (cmd == VIDIOC_DBG_G_REGISTER) 284 if (cmd == VIDIOC_DBG_G_REGISTER)
290 regs->val = cx18_read_enc(cx, regs->reg); 285 regs->val = cx18_read_enc(cx, regs->reg);
291 else 286 else
@@ -295,31 +290,25 @@ static int cx18_cxc(struct cx18 *cx, unsigned int cmd, void *arg)
295} 290}
296 291
297static int cx18_g_register(struct file *file, void *fh, 292static int cx18_g_register(struct file *file, void *fh,
298 struct v4l2_register *reg) 293 struct v4l2_dbg_register *reg)
299{ 294{
300 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; 295 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
301 296
302 if (v4l2_chip_match_host(reg->match_type, reg->match_chip)) 297 if (v4l2_chip_match_host(&reg->match))
303 return cx18_cxc(cx, VIDIOC_DBG_G_REGISTER, reg); 298 return cx18_cxc(cx, VIDIOC_DBG_G_REGISTER, reg);
304 if (reg->match_type == V4L2_CHIP_MATCH_I2C_DRIVER) 299 cx18_call_i2c_clients(cx, VIDIOC_DBG_G_REGISTER, reg);
305 return cx18_i2c_id(cx, reg->match_chip, VIDIOC_DBG_G_REGISTER, 300 return 0;
306 reg);
307 return cx18_call_i2c_client(cx, reg->match_chip, VIDIOC_DBG_G_REGISTER,
308 reg);
309} 301}
310 302
311static int cx18_s_register(struct file *file, void *fh, 303static int cx18_s_register(struct file *file, void *fh,
312 struct v4l2_register *reg) 304 struct v4l2_dbg_register *reg)
313{ 305{
314 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; 306 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
315 307
316 if (v4l2_chip_match_host(reg->match_type, reg->match_chip)) 308 if (v4l2_chip_match_host(&reg->match))
317 return cx18_cxc(cx, VIDIOC_DBG_S_REGISTER, reg); 309 return cx18_cxc(cx, VIDIOC_DBG_S_REGISTER, reg);
318 if (reg->match_type == V4L2_CHIP_MATCH_I2C_DRIVER) 310 cx18_call_i2c_clients(cx, VIDIOC_DBG_S_REGISTER, reg);
319 return cx18_i2c_id(cx, reg->match_chip, VIDIOC_DBG_S_REGISTER, 311 return 0;
320 reg);
321 return cx18_call_i2c_client(cx, reg->match_chip, VIDIOC_DBG_S_REGISTER,
322 reg);
323} 312}
324#endif 313#endif
325 314
@@ -755,7 +744,7 @@ static int cx18_log_status(struct file *file, void *fh)
755 return 0; 744 return 0;
756} 745}
757 746
758static int cx18_default(struct file *file, void *fh, int cmd, void *arg) 747static long cx18_default(struct file *file, void *fh, int cmd, void *arg)
759{ 748{
760 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; 749 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
761 750
@@ -783,19 +772,19 @@ static int cx18_default(struct file *file, void *fh, int cmd, void *arg)
783 return 0; 772 return 0;
784} 773}
785 774
786int cx18_v4l2_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, 775long cx18_v4l2_ioctl(struct file *filp, unsigned int cmd,
787 unsigned long arg) 776 unsigned long arg)
788{ 777{
789 struct video_device *vfd = video_devdata(filp); 778 struct video_device *vfd = video_devdata(filp);
790 struct cx18_open_id *id = (struct cx18_open_id *)filp->private_data; 779 struct cx18_open_id *id = (struct cx18_open_id *)filp->private_data;
791 struct cx18 *cx = id->cx; 780 struct cx18 *cx = id->cx;
792 int res; 781 long res;
793 782
794 mutex_lock(&cx->serialize_lock); 783 mutex_lock(&cx->serialize_lock);
795 784
796 if (cx18_debug & CX18_DBGFLG_IOCTL) 785 if (cx18_debug & CX18_DBGFLG_IOCTL)
797 vfd->debug = V4L2_DEBUG_IOCTL | V4L2_DEBUG_IOCTL_ARG; 786 vfd->debug = V4L2_DEBUG_IOCTL | V4L2_DEBUG_IOCTL_ARG;
798 res = video_ioctl2(inode, filp, cmd, arg); 787 res = video_ioctl2(filp, cmd, arg);
799 vfd->debug = 0; 788 vfd->debug = 0;
800 mutex_unlock(&cx->serialize_lock); 789 mutex_unlock(&cx->serialize_lock);
801 return res; 790 return res;
diff --git a/drivers/media/video/cx18/cx18-ioctl.h b/drivers/media/video/cx18/cx18-ioctl.h
index 08fe24e9510e..e2ca0d152116 100644
--- a/drivers/media/video/cx18/cx18-ioctl.h
+++ b/drivers/media/video/cx18/cx18-ioctl.h
@@ -29,5 +29,5 @@ void cx18_set_funcs(struct video_device *vdev);
29int cx18_s_std(struct file *file, void *fh, v4l2_std_id *std); 29int cx18_s_std(struct file *file, void *fh, v4l2_std_id *std);
30int cx18_s_frequency(struct file *file, void *fh, struct v4l2_frequency *vf); 30int cx18_s_frequency(struct file *file, void *fh, struct v4l2_frequency *vf);
31int cx18_s_input(struct file *file, void *fh, unsigned int inp); 31int cx18_s_input(struct file *file, void *fh, unsigned int inp);
32int cx18_v4l2_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, 32long cx18_v4l2_ioctl(struct file *filp, unsigned int cmd,
33 unsigned long arg); 33 unsigned long arg);
diff --git a/drivers/media/video/cx18/cx18-streams.c b/drivers/media/video/cx18/cx18-streams.c
index 63c336c95ff5..89c1ec94f335 100644
--- a/drivers/media/video/cx18/cx18-streams.c
+++ b/drivers/media/video/cx18/cx18-streams.c
@@ -37,13 +37,12 @@
37 37
38#define CX18_DSP0_INTERRUPT_MASK 0xd0004C 38#define CX18_DSP0_INTERRUPT_MASK 0xd0004C
39 39
40static struct file_operations cx18_v4l2_enc_fops = { 40static struct v4l2_file_operations cx18_v4l2_enc_fops = {
41 .owner = THIS_MODULE, 41 .owner = THIS_MODULE,
42 .read = cx18_v4l2_read, 42 .read = cx18_v4l2_read,
43 .open = cx18_v4l2_open, 43 .open = cx18_v4l2_open,
44 /* FIXME change to video_ioctl2 if serialization lock can be removed */ 44 /* FIXME change to video_ioctl2 if serialization lock can be removed */
45 .ioctl = cx18_v4l2_ioctl, 45 .ioctl = cx18_v4l2_ioctl,
46 .compat_ioctl = v4l_compat_ioctl32,
47 .release = cx18_v4l2_close, 46 .release = cx18_v4l2_close,
48 .poll = cx18_v4l2_enc_poll, 47 .poll = cx18_v4l2_enc_poll,
49}; 48};
@@ -61,49 +60,41 @@ static struct {
61 int num_offset; 60 int num_offset;
62 int dma; 61 int dma;
63 enum v4l2_buf_type buf_type; 62 enum v4l2_buf_type buf_type;
64 struct file_operations *fops;
65} cx18_stream_info[] = { 63} cx18_stream_info[] = {
66 { /* CX18_ENC_STREAM_TYPE_MPG */ 64 { /* CX18_ENC_STREAM_TYPE_MPG */
67 "encoder MPEG", 65 "encoder MPEG",
68 VFL_TYPE_GRABBER, 0, 66 VFL_TYPE_GRABBER, 0,
69 PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_VIDEO_CAPTURE, 67 PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_VIDEO_CAPTURE,
70 &cx18_v4l2_enc_fops
71 }, 68 },
72 { /* CX18_ENC_STREAM_TYPE_TS */ 69 { /* CX18_ENC_STREAM_TYPE_TS */
73 "TS", 70 "TS",
74 VFL_TYPE_GRABBER, -1, 71 VFL_TYPE_GRABBER, -1,
75 PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_VIDEO_CAPTURE, 72 PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_VIDEO_CAPTURE,
76 &cx18_v4l2_enc_fops
77 }, 73 },
78 { /* CX18_ENC_STREAM_TYPE_YUV */ 74 { /* CX18_ENC_STREAM_TYPE_YUV */
79 "encoder YUV", 75 "encoder YUV",
80 VFL_TYPE_GRABBER, CX18_V4L2_ENC_YUV_OFFSET, 76 VFL_TYPE_GRABBER, CX18_V4L2_ENC_YUV_OFFSET,
81 PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_VIDEO_CAPTURE, 77 PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_VIDEO_CAPTURE,
82 &cx18_v4l2_enc_fops
83 }, 78 },
84 { /* CX18_ENC_STREAM_TYPE_VBI */ 79 { /* CX18_ENC_STREAM_TYPE_VBI */
85 "encoder VBI", 80 "encoder VBI",
86 VFL_TYPE_VBI, 0, 81 VFL_TYPE_VBI, 0,
87 PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_VBI_CAPTURE, 82 PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_VBI_CAPTURE,
88 &cx18_v4l2_enc_fops
89 }, 83 },
90 { /* CX18_ENC_STREAM_TYPE_PCM */ 84 { /* CX18_ENC_STREAM_TYPE_PCM */
91 "encoder PCM audio", 85 "encoder PCM audio",
92 VFL_TYPE_GRABBER, CX18_V4L2_ENC_PCM_OFFSET, 86 VFL_TYPE_GRABBER, CX18_V4L2_ENC_PCM_OFFSET,
93 PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_PRIVATE, 87 PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_PRIVATE,
94 &cx18_v4l2_enc_fops
95 }, 88 },
96 { /* CX18_ENC_STREAM_TYPE_IDX */ 89 { /* CX18_ENC_STREAM_TYPE_IDX */
97 "encoder IDX", 90 "encoder IDX",
98 VFL_TYPE_GRABBER, -1, 91 VFL_TYPE_GRABBER, -1,
99 PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_VIDEO_CAPTURE, 92 PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_VIDEO_CAPTURE,
100 &cx18_v4l2_enc_fops
101 }, 93 },
102 { /* CX18_ENC_STREAM_TYPE_RAD */ 94 { /* CX18_ENC_STREAM_TYPE_RAD */
103 "encoder radio", 95 "encoder radio",
104 VFL_TYPE_RADIO, 0, 96 VFL_TYPE_RADIO, 0,
105 PCI_DMA_NONE, V4L2_BUF_TYPE_PRIVATE, 97 PCI_DMA_NONE, V4L2_BUF_TYPE_PRIVATE,
106 &cx18_v4l2_enc_fops
107 }, 98 },
108}; 99};
109 100
@@ -184,7 +175,7 @@ static int cx18_prep_dev(struct cx18 *cx, int type)
184 175
185 s->v4l2dev->num = num; 176 s->v4l2dev->num = num;
186 s->v4l2dev->parent = &cx->dev->dev; 177 s->v4l2dev->parent = &cx->dev->dev;
187 s->v4l2dev->fops = cx18_stream_info[type].fops; 178 s->v4l2dev->fops = &cx18_v4l2_enc_fops;
188 s->v4l2dev->release = video_device_release; 179 s->v4l2dev->release = video_device_release;
189 s->v4l2dev->tvnorms = V4L2_STD_ALL; 180 s->v4l2dev->tvnorms = V4L2_STD_ALL;
190 cx18_set_funcs(s->v4l2dev); 181 cx18_set_funcs(s->v4l2dev);