[libcamera-devel] Are camera sensor drivers required to support VIDIOC_SUBDEV_ENUM_FRAME_SIZE ioctl?

Laurent Pinchart laurent.pinchart at ideasonboard.com
Thu Oct 17 23:18:52 CEST 2019


Hi Andrey,

On Thu, Oct 17, 2019 at 08:39:56PM +0300, Andrey Konovalov wrote:
> Sorry, I mixed up the errno value.
> 
> On 17.10.2019 13:34, Andrey Konovalov wrote:
> > Hi,
> > 
> > (The current) libcamera wouldn't work with sensors which don't support VIDIOC_SUBDEV_ENUM_FRAME_SIZE ioctl:
> > 1) to "enumerate all media bus codes and frame sizes supported by the subdevice on a pad",
> >     V4L2Subdevice::formats() calls V4L2Subdevice::enumPadSizes()
> > 2) V4L2Subdevice::enumPadSizes() calls ioctl(VIDIOC_SUBDEV_ENUM_FRAME_SIZE, &sizeEnum), and the sensor driver
> >     which doesn't implement the enum_frame_size entry in v4l2_subdev_pad_ops returns -EINVAL for the very first pad.
> 
> Not -EINVAL, but -ENOTTY.
> 
> > 3) V4L2Subdevice::enumPadSizes() returns the empty vector of the sizes supported by the pad w/o logging any error.
> > 4) V4L2Subdevice::formats() sees sizes.empty()==TRUE, and returns the empty list of the formats supported by the sensor.
> > 
> > Many camera sensor drivers don't support VIDIOC_SUBDEV_ENUM_FRAME_SIZE, but do implement
> > VIDIOC_SUBDEV_[G,S]_FMT(which=V4L2_SUBDEV_FORMAT_TRY). The recently submitted to lkml drivers included.
> > 
> > What is the right way to fix that?
> > Add VIDIOC_SUBDEV_ENUM_FRAME_SIZE to all the sensor drivers?
> > Or extend libcamera's V4L2Subdevice::enumPadSizes() to use the VIDIOC_SUBDEV_[G,S]_FMT(which=V4L2_SUBDEV_FORMAT_TRY)
> > to find out the sizes supported by the sensor when VIDIOC_SUBDEV_ENUM_FRAME_SIZE is not implemented?
> > (Or maybe the both?)

VIDIOC_SUBDEV_ENUM_FRAME_SIZE is actually an ioctl that sensor drivers
shouldn't implement, in a perfect world. In a perfect world the drivers
would configure the sensor based on the cropping and scaling parameters
set by userspace through the selection rectangles and formats.
Unfortunately most drivers only implement a hardcoded list of
resolutions, most of the time because information on how to configure
the sensor properly is lacking (most sensors don't have public
datasheets, and private datasheets are often of low quality, in
particular for Omnivision sensors). libcamera should thus support
querying information from sensors using the format- and
selection-related ioctls. The only reason why that's not the case yet is
because we have only had to deal with sensors that only support a
hardcoded list of resolutions.

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list