diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2009-01-18 17:59:11 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-03-30 11:42:24 -0400 |
commit | b960074fec573fb1b226d9e2686ce51be807cdf1 (patch) | |
tree | da58b7afa37b0ccd1c06948ad6497cb801553335 /drivers/media/video/hexium_orion.c | |
parent | c9b8b04b267f9a7e472daa06cdf6d4963d503d1f (diff) |
V4L/DVB (10271): saa7146: convert to video_ioctl2.
The conversion to video_ioctl2 is the first phase to converting this driver
to the latest v4l2 framework.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/hexium_orion.c')
-rw-r--r-- | drivers/media/video/hexium_orion.c | 103 |
1 files changed, 41 insertions, 62 deletions
diff --git a/drivers/media/video/hexium_orion.c b/drivers/media/video/hexium_orion.c index 074bec711fe0..2bc39f628455 100644 --- a/drivers/media/video/hexium_orion.c +++ b/drivers/media/video/hexium_orion.c | |||
@@ -57,14 +57,6 @@ struct hexium_data | |||
57 | u8 byte; | 57 | u8 byte; |
58 | }; | 58 | }; |
59 | 59 | ||
60 | static struct saa7146_extension_ioctls ioctls[] = { | ||
61 | { VIDIOC_G_INPUT, SAA7146_EXCLUSIVE }, | ||
62 | { VIDIOC_S_INPUT, SAA7146_EXCLUSIVE }, | ||
63 | { VIDIOC_ENUMINPUT, SAA7146_EXCLUSIVE }, | ||
64 | { VIDIOC_S_STD, SAA7146_AFTER }, | ||
65 | { 0, 0 } | ||
66 | }; | ||
67 | |||
68 | struct hexium | 60 | struct hexium |
69 | { | 61 | { |
70 | int type; | 62 | int type; |
@@ -329,6 +321,44 @@ static int hexium_set_input(struct hexium *hexium, int input) | |||
329 | return 0; | 321 | return 0; |
330 | } | 322 | } |
331 | 323 | ||
324 | static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *i) | ||
325 | { | ||
326 | DEB_EE(("VIDIOC_ENUMINPUT %d.\n", i->index)); | ||
327 | |||
328 | if (i->index < 0 || i->index >= HEXIUM_INPUTS) | ||
329 | return -EINVAL; | ||
330 | |||
331 | memcpy(i, &hexium_inputs[i->index], sizeof(struct v4l2_input)); | ||
332 | |||
333 | DEB_D(("v4l2_ioctl: VIDIOC_ENUMINPUT %d.\n", i->index)); | ||
334 | return 0; | ||
335 | } | ||
336 | |||
337 | static int vidioc_g_input(struct file *file, void *fh, unsigned int *input) | ||
338 | { | ||
339 | struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; | ||
340 | struct hexium *hexium = (struct hexium *) dev->ext_priv; | ||
341 | |||
342 | *input = hexium->cur_input; | ||
343 | |||
344 | DEB_D(("VIDIOC_G_INPUT: %d\n", *input)); | ||
345 | return 0; | ||
346 | } | ||
347 | |||
348 | static int vidioc_s_input(struct file *file, void *fh, unsigned int input) | ||
349 | { | ||
350 | struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; | ||
351 | struct hexium *hexium = (struct hexium *) dev->ext_priv; | ||
352 | |||
353 | if (input < 0 || input >= HEXIUM_INPUTS) | ||
354 | return -EINVAL; | ||
355 | |||
356 | hexium->cur_input = input; | ||
357 | hexium_set_input(hexium, input); | ||
358 | |||
359 | return 0; | ||
360 | } | ||
361 | |||
332 | static struct saa7146_ext_vv vv_data; | 362 | static struct saa7146_ext_vv vv_data; |
333 | 363 | ||
334 | /* this function only gets called when the probing was successful */ | 364 | /* this function only gets called when the probing was successful */ |
@@ -339,6 +369,9 @@ static int hexium_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_d | |||
339 | DEB_EE((".\n")); | 369 | DEB_EE((".\n")); |
340 | 370 | ||
341 | saa7146_vv_init(dev, &vv_data); | 371 | saa7146_vv_init(dev, &vv_data); |
372 | vv_data.ops.vidioc_enum_input = vidioc_enum_input; | ||
373 | vv_data.ops.vidioc_g_input = vidioc_g_input; | ||
374 | vv_data.ops.vidioc_s_input = vidioc_s_input; | ||
342 | if (0 != saa7146_register_device(&hexium->video_dev, dev, "hexium orion", VFL_TYPE_GRABBER)) { | 375 | if (0 != saa7146_register_device(&hexium->video_dev, dev, "hexium orion", VFL_TYPE_GRABBER)) { |
343 | printk("hexium_orion: cannot register capture v4l2 device. skipping.\n"); | 376 | printk("hexium_orion: cannot register capture v4l2 device. skipping.\n"); |
344 | return -1; | 377 | return -1; |
@@ -370,58 +403,6 @@ static int hexium_detach(struct saa7146_dev *dev) | |||
370 | return 0; | 403 | return 0; |
371 | } | 404 | } |
372 | 405 | ||
373 | static long hexium_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) | ||
374 | { | ||
375 | struct saa7146_dev *dev = fh->dev; | ||
376 | struct hexium *hexium = (struct hexium *) dev->ext_priv; | ||
377 | /* | ||
378 | struct saa7146_vv *vv = dev->vv_data; | ||
379 | */ | ||
380 | switch (cmd) { | ||
381 | case VIDIOC_ENUMINPUT: | ||
382 | { | ||
383 | struct v4l2_input *i = arg; | ||
384 | DEB_EE(("VIDIOC_ENUMINPUT %d.\n", i->index)); | ||
385 | |||
386 | if (i->index < 0 || i->index >= HEXIUM_INPUTS) { | ||
387 | return -EINVAL; | ||
388 | } | ||
389 | |||
390 | memcpy(i, &hexium_inputs[i->index], sizeof(struct v4l2_input)); | ||
391 | |||
392 | DEB_D(("v4l2_ioctl: VIDIOC_ENUMINPUT %d.\n", i->index)); | ||
393 | return 0; | ||
394 | } | ||
395 | case VIDIOC_G_INPUT: | ||
396 | { | ||
397 | int *input = (int *) arg; | ||
398 | *input = hexium->cur_input; | ||
399 | |||
400 | DEB_D(("VIDIOC_G_INPUT: %d\n", *input)); | ||
401 | return 0; | ||
402 | } | ||
403 | case VIDIOC_S_INPUT: | ||
404 | { | ||
405 | int input = *(int *) arg; | ||
406 | |||
407 | if (input < 0 || input >= HEXIUM_INPUTS) { | ||
408 | return -EINVAL; | ||
409 | } | ||
410 | |||
411 | hexium->cur_input = input; | ||
412 | hexium_set_input(hexium, input); | ||
413 | |||
414 | return 0; | ||
415 | } | ||
416 | default: | ||
417 | /* | ||
418 | DEB_D(("hexium_ioctl() does not handle this ioctl.\n")); | ||
419 | */ | ||
420 | return -ENOIOCTLCMD; | ||
421 | } | ||
422 | return 0; | ||
423 | } | ||
424 | |||
425 | static int std_callback(struct saa7146_dev *dev, struct saa7146_standard *std) | 406 | static int std_callback(struct saa7146_dev *dev, struct saa7146_standard *std) |
426 | { | 407 | { |
427 | return 0; | 408 | return 0; |
@@ -479,8 +460,6 @@ static struct saa7146_ext_vv vv_data = { | |||
479 | .stds = &hexium_standards[0], | 460 | .stds = &hexium_standards[0], |
480 | .num_stds = sizeof(hexium_standards) / sizeof(struct saa7146_standard), | 461 | .num_stds = sizeof(hexium_standards) / sizeof(struct saa7146_standard), |
481 | .std_callback = &std_callback, | 462 | .std_callback = &std_callback, |
482 | .ioctls = &ioctls[0], | ||
483 | .ioctl = hexium_ioctl, | ||
484 | }; | 463 | }; |
485 | 464 | ||
486 | static struct saa7146_extension extension = { | 465 | static struct saa7146_extension extension = { |