History

media: v4l2: Extend VIDIOC_ENUM_FMT to support MC-centric devices

The VIDIOC_ENUM_FMT ioctl enumerates all formats supported by a video node. For MC-centric devices, its behaviour has always been ill-defined, with drivers implementing one of the following behaviours: - No support for VIDIOC_ENUM_FMT at all - Enumerating all formats supported by the video node, regardless of the configuration of the pipeline - Enumerating formats supported by the video node for the active configuration of the connected subdevice The first behaviour is obviously useless for applications. The second behaviour provides the most information, but doesn't offer a way to find what formats are compatible with a given pipeline configuration. The third behaviour fixes that, but with the drawback that applications can't enumerate all supported formats anymore, and have to modify the active configuration of the pipeline to enumerate formats. The situation is messy as none of the implemented behaviours are ideal, and userspace can't predict what will happen as the behaviour is driver-specific. To fix this, let's extend the VIDIOC_ENUM_FMT with a missing capability: enumerating pixel formats for a given media bus code. The media bus code is passed through the v4l2_fmtdesc structure in a new mbus_code field (repurposed from the reserved fields). With this capability in place, applications can enumerate pixel formats for a given media bus code without modifying the active configuration of the device. The current behaviour of the ioctl is preserved when the new mbus_code field is set to 0, ensuring compatibility with existing userspace. The API extension is documented as mandatory for MC-centric devices (as advertised through the V4L2_CAP_IO_MC capability), allowing applications and compliance tools to easily determine the availability of the VIDIOC_ENUM_FMT extension.

Laurent Pinchart committed 6 years ago

Commit e5b6b071 parent b72f14e3 files · +35 −8Browse files

Showing the changes to include/uapi/linux (1 of 3 files). Show all

Unified · Split

include/uapi/linux/videodev2.h+2−1
@@ -784,7 +784,8 @@ struct v4l2_fmtdesc { · 783 unmodified lines
784 __u32 flags;784 __u32 flags;
785 __u8 description[32]; /* Description string */785 __u8 description[32]; /* Description string */
786 __u32 pixelformat; /* Format fourcc */786 __u32 pixelformat; /* Format fourcc */
787 __u32 reserved[4];787 __u32 mbus_code; /* Media bus code */
788 __u32 reserved[3];
788};789};
789 790
790#define V4L2_FMT_FLAG_COMPRESSED 0x0001791#define V4L2_FMT_FLAG_COMPRESSED 0x0001