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

Commit 305519c9 authored by Douglas Schilling Landgraf's avatar Douglas Schilling Landgraf Committed by Mauro Carvalho Chehab
Browse files

V4L/DVB (8120): cx23885-417: Replace cx23885_do_ioctl to use video_ioctl2



Convert cx23885-417 to use video_ioctl2

Signed-off-by: default avatarDouglas Schilling Landgraf <dougsland@gmail.com>
Signed-off-by: default avatarMichael Krufky <mkrufky@linuxtv.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 9c7ecaf5
Loading
Loading
Loading
Loading
+375 −324
Original line number Diff line number Diff line
@@ -1176,40 +1176,10 @@ static int cx23885_querymenu(struct cx23885_dev *dev,
		cx2341x_ctrl_get_menu(&dev->mpeg_params, qmenu->id));
}

int cx23885_do_ioctl(struct inode *inode, struct file *file, int radio,
	struct cx23885_dev *dev, unsigned int cmd, void *arg,
	v4l2_kioctl driver_ioctl)
static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *id)
{
	int err;

	switch (cmd) {
	/* ---------- tv norms ---------- */
	case VIDIOC_ENUMSTD:
	{
		struct v4l2_standard *e = arg;
		unsigned int i;

		i = e->index;
		if (i >= ARRAY_SIZE(cx23885_tvnorms))
			return -EINVAL;
		err = v4l2_video_std_construct(e,
			cx23885_tvnorms[e->index].id,
			cx23885_tvnorms[e->index].name);
		e->index = i;
		if (err < 0)
			return err;
		return 0;
	}
	case VIDIOC_G_STD:
	{
		v4l2_std_id *id = arg;

		*id = dev->encodernorm.id;
		return 0;
	}
	case VIDIOC_S_STD:
	{
		v4l2_std_id *id = arg;
	struct cx23885_fh  *fh  = file->private_data;
	struct cx23885_dev *dev = fh->dev;
	unsigned int i;

	for (i = 0; i < ARRAY_SIZE(cx23885_tvnorms); i++)
@@ -1218,28 +1188,34 @@ int cx23885_do_ioctl(struct inode *inode, struct file *file, int radio,
	if (i == ARRAY_SIZE(cx23885_tvnorms))
		return -EINVAL;
	dev->encodernorm = cx23885_tvnorms[i];

	return 0;
}

	/* ------ input switching ---------- */
	case VIDIOC_ENUMINPUT:
static int vidioc_enum_input(struct file *file, void *priv,
				struct v4l2_input *i)
{
	struct cx23885_fh  *fh  = file->private_data;
	struct cx23885_dev *dev = fh->dev;
	struct cx23885_input *input;
		struct v4l2_input *i = arg;
	unsigned int n;

	n = i->index;

	if (n >= 4)
		return -EINVAL;

	input = &cx23885_boards[dev->board].input[n];

	if (input->type == 0)
		return -EINVAL;

	memset(i, 0, sizeof(*i));
	i->index = n;

	/* FIXME
	 * strcpy(i->name, input->name); */
	strcpy(i->name, "unset");

	if (input->type == CX23885_VMUX_TELEVISION ||
	    input->type == CX23885_VMUX_CABLE)
		i->type = V4L2_INPUT_TYPE_TUNER;
@@ -1250,27 +1226,29 @@ int cx23885_do_ioctl(struct inode *inode, struct file *file, int radio,
		i->std |= cx23885_tvnorms[n].id;
	return 0;
}
	case VIDIOC_G_INPUT:

static int vidioc_g_input(struct file *file, void *priv, unsigned int *i)
{
		unsigned int *i = arg;
	struct cx23885_fh  *fh  = file->private_data;
	struct cx23885_dev *dev = fh->dev;

	*i = dev->input;
	return 0;
}
	case VIDIOC_S_INPUT:
	{
		unsigned int *i = arg;

		if (*i >= 4)
static int vidioc_s_input(struct file *file, void *priv, unsigned int i)
{
	if (i >= 4)
		return -EINVAL;

	return 0;
}

	/* --- tuner ioctls ------------------------------------------ */
	case VIDIOC_G_TUNER:
static int vidioc_g_tuner(struct file *file, void *priv,
				struct v4l2_tuner *t)
{
		struct v4l2_tuner *t = arg;
	struct cx23885_fh  *fh  = file->private_data;
	struct cx23885_dev *dev = fh->dev;

	if (UNSET == dev->tuner_type)
		return -EINVAL;
@@ -1285,9 +1263,12 @@ int cx23885_do_ioctl(struct inode *inode, struct file *file, int radio,

	return 0;
}
	case VIDIOC_S_TUNER:

static int vidioc_s_tuner(struct file *file, void *priv,
				struct v4l2_tuner *t)
{
		struct v4l2_tuner *t = arg;
	struct cx23885_fh  *fh  = file->private_data;
	struct cx23885_dev *dev = fh->dev;

	if (UNSET == dev->tuner_type)
		return -EINVAL;
@@ -1297,9 +1278,12 @@ int cx23885_do_ioctl(struct inode *inode, struct file *file, int radio,

	return 0;
}
	case VIDIOC_G_FREQUENCY:

static int vidioc_g_frequency(struct file *file, void *priv,
				struct v4l2_frequency *f)
{
		struct v4l2_frequency *f = arg;
	struct cx23885_fh  *fh  = file->private_data;
	struct cx23885_dev *dev = fh->dev;

	memset(f, 0, sizeof(*f));
	if (UNSET == dev->tuner_type)
@@ -1308,14 +1292,20 @@ int cx23885_do_ioctl(struct inode *inode, struct file *file, int radio,
	f->frequency = dev->freq;

	/* Assumption that tuner is always on bus 1 */
		cx23885_call_i2c_clients(&dev->i2c_bus[1],
			VIDIOC_G_FREQUENCY, f);
	cx23885_call_i2c_clients(&dev->i2c_bus[1], VIDIOC_G_FREQUENCY, f);

	return 0;
}
	case VIDIOC_S_FREQUENCY:

static int vidioc_s_frequency(struct file *file, void *priv,
				struct v4l2_frequency *f)
{
		struct v4l2_frequency *f = arg;
	struct cx23885_fh  *fh  = file->private_data;
	struct cx23885_dev *dev = fh->dev;

	cx23885_api_cmd(fh->dev, CX2341X_ENC_STOP_CAPTURE, 3, 0,
		CX23885_END_NOW, CX23885_MPEG_CAPTURE,
		CX23885_RAW_BITS_NONE);

	dprintk(1, "VIDIOC_S_FREQUENCY: dev type %d, f\n",
		dev->tuner_type);
@@ -1330,43 +1320,31 @@ int cx23885_do_ioctl(struct inode *inode, struct file *file, int radio,
	dev->freq = f->frequency;

	/* Assumption that tuner is always on bus 1 */
		cx23885_call_i2c_clients(&dev->i2c_bus[1],
			VIDIOC_S_FREQUENCY, f);
	cx23885_call_i2c_clients(&dev->i2c_bus[1], VIDIOC_S_FREQUENCY, f);

	cx23885_initialize_codec(dev);

	return 0;
}
	case VIDIOC_S_CTRL:

static int vidioc_s_ctrl(struct file *file, void *priv,
				struct v4l2_control *ctl)
{
		/* Update the A/V core */
		cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_S_CTRL, arg);
		return 0;
	}
	default:
		/* Convert V4L ioctl to V4L2 and call mpeg_do_ioctl
		 * (driver_ioctl) */
		return v4l_compat_translate_ioctl(inode, file, cmd, arg,
						  driver_ioctl);
	}
	struct cx23885_fh  *fh  = file->private_data;
	struct cx23885_dev *dev = fh->dev;

	/* Update the A/V core */
	cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_S_CTRL, ctl);
	return 0;
}

static int mpeg_do_ioctl(struct inode *inode, struct file *file,
			 unsigned int cmd, void *arg)
static int vidioc_querycap(struct file *file, void  *priv,
				struct v4l2_capability *cap)
{
	struct cx23885_fh  *fh  = file->private_data;
	struct cx23885_dev *dev = fh->dev;
	struct cx23885_tsport  *tsport = &dev->ts1;

	if (v4l_debug > 1)
		v4l_print_ioctl(dev->name, cmd);

	switch (cmd) {

	/* --- capabilities ------------------------------------------ */
	case VIDIOC_QUERYCAP:
	{
		struct v4l2_capability *cap = arg;

	memset(cap, 0, sizeof(*cap));
	strcpy(cap->driver, dev->name);
	strlcpy(cap->card, cx23885_boards[tsport->dev->board].name,
@@ -1384,10 +1362,9 @@ static int mpeg_do_ioctl(struct inode *inode, struct file *file,
	return 0;
}

	/* --- capture ioctls ---------------------------------------- */
	case VIDIOC_ENUM_FMT:
static int vidioc_enum_fmt_vid_cap(struct file *file, void  *priv,
					struct v4l2_fmtdesc *f)
{
		struct v4l2_fmtdesc *f = arg;
	int index;

	index = f->index;
@@ -1399,11 +1376,15 @@ static int mpeg_do_ioctl(struct inode *inode, struct file *file,
	strlcpy(f->description, "MPEG", sizeof(f->description));
	f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
	f->pixelformat = V4L2_PIX_FMT_MPEG;

	return 0;
}
	case VIDIOC_G_FMT:

static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
				struct v4l2_format *f)
{
		struct v4l2_format *f = arg;
	struct cx23885_fh  *fh  = file->private_data;
	struct cx23885_dev *dev = fh->dev;

	memset(f, 0, sizeof(*f));
	f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
@@ -1419,9 +1400,12 @@ static int mpeg_do_ioctl(struct inode *inode, struct file *file,
		dev->ts1.width, dev->ts1.height, fh->mpegq.field);
	return 0;
}
	case VIDIOC_TRY_FMT:

static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
				struct v4l2_format *f)
{
		struct v4l2_format *f = arg;
	struct cx23885_fh  *fh  = file->private_data;
	struct cx23885_dev *dev = fh->dev;

	f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
	f->fmt.pix.pixelformat  = V4L2_PIX_FMT_MPEG;
@@ -1434,9 +1418,12 @@ static int mpeg_do_ioctl(struct inode *inode, struct file *file,
		dev->ts1.width, dev->ts1.height, fh->mpegq.field);
	return 0;
}
	case VIDIOC_S_FMT:

static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
				struct v4l2_format *f)
{
		struct v4l2_format *f = arg;
	struct cx23885_fh  *fh  = file->private_data;
	struct cx23885_dev *dev = fh->dev;

	f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
	f->fmt.pix.pixelformat  = V4L2_PIX_FMT_MPEG;
@@ -1449,65 +1436,106 @@ static int mpeg_do_ioctl(struct inode *inode, struct file *file,
	return 0;
}

	/* --- streaming capture ------------------------------------- */
	case VIDIOC_REQBUFS:
		return videobuf_reqbufs(&fh->mpegq, arg);
static int vidioc_reqbufs(struct file *file, void *priv,
				struct v4l2_requestbuffers *p)
{
	struct cx23885_fh  *fh  = file->private_data;

	case VIDIOC_QUERYBUF:
		return videobuf_querybuf(&fh->mpegq, arg);
	return videobuf_reqbufs(&fh->mpegq, p);
}

	case VIDIOC_QBUF:
		return videobuf_qbuf(&fh->mpegq, arg);
static int vidioc_querybuf(struct file *file, void *priv,
				struct v4l2_buffer *p)
{
	struct cx23885_fh  *fh  = file->private_data;

	case VIDIOC_DQBUF:
		return videobuf_dqbuf(&fh->mpegq, arg,
				      file->f_flags & O_NONBLOCK);
	return videobuf_querybuf(&fh->mpegq, p);
}

static int vidioc_qbuf(struct file *file, void *priv,
				struct v4l2_buffer *p)
{
	struct cx23885_fh  *fh  = file->private_data;

	return videobuf_qbuf(&fh->mpegq, p);
}

static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *b)
{
	struct cx23885_fh  *fh  = priv;

	return videobuf_dqbuf(&fh->mpegq, b, file->f_flags & O_NONBLOCK);
}


static int vidioc_streamon(struct file *file, void *priv,
				enum v4l2_buf_type i)
{
	struct cx23885_fh  *fh  = file->private_data;

	case VIDIOC_STREAMON:
	return videobuf_streamon(&fh->mpegq);
}

static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
{
	struct cx23885_fh  *fh  = file->private_data;

	case VIDIOC_STREAMOFF:
	return videobuf_streamoff(&fh->mpegq);
}

	case VIDIOC_G_EXT_CTRLS:
static int vidioc_g_ext_ctrls(struct file *file, void *priv,
				struct v4l2_ext_controls *f)
{
		struct v4l2_ext_controls *f = arg;
	struct cx23885_fh  *fh  = priv;
	struct cx23885_dev *dev = fh->dev;

	if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG)
		return -EINVAL;
		return cx2341x_ext_ctrls(&dev->mpeg_params, 0, f, cmd);
	return cx2341x_ext_ctrls(&dev->mpeg_params, 0, f, VIDIOC_G_EXT_CTRLS);
}
	case VIDIOC_S_EXT_CTRLS:
	case VIDIOC_TRY_EXT_CTRLS:

static int vidioc_s_ext_ctrls(struct file *file, void *priv,
				struct v4l2_ext_controls *f)
{
		struct v4l2_ext_controls *f = arg;
	struct cx23885_fh  *fh  = priv;
	struct cx23885_dev *dev = fh->dev;
	struct cx2341x_mpeg_params p;
	int err;

	if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG)
		return -EINVAL;

	p = dev->mpeg_params;
		err = cx2341x_ext_ctrls(&p, 0, f, cmd);
		if (err == 0 && cmd == VIDIOC_S_EXT_CTRLS) {
	err = cx2341x_ext_ctrls(&p, 0, f, VIDIOC_S_EXT_CTRLS);

	if (err == 0) {
		err = cx2341x_update(dev, cx23885_mbox_func,
			&dev->mpeg_params, &p);
		dev->mpeg_params = p;
	}
	return err;
}
	case VIDIOC_S_FREQUENCY:

static int vidioc_try_ext_ctrls(struct file *file, void *priv,
				struct v4l2_ext_controls *f)
{
		cx23885_api_cmd(fh->dev, CX2341X_ENC_STOP_CAPTURE, 3, 0,
			CX23885_END_NOW, CX23885_MPEG_CAPTURE,
			CX23885_RAW_BITS_NONE);
		cx23885_do_ioctl(inode, file, 0, dev, cmd, arg,
			mpeg_do_ioctl);
		cx23885_initialize_codec(dev);
	struct cx23885_fh  *fh  = priv;
	struct cx23885_dev *dev = fh->dev;
	struct cx2341x_mpeg_params p;
	int err;

		return 0;
	if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG)
		return -EINVAL;

	p = dev->mpeg_params;
	err = cx2341x_ext_ctrls(&p, 0, f, VIDIOC_TRY_EXT_CTRLS);
	return err;
}
	case VIDIOC_LOG_STATUS:

static int vidioc_log_status(struct file *file, void *priv)
{
	struct cx23885_fh  *fh  = priv;
	struct cx23885_dev *dev = fh->dev;
	char name[32 + 2];

	snprintf(name, sizeof(name), "%s/2", dev->name);
@@ -1526,26 +1554,23 @@ static int mpeg_do_ioctl(struct inode *inode, struct file *file,
	       dev->name);
	return 0;
}
	case VIDIOC_QUERYMENU:
		return cx23885_querymenu(dev, arg);
	case VIDIOC_QUERYCTRL:
	{
		struct v4l2_queryctrl *c = arg;

		return cx23885_queryctrl(dev, c);
	}
static int vidioc_querymenu(struct file *file, void *priv,
				struct v4l2_querymenu *a)
{
	struct cx23885_fh  *fh  = priv;
	struct cx23885_dev *dev = fh->dev;

	default:
		return cx23885_do_ioctl(inode, file, 0, dev, cmd, arg,
				mpeg_do_ioctl);
	}
	return 0;
	return cx23885_querymenu(dev, a);
}

static int mpeg_ioctl(struct inode *inode, struct file *file,
			unsigned int cmd, unsigned long arg)
static int vidioc_queryctrl(struct file *file, void *priv,
				struct v4l2_queryctrl *c)
{
	return video_usercopy(inode, file, cmd, arg, mpeg_do_ioctl);
	struct cx23885_fh  *fh  = priv;
	struct cx23885_dev *dev = fh->dev;

	return cx23885_queryctrl(dev, c);
}

static int mpeg_open(struct inode *inode, struct file *file)
@@ -1670,7 +1695,7 @@ static struct file_operations mpeg_fops = {
	.read	       = mpeg_read,
	.poll          = mpeg_poll,
	.mmap	       = mpeg_mmap,
	.ioctl	       = mpeg_ioctl,
	.ioctl	       = video_ioctl2,
	.llseek        = no_llseek,
};

@@ -1682,6 +1707,32 @@ static struct video_device cx23885_mpeg_template = {
				VID_TYPE_MPEG_ENCODER,
	.fops          = &mpeg_fops,
	.minor         = -1,
	.vidioc_s_std		 = vidioc_s_std,
	.vidioc_enum_input	 = vidioc_enum_input,
	.vidioc_g_input		 = vidioc_g_input,
	.vidioc_s_input		 = vidioc_s_input,
	.vidioc_g_tuner		 = vidioc_g_tuner,
	.vidioc_s_tuner		 = vidioc_s_tuner,
	.vidioc_g_frequency	 = vidioc_g_frequency,
	.vidioc_s_frequency	 = vidioc_s_frequency,
	.vidioc_s_ctrl		 = vidioc_s_ctrl,
	.vidioc_querycap	 = vidioc_querycap,
	.vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap,
	.vidioc_g_fmt_vid_cap	 = vidioc_g_fmt_vid_cap,
	.vidioc_try_fmt_vid_cap	 = vidioc_try_fmt_vid_cap,
	.vidioc_s_fmt_vid_cap	 = vidioc_s_fmt_vid_cap,
	.vidioc_reqbufs		 = vidioc_reqbufs,
	.vidioc_querybuf	 = vidioc_querybuf,
	.vidioc_qbuf		 = vidioc_qbuf,
	.vidioc_dqbuf		 = vidioc_dqbuf,
	.vidioc_streamon	 = vidioc_streamon,
	.vidioc_streamoff	 = vidioc_streamoff,
	.vidioc_g_ext_ctrls	 = vidioc_g_ext_ctrls,
	.vidioc_s_ext_ctrls	 = vidioc_s_ext_ctrls,
	.vidioc_try_ext_ctrls	 = vidioc_try_ext_ctrls,
	.vidioc_log_status	 = vidioc_log_status,
	.vidioc_querymenu	 = vidioc_querymenu,
	.vidioc_queryctrl	 = vidioc_queryctrl,
};

void cx23885_417_unregister(struct cx23885_dev *dev)