Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3b6fe58f authored by Andy Walls's avatar Andy Walls Committed by Mauro Carvalho Chehab
Browse files

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: default avatarAndy Walls <awalls@radix.net>
Signed-off-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 1a05221b
Loading
Loading
Loading
Loading
+97 −98
Original line number Diff line number Diff line
@@ -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,27 +206,43 @@ 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);
	if (c->ctrl_class == V4L2_CTRL_CLASS_USER) {
		int i;
		int err = 0;

	case VIDIOC_G_CTRL:
		return cx18_g_ctrl(cx, arg);
		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_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;
}

	case VIDIOC_S_EXT_CTRLS:
int cx18_s_ext_ctrls(struct file *file, void *fh, struct v4l2_ext_controls *c)
{
		struct v4l2_ext_controls *c = arg;
	struct cx18_open_id *id = fh;
	struct cx18 *cx = id->cx;
	int ret;
	struct v4l2_control ctrl;

	ret = v4l2_prio_check(&cx->prio, &id->prio);
	if (ret)
		return ret;

	if (c->ctrl_class == V4L2_CTRL_CLASS_USER) {
		int i;
@@ -223,7 +251,7 @@ int cx18_control_ioctls(struct cx18 *cx, unsigned int cmd, void *arg)
		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);
			err = cx18_s_ctrl(file, fh, &ctrl);
			c->controls[i].value = ctrl.value;
			if (err) {
				c->error_idx = i;
@@ -235,7 +263,8 @@ int cx18_control_ioctls(struct cx18 *cx, unsigned int cmd, void *arg)
	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);
		int err = cx2341x_ext_ctrls(&p, atomic_read(&cx->ana_capturing),
						c, VIDIOC_S_EXT_CTRLS);

		if (err)
			return err;
@@ -247,7 +276,8 @@ int cx18_control_ioctls(struct cx18 *cx, unsigned int cmd, void *arg)

			/* fix videodecoder resolution */
			fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
				fmt.fmt.pix.width = cx->params.width / (is_mpeg1 ? 2 : 1);
			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);
		}
@@ -262,45 +292,14 @@ int cx18_control_ioctls(struct cx18 *cx, unsigned int cmd, void *arg)
	return -EINVAL;
}

	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;
				}
			}
			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:
int cx18_try_ext_ctrls(struct file *file, void *fh, struct v4l2_ext_controls *c)
{
		struct v4l2_ext_controls *c = arg;
	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), arg, cmd);
						atomic_read(&cx->ana_capturing),
						c, VIDIOC_TRY_EXT_CTRLS);
	return -EINVAL;
}

	default:
		return -EINVAL;
	}
	return 0;
}
+8 −1
Original line number Diff line number Diff line
@@ -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
Original line number Diff line number Diff line
@@ -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;
}

+627 −584

File changed.

Preview size limit exceeded, changes collapsed.

+4 −2
Original line number Diff line number Diff line
@@ -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);
Loading