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

[media] cx88: remove radio and type from cx8800_fh

This information is available elsewhere already.
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 7bb34c8e
...@@ -683,12 +683,15 @@ static const struct videobuf_queue_ops cx8800_video_qops = { ...@@ -683,12 +683,15 @@ static const struct videobuf_queue_ops cx8800_video_qops = {
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static struct videobuf_queue* get_queue(struct cx8800_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 cx8800_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(); BUG();
...@@ -696,12 +699,14 @@ static struct videobuf_queue* get_queue(struct cx8800_fh *fh) ...@@ -696,12 +699,14 @@ static struct videobuf_queue* get_queue(struct cx8800_fh *fh)
} }
} }
static int get_ressource(struct cx8800_fh *fh) static int get_resource(struct file *file)
{ {
switch (fh->type) { struct video_device *vdev = video_devdata(file);
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
switch (vdev->vfl_type) {
case VFL_TYPE_GRABBER:
return RESOURCE_VIDEO; return RESOURCE_VIDEO;
case V4L2_BUF_TYPE_VBI_CAPTURE: case VFL_TYPE_VBI:
return RESOURCE_VBI; return RESOURCE_VBI;
default: default:
BUG(); BUG();
...@@ -740,8 +745,6 @@ static int video_open(struct file *file) ...@@ -740,8 +745,6 @@ static int video_open(struct file *file)
file->private_data = fh; file->private_data = fh;
fh->dev = dev; fh->dev = dev;
fh->radio = radio;
fh->type = type;
fh->width = 320; fh->width = 320;
fh->height = 240; fh->height = 240;
fh->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24); fh->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24);
...@@ -761,7 +764,7 @@ static int video_open(struct file *file) ...@@ -761,7 +764,7 @@ static int video_open(struct file *file)
sizeof(struct cx88_buffer), sizeof(struct cx88_buffer),
fh, NULL); fh, NULL);
if (fh->radio) { if (vdev->vfl_type == VFL_TYPE_RADIO) {
dprintk(1,"video_open: setting radio device\n"); dprintk(1,"video_open: setting radio device\n");
cx_write(MO_GP3_IO, core->board.radio.gpio3); cx_write(MO_GP3_IO, core->board.radio.gpio3);
cx_write(MO_GP0_IO, core->board.radio.gpio0); cx_write(MO_GP0_IO, core->board.radio.gpio0);
...@@ -794,15 +797,16 @@ static int video_open(struct file *file) ...@@ -794,15 +797,16 @@ static int video_open(struct file *file)
static ssize_t static ssize_t
video_read(struct file *file, char __user *data, size_t count, loff_t *ppos) video_read(struct file *file, char __user *data, size_t count, loff_t *ppos)
{ {
struct video_device *vdev = video_devdata(file);
struct cx8800_fh *fh = file->private_data; struct cx8800_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,
...@@ -816,11 +820,12 @@ video_read(struct file *file, char __user *data, size_t count, loff_t *ppos) ...@@ -816,11 +820,12 @@ video_read(struct file *file, char __user *data, size_t count, loff_t *ppos)
static unsigned int static unsigned int
video_poll(struct file *file, struct poll_table_struct *wait) video_poll(struct file *file, struct poll_table_struct *wait)
{ {
struct video_device *vdev = video_devdata(file);
struct cx8800_fh *fh = file->private_data; struct cx8800_fh *fh = file->private_data;
struct cx88_buffer *buf; struct cx88_buffer *buf;
unsigned int rc = POLLERR; unsigned int rc = POLLERR;
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 POLLERR; return POLLERR;
return videobuf_poll_stream(file, &fh->vbiq, wait); return videobuf_poll_stream(file, &fh->vbiq, wait);
...@@ -894,9 +899,7 @@ static int video_release(struct file *file) ...@@ -894,9 +899,7 @@ static int video_release(struct file *file)
static int static int
video_mmap(struct file *file, struct vm_area_struct * vma) video_mmap(struct file *file, struct vm_area_struct * vma)
{ {
struct cx8800_fh *fh = file->private_data; return videobuf_mmap_mapper(get_queue(file), vma);
return videobuf_mmap_mapper(get_queue(fh), vma);
} }
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
...@@ -1126,63 +1129,53 @@ static int vidioc_enum_fmt_vid_cap (struct file *file, void *priv, ...@@ -1126,63 +1129,53 @@ static int vidioc_enum_fmt_vid_cap (struct file *file, void *priv,
static int vidioc_reqbufs (struct file *file, void *priv, struct v4l2_requestbuffers *p) static int vidioc_reqbufs (struct file *file, void *priv, struct v4l2_requestbuffers *p)
{ {
struct cx8800_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, struct v4l2_buffer *p) static int vidioc_querybuf (struct file *file, void *priv, struct v4l2_buffer *p)
{ {
struct cx8800_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, struct v4l2_buffer *p) static int vidioc_qbuf (struct file *file, void *priv, struct v4l2_buffer *p)
{ {
struct cx8800_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, struct v4l2_buffer *p) static int vidioc_dqbuf (struct file *file, void *priv, struct v4l2_buffer *p)
{ {
struct cx8800_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, enum v4l2_buf_type i) static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
{ {
struct video_device *vdev = video_devdata(file);
struct cx8800_fh *fh = priv; struct cx8800_fh *fh = priv;
struct cx8800_dev *dev = fh->dev; struct cx8800_dev *dev = fh->dev;
/* We should remember that this driver also supports teletext, */ if ((vdev->vfl_type == VFL_TYPE_GRABBER && i != V4L2_BUF_TYPE_VIDEO_CAPTURE) ||
/* so we have to test if the v4l2_buf_type is VBI capture data. */ (vdev->vfl_type == VFL_TYPE_VBI && i != V4L2_BUF_TYPE_VBI_CAPTURE))
if (unlikely((fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) &&
(fh->type != V4L2_BUF_TYPE_VBI_CAPTURE)))
return -EINVAL; return -EINVAL;
if (unlikely(i != fh->type)) if (unlikely(!res_get(dev, fh, get_resource(file))))
return -EINVAL;
if (unlikely(!res_get(dev,fh,get_ressource(fh))))
return -EBUSY; return -EBUSY;
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 cx8800_fh *fh = priv; struct cx8800_fh *fh = priv;
struct cx8800_dev *dev = fh->dev; struct cx8800_dev *dev = fh->dev;
int err, res; int err, res;
if ((fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) && if ((vdev->vfl_type == VFL_TYPE_GRABBER && i != V4L2_BUF_TYPE_VIDEO_CAPTURE) ||
(fh->type != V4L2_BUF_TYPE_VBI_CAPTURE)) (vdev->vfl_type == VFL_TYPE_VBI && i != V4L2_BUF_TYPE_VBI_CAPTURE))
return -EINVAL;
if (i != fh->type)
return -EINVAL; return -EINVAL;
res = get_ressource(fh); res = get_resource(file);
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);
...@@ -1305,8 +1298,6 @@ static int vidioc_g_frequency (struct file *file, void *priv, ...@@ -1305,8 +1298,6 @@ static int vidioc_g_frequency (struct file *file, void *priv,
if (unlikely(UNSET == core->board.tuner_type)) if (unlikely(UNSET == core->board.tuner_type))
return -EINVAL; return -EINVAL;
/* f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; */
f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
f->frequency = core->freq; f->frequency = core->freq;
call_all(core, tuner, g_frequency, f); call_all(core, tuner, g_frequency, f);
...@@ -1343,13 +1334,7 @@ static int vidioc_s_frequency (struct file *file, void *priv, ...@@ -1343,13 +1334,7 @@ static int vidioc_s_frequency (struct file *file, void *priv,
struct cx8800_fh *fh = priv; struct cx8800_fh *fh = priv;
struct cx88_core *core = fh->dev->core; struct cx88_core *core = fh->dev->core;
if (unlikely(0 == fh->radio && f->type != V4L2_TUNER_ANALOG_TV)) return cx88_set_freq(core, f);
return -EINVAL;
if (unlikely(1 == fh->radio && f->type != V4L2_TUNER_RADIO))
return -EINVAL;
return
cx88_set_freq (core,f);
} }
#ifdef CONFIG_VIDEO_ADV_DEBUG #ifdef CONFIG_VIDEO_ADV_DEBUG
......
...@@ -455,8 +455,6 @@ struct cx8802_dev; ...@@ -455,8 +455,6 @@ struct cx8802_dev;
struct cx8800_fh { struct cx8800_fh {
struct cx8800_dev *dev; struct cx8800_dev *dev;
enum v4l2_buf_type type;
int radio;
unsigned int resources; unsigned int 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