IntelRealSense / realsense_mipi_platform_driver

Intel® RealSense™ camera driver for GMSL* interface
GNU General Public License v2.0
15 stars 14 forks source link

Aligned pixel format when set a mismatching one #64

Closed shikundi closed 2 years ago

shikundi commented 2 years ago

The issue to be fixed is when user set a unconfigurable format to video node using v4l2-ctl tool:

v4l2-ctl -d /dev/video2 --set-fmt-video=pixelformat=GREY --stream-mmap=3 --stream-count=5

In user space, there's no error reply but dmesg has a no reply from camera processor message. mismatch

This may confuse the user while the streaming is not working as expected .

This issue caused of: The behavior between set_fmt in D4xx and tegra_channel_try_format in channel.c is mismatch. Since set_fmt in D4xx will set it to a default when the format was not found after searching mbus_code. tegra_channel_try_format or tegra_channel_set_format still updated to the mismatch one.

Current solution: As the official description on ioctl VIDIOC_S_FMT says that 'Drivers should not return an error code unless the type field is invalid, this is a mechanism to fathom device capabilities and to approach parameters acceptable for both the application and driver', this fix is to make ioctl VIDIOC_S_FMT not return any error message on both user space and kernel space by updating the pixel format to the correct one instead of the mismatch one in the above scenario.

ev-mp commented 2 years ago

@shikundi , pls check that the PR can be rebased correctly for JP4.6 Also modify the dmesg report to include the requested stream types instead of numbers

shikundi commented 2 years ago

The current solution is to comply official description on ioctl VIDIOC_S_FMT that Drivers should not return an error code unless the type field is invalid by updating the channel pixel format and finding the corresponding video format.

The type filed mentioned above means the enum-v4l2-buf-type but not the pixel format. Hence even the pixel format is set to wrong by the user, we only need to redirect it to a correct one in driver instead of returning an error.

For example, streaming the RGB video node with wrong format GREY or XXX, actually there's no format named XXX, just for test: image

There will be no any error message to user since in driver the the wrong pixel formats have changed to YUYV, the correct one for RGB video node.

shikundi commented 2 years ago

Rebased for JetPack_4.6.1_baseline branch