@@ -473,6 +473,28 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input)
473473 return av7110_dvb_c_switch (dev );
474474}
475475
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+
476498static int vidioc_enumaudio (struct file * file , void * fh , struct v4l2_audio * a )
477499{
478500 dprintk (2 , "VIDIOC_G_AUDIO: %d\n" , a -> index );
@@ -536,52 +558,53 @@ static int vidioc_g_fmt_sliced_vbi_out(struct file *file, void *fh,
536558 if (av7110 -> wssMode ) {
537559 f -> fmt .sliced .service_set = V4L2_SLICED_WSS_625 ;
538560 f -> fmt .sliced .service_lines [0 ][23 ] = V4L2_SLICED_WSS_625 ;
539- f -> fmt .sliced .io_size = sizeof (struct v4l2_sliced_vbi_data );
540561 }
562+ f -> fmt .sliced .io_size = sizeof (struct v4l2_sliced_vbi_data );
541563 return 0 ;
542564}
543565
544- static int vidioc_s_fmt_sliced_vbi_out (struct file * file , void * fh ,
545- struct v4l2_format * f )
566+ static int vidioc_try_fmt_sliced_vbi_out (struct file * file , void * fh ,
567+ struct v4l2_format * f )
546568{
547569 struct saa7146_dev * dev = video_drvdata (file );
548570 struct av7110 * av7110 = (struct av7110 * )dev -> ext_priv ;
571+ bool want_wss = (f -> fmt .sliced .service_set & V4L2_SLICED_WSS_625 ) ||
572+ (!f -> fmt .sliced .service_set &&
573+ f -> fmt .sliced .service_lines [0 ][23 ] == V4L2_SLICED_WSS_625 );
549574
550- dprintk (2 , "VIDIOC_S_FMT \n" );
575+ dprintk (2 , "VIDIOC_G_FMT: \n" );
551576 if (FW_VERSION (av7110 -> arm_app ) < 0x2623 )
552577 return - EINVAL ;
553- if (f -> fmt .sliced .service_set != V4L2_SLICED_WSS_625 &&
554- f -> fmt .sliced .service_lines [0 ][23 ] != V4L2_SLICED_WSS_625 ) {
555- memset (& f -> fmt .sliced , 0 , sizeof (f -> fmt .sliced ));
556- /* WSS controlled by firmware */
557- av7110 -> wssMode = 0 ;
558- av7110 -> wssData = 0 ;
559- return av7110_fw_cmd (av7110 , COMTYPE_ENCODER ,
560- SetWSSConfig , 1 , 0 );
561- } else {
562- memset (& f -> fmt .sliced , 0 , sizeof (f -> fmt .sliced ));
578+ memset (& f -> fmt .sliced , 0 , sizeof (f -> fmt .sliced ));
579+ if (want_wss ) {
563580 f -> fmt .sliced .service_set = V4L2_SLICED_WSS_625 ;
564581 f -> fmt .sliced .service_lines [0 ][23 ] = V4L2_SLICED_WSS_625 ;
565- f -> fmt .sliced .io_size = sizeof (struct v4l2_sliced_vbi_data );
566- /* WSS controlled by userspace */
567- av7110 -> wssMode = 1 ;
568- av7110 -> wssData = 0 ;
569582 }
583+ f -> fmt .sliced .io_size = sizeof (struct v4l2_sliced_vbi_data );
570584 return 0 ;
571585}
572586
573- static int av7110_vbi_reset (struct file * file )
587+ static int vidioc_s_fmt_sliced_vbi_out (struct file * file , void * fh ,
588+ struct v4l2_format * f )
574589{
575590 struct saa7146_dev * dev = video_drvdata (file );
576- struct av7110 * av7110 = (struct av7110 * ) dev -> ext_priv ;
591+ struct av7110 * av7110 = (struct av7110 * ) dev -> ext_priv ;
577592
578- dprintk (2 , "%s\n" , __func__ );
579- av7110 -> wssMode = 0 ;
580- av7110 -> wssData = 0 ;
581- if (FW_VERSION (av7110 -> arm_app ) < 0x2623 )
582- return 0 ;
583- else
584- return av7110_fw_cmd (av7110 , COMTYPE_ENCODER , SetWSSConfig , 1 , 0 );
593+ dprintk (2 , "VIDIOC_S_FMT\n" );
594+ if (vidioc_try_fmt_sliced_vbi_out (file , fh , f ))
595+ return - EINVAL ;
596+ if (f -> fmt .sliced .service_set & V4L2_SLICED_WSS_625 ) {
597+ /* WSS controlled by userspace */
598+ av7110 -> wssMode = 1 ;
599+ av7110 -> wssData = 0 ;
600+ } else {
601+ /* WSS controlled by firmware */
602+ av7110 -> wssMode = 0 ;
603+ av7110 -> wssData = 0 ;
604+ return av7110_fw_cmd (av7110 , COMTYPE_ENCODER ,
605+ SetWSSConfig , 1 , 0 );
606+ }
607+ return 0 ;
585608}
586609
587610static ssize_t av7110_vbi_write (struct file * file , const char __user * data , size_t count , loff_t * ppos )
@@ -801,13 +824,16 @@ int av7110_init_v4l(struct av7110 *av7110)
801824 vv_data -> vid_ops .vidioc_s_audio = vidioc_s_audio ;
802825 vv_data -> vid_ops .vidioc_g_fmt_vbi_cap = NULL ;
803826
804- vv_data -> vbi_ops .vidioc_g_tuner = vidioc_g_tuner ;
805- vv_data -> vbi_ops .vidioc_s_tuner = vidioc_s_tuner ;
806- vv_data -> vbi_ops .vidioc_g_frequency = vidioc_g_frequency ;
807- vv_data -> vbi_ops .vidioc_s_frequency = vidioc_s_frequency ;
827+ vv_data -> vbi_ops .vidioc_enum_output = vidioc_enum_output ;
828+ vv_data -> vbi_ops .vidioc_g_output = vidioc_g_output ;
829+ vv_data -> vbi_ops .vidioc_s_output = vidioc_s_output ;
830+ vv_data -> vbi_ops .vidioc_g_parm = NULL ;
808831 vv_data -> vbi_ops .vidioc_g_fmt_vbi_cap = NULL ;
832+ vv_data -> vbi_ops .vidioc_try_fmt_vbi_cap = NULL ;
833+ vv_data -> vbi_ops .vidioc_s_fmt_vbi_cap = NULL ;
809834 vv_data -> vbi_ops .vidioc_g_sliced_vbi_cap = vidioc_g_sliced_vbi_cap ;
810835 vv_data -> vbi_ops .vidioc_g_fmt_sliced_vbi_out = vidioc_g_fmt_sliced_vbi_out ;
836+ vv_data -> vbi_ops .vidioc_try_fmt_sliced_vbi_out = vidioc_try_fmt_sliced_vbi_out ;
811837 vv_data -> vbi_ops .vidioc_s_fmt_sliced_vbi_out = vidioc_s_fmt_sliced_vbi_out ;
812838
813839 if (FW_VERSION (av7110 -> arm_app ) < 0x2623 )
@@ -848,7 +874,7 @@ static struct saa7146_standard standard[] = {
848874 .h_offset = 0x48 , .h_pixels = 708 ,
849875 .v_max_out = 576 , .h_max_out = 768 ,
850876 }, {
851- .name = "NTSC" , .id = V4L2_STD_NTSC ,
877+ .name = "NTSC" , .id = V4L2_STD_NTSC_M ,
852878 .v_offset = 0x10 , .v_field = 244 ,
853879 .h_offset = 0x40 , .h_pixels = 708 ,
854880 .v_max_out = 480 , .h_max_out = 640 ,
@@ -862,7 +888,7 @@ static struct saa7146_standard analog_standard[] = {
862888 .h_offset = 0x08 , .h_pixels = 708 ,
863889 .v_max_out = 576 , .h_max_out = 768 ,
864890 }, {
865- .name = "NTSC" , .id = V4L2_STD_NTSC ,
891+ .name = "NTSC" , .id = V4L2_STD_NTSC_M ,
866892 .v_offset = 0x10 , .v_field = 244 ,
867893 .h_offset = 0x40 , .h_pixels = 708 ,
868894 .v_max_out = 480 , .h_max_out = 640 ,
@@ -876,7 +902,7 @@ static struct saa7146_standard dvb_standard[] = {
876902 .h_offset = 0x48 , .h_pixels = 708 ,
877903 .v_max_out = 576 , .h_max_out = 768 ,
878904 }, {
879- .name = "NTSC" , .id = V4L2_STD_NTSC ,
905+ .name = "NTSC" , .id = V4L2_STD_NTSC_M ,
880906 .v_offset = 0x10 , .v_field = 244 ,
881907 .h_offset = 0x40 , .h_pixels = 708 ,
882908 .v_max_out = 480 , .h_max_out = 640 ,
@@ -912,8 +938,6 @@ static struct saa7146_ext_vv av7110_vv_data_st = {
912938 .num_stds = ARRAY_SIZE (standard ),
913939 .std_callback = & std_callback ,
914940
915- .vbi_fops .open = av7110_vbi_reset ,
916- .vbi_fops .release = av7110_vbi_reset ,
917941 .vbi_fops .write = av7110_vbi_write ,
918942};
919943
@@ -927,8 +951,6 @@ static struct saa7146_ext_vv av7110_vv_data_c = {
927951 .num_stds = ARRAY_SIZE (standard ),
928952 .std_callback = & std_callback ,
929953
930- .vbi_fops .open = av7110_vbi_reset ,
931- .vbi_fops .release = av7110_vbi_reset ,
932954 .vbi_fops .write = av7110_vbi_write ,
933955};
934956
0 commit comments