Camera Driver Porting

This topic gives a high-level overview of changes in Jetson Linux release 34 that may impact camera driver development when kernel version 4.9 is replaced by kernel version 5.10. It is intended to assist camera driver developers who must migrate to the new kernel version.

For more details, see the source code released with the BSP and the documentation in the BSP distribution’s directory kernel/kernel-5.10/Documentation/.

For additional information about kernel 5.10, see the description of changes in Linux 5.1 on the Kernelnewbies web site.

Configuration Changes

This table summarizes Linux configuration changes from kernel version 4.9 to version.

Environment variable Kernel 5.10 Kernel 4.9
CONFIG_MEDIA CONFIG_MEDIA_PLATFORM_SUPPORT=y
CONFIG_MEDIA_TEST_SUPPORT=y
N/A
CONFIG_TEGRA_GRHOST CONFIG_TEGRA_GRHOST_NVCSI=y
CONFIG_TEGRA_GRHOST_SLVSEC=y
N/A
CONFIG_VIDEO CONFIG_VIDEO_ISC=m
CONFIG_VIDEO_CDI=m
N/A
CONFIG_VIDEO (sensor) CONFIG_NV_VIDEO_IMX185=m
CONFIG_NV_VIDEO_IMX268=m
CONFIG_NV_VIDEO_IMX318=m
CONFIG_NV_VIDEO_OV9281=m
CONFIG_NV_VIDEO_OV10823=m
CONFIG_NV_VIDEO_OV23850=m
CONFIG_NV_VIDEO_IMX390=y
CONFIG_NV_VIDEO_IMX219=m
CONFIG_NV_VIDEO_IMX274=m
CONFIG_NV_VIDEO_LC898212=m
CONFIG_NV_VIDEO_OV5693=m
CONFIG_VIDEO_IMX185=m
CONFIG_VIDEO_IMX268=y
CONFIG_VIDEO_IMX318=y
CONFIG_VIDEO_OV9281=y
CONFIG_VIDEO_OV10823=y
CONFIG_VIDEO_OV23850=y
CONFIG_VIDEO_IMX390=y
CONFIG_VIDEO_IMX219=y
CONFIG_VIDEO_IMX274=m
CONFIG_VIDEO_LC898212=y
CONFIG_VIDEO_OV5693=mSen
CONFIG_THERMAL_GOV N/A CONFIG_THERMAL_GOV_CONTINUOUS=y

Sensor Driver File Name Changes

This table describes files whose names have changed from kernel version 4.9 to version 5.10.

Kernel 5.10 Kernel 4.9
nv_imx185.c imx185.c
nv_imx268.c imx268.c
nv_imx318.c imx318.c
nv_ov9281.c ov9281.c
nv_ov10823.c ov10823.c
nv_ov23850.c ov23850.c
nv_imx390.c imx390.c
nv_imx219.c imx219.c
nv_imx274.c imx274.c
nv_lc898212 lc898212
nv_ov5693.c ov5693.c

Guarding Kernel Version-Specific Code

NVIDIA-specific kernel code in kernel/nvidia/ is guarded by checks that compare the LINUX_VERSION_CODE macro against KERNEL_VERSION(x, x, x).

These are the important changes in the new driver that is protected by this comparison of macros:

  1. Adapting the new Power Domain framework in drivers and corresponding header inclusions. The use of powergate_id is dropped, as tegra_powergate is deprecated in kernel version 5.10.

    The following table shows paths for the functions used in the current and previous kernel versions.

    Kernel 5.10 Kernel 4.9

    kernel/kernel-5.10/include/linux/pm_domain.h

    kernel/kernel-4.9/include/linux/tegra_pm_domains.h

  2. Adapting VI drivers to V4L2 framework changes to replace video buffer state, and changes to time related v4l2-ctl APIs and structures. Some examples are listed in the table below.

    Kernel 5.10 Kernel 4.9
    ktime_get_ts64 getrawmonotonic()
    struct timespec64 struct timespec
    ns_to_timespec64 ns_to_timespec
    VB2_BUF_STATE_ERROR VB2_BUF_STATE_REQUEUEING

    VFL_TYPE_VIDEO

    kernel/kernel-4.9/include/media/v4l2-dev.h

    VFL_TYPE_GRABBER

    kernel/kernel-5.10/include/media/v4l2-dev.h

    V4l2 ctl API changes:

    kernel/kernel-5.10/drivers/media/v4l2-core/v4l2-ctrls.c

    V4l2 ctl API changes:

    kernel/kernel-4.9/drivers/media/v4l2-core/v4l2-ctrls.c

    V4L2 structure changes:

    kernel/kernel-5.10/include/media/v4l2-async.h

    V4L2 structure changes:

    kernel/kernel-4.9/include/media/v4l2-async.h

    Modified enum type for C-PHY and D-PHY in v4l2_mbus_config:

    /dev-main_l4t/kernel/kernel-5.10/include/media/v4l2-mediabus.h

    v4l2_mbus_type for kernel version 4.9:

    kernel/kernel-4.9/include/media/v4l2-mediabus.h

  3. Adapting to changes in debugfs APIs. For function definitions, see the files listed in the table below.

    Kernel 5.10 Kernel 4.9

    kernel/kernel-5.10/fs/debugfs/file.c

    kernel/kernel-4.9/fs/debugfs/file.c

  4. Adapting to replacement of kmap APIs with vmap dma_buf APIs. For API definitions, see the files listed in the table below.

    Kernel 5.10 Kernel 4.9

    kernel/kernel-5.10/drivers/dma-buf/dma-buf.c

    kernel/kernel-4.9/drivers/dma-buf/dma-buf.c

dev_err() Function

The definition of dev_err() has changed. For more information, see the files listed below.

Kernel 5.10 Kernel 4.9

kernel/kernel-5.10/include/linux/dev_printk.h

kernel/kernel-4.9/include/linux/device.h

I2C API

I2C API changes are listed below.

Kernel 5.10 Kernel 4.9

i2c_lock_bus() and i2c_unlock_bus()

kernel/kernel-5.10/include/linux/i2c.h

i2c_lock_adapter() and i2c_unlock_adapter()

kernel/kernel-4.9/include/linux/i2c.h

i2c_new_client_device()

kernel/kernel-5.10/drivers/i2c/i2c-core-base.c

i2c_new_device()

kernel/kernel-4.9/drivers/i2c/i2c-core.c

NVIDIA Capture Driver Code Path

Some of the capture mode driver file paths for channel configuration (VI, ISP) have changed.

Kernel 5.10 Kernel 4.9

kernel/nvidia/drivers/media/platform/tegra/camera/fusa-capture/

kernel/nvidia/drivers/media/platform/tegra/camera/isp/

kernel/nvidia/drivers/media/platform/tegra/camera/vi/