aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2012-05-01 10:06:44 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-05-14 13:57:51 -0400
commit5da545ad08a3c6ea71d3ba074adc7582e7e9a024 (patch)
tree2a3f5a859822518184a4507a60fbaccbab486611 /drivers/media
parent4894b709d14c593466cc05e55ee493af931205e8 (diff)
[media] saa7146: move overlay information from saa7146_fh into saa7146_vv
This is global information, not per-filehandle information. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/common/saa7146_fops.c10
-rw-r--r--drivers/media/common/saa7146_hlp.c23
-rw-r--r--drivers/media/common/saa7146_video.c37
3 files changed, 42 insertions, 28 deletions
diff --git a/drivers/media/common/saa7146_fops.c b/drivers/media/common/saa7146_fops.c
index f14e218bed16..68047c93fd9d 100644
--- a/drivers/media/common/saa7146_fops.c
+++ b/drivers/media/common/saa7146_fops.c
@@ -436,6 +436,7 @@ static const struct v4l2_ctrl_ops saa7146_ctrl_ops = {
436int saa7146_vv_init(struct saa7146_dev* dev, struct saa7146_ext_vv *ext_vv) 436int saa7146_vv_init(struct saa7146_dev* dev, struct saa7146_ext_vv *ext_vv)
437{ 437{
438 struct v4l2_ctrl_handler *hdl = &dev->ctrl_handler; 438 struct v4l2_ctrl_handler *hdl = &dev->ctrl_handler;
439 struct v4l2_pix_format *fmt;
439 struct saa7146_vv *vv; 440 struct saa7146_vv *vv;
440 int err; 441 int err;
441 442
@@ -496,6 +497,15 @@ int saa7146_vv_init(struct saa7146_dev* dev, struct saa7146_ext_vv *ext_vv)
496 if (dev->ext_vv_data->capabilities & V4L2_CAP_VBI_CAPTURE) 497 if (dev->ext_vv_data->capabilities & V4L2_CAP_VBI_CAPTURE)
497 saa7146_vbi_uops.init(dev,vv); 498 saa7146_vbi_uops.init(dev,vv);
498 499
500 fmt = &vv->ov_fb.fmt;
501 fmt->width = vv->standard->h_max_out;
502 fmt->height = vv->standard->v_max_out;
503 fmt->pixelformat = V4L2_PIX_FMT_RGB565;
504 fmt->bytesperline = 2 * fmt->width;
505 fmt->sizeimage = fmt->bytesperline * fmt->height;
506 fmt->colorspace = V4L2_COLORSPACE_SRGB;
507 vv->ov_fb.capability = V4L2_FBUF_CAP_LIST_CLIPPING;
508 vv->ov_fb.flags = V4L2_FBUF_FLAG_PRIMARY;
499 dev->vv_data = vv; 509 dev->vv_data = vv;
500 dev->vv_callback = &vv_callback; 510 dev->vv_callback = &vv_callback;
501 511
diff --git a/drivers/media/common/saa7146_hlp.c b/drivers/media/common/saa7146_hlp.c
index bc1f545c95cb..be746d1aee9a 100644
--- a/drivers/media/common/saa7146_hlp.c
+++ b/drivers/media/common/saa7146_hlp.c
@@ -343,9 +343,9 @@ static void calculate_clipping_registers_rect(struct saa7146_dev *dev, struct sa
343 struct saa7146_vv *vv = dev->vv_data; 343 struct saa7146_vv *vv = dev->vv_data;
344 __le32 *clipping = vv->d_clipping.cpu_addr; 344 __le32 *clipping = vv->d_clipping.cpu_addr;
345 345
346 int width = fh->ov.win.w.width; 346 int width = vv->ov.win.w.width;
347 int height = fh->ov.win.w.height; 347 int height = vv->ov.win.w.height;
348 int clipcount = fh->ov.nclips; 348 int clipcount = vv->ov.nclips;
349 349
350 u32 line_list[32]; 350 u32 line_list[32];
351 u32 pixel_list[32]; 351 u32 pixel_list[32];
@@ -365,10 +365,10 @@ static void calculate_clipping_registers_rect(struct saa7146_dev *dev, struct sa
365 for(i = 0; i < clipcount; i++) { 365 for(i = 0; i < clipcount; i++) {
366 int l = 0, r = 0, t = 0, b = 0; 366 int l = 0, r = 0, t = 0, b = 0;
367 367
368 x[i] = fh->ov.clips[i].c.left; 368 x[i] = vv->ov.clips[i].c.left;
369 y[i] = fh->ov.clips[i].c.top; 369 y[i] = vv->ov.clips[i].c.top;
370 w[i] = fh->ov.clips[i].c.width; 370 w[i] = vv->ov.clips[i].c.width;
371 h[i] = fh->ov.clips[i].c.height; 371 h[i] = vv->ov.clips[i].c.height;
372 372
373 if( w[i] < 0) { 373 if( w[i] < 0) {
374 x[i] += w[i]; w[i] = -w[i]; 374 x[i] += w[i]; w[i] = -w[i];
@@ -485,13 +485,14 @@ static void saa7146_disable_clipping(struct saa7146_dev *dev)
485static void saa7146_set_clipping_rect(struct saa7146_fh *fh) 485static void saa7146_set_clipping_rect(struct saa7146_fh *fh)
486{ 486{
487 struct saa7146_dev *dev = fh->dev; 487 struct saa7146_dev *dev = fh->dev;
488 enum v4l2_field field = fh->ov.win.field; 488 struct saa7146_vv *vv = dev->vv_data;
489 enum v4l2_field field = vv->ov.win.field;
489 struct saa7146_video_dma vdma2; 490 struct saa7146_video_dma vdma2;
490 u32 clip_format; 491 u32 clip_format;
491 u32 arbtr_ctrl; 492 u32 arbtr_ctrl;
492 493
493 /* check clipcount, disable clipping if clipcount == 0*/ 494 /* check clipcount, disable clipping if clipcount == 0*/
494 if( fh->ov.nclips == 0 ) { 495 if (vv->ov.nclips == 0) {
495 saa7146_disable_clipping(dev); 496 saa7146_disable_clipping(dev);
496 return; 497 return;
497 } 498 }
@@ -651,8 +652,8 @@ int saa7146_enable_overlay(struct saa7146_fh *fh)
651 struct saa7146_dev *dev = fh->dev; 652 struct saa7146_dev *dev = fh->dev;
652 struct saa7146_vv *vv = dev->vv_data; 653 struct saa7146_vv *vv = dev->vv_data;
653 654
654 saa7146_set_window(dev, fh->ov.win.w.width, fh->ov.win.w.height, fh->ov.win.field); 655 saa7146_set_window(dev, vv->ov.win.w.width, vv->ov.win.w.height, vv->ov.win.field);
655 saa7146_set_position(dev, fh->ov.win.w.left, fh->ov.win.w.top, fh->ov.win.w.height, fh->ov.win.field, vv->ov_fmt->pixelformat); 656 saa7146_set_position(dev, vv->ov.win.w.left, vv->ov.win.w.top, vv->ov.win.w.height, vv->ov.win.field, vv->ov_fmt->pixelformat);
656 saa7146_set_output_format(dev, vv->ov_fmt->trans); 657 saa7146_set_output_format(dev, vv->ov_fmt->trans);
657 saa7146_set_clipping_rect(fh); 658 saa7146_set_clipping_rect(fh);
658 659
diff --git a/drivers/media/common/saa7146_video.c b/drivers/media/common/saa7146_video.c
index 8818e661a42f..e1b639b76e38 100644
--- a/drivers/media/common/saa7146_video.c
+++ b/drivers/media/common/saa7146_video.c
@@ -112,8 +112,8 @@ int saa7146_start_preview(struct saa7146_fh *fh)
112 112
113 DEB_EE("dev:%p, fh:%p\n", dev, fh); 113 DEB_EE("dev:%p, fh:%p\n", dev, fh);
114 114
115 /* check if we have overlay informations */ 115 /* check if we have overlay information */
116 if( NULL == fh->ov.fh ) { 116 if (vv->ov.fh == NULL) {
117 DEB_D("no overlay data available. try S_FMT first.\n"); 117 DEB_D("no overlay data available. try S_FMT first.\n");
118 return -EAGAIN; 118 return -EAGAIN;
119 } 119 }
@@ -139,19 +139,18 @@ int saa7146_start_preview(struct saa7146_fh *fh)
139 return -EBUSY; 139 return -EBUSY;
140 } 140 }
141 141
142 fmt.fmt.win = fh->ov.win; 142 fmt.fmt.win = vv->ov.win;
143 err = vidioc_try_fmt_vid_overlay(NULL, fh, &fmt); 143 err = vidioc_try_fmt_vid_overlay(NULL, fh, &fmt);
144 if (0 != err) { 144 if (0 != err) {
145 saa7146_res_free(vv->video_fh, RESOURCE_DMA1_HPS|RESOURCE_DMA2_CLP); 145 saa7146_res_free(vv->video_fh, RESOURCE_DMA1_HPS|RESOURCE_DMA2_CLP);
146 return -EBUSY; 146 return -EBUSY;
147 } 147 }
148 fh->ov.win = fmt.fmt.win; 148 vv->ov.win = fmt.fmt.win;
149 vv->ov_data = &fh->ov;
150 149
151 DEB_D("%dx%d+%d+%d %s field=%s\n", 150 DEB_D("%dx%d+%d+%d %s field=%s\n",
152 fh->ov.win.w.width, fh->ov.win.w.height, 151 vv->ov.win.w.width, vv->ov.win.w.height,
153 fh->ov.win.w.left, fh->ov.win.w.top, 152 vv->ov.win.w.left, vv->ov.win.w.top,
154 vv->ov_fmt->name, v4l2_field_names[fh->ov.win.field]); 153 vv->ov_fmt->name, v4l2_field_names[vv->ov.win.field]);
155 154
156 if (0 != (ret = saa7146_enable_overlay(fh))) { 155 if (0 != (ret = saa7146_enable_overlay(fh))) {
157 DEB_D("enabling overlay failed: %d\n", ret); 156 DEB_D("enabling overlay failed: %d\n", ret);
@@ -468,6 +467,7 @@ static int vidioc_g_fbuf(struct file *file, void *fh, struct v4l2_framebuffer *f
468 467
469 *fb = vv->ov_fb; 468 *fb = vv->ov_fb;
470 fb->capability = V4L2_FBUF_CAP_LIST_CLIPPING; 469 fb->capability = V4L2_FBUF_CAP_LIST_CLIPPING;
470 fb->flags = V4L2_FBUF_FLAG_PRIMARY;
471 return 0; 471 return 0;
472} 472}
473 473
@@ -601,7 +601,10 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format
601 601
602static int vidioc_g_fmt_vid_overlay(struct file *file, void *fh, struct v4l2_format *f) 602static int vidioc_g_fmt_vid_overlay(struct file *file, void *fh, struct v4l2_format *f)
603{ 603{
604 f->fmt.win = ((struct saa7146_fh *)fh)->ov.win; 604 struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev;
605 struct saa7146_vv *vv = dev->vv_data;
606
607 f->fmt.win = vv->ov.win;
605 return 0; 608 return 0;
606} 609}
607 610
@@ -768,17 +771,17 @@ static int vidioc_s_fmt_vid_overlay(struct file *file, void *__fh, struct v4l2_f
768 err = vidioc_try_fmt_vid_overlay(file, fh, f); 771 err = vidioc_try_fmt_vid_overlay(file, fh, f);
769 if (0 != err) 772 if (0 != err)
770 return err; 773 return err;
771 fh->ov.win = f->fmt.win; 774 vv->ov.win = f->fmt.win;
772 fh->ov.nclips = f->fmt.win.clipcount; 775 vv->ov.nclips = f->fmt.win.clipcount;
773 if (fh->ov.nclips > 16) 776 if (vv->ov.nclips > 16)
774 fh->ov.nclips = 16; 777 vv->ov.nclips = 16;
775 if (copy_from_user(fh->ov.clips, f->fmt.win.clips, 778 if (copy_from_user(vv->ov.clips, f->fmt.win.clips,
776 sizeof(struct v4l2_clip) * fh->ov.nclips)) { 779 sizeof(struct v4l2_clip) * vv->ov.nclips)) {
777 return -EFAULT; 780 return -EFAULT;
778 } 781 }
779 782
780 /* fh->ov.fh is used to indicate that we have valid overlay informations, too */ 783 /* vv->ov.fh is used to indicate that we have valid overlay informations, too */
781 fh->ov.fh = fh; 784 vv->ov.fh = fh;
782 785
783 /* check if our current overlay is active */ 786 /* check if our current overlay is active */
784 if (IS_OVERLAY_ACTIVE(fh) != 0) { 787 if (IS_OVERLAY_ACTIVE(fh) != 0) {