From 8695e02916ab7687231cb6e1a7f489b874f8b269 Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Wed, 30 Mar 2022 15:33:03 +0200 Subject: libcamera: v4l2_subdevice: Change V4L2Subdevice::Whence The V4L2Subdevice::Whence enumerations defines two values that should correspond to the V4L2_SUBDEV_FORMAT_ACTIVE and V4L2_SUBDEV_FORMAT_TRY definitions. The V4L2 symbols are defined as: V4L2_SUBDEV_FORMAT_TRY = 0, V4L2_SUBDEV_FORMAT_ACTIVE = 1, While the libcamera defined enumeration is: enum Whence { ActiveFormat, TryFormat, } As V4L2Subdevice::Whence values are used to populate data types defined in v4l2-subdev.h used as arguments to VIDIOC_SUBDEV_* ioctls, the V4L2Subdevice class is required to adjust their value as: subdevFmt.which = whence == ActiveFormat ? V4L2_SUBDEV_FORMAT_ACTIVE : V4L2_SUBDEV_FORMAT_TRY; Drop the adjustment by defining : Whence::TryFormat = V4L2_SUBDEV_FORMAT_TRY; Whence::ActiveFormat = V4L2_SUBDEV_FORMAT_ACTIVE; Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart Tested-by: Jacopo Mondi Reviewed-by: Kieran Bingham Signed-off-by: Laurent Pinchart --- src/libcamera/v4l2_subdevice.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index 98a3911a..37960b76 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -416,8 +416,7 @@ int V4L2Subdevice::getFormat(unsigned int pad, V4L2SubdeviceFormat *format, Whence whence) { struct v4l2_subdev_format subdevFmt = {}; - subdevFmt.which = whence == ActiveFormat ? V4L2_SUBDEV_FORMAT_ACTIVE - : V4L2_SUBDEV_FORMAT_TRY; + subdevFmt.which = whence; subdevFmt.pad = pad; int ret = ioctl(VIDIOC_SUBDEV_G_FMT, &subdevFmt); @@ -452,8 +451,7 @@ int V4L2Subdevice::setFormat(unsigned int pad, V4L2SubdeviceFormat *format, Whence whence) { struct v4l2_subdev_format subdevFmt = {}; - subdevFmt.which = whence == ActiveFormat ? V4L2_SUBDEV_FORMAT_ACTIVE - : V4L2_SUBDEV_FORMAT_TRY; + subdevFmt.which = whence; subdevFmt.pad = pad; subdevFmt.format.width = format->size.width; subdevFmt.format.height = format->size.height; -- cgit v1.2.1