Le dimanche 17 mars 2019 à 18:10 +0200, Laurent Pinchart a écrit : > > 3) For CAPTURE buffers, it's actually defined as set-by-driver > > (https://linuxtv.org/downloads/v4l-dvb-apis/uapi/v4l/buffer.html#struct-v4l2-plane), > > so anything userspace sets there is bound to be ignored. I'm not sure > > if we can change this now, as it would be a compatibility issue. > > > > (There are actually real use cases for it, i.e. the venus driver > > outputs VPx encoded frames prepended with the IVF header, but that's > > not what the V4L2 VPx formats expect, so the data_offset is set by the > > driver to point to the raw bitstream data.) > > Doesn't that essentially create a custom format though ? Who consumes > the IVF header ? I see where you are going, but exposing IVF would be a useless dump of complexity for the userspace. IFV contains no useful information that is not already exposed by v4l2 interface. In this context, it's like exposing the USB headers. The use of data_offset is simply to avoid a copy. As Tomasz said, this is the exact purpose of data_offset. > > Another use case is handling of embedded data with CSI-2. > > CSI-2 sensors can send multiple types of data multiplexed in a single > virtual channels. Common use cases include sending a few lines of > metadata, or sending optical black lines, in addition to the main image. > A CSI-2 source could also send the same image in multiple formats, but I > haven't seen that happening in practice. The CSI-2 standard tags each > line with a data type in order to differentiate them on the receiver > side. On the receiver side, some receivers allow capturing different > data types in different buffers, while other support a single buffer > only, with or without data type filtering. It may thus be that a sensor > sending 2 lines of embedded data before the image to a CSI-2 receiver > that supports a single buffer will leave the user with two options, > capturing the image only or capturing both in the same buffer (really > simple receivers may only offer the last option). Reporting to the user > how data is organized in the buffer is needed, and the data_offset field > is used for this. > > This being said, I don't think it's a valid use case fo data_offset. As > mentioned above a sensor could send more than one data type in addition > to the main image (embedded data + optical black is one example), so a > single data_offset field wouldn't allow differentiating embedded data > from optical black lines. I think a more powerful frame descriptor API > would be needed for this. The fact that the buffer layout doesn't change > between frames also hints that this should be supported at the format > level, not the buffer level.