Commit 5da545ad08a3c6ea71d3ba074adc7582e7e9a024
Committed by
Mauro Carvalho Chehab
1 parent
4894b709d1
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
[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>
Showing 4 changed files with 43 additions and 32 deletions Side-by-side Diff
drivers/media/common/saa7146_fops.c
... | ... | @@ -436,6 +436,7 @@ |
436 | 436 | int saa7146_vv_init(struct saa7146_dev* dev, struct saa7146_ext_vv *ext_vv) |
437 | 437 | { |
438 | 438 | struct v4l2_ctrl_handler *hdl = &dev->ctrl_handler; |
439 | + struct v4l2_pix_format *fmt; | |
439 | 440 | struct saa7146_vv *vv; |
440 | 441 | int err; |
441 | 442 | |
... | ... | @@ -496,6 +497,15 @@ |
496 | 497 | if (dev->ext_vv_data->capabilities & V4L2_CAP_VBI_CAPTURE) |
497 | 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 | 509 | dev->vv_data = vv; |
500 | 510 | dev->vv_callback = &vv_callback; |
501 | 511 |
drivers/media/common/saa7146_hlp.c
... | ... | @@ -343,9 +343,9 @@ |
343 | 343 | struct saa7146_vv *vv = dev->vv_data; |
344 | 344 | __le32 *clipping = vv->d_clipping.cpu_addr; |
345 | 345 | |
346 | - int width = fh->ov.win.w.width; | |
347 | - int height = fh->ov.win.w.height; | |
348 | - int clipcount = fh->ov.nclips; | |
346 | + int width = vv->ov.win.w.width; | |
347 | + int height = vv->ov.win.w.height; | |
348 | + int clipcount = vv->ov.nclips; | |
349 | 349 | |
350 | 350 | u32 line_list[32]; |
351 | 351 | u32 pixel_list[32]; |
... | ... | @@ -365,10 +365,10 @@ |
365 | 365 | for(i = 0; i < clipcount; i++) { |
366 | 366 | int l = 0, r = 0, t = 0, b = 0; |
367 | 367 | |
368 | - x[i] = fh->ov.clips[i].c.left; | |
369 | - y[i] = fh->ov.clips[i].c.top; | |
370 | - w[i] = fh->ov.clips[i].c.width; | |
371 | - h[i] = fh->ov.clips[i].c.height; | |
368 | + x[i] = vv->ov.clips[i].c.left; | |
369 | + y[i] = vv->ov.clips[i].c.top; | |
370 | + w[i] = vv->ov.clips[i].c.width; | |
371 | + h[i] = vv->ov.clips[i].c.height; | |
372 | 372 | |
373 | 373 | if( w[i] < 0) { |
374 | 374 | x[i] += w[i]; w[i] = -w[i]; |
375 | 375 | |
... | ... | @@ -485,13 +485,14 @@ |
485 | 485 | static void saa7146_set_clipping_rect(struct saa7146_fh *fh) |
486 | 486 | { |
487 | 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 | 490 | struct saa7146_video_dma vdma2; |
490 | 491 | u32 clip_format; |
491 | 492 | u32 arbtr_ctrl; |
492 | 493 | |
493 | 494 | /* check clipcount, disable clipping if clipcount == 0*/ |
494 | - if( fh->ov.nclips == 0 ) { | |
495 | + if (vv->ov.nclips == 0) { | |
495 | 496 | saa7146_disable_clipping(dev); |
496 | 497 | return; |
497 | 498 | } |
... | ... | @@ -651,8 +652,8 @@ |
651 | 652 | struct saa7146_dev *dev = fh->dev; |
652 | 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_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); | |
655 | + saa7146_set_window(dev, vv->ov.win.w.width, vv->ov.win.w.height, vv->ov.win.field); | |
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 | 657 | saa7146_set_output_format(dev, vv->ov_fmt->trans); |
657 | 658 | saa7146_set_clipping_rect(fh); |
658 | 659 |
drivers/media/common/saa7146_video.c
... | ... | @@ -112,8 +112,8 @@ |
112 | 112 | |
113 | 113 | DEB_EE("dev:%p, fh:%p\n", dev, fh); |
114 | 114 | |
115 | - /* check if we have overlay informations */ | |
116 | - if( NULL == fh->ov.fh ) { | |
115 | + /* check if we have overlay information */ | |
116 | + if (vv->ov.fh == NULL) { | |
117 | 117 | DEB_D("no overlay data available. try S_FMT first.\n"); |
118 | 118 | return -EAGAIN; |
119 | 119 | } |
120 | 120 | |
121 | 121 | |
... | ... | @@ -139,19 +139,18 @@ |
139 | 139 | return -EBUSY; |
140 | 140 | } |
141 | 141 | |
142 | - fmt.fmt.win = fh->ov.win; | |
142 | + fmt.fmt.win = vv->ov.win; | |
143 | 143 | err = vidioc_try_fmt_vid_overlay(NULL, fh, &fmt); |
144 | 144 | if (0 != err) { |
145 | 145 | saa7146_res_free(vv->video_fh, RESOURCE_DMA1_HPS|RESOURCE_DMA2_CLP); |
146 | 146 | return -EBUSY; |
147 | 147 | } |
148 | - fh->ov.win = fmt.fmt.win; | |
149 | - vv->ov_data = &fh->ov; | |
148 | + vv->ov.win = fmt.fmt.win; | |
150 | 149 | |
151 | 150 | DEB_D("%dx%d+%d+%d %s field=%s\n", |
152 | - fh->ov.win.w.width, fh->ov.win.w.height, | |
153 | - fh->ov.win.w.left, fh->ov.win.w.top, | |
154 | - vv->ov_fmt->name, v4l2_field_names[fh->ov.win.field]); | |
151 | + vv->ov.win.w.width, vv->ov.win.w.height, | |
152 | + vv->ov.win.w.left, vv->ov.win.w.top, | |
153 | + vv->ov_fmt->name, v4l2_field_names[vv->ov.win.field]); | |
155 | 154 | |
156 | 155 | if (0 != (ret = saa7146_enable_overlay(fh))) { |
157 | 156 | DEB_D("enabling overlay failed: %d\n", ret); |
... | ... | @@ -468,6 +467,7 @@ |
468 | 467 | |
469 | 468 | *fb = vv->ov_fb; |
470 | 469 | fb->capability = V4L2_FBUF_CAP_LIST_CLIPPING; |
470 | + fb->flags = V4L2_FBUF_FLAG_PRIMARY; | |
471 | 471 | return 0; |
472 | 472 | } |
473 | 473 | |
... | ... | @@ -601,7 +601,10 @@ |
601 | 601 | |
602 | 602 | static 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 | 608 | return 0; |
606 | 609 | } |
607 | 610 | |
608 | 611 | |
... | ... | @@ -768,17 +771,17 @@ |
768 | 771 | err = vidioc_try_fmt_vid_overlay(file, fh, f); |
769 | 772 | if (0 != err) |
770 | 773 | return err; |
771 | - fh->ov.win = f->fmt.win; | |
772 | - fh->ov.nclips = f->fmt.win.clipcount; | |
773 | - if (fh->ov.nclips > 16) | |
774 | - fh->ov.nclips = 16; | |
775 | - if (copy_from_user(fh->ov.clips, f->fmt.win.clips, | |
776 | - sizeof(struct v4l2_clip) * fh->ov.nclips)) { | |
774 | + vv->ov.win = f->fmt.win; | |
775 | + vv->ov.nclips = f->fmt.win.clipcount; | |
776 | + if (vv->ov.nclips > 16) | |
777 | + vv->ov.nclips = 16; | |
778 | + if (copy_from_user(vv->ov.clips, f->fmt.win.clips, | |
779 | + sizeof(struct v4l2_clip) * vv->ov.nclips)) { | |
777 | 780 | return -EFAULT; |
778 | 781 | } |
779 | 782 | |
780 | - /* fh->ov.fh is used to indicate that we have valid overlay informations, too */ | |
781 | - fh->ov.fh = fh; | |
783 | + /* vv->ov.fh is used to indicate that we have valid overlay informations, too */ | |
784 | + vv->ov.fh = fh; | |
782 | 785 | |
783 | 786 | /* check if our current overlay is active */ |
784 | 787 | if (IS_OVERLAY_ACTIVE(fh) != 0) { |
include/media/saa7146_vv.h
... | ... | @@ -88,9 +88,6 @@ |
88 | 88 | /* if this is a vbi or capture open */ |
89 | 89 | enum v4l2_buf_type type; |
90 | 90 | |
91 | - /* video overlay */ | |
92 | - struct saa7146_overlay ov; | |
93 | - | |
94 | 91 | /* video capture */ |
95 | 92 | struct videobuf_queue video_q; |
96 | 93 | struct v4l2_pix_format video_fmt; |
97 | 94 | |
... | ... | @@ -119,9 +116,9 @@ |
119 | 116 | struct saa7146_fh *video_fh; |
120 | 117 | |
121 | 118 | /* video overlay */ |
119 | + struct saa7146_overlay ov; | |
122 | 120 | struct v4l2_framebuffer ov_fb; |
123 | 121 | struct saa7146_format *ov_fmt; |
124 | - struct saa7146_overlay *ov_data; | |
125 | 122 | struct saa7146_fh *ov_suspend; |
126 | 123 | |
127 | 124 | /* video capture */ |