Custom V4L2 controls with tegracam_device


Our camera module has an IMX185 and a switchable IR filter controlled via GPIO. Is there a way to include non TEGRA_CAMERA controls and still use the Tegra Camera Framework?

I would like to add a boolean control that switches a GPIO but it looks like tegracam_ctrl_handler_init will reject anything not in the tegracam_ctrls.c ctrl_cfg_list.

Is there any support for adding arbitrary controls?


Alternatively what is the status of the adding sub-devices such as focusers? If I could make some sort of stupid non-I2C sub-device with an on/off method that would be perfect.

hello Atrer,

you may calling below kernel APIs to control GPIO,

<i>$l4t-r32.3.1/JAX_TX2/Linux_for_Tegra/source/public/kernel/kernel-4.9/include/linux/gpio.h </i>

static inline int gpio_get_value(unsigned int gpio)
  	return __gpio_get_value(gpio);
static inline void gpio_set_value(unsigned int gpio, int value)
  	__gpio_set_value(gpio, value);

for the quick testing, you may assign specific gpio numbers to control it, please also refer to Jetson TX2 Platform Adaptation and Bring-Up Guide, and check [GPIO Changes] chapter to calculate the pin number.
furthermore, you should update your sensor device tree to add gpio pin property, and you could parse such pin in the sensor driver to control it.
for example,

gpio = of_get_named_gpio(np, "reset-gpios", 0);

I’m sorry, I should have said V4L2 custom controls. For example if our camera had a flash we would want to add V4L2_CID_FLASH_LED_MODE to our controls and use v4l2-ctl to trigger it.

In the past we defined our own v4l2_ctrl_config, but now everything seems to be handled by tegracam. Is there any way to add additional V4L2 control IDs beyond the ones defined by tegracam?

Controls in addition to TEGRA_CAMERA_CID_GAIN, TEGRA_CAMERA_CID_HDR_EN, etc.

hello Atrer,

you may have implementation in the VI drivers to extend CID controls, you’ll also add control flags in tegra-v4l2-camera.h to report the property.
please refer to TEGRA_CAMERA_CID_LOW_LATENCY as an example,

Once sub-devices are implemented is there going to be support for non-I2C “dumb” devices or will you only support I2C based focusers?

hello Atrer,

sorry, may I know what’s the non-I2C “dumb” focuser devices?
it’s workable if you’re able to have implementation to calculate current scene contrast and also determine the direction of lens.
you might also contact with Jetson Preferred Partners for camera solutions.

I mean devices other than focusers. For example this GPIO based switchable IR filter:

hello Atrer,

it’s doable to use kernel APIs to control GPIO,