Support RG16 pixel format

Hi,
I’m using JP 4.5.1. My image sensor supports 16bits RGGB bayer format.
In device tree mode, I defined:

					dynamic_pixel_bit_depth = "16";
					csi_pixel_bit_depth = "16";
					mode_type = "bayer";
					pixel_phase = "rggb";

I also added some code in tegra camera

diff --git a/drivers/media/platform/soc_camera/soc_mediabus.c b/drivers/media/platform/soc_camera/soc_mediabus.c
index e3e665e1c503..e9b0a58ee2f5 100644
--- a/drivers/media/platform/soc_camera/soc_mediabus.c
+++ b/drivers/media/platform/soc_camera/soc_mediabus.c
@@ -382,6 +382,16 @@ static const struct soc_mbus_lookup mbus_fmt[] = {
                .order                  = SOC_MBUS_ORDER_LE,
                .layout                 = SOC_MBUS_LAYOUT_PACKED,
        },
+}, {
+       .code = MEDIA_BUS_FMT_SRGGB16_1X16,
+       .fmt = {
+               .fourcc                 = V4L2_PIX_FMT_SRGGB16,
+               .name                   = "Bayer 16 RGGB",
+               .bits_per_sample        = 16,
+               .packing                = SOC_MBUS_PACKING_NONE,
+               .order                  = SOC_MBUS_ORDER_LE,
+               .layout                 = SOC_MBUS_LAYOUT_PACKED,
+       },
 },
 };
 
diff --git a/nvidia/drivers/media/platform/tegra/camera/camera_common.c b/nvidia/drivers/media/platform/tegra/camera/camera_common.c
index 38ab8035b4ae..5b04435b9bcd 100644
--- a/nvidia/drivers/media/platform/tegra/camera/camera_common.c
+++ b/nvidia/drivers/media/platform/tegra/camera/camera_common.c
@@ -136,6 +136,11 @@ static const struct camera_common_colorfmt camera_common_color_fmts[] = {
                V4L2_COLORSPACE_SRGB,
                V4L2_PIX_FMT_VYUY,
        },
+       {
+               MEDIA_BUS_FMT_SRGGB16_1X16,
+               V4L2_COLORSPACE_SRGB,
+               V4L2_PIX_FMT_SRGGB16,
+       },
        /*
         * The below two formats are not supported by VI4,
         * keep them at the last to ensure they get discarded

But v4l2-ctl only recognizes RG12 format, which is one mode of the 5 modes I have.

root@test: ~# v4l2-ctl --list-formats -d /dev/video0 
ioctl: VIDIOC_ENUM_FMT
        Type: Video Capture

        [0]: 'RG12' (12-bit Bayer RGRG/GBGB)
root@test: ~# v4l2-ctl --list-formats-ext -d /dev/video0 
ioctl: VIDIOC_ENUM_FMT
        Type: Video Capture

        [0]: 'RG12' (12-bit Bayer RGRG/GBGB)
                Size: Discrete 3856x2180
                        Interval: Discrete 0.017s (60.000 fps)
                Size: Discrete 1928x1090
                        Interval: Discrete 0.017s (60.000 fps)
                Size: Discrete 3856x2180
                        Interval: Discrete 0.017s (60.000 fps)
                Size: Discrete 1928x1090
                        Interval: Discrete 0.017s (60.000 fps)
                Size: Discrete 3856x2180
                        Interval: Discrete 0.017s (60.000 fps)

Can you please guide me how to make the video device recognizes both RG12 and RG16 pixel format?
Based on this format, I can choose relevant mode.

Thank you.

hello HnilND,

Raw16 is not support by Nano series. it’s Xavier or later Jetson series support Raw16.

Thank you @JerryChang . How about TX2NX? Does it support RAW16?

I don’t know the reason, but I think RAW16 is more light weight (in term of processing power) compare to RAW12? RAW12 need to unpack, extend to 16bit per pixel, but it looks like RAW16 can be used directly?

hello HnilND,

TX2NX also not support Raw16.
actually, you should check TRM for the memory allocation types, it uses T_R16_I as Raw memory formats.
as you can see in the [27.10.6 RAW Memory Formats] session, it supports up-to Raw14.

1 Like

Thank you for the clarification.

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