Commit 1f159c77 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

[media] cx23885: drop type field from struct cx23885_fh

This information is available elsewhere as well.
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent 86961933
...@@ -692,28 +692,31 @@ static struct videobuf_queue_ops cx23885_video_qops = { ...@@ -692,28 +692,31 @@ static struct videobuf_queue_ops cx23885_video_qops = {
.buf_release = buffer_release, .buf_release = buffer_release,
}; };
static struct videobuf_queue *get_queue(struct cx23885_fh *fh) static struct videobuf_queue *get_queue(struct file *file)
{ {
switch (fh->type) { struct video_device *vdev = video_devdata(file);
case V4L2_BUF_TYPE_VIDEO_CAPTURE: struct cx23885_fh *fh = file->private_data;
switch (vdev->vfl_type) {
case VFL_TYPE_GRABBER:
return &fh->vidq; return &fh->vidq;
case V4L2_BUF_TYPE_VBI_CAPTURE: case VFL_TYPE_VBI:
return &fh->vbiq; return &fh->vbiq;
default: default:
BUG(); WARN_ON(1);
return NULL; return NULL;
} }
} }
static int get_resource(struct cx23885_fh *fh) static int get_resource(u32 type)
{ {
switch (fh->type) { switch (type) {
case V4L2_BUF_TYPE_VIDEO_CAPTURE: case V4L2_BUF_TYPE_VIDEO_CAPTURE:
return RESOURCE_VIDEO; return RESOURCE_VIDEO;
case V4L2_BUF_TYPE_VBI_CAPTURE: case V4L2_BUF_TYPE_VBI_CAPTURE:
return RESOURCE_VBI; return RESOURCE_VBI;
default: default:
BUG(); WARN_ON(1);
return 0; return 0;
} }
} }
...@@ -723,19 +726,9 @@ static int video_open(struct file *file) ...@@ -723,19 +726,9 @@ static int video_open(struct file *file)
struct video_device *vdev = video_devdata(file); struct video_device *vdev = video_devdata(file);
struct cx23885_dev *dev = video_drvdata(file); struct cx23885_dev *dev = video_drvdata(file);
struct cx23885_fh *fh; struct cx23885_fh *fh;
enum v4l2_buf_type type = 0;
switch (vdev->vfl_type) { dprintk(1, "open dev=%s\n",
case VFL_TYPE_GRABBER: video_device_node_name(vdev));
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
break;
case VFL_TYPE_VBI:
type = V4L2_BUF_TYPE_VBI_CAPTURE;
break;
}
dprintk(1, "open dev=%s type=%s\n",
video_device_node_name(vdev), v4l2_type_names[type]);
/* allocate + initialize per filehandle data */ /* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL); fh = kzalloc(sizeof(*fh), GFP_KERNEL);
...@@ -745,7 +738,6 @@ static int video_open(struct file *file) ...@@ -745,7 +738,6 @@ static int video_open(struct file *file)
v4l2_fh_init(&fh->fh, vdev); v4l2_fh_init(&fh->fh, vdev);
file->private_data = &fh->fh; file->private_data = &fh->fh;
fh->dev = dev; fh->dev = dev;
fh->type = type;
fh->width = 320; fh->width = 320;
fh->height = 240; fh->height = 240;
fh->fmt = format_by_fourcc(V4L2_PIX_FMT_YUYV); fh->fmt = format_by_fourcc(V4L2_PIX_FMT_YUYV);
...@@ -774,28 +766,29 @@ static int video_open(struct file *file) ...@@ -774,28 +766,29 @@ static int video_open(struct file *file)
static ssize_t video_read(struct file *file, char __user *data, static ssize_t video_read(struct file *file, char __user *data,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct video_device *vdev = video_devdata(file);
struct cx23885_fh *fh = file->private_data; struct cx23885_fh *fh = file->private_data;
switch (fh->type) { switch (vdev->vfl_type) {
case V4L2_BUF_TYPE_VIDEO_CAPTURE: case VFL_TYPE_GRABBER:
if (res_locked(fh->dev, RESOURCE_VIDEO)) if (res_locked(fh->dev, RESOURCE_VIDEO))
return -EBUSY; return -EBUSY;
return videobuf_read_one(&fh->vidq, data, count, ppos, return videobuf_read_one(&fh->vidq, data, count, ppos,
file->f_flags & O_NONBLOCK); file->f_flags & O_NONBLOCK);
case V4L2_BUF_TYPE_VBI_CAPTURE: case VFL_TYPE_VBI:
if (!res_get(fh->dev, fh, RESOURCE_VBI)) if (!res_get(fh->dev, fh, RESOURCE_VBI))
return -EBUSY; return -EBUSY;
return videobuf_read_stream(&fh->vbiq, data, count, ppos, 1, return videobuf_read_stream(&fh->vbiq, data, count, ppos, 1,
file->f_flags & O_NONBLOCK); file->f_flags & O_NONBLOCK);
default: default:
BUG(); return -EINVAL;
return 0;
} }
} }
static unsigned int video_poll(struct file *file, static unsigned int video_poll(struct file *file,
struct poll_table_struct *wait) struct poll_table_struct *wait)
{ {
struct video_device *vdev = video_devdata(file);
struct cx23885_fh *fh = file->private_data; struct cx23885_fh *fh = file->private_data;
struct cx23885_buffer *buf; struct cx23885_buffer *buf;
unsigned long req_events = poll_requested_events(wait); unsigned long req_events = poll_requested_events(wait);
...@@ -808,7 +801,7 @@ static unsigned int video_poll(struct file *file, ...@@ -808,7 +801,7 @@ static unsigned int video_poll(struct file *file,
if (!(req_events & (POLLIN | POLLRDNORM))) if (!(req_events & (POLLIN | POLLRDNORM)))
return rc; return rc;
if (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type) { if (vdev->vfl_type == VFL_TYPE_VBI) {
if (!res_get(fh->dev, fh, RESOURCE_VBI)) if (!res_get(fh->dev, fh, RESOURCE_VBI))
return rc | POLLERR; return rc | POLLERR;
return rc | videobuf_poll_stream(file, &fh->vbiq, wait); return rc | videobuf_poll_stream(file, &fh->vbiq, wait);
...@@ -884,9 +877,7 @@ static int video_release(struct file *file) ...@@ -884,9 +877,7 @@ static int video_release(struct file *file)
static int video_mmap(struct file *file, struct vm_area_struct *vma) static int video_mmap(struct file *file, struct vm_area_struct *vma)
{ {
struct cx23885_fh *fh = file->private_data; return videobuf_mmap_mapper(get_queue(file), vma);
return videobuf_mmap_mapper(get_queue(fh), vma);
} }
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
...@@ -1019,73 +1010,73 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv, ...@@ -1019,73 +1010,73 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
static int vidioc_reqbufs(struct file *file, void *priv, static int vidioc_reqbufs(struct file *file, void *priv,
struct v4l2_requestbuffers *p) struct v4l2_requestbuffers *p)
{ {
struct cx23885_fh *fh = priv; return videobuf_reqbufs(get_queue(file), p);
return videobuf_reqbufs(get_queue(fh), p);
} }
static int vidioc_querybuf(struct file *file, void *priv, static int vidioc_querybuf(struct file *file, void *priv,
struct v4l2_buffer *p) struct v4l2_buffer *p)
{ {
struct cx23885_fh *fh = priv; return videobuf_querybuf(get_queue(file), p);
return videobuf_querybuf(get_queue(fh), p);
} }
static int vidioc_qbuf(struct file *file, void *priv, static int vidioc_qbuf(struct file *file, void *priv,
struct v4l2_buffer *p) struct v4l2_buffer *p)
{ {
struct cx23885_fh *fh = priv; return videobuf_qbuf(get_queue(file), p);
return videobuf_qbuf(get_queue(fh), p);
} }
static int vidioc_dqbuf(struct file *file, void *priv, static int vidioc_dqbuf(struct file *file, void *priv,
struct v4l2_buffer *p) struct v4l2_buffer *p)
{ {
struct cx23885_fh *fh = priv; return videobuf_dqbuf(get_queue(file), p,
return videobuf_dqbuf(get_queue(fh), p,
file->f_flags & O_NONBLOCK); file->f_flags & O_NONBLOCK);
} }
static int vidioc_streamon(struct file *file, void *priv, static int vidioc_streamon(struct file *file, void *priv,
enum v4l2_buf_type i) enum v4l2_buf_type i)
{ {
struct video_device *vdev = video_devdata(file);
struct cx23885_fh *fh = priv; struct cx23885_fh *fh = priv;
struct cx23885_dev *dev = fh->dev; struct cx23885_dev *dev = fh->dev;
dprintk(1, "%s()\n", __func__); dprintk(1, "%s()\n", __func__);
if ((fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) && if (vdev->vfl_type == VFL_TYPE_VBI &&
(fh->type != V4L2_BUF_TYPE_VBI_CAPTURE)) i != V4L2_BUF_TYPE_VBI_CAPTURE)
return -EINVAL; return -EINVAL;
if (unlikely(i != fh->type)) if (vdev->vfl_type == VFL_TYPE_GRABBER &&
i != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL; return -EINVAL;
if (unlikely(!res_get(dev, fh, get_resource(fh)))) if (unlikely(!res_get(dev, fh, get_resource(i))))
return -EBUSY; return -EBUSY;
/* Don't start VBI streaming unless vida streaming /* Don't start VBI streaming unless vida streaming
* has already started. * has already started.
*/ */
if ((fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) && if ((i == V4L2_BUF_TYPE_VBI_CAPTURE) &&
((cx_read(VID_A_DMA_CTL) & 0x11) == 0)) ((cx_read(VID_A_DMA_CTL) & 0x11) == 0))
return -EINVAL; return -EINVAL;
return videobuf_streamon(get_queue(fh)); return videobuf_streamon(get_queue(file));
} }
static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
{ {
struct video_device *vdev = video_devdata(file);
struct cx23885_fh *fh = priv; struct cx23885_fh *fh = priv;
struct cx23885_dev *dev = fh->dev; struct cx23885_dev *dev = fh->dev;
int err, res; int err, res;
dprintk(1, "%s()\n", __func__); dprintk(1, "%s()\n", __func__);
if ((fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) && if (vdev->vfl_type == VFL_TYPE_VBI &&
(fh->type != V4L2_BUF_TYPE_VBI_CAPTURE)) i != V4L2_BUF_TYPE_VBI_CAPTURE)
return -EINVAL; return -EINVAL;
if (i != fh->type) if (vdev->vfl_type == VFL_TYPE_GRABBER &&
i != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL; return -EINVAL;
res = get_resource(fh); res = get_resource(i);
err = videobuf_streamoff(get_queue(fh)); err = videobuf_streamoff(get_queue(file));
if (err < 0) if (err < 0)
return err; return err;
res_free(dev, fh, res); res_free(dev, fh, res);
......
...@@ -143,7 +143,6 @@ struct cx23885_tvnorm { ...@@ -143,7 +143,6 @@ struct cx23885_tvnorm {
struct cx23885_fh { struct cx23885_fh {
struct v4l2_fh fh; struct v4l2_fh fh;
struct cx23885_dev *dev; struct cx23885_dev *dev;
enum v4l2_buf_type type;
u32 resources; u32 resources;
/* video overlay */ /* video overlay */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment