How to use camera trig function on orin platform?

I have a camera working on the agx orin platform. When I use the master mode receiver on the sensor side, I can capture the video stream through the following commands:
v4l2-ctl --set-fmt-video=width=4128,height=3008,pixelformat=RG12 --set-ctrl bypass_mode=0 --stream-skip=30 --stream-mmap --stream-count=1 --stream-to=ov1081.raw -d /dev/video0

When I use the trig function on the Sensor side, I use a third party to synchronize and trigger the clock, and the frequency is 29HZ, which is consistent with the master mode. The MIPI signal can be measured, but the video stream cannot be obtained.

dmesg log

[   75.081571] tegra-camrtc-capture-vi tegra-capture-vi: corr_err: discarding frame 1, flags: 0, err_data 131072
[   75.131396] tegra-camrtc-capture-vi tegra-capture-vi: corr_err: discarding frame 2, flags: 0, err_data 131072
[   75.181565] tegra-camrtc-capture-vi tegra-capture-vi: corr_err: discarding frame 3, flags: 0, err_data 131072
[   75.231398] tegra-camrtc-capture-vi tegra-capture-vi: corr_err: discarding frame 4, flags: 0, err_data 131072

trace log

     kworker/3:1-138     [003] ....   263.616693: rtcpu_string: tstamp:11514050037 id:0x04010000 str:"VM0 activating."
     kworker/3:1-138     [003] ....   263.616695: rtcpu_vinotify_event: tstamp:11514675810 cch:0 vi:0 tag:VIFALC_TDSTATE channel:0x23 frame:0 vi_tstamp:368454244512 data:0x399d580010000000
     kworker/3:1-138     [003] ....   263.616695: rtcpu_vinotify_event: tstamp:11514675946 cch:0 vi:0 tag:VIFALC_TDSTATE channel:0x23 frame:0 vi_tstamp:368454251008 data:0x0000000031000001
     kworker/3:1-138     [003] ....   263.616696: rtcpu_vinotify_event: tstamp:11514676100 cch:0 vi:0 tag:VIFALC_TDSTATE channel:0x23 frame:0 vi_tstamp:368454296704 data:0x399d550010000000
     kworker/3:1-138     [003] ....   263.616696: rtcpu_vinotify_event: tstamp:11514676233 cch:0 vi:0 tag:VIFALC_TDSTATE channel:0x23 frame:0 vi_tstamp:368454303296 data:0x0000000031000002
     kworker/3:1-138     [003] ....   263.672677: rtcpu_vinotify_error: tstamp:11516147205 cch:0 vi:0 tag:CHANSEL_NOMATCH channel:0x01 frame:1 vi_tstamp:368516522368 data:0x0000000000000269
     kworker/3:1-138     [003] ....   263.672680: rtcpu_vinotify_event: tstamp:11516303858 cch:0 vi:0 tag:FS channel:0x00 frame:1 vi_tstamp:368516498848 data:0x0000000100000010
     kworker/3:1-138     [003] ....   263.672681: rtcpu_vinotify_event: tstamp:11516303996 cch:0 vi:0 tag:ATOMP_FS channel:0x00 frame:1 vi_tstamp:368516498944 data:0x0000000800000000
     kworker/3:1-138     [003] ....   263.672681: rtcpu_vinotify_event: tstamp:11516304150 cch:0 vi:0 tag:CHANSEL_EMBED_SOF channel:0x23 frame:1 vi_tstamp:368516511456 data:0x0000000000000004
     kworker/3:1-138     [003] ....   263.672681: rtcpu_vinotify_event: tstamp:11516304281 cch:0 vi:0 tag:CHANSEL_EMBED_EOF channel:0x23 frame:1 vi_tstamp:368516521856 data:0x0000000000000008
     kworker/3:1-138     [003] ....   263.672682: rtcpu_vinotify_event: tstamp:11516304434 cch:0 vi:0 tag:CHANSEL_NOMATCH channel:0x01 frame:1 vi_tstamp:368516522368 data:0x0000000000000269
     kworker/3:1-138     [003] ....   263.672682: rtcpu_vinotify_event: tstamp:11516304569 cch:0 vi:0 tag:ATOMP_EMB_DATA_DONE channel:0x23 frame:1 vi_tstamp:368516522816 data:0x0000000000000000
     kworker/3:1-138     [003] ....   263.672683: rtcpu_vinotify_event: tstamp:11516304721 cch:0 vi:0 tag:VIFALC_ACTIONLST channel:0x23 frame:1 vi_tstamp:368516590272 data:0x0000000003020001
     kworker/3:1-138     [003] ....   263.672683: rtcpu_vinotify_event: tstamp:11516304854 cch:0 vi:0 tag:CHANSEL_PXL_SOF channel:0x23 frame:1 vi_tstamp:368517255744 data:0x0000000000000001
     kworker/3:1-138     [003] ....   263.672683: rtcpu_vinotify_event: tstamp:11516305006 cch:0 vi:0 tag:VIFALC_ACTIONLST channel:0x23 frame:1 vi_tstamp:368517266592 data:0x0000000008020001
     kworker/3:1-138     [003] ....   263.728687: rtcpu_vinotify_event: tstamp:11517217850 cch:0 vi:0 tag:FE channel:0x00 frame:1 vi_tstamp:368550674976 data:0x0000000100000020
     kworker/3:1-138     [003] ....   263.728688: rtcpu_vinotify_event: tstamp:11517218012 cch:0 vi:0 tag:CHANSEL_SHORT_FRAME channel:0x01 frame:1 vi_tstamp:368550675008 data:0x0bbc200001000000
     kworker/3:1-138     [003] ....   263.728688: rtcpu_vinotify_event: tstamp:11517218145 cch:0 vi:0 tag:VIFALC_ACTIONLST channel:0x23 frame:1 vi_tstamp:368550741760 data:0x0000000001020001
     kworker/3:1-138     [003] ....   263.728689: rtcpu_vinotify_error: tstamp:11517224897 cch:0 vi:0 tag:CHANSEL_NOMATCH channel:0x01 frame:2 vi_tstamp:368551005568 data:0x0000000000000269
     kworker/3:1-138     [003] ....   263.728689: rtcpu_vinotify_event: tstamp:11517714644 cch:0 vi:0 tag:ATOMP_FE channel:0x00 frame:1 vi_tstamp:368550675072 data:0x0000000800000000
     kworker/3:1-138     [003] ....   263.728689: rtcpu_vinotify_event: tstamp:11517714779 cch:0 vi:0 tag:FS channel:0x00 frame:2 vi_tstamp:368550982048 data:0x0000000200000010

hello 1508723374,

do you meant there’s hardware sync pin for your multi-cam modules?
could you please give more details, for example, may I know how the synchronize works?

I use a single camera, and I use an external trigger to simulate XTRIG signal. XHS uses orin’s clock 37.125Mhz. When XTRIG signal comes, camera starts to expose and generate data, and the data enters orin through MIPI, CSI and VI.

hello 1508723374,

just for confirmation,
is it camera output frames only when you given the external trigger pulse?

Yes.There is no MIPI signal when I do not give the trigger signal, and only MIPI output when I give the trigger pulse.

hello 1508723374,

please check low-level VI driver,
there’s by default configure CAPTURE_TIMEOUT_MS as 2500ms. you may increasing that for external trigger use-case.
for example, $public_source/kernel_src/kernel/nvidia/drivers/media/platform/tegra/camera/vi/vi5_fops.c

#define CAPTURE_TIMEOUT_MS      2500

static void vi5_capture_dequeue()
...
                /* Dequeue a frame and check its capture status */
                err = vi_capture_status(chan->tegra_vi_channel[vi_port], CAPTURE_TIMEOUT_MS);

you may also running gst pipeline with -e flag, for sending an EoS at shutdown
for example, $ gst-launch-1.0 -e v4l2src device=/dev/video<X> ! "video/x-raw, format=(string)UYVY, width=(int)1280, height=(int)720" ! jpegenc ! multifilesink location=capture%d.jpeg

however,
may I know what’s the actual use-case, what’s the time interval for every external trigger?
it’s configuration to increase timeout value, it doesn’t meant it could configure one huge timeout value to wait for external trigger pulse infinitely.

hello JerryChang,

I work with 1508723374, I am currently taking over the debugging work.

  1. I try configure CAPTURE_TIMEOUT_MS as 25000ms, but get the same result, dmesg and trace log is same as before.

2.the time interval for every external trigger is 50ms.

3.what is meaning of “err_data 131072” in dmesg log?

Please give me some debugging suggestions.

that’s data-corrupting general error, do you also seeing the error with General error queue is out of sync with frame queue...? that should also show the notification bits for analysis.

I am not sure what needs to be corrected for these errors, could you give me more advice?

hello 331721333,

please share complete VI tracing logs for checking.
furthermore, is it possible for probing the MIPI signaling to ensure there’s data on the CSI channel?

I measured with an oscilloscope and confirmed that there was a MIPI signal when cmos work in trig mode.

the file “trace-20230704-1.txt” is cmos work in trig mode, and can’t get image.
the file “trace-20230705-3-success.txt” is cmos work in master mode, and can get image.

the v4l2 commad same is “v4l2-ctl --set-fmt-video=width=4128,height=3008,pixelformat=RG12 --set-ctrl bypass_mode=0 --stream-skip=0 --stream-mmap --stream-count=1 --stream-to=/dev/null -d /dev/video0”.

and i compare the two trace file , found some difference, but i don’t know what that means( CHANSEL_SHORT_FRAME and CHANSEL_PXL_EOF ).


trace-20230704-1.txt (431.9 KB)
trace-20230705-3-success.txt (16.5 KB)

hello 331721333,

the error CHANSEL_SHORT_FRAME means the receiving image height is less then active_h settings.
could you please try reduce active_h for quick testing.

the “active_h” on dts value is 3008, i try to change it to 3000\2992\2976\2160, the result is same, v4l2 can’t get image, and tarce log is same as before.

hello 331721333,

what’s the data follow by CHANSEL_SHORT_FRAME failure? is it still same as 0x0bbc....
0xbbc shows the receiving image height, it’s start from 0. so, it means there’re 3005-lines sending to VI engine. whereas your active_h=3008; the expect result should be 0xbbf.

do you mean i should change active_h to 3005? i try set active_h=3005, but still can’t get any image, the dmesg and trace is same as before.

i just change active_h in dts file, not change cmos driver and v4l2 command, it is ok?

another question, in the success trace file( trace-20230705-3-success.txt), one CHANSEL_PXL_SOF will match one CHANSEL_PXL_EOF, but in fail trace file, only exist CHANSEL_PXL_SOF, can’t find the CHANSEL_PXL_EOF, is means some error?

hello 331721333,

please change device tree and also sensor driver to have less lines for testing.
v4l command-line should assign the same format as it reported by… $ v4l2-ctl -d /dev/video0 --list-formats-ext

your understanding is correct. the active stream should have one CHANSEL_PXL_SOF match to one CHANSEL_PXL_EOF.
EOF is missing for your failure case since there’s an error CHANSEL_SHORT_FRAME triggered.

sensor dirver and dts file all be changed, the active_h set to 3005;

v4l2-ctl -d /dev/video0 --list-formats-ext

ioctl: VIDIOC_ENUM_FMT
        Type: Video Capture

        [0]: 'RG12' (12-bit Bayer RGRG/GBGB)
                Size: Discrete 4128x3005
                        Interval: Discrete 0.034s (29.000 fps)

result is not changed, can’t get image, and same trace and dmesg.
v4l2 command is:

v4l2-ctl --set-fmt-video=width=4128,height=3005,pixelformat=RG12 --set-ctrl bypass_mode=0 --stream-skip=0 --stream-mmap --stream-count=1 --stream-to=/dev/null -d /dev/video0

the trace is still report these info:

kworker/3:1-155 [003] … 60.179449: rtcpu_string: tstamp:2766179903 id:0x04010000 str:“VM0 deactivating.”
kworker/3:1-155 [003] … 86.284445: rtcpu_string: tstamp:3581597805 id:0x04010000 str:“VM0 activating.”
kworker/3:1-155 [003] … 86.284449: rtcpu_vinotify_event: tstamp:3582264655 cch:0 vi:0 tag:VIFALC_TDSTATE channel:0x23 frame:0 vi_tstamp:114615995008 data:0x399d580010000000
kworker/3:1-155 [003] … 86.284450: rtcpu_vinotify_event: tstamp:3582264790 cch:0 vi:0 tag:VIFALC_TDSTATE channel:0x23 frame:0 vi_tstamp:114616001536 data:0x0000000031000001
kworker/3:1-155 [003] … 86.284450: rtcpu_vinotify_event: tstamp:3582264942 cch:0 vi:0 tag:VIFALC_TDSTATE channel:0x23 frame:0 vi_tstamp:114616047648 data:0x399d550010000000
kworker/3:1-155 [003] … 86.284450: rtcpu_vinotify_event: tstamp:3582265070 cch:0 vi:0 tag:VIFALC_TDSTATE channel:0x23 frame:0 vi_tstamp:114616054240 data:0x0000000031000002
kworker/3:1-155 [003] … 86.340418: rtcpu_vinotify_error: tstamp:3584099540 cch:0 vi:0 tag:CHANSEL_NOMATCH channel:0x01 frame:1 vi_tstamp:114690997088 data:0x0000000000000269
kworker/3:1-155 [003] … 86.340419: rtcpu_vinotify_event: tstamp:3584434550 cch:0 vi:0 tag:FS channel:0x00 frame:1 vi_tstamp:114690973536 data:0x0000000100000010
kworker/3:1-155 [003] … 86.340419: rtcpu_vinotify_event: tstamp:3584434685 cch:0 vi:0 tag:ATOMP_FS channel:0x00 frame:1 vi_tstamp:114690973664 data:0x0000000800000000
kworker/3:1-155 [003] … 86.340420: rtcpu_vinotify_event: tstamp:3584434841 cch:0 vi:0 tag:CHANSEL_EMBED_SOF channel:0x23 frame:1 vi_tstamp:114690986144 data:0x0000000000000004
kworker/3:1-155 [003] … 86.340420: rtcpu_vinotify_event: tstamp:3584434969 cch:0 vi:0 tag:CHANSEL_EMBED_EOF channel:0x23 frame:1 vi_tstamp:114690996576 data:0x0000000000000008
kworker/3:1-155 [003] … 86.340420: rtcpu_vinotify_event: tstamp:3584435117 cch:0 vi:0 tag:CHANSEL_NOMATCH channel:0x01 frame:1 vi_tstamp:114690997088 data:0x0000000000000269
kworker/3:1-155 [003] … 86.340421: rtcpu_vinotify_event: tstamp:3584435249 cch:0 vi:0 tag:ATOMP_EMB_DATA_DONE channel:0x23 frame:1 vi_tstamp:114690997568 data:0x0000000000000000
kworker/3:1-155 [003] … 86.340421: rtcpu_vinotify_event: tstamp:3584435401 cch:0 vi:0 tag:VIFALC_ACTIONLST channel:0x23 frame:1 vi_tstamp:114691064960 data:0x0000000003020001
kworker/3:1-155 [003] … 86.340422: rtcpu_vinotify_event: tstamp:3584435531 cch:0 vi:0 tag:CHANSEL_PXL_SOF channel:0x23 frame:1 vi_tstamp:114691730464 data:0x0000000000000001
kworker/3:1-155 [003] … 86.340422: rtcpu_vinotify_event: tstamp:3584435681 cch:0 vi:0 tag:VIFALC_ACTIONLST channel:0x23 frame:1 vi_tstamp:114691741312 data:0x0000000008020001
kworker/3:1-155 [003] … 86.396391: rtcpu_vinotify_event: tstamp:3585655156 cch:0 vi:0 tag:FE channel:0x00 frame:1 vi_tstamp:114740667104 data:0x0000000100000020
kworker/3:1-155 [003] … 86.396392: rtcpu_vinotify_event: tstamp:3585655317 cch:0 vi:0 tag:CHANSEL_SHORT_FRAME channel:0x01 frame:1 vi_tstamp:114740667136 data:0x0bbc200001000000
kworker/3:1-155 [003] … 86.396392: rtcpu_vinotify_event: tstamp:3585655453 cch:0 vi:0 tag:VIFALC_ACTIONLST channel:0x23 frame:1 vi_tstamp:114740733888 data:0x0000000001020001
kworker/3:1-155 [003] … 86.396393: rtcpu_vinotify_error: tstamp:3585662062 cch:0 vi:0 tag:CHANSEL_NOMATCH channel:0x01 frame:2 vi_tstamp:114740997728 data:0x0000000000000269
kworker/3:1-155 [003] … 86.396393: rtcpu_vinotify_event: tstamp:3586170563 cch:0 vi:0 tag:ATOMP_FE channel:0x00 frame:1 vi_tstamp:114740667232 data:0x0000000800000000
kworker/3:1-155 [003] … 86.396394: rtcpu_vinotify_event: tstamp:3586170694 cch:0 vi:0 tag:FS channel:0x00 frame:2 vi_tstamp:114740974176 data:0x0000000200000010
kworker/3:1-155 [003] … 86.396394: rtcpu_vinotify_event: tstamp:3586170847 cch:0 vi:0 tag:ATOMP_FS channel:0x00 frame:2 vi_tstamp:114740974272 data:0x0000000800000000
kworker/3:1-155 [003] … 86.396394: rtcpu_vinotify_event: tstamp:3586170978 cch:0 vi:0 tag:CHANSEL_EMBED_SOF channel:0x23 frame:2 vi_tstamp:114740986784 data:0x0000000000000004
kworker/3:1-155 [003] … 86.396395: rtcpu_vinotify_event: tstamp:3586171130 cch:0 vi:0 tag:CHANSEL_EMBED_EOF channel:0x23 frame:2 vi_tstamp:114740997184 data:0x0000000000000008
kworker/3:1-155 [003] … 86.396395: rtcpu_vinotify_event: tstamp:3586171262 cch:0 vi:0 tag:CHANSEL_NOMATCH channel:0x01 frame:2 vi_tstamp:114740997728 data:0x0000000000000269
kworker/3:1-155 [003] … 86.396396: rtcpu_vinotify_event: tstamp:3586171414 cch:0 vi:0 tag:ATOMP_EMB_DATA_DONE channel:0x23 frame:2 vi_tstamp:114740998144 data:0x0000000000000000
kworker/3:1-155 [003] … 86.396396: rtcpu_vinotify_event: tstamp:3586171547 cch:0 vi:0 tag:VIFALC_ACTIONLST channel:0x23 frame:2 vi_tstamp:114741065728 data:0x0000000003020002

hi JerryChang,
the trig mode work success, it is a sensor dirver problem , we only changed sensor dirver code , then , we get right image.
thanks for your reply and sugguest.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.