aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/hdpvr
diff options
context:
space:
mode:
authorJanne Grunau <j@jannau.net>2009-03-18 19:57:04 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-30 11:43:28 -0400
commit76717b887cccc77d04357fc0d6ac98f894e3eb3c (patch)
tree2ac15d685d39e9171060914dc963fc086bf7971e /drivers/media/video/hdpvr
parent9aba42efe85bc7a55e3fed0747ce14abc9ee96e7 (diff)
V4L/DVB (11097): use video_ioctl2 as ioctl handler directly
The encoder commands ioctls are available in v4l2_ioctl_ops. Use them and get rid of the custom ioctl handler and use video_ioctl2. Signed-off-by: Janne Grunau <j@jannau.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/hdpvr')
-rw-r--r--drivers/media/video/hdpvr/hdpvr-video.c85
1 files changed, 41 insertions, 44 deletions
diff --git a/drivers/media/video/hdpvr/hdpvr-video.c b/drivers/media/video/hdpvr/hdpvr-video.c
index ee481495e4fc..6dd11f490735 100644
--- a/drivers/media/video/hdpvr/hdpvr-video.c
+++ b/drivers/media/video/hdpvr/hdpvr-video.c
@@ -524,56 +524,13 @@ static unsigned int hdpvr_poll(struct file *filp, poll_table *wait)
524} 524}
525 525
526 526
527static long hdpvr_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
528{
529 struct hdpvr_fh *fh = (struct hdpvr_fh *)filp->private_data;
530 struct hdpvr_device *dev = fh->dev;
531 int res;
532
533 if (video_is_unregistered(dev->video_dev))
534 return -EIO;
535
536 mutex_lock(&dev->io_mutex);
537 switch (cmd) {
538 case VIDIOC_TRY_ENCODER_CMD:
539 case VIDIOC_ENCODER_CMD: {
540 struct v4l2_encoder_cmd *enc = (struct v4l2_encoder_cmd *)arg;
541 int try = cmd == VIDIOC_TRY_ENCODER_CMD;
542
543 memset(&enc->raw, 0, sizeof(enc->raw));
544 switch (enc->cmd) {
545 case V4L2_ENC_CMD_START:
546 enc->flags = 0;
547 if (try)
548 return 0;
549 res = hdpvr_start_streaming(dev);
550 break;
551 case V4L2_ENC_CMD_STOP:
552 if (try)
553 return 0;
554 res = hdpvr_stop_streaming(dev);
555 break;
556 default:
557 v4l2_dbg(MSG_INFO, hdpvr_debug, dev->video_dev,
558 "Unsupported encoder cmd %d\n", enc->cmd);
559 return -EINVAL;
560 }
561 break;
562 }
563 default:
564 res = video_ioctl2(filp, cmd, arg);
565 }
566 mutex_unlock(&dev->io_mutex);
567 return res;
568}
569
570static const struct v4l2_file_operations hdpvr_fops = { 527static const struct v4l2_file_operations hdpvr_fops = {
571 .owner = THIS_MODULE, 528 .owner = THIS_MODULE,
572 .open = hdpvr_open, 529 .open = hdpvr_open,
573 .release = hdpvr_release, 530 .release = hdpvr_release,
574 .read = hdpvr_read, 531 .read = hdpvr_read,
575 .poll = hdpvr_poll, 532 .poll = hdpvr_poll,
576 .unlocked_ioctl = hdpvr_ioctl, 533 .unlocked_ioctl = video_ioctl2,
577}; 534};
578 535
579/*=======================================================================*/ 536/*=======================================================================*/
@@ -1163,6 +1120,44 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *private_data,
1163 return 0; 1120 return 0;
1164} 1121}
1165 1122
1123static int vidioc_encoder_cmd(struct file *filp, void *priv,
1124 struct v4l2_encoder_cmd *a)
1125{
1126 struct hdpvr_fh *fh = filp->private_data;
1127 struct hdpvr_device *dev = fh->dev;
1128 int res;
1129
1130 mutex_lock(&dev->io_mutex);
1131
1132 memset(&a->raw, 0, sizeof(a->raw));
1133 switch (a->cmd) {
1134 case V4L2_ENC_CMD_START:
1135 a->flags = 0;
1136 res = hdpvr_start_streaming(dev);
1137 break;
1138 case V4L2_ENC_CMD_STOP:
1139 res = hdpvr_stop_streaming(dev);
1140 break;
1141 default:
1142 v4l2_dbg(MSG_INFO, hdpvr_debug, dev->video_dev,
1143 "Unsupported encoder cmd %d\n", a->cmd);
1144 return -EINVAL;
1145 }
1146 mutex_unlock(&dev->io_mutex);
1147 return res;
1148}
1149
1150static int vidioc_try_encoder_cmd(struct file *filp, void *priv,
1151 struct v4l2_encoder_cmd *a)
1152{
1153 switch (a->cmd) {
1154 case V4L2_ENC_CMD_START:
1155 case V4L2_ENC_CMD_STOP:
1156 return 0;
1157 default:
1158 return -EINVAL;
1159 }
1160}
1166 1161
1167static const struct v4l2_ioctl_ops hdpvr_ioctl_ops = { 1162static const struct v4l2_ioctl_ops hdpvr_ioctl_ops = {
1168 .vidioc_querycap = vidioc_querycap, 1163 .vidioc_querycap = vidioc_querycap,
@@ -1181,6 +1176,8 @@ static const struct v4l2_ioctl_ops hdpvr_ioctl_ops = {
1181 .vidioc_try_ext_ctrls = vidioc_try_ext_ctrls, 1176 .vidioc_try_ext_ctrls = vidioc_try_ext_ctrls,
1182 .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap, 1177 .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap,
1183 .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap, 1178 .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap,
1179 .vidioc_encoder_cmd = vidioc_encoder_cmd,
1180 .vidioc_try_encoder_cmd = vidioc_try_encoder_cmd,
1184}; 1181};
1185 1182
1186static void hdpvr_device_release(struct video_device *vdev) 1183static void hdpvr_device_release(struct video_device *vdev)