I am currently porting a camera driver for Jetson Orin NX the camera outputs RAW8 monochrome video, I have added RAW8 support in tegracam and seem to almost be able to capture something.
I use CSI3 (2 lane CSI input) to capture the data with this command:
v4l2-ctl --set-fmt-video=width=640,height=480,pixelformat=GREY --stream-mmap --stream-count=1 -d /dev/video0 --stream-to=/tmp/test.raw
The issue is there seem to be a problem decoding frames as I have the following errors in dmesg:
[ 692.401474] tegra-camrtc-capture-vi tegra-capture-vi: corr_err: discarding frame 1280, flags: 0, err_data 256
[ 692.418144] tegra-camrtc-capture-vi tegra-capture-vi: corr_err: discarding frame 1280, flags: 0, err_data 256
[ 692.434817] tegra-camrtc-capture-vi tegra-capture-vi: corr_err: discarding frame 1280, flags: 0, err_data 256
This is the mode i use :
mode0 {
mclk_khz = "24000";
num_lanes = "2";
pix_clk_hz = "44000000";
csi_pixel_bit_depth = "8";
tegra_sinterface = "serial_c";
phy_mode = "DPHY";
active_w = "640";
active_h = "480";
line_length = "1464";
pixel_t = "y8";
horz_front_porch = "412";
horz_back_porch = "412";
lane_polarity = "0";
gain_factor = "10";
min_gain_val = "0"; /* 0dB */
max_gain_val = "480"; /* 48dB */
step_gain_val = "3"; /* 0.3 */
default_gain = "0";
framerate_factor = "1000000";
default_framerate = "60000000";
min_framerate = "9000000";
max_framerate = "90000000"; /* 30 */
step_framerate = "1000000";
omin_exp_time = "30"; /* us */
max_exp_time = "660000"; /* us */
step_exp_time = "10";
default_exp_time = "33334"; /* us */
exposure_factor = "1";
/*cil_settletime = "0";*/
/*embedded_metadata_height = "10";*/
};
I modified the following files:
--- a/drivers/media/platform/tegra/camera/camera_common.c
+++ b/drivers/media/platform/tegra/camera/camera_common.c
@@ -129,6 +129,11 @@ static const struct camera_common_colorfmt camera_common_color_fmts[] = {
V4L2_COLORSPACE_SRGB,
V4L2_PIX_FMT_VYUY,
},
+ {
+ MEDIA_BUS_FMT_Y8_1X8,
+ V4L2_COLORSPACE_RAW,
+ V4L2_PIX_FMT_GREY,
+ },
};
struct camera_common_csi_io_pad_ctx {
@@ -667,7 +672,8 @@ int camera_common_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
verify_code:
mf->field = V4L2_FIELD_NONE;
- mf->colorspace = V4L2_COLORSPACE_SRGB;
+ //mf->colorspace = V4L2_COLORSPACE_SRGB;
mf->xfer_func = V4L2_XFER_FUNC_DEFAULT;
mf->ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT;
mf->quantization = V4L2_QUANTIZATION_DEFAULT;
--- a/drivers/media/platform/tegra/camera/sensor_common.c
+++ b/drivers/media/platform/tegra/camera/sensor_common.c
@@ -267,6 +267,8 @@ static int extract_pixel_format(
*format = V4L2_PIX_FMT_UYVY;
else if (strncmp(pixel_t, "yuv_vyuy16", size) == 0)
*format = V4L2_PIX_FMT_VYUY;
+ else if (strncmp(pixel_t, "grey_y8", size) == 0)
+ *format = V4L2_PIX_FMT_GREY;
else {
pr_err("%s: Need to extend format%s\n", __func__, pixel_t);
return -EINVAL;
--- a/drivers/media/platform/tegra/camera/vi/vi5_formats.h
+++ b/drivers/media/platform/tegra/camera/vi/vi5_formats.h
@@ -82,6 +82,8 @@ static const struct tegra_video_format vi5_video_formats[] = {
/* RAW 7: TODO */
/* RAW 8 */
+ TEGRA_VIDEO_FORMAT(RAW8, 8, Y8_1X8, 1, 1, T_R8, RAW8, GREY, "Greyscale 8"),
+
TEGRA_VIDEO_FORMAT(RAW8, 8, SRGGB8_1X8, 1, 1, T_R8,
RAW8, SRGGB8, "RGRG.. GBGB.."),
TEGRA_VIDEO_FORMAT(RAW8, 8, SGRBG8_1X8, 1, 1, T_R8,
Is there something Im missing ? How can I get more logs from the CSI interface ?