Integration of MIPI driver

Hi,
I am trying to integrate ar1335 sensor through mipi. I am able to integrate the driver. WhenI run the following command,

v4l2-ctl --device /dev/video0 --stream-mmap --stream-to=frame.raw --stream-count=50

I am getting this error,
vi 54080000.vi: tegra_channel_error_status:error 4000 frame 0

when I execute this command, v4l2-ctl --list-formats-ext

ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: ‘UYVY’
Name : UYVY 4:2:2
Size: Discrete 4208x3120
Interval: Discrete 0.048s (21.000 fps)

Index       : 1
Type        : Video Capture
Pixel Format: 'NV16'
Name        : Y/CbCr 4:2:2
	Size: Discrete 4208x3120
		Interval: Discrete 0.048s (21.000 fps)

Seems like the driver is integrated. But I am not getting video. Any suggestion to debug the issue?

hello JSP_1,

may I know which JetPack release you’re working with.
according to below kernel source, it’s report a pixel parser failure.

<i>$l4t-r32.2/public_sources/kernel_src/kernel/nvidia/drivers/media/platform/tegra/camera/csi/csi2_fops.c</i>

int tegra_csi_error(struct tegra_csi_channel *chan, int port_idx)
{
...
        val = pp_read(port, TEGRA_CSI_PIXEL_PARSER_STATUS);
        err |= val & 0x4000;

please review your DT pixel_phase settings, you might also have a try to specify pixel formats.
for example,

$ v4l2-ctl -d /dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat=UYVY --set-ctrl bypass_mode=0 --stream-mmap --stream-count=100

BTW,
since there’re signaling configurations in the device tree properties settings, which depends-on sensors hardware.
please access to Sensor Software Driver Programming Guide, and review your DT property settings.
thanks

Hi JerryChang,
Thanks for your response. I am using Jetpack 4.2 (Jetson Nano). I am using the following device tree configuration:

mclk_khz = "24000";
num_lanes = "4";
tegra_sinterface = "serial_a";
phy_mode = "DPHY";
discontinuous_clk = "yes";
dpcm_enable = "false";
cil_settletime = "0";
active_w = "4208";
active_h = "3120";
pixel_t = "uyvy";
dynamic_pixel_bit_depth = "16";
    csi_pixel_bit_depth = "16";
    mode_type = "uyvy";
pixel_phase = "uyvy";
readout_orientation = "90";
line_length = "8416";

I have added the following configuration to camera_common.c file
{
MEDIA_BUS_FMT_UYVY8_1X16,
V4L2_COLORSPACE_SRGB,
V4L2_PIX_FMT_UYVY
}

Any suggestion to fix this issue…?

Thanks.

hello JSP_1,

due to t210 hardware limitation, you should adjust the frame stride setting as multiple of 64.
please update sensor init register table and also output width of active_w=4160.
thanks

Hi Jerrychang,
I have updated the frame stride as per your suggestion. Still the issue persist.

Please check whether my device tree link is fine…?

sudo media-ctl -p -d /dev/media0
Media controller API version 0.1.0

Media device information

driver vi
model NVIDIA Tegra Video Input Device
serial
bus info
hw revision 0x3
driver version 0.0.0

Device topology

  • entity 1: nvcsi–2 (2 pads, 2 links)
    type V4L2 subdev subtype Unknown flags 0
    device node name /dev/v4l-subdev0
    pad0: Sink
    <- “ar1335_mipi 6-0042”:0 [ENABLED]
    pad1: Source
    -> “vi-output, ar1335_mipi 6-0042”:0 [ENABLED]

  • entity 4: nvcsi–1 (2 pads, 0 link)
    type V4L2 subdev subtype Unknown flags 0
    device node name /dev/v4l-subdev1
    pad0: Sink
    pad1: Source

  • entity 7: ar1335_mipi 6-0042 (1 pad, 1 link)
    type V4L2 subdev subtype Sensor flags 0
    device node name /dev/v4l-subdev2
    pad0: Source
    [fmt:UYVY8_1X16/4160x3120 field:none colorspace:srgb]
    -> “nvcsi–2”:0 [ENABLED]

  • entity 9: vi-output, ar1335_mipi 6-0042 (1 pad, 1 link)
    type Node subtype V4L flags 0
    device node name /dev/video5
    pad0: Sink
    <- “nvcsi–2”:1 [ENABLED]

      ar1335_mipi_a@42 {
      		compatible = "nvidia,ar1335_mipi";
      		reg = <0x42>;
      		devnode = "video0";
      		physical_w = "3.680";
      		physical_h = "2.760";
      		sensor_model = "ar1335_mipi";
      		use_sensor_mode_id = "true";
      		status = "okay";
      		reset-gpios = <0x5d 0x97 0x0>;
    
      		mode0 {
      			mclk_khz = "24000";
      			num_lanes = "4";
      			tegra_sinterface = "serial_a";
      			phy_mode = "DPHY";
      			discontinuous_clk = "no";
      			dpcm_enable = "false";
      			cil_settletime = "0";
      			active_w = "4160";
      			active_h = "3120";
      			//pixel_t = "bayer_rggb";
      		        csi_pixel_bit_depth = "16";
      		        mode_type = "yuv";
      		        pixel_phase = "uyvy";
         				dynamic_pixel_bit_depth = "16";
      			readout_orientation = "90";
      			line_length = "8320";
      			inherent_gain = "1";
      			mclk_multiplier = "9.33";
      			pix_clk_hz = "259584000"; //"182400000";
      			gain_factor = "16";
      			framerate_factor = "1000000";
      			exposure_factor = "1000000";
      			min_gain_val = "16";
      			max_gain_val = "170";
      			step_gain_val = "1";
      			default_gain = "16";
      			min_hdr_ratio = "1";
      			max_hdr_ratio = "1";
      			min_framerate = "2000000";
      			max_framerate = "21000000";
      			step_framerate = "1";
      			default_framerate = "20000000";
      			min_exp_time = "13";
      			max_exp_time = "683709";
      			step_exp_time = "1";
      			default_exp_time = "2495";
      			embedded_metadata_height = "2";
      		};
    
      		ports {
      			#address-cells = <1>;
      			#size-cells = <0>;
    
      			port@0 {
      				reg = <0>;
      				ar1335_out0: endpoint {
      					port-index = <0>;
      					bus-width = <4>;
      					remote-endpoint = <&ar1335_csi_in0>;
      				};
      			};
      		};
    

Any suggestion…?

Thanks

hello JSP_1,

your media device information looks correct. (i.e. AR1335–> NVCSI–> VI)
we usually need to double check pix_clk_hz during sensor bring-up, could you access Sensor Pixel Clock session to review DT property settings.
thanks