Skeleton driver for MIPI camera

Is there any available skeleton driver with the basic structure for a MIPI sensor? The available sensor drivers like OV5693, IMX185, IMX274, … have many particular things that many others don’t require, so I’d like to know if there is available any kind of template to build a V4L2 driver for a MIPI camera. I’ve been following the Sensor Driver Programming Guide of NVIDIA, but yet it is too generic, and differs a lot from the working sensors of OmniVision or Sony.

hello euskadi,

may I know which sensor you’re working with?
please also check below for reference.

  1. there are several drivers in the public release sources for your reference,
    for example,
    $l4t-r32.2/kernel_src/kernel/nvidia/drivers/media/i2c/*
  2. some of above reference drivers has moving to new v4l2 framework.
    suggest you check [Sensor Software Driver Programming Guide], and check the V4L2 Kernel Driver (Version 2.0) chapter for details.
  3. you might also check below kernel sources for operations to control MIPI camera sensors,
    for example,
    $l4t-r32.2/kernel_src/kernel/nvidia/drivers/media/platform/tegra/camera/vi/channel.c
    $l4t-r32.2/kernel_src/kernel/nvidia/drivers/media/platform/tegra/camera/vi/vi4_fops.c

So vi4_fops.c and channel.c are used to configure the camera properties too? My idea was to develop a driver for a particular sensor making use of the V4L2 API, and with the idea of configuring just few parameters like exposure time or framerate. Is it enough with the driver for that?

hello euskadi,

Both vi4_fops.c and channel.c were handle the V4L2 operations controls.

it looks like you would like to implement drivers to controls the exposure-time.
please check CID controls to sending user-space control property to low-level driver.
for example, TEGRA_CAMERA_CID_EXPOSURE.
you may also refer to below kernel sources to understand how it works,

<i>$l4t-r32.2/kernel_src/kernel/nvidia/drivers/media/platform/tegra/camera/tegracam_ctrls.c</i>
static int tegracam_set_ctrls(struct tegracam_ctrl_handler *handler,
                        struct v4l2_ctrl *ctrl)
{
        ...
        case TEGRA_CAMERA_CID_EXPOSURE:
                err = ops->set_exposure(tc_dev, *ctrl->p_new.p_s64);

<i>$l4t-r32.2/kernel_src/kernel/nvidia/drivers/media/i2c/ov5693.c</i>
static struct tegracam_ctrl_ops ov5693_ctrl_ops = {
        ...
        .set_exposure = ov5693_set_exposure,

hence, you’ll still need to create your own driver, have implementation to handle those CID controls.
thanks