[Camera][JP-7.2/r39.2] v4l2 fails to capture images

Hi NV_Team,

I encountered an error while debugging another camera (ISX031 → IMX623) based on the same hardware setup (MAX96712 + MAX96717).Please help analyze it.

$ v4l2-ctl --list-formats-ext -d /dev/video0
ioctl: VIDIOC_ENUM_FMT
        Type: Video Capture

        [0]: 'RG12' (12-bit Bayer RGRG/GBGB)
                Size: Discrete 1920x1536
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 1920x1536
                        Interval: Discrete 0.033s (30.000 fps)

$ v4l2-ctl --get-fmt-video -d /dev/video0
Format Video Capture:
        Width/Height      : 1920/1536
        Pixel Format      : 'RG12' (12-bit Bayer RGRG/GBGB)
        Field             : None
        Bytes per Line    : 3840
        Size Image        : 5898240
        Colorspace        : sRGB
        Transfer Function : Default (maps to sRGB)
        YCbCr/HSV Encoding: Default (maps to ITU-R 601)
        Quantization      : Default (maps to Full Range)
        Flags             :

$ v4l2-ctl --list-devices
NVIDIA Tegra Video Input Device (platform:tegra-capture-vi):
        /dev/media0

vi-output, isx031 3-003a (platform:tegra-capture-vi:0):
        /dev/video0

V4L2 Commands:

v4l2-ctl -d /dev/video0 \
  --set-fmt-video=width=1920,height=1536,pixelformat=RG12 \
  --stream-mmap=3 \
  --stream-skip=3 \
  --stream-count=1 \
  --stream-to=./capture.raw \
  --stream-poll

dts:

mode0 {/*mode IMX623_MODE_1920X1536_CROP_30FPS*/
						mclk_khz = "24000";
						num_lanes = "4";
						tegra_sinterface = "serial_a";
						phy_mode = "DPHY";
						vc_id = "0";
						discontinuous_clk = "no";
						dpcm_enable = "false";
						cil_settletime = "0";
						dynamic_pixel_bit_depth = "12";
						csi_pixel_bit_depth = "12";
						mode_type = "bayer";
						pixel_phase = "rggb";

						active_w = "1920";
						active_h = "1536";
						readout_orientation = "0";
						line_length = "2400";
						inherent_gain = "1";
						mclk_multiplier = "5.25";
						pix_clk_hz = "126000000";

						gain_factor = "10";
						min_gain_val = "0"; /* 0dB */
						max_gain_val = "480"; /* 48dB */
						step_gain_val = "3"; /* 0.3 */
						default_gain = "0";
						min_hdr_ratio = "1";
						max_hdr_ratio = "1";
						framerate_factor = "1000000";
						min_framerate = "1500000"; /* 1.5 */
						max_framerate = "30000000"; /* 30 */
						step_framerate = "1";
						default_framerate= "30000000";
						exposure_factor = "1000000";
						min_exp_time = "30"; /* us */
						max_exp_time = "660000"; /* us */
						step_exp_time = "1";
						default_exp_time = "33334";/* us */
						embedded_metadata_height = "0";
					};

hello ZillaHou,

let me have confirmation,
were you able to capture frame with ISX031, but there’s an issue after modify the driver to adapt IMX623?
if yes.. may I know what’s the failure logs?

Hello JerryChang,

this is trace log.

trace_log.log (40.9 KB)

When I changing active_h from 1536 to 1552,the trcae log is as follows:

log.log (60.7 KB)

hello ZillaHou,

IIUC, you’re based-on Jetson AGX Orin, JP7.2/R39.2, adapting an ISX031 driver to IMX623 through MAX96717 + MAX96712.
there’re some errors according to your VI tracing logs.
for instance,
PHY_INTR0 = 0x44 it shows multi-bit Start-of-Transmission sync-word errors on data lanes 0 and 1 of that CIL.
after that, it reported with PHY_INTR = 0x154 and PHY_INTR = 0x110, which related to RX FIFO-full errors.
besides, there’s STREAM_VC = 0x04 it meant packet payload CRC failure.

please double check developer guide, SerDes Pixel Clock, to review your clock rate settings, which must be set correctly to avoid potential issues.
BTW, since you’re working with a serdes chip, is it possible to enable test-pattern-generator for issue narrow down?

hello JerryChang,

I configured max_lane_speed to 1.8Gbps and boosted the clock with the command below. The situation improved—I can see more frames in the trace log—but I still cannot successfully capture an image.

My capture command is as follows:

v4l2-ctl -d /dev/video0 \
  --set-fmt-video=width=1920,height=1536,pixelformat=RG12 \
  --stream-mmap=3 \
  --stream-skip=3 \
  --stream-count=1 \
  --stream-to=./capture.raw \
  --stream-poll

New trace log:

imx623_trace.log (2.6 MB)

hello ZillaHou,

it looks you’ve lots of CHANSEL_PXL_SOF/CHANSEL_PXL_EOF to indicate frame-start and frame-end has detected by VI engine.
the later ATOMP_FRAME_DONE to indicate it’s complete writing a frame to memory.

we should dig into below. the receiver is reporting unsuccessful deskew calibration.

     kworker/3:1-63      [003] .....    93.302625: rtcpu_nvcsi_intr: tstamp:3548191838 class:CORRECTABLE_ERR type:PHY_INTR phy:0 cil:0 st:0 vc:0 status:0x00000e00
     kworker/3:1-63      [003] .....    93.302626: rtcpu_nvcsi_intr: tstamp:3548191838 class:CORRECTABLE_ERR type:PHY_INTR phy:0 cil:1 st:0 vc:0 status:0x00000600

you may refer to a similar MAX96712 use-case, such as Topic 372110.
above thread shows this exact 0xe00/0x600 pair disappearing after periodic deskew was disabled.

hello,

我参考了你提供的帖子:

1.max96712端的deskew原本都是开启状态的

2.我修改了cil_settletime = “26”

之前的问题消失了,但又出现了新的报错

tag:CSIMUX_FRAME channel:0x00 frame:2 vi_tstamp:833912194112 data:0x00000000000000a0
tag:CHANSEL_SHORT_FRAME channel:0x01 frame:11 vi_tstamp:843228537504 data:0x004c200001000000

i2c3.log (48 KB)

另外补充一点,我在代码中以及sensor寄存器中都已经关闭了embedded data,请帮忙分析一下。

hello ZillaHou,

it looks strange that these logs are reported by frame-2 and frame-11, with different timestamps.
anyways,
CSIMUX_FRAME = 0xa0 indicates an unexpected frame-start before the preceding frame was closed.
the later CHANSEL_SHORT_FRAME means VI received an incomplete frame. please double check the line count matches active_h configuration.

is this correct attachment? it shows I2C transactions only.
please provide a fresh VI/NVCSI trace and dmesg from the same capture with cil_settletime = "26".

不好意思,log上传错误,正确log如下

log3.log (480.8 KB)

hello ZillaHou,

thanks for sharing the logs, it still report deskew errors, FIFO-full errors, CRC failures, and short packets still occur repeatedly. no complete pixel frame is received.

let’s double check the clock-rate settings, assume the transmitter really outputs 1.8 Gb/s/lane over four lanes with RAW12, the corresponding SerDes pixel-clock value should be.. serdes_pix_clk_hz = 1800000000 × 4 / 12 = 600000000.

hello,

我在设备树中加入serdes_pix_clk_hz = "600000000"后,CHANSEL_SHORT_FRAME消失了,通过v4l2工具概率性的可以抓到帧,但trace log中仍有大量报错。

log.txt (8.8 MB)

抓到的图,看起来也有些问题。

hello ZillaHou,

may I know what’s the sensor’s RAW interpretation, did you assign the corresponding sensor pixel phase to the device tree?
besides.. every frame still reports PIXEL_RUNAWAY at line 1536. it usually means actual transmitted image height still exceeds VI’s configuration.

here’re couple of questions.

  1. v4l2-ctl is capturing raw files, may I know how you convert it as attached JPG file?
  2. let’s examine your DT settings, please follow the commands to dump device tree into dts formats. for instance, $ sudo dtc -I fs -O dts /sys/firmware/devicetree/base > /tmp/123.dts

hello,

1.我确认了sneosr内部的寄存器,有效输出宽度确实是1536

2.我的png图是抓到raw图后使用脚本转换的,使用这个脚本转换用另一个摄像头抓到的raw图时没有任何问题。

3.使用你提供的命令抓取的设备树文件如下:

123.dts.txt (296.2 KB)

hello ZillaHou,

it looks you’ve configure embedded_metadata_height = "0";
please dig into sensor data-sheet, and also the serdes chips for checking whether it sends embedded metadata lines.