Failed to register V4L2 subdev device file using SPI camera driver


With reference from drivers/media/spi/imx204.c, I’m developing a SPI based V4L2 camera sensor driver. The hardware setup is a Jetson Orin Nano Developer Kit and a custom camera sensor. The SPI lines are connected between the J12 (19, 21, 23, 24) and interposer boards. When the driver probe function is called, the below API doesn’t return any value, and the subdev device file is not created ( device node names: /dev/v4l-subdev1).

err = v4l2_async_register_subdev(priv->subdev);

From the NVCSI, the subdev device (dev/v4l-subdev0) file is not created in the /dev/directory.

On the Jetson Orin Nano target board, below is the response of the mediactl command. None of the subdev device files were created.

testing@nvidia-desktop:~$ media-ctl -p
Media controller API version 5.10.104

Media device information

driver tegra-camrtc-ca
model NVIDIA Tegra Video Input Device
bus info
hw revision 0x3
driver version 5.10.104

Device topology

  • entity 1: 13e40000.host1x:nvcsi@15a00000- (2 pads, 2 links)
    type V4L2 subdev subtype Unknown flags 0
    pad0: Sink
    ← “test_cam spi0.0”:0 [ENABLED]
    pad1: Source
    → “vi-output, test_cam spi0.0”:0 [ENABLED]

  • entity 4: test_cam spi0.0 (1 pad, 1 link)
    type V4L2 subdev subtype Sensor flags 0
    pad0: Source
    → “13e40000.host1x:nvcsi@15a00000-”:0 [ENABLED]

  • entity 6: vi-output, test_cam spi0.0 (1 pad, 1 link)
    type Node subtype V4L flags 0
    device node name /dev/video0
    pad0: Sink
    ← “13e40000.host1x:nvcsi@15a00000-”:1 [ENABLED]

The SPI communication is working and able to read the sensor chip ID. But the V4l2 asynchronous register subdev API doesn’t return any value and debug message after it didn’t get printed on the kernel message.

Can you please provide help us to debug the probe failing issue.


spi_test_camera_dtsi.txt (16.5 KB)

This is the SPI device tree changes for the camera driver.

Any error message in kernel log for the sensor probe?

There is no error message for the sensor probe in the kernel log and debug/error print didn’t printed on the console.

kernel driver V4l2 subdev API:
dev_info(&client->dev, “Register V4l2 sub device\n”);
ret = v4l2_async_register_subdev(priv->sd);
if(ret) {
dev_err(&client->dev, “could not register v4l2 device. (%d)\n”, LINE);
return ret;
dev_info(&client->dev, “Detected test_cam sensor. (%d)\n”, LINE);

Kernel log SPI driver:

[ 19.123390] test_cam spi0.0: probing test_cam v4l2 sensor
[ 19.129031] test_cam spi0.0: Entered test_cam_parse_dt
[ 19.134516] test_cam spi0.0: Register V4l2 sub device
[ 19.139738] tegra-camrtc-capture-vi tegra-capture-vi: subdev test_cam spi0.0 bound
return ret;

Please check the …/vi/graph.c for the tegra_vi_graph_notify_complete() to generate the video node.


In the camera/vi/channel.c for the “static void tegra_channel_fmts_bitmap_init(struct tegra_channel *chan),” the while loop is running infinitely, and it fails to match media bus format code.

The test_cam driver had MEDIA_BUS_FMT_SBGGR12_1X12 as the pixel code and replaced it with MEDIA_BUS_FMT_SRGGB12_1X12. The sudev device file is created, and the driver is probed succesfully.

The nvidia video formats list doesn’t support the media bus format code MEDIA_BUS_FMT_SBGGR12_1X12.

The sensor_common.c shows supported SBGGR12, looks like you need add
MEDIA_BUS_FMT_SBGGR12_1X12 to …/kernel/nvidia/drivers/media/platform/tegra/camera/camera_common.c for it.

static const struct camera_common_colorfmt camera_common_color_fmts[] = {

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