aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/ivtv/ivtv-ioctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/ivtv/ivtv-ioctl.c')
-rw-r--r--drivers/media/video/ivtv/ivtv-ioctl.c58
1 files changed, 25 insertions, 33 deletions
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c
index 61030309d0ad..8696527ab134 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.c
+++ b/drivers/media/video/ivtv/ivtv-ioctl.c
@@ -101,18 +101,15 @@ void ivtv_expand_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal)
101 } 101 }
102} 102}
103 103
104static int check_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal) 104static void check_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal)
105{ 105{
106 int f, l; 106 int f, l;
107 u16 set = 0;
108 107
109 for (f = 0; f < 2; f++) { 108 for (f = 0; f < 2; f++) {
110 for (l = 0; l < 24; l++) { 109 for (l = 0; l < 24; l++) {
111 fmt->service_lines[f][l] = select_service_from_set(f, l, fmt->service_lines[f][l], is_pal); 110 fmt->service_lines[f][l] = select_service_from_set(f, l, fmt->service_lines[f][l], is_pal);
112 set |= fmt->service_lines[f][l];
113 } 111 }
114 } 112 }
115 return set != 0;
116} 113}
117 114
118u16 ivtv_get_service_set(struct v4l2_sliced_vbi_format *fmt) 115u16 ivtv_get_service_set(struct v4l2_sliced_vbi_format *fmt)
@@ -474,7 +471,7 @@ static int ivtv_try_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format
474 int h = fmt->fmt.pix.height; 471 int h = fmt->fmt.pix.height;
475 472
476 w = min(w, 720); 473 w = min(w, 720);
477 w = max(w, 1); 474 w = max(w, 2);
478 h = min(h, itv->is_50hz ? 576 : 480); 475 h = min(h, itv->is_50hz ? 576 : 480);
479 h = max(h, 2); 476 h = max(h, 2);
480 ivtv_g_fmt_vid_cap(file, fh, fmt); 477 ivtv_g_fmt_vid_cap(file, fh, fmt);
@@ -512,27 +509,20 @@ static int ivtv_try_fmt_sliced_vbi_cap(struct file *file, void *fh, struct v4l2_
512static int ivtv_try_fmt_vid_out(struct file *file, void *fh, struct v4l2_format *fmt) 509static int ivtv_try_fmt_vid_out(struct file *file, void *fh, struct v4l2_format *fmt)
513{ 510{
514 struct ivtv_open_id *id = fh; 511 struct ivtv_open_id *id = fh;
515 s32 w, h; 512 struct ivtv *itv = id->itv;
516 int field; 513 s32 w = fmt->fmt.pix.width;
517 int ret; 514 s32 h = fmt->fmt.pix.height;
515 int field = fmt->fmt.pix.field;
516 int ret = ivtv_g_fmt_vid_out(file, fh, fmt);
518 517
519 w = fmt->fmt.pix.width; 518 w = min(w, 720);
520 h = fmt->fmt.pix.height; 519 w = max(w, 2);
521 field = fmt->fmt.pix.field; 520 h = min(h, itv->is_out_50hz ? 576 : 480);
522 ret = ivtv_g_fmt_vid_out(file, fh, fmt); 521 h = max(h, 2);
522 if (id->type == IVTV_DEC_STREAM_TYPE_YUV)
523 fmt->fmt.pix.field = field;
523 fmt->fmt.pix.width = w; 524 fmt->fmt.pix.width = w;
524 fmt->fmt.pix.height = h; 525 fmt->fmt.pix.height = h;
525 if (!ret && id->type == IVTV_DEC_STREAM_TYPE_YUV) {
526 fmt->fmt.pix.field = field;
527 if (fmt->fmt.pix.width < 2)
528 fmt->fmt.pix.width = 2;
529 if (fmt->fmt.pix.width > 720)
530 fmt->fmt.pix.width = 720;
531 if (fmt->fmt.pix.height < 2)
532 fmt->fmt.pix.height = 2;
533 if (fmt->fmt.pix.height > 576)
534 fmt->fmt.pix.height = 576;
535 }
536 return ret; 526 return ret;
537} 527}
538 528
@@ -560,9 +550,9 @@ static int ivtv_s_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f
560 struct ivtv_open_id *id = fh; 550 struct ivtv_open_id *id = fh;
561 struct ivtv *itv = id->itv; 551 struct ivtv *itv = id->itv;
562 struct cx2341x_mpeg_params *p = &itv->params; 552 struct cx2341x_mpeg_params *p = &itv->params;
553 int ret = ivtv_try_fmt_vid_cap(file, fh, fmt);
563 int w = fmt->fmt.pix.width; 554 int w = fmt->fmt.pix.width;
564 int h = fmt->fmt.pix.height; 555 int h = fmt->fmt.pix.height;
565 int ret = ivtv_try_fmt_vid_cap(file, fh, fmt);
566 556
567 if (ret) 557 if (ret)
568 return ret; 558 return ret;
@@ -585,8 +575,11 @@ static int ivtv_s_fmt_vbi_cap(struct file *file, void *fh, struct v4l2_format *f
585{ 575{
586 struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv; 576 struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
587 577
578 if (!ivtv_raw_vbi(itv) && atomic_read(&itv->capturing) > 0)
579 return -EBUSY;
588 itv->vbi.sliced_in->service_set = 0; 580 itv->vbi.sliced_in->service_set = 0;
589 itv->video_dec_func(itv, VIDIOC_S_FMT, &itv->vbi.in); 581 itv->vbi.in.type = V4L2_BUF_TYPE_VBI_CAPTURE;
582 itv->video_dec_func(itv, VIDIOC_S_FMT, fmt);
590 return ivtv_g_fmt_vbi_cap(file, fh, fmt); 583 return ivtv_g_fmt_vbi_cap(file, fh, fmt);
591} 584}
592 585
@@ -600,10 +593,10 @@ static int ivtv_s_fmt_sliced_vbi_cap(struct file *file, void *fh, struct v4l2_fo
600 if (ret || id->type == IVTV_DEC_STREAM_TYPE_VBI) 593 if (ret || id->type == IVTV_DEC_STREAM_TYPE_VBI)
601 return ret; 594 return ret;
602 595
603 if (check_service_set(vbifmt, itv->is_50hz) == 0) 596 check_service_set(vbifmt, itv->is_50hz);
604 return -EINVAL; 597 if (ivtv_raw_vbi(itv) && atomic_read(&itv->capturing) > 0)
605 if (atomic_read(&itv->capturing) > 0)
606 return -EBUSY; 598 return -EBUSY;
599 itv->vbi.in.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE;
607 itv->video_dec_func(itv, VIDIOC_S_FMT, fmt); 600 itv->video_dec_func(itv, VIDIOC_S_FMT, fmt);
608 memcpy(itv->vbi.sliced_in, vbifmt, sizeof(*itv->vbi.sliced_in)); 601 memcpy(itv->vbi.sliced_in, vbifmt, sizeof(*itv->vbi.sliced_in));
609 return 0; 602 return 0;
@@ -651,8 +644,6 @@ static int ivtv_s_fmt_vid_out(struct file *file, void *fh, struct v4l2_format *f
651 itv->dma_data_req_size = 644 itv->dma_data_req_size =
652 1080 * ((yi->v4l2_src_h + 31) & ~31); 645 1080 * ((yi->v4l2_src_h + 31) & ~31);
653 646
654 /* Force update of yuv registers */
655 yi->yuv_forced_update = 1;
656 return 0; 647 return 0;
657} 648}
658 649
@@ -761,7 +752,7 @@ static int ivtv_querycap(struct file *file, void *fh, struct v4l2_capability *vc
761 752
762 strlcpy(vcap->driver, IVTV_DRIVER_NAME, sizeof(vcap->driver)); 753 strlcpy(vcap->driver, IVTV_DRIVER_NAME, sizeof(vcap->driver));
763 strlcpy(vcap->card, itv->card_name, sizeof(vcap->card)); 754 strlcpy(vcap->card, itv->card_name, sizeof(vcap->card));
764 strlcpy(vcap->bus_info, pci_name(itv->dev), sizeof(vcap->bus_info)); 755 snprintf(vcap->bus_info, sizeof(vcap->bus_info), "PCI:%s", pci_name(itv->dev));
765 vcap->version = IVTV_DRIVER_VERSION; /* version */ 756 vcap->version = IVTV_DRIVER_VERSION; /* version */
766 vcap->capabilities = itv->v4l2_cap; /* capabilities */ 757 vcap->capabilities = itv->v4l2_cap; /* capabilities */
767 return 0; 758 return 0;
@@ -1370,6 +1361,9 @@ static int ivtv_g_fbuf(struct file *file, void *fh, struct v4l2_framebuffer *fb)
1370 if (itv->osd_global_alpha_state) 1361 if (itv->osd_global_alpha_state)
1371 fb->flags |= V4L2_FBUF_FLAG_GLOBAL_ALPHA; 1362 fb->flags |= V4L2_FBUF_FLAG_GLOBAL_ALPHA;
1372 1363
1364 if (yi->track_osd)
1365 fb->flags |= V4L2_FBUF_FLAG_OVERLAY;
1366
1373 pixfmt &= 7; 1367 pixfmt &= 7;
1374 1368
1375 /* no local alpha for RGB565 or unknown formats */ 1369 /* no local alpha for RGB565 or unknown formats */
@@ -1389,8 +1383,6 @@ static int ivtv_g_fbuf(struct file *file, void *fh, struct v4l2_framebuffer *fb)
1389 else 1383 else
1390 fb->flags |= V4L2_FBUF_FLAG_LOCAL_ALPHA; 1384 fb->flags |= V4L2_FBUF_FLAG_LOCAL_ALPHA;
1391 } 1385 }
1392 if (yi->track_osd)
1393 fb->flags |= V4L2_FBUF_FLAG_OVERLAY;
1394 1386
1395 return 0; 1387 return 0;
1396} 1388}