Camera Core Library or Direct V4L2 – device tree and driver differences

So I’ve come to terms with that I need to make a custom driver for my MIPI CSI sensor, and I’m trying my best at following the Sensor Software Driver Programming guide.

At the very top it says There are two types of camera programming paths. You must choose one, depending on the camera and your application: Camera Core Library interface or Direct V4L2 interface.

I will only work with the raw data from the sensor, so it seems clear that I should go for the latter choice. However, it isn’t clear at all to me if that should impact my device tree modules and/or driver, and if so what parts of them? Or does this only matter at the application layer?

The first mention of anything that seems specific the Camera Core Library is Device Tree-related under Individual Imaging DeviceProperty Value pairs, at num_control_point . Can and/or should I omit for example everything that has to do with the control points, and if so, how do I figure out what else I can omit?

The only thing that seems to relate to the Camera Core Library driver-wise (at least for V4L version 2, which it seems I should use) is under * V4L2 Kernel Driver (Version 2.0)* → * Control Handlers* TEGRA_CAMERA_CID_VI_BYPASS_MODE. Does that mean it doesn’t matter for the driver?

Thank you

hello JohanPi,

according to the diagram. it’s different user-space application for the different code flow. but they’re sharing the same camera driver.
as you’re only work with the raw data from the sensor, please use the direct V4L2 Interface, (i.e. v4l2src).

you’ll need to have implementation to complete the sensor device tree, please also check Verifying the V4L2 Sensor Driver session to examine your driver.
thanks

1 Like

Thank you for your answer JerryChang!

I was also wondering if I can leave out various values in for example the device tree?

So for instance exposure has no real meaning for my sensor, can I then leave out for example exposure_factor and min_exp_time? Gain and HDR is also meaningless for the sensor.

hello JohanPi,

please refer to below driver,
there’s kernel API to parse the device tree properties,
for example,
$L4T_Sources/r32.6.1/Linux_for_Tegra/source/public/kernel/nvidia/drivers/media/platform/tegra/camera/sensor_common.c

static int sensor_common_parse_control_props(
        struct device *dev, struct device_node *node,
        struct sensor_control_properties *control)
...
        err = read_property_u32(node, "exposure_factor", &value);
        if (err) {
                dev_err(dev, "%s:%s:property missing\n",
                        __func__, "exposure_factor");
                control->exposure_factor = 1;
        } else
                control->exposure_factor = value;

as you can see, it’ll return a default value if there without a definition in the device tree.

1 Like