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/dvb/ttpci/budget-av.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/dvb/ttpci/budget-av.c')
-rw-r--r-- | drivers/media/dvb/ttpci/budget-av.c | 88 |
1 files changed, 38 insertions, 50 deletions
diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c index 4182121d7e5d..855fe74b640b 100644 --- a/drivers/media/dvb/ttpci/budget-av.c +++ b/drivers/media/dvb/ttpci/budget-av.c | |||
@@ -1404,6 +1404,41 @@ static int budget_av_detach(struct saa7146_dev *dev) | |||
1404 | return err; | 1404 | return err; |
1405 | } | 1405 | } |
1406 | 1406 | ||
1407 | #define KNC1_INPUTS 2 | ||
1408 | static struct v4l2_input knc1_inputs[KNC1_INPUTS] = { | ||
1409 | {0, "Composite", V4L2_INPUT_TYPE_TUNER, 1, 0, V4L2_STD_PAL_BG | V4L2_STD_NTSC_M, 0}, | ||
1410 | {1, "S-Video", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG | V4L2_STD_NTSC_M, 0}, | ||
1411 | }; | ||
1412 | |||
1413 | static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *i) | ||
1414 | { | ||
1415 | dprintk(1, "VIDIOC_ENUMINPUT %d.\n", i->index); | ||
1416 | if (i->index < 0 || i->index >= KNC1_INPUTS) | ||
1417 | return -EINVAL; | ||
1418 | memcpy(i, &knc1_inputs[i->index], sizeof(struct v4l2_input)); | ||
1419 | return 0; | ||
1420 | } | ||
1421 | |||
1422 | static int vidioc_g_input(struct file *file, void *fh, unsigned int *i) | ||
1423 | { | ||
1424 | struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; | ||
1425 | struct budget_av *budget_av = (struct budget_av *)dev->ext_priv; | ||
1426 | |||
1427 | *i = budget_av->cur_input; | ||
1428 | |||
1429 | dprintk(1, "VIDIOC_G_INPUT %d.\n", *i); | ||
1430 | return 0; | ||
1431 | } | ||
1432 | |||
1433 | static int vidioc_s_input(struct file *file, void *fh, unsigned int input) | ||
1434 | { | ||
1435 | struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; | ||
1436 | struct budget_av *budget_av = (struct budget_av *)dev->ext_priv; | ||
1437 | |||
1438 | dprintk(1, "VIDIOC_S_INPUT %d.\n", input); | ||
1439 | return saa7113_setinput(budget_av, input); | ||
1440 | } | ||
1441 | |||
1407 | static struct saa7146_ext_vv vv_data; | 1442 | static struct saa7146_ext_vv vv_data; |
1408 | 1443 | ||
1409 | static int budget_av_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_data *info) | 1444 | static int budget_av_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_data *info) |
@@ -1442,6 +1477,9 @@ static int budget_av_attach(struct saa7146_dev *dev, struct saa7146_pci_extensio | |||
1442 | ERR(("cannot init vv subsystem.\n")); | 1477 | ERR(("cannot init vv subsystem.\n")); |
1443 | return err; | 1478 | return err; |
1444 | } | 1479 | } |
1480 | vv_data.ops.vidioc_enum_input = vidioc_enum_input; | ||
1481 | vv_data.ops.vidioc_g_input = vidioc_g_input; | ||
1482 | vv_data.ops.vidioc_s_input = vidioc_s_input; | ||
1445 | 1483 | ||
1446 | if ((err = saa7146_register_device(&budget_av->vd, dev, "knc1", VFL_TYPE_GRABBER))) { | 1484 | if ((err = saa7146_register_device(&budget_av->vd, dev, "knc1", VFL_TYPE_GRABBER))) { |
1447 | /* fixme: proper cleanup here */ | 1485 | /* fixme: proper cleanup here */ |
@@ -1480,54 +1518,6 @@ static int budget_av_attach(struct saa7146_dev *dev, struct saa7146_pci_extensio | |||
1480 | return 0; | 1518 | return 0; |
1481 | } | 1519 | } |
1482 | 1520 | ||
1483 | #define KNC1_INPUTS 2 | ||
1484 | static struct v4l2_input knc1_inputs[KNC1_INPUTS] = { | ||
1485 | {0, "Composite", V4L2_INPUT_TYPE_TUNER, 1, 0, V4L2_STD_PAL_BG | V4L2_STD_NTSC_M, 0}, | ||
1486 | {1, "S-Video", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG | V4L2_STD_NTSC_M, 0}, | ||
1487 | }; | ||
1488 | |||
1489 | static struct saa7146_extension_ioctls ioctls[] = { | ||
1490 | {VIDIOC_ENUMINPUT, SAA7146_EXCLUSIVE}, | ||
1491 | {VIDIOC_G_INPUT, SAA7146_EXCLUSIVE}, | ||
1492 | {VIDIOC_S_INPUT, SAA7146_EXCLUSIVE}, | ||
1493 | {0, 0} | ||
1494 | }; | ||
1495 | |||
1496 | static long av_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) | ||
1497 | { | ||
1498 | struct saa7146_dev *dev = fh->dev; | ||
1499 | struct budget_av *budget_av = (struct budget_av *) dev->ext_priv; | ||
1500 | |||
1501 | switch (cmd) { | ||
1502 | case VIDIOC_ENUMINPUT:{ | ||
1503 | struct v4l2_input *i = arg; | ||
1504 | |||
1505 | dprintk(1, "VIDIOC_ENUMINPUT %d.\n", i->index); | ||
1506 | if (i->index < 0 || i->index >= KNC1_INPUTS) { | ||
1507 | return -EINVAL; | ||
1508 | } | ||
1509 | memcpy(i, &knc1_inputs[i->index], sizeof(struct v4l2_input)); | ||
1510 | return 0; | ||
1511 | } | ||
1512 | case VIDIOC_G_INPUT:{ | ||
1513 | int *input = (int *) arg; | ||
1514 | |||
1515 | *input = budget_av->cur_input; | ||
1516 | |||
1517 | dprintk(1, "VIDIOC_G_INPUT %d.\n", *input); | ||
1518 | return 0; | ||
1519 | } | ||
1520 | case VIDIOC_S_INPUT:{ | ||
1521 | int input = *(int *) arg; | ||
1522 | dprintk(1, "VIDIOC_S_INPUT %d.\n", input); | ||
1523 | return saa7113_setinput(budget_av, input); | ||
1524 | } | ||
1525 | default: | ||
1526 | return -ENOIOCTLCMD; | ||
1527 | } | ||
1528 | return 0; | ||
1529 | } | ||
1530 | |||
1531 | static struct saa7146_standard standard[] = { | 1521 | static struct saa7146_standard standard[] = { |
1532 | {.name = "PAL",.id = V4L2_STD_PAL, | 1522 | {.name = "PAL",.id = V4L2_STD_PAL, |
1533 | .v_offset = 0x17,.v_field = 288, | 1523 | .v_offset = 0x17,.v_field = 288, |
@@ -1546,8 +1536,6 @@ static struct saa7146_ext_vv vv_data = { | |||
1546 | .flags = 0, | 1536 | .flags = 0, |
1547 | .stds = &standard[0], | 1537 | .stds = &standard[0], |
1548 | .num_stds = ARRAY_SIZE(standard), | 1538 | .num_stds = ARRAY_SIZE(standard), |
1549 | .ioctls = &ioctls[0], | ||
1550 | .ioctl = av_ioctl, | ||
1551 | }; | 1539 | }; |
1552 | 1540 | ||
1553 | static struct saa7146_extension budget_extension; | 1541 | static struct saa7146_extension budget_extension; |