aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx88
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2012-07-02 07:47:11 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-07-06 17:09:48 -0400
commit7bb34c8e42fe2e7cfa0a46db52dc2a79f2ba723a (patch)
tree1ac5fff72fb958887e564300bf1c136d4b4cdb5b /drivers/media/video/cx88
parent8c7cb12ac1cc4ecc318765e0e2dcd853fa4a4d62 (diff)
[media] cx88: convert cx88-blackbird to the control framework
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-blackbird.c106
-rw-r--r--drivers/media/video/cx88/cx88.h2
2 files changed, 39 insertions, 69 deletions
diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c
index c9bbe9fc9c7e..d8c25c5bb323 100644
--- a/drivers/media/video/cx88/cx88-blackbird.c
+++ b/drivers/media/video/cx88/cx88-blackbird.c
@@ -523,11 +523,10 @@ static void blackbird_codec_settings(struct cx8802_dev *dev)
523 blackbird_api_cmd(dev, CX2341X_ENC_SET_FRAME_SIZE, 2, 0, 523 blackbird_api_cmd(dev, CX2341X_ENC_SET_FRAME_SIZE, 2, 0,
524 dev->height, dev->width); 524 dev->height, dev->width);
525 525
526 dev->params.width = dev->width; 526 dev->cxhdl.width = dev->width;
527 dev->params.height = dev->height; 527 dev->cxhdl.height = dev->height;
528 dev->params.is_50hz = (dev->core->tvnorm & V4L2_STD_625_50) != 0; 528 cx2341x_handler_set_50hz(&dev->cxhdl, dev->core->tvnorm & V4L2_STD_625_50);
529 529 cx2341x_handler_setup(&dev->cxhdl);
530 cx2341x_update(dev, blackbird_mbox_func, NULL, &dev->params);
531} 530}
532 531
533static int blackbird_initialize_codec(struct cx8802_dev *dev) 532static int blackbird_initialize_codec(struct cx8802_dev *dev)
@@ -618,6 +617,8 @@ static int blackbird_start_codec(struct file *file, void *priv)
618 /* initialize the video input */ 617 /* initialize the video input */
619 blackbird_api_cmd(dev, CX2341X_ENC_INITIALIZE_INPUT, 0, 0); 618 blackbird_api_cmd(dev, CX2341X_ENC_INITIALIZE_INPUT, 0, 0);
620 619
620 cx2341x_handler_set_busy(&dev->cxhdl, 1);
621
621 /* start capturing to the host interface */ 622 /* start capturing to the host interface */
622 blackbird_api_cmd(dev, CX2341X_ENC_START_CAPTURE, 2, 0, 623 blackbird_api_cmd(dev, CX2341X_ENC_START_CAPTURE, 2, 0,
623 BLACKBIRD_MPEG_CAPTURE, 624 BLACKBIRD_MPEG_CAPTURE,
@@ -636,6 +637,8 @@ static int blackbird_stop_codec(struct cx8802_dev *dev)
636 BLACKBIRD_RAW_BITS_NONE 637 BLACKBIRD_RAW_BITS_NONE
637 ); 638 );
638 639
640 cx2341x_handler_set_busy(&dev->cxhdl, 0);
641
639 dev->mpeg_active = 0; 642 dev->mpeg_active = 0;
640 return 0; 643 return 0;
641} 644}
@@ -721,7 +724,7 @@ static int vidioc_g_fmt_vid_cap (struct file *file, void *priv,
721 f->fmt.pix.width = dev->width; 724 f->fmt.pix.width = dev->width;
722 f->fmt.pix.height = dev->height; 725 f->fmt.pix.height = dev->height;
723 f->fmt.pix.field = fh->mpegq.field; 726 f->fmt.pix.field = fh->mpegq.field;
724 dprintk(0,"VIDIOC_G_FMT: w: %d, h: %d, f: %d\n", 727 dprintk(1, "VIDIOC_G_FMT: w: %d, h: %d, f: %d\n",
725 dev->width, dev->height, fh->mpegq.field ); 728 dev->width, dev->height, fh->mpegq.field );
726 return 0; 729 return 0;
727} 730}
@@ -736,7 +739,7 @@ static int vidioc_try_fmt_vid_cap (struct file *file, void *priv,
736 f->fmt.pix.bytesperline = 0; 739 f->fmt.pix.bytesperline = 0;
737 f->fmt.pix.sizeimage = dev->ts_packet_size * dev->ts_packet_count; /* 188 * 4 * 1024; */; 740 f->fmt.pix.sizeimage = dev->ts_packet_size * dev->ts_packet_count; /* 188 * 4 * 1024; */;
738 f->fmt.pix.colorspace = 0; 741 f->fmt.pix.colorspace = 0;
739 dprintk(0,"VIDIOC_TRY_FMT: w: %d, h: %d, f: %d\n", 742 dprintk(1, "VIDIOC_TRY_FMT: w: %d, h: %d, f: %d\n",
740 dev->width, dev->height, fh->mpegq.field ); 743 dev->width, dev->height, fh->mpegq.field );
741 return 0; 744 return 0;
742} 745}
@@ -758,7 +761,7 @@ static int vidioc_s_fmt_vid_cap (struct file *file, void *priv,
758 cx88_set_scale(core, f->fmt.pix.width, f->fmt.pix.height, f->fmt.pix.field); 761 cx88_set_scale(core, f->fmt.pix.width, f->fmt.pix.height, f->fmt.pix.field);
759 blackbird_api_cmd(dev, CX2341X_ENC_SET_FRAME_SIZE, 2, 0, 762 blackbird_api_cmd(dev, CX2341X_ENC_SET_FRAME_SIZE, 2, 0,
760 f->fmt.pix.height, f->fmt.pix.width); 763 f->fmt.pix.height, f->fmt.pix.width);
761 dprintk(0,"VIDIOC_S_FMT: w: %d, h: %d, f: %d\n", 764 dprintk(1, "VIDIOC_S_FMT: w: %d, h: %d, f: %d\n",
762 f->fmt.pix.width, f->fmt.pix.height, f->fmt.pix.field ); 765 f->fmt.pix.width, f->fmt.pix.height, f->fmt.pix.field );
763 return 0; 766 return 0;
764} 767}
@@ -791,60 +794,21 @@ static int vidioc_dqbuf (struct file *file, void *priv, struct v4l2_buffer *p)
791static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) 794static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
792{ 795{
793 struct cx8802_fh *fh = priv; 796 struct cx8802_fh *fh = priv;
797 struct cx8802_dev *dev = fh->dev;
798
799 if (!dev->mpeg_active)
800 blackbird_start_codec(file, fh);
794 return videobuf_streamon(&fh->mpegq); 801 return videobuf_streamon(&fh->mpegq);
795} 802}
796 803
797static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) 804static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
798{ 805{
799 struct cx8802_fh *fh = priv; 806 struct cx8802_fh *fh = priv;
800 return videobuf_streamoff(&fh->mpegq); 807 struct cx8802_dev *dev = fh->dev;
801}
802
803static int vidioc_g_ext_ctrls (struct file *file, void *priv,
804 struct v4l2_ext_controls *f)
805{
806 struct cx8802_dev *dev = ((struct cx8802_fh *)priv)->dev;
807
808 if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG)
809 return -EINVAL;
810 return cx2341x_ext_ctrls(&dev->params, 0, f, VIDIOC_G_EXT_CTRLS);
811}
812
813static int vidioc_s_ext_ctrls (struct file *file, void *priv,
814 struct v4l2_ext_controls *f)
815{
816 struct cx8802_dev *dev = ((struct cx8802_fh *)priv)->dev;
817 struct cx2341x_mpeg_params p;
818 int err;
819
820 if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG)
821 return -EINVAL;
822 808
823 if (dev->mpeg_active) 809 if (dev->mpeg_active)
824 blackbird_stop_codec(dev); 810 blackbird_stop_codec(dev);
825 811 return videobuf_streamoff(&fh->mpegq);
826 p = dev->params;
827 err = cx2341x_ext_ctrls(&p, 0, f, VIDIOC_S_EXT_CTRLS);
828 if (!err) {
829 err = cx2341x_update(dev, blackbird_mbox_func, &dev->params, &p);
830 dev->params = p;
831 }
832 return err;
833}
834
835static int vidioc_try_ext_ctrls (struct file *file, void *priv,
836 struct v4l2_ext_controls *f)
837{
838 struct cx8802_dev *dev = ((struct cx8802_fh *)priv)->dev;
839 struct cx2341x_mpeg_params p;
840 int err;
841
842 if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG)
843 return -EINVAL;
844 p = dev->params;
845 err = cx2341x_ext_ctrls(&p, 0, f, VIDIOC_TRY_EXT_CTRLS);
846
847 return err;
848} 812}
849 813
850static int vidioc_s_frequency (struct file *file, void *priv, 814static int vidioc_s_frequency (struct file *file, void *priv,
@@ -871,12 +835,8 @@ static int vidioc_log_status (struct file *file, void *priv)
871 char name[32 + 2]; 835 char name[32 + 2];
872 836
873 snprintf(name, sizeof(name), "%s/2", core->name); 837 snprintf(name, sizeof(name), "%s/2", core->name);
874 printk("%s/2: ============ START LOG STATUS ============\n",
875 core->name);
876 call_all(core, core, log_status); 838 call_all(core, core, log_status);
877 cx2341x_log_status(&dev->params, name); 839 v4l2_ctrl_handler_log_status(&dev->cxhdl.hdl, name);
878 printk("%s/2: ============= END LOG STATUS =============\n",
879 core->name);
880 return 0; 840 return 0;
881} 841}
882 842
@@ -1082,10 +1042,11 @@ mpeg_read(struct file *file, char __user *data, size_t count, loff_t *ppos)
1082static unsigned int 1042static unsigned int
1083mpeg_poll(struct file *file, struct poll_table_struct *wait) 1043mpeg_poll(struct file *file, struct poll_table_struct *wait)
1084{ 1044{
1045 unsigned long req_events = poll_requested_events(wait);
1085 struct cx8802_fh *fh = file->private_data; 1046 struct cx8802_fh *fh = file->private_data;
1086 struct cx8802_dev *dev = fh->dev; 1047 struct cx8802_dev *dev = fh->dev;
1087 1048
1088 if (!dev->mpeg_active) 1049 if (!dev->mpeg_active && (req_events & (POLLIN | POLLRDNORM)))
1089 blackbird_start_codec(file, fh); 1050 blackbird_start_codec(file, fh);
1090 1051
1091 return videobuf_poll_stream(file, &fh->mpegq, wait); 1052 return videobuf_poll_stream(file, &fh->mpegq, wait);
@@ -1122,9 +1083,6 @@ static const struct v4l2_ioctl_ops mpeg_ioctl_ops = {
1122 .vidioc_dqbuf = vidioc_dqbuf, 1083 .vidioc_dqbuf = vidioc_dqbuf,
1123 .vidioc_streamon = vidioc_streamon, 1084 .vidioc_streamon = vidioc_streamon,
1124 .vidioc_streamoff = vidioc_streamoff, 1085 .vidioc_streamoff = vidioc_streamoff,
1125 .vidioc_g_ext_ctrls = vidioc_g_ext_ctrls,
1126 .vidioc_s_ext_ctrls = vidioc_s_ext_ctrls,
1127 .vidioc_try_ext_ctrls = vidioc_try_ext_ctrls,
1128 .vidioc_s_frequency = vidioc_s_frequency, 1086 .vidioc_s_frequency = vidioc_s_frequency,
1129 .vidioc_log_status = vidioc_log_status, 1087 .vidioc_log_status = vidioc_log_status,
1130 .vidioc_enum_input = vidioc_enum_input, 1088 .vidioc_enum_input = vidioc_enum_input,
@@ -1209,6 +1167,7 @@ static int blackbird_register_video(struct cx8802_dev *dev)
1209 1167
1210 dev->mpeg_dev = cx88_vdev_init(dev->core,dev->pci, 1168 dev->mpeg_dev = cx88_vdev_init(dev->core,dev->pci,
1211 &cx8802_mpeg_template,"mpeg"); 1169 &cx8802_mpeg_template,"mpeg");
1170 dev->mpeg_dev->ctrl_handler = &dev->cxhdl.hdl;
1212 video_set_drvdata(dev->mpeg_dev, dev); 1171 video_set_drvdata(dev->mpeg_dev, dev);
1213 err = video_register_device(dev->mpeg_dev,VFL_TYPE_GRABBER, -1); 1172 err = video_register_device(dev->mpeg_dev,VFL_TYPE_GRABBER, -1);
1214 if (err < 0) { 1173 if (err < 0) {
@@ -1240,18 +1199,23 @@ static int cx8802_blackbird_probe(struct cx8802_driver *drv)
1240 if (!(core->board.mpeg & CX88_MPEG_BLACKBIRD)) 1199 if (!(core->board.mpeg & CX88_MPEG_BLACKBIRD))
1241 goto fail_core; 1200 goto fail_core;
1242 1201
1243 dev->width = 720;
1244 dev->height = 576;
1245 cx2341x_fill_defaults(&dev->params);
1246 dev->params.port = CX2341X_PORT_STREAMING;
1247
1248 cx8802_mpeg_template.current_norm = core->tvnorm; 1202 cx8802_mpeg_template.current_norm = core->tvnorm;
1249 1203
1204 dev->width = 720;
1250 if (core->tvnorm & V4L2_STD_525_60) { 1205 if (core->tvnorm & V4L2_STD_525_60) {
1251 dev->height = 480; 1206 dev->height = 480;
1252 } else { 1207 } else {
1253 dev->height = 576; 1208 dev->height = 576;
1254 } 1209 }
1210 dev->cxhdl.port = CX2341X_PORT_STREAMING;
1211 dev->cxhdl.width = dev->width;
1212 dev->cxhdl.height = dev->height;
1213 dev->cxhdl.func = blackbird_mbox_func;
1214 dev->cxhdl.priv = dev;
1215 err = cx2341x_handler_init(&dev->cxhdl, 36);
1216 if (err)
1217 goto fail_core;
1218 v4l2_ctrl_add_handler(&dev->cxhdl.hdl, &core->video_hdl);
1255 1219
1256 /* blackbird stuff */ 1220 /* blackbird stuff */
1257 printk("%s/2: cx23416 based mpeg encoder (blackbird reference design)\n", 1221 printk("%s/2: cx23416 based mpeg encoder (blackbird reference design)\n",
@@ -1259,12 +1223,14 @@ static int cx8802_blackbird_probe(struct cx8802_driver *drv)
1259 host_setup(dev->core); 1223 host_setup(dev->core);
1260 1224
1261 blackbird_initialize_codec(dev); 1225 blackbird_initialize_codec(dev);
1262 blackbird_register_video(dev);
1263 1226
1264 /* initial device configuration: needed ? */ 1227 /* initial device configuration: needed ? */
1265// init_controls(core); 1228// init_controls(core);
1266 cx88_set_tvnorm(core,core->tvnorm); 1229 cx88_set_tvnorm(core,core->tvnorm);
1267 cx88_video_mux(core,0); 1230 cx88_video_mux(core,0);
1231 cx2341x_handler_set_50hz(&dev->cxhdl, dev->height == 576);
1232 cx2341x_handler_setup(&dev->cxhdl);
1233 blackbird_register_video(dev);
1268 1234
1269 return 0; 1235 return 0;
1270 1236
@@ -1274,8 +1240,12 @@ static int cx8802_blackbird_probe(struct cx8802_driver *drv)
1274 1240
1275static int cx8802_blackbird_remove(struct cx8802_driver *drv) 1241static int cx8802_blackbird_remove(struct cx8802_driver *drv)
1276{ 1242{
1243 struct cx88_core *core = drv->core;
1244 struct cx8802_dev *dev = core->dvbdev;
1245
1277 /* blackbird */ 1246 /* blackbird */
1278 blackbird_unregister_video(drv->core->dvbdev); 1247 blackbird_unregister_video(drv->core->dvbdev);
1248 v4l2_ctrl_handler_free(&dev->cxhdl.hdl);
1279 1249
1280 return 0; 1250 return 0;
1281} 1251}
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index 280bf6ab7b75..e79cb878379a 100644
--- a/drivers/media/video/cx88/cx88.h
+++ b/drivers/media/video/cx88/cx88.h
@@ -575,7 +575,7 @@ struct cx8802_dev {
575 unsigned char mpeg_active; /* nonzero if mpeg encoder is active */ 575 unsigned char mpeg_active; /* nonzero if mpeg encoder is active */
576 576
577 /* mpeg params */ 577 /* mpeg params */
578 struct cx2341x_mpeg_params params; 578 struct cx2341x_handler cxhdl;
579#endif 579#endif
580 580
581#if defined(CONFIG_VIDEO_CX88_DVB) || defined(CONFIG_VIDEO_CX88_DVB_MODULE) 581#if defined(CONFIG_VIDEO_CX88_DVB) || defined(CONFIG_VIDEO_CX88_DVB_MODULE)