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

Commit 3f038d80 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab
Browse files

V4L/DVB (8079): ivtv: Convert to video_ioctl2.



Based on an initial conversion patch from Douglas Landgraf.

Signed-off-by: default avatarDouglas Schilling Landgraf <dougsland@gmail.com>
Signed-off-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 539a7555
Loading
Loading
Loading
Loading
+90 −106
Original line number Diff line number Diff line
@@ -47,8 +47,10 @@ static const u32 *ctrl_classes[] = {
	NULL
};

static int ivtv_queryctrl(struct ivtv *itv, struct v4l2_queryctrl *qctrl)

int ivtv_queryctrl(struct file *file, void *fh, struct v4l2_queryctrl *qctrl)
{
	struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
	const char *name;

	IVTV_DEBUG_IOCTL("VIDIOC_QUERYCTRL(%08x)\n", qctrl->id);
@@ -87,17 +89,20 @@ static int ivtv_queryctrl(struct ivtv *itv, struct v4l2_queryctrl *qctrl)
	return 0;
}

static int ivtv_querymenu(struct ivtv *itv, struct v4l2_querymenu *qmenu)
int ivtv_querymenu(struct file *file, void *fh, struct v4l2_querymenu *qmenu)
{
	struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
	struct v4l2_queryctrl qctrl;

	IVTV_DEBUG_IOCTL("VIDIOC_QUERYMENU\n");
	qctrl.id = qmenu->id;
	ivtv_queryctrl(itv, &qctrl);
	ivtv_queryctrl(file, fh, &qctrl);
	return v4l2_ctrl_query_menu(qmenu, &qctrl, cx2341x_ctrl_get_menu(qmenu->id));
}

static int ivtv_s_ctrl(struct ivtv *itv, struct v4l2_control *vctrl)
int ivtv_s_ctrl(struct file *file, void *fh, struct v4l2_control *vctrl)
{
	struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
	s32 v = vctrl->value;

	IVTV_DEBUG_IOCTL("VIDIOC_S_CTRL(%08x, %x)\n", vctrl->id, v);
@@ -125,8 +130,10 @@ static int ivtv_s_ctrl(struct ivtv *itv, struct v4l2_control *vctrl)
	return 0;
}

static int ivtv_g_ctrl(struct ivtv *itv, struct v4l2_control *vctrl)
int ivtv_g_ctrl(struct file *file, void *fh, struct v4l2_control *vctrl)
{
	struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;

	IVTV_DEBUG_IOCTL("VIDIOC_G_CTRL(%08x)\n", vctrl->id);

	switch (vctrl->id) {
@@ -191,27 +198,37 @@ static int ivtv_setup_vbi_fmt(struct ivtv *itv, enum v4l2_mpeg_stream_vbi_fmt fm
	return 0;
}

int ivtv_control_ioctls(struct ivtv *itv, unsigned int cmd, void *arg)
int ivtv_g_ext_ctrls(struct file *file, void *fh, struct v4l2_ext_controls *c)
{
	struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
	struct v4l2_control ctrl;

	switch (cmd) {
	case VIDIOC_QUERYMENU:
		IVTV_DEBUG_IOCTL("VIDIOC_QUERYMENU\n");
		return ivtv_querymenu(itv, arg);

	case VIDIOC_QUERYCTRL:
		return ivtv_queryctrl(itv, arg);

	case VIDIOC_S_CTRL:
		return ivtv_s_ctrl(itv, arg);
	if (c->ctrl_class == V4L2_CTRL_CLASS_USER) {
		int i;
		int err = 0;

	case VIDIOC_G_CTRL:
		return ivtv_g_ctrl(itv, arg);
		for (i = 0; i < c->count; i++) {
			ctrl.id = c->controls[i].id;
			ctrl.value = c->controls[i].value;
			err = ivtv_g_ctrl(file, fh, &ctrl);
			c->controls[i].value = ctrl.value;
			if (err) {
				c->error_idx = i;
				break;
			}
		}
		return err;
	}
	IVTV_DEBUG_IOCTL("VIDIOC_G_EXT_CTRLS\n");
	if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG)
		return cx2341x_ext_ctrls(&itv->params, 0, c, VIDIOC_G_EXT_CTRLS);
	return -EINVAL;
}

	case VIDIOC_S_EXT_CTRLS:
int ivtv_s_ext_ctrls(struct file *file, void *fh, struct v4l2_ext_controls *c)
{
		struct v4l2_ext_controls *c = arg;
	struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
	struct v4l2_control ctrl;

	if (c->ctrl_class == V4L2_CTRL_CLASS_USER) {
		int i;
@@ -220,7 +237,7 @@ int ivtv_control_ioctls(struct ivtv *itv, 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 = ivtv_s_ctrl(itv, &ctrl);
			err = ivtv_s_ctrl(file, fh, &ctrl);
			c->controls[i].value = ctrl.value;
			if (err) {
				c->error_idx = i;
@@ -233,7 +250,7 @@ int ivtv_control_ioctls(struct ivtv *itv, unsigned int cmd, void *arg)
	if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG) {
		static u32 freqs[3] = { 44100, 48000, 32000 };
		struct cx2341x_mpeg_params p = itv->params;
			int err = cx2341x_ext_ctrls(&p, atomic_read(&itv->capturing), arg, cmd);
		int err = cx2341x_ext_ctrls(&p, atomic_read(&itv->capturing), c, VIDIOC_S_EXT_CTRLS);
		unsigned idx;

		if (err)
@@ -251,9 +268,8 @@ int ivtv_control_ioctls(struct ivtv *itv, unsigned int cmd, void *arg)
			itv->video_dec_func(itv, VIDIOC_S_FMT, &fmt);
		}
		err = cx2341x_update(itv, ivtv_api_func, &itv->params, &p);
			if (!err && itv->params.stream_vbi_fmt != p.stream_vbi_fmt) {
		if (!err && itv->params.stream_vbi_fmt != p.stream_vbi_fmt)
			err = ivtv_setup_vbi_fmt(itv, p.stream_vbi_fmt);
			}
		itv->params = p;
		itv->dualwatch_stereo_mode = p.audio_properties & 0x0300;
		idx = p.audio_properties & 0x03;
@@ -266,44 +282,12 @@ int ivtv_control_ioctls(struct ivtv *itv, 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 = ivtv_g_ctrl(itv, &ctrl);
				c->controls[i].value = ctrl.value;
				if (err) {
					c->error_idx = i;
					break;
				}
			}
			return err;
		}
		IVTV_DEBUG_IOCTL("VIDIOC_G_EXT_CTRLS\n");
		if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG)
			return cx2341x_ext_ctrls(&itv->params, 0, arg, cmd);
		return -EINVAL;
	}

	case VIDIOC_TRY_EXT_CTRLS:
int ivtv_try_ext_ctrls(struct file *file, void *fh, struct v4l2_ext_controls *c)
{
		struct v4l2_ext_controls *c = arg;
	struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;

	IVTV_DEBUG_IOCTL("VIDIOC_TRY_EXT_CTRLS\n");
	if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG)
			return cx2341x_ext_ctrls(&itv->params, atomic_read(&itv->capturing), arg, cmd);
		return cx2341x_ext_ctrls(&itv->params, atomic_read(&itv->capturing), c, VIDIOC_TRY_EXT_CTRLS);
	return -EINVAL;
}

	default:
		return -EINVAL;
	}
	return 0;
}
+7 −1
Original line number Diff line number Diff line
@@ -21,6 +21,12 @@
#ifndef IVTV_CONTROLS_H
#define IVTV_CONTROLS_H

int ivtv_control_ioctls(struct ivtv *itv, unsigned int cmd, void *arg);
int ivtv_queryctrl(struct file *file, void *fh, struct v4l2_queryctrl *a);
int ivtv_g_ctrl(struct file *file, void *fh, struct v4l2_control *a);
int ivtv_s_ctrl(struct file *file, void *fh, struct v4l2_control *a);
int ivtv_g_ext_ctrls(struct file *file, void *fh, struct v4l2_ext_controls *a);
int ivtv_s_ext_ctrls(struct file *file, void *fh, struct v4l2_ext_controls *a);
int ivtv_try_ext_ctrls(struct file *file, void *fh, struct v4l2_ext_controls *a);
int ivtv_querymenu(struct file *file, void *fh, struct v4l2_querymenu *a);

#endif
+7 −3
Original line number Diff line number Diff line
@@ -1262,9 +1262,13 @@ static int __devinit ivtv_probe(struct pci_dev *dev,
int ivtv_init_on_first_open(struct ivtv *itv)
{
	struct v4l2_frequency vf;
	/* Needed to call ioctls later */
	struct ivtv_open_id fh;
	int fw_retry_count = 3;
	int video_input;

	fh.itv = itv;

	if (test_bit(IVTV_F_I_FAILED, &itv->i_flags))
		return -ENXIO;

@@ -1312,18 +1316,18 @@ int ivtv_init_on_first_open(struct ivtv *itv)

	video_input = itv->active_input;
	itv->active_input++;	/* Force update of input */
	ivtv_v4l2_ioctls(itv, NULL, VIDIOC_S_INPUT, &video_input);
	ivtv_s_input(NULL, &fh, video_input);

	/* Let the VIDIOC_S_STD ioctl do all the work, keeps the code
	   in one place. */
	itv->std++;		/* Force full standard initialization */
	itv->std_out = itv->std;
	ivtv_v4l2_ioctls(itv, NULL, VIDIOC_S_FREQUENCY, &vf);
	ivtv_s_frequency(NULL, &fh, &vf);

	if (itv->card->v4l2_capabilities & V4L2_CAP_VIDEO_OUTPUT) {
		ivtv_init_mpeg_decoder(itv);
	}
	ivtv_v4l2_ioctls(itv, NULL, VIDIOC_S_STD, &itv->tuner_std);
	ivtv_s_std(NULL, &fh, &itv->tuner_std);

	/* On a cx23416 this seems to be able to enable DMA to the chip? */
	if (!itv->has_cx23415)
Loading