R-Car/Tests:rcar-vin

This document describes how to test the VIN and CSI2 (only present on Gen3) functionality on Renesas R-Car Gen2 and Gen3.

Get the code
Ideally all the code to test VIN should be available in the mainline kernel, unfortunately this is not the case yet. Renesas driver parts not yet picked-up are available in renesas-drivers tree while none Renesas drivers (e.g. the ADV7482 driver for Gen3 testing) are only available in the out-of-tree repository bellow.

There are also some patches needed to facilitate testing that are not part of renesas-drivers such as kernel configurations and DT changes. To ease testing a tag is available where all patches are included which can be build and used to test at:

https://git.ragnatech.se/linux rcar-vin-elinux-v4

Gen2

 * VIN driver picked-up in v4.8-rc1.
 * To test the HDMI input the ADV7604 needs to be enabled (not default in shmobile_defconfig) and added to DT, see example in out-of-tree repository mentioned above.

Gen3

 * VIN and CSI2 driver support is included in renesas-drivers.
 * Prototype driver for ADV7482 are not available in renesas-drivers but in the out-of-tree repository mentioned above, this driver is incomplete and requires more work before it's ready for mainline.
 * To test CVBS or HDMI input the RCAR_VIN, RCAR_CSI2 and ADV7482 needs to be enabled (not default in defconfig) and added to DT, see example in out-of-tree repository mentioned above.

Boot the kernel
You should see this on successful probe (this is from Gen3):

rcar-vin e6ef0000.video: Device registered as video22 rcar-vin e6ef1000.video: Device registered as video23 rcar-vin e6ef2000.video: Device registered as video24 rcar-vin e6ef3000.video: Device registered as video25 rcar-vin e6ef4000.video: Device registered as video26 rcar-vin e6ef5000.video: Device registered as video27 rcar-vin e6ef6000.video: Device registered as video28 rcar-vin e6ef7000.video: Device registered as video29

Media Controller configuration on Gen3
On Gen3 a new mode of operation is added, the ability not only work with a local digital subdevice directly attached to a VIN instance in a 1:1 mapping but to be part of a CSI-2 group which share a set of video sources and CSI-2 bridges. In this mode of operation each video source is connected to a CSI-2 bridge which in turn can be routed to the different VIN instances depending on one of the predetermined routing setups for that particular SoC, it's not possible to go outside the routing tables provided by the hardware.

To control the routing from user-space the Media Controller framework are used, this section will briefly describe how to use the Media Controller framework for the rcar-vin driver using the media-ctl tool form the v4l-utils package.

Show current routing
Examine the current routing setup with 'media-ctl -d /dev/mediaX -p'.

Note: In the example bellow the ADV7482 node is shown twice, this do not represent reality but is one of the hacks in the ADV7482 driver which needs to be solved before it's ready for upstream.

Media controller API version 0.1.0
 * 1) media-ctl -d /dev/media0 -p

Media device information

driver         Renesas VIN model          video serial bus info       /soc/video@e6ef0000 hw revision    0x0 driver version 4.9.0

Device topology - entity 1: adv7482 4-0034 (12 pads, 1 link) type V4L2 subdev subtype Unknown flags 20004 device node name /dev/v4l-subdev0 pad0: Sink pad1: Sink pad2: Sink pad3: Sink pad4: Sink pad5: Sink pad6: Sink pad7: Sink pad8: Sink pad9: Sink pad10: Source [fmt:RGB888_1X24/720x480 field:interlaced] pad11: Source [fmt:UYVY8_2X8/720x480 field:interlaced] -> "rcar_csi2.fea80000.csi2":0 [ENABLED,IMMUTABLE]

- entity 14: adv7482 4-0070 (12 pads, 1 link) type V4L2 subdev subtype Unknown flags 20004 device node name /dev/v4l-subdev1 pad0: Sink [dv.caps:BT.656/1120 min:640x480@0 max:1920x1200@162000000 stds:CEA-861,DMT caps:interlaced,progressive] pad1: Sink [dv.caps:BT.656/1120 min:640x480@0 max:1920x1200@162000000 stds:CEA-861,DMT caps:interlaced,progressive] pad2: Sink [dv.caps:BT.656/1120 min:640x480@0 max:1920x1200@162000000 stds:CEA-861,DMT caps:interlaced,progressive] pad3: Sink [dv.caps:BT.656/1120 min:640x480@0 max:1920x1200@162000000 stds:CEA-861,DMT caps:interlaced,progressive] pad4: Sink [dv.caps:BT.656/1120 min:640x480@0 max:1920x1200@162000000 stds:CEA-861,DMT caps:interlaced,progressive] pad5: Sink [dv.caps:BT.656/1120 min:640x480@0 max:1920x1200@162000000 stds:CEA-861,DMT caps:interlaced,progressive] pad6: Sink [dv.caps:BT.656/1120 min:640x480@0 max:1920x1200@162000000 stds:CEA-861,DMT caps:interlaced,progressive] pad7: Sink [dv.caps:BT.656/1120 min:640x480@0 max:1920x1200@162000000 stds:CEA-861,DMT caps:interlaced,progressive] pad8: Sink [dv.caps:BT.656/1120 min:640x480@0 max:1920x1200@162000000 stds:CEA-861,DMT caps:interlaced,progressive] pad9: Sink [dv.caps:BT.656/1120 min:640x480@0 max:1920x1200@162000000 stds:CEA-861,DMT caps:interlaced,progressive] pad10: Source [fmt:RGB888_1X24/720x480 field:interlaced] [dv.caps:BT.656/1120 min:640x480@0 max:1920x1200@162000000 stds:CEA-861,DMT caps:interlaced,progressive] [dv.query:no-link] [dv.current:BT.656/1120 720x480i29 (858x525) stds:CEA-861 flags:half-line,CE-video] -> "rcar_csi2.feaa0000.csi2":0 [ENABLED,IMMUTABLE] pad11: Source [fmt:UYVY8_2X8/720x480 field:interlaced] [dv.caps:BT.656/1120 min:640x480@0 max:1920x1200@162000000 stds:CEA-861,DMT caps:interlaced,progressive] [dv.query:no-link] [dv.current:BT.656/1120 720x480i29 (858x525) stds:CEA-861 flags:half-line,CE-video]

- entity 27: rcar_vin.e6ef0000.video (1 pad, 2 links) type Node subtype V4L flags 0 device node name /dev/video0 pad0: Sink <- "rcar_csi2.fea80000.csi2":1 [] <- "rcar_csi2.feaa0000.csi2":1 [ENABLED]

- entity 31: rcar_vin.e6ef1000.video (1 pad, 4 links) type Node subtype V4L flags 0 device node name /dev/video1 pad0: Sink <- "rcar_csi2.fea80000.csi2":1 [ENABLED] <- "rcar_csi2.fea80000.csi2":2 [] <- "rcar_csi2.feaa0000.csi2":1 [] <- "rcar_csi2.feaa0000.csi2":2 []

- entity 35: rcar_vin.e6ef2000.video (1 pad, 4 links) type Node subtype V4L flags 0 device node name /dev/video2 pad0: Sink <- "rcar_csi2.fea80000.csi2":1 [] <- "rcar_csi2.fea80000.csi2":3 [] <- "rcar_csi2.feaa0000.csi2":1 [] <- "rcar_csi2.feaa0000.csi2":3 []

- entity 39: rcar_vin.e6ef3000.video (1 pad, 4 links) type Node subtype V4L flags 0 device node name /dev/video3 pad0: Sink <- "rcar_csi2.fea80000.csi2":2 [] <- "rcar_csi2.fea80000.csi2":4 [] <- "rcar_csi2.feaa0000.csi2":2 [ENABLED] <- "rcar_csi2.feaa0000.csi2":4 []

- entity 43: rcar_vin.e6ef4000.video (1 pad, 1 link) type Node subtype V4L flags 0 device node name /dev/video4 pad0: Sink <- "rcar_csi2.fea80000.csi2":1 []

- entity 47: rcar_vin.e6ef5000.video (1 pad, 2 links) type Node subtype V4L flags 0 device node name /dev/video5 pad0: Sink <- "rcar_csi2.fea80000.csi2":1 [ENABLED] <- "rcar_csi2.fea80000.csi2":2 []

- entity 51: rcar_vin.e6ef6000.video (1 pad, 2 links) type Node subtype V4L flags 0 device node name /dev/video6 pad0: Sink <- "rcar_csi2.fea80000.csi2":1 [] <- "rcar_csi2.fea80000.csi2":3 []

- entity 55: rcar_vin.e6ef7000.video (1 pad, 2 links) type Node subtype V4L flags 0 device node name /dev/video7 pad0: Sink <- "rcar_csi2.fea80000.csi2":2 [] <- "rcar_csi2.fea80000.csi2":4 []

- entity 59: rcar_csi2.fea80000.csi2 (5 pads, 15 links) type V4L2 subdev subtype Unknown flags 20004 device node name /dev/v4l-subdev2 pad0: Sink [fmt:UYVY8_2X8/720x480 field:interlaced] <- "adv7482 4-0034":11 [ENABLED,IMMUTABLE] pad1: Source -> "rcar_vin.e6ef0000.video":0 [] -> "rcar_vin.e6ef1000.video":0 [ENABLED] -> "rcar_vin.e6ef2000.video":0 [] -> "rcar_vin.e6ef4000.video":0 [] -> "rcar_vin.e6ef5000.video":0 [ENABLED] -> "rcar_vin.e6ef6000.video":0 [] pad2: Source -> "rcar_vin.e6ef1000.video":0 [] -> "rcar_vin.e6ef3000.video":0 [] -> "rcar_vin.e6ef5000.video":0 [] -> "rcar_vin.e6ef7000.video":0 [] pad3: Source -> "rcar_vin.e6ef2000.video":0 [] -> "rcar_vin.e6ef6000.video":0 [] pad4: Source -> "rcar_vin.e6ef3000.video":0 [] -> "rcar_vin.e6ef7000.video":0 []

- entity 65: rcar_csi2.feaa0000.csi2 (5 pads, 8 links) type V4L2 subdev subtype Unknown flags 20004 device node name /dev/v4l-subdev3 pad0: Sink [fmt:RGB888_1X24/720x480 field:interlaced] <- "adv7482 4-0070":10 [ENABLED,IMMUTABLE] pad1: Source -> "rcar_vin.e6ef0000.video":0 [ENABLED] -> "rcar_vin.e6ef1000.video":0 [] -> "rcar_vin.e6ef2000.video":0 [] pad2: Source -> "rcar_vin.e6ef1000.video":0 [] -> "rcar_vin.e6ef3000.video":0 [ENABLED] pad3: Source -> "rcar_vin.e6ef2000.video":0 [] pad4: Source -> "rcar_vin.e6ef3000.video":0 []

Activate/Deactivate a link
The Media Controller framework allows user-space to enable/disable a link and that way control the routing of video data from a CSI-2 to a VIN instance. Not all CSI-2 and Virtual Channel are possible to route to any and all VIN instances, this is limited by the SoC hardware and is specific for each SoC version. Look at the previous section on how to show which links are possible on your particular SoC. Further more not all links can be activated independent of other links, this is also a limitation set by the hardware. If you try to enable a link which would not be possible with regard to other already active links the operation will fail with a EBUSY error. Try deactivating some other link to crate more routing possibilities and try again, all possible routing setups for a specific SoC are documented in the datasheet.

A link is always configured from a CSI-2 instance to a VIN instance, the same way the video data is flowing.

To enable a link use the media-ctl utility from v4l-utils package:


 * 1) media-ctl -d /dev/media0 -l "'rcar_csi2.fea80000.csi2':1 -> 'rcar_vin.e6ef0000.video':0 [1]"

To disable the same link use:


 * 1) media-ctl -d /dev/media0 -l "'rcar_csi2.fea80000.csi2':1 -> 'rcar_vin.e6ef0000.video':0 [0]"

Once a link is enabled you can access the /dev/videoX node associated with the VIN instance to start capturing video data. Using the link from the example above you would be able to access video data from CSI20/VC0 on the VIN0 instance.

Deactivate all active links
This is a useful command to reset all links before you start enabeling new links to make sure you got the biggest possible routing space to start out with.


 * 1) media-ctl -d /dev/media0 -r

Use v4l-utils to test
The v4l2-utils (git://linuxtv.org/v4l-utils.git) provide two tools which are helpful in testing rcar-vin.

qv4l2
A GUI tool which lets you view the video from a rcar-vin device and test a wide range of different input parameters. Start the tool and specifying which video device you wish to operate on using the -d parameter, the video device number for the different video nodes can be observed in the boot log as shown above.


 * 1) qv4l2 -d 23

v4l2-compliance
A compliance test tool that verifies the drivers user-space interface. Start the tool and specifying which video device you wish to operate on using the -d parameter, the video device number for the different video nodes can be observed in the boot log as shown above. There are a few other options worth testing, --stream-all-formats (-f) and --streaming= (-s) will test that the driver actually can grab frames in different formats.

Driver Info: Driver name  : rcar_vin Card type    : R_Car_VIN Bus info     : platform:e6ef1000.video Driver version: 4.6.0 Capabilities : 0x85200001 Video Capture Read/Write Streaming Extended Pix Format Device Capabilities Device Caps  : 0x05200001 Video Capture Read/Write Streaming Extended Pix Format
 * 1) v4l2-compliance -d 23 -s -f

Compliance test for device /dev/video23 (not using libv4l2):

Required ioctls: test VIDIOC_QUERYCAP: OK

Allow for multiple opens: test second video open: OK	test VIDIOC_QUERYCAP: OK	test VIDIOC_G/S_PRIORITY: OK

Debug ioctls: test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported) test VIDIOC_LOG_STATUS: OK

Input ioctls: test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported) test VIDIOC_ENUMAUDIO: OK (Not Supported) test VIDIOC_G/S/ENUMINPUT: OK	test VIDIOC_G/S_AUDIO: OK (Not Supported) Inputs: 2 Audio Inputs: 0 Tuners: 0

Output ioctls: test VIDIOC_G/S_MODULATOR: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_ENUMAUDOUT: OK (Not Supported) test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported) test VIDIOC_G/S_AUDOUT: OK (Not Supported) Outputs: 0 Audio Outputs: 0 Modulators: 0

Input/Output configuration ioctls: test VIDIOC_ENUM/G/S/QUERY_STD: OK	test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported) test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported) test VIDIOC_G/S_EDID: OK (Not Supported)

Test input 0:

Control ioctls: test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK		test VIDIOC_QUERYCTRL: OK		test VIDIOC_G/S_CTRL: OK		test VIDIOC_G/S/TRY_EXT_CTRLS: OK		test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK		test VIDIOC_G/S_JPEGCOMP: OK (Not Supported) Standard Controls: 5 Private Controls: 0

Format ioctls: test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK		test VIDIOC_G/S_PARM: OK		test VIDIOC_G_FBUF: OK (Not Supported) test VIDIOC_G_FMT: OK		test VIDIOC_TRY_FMT: OK		test VIDIOC_S_FMT: OK		test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported) test Cropping: OK		test Composing: OK		test Scaling: OK (Not Supported)

Codec ioctls: test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported) test VIDIOC_G_ENC_INDEX: OK (Not Supported) test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)

Buffer ioctls: test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK		test VIDIOC_EXPBUF: OK

Test input 1:

Control ioctls: test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK		test VIDIOC_QUERYCTRL: OK		test VIDIOC_G/S_CTRL: OK		test VIDIOC_G/S/TRY_EXT_CTRLS: OK		test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK		test VIDIOC_G/S_JPEGCOMP: OK (Not Supported) Standard Controls: 5 Private Controls: 0

Format ioctls: test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK		test VIDIOC_G/S_PARM: OK		test VIDIOC_G_FBUF: OK (Not Supported) test VIDIOC_G_FMT: OK		test VIDIOC_TRY_FMT: OK		test VIDIOC_S_FMT: OK		test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported) test Cropping: OK		test Composing: OK		test Scaling: OK (Not Supported)

Codec ioctls: test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported) test VIDIOC_G_ENC_INDEX: OK (Not Supported) test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)

Buffer ioctls: test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK		test VIDIOC_EXPBUF: OK

Test input 0:

Streaming ioctls: test read/write: OK	test MMAP: OK                                    	test USERPTR: OK (Not Supported) test DMABUF: Cannot test, specify --expbuf-device

Stream using all formats: test MMAP for Format NV16, Frame Size 720x576: Crop 720x576@0x0, Compose 720x576@0x0, Stride 736, Field None: OK  		Crop 720x576@0x0, Compose 720x576@0x0, Stride 736, Field Top: OK   		Crop 720x576@0x0, Compose 720x576@0x0, Stride 736, Field Bottom: OK   		Crop 720x576@0x0, Compose 720x576@0x0, Stride 736, Field Interlaced: OK   		Crop 720x576@0x0, Compose 720x576@0x0, Stride 736, Field Interlaced Top-Bottom: OK   		Crop 720x576@0x0, Compose 720x576@0x0, Stride 736, Field Interlaced Bottom-Top: OK   		Crop 6x4@0x0, Compose 720x576@0x0, Stride 736, Field Interlaced, SelTest: OK   		Crop 6x4@0x0, Compose 6x2@0x0, Stride 736, Field Interlaced, SelTest: OK   		Crop 720x576@0x0, Compose 6x2@0x0, Stride 736, Field Interlaced, SelTest: OK   		Crop 6x4@0x0, Compose 736x576@0x0, Stride 736, Field Interlaced, SelTest: OK   		Crop 720x576@0x0, Compose 736x576@0x0, Stride 736, Field Interlaced, SelTest: OK   	test MMAP for Format YUYV, Frame Size 736x576: Crop 720x576@0x0, Compose 720x576@0x0, Stride 1440, Field None: OK  		Crop 720x576@0x0, Compose 720x576@0x0, Stride 1440, Field Top: OK   		Crop 720x576@0x0, Compose 720x576@0x0, Stride 1440, Field Bottom: OK   		Crop 720x576@0x0, Compose 720x576@0x0, Stride 1440, Field Interlaced: OK   		Crop 720x576@0x0, Compose 720x576@0x0, Stride 1440, Field Interlaced Top-Bottom: OK   		Crop 720x576@0x0, Compose 720x576@0x0, Stride 1440, Field Interlaced Bottom-Top: OK   		Crop 6x4@0x0, Compose 720x576@0x0, Stride 1440, Field Interlaced, SelTest: OK   		Crop 6x4@0x0, Compose 6x2@0x0, Stride 1440, Field Interlaced, SelTest: OK   		Crop 720x576@0x0, Compose 6x2@0x0, Stride 1440, Field Interlaced, SelTest: OK   	test MMAP for Format UYVY, Frame Size 720x576: Crop 720x576@0x0, Compose 720x576@0x0, Stride 1440, Field None: OK  		Crop 720x576@0x0, Compose 720x576@0x0, Stride 1440, Field Top: OK   		Crop 720x576@0x0, Compose 720x576@0x0, Stride 1440, Field Bottom: OK   		Crop 720x576@0x0, Compose 720x576@0x0, Stride 1440, Field Interlaced: OK   		Crop 720x576@0x0, Compose 720x576@0x0, Stride 1440, Field Interlaced Top-Bottom: OK   		Crop 720x576@0x0, Compose 720x576@0x0, Stride 1440, Field Interlaced Bottom-Top: OK   	test MMAP for Format RGBP, Frame Size 720x576: Crop 720x576@0x0, Compose 720x576@0x0, Stride 1440, Field None: OK  		Crop 720x576@0x0, Compose 720x576@0x0, Stride 1440, Field Top: OK   		Crop 720x576@0x0, Compose 720x576@0x0, Stride 1440, Field Bottom: OK   		Crop 720x576@0x0, Compose 720x576@0x0, Stride 1440, Field Interlaced: OK   		Crop 720x576@0x0, Compose 720x576@0x0, Stride 1440, Field Interlaced Top-Bottom: OK   		Crop 720x576@0x0, Compose 720x576@0x0, Stride 1440, Field Interlaced Bottom-Top: OK   	test MMAP for Format XR15, Frame Size 720x576: Crop 720x576@0x0, Compose 720x576@0x0, Stride 1440, Field None: OK  		Crop 720x576@0x0, Compose 720x576@0x0, Stride 1440, Field Top: OK   		Crop 720x576@0x0, Compose 720x576@0x0, Stride 1440, Field Bottom: OK   		Crop 720x576@0x0, Compose 720x576@0x0, Stride 1440, Field Interlaced: OK   		Crop 720x576@0x0, Compose 720x576@0x0, Stride 1440, Field Interlaced Top-Bottom: OK   		Crop 720x576@0x0, Compose 720x576@0x0, Stride 1440, Field Interlaced Bottom-Top: OK   	test MMAP for Format XR24, Frame Size 720x576: Crop 720x576@0x0, Compose 720x576@0x0, Stride 2880, Field None: OK  		Crop 720x576@0x0, Compose 720x576@0x0, Stride 2880, Field Top: OK   		Crop 720x576@0x0, Compose 720x576@0x0, Stride 2880, Field Bottom: OK   		Crop 720x576@0x0, Compose 720x576@0x0, Stride 2880, Field Interlaced: OK   		Crop 720x576@0x0, Compose 720x576@0x0, Stride 2880, Field Interlaced Top-Bottom: OK   		Crop 720x576@0x0, Compose 720x576@0x0, Stride 2880, Field Interlaced Bottom-Top: OK

Total: 110, Succeeded: 110, Failed: 0, Warnings: 0