How to realize RAW16 capture?

I refer to this link, but can’t catch the video stream.

Hi,

For the camera basic functionality first needs to check the device and driver configuration.
You can reference to below program guide for the detailed information of device tree and driver implementation.
https://docs.nvidia.com/jetson/archives/r36.3/DeveloperGuide/SD/CameraDevelopment/SensorSoftwareDriverProgramming.html?highlight=programing#sensor-software-driver-programming

Please refer to Applications Using V4L2 IOCTL Directly by using V4L2 IOCTL to verify basic camera functionality.
https://docs.nvidia.com/jetson/archives/r36.3/DeveloperGuide/SD/CameraDevelopment/SensorSoftwareDriverProgramming.html?highlight=programing#to-run-a-v4l2-ctl-test

Once confirm the configure and still failed below link help to get log and some information and some tips for debug.
https://elinux.org/Jetson/l4t/Camera_BringUp#Steps_to_enable_more_debug_messages

Thanks!

Hi,
RAW16 is not supported in software stack. Please check
About raw16 - #3 by ShaneCCC

Sorry, due to network issues, some descriptions were not submitted.

I referred to this web link and did the support for the software driver. The error message is as follows:

v4l2-ctl -d /dev/video0 --set-fmt-video=width=3840,height=2160,pixelformat=GB16 --stream-count=1 --stream-mmap --stream-to=csi.raw --verbose
VIDIOC_QUERYCAP: ok
VIDIOC_G_FMT: ok
VIDIOC_S_FMT: ok
Format Video Capture:
        Width/Height      : 3840/2160
        Pixel Format      : 'GB16' (16-bit Bayer GBGB/RGRG (Exp.))
        Field             : None
        Bytes per Line    : 7680
        Size Image        : 16588800
        Colorspace        : sRGB
        Transfer Function : Default (maps to sRGB)
        YCbCr/HSV Encoding: Default (maps to ITU-R 601)
        Quantization      : Default (maps to Full Range)
        Flags             :
                VIDIOC_REQBUFS returned 0 (Success)
                VIDIOC_QUERYBUF returned 0 (Success)
                VIDIOC_QUERYBUF returned 0 (Success)
                VIDIOC_QUERYBUF returned 0 (Success)
                VIDIOC_QUERYBUF returned 0 (Success)
                VIDIOC_QBUF returned 0 (Success)
                VIDIOC_QBUF returned 0 (Success)
                VIDIOC_QBUF returned 0 (Success)
                VIDIOC_QBUF returned 0 (Success)
                VIDIOC_STREAMON returned 0 (Success)
cap dqbuf: 0 seq:      0 bytesused: 16588800 ts: 0.000000 (error, ts-monotonic, ts-src-eof)
cap dqbuf: 0 seq:      0 bytesused: 16588800 ts: 0.000000 (error, ts-monotonic, ts-src-eof)
cap dqbuf: 1 seq:      1 bytesused: 16588800 ts: 0.000000 (error, ts-monotonic, ts-src-eof)
cap dqbuf: 2 seq:      2 bytesused: 16588800 ts: 0.000000 (error, ts-monotonic, ts-src-eof)
cap dqbuf: 3 seq:      3 bytesused: 16588800 ts: 0.000000 (error, ts-monotonic, ts-src-eof)
cap dqbuf: 0 seq:      0 bytesused: 16588800 ts: 0.000000 (error, ts-monotonic, ts-src-eof)
cap dqbuf: 0 seq:      0 bytesused: 16588800 ts: 0.000000 (error, ts-monotonic, ts-src-eof)
cap dqbuf: 1 seq:      1 bytesused: 16588800 ts: 0.000000 (error, ts-monotonic, ts-src-eof)

kernel log:

[ 2502.586718] tegra-camrtc-capture-vi tegra-capture-vi: uncorr_err: request timed out after 2500 ms
[ 2502.595887] tegra-camrtc-capture-vi tegra-capture-vi: err_rec: attempting to reset the capture channel
[ 2502.605939] (NULL device *): vi_capture_control_message: NULL VI channel received
[ 2502.613710] t194-nvcsi 13e40000.host1x:nvcsi@15a00000: csi5_stream_close: Error in closing stream_id=0, csi_port=0

trace log:

  v4l2-ctl-3859    [006] ....  1718.111758: tegra_channel_capture_setup: vnc_id 0 W 3840 H 2160 fmt c4
       v4l2-ctl-3859    [006] ....  1718.117659: tegra_channel_set_stream: enable : 0x1
       v4l2-ctl-3859    [007] ....  1718.124494: tegra_channel_set_stream: 13e40000.host1x:nvcsi@15a00000- : 0x1
       v4l2-ctl-3859    [007] ....  1718.124496: csi_s_stream: enable : 0x1
    kworker/3:1-3590    [003] ....  1718.133437: rtcpu_string: tstamp:54349552113 id:0x04010000 str:"VM0 activating."
    kworker/3:1-3590    [003] ....  1718.133440: rtcpu_vinotify_event: tstamp:54349996426 cch:0 vi:0 tag:VIFALC_TDSTATE channel:0x23 frame:0 vi_tstamp:1739189403392 data:0x359d580010000000
    kworker/3:1-3590    [003] ....  1718.133440: rtcpu_vinotify_event: tstamp:54349996579 cch:0 vi:0 tag:VIFALC_TDSTATE channel:0x23 frame:0 vi_tstamp:1739189409824 data:0x0000000031000001
    kworker/3:1-3590    [003] ....  1718.133440: rtcpu_vinotify_event: tstamp:54349996732 cch:0 vi:0 tag:VIFALC_TDSTATE channel:0x23 frame:0 vi_tstamp:1739189450176 data:0x359d550010000000
    kworker/3:1-3590    [003] ....  1718.133441: rtcpu_vinotify_event: tstamp:54349996866 cch:0 vi:0 tag:VIFALC_TDSTATE channel:0x23 frame:0 vi_tstamp:1739189456736 data:0x0000000031000002

version:

cat /etc/nv_tegra_release
# R35 (release), REVISION: 4.1, GCID: 33958178, BOARD: t186ref, EABI: aarch64, DATE: Tue Aug  1 19:57:35 UTC 2023

Please check if there are any omissions in the modification.
Driver code patch:

diff --git a/include/media/tegra_camera_core.h b/include/media/tegra_camera_core.h
index 788cf77dc..ea65775cd 100644
--- a/include/media/tegra_camera_core.h
+++ b/include/media/tegra_camera_core.h
@@ -56,6 +56,7 @@ enum tegra_image_dt {
        TEGRA_IMAGE_DT_RAW10,
        TEGRA_IMAGE_DT_RAW12,
        TEGRA_IMAGE_DT_RAW14,
+       TEGRA_IMAGE_DT_RAW16 = 46, //raw16 debug
 };
 
 /* Supported CSI to VI Data Formats */
@@ -75,6 +76,7 @@ enum tegra_vf_code {
        TEGRA_VF_YUV422,
        TEGRA_VF_YUV420,
        TEGRA_VF_YUV420_CSPS,
+       TEGRA_VF_RAW16,  //raw16 debug
 };

diff --git a/drivers/media/platform/tegra/camera/camera_common.c b/drivers/media/platform/tegra/camera/camera_common.c
index 2b0b341b0..4a1eed1ee 100644
--- a/drivers/media/platform/tegra/camera/camera_common.c
+++ b/drivers/media/platform/tegra/camera/camera_common.c
@@ -46,6 +46,16 @@
 #define HDR_ENABLE             0x1
 
 static const struct camera_common_colorfmt camera_common_color_fmts[] = {
+       {
+               MEDIA_BUS_FMT_SGBRG16_1X16,
+               V4L2_COLORSPACE_SRGB,
+               V4L2_PIX_FMT_SGBRG16,
+       },

diff --git a/drivers/media/platform/tegra/camera/sensor_common.c b/drivers/media/platform/tegra/camera/sensor_common.c
index d50b22e49..ef6e9ddde 100644
--- a/drivers/media/platform/tegra/camera/sensor_common.c
+++ b/drivers/media/platform/tegra/camera/sensor_common.c
@@ -249,6 +249,8 @@ static int extract_pixel_format(
                *format = V4L2_PIX_FMT_SRGGB12;
        else if (strncmp(pixel_t, "bayer_gbrg12", size) == 0)
                *format = V4L2_PIX_FMT_SGBRG12;
+       else if (strncmp(pixel_t, "bayer_gbrg16", size) == 0)
+               *format = V4L2_PIX_FMT_SGBRG16;

iff --git a/drivers/media/platform/tegra/camera/vi/vi5_formats.h b/drivers/media/platform/tegra/camera/vi/vi5_formats.h
index 7ee3a6223..b6ed92bf9 100644
--- a/drivers/media/platform/tegra/camera/vi/vi5_formats.h
+++ b/drivers/media/platform/tegra/camera/vi/vi5_formats.h
@@ -116,6 +121,12 @@ static const struct tegra_video_format vi5_video_formats[] = {
        TEGRA_VIDEO_FORMAT(RAW12, 12, SBGGR12_1X12, 2, 1, T_R16,
                                RAW12, SBGGR12, "BGBG.. GRGR.."),
 
+       /*********raw16 debug**************/
+       /* RAW 16 */
+       TEGRA_VIDEO_FORMAT(RAW16, 16, SGBRG16_1X16, 2, 1, T_R16,
+                               RAW16, SGBRG16, "GBGB.. RGRG.."),
+       /*********raw16 debug end**************/
+

dtb:
active_w = "3840";
active_h = "2160";
mode_type = "bayer";
pixel_phase = "gbrg";
csi_pixel_bit_depth = "16";
dynamic_pixel_bit_depth = "16";

The trace log tell didn’t receive any data from the sensor.

Thanks

The MIPI signal has been measured by the oscilloscope.
And the sensor configuration has been lit up on other soc platforms.

Could someone please help me?

Hi,
As mentioned in previous comment RAW 16 is not supported in software stack. Please use RAW12 or RAW10.

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