aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx88
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2012-05-11 09:33:25 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-07-06 17:10:54 -0400
commitedbd138ed0cae5abe469b61e368d2629815d4c37 (patch)
treef3d15ca30dc15f13dc81574d95a5fe1edee4e7e7 /drivers/media/video/cx88
parent7bb34c8e42fe2e7cfa0a46db52dc2a79f2ba723a (diff)
[media] cx88: remove radio and type from cx8800_fh
This information is available elsewhere already. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/cx88')
-rw-r--r--drivers/media/video/cx88/cx88-video.c89
-rw-r--r--drivers/media/video/cx88/cx88.h2
2 files changed, 37 insertions, 54 deletions
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index 104a85c265f3..e5e551090d1c 100644
--- a/drivers/media/video/cx88/cx88-video.c
+++ b/drivers/media/video/cx88/cx88-video.c
@@ -683,12 +683,15 @@ static const struct videobuf_queue_ops cx8800_video_qops = {
683 683
684/* ------------------------------------------------------------------ */ 684/* ------------------------------------------------------------------ */
685 685
686static struct videobuf_queue* get_queue(struct cx8800_fh *fh) 686static struct videobuf_queue *get_queue(struct file *file)
687{ 687{
688 switch (fh->type) { 688 struct video_device *vdev = video_devdata(file);
689 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 689 struct cx8800_fh *fh = file->private_data;
690
691 switch (vdev->vfl_type) {
692 case VFL_TYPE_GRABBER:
690 return &fh->vidq; 693 return &fh->vidq;
691 case V4L2_BUF_TYPE_VBI_CAPTURE: 694 case VFL_TYPE_VBI:
692 return &fh->vbiq; 695 return &fh->vbiq;
693 default: 696 default:
694 BUG(); 697 BUG();
@@ -696,12 +699,14 @@ static struct videobuf_queue* get_queue(struct cx8800_fh *fh)
696 } 699 }
697} 700}
698 701
699static int get_ressource(struct cx8800_fh *fh) 702static int get_resource(struct file *file)
700{ 703{
701 switch (fh->type) { 704 struct video_device *vdev = video_devdata(file);
702 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 705
706 switch (vdev->vfl_type) {
707 case VFL_TYPE_GRABBER:
703 return RESOURCE_VIDEO; 708 return RESOURCE_VIDEO;
704 case V4L2_BUF_TYPE_VBI_CAPTURE: 709 case VFL_TYPE_VBI:
705 return RESOURCE_VBI; 710 return RESOURCE_VBI;
706 default: 711 default:
707 BUG(); 712 BUG();
@@ -740,8 +745,6 @@ static int video_open(struct file *file)
740 745
741 file->private_data = fh; 746 file->private_data = fh;
742 fh->dev = dev; 747 fh->dev = dev;
743 fh->radio = radio;
744 fh->type = type;
745 fh->width = 320; 748 fh->width = 320;
746 fh->height = 240; 749 fh->height = 240;
747 fh->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24); 750 fh->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24);
@@ -761,7 +764,7 @@ static int video_open(struct file *file)
761 sizeof(struct cx88_buffer), 764 sizeof(struct cx88_buffer),
762 fh, NULL); 765 fh, NULL);
763 766
764 if (fh->radio) { 767 if (vdev->vfl_type == VFL_TYPE_RADIO) {
765 dprintk(1,"video_open: setting radio device\n"); 768 dprintk(1,"video_open: setting radio device\n");
766 cx_write(MO_GP3_IO, core->board.radio.gpio3); 769 cx_write(MO_GP3_IO, core->board.radio.gpio3);
767 cx_write(MO_GP0_IO, core->board.radio.gpio0); 770 cx_write(MO_GP0_IO, core->board.radio.gpio0);
@@ -794,15 +797,16 @@ static int video_open(struct file *file)
794static ssize_t 797static ssize_t
795video_read(struct file *file, char __user *data, size_t count, loff_t *ppos) 798video_read(struct file *file, char __user *data, size_t count, loff_t *ppos)
796{ 799{
800 struct video_device *vdev = video_devdata(file);
797 struct cx8800_fh *fh = file->private_data; 801 struct cx8800_fh *fh = file->private_data;
798 802
799 switch (fh->type) { 803 switch (vdev->vfl_type) {
800 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 804 case VFL_TYPE_GRABBER:
801 if (res_locked(fh->dev,RESOURCE_VIDEO)) 805 if (res_locked(fh->dev,RESOURCE_VIDEO))
802 return -EBUSY; 806 return -EBUSY;
803 return videobuf_read_one(&fh->vidq, data, count, ppos, 807 return videobuf_read_one(&fh->vidq, data, count, ppos,
804 file->f_flags & O_NONBLOCK); 808 file->f_flags & O_NONBLOCK);
805 case V4L2_BUF_TYPE_VBI_CAPTURE: 809 case VFL_TYPE_VBI:
806 if (!res_get(fh->dev,fh,RESOURCE_VBI)) 810 if (!res_get(fh->dev,fh,RESOURCE_VBI))
807 return -EBUSY; 811 return -EBUSY;
808 return videobuf_read_stream(&fh->vbiq, data, count, ppos, 1, 812 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)
816static unsigned int 820static unsigned int
817video_poll(struct file *file, struct poll_table_struct *wait) 821video_poll(struct file *file, struct poll_table_struct *wait)
818{ 822{
823 struct video_device *vdev = video_devdata(file);
819 struct cx8800_fh *fh = file->private_data; 824 struct cx8800_fh *fh = file->private_data;
820 struct cx88_buffer *buf; 825 struct cx88_buffer *buf;
821 unsigned int rc = POLLERR; 826 unsigned int rc = POLLERR;
822 827
823 if (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type) { 828 if (vdev->vfl_type == VFL_TYPE_VBI) {
824 if (!res_get(fh->dev,fh,RESOURCE_VBI)) 829 if (!res_get(fh->dev,fh,RESOURCE_VBI))
825 return POLLERR; 830 return POLLERR;
826 return videobuf_poll_stream(file, &fh->vbiq, wait); 831 return videobuf_poll_stream(file, &fh->vbiq, wait);
@@ -894,9 +899,7 @@ static int video_release(struct file *file)
894static int 899static int
895video_mmap(struct file *file, struct vm_area_struct * vma) 900video_mmap(struct file *file, struct vm_area_struct * vma)
896{ 901{
897 struct cx8800_fh *fh = file->private_data; 902 return videobuf_mmap_mapper(get_queue(file), vma);
898
899 return videobuf_mmap_mapper(get_queue(fh), vma);
900} 903}
901 904
902/* ------------------------------------------------------------------ */ 905/* ------------------------------------------------------------------ */
@@ -1126,63 +1129,53 @@ static int vidioc_enum_fmt_vid_cap (struct file *file, void *priv,
1126 1129
1127static int vidioc_reqbufs (struct file *file, void *priv, struct v4l2_requestbuffers *p) 1130static int vidioc_reqbufs (struct file *file, void *priv, struct v4l2_requestbuffers *p)
1128{ 1131{
1129 struct cx8800_fh *fh = priv; 1132 return videobuf_reqbufs(get_queue(file), p);
1130 return (videobuf_reqbufs(get_queue(fh), p));
1131} 1133}
1132 1134
1133static int vidioc_querybuf (struct file *file, void *priv, struct v4l2_buffer *p) 1135static int vidioc_querybuf (struct file *file, void *priv, struct v4l2_buffer *p)
1134{ 1136{
1135 struct cx8800_fh *fh = priv; 1137 return videobuf_querybuf(get_queue(file), p);
1136 return (videobuf_querybuf(get_queue(fh), p));
1137} 1138}
1138 1139
1139static int vidioc_qbuf (struct file *file, void *priv, struct v4l2_buffer *p) 1140static int vidioc_qbuf (struct file *file, void *priv, struct v4l2_buffer *p)
1140{ 1141{
1141 struct cx8800_fh *fh = priv; 1142 return videobuf_qbuf(get_queue(file), p);
1142 return (videobuf_qbuf(get_queue(fh), p));
1143} 1143}
1144 1144
1145static int vidioc_dqbuf (struct file *file, void *priv, struct v4l2_buffer *p) 1145static int vidioc_dqbuf (struct file *file, void *priv, struct v4l2_buffer *p)
1146{ 1146{
1147 struct cx8800_fh *fh = priv; 1147 return videobuf_dqbuf(get_queue(file), p,
1148 return (videobuf_dqbuf(get_queue(fh), p, 1148 file->f_flags & O_NONBLOCK);
1149 file->f_flags & O_NONBLOCK));
1150} 1149}
1151 1150
1152static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) 1151static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
1153{ 1152{
1153 struct video_device *vdev = video_devdata(file);
1154 struct cx8800_fh *fh = priv; 1154 struct cx8800_fh *fh = priv;
1155 struct cx8800_dev *dev = fh->dev; 1155 struct cx8800_dev *dev = fh->dev;
1156 1156
1157 /* We should remember that this driver also supports teletext, */ 1157 if ((vdev->vfl_type == VFL_TYPE_GRABBER && i != V4L2_BUF_TYPE_VIDEO_CAPTURE) ||
1158 /* so we have to test if the v4l2_buf_type is VBI capture data. */ 1158 (vdev->vfl_type == VFL_TYPE_VBI && i != V4L2_BUF_TYPE_VBI_CAPTURE))
1159 if (unlikely((fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) &&
1160 (fh->type != V4L2_BUF_TYPE_VBI_CAPTURE)))
1161 return -EINVAL; 1159 return -EINVAL;
1162 1160
1163 if (unlikely(i != fh->type)) 1161 if (unlikely(!res_get(dev, fh, get_resource(file))))
1164 return -EINVAL;
1165
1166 if (unlikely(!res_get(dev,fh,get_ressource(fh))))
1167 return -EBUSY; 1162 return -EBUSY;
1168 return videobuf_streamon(get_queue(fh)); 1163 return videobuf_streamon(get_queue(file));
1169} 1164}
1170 1165
1171static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) 1166static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
1172{ 1167{
1168 struct video_device *vdev = video_devdata(file);
1173 struct cx8800_fh *fh = priv; 1169 struct cx8800_fh *fh = priv;
1174 struct cx8800_dev *dev = fh->dev; 1170 struct cx8800_dev *dev = fh->dev;
1175 int err, res; 1171 int err, res;
1176 1172
1177 if ((fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) && 1173 if ((vdev->vfl_type == VFL_TYPE_GRABBER && i != V4L2_BUF_TYPE_VIDEO_CAPTURE) ||
1178 (fh->type != V4L2_BUF_TYPE_VBI_CAPTURE)) 1174 (vdev->vfl_type == VFL_TYPE_VBI && i != V4L2_BUF_TYPE_VBI_CAPTURE))
1179 return -EINVAL;
1180
1181 if (i != fh->type)
1182 return -EINVAL; 1175 return -EINVAL;
1183 1176
1184 res = get_ressource(fh); 1177 res = get_resource(file);
1185 err = videobuf_streamoff(get_queue(fh)); 1178 err = videobuf_streamoff(get_queue(file));
1186 if (err < 0) 1179 if (err < 0)
1187 return err; 1180 return err;
1188 res_free(dev,fh,res); 1181 res_free(dev,fh,res);
@@ -1305,8 +1298,6 @@ static int vidioc_g_frequency (struct file *file, void *priv,
1305 if (unlikely(UNSET == core->board.tuner_type)) 1298 if (unlikely(UNSET == core->board.tuner_type))
1306 return -EINVAL; 1299 return -EINVAL;
1307 1300
1308 /* f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; */
1309 f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
1310 f->frequency = core->freq; 1301 f->frequency = core->freq;
1311 1302
1312 call_all(core, tuner, g_frequency, f); 1303 call_all(core, tuner, g_frequency, f);
@@ -1343,13 +1334,7 @@ static int vidioc_s_frequency (struct file *file, void *priv,
1343 struct cx8800_fh *fh = priv; 1334 struct cx8800_fh *fh = priv;
1344 struct cx88_core *core = fh->dev->core; 1335 struct cx88_core *core = fh->dev->core;
1345 1336
1346 if (unlikely(0 == fh->radio && f->type != V4L2_TUNER_ANALOG_TV)) 1337 return cx88_set_freq(core, f);
1347 return -EINVAL;
1348 if (unlikely(1 == fh->radio && f->type != V4L2_TUNER_RADIO))
1349 return -EINVAL;
1350
1351 return
1352 cx88_set_freq (core,f);
1353} 1338}
1354 1339
1355#ifdef CONFIG_VIDEO_ADV_DEBUG 1340#ifdef CONFIG_VIDEO_ADV_DEBUG
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index e79cb878379a..1426993079b0 100644
--- a/drivers/media/video/cx88/cx88.h
+++ b/drivers/media/video/cx88/cx88.h
@@ -455,8 +455,6 @@ struct cx8802_dev;
455 455
456struct cx8800_fh { 456struct cx8800_fh {
457 struct cx8800_dev *dev; 457 struct cx8800_dev *dev;
458 enum v4l2_buf_type type;
459 int radio;
460 unsigned int resources; 458 unsigned int resources;
461 459
462 /* video overlay */ 460 /* video overlay */