Skip to contentSkip to conversation

v4l2 api: supported resolution negotiation

DISCUSSION Matwey V. Kornilov 4 participants 4 messages Oct 4, 2015 – Oct 12, 2015 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

Hello,

I learned from V2L2 API how to detect all supported formats using VIDIOC_ENUM_FMT.
When I perform VIDIOC_S_FMT I don't know how to fill fmt.pix.width and fmt.pix.height, since I know only format.
How should I negotiate device resolution? Could you point me?

#1 lore raw
Quoted 7 lines · Matwey V. Kornilov

Hello,

I learned from V2L2 API how to detect all supported formats using VIDIOC_ENUM_FMT.
When I perform VIDIOC_S_FMT I don't know how to fill fmt.pix.width and fmt.pix.height, since I know only format.
How should I negotiate device resolution? Could you point me?

VIDIOC_ENUM_FRAMESIZES may give you hints, but it's optional. You can use values you prefer to try if drivers support them; I think the GStreamer v4lsrc tries very small and very large values. The driver will clamp them to a supported values which are passed to the application from the IOCTL.

<URL:http://hverkuil.home.xs4all.nl/spec/media.html#vidioc-enum-framesizes>

Signature · 4 lines
Regards,

Sakari Ailus
e-mail: [email protected]	XMPP: [email protected]
#2 lore raw
Quoted 5 lines · Sakari Ailus

I think the GStreamer
v4lsrc tries very small and very large values. The driver will clamp them to
a supported values which are passed to the application from the IOCTL.

In GStreamer we try ENUM_FRAMESIZE, and when no supported, we fallback to try_fmt() with 1x1 (driver will raise it to the minimum) and then MAX,MAX (driver will lower it to the maximum). We assume that the driver supports a range, as iterating over all possibilities takes too much time.

Nicolas

#3 lore raw
In reply to Sakari Ailus
Quoted 9 lines · Sakari Ailus
Quoted 7 lines · Matwey V. Kornilov

Hello,

I learned from V2L2 API how to detect all supported formats using VIDIOC_ENUM_FMT.
When I perform VIDIOC_S_FMT I don't know how to fill fmt.pix.width and fmt.pix.height, since I know only format.
How should I negotiate device resolution? Could you point me?

Quoted 7 lines

VIDIOC_ENUM_FRAMESIZES may give you hints, but it's optional. You can use values you prefer to try if drivers support them; I think the GStreamer v4lsrc tries very small and very large values. The driver will clamp them to a supported values which are passed to the application from the IOCTL.

<URL:http://hverkuil.home.xs4all.nl/spec/media.html#vidioc-enum-framesizes>

You can also call G_FMT first, then change the pixelformat and call S_FMT. This will only change the pixelformat and leave the resolution the same (unless the driver has some restrictions for the new pixelformat, but that's unlikely).

Regards,

Hans