Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: staging: media: av7110: fix VBI output support

With these changes it now passes the v4l2-compliance test.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
5fe4230d c116a5c6

+60 -38
+60 -38
drivers/staging/media/av7110/av7110_v4l.c
··· 473 473 return av7110_dvb_c_switch(dev); 474 474 } 475 475 476 + static int vidioc_enum_output(struct file *file, void *fh, struct v4l2_output *o) 477 + { 478 + if (o->index) 479 + return -EINVAL; 480 + strscpy(o->name, "Video Output", sizeof(o->name)); 481 + o->type = V4L2_OUTPUT_TYPE_ANALOG; 482 + o->std = V4L2_STD_NTSC_M | V4L2_STD_PAL_BG; 483 + o->capabilities = V4L2_OUT_CAP_STD; 484 + return 0; 485 + } 486 + 487 + static int vidioc_g_output(struct file *file, void *fh, unsigned int *output) 488 + { 489 + *output = 0; 490 + return 0; 491 + } 492 + 493 + static int vidioc_s_output(struct file *file, void *fh, unsigned int output) 494 + { 495 + return output ? -EINVAL : 0; 496 + } 497 + 476 498 static int vidioc_enumaudio(struct file *file, void *fh, struct v4l2_audio *a) 477 499 { 478 500 dprintk(2, "VIDIOC_G_AUDIO: %d\n", a->index); ··· 558 536 if (av7110->wssMode) { 559 537 f->fmt.sliced.service_set = V4L2_SLICED_WSS_625; 560 538 f->fmt.sliced.service_lines[0][23] = V4L2_SLICED_WSS_625; 561 - f->fmt.sliced.io_size = sizeof(struct v4l2_sliced_vbi_data); 562 539 } 540 + f->fmt.sliced.io_size = sizeof(struct v4l2_sliced_vbi_data); 541 + return 0; 542 + } 543 + 544 + static int vidioc_try_fmt_sliced_vbi_out(struct file *file, void *fh, 545 + struct v4l2_format *f) 546 + { 547 + struct saa7146_dev *dev = video_drvdata(file); 548 + struct av7110 *av7110 = (struct av7110 *)dev->ext_priv; 549 + bool want_wss = (f->fmt.sliced.service_set & V4L2_SLICED_WSS_625) || 550 + (!f->fmt.sliced.service_set && 551 + f->fmt.sliced.service_lines[0][23] == V4L2_SLICED_WSS_625); 552 + 553 + dprintk(2, "VIDIOC_G_FMT:\n"); 554 + if (FW_VERSION(av7110->arm_app) < 0x2623) 555 + return -EINVAL; 556 + memset(&f->fmt.sliced, 0, sizeof(f->fmt.sliced)); 557 + if (want_wss) { 558 + f->fmt.sliced.service_set = V4L2_SLICED_WSS_625; 559 + f->fmt.sliced.service_lines[0][23] = V4L2_SLICED_WSS_625; 560 + } 561 + f->fmt.sliced.io_size = sizeof(struct v4l2_sliced_vbi_data); 563 562 return 0; 564 563 } 565 564 ··· 591 548 struct av7110 *av7110 = (struct av7110 *)dev->ext_priv; 592 549 593 550 dprintk(2, "VIDIOC_S_FMT\n"); 594 - if (FW_VERSION(av7110->arm_app) < 0x2623) 551 + if (vidioc_try_fmt_sliced_vbi_out(file, fh, f)) 595 552 return -EINVAL; 596 - if (f->fmt.sliced.service_set != V4L2_SLICED_WSS_625 && 597 - f->fmt.sliced.service_lines[0][23] != V4L2_SLICED_WSS_625) { 598 - memset(&f->fmt.sliced, 0, sizeof(f->fmt.sliced)); 553 + if (f->fmt.sliced.service_set & V4L2_SLICED_WSS_625) { 554 + /* WSS controlled by userspace */ 555 + av7110->wssMode = 1; 556 + av7110->wssData = 0; 557 + } else { 599 558 /* WSS controlled by firmware */ 600 559 av7110->wssMode = 0; 601 560 av7110->wssData = 0; 602 561 return av7110_fw_cmd(av7110, COMTYPE_ENCODER, 603 562 SetWSSConfig, 1, 0); 604 - } else { 605 - memset(&f->fmt.sliced, 0, sizeof(f->fmt.sliced)); 606 - f->fmt.sliced.service_set = V4L2_SLICED_WSS_625; 607 - f->fmt.sliced.service_lines[0][23] = V4L2_SLICED_WSS_625; 608 - f->fmt.sliced.io_size = sizeof(struct v4l2_sliced_vbi_data); 609 - /* WSS controlled by userspace */ 610 - av7110->wssMode = 1; 611 - av7110->wssData = 0; 612 563 } 613 564 return 0; 614 - } 615 - 616 - static int av7110_vbi_reset(struct file *file) 617 - { 618 - struct saa7146_dev *dev = video_drvdata(file); 619 - struct av7110 *av7110 = (struct av7110*) dev->ext_priv; 620 - 621 - dprintk(2, "%s\n", __func__); 622 - av7110->wssMode = 0; 623 - av7110->wssData = 0; 624 - if (FW_VERSION(av7110->arm_app) < 0x2623) 625 - return 0; 626 - else 627 - return av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetWSSConfig, 1, 0); 628 565 } 629 566 630 567 static ssize_t av7110_vbi_write(struct file *file, const char __user *data, size_t count, loff_t *ppos) ··· 824 801 vv_data->vid_ops.vidioc_s_audio = vidioc_s_audio; 825 802 vv_data->vid_ops.vidioc_g_fmt_vbi_cap = NULL; 826 803 827 - vv_data->vbi_ops.vidioc_g_tuner = vidioc_g_tuner; 828 - vv_data->vbi_ops.vidioc_s_tuner = vidioc_s_tuner; 829 - vv_data->vbi_ops.vidioc_g_frequency = vidioc_g_frequency; 830 - vv_data->vbi_ops.vidioc_s_frequency = vidioc_s_frequency; 804 + vv_data->vbi_ops.vidioc_enum_output = vidioc_enum_output; 805 + vv_data->vbi_ops.vidioc_g_output = vidioc_g_output; 806 + vv_data->vbi_ops.vidioc_s_output = vidioc_s_output; 807 + vv_data->vbi_ops.vidioc_g_parm = NULL; 831 808 vv_data->vbi_ops.vidioc_g_fmt_vbi_cap = NULL; 809 + vv_data->vbi_ops.vidioc_try_fmt_vbi_cap = NULL; 810 + vv_data->vbi_ops.vidioc_s_fmt_vbi_cap = NULL; 832 811 vv_data->vbi_ops.vidioc_g_sliced_vbi_cap = vidioc_g_sliced_vbi_cap; 833 812 vv_data->vbi_ops.vidioc_g_fmt_sliced_vbi_out = vidioc_g_fmt_sliced_vbi_out; 813 + vv_data->vbi_ops.vidioc_try_fmt_sliced_vbi_out = vidioc_try_fmt_sliced_vbi_out; 834 814 vv_data->vbi_ops.vidioc_s_fmt_sliced_vbi_out = vidioc_s_fmt_sliced_vbi_out; 835 815 836 816 if (FW_VERSION(av7110->arm_app) < 0x2623) ··· 874 848 .h_offset = 0x48, .h_pixels = 708, 875 849 .v_max_out = 576, .h_max_out = 768, 876 850 }, { 877 - .name = "NTSC", .id = V4L2_STD_NTSC, 851 + .name = "NTSC", .id = V4L2_STD_NTSC_M, 878 852 .v_offset = 0x10, .v_field = 244, 879 853 .h_offset = 0x40, .h_pixels = 708, 880 854 .v_max_out = 480, .h_max_out = 640, ··· 888 862 .h_offset = 0x08, .h_pixels = 708, 889 863 .v_max_out = 576, .h_max_out = 768, 890 864 }, { 891 - .name = "NTSC", .id = V4L2_STD_NTSC, 865 + .name = "NTSC", .id = V4L2_STD_NTSC_M, 892 866 .v_offset = 0x10, .v_field = 244, 893 867 .h_offset = 0x40, .h_pixels = 708, 894 868 .v_max_out = 480, .h_max_out = 640, ··· 902 876 .h_offset = 0x48, .h_pixels = 708, 903 877 .v_max_out = 576, .h_max_out = 768, 904 878 }, { 905 - .name = "NTSC", .id = V4L2_STD_NTSC, 879 + .name = "NTSC", .id = V4L2_STD_NTSC_M, 906 880 .v_offset = 0x10, .v_field = 244, 907 881 .h_offset = 0x40, .h_pixels = 708, 908 882 .v_max_out = 480, .h_max_out = 640, ··· 938 912 .num_stds = ARRAY_SIZE(standard), 939 913 .std_callback = &std_callback, 940 914 941 - .vbi_fops.open = av7110_vbi_reset, 942 - .vbi_fops.release = av7110_vbi_reset, 943 915 .vbi_fops.write = av7110_vbi_write, 944 916 }; 945 917 ··· 951 927 .num_stds = ARRAY_SIZE(standard), 952 928 .std_callback = &std_callback, 953 929 954 - .vbi_fops.open = av7110_vbi_reset, 955 - .vbi_fops.release = av7110_vbi_reset, 956 930 .vbi_fops.write = av7110_vbi_write, 957 931 }; 958 932