I have an an IMX492 camera working on an Orin devkit with the latest Jetpack 5.1.2.
I need to control the test pattern for that sensor and have added a parameter “test_pattern” with the associated command TEGRA_CAMERA_CID_TEST_PATTERN to the kernel+driver.
I run “v4l2-ctl --set-ctrl test_pattern=11 -d 0” and can verify the sensor outputs the expected pattern.
The second time I run “v4l2-ctl --set-ctrl test_pattern=10 -d 0”, the test pattern doesn’t change and debug prints in the driver indicate that the handler “set_test_pattern” is not called the second time.
Looking at the output of dmesg, I indeed see only 1 call to set_test_pattern(), and a call to power_off() inbetween the 2 calls I made:
[ 140.247870] imx492 30-001a: imx492_set_test_pattern: select test pattern 11 ## v4l2 command detected, handler called ==> OK
[ 140.516140] imx492 30-001a: imx492_set_mode 880: HMAX=2193 => 1202
[ 140.520336] imx492 30-001a: imx492_set_mode: mode 0, 8432x5648
[ 140.520341] imx492 30-001a: imx492_set_mode: selecting test pattern 11
[ 141.330743] imx492 30-001a: imx492_power_off: line 667 ## <== power_off causing issue?
## second call to v4l2-ctl, set_test_pattern() not called here
[ 148.885530] imx492 30-001a: imx492_set_mode: mode 0, 8432x5648
[ 148.885535] imx492 30-001a: imx492_set_mode: selecting test pattern 11 ## using stale value
[ 149.779789] imx492 30-001a: imx492_power_off: line 667
So my question is: could it be that power_off() is causing the issue by preventing the call to set_test_pattern() in the driver?
If so, how can I make sure that set_test_pattern is called in all cases?
please help me to understand this control property,
for example, is it something like a mode setting for writing different sensor mode registers? what’s the expected sensor behavior?
The idea is to configure the sensor to produce a known output (test pattern).
set_mode() still exists to select a resolution and bit depth, but there are a couple of extra registers to enable the test pattern generation and select which test pattern (black, white, grey, vertical stripes, horizontal stripes).
Setting the test pattern in realtime using v4l2-ctl and gstreamer works fine:
But if I rely only on v4l2-ctl to select the test pattern (off/vertical or horizontal stripes) and capture frames, it doesn’t work: I always get the test pattern that was first set.
Subsequent calls will not change the test pattern.
I think the call to power_off() that I see in “dmesg” output after the first call to “v4l2-ctl --set-ctrl test_pattern=XXX” is causing the problem.
Subsequent calls to “v4l2-ctl --set-ctrl test_pattern=XXX” doesn’t generate any log in dmesg, so driver is likely not called.
I’m wondering why that would be.
please refer to below code flow, and it looks like it treat test_pattern=10 as init settings to configure the stream.
you may refer to the code snippet as following.
for example, $public_sources/kernel_src/kernel/nvidia/drivers/media/platform/tegra/camera/tegracam_v4l2.c
static int v4l2sd_stream(struct v4l2_subdev *sd, int enable)
{
...
err = sensor_ops->set_mode(tc_dev);
/* update control ranges based on mode settings*/
err = tegracam_init_ctrl_ranges_by_mode(
s_data->tegracam_ctrl_hdl, (u32) s_data->mode);
int tegracam_init_ctrl_ranges(struct tegracam_ctrl_handler *handler)
{
...
/* Use mode 0 control ranges as default */
if (s_data->sensor_props.num_modes > 0)
{
err = tegracam_init_ctrl_ranges_by_mode(handler, 0);
hence,
please give it a try by adding your set_test_pattern CID controls into tegracam_init_ctrl_ranges_by_mode functions to update control properties.
thanks, I did that and ensured that values from the device tree are indeed applied.
Still, driver doesn’t seem to be called after the V4L framework calls power_off().
Note however that if I use my C++ wrapper around V4L2, the commands to select test_pattern are working as long as camera capture is started (sensor not turned off).
I guess it must be an issue specific to v4l2-ctl because controls can’t be set while streaming is enabled?
that init ctrl only called once while sensor streaming started.
there’re some CID controls able to called while streaming, such as TEGRA_CAMERA_CID_GROUP_HOLD.