5.3. 多媒体系统调试指南

5.3.1. 控制节点

5.3.1.1. tuning server

功能:开启 tuning server。

说明: 使用该命令后, cam-service 将能够支持 tuning service,允许用户通过 vtuner 对 isp 进行参数 tuning。

命令:

echo 1 > /sys/kernel/debug/isp/tune

5.3.1.2. cam-service

功能:控制 cam-service 输出 log 等级。

说明: 使用该命令,可以控制 cam-service log 的输出 mask,根据 mask 输出对应等级的 log 打印。其中, bit0 为 error 级别, bit1 为 warning 级别, bit2 为 info 级别, bit3 为 debug 级别, bit4 为 verbose 级别。三个数字则分别对应 cam-service 中 isp adapter layer/3A、 isp auto control、 isp upper api 这三个部分的打印等级。

命令:

echo 31 31 31 > /sys/kernel/debug/isp/log

5.3.1.3. libcam/libvpf

功能:控制 libcam/libvpf 的输出 log 等级。

说明: 使用该命令,可以分别控制 libcam/libvpf 的日志输出等级。这两个动态库总共有四个打印等级,分别是 err, warning, info, debug,分别对应 1 , 2 , 3 , 4 。默认打印等级为 warning 级别,该命令修改打印等级, loglevel 为 4 时输出所有打印。

命令:

export CAM_LOGLEVEL=4
export VPF_LOGLEVEL=4

5.3.2. 统计信息节点

5.3.2.1. VPU 模块调试信息

VENC 编码

在调试 VPU 模块并获取信息时,需要先运行相应的编码或解码示例程序,然后再 cat /sys/kernel/debug/ 路径下对应的编解码模块。以 app/samples/platform_samples/sample_codec 为例,其中编码配置文件如下:

encode]
; 启用编码 , 按位运算
; 0x0 表示不启用编码
; 0x01 表示只启用 venc_stream1 编码流
; 0x02 表示只启用 venc_stream2 编码流
; 0x04 表示只启用 venc_stream3 编码流
; 0x08 表示只启用 venc_stream4 编码流
; 0x10 表示只启用 venc_stream5 编码流
; 0x03 表示只启用前两路编码流( venc_stream1  venc_stream2 ), 0x07 表示启用前三路编码流 , 0x0f 表示启用前四路编码流,以此类推
encode_streams = 0x1

[venc_stream1]
; 编码类型( 0  H264  1  H265  2  MJPEG, 3  JPEG)
codec_type = 0
width = 1920
height = 1080
frame_rate = 30
bit_rate = 8192
input = 1920x1080_NV12.yuv
output = 1920x1080_30fps.h264
frame_num = 100
external_buffer = 1
profile = h264_main@L4

[venc_stream2]
; 编码类型( 0  H264  1  H265  2  MJPEG, 3  JPEG)
codec_type = 1
width = 1280
height = 720
frame_rate = 25
bit_rate = 4096
input = 1280x720_NV12.yuv
output = 1280x720_25fps.h265
frame_num = 100
profile = h265_main@L4%high_tier

[venc_stream3]
; 编码类型( 0  H264  1  H265  2  MJPEG, 3  JPEG)
codec_type = 3
width = 1280
height = 720
frame_rate = 25
bit_rate = 4096
input = 1280x720_NV12.yuv
output = 1280x720.jpg
frame_num = 100

[venc_stream4]
; 编码类型( 0  H264  1  H265  2  MJPEG, 3  JPEG)
codec_type = 0
width = 640
height = 480
frame_rate = 30
bit_rate = 8192
input = 640x480_nv12.yuv
output = 640x480_30fps.h264
frame_num = 1000

运行编码程序:

默认使能一路 H264 编码: encode_streams = 0x1

root@buildroot:/app/platform_samples/sample_codec# ./sample_codec

打印输出:

Config file: codec_config.ini
encode_streams: 0x1
decode_streams: 0x0
Encoding video...
Encode params...
 codec_type: 0, width: 1920, height: 1080, frame_rate: 30, bit_rate: 8192, input_file: 1920x1080_NV12.yuv, output_file: 1920x1080_30fps.h264, frame_num: 100, profile: h264_main@L4, external_buffer: 1 performance_test:0
encode_video_external_buffer...
Encode idx: 0, init successful
Encode idx: 0, start successful
dequeue input buffer. src_idx(0), user_ptr((nil))
Encode idx: 0, frame= 1
on_encode_input_buffer_consumed userdata((nil)), inputBuffer->user_ptr(0xffffb0024810)
dequeue input buffer. src_idx(1), user_ptr((nil))
Encode idx: 0, frame= 2
on_encode_input_buffer_consumed userdata((nil)), inputBuffer->user_ptr(0xffffb0024fc0)
dequeue input buffer. src_idx(2), user_ptr((nil))
Encode idx: 0, frame= 3
....

命令:

cat /sys/kernel/debug/vpu/venc

功能:获取编码调试信息

输出示例:

----encode enc param----
enc_idx  enc_id     profile       level width height pix_fmt fbuf_count extern_buf_flag bsbuf_count bsbuf_size mirror rotate
      0    h264 unspecified unspecified  1920   1080       1          5               0           8    3110912      0      0

----encode h264cbr param----
enc_idx rc_mode intra_period intra_qp bit_rate frame_rate initial_rc_qp vbv_buffer_size mb_level_rc_enalbe min_qp_I max_qp_I min_qp_P max_qp_P min_qp_B max_qp_B hvs_qp_enable hvs_qp_scale qp_map_enable max_delta_qp
      0 h264cbr           30       30     8192         30            20              20                  1        8       50        8       50        8       50             1            2             0           10


----encode gop param----
enc_idx  enc_id gop_preset_idx custom_gop_size decoding_refresh_type
      0    h264              1               0                     2

----encode intra refresh----
enc_idx  enc_id intra_refresh_mode intra_refresh_arg
      0    h264                  0                 1

----encode longterm ref----
enc_idx  enc_id use_longterm longterm_pic_period longterm_pic_using_period
      0    h264            0                   0                         0

----encode roi_params----
enc_idx  enc_id roi_enable roi_map_array_count
      0    h264          0                   0

----encode h264 entropy params----
enc_idx  enc_id entropy_coding_mode
      0    h264               CABAC

----encode h264 slice params----
enc_idx  enc_id h264_slice_mode h264_slice_arg
      0    h264               0              0

----encode h264 deblk filter----
enc_idx  enc_id disable_deblocking_filter_idc slice_alpha_c0_offset_div2 slice_beta_offset_div2
      0    h264                             1                          0                      0

----encode h264 timing----
enc_idx  enc_id vui_num_units_in_tick vui_time_scale fixed_frame_rate_flag
      0    h264                  1000          60000                     0

----encode h264_intra_pred----
enc_idx  enc_id constrained_intra_pred_flag
      0    h264                           0

----encode h264_transform----
enc_idx  enc_id transform_8x8_enable chroma_cb_qp_offset chroma_cr_qp_offset user_scaling_list_enable
      0    h264                    1                   0                   0                        0

----encode h264 vui----
enc_idx  enc_id aspect_ratio_info_present_flag aspect_ratio_idc sar_width sar_height overscan_info_present_flag overscan_appropriate_flag video_signal_type_present_flag video_format video_full_range_flag colour_description_present_flag colour_primaries transfer_characteristics matrix_coefficients vui_timing_info_present_flag vui_num_units_in_tick vui_time_scale vui_fixed_frame_rate_flag bitstream_restriction_flag
      0    h264                              0                0         0          0                          0                         0                              1            0                     1                               0                0                        0                   0                            1                  1000          60000                         0                          0

----encode 3dnr----
enc_idx  enc_id nr_y_enable nr_cb_enable nr_cr_enable nr_est_enable nr_intra_weightY nr_intra_weightCb nr_intra_weightCr nr_inter_weightY nr_inter_weightCb nr_inter_weightCr nr_noise_sigmaY nr_noise_sigmaCb nr_noise_sigmaCr
      0    h264           0            0            0             0                0                 0                 0                0                 0                 0               0                0                0

----encode smart bg----
enc_idx  enc_id bg_detect_enable bg_threshold_diff bg_threshold_mean_diff bg_lambda_qp bg_delta_qp s2fme_disable
      0    h264                0                 0                      0            0           0             0

----encode status----
enc_idx  enc_id cur_input_buf_cnt cur_output_buf_cnt left_recv_frame left_enc_frame total_input_buf_cnt total_output_buf_cnt     fps
      0    h264                 0                  1               0              0               28985                28985      30

参数解析:

调试信息分组 状态参数 说明
encode enc param 基础编码参数 enc_idx:编码实例值 enc_id:编码类型 profile: profile 类型 level: h265 level 类型 width:编码宽度 height:编码高度 pix_fmt:输入帧像素类型 fbuf_count:输入的 FrameBuffer 数 extern_buf_flag:是否使用外部输入 buffer bsbuf_count: bitstreamBuffer 数 bsbuf_size: bitstreamBuffer 大小 mirror:是否设置镜像 rotate:是否设置旋转
encode h265cbr param CBR 码率控制参数 enc_idx:编码实例值 rc_mode:码率控制类型 intra_period: I 帧间隔 intra_qp: I 帧 qp 值 bit_rate:码率值 frame_rate:帧率 initial_rc_qp:初始 QP 值 vbv_buffer_size: VBV buffer 的大小 ctu_level_rc_enable:码率控制是否工作在 ctu 级别 min_qp_I: I 帧最小 QP 值 max_qp_I: I 帧最大 QP 值 min_qp_P: P 帧最小 QP 值 max_qp_P: P 帧最大 QP 值 min_qp_B: B 帧最小 QP 值 max_qp_B: B 帧最大 QP 值 hvs_qp_enable:码率控制是否工作在 subCTU 级别 hvs_qp_scale: QP 缩放因子 qp_map_enable:使能 ROI 编码时的 QP map max_delta_qp:指定 HVS QP 值的最大偏差范围
encode gop param GOP 参数 enc_idx:编码实例值 enc_id:编码类型 gop_preset_idx:选择预置的 GOP 结构 custom_gop_size:自定义时 GOP 的大小 decoding_refresh_type:设置 IDR 帧的具体类型
encode intra refresh 帧内刷新参数 enc_idx:编码实例值 enc_id:编码类型 intra_refresh_mode:帧内刷新模式 intra_refresh_arg:帧内刷新参数
encode longterm ref 长期参考帧参数 enc_idx:编码实例值 enc_id:编码类型 use_longterm:使能长期参考帧 longterm_pic_period:长期参考帧周期 longterm_pic_using_period:参考长期参考帧的周期
encode roi_params ROI 参数 enc_idx:编码实例值 enc_id:编码类型 roi_enable:使能 ROI 编码 roi_map_array_count: ROI map 中元素的个数
encode mode_decision 1 块编码模式决策参数 1 各种模式选择参数值,包括 pu04_delta_rate, pu08_delta_rate 等
encode mode_decision 2 块编码模式决策参数 2 各种模式选择参数值,包括 pu32_intra_planar_delta_rate, pu32_intra_dc_delta_rate 等
encode h265_transform Transform 参数 enc_idx:编码实例值 enc_id:编码类型 chroma_cb_qp_offset:指定 cb 分量的 QP 偏差 chroma_cr_qp_offset:指定 cr 分量的 QP 偏差 user_scaling_list_enable:使能用户指定的 scaling list
encode h265_pred_unit 预测单元参数 enc_idx:编码实例值 enc_id:编码类型 intra_nxn_enable:使能 intra NXN PUs constrained_intra_pred_flag:帧内预测是否受限 strong_intra_smoothing_enabled_flag:滤波过程是否使用双向线性插值 max_num_merge:指定 merge 候选的数量
encode h265 timing Timing 参数 enc_idx:编码实例值 enc_id:编码类型 vui_num_units_in_tick:指定时间单位数 vui_time_scale:一秒内的时间单位数 vui_num_ticks_poc_diff_one_minus1 :指定与等于 1 的图片顺序计数值之差对应的时钟滴答数
encode h265 slice params Slice 参数 enc_idx:编码实例值 enc_id:编码类型 h265_independent_slice_mode:独立 slice 编码模式 h265_independent_slice_arg:独立 slice 的大小 h265_dependent_slice_mode:非独立 slice 编码模式 h265_dependent_slice_arg:非独立 slice 的大小
encode h265 deblk filter 去块滤波参数 enc_idx:编码实例值 enc_id:编码类型 slice_deblocking_filter_disabled_flag:是否进行 slice 内部滤波 slice_beta_offset_div2 :指定当前切片的 β 去块参数偏移量 slice_tc_offset_div2 :指定当前切片的 tC 去块参数偏移量 slice_loop_filter_across_slices_enabled_flag:是否进行边界滤波
encode h265 sao param SAO 参数 enc_idx:编码实例值 enc_id:编码类型 sample_adaptive_offset_enabled_flag:是否对经过去块滤波处理后的重构图像进行采样自适应偏移处理
encode status 当前编码状态参数 enc_idx:编码实例值 enc_id:编码类型 cur_input_buf_cnt:当前使用的 inputbuffer 数量 cur_output_buf_cnt:当前使用的 outputbuffer 数量 left_recv_frame:剩余需要接收的帧数(设置 receive_frame_number 后有效) left_enc_frame:剩余需要编码的帧数(设置 receive_frame_number 后有效) total_input_buf_cnt:表示当前总使用的 inputbuffer 数 total_output_buf_cnt:表示当前总使用的 outputbuffer 数 fps:表示当前的帧率

说明: VPU(视频处理单元)是一种专用的视觉处理模块,专用于高效处理视频内容。它支持 H.264/H.265 视频格式的编码,并通过 Codec 提供的接口,供用户获取编码后的视频流。

VDEC 解码

以 app/samples/platform_samples/sample_codec 为例,其中解码配置文件如下:

[decode]
; 启用解码,按位运算
; 0x0 表示不启用解码
; 0x01 表示只启用 vdec_stream1 解码流
; 0x02 表示只启用 vdec_stream2 解码流
; 0x03 表示只启用前两路解码流( vdec_stream1  vdec_stream2 ), 0x07 表示启用前三路解码流 , 0x0f 表示启动前四路解码流,以此类推
decode_streams = 0x0

[vdec_stream1]
; 编码类型( 0  H264  1  H265  2  MJPEG, 3  JPEG)
codec_type = 0
width = 1920
height = 1080
input = 1920x1080_30fps.h264
output = 1920x1080_NV12.yuv

[vdec_stream2]
; 编码类型( 0  H264  1  H265  2  MJPEG, 3  JPEG)
codec_type = 1
width = 1280
height = 720
input = 1280x720_25fps.h265
output = 1280x720_NV12.yuv

[vdec_stream3]
; 编码类型( 0  H264  1  H265  2  MJPEG, 3  JPEG)
codec_type = 3
width = 1280
height = 720
input = 1280x720.jpg
output = 1280x720_NV12.yuv

[vdec_stream4]
; 编码类型( 0  H264  1  H265  2  MJPEG, 3  JPEG)
codec_type = 0
width = 640
height = 480
input = 640x480_30fps.h264
output = 640x480_nv12.yuv

运行解码程序:

关闭编码,启动 vdec_stream1 解码

root@buildroot:/app/platform_samples/sample_codec# ./sample_codec -e 0 -d 0x1

打印输出:

Config file: codec_config.ini
encode_streams: 0x0
decode_streams: 0x1
Decode params...
 codec_type: 0, width: 1920, height: 1080, input_file: 1920x1080_30fps.h264, output_file: 1920x1080_NV12.yuv
Decode idx: 0, init successful
Init video decode instance 0 successful
Decode idx: 0, start successful
Decoding video...
Decoding output video...
[h264 @ 0xffff68000d50] Stream #0: not enough frames to estimate rate; consider increasing probesize
p_param->frame_num: 98
decode output continue
No more valid data available for decoding, avpacket.size: 0. Decoder will exit due to timeout after fetching decoded output.
decode output continue
Decode idx: 0, hb_mm_mc_dequeue_output_buffer timed out (possibly normal exit due to lack of data)
decode output continue
Decode idx: 0, stop successful
Decode idx: 0, deinit successful
deinit video decode instance 0 successful
....

命令:

cat /sys/kernel/debug/vpu/vdec

功能:获取 vdec 解码调试信息

输出示例:

----decode param----
dec_idx  dec_id feed_mode pix_fmt bitstream_buf_size bitstream_buf_count frame_buf_count
      0    h264         1       1            3110912                   3               3
----h264 decode param----
dec_idx  dec_id reorder_enable skip_mode bandwidth_Opt
      0    h264              1         0             1

----decode frameinfo----
dec_idx  dec_id display_width display_height
      0    h264          1920           1080
----decode status----
dec_idx  dec_id cur_input_buf_cnt cur_output_buf_cnt total_input_buf_cnt total_output_buf_cnt     fps
      0    h264                 0                  1                  66                   62      12

参数解析:

调试信息分组 状态参数 说明
decode param 基础解码参数 dec_idx:解码实例值 dec_id:解码类型 feed_mode:数据填充类型 pix_fmt:输出像素类型 bitstream_buf_size:输入的 bitstream 缓存区大小 bitstream_buf_count:输入的 bitstream 缓存区个数 frame_buf_count:输出的 Framebuffer 缓存的个数
h264 decode param H264 解码基础参数 dec_idx:解码实例值 dec_id:解码类型 reorder_enable:使能解码器按显示顺序输出帧序列 skip_mode:使能帧解码忽略模式 bandwidth_Opt:使能节省带宽模式
decode frameinfo 解码输出帧信息 dec_idx:解码实例值 dec_id:解码类型 display_width:显示的宽度 display_height:显示的高度
decode status 当前解码状态参数 dec_idx:解码实例值 dec_id:解码类型 cur_input_buf_cnt:当前使用的 inputbuffer 数量 cur_output_buf_cnt:当前使用的 outputbuffer 数量 total_input_buf_cnt:当前总使用的 inputbuffer 数 total_output_buf_cnt:当前总使用的 outputbuffer 数 fps:当前帧率

说明: VPU(视频处理单元)是一种专用的视觉处理模块,专用于高效处理视频内容。它支持 H.264/H.265 视频格式的解码,并通过 Codec 提供的接口,供用户获取解码后的视频流。

5.3.2.2. JPU 模块调试信息

JENC 编码

以 app/samples/platform_samples/sample_codec 为例,输入命令运行如下:

启用 vdec_stream3 使用 jpeg 编码

root@buildroot:/app/platform_samples/sample_codec# ./sample_codec -e 0x4

打印输出:

root@buildroot:/app/platform_samples/sample_codec# ./sample_codec -e 0x4
Config file: codec_config.ini
encode_streams: 0x4
decode_streams: 0x0
Encoding video...
Encode params...
 codec_type: 3, width: 1280, height: 720, frame_rate: 25, bit_rate: 4096, input_file: 1280x720_NV12.yuv, output_file: 1280x720.jpg, frame_num: 100, profile: , external_buffer: 0 performance_test:0
encode_video...
Encode idx: 0, init successful
Encode idx: 0, start successful
Encode idx: 0, frame= 1
Encode idx: 0, frame= 2
....
Encode idx: 0, frame= 100

命令:

cat /sys/kernel/debug/jpu/jenc

功能:获取 JPEG 编码调试信息

输出示例:

----encode param----
enc_idx  enc_id width height pix_fmt fbuf_count extern_buf_flag bsbuf_count bsbuf_size mirror rotate
      0    jpeg  1280    720       1          3               0           3    1384448      0      0

----encode rc param----
enc_idx   rc_mode frame_rate quality_factor
      0 noratecontrol          0             50


----encode status----
enc_idx  enc_id cur_input_buf_cnt cur_output_buf_cnt left_recv_frame left_enc_frame total_input_buf_cnt total_output_buf_cnt     fps
      0    jpeg                 0                  1               0              0                  40                   40      28

参数解析:

调试信息分组 状态参数 说明
encode param 基础编码参数 enc_idx:编码实例 enc_id:编码类型 width:图像宽度 height:图像高度 pix_fmt:像素类型 fbuf_count:输入的 Framebuffer 缓存的个数 extern_buf_flag:是否使用用户分配的输入 buffer bsbuf_count:输出的 bitstream 缓存区个数 bsbuf_size:输出的 bitstream 的大小 mirror:是否设置镜像 rotate:是否设置旋转
encode rc param mjpeg 码率控制参数 enc_idx:编码实例值 rc_mode:码率控制模式 frame_rate:目标帧率 quality_factor:量化因子
encode status 当前编码状态 enc_idx:编码实例值 enc_id:编码类型 cur_input_buf_cnt:当前使用的 inputbuffer 数量 cur_output_buf_cnt:当前使用的 outputbuffer 数量 left_recv_frame:剩余需要接收的帧数(设置 receive_frame_number 后有效) left_enc_frame:剩余需要编码的帧数(设置 receive_frame_number 后有效) total_input_buf_cnt:表示当前总使用的 inputbuffer 数 total_output_buf_cnt:表示当前总使用的 outputbuffer 数 fps:当前帧率

说明:

JPU(图片处理单元)主要用以完成 JPEG/MJPEG 的编码功能。用户可以通过 CODEC 接口输入待编码的 YUV 数据,通过 JPU 处理后获取编码完的 JPEG/MJPEG 图片。

JDEC 解码

以 app/samples/platform_samples/sample_codec 为例,输入命令运行如下:

启用 vdec_stream3 进行 jpeg 解码

root@buildroot:/app/platform_samples/sample_codec# ./sample_codec -e 0 -d 0x4

打印输出:

Config file: codec_config.ini
encode_streams: 0x4
decode_streams: 0x0
Encoding video...
Encode params...
 codec_type: 3, width: 1280, height: 720, frame_rate: 25, bit_rate: 4096, input_file: 1280x720_NV12.yuv, output_file: 1280x720.jpg, frame_num: 100, profile: , external_buffer: 0 performance_test:0
encode_video...
Encode idx: 0, init successful
Encode idx: 0, start successful
Encode idx: 0, frame= 1
Encode idx: 0, frame= 2
....
Encode idx: 0, frame= 100

命令:

cat /sys/kernel/debug/jpu/jdec

功能:获取 jdec 解码调试信息

输出示例:

----decode param----
dec_idx  dec_id feed_mode pix_fmt bitstream_buf_size bitstream_buf_count frame_buf_count mirror rotate
      0    jpeg         1       1            1382400                   3               3      0      0

----decode frameinfo----
dec_idx  dec_id display_width display_height
      0    jpeg             0              0

----decode status----
dec_idx  dec_id cur_input_buf_cnt cur_output_buf_cnt total_input_buf_cnt total_output_buf_cnt     fps
      0    jpeg                 0                  0                   0                    0       0

参数解析:

调试信息分组 状态参数 说明
decode param 解码基础参数 dec_idx:解码实例 dec_id:解码类型 feed_mode: pix_fmt:图像像素 bitstream_buf_size:输入的 bitstream 缓存区大小 bitstream_buf_count:输入的 bitstream 缓存区个数 frame_buf_count:输出的 Framebuffer 缓存的个数 mirror:是否设置镜像 rotate:是否设置旋转
decode frameinfo 解码输出帧信息 dec_idx:解码实例值 dec_id:解码类型 display_width:显示的宽度 display_height:显示的高度
decode status 当前编码状态参数 dec_idx:解码实例值 dec_id:解码类型 cur_input_buf_cnt:当前使用的 inputbuffer 数量 cur_output_buf_cnt:当前使用的 outputbuffer 数量 total_input_buf_cnt:当前总使用的 inputbuffer 数 total_output_buf_cnt:当前总使用的 outputbuffer 数 fps:当前帧率

说明: JPU(图片处理单元)主要用以完成 JPEG/MJPEG 的解码功能。用户可以通过 CODEC 接口输入待解码的 JPEG 图片,通过 JPU 处理后获取解码完的 YUV 数据。

5.3.2.3. 中断统计信息

功能:输出各模块的中断次数。

命令:

watch -n 1 'grep -E "sif|isp|vse|gdc" /proc/interrupts'

输出示例:

/proc/interrupts:40: 62:          0          0          0          0          0          0          0          0     GICv3  69 Level     sif
/proc/interrupts:41: 63:          0          0          0          0          0          0          0          0     GICv3  70 Level     sif
/proc/interrupts:42: 64:      54451          0          0          0          0          0          0          0     GICv3  71 Level     sif
/proc/interrupts:43: 65:          0          0          0          0          0          0          0          0     GICv3  72 Level     sif
/proc/interrupts:48: 70:     134309          0          0          0          0          0          0          0     GICv3  75 Level     isp
/proc/interrupts:52: 74:      54342          0          0          0          0          0          0          0     GICv3  82 Level     vse
/proc/interrupts:53: 75:          0          0          0          0          0          0          0          0     GICv3  80 Level     gdc

说明: 打印当前视频流运行过程中各模块产生的中断次数,当完整链路出现错误时,可以根据各模块的中断次数来判断是哪个模块发生了异常。

5.3.2.4. 帧率信息

功能:输出帧率

命令:

cat /sys/devices/virtual/vps/flow/fps

输出示例:

-------------------------------------------------------------------
                              Flow0 FPS
-------------------------------------------------------------------
  vin3 ctx 0: | ich0   0 | och0   0 | och3   0 | och4   0 |
  isp0 ctx 0: | ich0   0 | och0  30 |
-------------------------------------------------------------------
                              Flow1 FPS
-------------------------------------------------------------------
  vin2 ctx 0: | ich0   0 | och0   0 | och3   0 | och4   0 |
  isp0 ctx 1: | ich0   0 | och0  30 |
-------------------------------------------------------------------
                              Flow2 FPS
-------------------------------------------------------------------
  vin0 ctx 0: | ich0   0 | och0   0 | och3   0 | och4   0 |
  isp0 ctx 2: | ich0   0 | och0  30 |
-------------------------------------------------------------------
                              Flow3 FPS
-------------------------------------------------------------------
  vin1 ctx 0: | ich0   0 | och0   0 | och3   0 | och4   0 |
  isp0 ctx 3: | ich0   0 | och0  30 |

说明: 此命令用于输出当前各视频通路(Flow)的帧率信息。以 get_isp_data 为例,在运行相关示例程序后,执行此命令可查看不同视频输入流(vin)和图像处理器上下文(isp)的帧率数据,输出中的每一行表示对应设备或通道的帧率信息。

命令:

cat /sys/devices/virtual/vps/flow/fps_stats

输出示例:

flowid mod    c_id   chn     fcnt   avg_fps   cur_fps
0      vin2   0
                     0       0     0.000     0.000
                     8       0     0.000     0.000
                     11      0     0.000     0.000
                     12      0     0.000     0.000

0      isp0   0
                     0       0     0.000     0.000
                     8      95    10.070     0.000

0      vse0   0
                     0       0     0.000     0.000
                     8      95    10.074     0.000
                     9       0     0.000     0.000
                     10      0     0.000     0.000
                     11      0     0.000     0.000
                     12      0     0.000     0.000
                     13      0     0.000     0.000

0      gdc0   0
                     0      95    10.074     0.000
                     8      95    10.079     0.000

说明: 打印所有在跑的模块的 fps,该 fps 为某模块输出到 ddr,且未被软件视为丢帧时的 fps。当某模块 online 到下级模块时不会有该信息,当出现丢帧时,则该统计值会小于预定 sensor 的 fps。需要注意的是,使用该节点需要打开 sif 的 timestamp 功能,对应 json 的配置可以参考如下:

	"function": {
		"enable_frame_id": 1,
		"set_init_frame_id": 1,
		"time_stamp_en": 1,
		"time_stamp_mode": 3,
		"ts_trigger_source": 1,
		"pps_trigger_source": 6
	}

5.3.2.5. 时间戳信息

功能:输出最近 5 帧时间戳。

命令:

cat /sys/devices/virtual/vps/flow/vio_delay

输出示例:

------------------------------- pipe 0 vio info -------------------------------
frameid  module FS              FE              QB              DQ
00000515 sif    00000184.562367 00000184.595320 00000184.592899 00000184.592901
00000516 sif    00000184.595700 00000184.628653 00000184.626232 00000184.626235
00000517 sif    00000184.629033 00000184.661986 00000184.659558 00000184.659560
00000518 sif    00000184.662366 00000000.000000 00000000.000000 00000000.000000
00000514 sif    00000184.529033 00000184.561986 00000184.559557 00000184.559560

00000515 isp    00000184.593734 00000184.596138 00000184.596186 00000000.000000
00000516 isp    00000184.627070 00000184.629533 00000184.629521 00000000.000000
00000517 isp    00000184.660506 00000184.662958 00000184.662946 00000000.000000
00000513 isp    00000184.527066 00000184.529460 00000184.529506 00000000.000000
00000514 isp    00000184.560459 00000184.562863 00000184.562910 00000000.000000

00000000 vse    00000000.000000 00000184.599267 00000184.599266 00000184.596168
00000000 vse    00000000.000000 00000184.632600 00000184.632600 00000184.629503
00000000 vse    00000000.000000 00000184.666027 00000184.666026 00000184.662929
00000000 vse    00000000.000000 00000184.532586 00000184.532585 00000184.529489
00000000 vse    00000000.000000 00000184.565982 00000184.565981 00000184.562894

00000000 gdc    00000000.000000 00000000.000000 00000000.000000 00000000.000000
00000000 gdc    00000000.000000 00000000.000000 00000000.000000 00000000.000000
00000000 gdc    00000000.000000 00000000.000000 00000000.000000 00000000.000000
00000000 gdc    00000000.000000 00000000.000000 00000000.000000 00000000.000000
00000000 gdc    00000000.000000 00000000.000000 00000000.000000 00000000.000000

00000000 n2d    00000000.000000 00000000.000000 00000000.000000 00000000.000000
00000000 n2d    00000000.000000 00000000.000000 00000000.000000 00000000.000000
00000000 n2d    00000000.000000 00000000.000000 00000000.000000 00000000.000000
00000000 n2d    00000000.000000 00000000.000000 00000000.000000 00000000.000000
00000000 n2d    00000000.000000 00000000.000000 00000000.000000 00000000.000000

说明: 打印所有在跑的模块的对应动作 (Frame start/Frame end/Queue buffer/Dqueue buffer) 时的时间戳(以秒为单位),该统计信息打印最近 5 帧 frameid 对应的时间戳。如果出现某帧数据为 0 ,说明该时刻还未到来。驱动会在 Frame end 去 Queue buffer/Dqueue buffer 操作,所以这三个时刻相近,且在 Frame end 之后。 VSE 模块因为硬件原因没有 Frame start 中断,因此该节点的此值为空。 frameid 使用 Frame start 时刻的 frameid,若没有 Frame start, frameid 值为空。

5.3.2.6. 延时信息

功能:输出模块处理一次数据的延时情况。

命令:

cat /sys/devices/virtual/vps/flow/delay_stats

输出示例:

---------------------------------------------------------------------------------------
flowid    module    ctx_id    chn   cur_delay_ms min_delay_ms avg_delay_ms max_delay_ms
---------------------------------------------------------------------------------------
0         vin0      0
                              ich0             0            0            0            0
                              och0            30           30           30           30
                              och3             0            0            0            0
                              och4             0            0            0            0

0         isp0      0
                              ich0             0            0            0            0
                              och0            33           33           33           34

0         vse0      0
                              ich0             0            0            0            0
                              och0            36           36           36           37
                              och1            36           36           36           37
                              och2            36           36           36           37
                              och3            36           36           36           37
                              och4            36           36           36           37
                              och5            36           36           36           37

说明: SIF 在 Frame start 时,会在内核获取当前的时间戳,这个时间戳会跟随这帧图像沿 vio 通路一直向后。该命令打印所有在跑的模块,当这个模块 framedone 也就是处理完成时,当前时间戳与 sif 时刻获取的时间戳之间的差值,也就是一帧图像从被 sif 接收到某个模块处理完成的时间延时。该节点信息依赖 offline 时的 framedone,没有保存到 ddr 的模块无法显示该信息。当某个模块没有 framedone 信息时,例如应用层没有获取图像 buffer,驱动会认为是软件丢帧,对应的节点也不会更新,将保持最后一次的信息。

5.3.2.7. 丢帧信息

功能:输出模块的丢帧信息。

命令:

cat /sys/devices/virtual/vps/flow/drop_info
cat /sys/devices/virtual/vps/flow/drop_stats

说明: 第一条命令打印所有在跑的模块,最近的几帧丢帧数据的 frameid。第二条命令打印所有在跑的模块,统计其丢帧的帧率,软件丢帧出现在 framedone 时,如果某个模块没有保存数据到 ddr,则不会出现软件丢帧。这两条功能暂时不支持。

5.3.2.8. 驱动 buffer 状态

功能:输出 buffer 状态。

命令:

cat /sys/devices/virtual/vps/flow/fmgr_stats

输出示例:

------------------------------------------------------------------------------
flowid    module    ctx_id    chn    FREE   REQUEST   PROCESS  COMPLETE  USED
------------------------------------------------------------------------------
0         vin0      0
                              ich0     16         0         0         0     0
                              och0      0         5         1         0     0

0         isp0      0
                              ich0     10         0         0         0     6
                              och0      0         6         0         0     0

0         vse0      0
                              ich0     10         0         0         0     6
                              och0      0         4         0         0     0
                              och1      0         4         0         0     0
                              och2      0         4         0         0     0
                              och3      0         4         0         0     0
                              och4      0         4         0         0     0
                              och5      0         4         0         0     0

说明: 打印所有在跑的模块,其输入输出通道的各个状态的 buffer 数量。

5.3.2.9. vio 通路信息

功能:输出通路状态。

命令:

cat /sys/devices/virtual/vps/flow/path_stat

输出示例:

(active)[S0] vin0_C0*(dma)-m2m-isp0_C0-m2m-vse0_C0

说明: 打印所有在跑的视频通路 ip 间的连接信息, S[ 数字 ] 表示当前通路的 flowid,模块名字后面的数字为 hw_id, C[ 数字 ] 表示其软件 ctx_id, dma 代表输出图像到 ddr, m2m 代表 offline 到后级模块, otf 代表直连到后级模块。

5.3.2.10. MIPI 中断

功能:查看 MIPI 中断计数。

命令:

cat /proc/interrupts |grep mipi_host

输出示例:

 66:          0          0          0          0          0          0          0          0     GICv3  76 Level     3d060000.mipi_host
 67:          0          0          0          0          0          0          0          0     GICv3  78 Level     3d070000.mipi_host
 68:          0          0          0          0          0          0          0          0     GICv3  77 Level     3d080000.mipi_host
 69:          0          0          0          0          0          0          0          0     GICv3  79 Level     3d090000.mipi_host

说明: 在 MIPI 模块正常运行过程中,不会触发中断,只有发生错误时 MIPI 模块才会产生中断,通过上述命令可以查看模块加载以来的总中断计数。

5.3.2.11. MIPI 状态寄存器

功能:查看 MIPI 中断计数。

命令:

cat /sys/class/vps/mipi_host0/status/regs

输出示例:

root@buildroot:/userdata/gmsl# cat /sys/class/vps/mipi_host0/status/regs
0x000: 0x30313534       - VERSION
0x004: 0x3      - N_LANES
0x008: 0x0      - CSI2_RESETN
0x040: 0x0      - PHY_SHUTDOWNZ
0x044: 0x0      - DPHY_RSTZ
0x048: 0x10000  - PHY_RX
0x04c: 0x0      - PHY_STOPSTATE
0x0cc: 0x0      - PHY_CAL
0x0a0: 0x1111   - IPI_SOFTRSTN
0x010: 0x0      - DATA_IDS_1
0x014: 0x0      - DATA_IDS_2
0x018: 0x0      - PHY_CFG
0x01c: 0x0      - PHY_MODE
0x030: 0x0      - DATA_IDS_VC1
0x034: 0x0      - DATA_IDS_VC2
0x00c: 0x0      - INT_ST_MAIN
0x0e0: 0x0      - INT_ST_PHY_FATAL
0x0f0: 0x0      - INT_ST_PKT_FATAL
0x110: 0x0      - INT_ST_PHY
0x130: 0x0      - INT_ST_LINE
0x140: 0x0      - INT_ST_IPI
0x150: 0x0      - INT_ST_IPI2
0x160: 0x0      - INT_ST_IPI3
0x170: 0x0      - INT_ST_IPI4
0x280: 0x0      - INT_ST_BNDRY_FRAME_FATAL
0x290: 0x0      - INT_ST_SEQ_FRAME_FATAL
0x2a0: 0x0      - INT_ST_CRC_FRAME_FATAL
0x2b0: 0x0      - INT_ST_PLD_CRC_FATAL
0x2c0: 0x0      - INT_ST_DATA_ID
0x2d0: 0x0      - INT_ST_ECC_CORRECT
0x0e4: 0x0      - INT_MSK_PHY_FATAL
0x0f4: 0x0      - INT_MSK_PKT_FATAL
0x114: 0x0      - INT_MSK_PHY
0x134: 0x0      - INT_MSK_LINE
0x144: 0x0      - INT_MSK_IPI
0x154: 0x0      - INT_MSK_IPI2
0x164: 0x0      - INT_MSK_IPI3
0x174: 0x0      - INT_MSK_IPI4
0x284: 0x0      - INT_MSK_BNDRY_FRAME_FATAL
0x294: 0x0      - INT_MSK_SEQ_FRAME_FATAL
0x2a4: 0x0      - INT_MSK_CRC_FRAME_FATAL
0x2b4: 0x0      - INT_MSK_PLD_CRC_FATAL
0x2c4: 0x0      - INT_MSK_DATA_ID
0x2d4: 0x0      - INT_MSK_ECC_CORRECT
0x080: 0x1010000        - IPI_MODE
0x084: 0x0      - IPI_VCID
0x088: 0x1e     - IPI_DATA_TYPE
0x08c: 0x100    - IPI_MEM_FLUSH
0x090: 0x4      - IPI_HSA_TIME
0x094: 0x4      - IPI_HBP_TIME
0x098: 0x1a     - IPI_HSD_TIME
0x09c: 0x0      - IPI_HLINE_TIME
0x0ac: 0x1030000        - IPI_ADV_FEATURES
0x0b0: 0x0      - IPI_VSA_LINES
0x0b4: 0x0      - IPI_VBP_LINES
0x0b8: 0x0      - IPI_VFP_LINES
0x0bc: 0x0      - IPI_VACTIVE_LINES
0x200: 0x1010000        - IPI2_MODE
0x204: 0x1      - IPI2_VCID
0x208: 0x1e     - IPI2_DATA_TYPE
0x20c: 0x100    - IPI2_MEM_FLUSH
0x210: 0x4      - IPI2_HSA_TIME
0x214: 0x4      - IPI2_HBP_TIME
0x218: 0x1a     - IPI2_HSD_TIME
0x21c: 0x1030000        - IPI2_ADV_FEATURES

说明: 以下为 MIPI 错误状态寄存器,列出重点关注部分:

  • INT_ST_PHY_FATAL

    • [7:0]: 0xff phy_errsotsynchs_7..0 :

      • 报错:对应 data lane 的 SOT 错 ( 未收到 sync)。

      • 排查:配置文件是否正确

    • [8]: 0x100 err_deskew

      • 报错: lane 间 skew 大于 2 个 rxworldhs,数据丢失

  • INT_ST_SEQ_FRAME_FATAL

    • [31:0]: 0xFFFFFFFF err_f_seq_vc31..0 :

      • 报错:对应的 VC 帧号不连续,丢帧。

      • 排查:带宽是否足够, serdes 状态和硬件信号

  • INT_ST_CRC_FRAME_FATAL

    • [31:0]: 0XFFFFFFFF err_frame_data_vc31..0

      • 报错:对应 vc 上的帧中至少有 1 个 CRC 错误

      • 排查: serdes 状态和硬件信号

  • INT_ST_PHY

    • [7:0]: 0x0000FF phy_errsoths_7..0

      • 报错:对应 data lane 的 SOT 错 ( 未收到 sync)。

      • 排查:配置文件 mipiclk 和 settle 配置是否正确

    • [23:16]: 0xFF0000 phy_errsoths_7..0

      • 报错:对应 data lane 的 SOT 错 ( 未收到 sync)。

      • 排查:配置文件 mipiclk 和 settle 配置是否正确

5.3.2.12. MIPI 中断打印

功能:查看当前打印限制,并解除 MIPI 模块打印报错的限制。

命令:

# 查看当前限制 :
cat /sys/class/vps/mipi_host0/param/irq_cnt

命令:

# 配置无限制 (debug 使用 ):
echo 0xffffffff > /sys/class/vps/mipi_host0/param/irq_cnt

输出示例:

root@buildroot:/userdata/gmsl# cat /sys/class/vps/mipi_host0/param/irq_cnt
10

说明: 如果发现 MIPI 仅打印十余行错误信息后停止,这并不意味着错误已消失,可能是中断日志被限制。可通过写入 irq_cnt 参数来增加打印行数,以获取更详细的错误信息。