Jetson Linux 39.2 bug in camera / vi driver

There seems to be a problem in the camera / vi driver which causes the ioctl VIDIOC_G_FMT to fail.

The driver calls v4l2_subdev_call() but doesn’t initialize the field stream within the v4l2_subdev_format structure:
https://gitlab.com/nvidia/nv-tegra/linux-nv-oot/-/blob/l4t/l4t-r39.2.1/drivers/media/platform/tegra/camera/vi/channel.c?ref_type=heads#L2224

Initialization of the stream field seems to be required since the following commit:

Thanks,
Ralf

hello ralf.goebel,

may I know what’s error logs, please also share your sensor capability, did you missing some property that report unsupported operations?

Hello Jerry,

Correction: it’s the VIDIOC_TRY_FMT and VIDIOC_S_FMT ioctls which are failing. Initialization of the stream number is missing in __tegra_channel_try_format and __tegra_channel_set_format.

We are using the V4L2 API on our custom hardware. The kernel was also compiled with custom configuration options.

The ioctls fail with -EINVAL because of the following check of the stream number:
https://gitlab.com/nvidia/nv-tegra/3rdparty/canonical/linux-noble/-/blob/l4t/l4t-r39.2.1-Ubuntu-nvidia-tegra-6.8.0-1021.21/drivers/media/v4l2-core/v4l2-subdev.c?ref_type=heads#L188

Ralf

hello ralf.goebel,

following upstream commit bb15c827, V4L2 core no longer automatically resets this field to zero for single-stream subdevices.
a nonzero uninitialized value therefore causes validation to return -EINVAL before the sensor callback is called.
let’s give it a try with zero-initializing the structure in both functions, i.e. struct v4l2_subdev_format fmt = { 0 };

Yes I know, zero-initializing the structure fixes the problem. I’m just reporting this issue.