xref: /linux/Documentation/admin-guide/media/visl.rst (revision 1a562c0d44974d3cf89c6cc5c34c708c08af420e)
1.. SPDX-License-Identifier: GPL-2.0
2
3The Virtual Stateless Decoder Driver (visl)
4===========================================
5
6A virtual stateless decoder device for stateless uAPI development
7purposes.
8
9This tool's objective is to help the development and testing of
10userspace applications that use the V4L2 stateless API to decode media.
11
12A userspace implementation can use visl to run a decoding loop even when
13no hardware is available or when the kernel uAPI for the codec has not
14been upstreamed yet. This can reveal bugs at an early stage.
15
16This driver can also trace the contents of the V4L2 controls submitted
17to it.  It can also dump the contents of the vb2 buffers through a
18debugfs interface. This is in many ways similar to the tracing
19infrastructure available for other popular encode/decode APIs out there
20and can help develop a userspace application by using another (working)
21one as a reference.
22
23.. note::
24
25        No actual decoding of video frames is performed by visl. The
26        V4L2 test pattern generator is used to write various debug information
27        to the capture buffers instead.
28
29Module parameters
30-----------------
31
32- visl_debug: Activates debug info, printing various debug messages through
33  dprintk. Also controls whether per-frame debug info is shown. Defaults to off.
34  Note that enabling this feature can result in slow performance through serial.
35
36- visl_transtime_ms: Simulated process time in milliseconds. Slowing down the
37  decoding speed can be useful for debugging.
38
39- visl_dprintk_frame_start, visl_dprintk_frame_nframes: Dictates a range of
40  frames where dprintk is activated. This only controls the dprintk tracing on a
41  per-frame basis. Note that printing a lot of data can be slow through serial.
42
43- keep_bitstream_buffers: Controls whether bitstream (i.e. OUTPUT) buffers are
44  kept after a decoding session. Defaults to false so as to reduce the amount of
45  clutter. keep_bitstream_buffers == false works well when live debugging the
46  client program with GDB.
47
48- bitstream_trace_frame_start, bitstream_trace_nframes: Similar to
49  visl_dprintk_frame_start, visl_dprintk_nframes, but controls the dumping of
50  buffer data through debugfs instead.
51
52What is the default use case for this driver?
53---------------------------------------------
54
55This driver can be used as a way to compare different userspace implementations.
56This assumes that a working client is run against visl and that the ftrace and
57OUTPUT buffer data is subsequently used to debug a work-in-progress
58implementation.
59
60Information on reference frames, their timestamps, the status of the OUTPUT and
61CAPTURE queues and more can be read directly from the CAPTURE buffers.
62
63Supported codecs
64----------------
65
66The following codecs are supported:
67
68- FWHT
69- MPEG2
70- VP8
71- VP9
72- H.264
73- HEVC
74- AV1
75
76visl trace events
77-----------------
78The trace events are defined on a per-codec basis, e.g.:
79
80.. code-block:: bash
81
82        $ ls /sys/kernel/tracing/events/ | grep visl
83        visl_av1_controls
84        visl_fwht_controls
85        visl_h264_controls
86        visl_hevc_controls
87        visl_mpeg2_controls
88        visl_vp8_controls
89        visl_vp9_controls
90
91For example, in order to dump HEVC SPS data:
92
93.. code-block:: bash
94
95        $ echo 1 >  /sys/kernel/tracing/events/visl_hevc_controls/v4l2_ctrl_hevc_sps/enable
96
97The SPS data will be dumped to the trace buffer, i.e.:
98
99.. code-block:: bash
100
101        $ cat /sys/kernel/tracing/trace
102        video_parameter_set_id 0
103        seq_parameter_set_id 0
104        pic_width_in_luma_samples 1920
105        pic_height_in_luma_samples 1080
106        bit_depth_luma_minus8 0
107        bit_depth_chroma_minus8 0
108        log2_max_pic_order_cnt_lsb_minus4 4
109        sps_max_dec_pic_buffering_minus1 6
110        sps_max_num_reorder_pics 2
111        sps_max_latency_increase_plus1 0
112        log2_min_luma_coding_block_size_minus3 0
113        log2_diff_max_min_luma_coding_block_size 3
114        log2_min_luma_transform_block_size_minus2 0
115        log2_diff_max_min_luma_transform_block_size 3
116        max_transform_hierarchy_depth_inter 2
117        max_transform_hierarchy_depth_intra 2
118        pcm_sample_bit_depth_luma_minus1 0
119        pcm_sample_bit_depth_chroma_minus1 0
120        log2_min_pcm_luma_coding_block_size_minus3 0
121        log2_diff_max_min_pcm_luma_coding_block_size 0
122        num_short_term_ref_pic_sets 0
123        num_long_term_ref_pics_sps 0
124        chroma_format_idc 1
125        sps_max_sub_layers_minus1 0
126        flags AMP_ENABLED|SAMPLE_ADAPTIVE_OFFSET|TEMPORAL_MVP_ENABLED|STRONG_INTRA_SMOOTHING_ENABLED
127
128
129Dumping OUTPUT buffer data through debugfs
130------------------------------------------
131
132If the **VISL_DEBUGFS** Kconfig is enabled, visl will populate
133**/sys/kernel/debug/visl/bitstream** with OUTPUT buffer data according to the
134values of bitstream_trace_frame_start and bitstream_trace_nframes. This can
135highlight errors as broken clients may fail to fill the buffers properly.
136
137A single file is created for each processed OUTPUT buffer. Its name contains an
138integer that denotes the buffer sequence, i.e.:
139
140.. code-block:: c
141
142	snprintf(name, 32, "bitstream%d", run->src->sequence);
143
144Dumping the values is simply a matter of reading from the file, i.e.:
145
146For the buffer with sequence == 0:
147
148.. code-block:: bash
149
150        $ xxd /sys/kernel/debug/visl/bitstream/bitstream0
151        00000000: 2601 af04 d088 bc25 a173 0e41 a4f2 3274  &......%.s.A..2t
152        00000010: c668 cb28 e775 b4ac f53a ba60 f8fd 3aa1  .h.(.u...:.`..:.
153        00000020: 46b4 bcfc 506c e227 2372 e5f5 d7ea 579f  F...Pl.'#r....W.
154        00000030: 6371 5eb5 0eb8 23b5 ca6a 5de5 983a 19e4  cq^...#..j]..:..
155        00000040: e8c3 4320 b4ba a226 cbc1 4138 3a12 32d6  ..C ...&..A8:.2.
156        00000050: fef3 247b 3523 4e90 9682 ac8e eb0c a389  ..${5#N.........
157        00000060: ddd0 6cfc 0187 0e20 7aae b15b 1812 3d33  ..l.... z..[..=3
158        00000070: e1c5 f425 a83a 00b7 4f18 8127 3c4c aefb  ...%.:..O..'<L..
159
160For the buffer with sequence == 1:
161
162.. code-block:: bash
163
164        $ xxd /sys/kernel/debug/visl/bitstream/bitstream1
165        00000000: 0201 d021 49e1 0c40 aa11 1449 14a6 01dc  ...!I..@...I....
166        00000010: 7023 889a c8cd 2cd0 13b4 dab0 e8ca 21fe  p#....,.......!.
167        00000020: c4c8 ab4c 486e 4e2f b0df 96cc c74e 8dde  ...LHnN/.....N..
168        00000030: 8ce7 ee36 d880 4095 4d64 30a0 ff4f 0c5e  ...6..@.Md0..O.^
169        00000040: f16b a6a1 d806 ca2a 0ece a673 7bea 1f37  .k.....*...s{..7
170        00000050: 370f 5bb9 1dc4 ba21 6434 bc53 0173 cba0  7.[....!d4.S.s..
171        00000060: dfe6 bc99 01ea b6e0 346b 92b5 c8de 9f5d  ........4k.....]
172        00000070: e7cc 3484 1769 fef2 a693 a945 2c8b 31da  ..4..i.....E,.1.
173
174And so on.
175
176By default, the files are removed during STREAMOFF. This is to reduce the amount
177of clutter.
178