Преглед на файлове

V4L/DVB (8082): cx18: convert to video_ioctl2()

cx18: convert driver to use video_ioctl2().  Pushed down ioctl debug
messages and priority checks as well.  Still left serialization lock in
place for now.  #if 0'ed out sliced vbi ioctl code for now.

Patch heavily based on similar changes made to ivtv by Hans Verkuil.

Signed-off-by: Andy Walls <awalls@radix.net>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Andy Walls преди 17 години
родител
ревизия
3b6fe58f0f

+ 97 - 98
drivers/media/video/cx18/cx18-controls.c

@@ -51,8 +51,9 @@ static const u32 *ctrl_classes[] = {
 	NULL
 };
 
-static int cx18_queryctrl(struct cx18 *cx, struct v4l2_queryctrl *qctrl)
+int cx18_queryctrl(struct file *file, void *fh, struct v4l2_queryctrl *qctrl)
 {
+	struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
 	const char *name;
 
 	CX18_DEBUG_IOCTL("VIDIOC_QUERYCTRL(%08x)\n", qctrl->id);
@@ -91,19 +92,28 @@ static int cx18_queryctrl(struct cx18 *cx, struct v4l2_queryctrl *qctrl)
 	return 0;
 }
 
-static int cx18_querymenu(struct cx18 *cx, struct v4l2_querymenu *qmenu)
+int cx18_querymenu(struct file *file, void *fh, struct v4l2_querymenu *qmenu)
 {
+	struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
 	struct v4l2_queryctrl qctrl;
 
+	CX18_DEBUG_IOCTL("VIDIOC_QUERYMENU\n");
 	qctrl.id = qmenu->id;
-	cx18_queryctrl(cx, &qctrl);
+	cx18_queryctrl(file, fh, &qctrl);
 	return v4l2_ctrl_query_menu(qmenu, &qctrl, cx2341x_ctrl_get_menu(qmenu->id));
 }
 
-static int cx18_s_ctrl(struct cx18 *cx, struct v4l2_control *vctrl)
+int cx18_s_ctrl(struct file *file, void *fh, struct v4l2_control *vctrl)
 {
+	struct cx18_open_id *id = fh;
+	struct cx18 *cx = id->cx;
+	int ret;
 	s32 v = vctrl->value;
 
+	ret = v4l2_prio_check(&cx->prio, &id->prio);
+	if (ret)
+		return ret;
+
 	CX18_DEBUG_IOCTL("VIDIOC_S_CTRL(%08x, %x)\n", vctrl->id, v);
 
 	switch (vctrl->id) {
@@ -129,8 +139,10 @@ static int cx18_s_ctrl(struct cx18 *cx, struct v4l2_control *vctrl)
 	return 0;
 }
 
-static int cx18_g_ctrl(struct cx18 *cx, struct v4l2_control *vctrl)
+int cx18_g_ctrl(struct file *file, void *fh, struct v4l2_control *vctrl)
 {
+	struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
+
 	CX18_DEBUG_IOCTL("VIDIOC_G_CTRL(%08x)\n", vctrl->id);
 
 	switch (vctrl->id) {
@@ -194,113 +206,100 @@ static int cx18_setup_vbi_fmt(struct cx18 *cx, enum v4l2_mpeg_stream_vbi_fmt fmt
 	return 0;
 }
 
-int cx18_control_ioctls(struct cx18 *cx, unsigned int cmd, void *arg)
+int cx18_g_ext_ctrls(struct file *file, void *fh, struct v4l2_ext_controls *c)
 {
+	struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
 	struct v4l2_control ctrl;
 
-	switch (cmd) {
-	case VIDIOC_QUERYMENU:
-		CX18_DEBUG_IOCTL("VIDIOC_QUERYMENU\n");
-		return cx18_querymenu(cx, arg);
-
-	case VIDIOC_QUERYCTRL:
-		return cx18_queryctrl(cx, arg);
-
-	case VIDIOC_S_CTRL:
-		return cx18_s_ctrl(cx, arg);
-
-	case VIDIOC_G_CTRL:
-		return cx18_g_ctrl(cx, arg);
-
-	case VIDIOC_S_EXT_CTRLS:
-	{
-		struct v4l2_ext_controls *c = arg;
-
-		if (c->ctrl_class == V4L2_CTRL_CLASS_USER) {
-			int i;
-			int err = 0;
-
-			for (i = 0; i < c->count; i++) {
-				ctrl.id = c->controls[i].id;
-				ctrl.value = c->controls[i].value;
-				err = cx18_s_ctrl(cx, &ctrl);
-				c->controls[i].value = ctrl.value;
-				if (err) {
-					c->error_idx = i;
-					break;
-				}
+	if (c->ctrl_class == V4L2_CTRL_CLASS_USER) {
+		int i;
+		int err = 0;
+
+		for (i = 0; i < c->count; i++) {
+			ctrl.id = c->controls[i].id;
+			ctrl.value = c->controls[i].value;
+			err = cx18_g_ctrl(file, fh, &ctrl);
+			c->controls[i].value = ctrl.value;
+			if (err) {
+				c->error_idx = i;
+				break;
 			}
-			return err;
 		}
-		CX18_DEBUG_IOCTL("VIDIOC_S_EXT_CTRLS\n");
-		if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG) {
-			struct cx2341x_mpeg_params p = cx->params;
-			int err = cx2341x_ext_ctrls(&p, atomic_read(&cx->ana_capturing), arg, cmd);
+		return err;
+	}
+	CX18_DEBUG_IOCTL("VIDIOC_G_EXT_CTRLS\n");
+	if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG)
+		return cx2341x_ext_ctrls(&cx->params, 0, c, VIDIOC_G_EXT_CTRLS);
+	return -EINVAL;
+}
 
-			if (err)
-				return err;
+int cx18_s_ext_ctrls(struct file *file, void *fh, struct v4l2_ext_controls *c)
+{
+	struct cx18_open_id *id = fh;
+	struct cx18 *cx = id->cx;
+	int ret;
+	struct v4l2_control ctrl;
 
-			if (p.video_encoding != cx->params.video_encoding) {
-				int is_mpeg1 = p.video_encoding ==
-						V4L2_MPEG_VIDEO_ENCODING_MPEG_1;
-				struct v4l2_format fmt;
+	ret = v4l2_prio_check(&cx->prio, &id->prio);
+	if (ret)
+		return ret;
 
-				/* fix videodecoder resolution */
-				fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-				fmt.fmt.pix.width = cx->params.width / (is_mpeg1 ? 2 : 1);
-				fmt.fmt.pix.height = cx->params.height;
-				cx18_av_cmd(cx, VIDIOC_S_FMT, &fmt);
+	if (c->ctrl_class == V4L2_CTRL_CLASS_USER) {
+		int i;
+		int err = 0;
+
+		for (i = 0; i < c->count; i++) {
+			ctrl.id = c->controls[i].id;
+			ctrl.value = c->controls[i].value;
+			err = cx18_s_ctrl(file, fh, &ctrl);
+			c->controls[i].value = ctrl.value;
+			if (err) {
+				c->error_idx = i;
+				break;
 			}
-			err = cx2341x_update(cx, cx18_api_func, &cx->params, &p);
-			if (!err && cx->params.stream_vbi_fmt != p.stream_vbi_fmt)
-				err = cx18_setup_vbi_fmt(cx, p.stream_vbi_fmt);
-			cx->params = p;
-			cx->dualwatch_stereo_mode = p.audio_properties & 0x0300;
-			cx18_audio_set_audio_clock_freq(cx, p.audio_properties & 0x03);
-			return err;
 		}
-		return -EINVAL;
+		return err;
 	}
+	CX18_DEBUG_IOCTL("VIDIOC_S_EXT_CTRLS\n");
+	if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG) {
+		struct cx2341x_mpeg_params p = cx->params;
+		int err = cx2341x_ext_ctrls(&p, atomic_read(&cx->ana_capturing),
+						c, VIDIOC_S_EXT_CTRLS);
 
-	case VIDIOC_G_EXT_CTRLS:
-	{
-		struct v4l2_ext_controls *c = arg;
-
-		if (c->ctrl_class == V4L2_CTRL_CLASS_USER) {
-			int i;
-			int err = 0;
-
-			for (i = 0; i < c->count; i++) {
-				ctrl.id = c->controls[i].id;
-				ctrl.value = c->controls[i].value;
-				err = cx18_g_ctrl(cx, &ctrl);
-				c->controls[i].value = ctrl.value;
-				if (err) {
-					c->error_idx = i;
-					break;
-				}
-			}
+		if (err)
 			return err;
-		}
-		CX18_DEBUG_IOCTL("VIDIOC_G_EXT_CTRLS\n");
-		if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG)
-			return cx2341x_ext_ctrls(&cx->params, 0, arg, cmd);
-		return -EINVAL;
-	}
 
-	case VIDIOC_TRY_EXT_CTRLS:
-	{
-		struct v4l2_ext_controls *c = arg;
-
-		CX18_DEBUG_IOCTL("VIDIOC_TRY_EXT_CTRLS\n");
-		if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG)
-			return cx2341x_ext_ctrls(&cx->params,
-					atomic_read(&cx->ana_capturing), arg, cmd);
-		return -EINVAL;
+		if (p.video_encoding != cx->params.video_encoding) {
+			int is_mpeg1 = p.video_encoding ==
+						V4L2_MPEG_VIDEO_ENCODING_MPEG_1;
+			struct v4l2_format fmt;
+
+			/* fix videodecoder resolution */
+			fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+			fmt.fmt.pix.width = cx->params.width
+						/ (is_mpeg1 ? 2 : 1);
+			fmt.fmt.pix.height = cx->params.height;
+			cx18_av_cmd(cx, VIDIOC_S_FMT, &fmt);
+		}
+		err = cx2341x_update(cx, cx18_api_func, &cx->params, &p);
+		if (!err && cx->params.stream_vbi_fmt != p.stream_vbi_fmt)
+			err = cx18_setup_vbi_fmt(cx, p.stream_vbi_fmt);
+		cx->params = p;
+		cx->dualwatch_stereo_mode = p.audio_properties & 0x0300;
+		cx18_audio_set_audio_clock_freq(cx, p.audio_properties & 0x03);
+		return err;
 	}
+	return -EINVAL;
+}
 
-	default:
-		return -EINVAL;
-	}
-	return 0;
+int cx18_try_ext_ctrls(struct file *file, void *fh, struct v4l2_ext_controls *c)
+{
+	struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
+
+	CX18_DEBUG_IOCTL("VIDIOC_TRY_EXT_CTRLS\n");
+	if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG)
+		return cx2341x_ext_ctrls(&cx->params,
+						atomic_read(&cx->ana_capturing),
+						c, VIDIOC_TRY_EXT_CTRLS);
+	return -EINVAL;
 }

+ 8 - 1
drivers/media/video/cx18/cx18-controls.h

@@ -21,4 +21,11 @@
  *  02111-1307  USA
  */
 
-int cx18_control_ioctls(struct cx18 *cx, unsigned int cmd, void *arg);
+int cx18_queryctrl(struct file *file, void *fh, struct v4l2_queryctrl *a);
+int cx18_g_ctrl(struct file *file, void *fh, struct v4l2_control *a);
+int cx18_s_ctrl(struct file *file, void *fh, struct v4l2_control *a);
+int cx18_g_ext_ctrls(struct file *file, void *fh, struct v4l2_ext_controls *a);
+int cx18_s_ext_ctrls(struct file *file, void *fh, struct v4l2_ext_controls *a);
+int cx18_try_ext_ctrls(struct file *file, void *fh,
+			struct v4l2_ext_controls *a);
+int cx18_querymenu(struct file *file, void *fh, struct v4l2_querymenu *a);

+ 6 - 3
drivers/media/video/cx18/cx18-driver.c

@@ -818,6 +818,9 @@ int cx18_init_on_first_open(struct cx18 *cx)
 	int video_input;
 	int fw_retry_count = 3;
 	struct v4l2_frequency vf;
+	struct cx18_open_id fh;
+
+	fh.cx = cx;
 
 	if (test_bit(CX18_F_I_FAILED, &cx->i_flags))
 		return -ENXIO;
@@ -869,13 +872,13 @@ int cx18_init_on_first_open(struct cx18 *cx)
 
 	video_input = cx->active_input;
 	cx->active_input++;	/* Force update of input */
-	cx18_v4l2_ioctls(cx, NULL, VIDIOC_S_INPUT, &video_input);
+	cx18_s_input(NULL, &fh, video_input);
 
 	/* Let the VIDIOC_S_STD ioctl do all the work, keeps the code
 	   in one place. */
 	cx->std++;		/* Force full standard initialization */
-	cx18_v4l2_ioctls(cx, NULL, VIDIOC_S_STD, &cx->tuner_std);
-	cx18_v4l2_ioctls(cx, NULL, VIDIOC_S_FREQUENCY, &vf);
+	cx18_s_std(NULL, &fh, &cx->tuner_std);
+	cx18_s_frequency(NULL, &fh, &vf);
 	return 0;
 }
 

Файловите разлики са ограничени, защото са твърде много
+ 578 - 583
drivers/media/video/cx18/cx18-ioctl.c


+ 4 - 2
drivers/media/video/cx18/cx18-ioctl.h

@@ -24,7 +24,9 @@
 u16 cx18_service2vbi(int type);
 void cx18_expand_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal);
 u16 cx18_get_service_set(struct v4l2_sliced_vbi_format *fmt);
+void cx18_set_funcs(struct video_device *vdev);
+int cx18_s_std(struct file *file, void *fh, v4l2_std_id *std);
+int cx18_s_frequency(struct file *file, void *fh, struct v4l2_frequency *vf);
+int cx18_s_input(struct file *file, void *fh, unsigned int inp);
 int cx18_v4l2_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
 		    unsigned long arg);
-int cx18_v4l2_ioctls(struct cx18 *cx, struct file *filp, unsigned cmd,
-		     void *arg);

+ 3 - 1
drivers/media/video/cx18/cx18-streams.c

@@ -39,6 +39,7 @@ static struct file_operations cx18_v4l2_enc_fops = {
 	.owner = THIS_MODULE,
 	.read = cx18_v4l2_read,
 	.open = cx18_v4l2_open,
+	/* FIXME change to video_ioctl2 if serialization lock can be removed */
 	.ioctl = cx18_v4l2_ioctl,
 	.compat_ioctl = v4l_compat_ioctl32,
 	.release = cx18_v4l2_close,
@@ -196,7 +197,8 @@ static int cx18_prep_dev(struct cx18 *cx, int type)
 	s->v4l2dev->dev = &cx->dev->dev;
 	s->v4l2dev->fops = cx18_stream_info[type].fops;
 	s->v4l2dev->release = video_device_release;
-
+	s->v4l2dev->tvnorms = V4L2_STD_ALL;
+	cx18_set_funcs(s->v4l2dev);
 	return 0;
 }
 

Някои файлове не бяха показани, защото твърде много файлове са промени