RE: Regarding VIN test(cvbs capture:- PAL resolution)

2018-08-29 Thread Biju Das
Hi Niklas,

Thanks for the  feedback.  I confirm it works.

> Subject: Re: Regarding VIN test(cvbs capture:- PAL resolution)
>
> Hi Biju,
>
> On 2018-08-29 10:41:16 +, Biju Das wrote:
> > Hi All,
> >
> > I started testing vin on R-Car Gen3(CVBS  input from DVD player
> > connected to R-Car M3-W,kernel:-renesas-devel-20180827-4.19-rc1)
> > based on the information present in https://elinux.org/R-Car/Tests:rcar-
> vin.
> >
> > Looks like PAL is not supported.
> > When i execute the command, "media-ctl -d /dev/media1 --get-v4l2
> > "'adv748x 4-0070 afe':8"" on target , i get "[fmt:UYVY8_2X8/720x240
> field:alternate]" instead of "[fmt:UYVY8_2X8/720x288 field:alternate]"
> >
> > root@salvator-x:~# media-ctl -d /dev/media1 --get-v4l2 "'adv748x 4-0070
> afe':8"
> > [   28.708110] ##afe->curr_norm=1000 V4L2_STD_525_60=f900
> > [fmt:UYVY8_2X8/720x240 field:alternate]
> >
> > Q1) Have any one observed this issue?
>
> The format from the AFE is based on the video standard set. As v4l2 don't
> allow a subdevice to autodetect and change the video standard
> automatically, you need to do this as the first step of the pipeline
> configuration. The default standard of the adv748x driver is NTSC and that is
> why this step is not strictly needed when testing a NTSC source.
>
>
> 1. Boot board video source off and check formats
>
> $ v4l2-ctl --get-detected-standard -d /dev/v4l-subdev23
> Video Standard = 0x
>
> $ media-ctl -d /dev/media2 --get-v4l2 "'adv748x 4-0070 afe':8"
> [fmt:UYVY8_2X8/720x240 field:alternate colorspace:smpte170m]
>
> 2. Turn on video PAL source and check formats
>
>
> $ v4l2-ctl --get-detected-standard -d /dev/v4l-subdev23
> Video Standard = 0x00ff
> PAL-B/B1/G/H/I/D/D1
>
> $ media-ctl -d /dev/media2 --get-v4l2 "'adv748x 4-0070 afe':8"
> [fmt:UYVY8_2X8/720x240 field:alternate colorspace:smpte170m]
>
> Notice that the resolution is still for NTSC.
>
> 3. Set video standard of the AFE and check format
>
> $ v4l2-ctl --set-standard=0x00ff -d /dev/v4l-subdev23
> Standard set to 80ff
>
> $ media-ctl -d /dev/media2 --get-v4l2 "'adv748x 4-0070 afe':8"
> [fmt:UYVY8_2X8/720x288 field:alternate colorspace:smpte170m]
>
> You now have a correct standard for the AFE and can configure a
> correct pipeline to capture PAL.

root@salvator-x:/# ./v4l2-ctl --get-detected-standard -d /dev/v4l-subdev13
Video Standard = 0x00ff
PAL-B/B1/G/H/I/D/D1/K

root@salvator-x:/# media-ctl -d /dev/media1 --get-v4l2 "'adv748x 4-0070 afe':8"
[ 5345.141942] ##afe->curr_norm=1000 V4L2_STD_525_60=f900
[fmt:UYVY8_2X8/720x240 field:alternate]

root@salvator-x:/# ./v4l2-ctl --set-standard=0x00ff -d /dev/v4l-subdev13
Standard set to 80ff

root@salvator-x:/# media-ctl -d /dev/media1 --get-v4l2 "'adv748x 4-0070 afe':8"
[ 5393.410504] ##afe->curr_norm=ff V4L2_STD_525_60=f900
[fmt:UYVY8_2X8/720x288 field:alternate]

root@salvator-x:/# media-ctl -d /dev/media1 -V "'rcar_csi2 fea8.csi2':1 
[fmt:UYVY8_2X8/720x288 field:alternate]"
root@salvator-x:/# media-ctl -d /dev/media1 -V "'adv748x 4-0070 afe':8 
[fmt:UYVY8_2X8/720x288 field:alternate]"
[ 5415.591865] ##afe->curr_norm=ff V4L2_STD_525_60=f900

root@salvator-x:/# /yavta -f RGB565 -s 720x576 --field interlaced -n 4 
--capture=10 -F -F /dev/video7
Device /dev/video7 opened.
Device `R_Car_VIN' o[ 5429.869587] ##afe->curr_norm=ff 
V4L2_STD_525_60=f900
n `platform:e6ef1000.video' (driver 'rcar_vin') supports video, capture, 
without mplanes.
Video format set: RGB565 (50424752) 720x576 (stride 1440) field interlaced 
buffer size 829440
Video format: RGB565 (50424752) 720x576 (stride 1440) field interlaced buffer 
size 829440
4 buffers requested.
length: 829440 offset: 0 timestamp type/source: mono/EoF
Buffer 0/0 mapped at address 0xb1289000.
length: 829440 offset: 831488 timestamp type/source: mono/EoF
Buffer 1/0 mapped at address 0xb11be000.
length: 829440 offset: 1662976 timestamp type/source: mono/EoF
Buffer 2/0 mapped at address 0xb10f3000.
length: 829440 offset: 2494464 timestamp type/source: mono/EoF
Buffer 3/0 mapped at address 0xb1028000.
0 (0) [-] interlaced 0 829440 B 5429.987981 5429.987994 12.577 fps ts mono/EoF
1 (1) [-] interlaced 1 829440 B 5430.027981 5430.517680 25.000 fps ts mono/EoF
2 (2) [-] interlaced 2 829440 B 5430.067984 5431.046340 24.998 fps ts mono/EoF
3 (3) [-] interlaced 3 829440 B 5430.107982 5431.582130 25.001 fps ts mono/EoF
4 (0) [-] interlaced 17 829440 B 5430.667986 5432.109747 1.786 f

Re: Regarding VIN test(cvbs capture:- PAL resolution)

2018-08-29 Thread Kieran Bingham
Hi Biju,

On 29/08/18 12:19, Biju Das wrote:
> Hi Kieran,
> 
> Thanks for the feedback.
> 



>> Could you check to see the output of any of the following is correct:
>>
>> media-ctl -d /dev/media1 --get-v4l2 "'adv748x 4-0070 afe':0"
>> .. (and 1,2,3,4,5,6 if necessary)
>> media-ctl -d /dev/media1 --get-v4l2 "'adv748x 4-0070 afe':7"
> 
> Please find the output.
> 
> root@salvator-x:~# media-ctl -d /dev/media1 --get-v4l2 "'adv748x 4-0070 
> afe':0"
> root@salvator-x:~# media-ctl -d /dev/media1 --get-v4l2 "'adv748x 4-0070 
> afe':1"
> root@salvator-x:~# media-ctl -d /dev/media1 --get-v4l2 "'adv748x 4-0070 
> afe':2"
> root@salvator-x:~# media-ctl -d /dev/media1 --get-v4l2 "'adv748x 4-0070 
> afe':3"
> root@salvator-x:~# media-ctl -d /dev/media1 --get-v4l2 "'adv748x 4-0070 
> afe':4"
> root@salvator-x:~# media-ctl -d /dev/media1 --get-v4l2 "'adv748x 4-0070 
> afe':5"
> root@salvator-x:~# media-ctl -d /dev/media1 --get-v4l2 "'adv748x 4-0070 
> afe':6"
> root@salvator-x:~# media-ctl -d /dev/media1 --get-v4l2 "'adv748x 4-0070 
> afe':7"
> root@salvator-x:~# media-ctl -d /dev/media1 --get-v4l2 "'adv748x 4-0070 
> afe':8"
> [ 2589.712578] ##afe->curr_norm=1000 V4L2_STD_525_60=f900
> [fmt:UYVY8_2X8/720x240 field:alternate]
> 


Aha - OK - I'm sorry - I was telling you the wrong way to detect.

Please see Niklas' recent e-mail :)

--
Kieran


Re: Regarding VIN test(cvbs capture:- PAL resolution)

2018-08-29 Thread Niklas Söderlund
Hi Biju,

On 2018-08-29 10:41:16 +, Biju Das wrote:
> Hi All,
> 
> I started testing vin on R-Car Gen3(CVBS  input from DVD player connected to 
> R-Car M3-W,kernel:-renesas-devel-20180827-4.19-rc1)
> based on the information present in https://elinux.org/R-Car/Tests:rcar-vin.
> 
> Looks like PAL is not supported.
> When i execute the command, "media-ctl -d /dev/media1 --get-v4l2 "'adv748x 
> 4-0070 afe':8"" on target
> , i get "[fmt:UYVY8_2X8/720x240 field:alternate]" instead of 
> "[fmt:UYVY8_2X8/720x288 field:alternate]"
> 
> root@salvator-x:~# media-ctl -d /dev/media1 --get-v4l2 "'adv748x 4-0070 
> afe':8"
> [   28.708110] ##afe->curr_norm=1000 V4L2_STD_525_60=f900
> [fmt:UYVY8_2X8/720x240 field:alternate]
> 
> Q1) Have any one observed this issue?

The format from the AFE is based on the video standard set. As v4l2 
don't allow a subdevice to autodetect and change the video standard 
automatically, you need to do this as the first step of the pipeline 
configuration. The default standard of the adv748x driver is NTSC and 
that is why this step is not strictly needed when testing a NTSC source.


1. Boot board video source off and check formats

$ v4l2-ctl --get-detected-standard -d /dev/v4l-subdev23
Video Standard = 0x

$ media-ctl -d /dev/media2 --get-v4l2 "'adv748x 4-0070 afe':8"
[fmt:UYVY8_2X8/720x240 field:alternate colorspace:smpte170m]

2. Turn on video PAL source and check formats


$ v4l2-ctl --get-detected-standard -d /dev/v4l-subdev23
Video Standard = 0x00ff
PAL-B/B1/G/H/I/D/D1

$ media-ctl -d /dev/media2 --get-v4l2 "'adv748x 4-0070 afe':8"
[fmt:UYVY8_2X8/720x240 field:alternate colorspace:smpte170m]

Notice that the resolution is still for NTSC.

3. Set video standard of the AFE and check format

$ v4l2-ctl --set-standard=0x00ff -d /dev/v4l-subdev23
Standard set to 80ff

$ media-ctl -d /dev/media2 --get-v4l2 "'adv748x 4-0070 afe':8"
[fmt:UYVY8_2X8/720x288 field:alternate colorspace:smpte170m]

You now have a correct standard for the AFE and can configure a 
correct pipeline to capture PAL.

> 
> So I created a patch[2], based on [1]. With this, I get proper PAL 
> resolution(720x576)
> 
> root@salvator-x:~# media-ctl -d /dev/media1 --get-v4l2 "'adv748x 4-0070 
> afe':8"
> [   42.472582] ##afe->curr_norm=ff V4L2_STD_525_60=f900
> [fmt:UYVY8_2X8/720x288 field:alternate]
> 
> Q2) Is there any reason for not upstreaming the patch [1]?

As Kieran stated a subdevice is not allowed to change the video standard 
on it's own. Instead the user is required to ask the subevice which 
standard it detects and explicitly set that standard when configuring 
the video pipeline before capturing.

> 
> [1] 
> https://kernel.googlesource.com/pub/scm/linux/kernel/git/horms/renesas-bsp/+/e0740949ae6b964da8bf1e88b504405276652aa7%5E%21/#F0
> 
> [2]
> --- a/drivers/media/i2c/adv748x/adv748x-afe.c
> +++ b/drivers/media/i2c/adv748x/adv748x-afe.c
> 
> @ -352,6 +353,7 @@ static int adv748x_afe_get_format(struct v4l2_subdev *sd,
> {
> struct adv748x_afe *afe = adv748x_sd_to_afe(sd);
> struct v4l2_mbus_framefmt *mbusformat;
> +   v4l2_std_id std = 0;
> /* It makes no sense to get the format of the analog sink pads */
> if (sdformat->pad != ADV748X_AFE_SOURCE)
> @@ -361,6 +363,9 @@ static int adv748x_afe_get_format(struct v4l2_subdev *sd,
> mbusformat = v4l2_subdev_get_try_format(sd, cfg, 
> sdformat->pad);
> sdformat->format = *mbusformat;
> } else {
> +   /* Set std_id automatically */
> +   adv748x_afe_querystd(sd, );
> +   adv748x_afe_s_std(sd, std);
> adv748x_afe_fill_format(afe, >format);
> adv748x_afe_propagate_pixelrate(afe);
> 
> 
> Regards,
> Biju
> 
> 
> 
> 
> Renesas Electronics Europe Ltd, Dukes Meadow, Millboard Road, Bourne End, 
> Buckinghamshire, SL8 5FH, UK. Registered in England & Wales under Registered 
> No. 04586709.

-- 
Regards,
Niklas Söderlund


RE: Regarding VIN test(cvbs capture:- PAL resolution)

2018-08-29 Thread Biju Das
Hi Kieran,

Thanks for the feedback.

> Subject: Re: Regarding VIN test(cvbs capture:- PAL resolution)

> On 29/08/18 11:41, Biju Das wrote:
> > Hi All,
> >
> >
> >
> > I started testing vin on R-Car Gen3(CVBS  input from DVD player
> > connected to R-Car M3-W,kernel:-renesas-devel-20180827-4.19-rc1)
> >
> > based on the information present in https://elinux.org/R-Car/Tests:rcar-
> vin.
> >
> >
> >
> > Looks like PAL is not supported.
> >
> > When i execute the command, "media-ctl -d /dev/media1 --get-v4l2
> > "'adv748x 4-0070 afe':8"" on target
> >
>
> This looks like a bug in the documentation at https://elinux.org/R-
> Car/Tests:rcar-vin. It's 'getting' the format of the source pad of the AFE.
>
>
> > , i get "[fmt:UYVY8_2X8/720x240 field:alternate]" instead of
> > "[fmt:UYVY8_2X8/720x288 field:alternate]"
>
> Hrm ... this is getting the format of the source pad of the AFE - which is
> manually set, but the get_fmt should be done on the SINK pad of the AFE.
> (ideally on the correct input port)
>
> Could you check to see the output of any of the following is correct:
>
> media-ctl -d /dev/media1 --get-v4l2 "'adv748x 4-0070 afe':0"
> .. (and 1,2,3,4,5,6 if necessary)
> media-ctl -d /dev/media1 --get-v4l2 "'adv748x 4-0070 afe':7"

Please find the output.

root@salvator-x:~# media-ctl -d /dev/media1 --get-v4l2 "'adv748x 4-0070 afe':0"
root@salvator-x:~# media-ctl -d /dev/media1 --get-v4l2 "'adv748x 4-0070 afe':1"
root@salvator-x:~# media-ctl -d /dev/media1 --get-v4l2 "'adv748x 4-0070 afe':2"
root@salvator-x:~# media-ctl -d /dev/media1 --get-v4l2 "'adv748x 4-0070 afe':3"
root@salvator-x:~# media-ctl -d /dev/media1 --get-v4l2 "'adv748x 4-0070 afe':4"
root@salvator-x:~# media-ctl -d /dev/media1 --get-v4l2 "'adv748x 4-0070 afe':5"
root@salvator-x:~# media-ctl -d /dev/media1 --get-v4l2 "'adv748x 4-0070 afe':6"
root@salvator-x:~# media-ctl -d /dev/media1 --get-v4l2 "'adv748x 4-0070 afe':7"
root@salvator-x:~# media-ctl -d /dev/media1 --get-v4l2 "'adv748x 4-0070 afe':8"
[ 2589.712578] ##afe->curr_norm=1000 V4L2_STD_525_60=f900
[fmt:UYVY8_2X8/720x240 field:alternate]

>
> I don't recall which pad is used on the Salvator-XS - and the media control
> output doesn't make that clear - so we should improve that.
>
>
> Anyway, then - Could you try setting the PAL format manually ?
>
> >  media-ctl -d /dev/media0 -V "'adv748x 4-0070 afe':8
> [fmt:UYVY8_2X8/720x288 field:alternate]"
> >  media-ctl -d /dev/media0 -V "'rcar_csi2 fea8.csi2':1
> [fmt:UYVY8_2X8/720x288 field:alternate]"

I tried this, it is not capturing the data, broken pipe,

root@salvator-x:~# media-ctl -d /dev/media1 -l "'rcar_csi2 fea8.csi2':1 -> 
'VIN1 output':0 [1]"
root@salvator-x:~# media-ctl -d /dev/media1 -V "'rcar_csi2 fea8.csi2':1 
[fmt:UYVY8_2X8/720x288 field:alternate]"
root@salvator-x:~# media-ctl -d /dev/media1 -V "'adv748x 4-0070 afe':8 
[fmt:UYVY8_2X8/720x288 field:alternate]"
[ 3102.288488] ##afe->curr_norm=1000 V4L2_STD_525_60=f900
root@salvator-x:~# /yavta -f RGB565 -s 720x576 --field interlaced -n 4 
--capture=10 -F -F /dev/video7
Device /dev/video7 opened.
Device `R_Car_VIN' on `platf[ 3111.778791] ##afe->curr_norm=1000 
V4L2_STD_525_60=f900
orm:e6ef1000.video' (driver 'rcar_vin') supports video, capture, without 
mplanes.
Video format set: RGB565 (50424752) 720x576 (stride 1440) field interlaced 
buffer size 829440
Video format: RGB565 (50424752) 720x576 (stride 1440) field interlaced buffer 
size 829440
4 buffers requested.
length: 829440 offset: 0 timestamp type/source: mono/EoF
Buffer 0/0 mapped at address 0xbbf61000.
length: 829440 offset: 831488 timestamp type/source: mono/EoF
Buffer 1/0 mapped at address 0xbbe96000.
length: 829440 offset: 1662976 timestamp type/source: mono/EoF
Buffer 2/0 mapped at address 0xbbdcb000.
length: 829440 offset: 2494464 timestamp type/source: mono/EoF
Buffer 3/0 mapped at address 0xbbd0.
Unable to start streaming: Broken pipe (32).
4 buffers released.

But if I configure for 720x480, it captures the data properly
---
media-ctl -d /dev/media1 -V "'rcar_csi2 fea8.csi2':1 [fmt:UYVY8_2X8/720x240 
field:alternate]"
media-ctl -d /dev/media1 -V "'adv748x 4-0070 afe':8 [fmt:UYVY8_2X8/720x240 
field:alternate]"

root@salvator-x:~# /yavta -f RGB565 -s 720x480 --field interlaced -n 4 
--capture=10 -F -F /dev/video7
Device /dev/video7 opened.
Device `R_Car_VIN' on `platf[ 3204.676120] ##afe->curr_norm=1000 
V4L2_STD_525_60=f900

Re: Regarding VIN test(cvbs capture:- PAL resolution)

2018-08-29 Thread Kieran Bingham
Hi Biju,

On 29/08/18 11:41, Biju Das wrote:
> Hi All,
> 
>  
> 
> I started testing vin on R-Car Gen3(CVBS  input from DVD player
> connected to R-Car M3-W,kernel:-renesas-devel-20180827-4.19-rc1)
> 
> based on the information present in https://elinux.org/R-Car/Tests:rcar-vin.
> 
>  
> 
> Looks like PAL is not supported.
> 
> When i execute the command, "media-ctl -d /dev/media1 --get-v4l2
> "'adv748x 4-0070 afe':8"" on target
> 

This looks like a bug in the documentation at
https://elinux.org/R-Car/Tests:rcar-vin. It's 'getting' the format of
the source pad of the AFE.


> , i get "[fmt:UYVY8_2X8/720x240 field:alternate]" instead of
> "[fmt:UYVY8_2X8/720x288 field:alternate]"

Hrm ... this is getting the format of the source pad of the AFE - which
is manually set, but the get_fmt should be done on the SINK pad of the
AFE. (ideally on the correct input port)

Could you check to see the output of any of the following is correct:

media-ctl -d /dev/media1 --get-v4l2 "'adv748x 4-0070 afe':0"
.. (and 1,2,3,4,5,6 if necessary)
media-ctl -d /dev/media1 --get-v4l2 "'adv748x 4-0070 afe':7"


I don't recall which pad is used on the Salvator-XS - and the media
control output doesn't make that clear - so we should improve that.


Anyway, then - Could you try setting the PAL format manually ?

>  media-ctl -d /dev/media0 -V "'adv748x 4-0070 afe':8 [fmt:UYVY8_2X8/720x288 
> field:alternate]"
>  media-ctl -d /dev/media0 -V "'rcar_csi2 fea8.csi2':1 
> [fmt:UYVY8_2X8/720x288 field:alternate]"

I thought the ADV748x can tell the difference between PAL/NTSC and so it
should have detected it, so perhaps there is a bug there - but you do
have to manually propagate the format you want regardless.



> 
> root@salvator-x:~# media-ctl -d /dev/media1 --get-v4l2 "'adv748x 4-0070
> afe':8"
> 
> [   28.708110] ##afe->curr_norm=1000 V4L2_STD_525_60=f900
> 
>     [fmt:UYVY8_2X8/720x240 field:alternate]
> 
>  
> 
> Q1) Have any one observed this issue?
> 

I thought most of my testing was on PAL actually. - But it's a long time
since I've tested the ADV748x CVBS input.


> So I created a patch[2], based on [1]. With this, I get proper PAL
> resolution(720x576)
> 
>  
> 
> root@salvator-x:~# media-ctl -d /dev/media1 --get-v4l2 "'adv748x 4-0070
> afe':8"
> 
> [   42.472582] ##afe->curr_norm=ff V4L2_STD_525_60=f900
> 
>     [fmt:UYVY8_2X8/720x288 field:alternate]
> 
>  
> 
> Q2) Is there any reason for not upstreaming the patch [1]?

Yes, unfortunately - the V4L2 spec does not allow us to automatically
detect and then set the format.

The choice of which format to set must belong to userspace.


> [1]
> https://kernel.googlesource.com/pub/scm/linux/kernel/git/horms/renesas-bsp/+/e0740949ae6b964da8bf1e88b504405276652aa7%5E%21/#F0
> 
>  
> 
> [2]
> 
> --- a/drivers/media/i2c/adv748x/adv748x-afe.c
> 
> +++ b/drivers/media/i2c/adv748x/adv748x-afe.c
> 
>  
> 
> @ -352,6 +353,7 @@ static int adv748x_afe_get_format(struct v4l2_subdev *sd,
> 
> {
> 
>     struct adv748x_afe *afe = adv748x_sd_to_afe(sd);
> 
>     struct v4l2_mbus_framefmt *mbusformat;
> 
> +   v4l2_std_id std = 0;
> 
> /* It makes no sense to get the format of the analog sink pads */
> 
>     if (sdformat->pad != ADV748X_AFE_SOURCE)
> 
> @@ -361,6 +363,9 @@ static int adv748x_afe_get_format(struct v4l2_subdev
> *sd,
> 
>     mbusformat = v4l2_subdev_get_try_format(sd, cfg,
> sdformat->pad);
> 
>     sdformat->format = *mbusformat;
> 
>     } else {
> 
> +   /* Set std_id automatically */
> 
> +   adv748x_afe_querystd(sd, );
> 
> +   adv748x_afe_s_std(sd, std);
> 
>     adv748x_afe_fill_format(afe, >format);
> 
>     adv748x_afe_propagate_pixelrate(afe);
> 
>    
> 
>  
> 
> Regards,
> 
> Biju
> 
> 
> 
> 
> Renesas Electronics Europe Ltd, Dukes Meadow, Millboard Road, Bourne
> End, Buckinghamshire, SL8 5FH, UK. Registered in England & Wales under
> Registered No. 04586709.
>