ROCK4 V4L2 Format listing doesn't match expectations

Hi,

I am trying to interface with the ROCK 4’s VPU via V4L2. I am running Linux 6.1 which provides two drivers that provide this interface, the hantro (mainlined in 6.0, supporting MPEG2 & VP8 decode on the RK3399’s VPU) driver, as well as the staging rkvdec driver (providing H264 & VP9 decode capability).

When I query the available V4L2 to devices via v4l2-ctl, though, the devices describe different capabilities:

  • /dev/video1, provided by rkvdec can only convert NV12 to H264 slices, i.e., it can encode raw data.
  • /dev/video2, provided by hantro as ‘rk3399-vpu-enc-source’, but advertises JPEG as its only input and YM12, NM12, YUYV, and UYVY as possible targets, which would make it a decoder (I assume?)
  • /dev/video3, provided by hantro as ‘rk3399-vpu-dec-source’ advertises conversion of NV12 to MPEG2 Slices, making it an encoder.

For completeness: there is a /dev/video0, provided by the rockchip-rga driver and two devices video-dec0 and video-{enc,dec}0 of unknown origin (they don’t appear to offer v4l2 capabilites and can’t be successfully probed by udevadm).

I am at a bit of a loss here, both because I don’t understand the mismatch between what I’d expect looking at the kernel, as well as the seemingly mislabeled driver devices. Am I doing something wrong here?

Thanks!

v4l2-ctl -d /dev/video1 --all:

Driver Info:
	Driver name      : rkvdec
	Card type        : rkvdec
	Bus info         : platform:rkvdec
	Driver version   : 6.1.24
	Capabilities     : 0x84204000
		Video Memory-to-Memory Multiplanar
		Streaming
		Extended Pix Format
		Device Capabilities
	Device Caps      : 0x04204000
		Video Memory-to-Memory Multiplanar
		Streaming
		Extended Pix Format
Media Driver Info:
	Driver name      : rkvdec
	Model            : rkvdec
	Serial           : 
	Bus info         : platform:rkvdec
	Media version    : 6.1.24
	Hardware revision: 0x00000000 (0)
	Driver version   : 6.1.24
Interface Info:
	ID               : 0x0300000c
	Type             : V4L Video
Entity Info:
	ID               : 0x00000001 (1)
	Name             : rkvdec-source
	Function         : V4L2 I/O
	Pad 0x01000002   : 0: Source
	  Link 0x02000008: to remote pad 0x1000004 of entity 'rkvdec-proc': Data, Enabled, Immutable
Priority: 2
Format Video Capture Multiplanar:
	Width/Height      : 48/48
	Pixel Format      : 'NV12' (Y/UV 4:2:0)
	Field             : None
	Number of planes  : 1
	Flags             : 
	Colorspace        : Rec. 709
	Transfer Function : Default
	YCbCr/HSV Encoding: Default
	Quantization      : Default
	Plane 0           :
	   Bytes per Line : 48
	   Size Image     : 4608
Format Video Output Multiplanar:
	Width/Height      : 48/48
	Pixel Format      : 'S264' (H.264 Parsed Slice Data)
	Field             : None
	Number of planes  : 1
	Flags             : 
	Colorspace        : Rec. 709
	Transfer Function : Default
	YCbCr/HSV Encoding: Default
	Quantization      : Default
	Plane 0           :
	   Bytes per Line : 0
	   Size Image     : 4608

Codec Controls

		     h264_level 0x00990a67 (menu)   : min=0 max=15 default=0 value=0
				0: 1
				1: 1b
				2: 1.1
				3: 1.2
				4: 1.3
				5: 2
				6: 2.1
				7: 2.2
				8: 3
				9: 3.1
				10: 3.2
				11: 4
				12: 4.1
				13: 4.2
				14: 5
				15: 5.1
		   h264_profile 0x00990a6b (menu)   : min=0 max=4 default=2 value=2
				0: Baseline
				1: Constrained Baseline
				2: Main
				4: High
		    vp9_profile 0x00990b00 (menu)   : min=0 max=0 default=0 value=0
				0: 0

Stateless Codec Controls

	       h264_decode_mode 0x00a40900 (menu)   : min=1 max=1 default=1 value=1
				1: Frame-Based
		h264_start_code 0x00a40901 (menu)   : min=1 max=1 default=1 value=1
				1: Annex B Start Code
    h264_sequence_parameter_set 0x00a40902 (unknown): type=200 flags=has-payload
     h264_picture_parameter_set 0x00a40903 (unknown): type=201 flags=has-payload
	    h264_scaling_matrix 0x00a40904 (unknown): type=202 flags=has-payload
	 h264_decode_parameters 0x00a40907 (unknown): type=204 flags=has-payload
    vp9_frame_decode_parameters 0x00a40a2c (unknown): type=261 flags=has-payload
      vp9_probabilities_updates 0x00a40a2d (unknown): type=260 flags=has-payload

v4l2-ctl -d /dev/video2 --all:

Driver Info:
	Driver name      : hantro-vpu
	Card type        : rockchip,rk3399-vpu-enc
	Bus info         : platform: hantro-vpu
	Driver version   : 6.1.24
	Capabilities     : 0x84204000
		Video Memory-to-Memory Multiplanar
		Streaming
		Extended Pix Format
		Device Capabilities
	Device Caps      : 0x04204000
		Video Memory-to-Memory Multiplanar
		Streaming
		Extended Pix Format
Media Driver Info:
	Driver name      : hantro-vpu
	Model            : hantro-vpu
	Serial           : 
	Bus info         : platform: hantro-vpu
	Media version    : 6.1.24
	Hardware revision: 0x00000000 (0)
	Driver version   : 6.1.24
Interface Info:
	ID               : 0x0300000c
	Type             : V4L Video
Entity Info:
	ID               : 0x00000001 (1)
	Name             : rockchip,rk3399-vpu-enc-source
	Function         : V4L2 I/O
	Pad 0x01000002   : 0: Source
	  Link 0x02000008: to remote pad 0x1000004 of entity 'rockchip,rk3399-vpu-enc-proc': Data, Enabled, Immutable
Priority: 2
Format Video Capture Multiplanar:
	Width/Height      : 96/32
	Pixel Format      : 'JPEG' (JFIF JPEG)
	Field             : None
	Number of planes  : 1
	Flags             : 
	Colorspace        : JPEG
	Transfer Function : Default
	YCbCr/HSV Encoding: Default
	Quantization      : Default
	Plane 0           :
	   Bytes per Line : 0
	   Size Image     : 6768
Format Video Output Multiplanar:
	Width/Height      : 96/32
	Pixel Format      : 'YM12' (Planar YUV 4:2:0 (N-C))
	Field             : None
	Number of planes  : 3
	Flags             : 
	Colorspace        : JPEG
	Transfer Function : Default
	YCbCr/HSV Encoding: Default
	Quantization      : Default
	Plane 0           :
	   Bytes per Line : 96
	   Size Image     : 3072
	Plane 1           :
	   Bytes per Line : 48
	   Size Image     : 768
	Plane 2           :
	   Bytes per Line : 48
	   Size Image     : 768
Selection Video Output: crop, Left 0, Top 0, Width 96, Height 32, Flags: 
Selection Video Output: crop_default, Left 0, Top 0, Width 96, Height 32, Flags: 
Selection Video Output: crop_bounds, Left 0, Top 0, Width 96, Height 32, Flags: 

JPEG Compression Controls

	    compression_quality 0x009d0903 (int)    : min=5 max=100 step=1 default=50 value=50
		 active_markers 0x009d0904 (bitmask): max=0x00070001 default=0x00070001 value=0x00070001

v4l2-ctl -d /dev/video3 --all:

Driver Info:
    Driver name      : hantro-vpu
    Card type        : rockchip,rk3399-vpu-dec
    Bus info         : platform: hantro-vpu
    Driver version   : 6.1.24
    Capabilities     : 0x84204000
        Video Memory-to-Memory Multiplanar
        Streaming
        Extended Pix Format
        Device Capabilities
    Device Caps      : 0x04204000
        Video Memory-to-Memory Multiplanar
        Streaming
        Extended Pix Format
Media Driver Info:
    Driver name      : hantro-vpu
    Model            : hantro-vpu
    Serial           : 
    Bus info         : platform: hantro-vpu
    Media version    : 6.1.24
    Hardware revision: 0x00000000 (0)
    Driver version   : 6.1.24
Interface Info:
    ID               : 0x0300001a
    Type             : V4L Video
Entity Info:
    ID               : 0x0000000f (15)
    Name             : rockchip,rk3399-vpu-dec-source
    Function         : V4L2 I/O
    Pad 0x01000010   : 0: Source
      Link 0x02000016: to remote pad 0x1000012 of entity 'rockchip,rk3399-vpu-dec-proc': Data, Enabled, Immutable
Priority: 2
Format Video Capture Multiplanar:
    Width/Height      : 48/48
    Pixel Format      : 'NV12' (Y/UV 4:2:0)
    Field             : None
    Number of planes  : 1
    Flags             : 
    Colorspace        : JPEG
    Transfer Function : Default
    YCbCr/HSV Encoding: Default
    Quantization      : Default
    Plane 0           :
       Bytes per Line : 48
       Size Image     : 3456
Format Video Output Multiplanar:
    Width/Height      : 48/48
    Pixel Format      : 'MG2S' (MPEG-2 Parsed Slice Data)
    Field             : None
    Number of planes  : 1
    Flags             : 
    Colorspace        : JPEG
    Transfer Function : Default
    YCbCr/HSV Encoding: Default
    Quantization      : Default
    Plane 0           :
       Bytes per Line : 0
       Size Image     : 4608
           vp8_frame_parameters 0x00a409c8 (unknown): type=240 flags=has-payload
         mpeg_2_sequence_header 0x00a409dc (unknown): type=251 flags=has-payload
          mpeg_2_picture_header 0x00a409dd (unknown): type=252 flags=has-payload
   mpeg_2_quantisation_matrices 0x00a409de (unknown): type=250 flags=has-payload