libcamera: Remove transform from V4L2SubdeviceFormat

Commit 6f6e1bf704 ("libcamera: camera_sensor: Apply flips at
setFormat()") extended the CameraSensor::setFormat() function
to apply vertical/horizontal flips on the sensor based on the
supplied Transform. To pass the Transform to the function the
V4L2SubdeviceFormat structure has been augmented with a Transform
member.

However as the newly added Transform is not used at all in the
V4L2Subdevice class, it should not be part of V4L2SubdeviceFormat.

Fix that by removing the transform field from V4L2SubdeviceFormat
and pass it as an explicit parameter to CameraSensor::setFormat().

Fixes: 6f6e1bf704 ("libcamera: camera_sensor: Apply flips at setFormat())
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Jacopo Mondi
2023-02-06 19:21:32 +01:00
parent 3aa42f36c0
commit 85befa816e
7 changed files with 19 additions and 28 deletions

View File

@@ -16,7 +16,6 @@
#include <string.h>
#include <libcamera/property_ids.h>
#include <libcamera/transform.h>
#include <libcamera/base/utils.h>
@@ -751,7 +750,6 @@ V4L2SubdeviceFormat CameraSensor::getFormat(const std::vector<unsigned int> &mbu
.mbus_code = bestCode,
.size = *bestSize,
.colorSpace = ColorSpace::Raw,
.transform = Transform::Identity,
};
return format;
@@ -760,6 +758,8 @@ V4L2SubdeviceFormat CameraSensor::getFormat(const std::vector<unsigned int> &mbu
/**
* \brief Set the sensor output format
* \param[in] format The desired sensor output format
* \param[in] transform The transform to be applied on the sensor.
* Defaults to Identity.
*
* If flips are writable they are configured according to the desired Transform.
* Transform::Identity always corresponds to H/V flip being disabled if the
@@ -770,18 +770,16 @@ V4L2SubdeviceFormat CameraSensor::getFormat(const std::vector<unsigned int> &mbu
*
* \return 0 on success or a negative error code otherwise
*/
int CameraSensor::setFormat(V4L2SubdeviceFormat *format)
int CameraSensor::setFormat(V4L2SubdeviceFormat *format, Transform transform)
{
/* Configure flips if the sensor supports that. */
if (supportFlips_) {
ControlList flipCtrls(subdev_->controls());
flipCtrls.set(V4L2_CID_HFLIP,
static_cast<int32_t>(!!(format->transform &
Transform::HFlip)));
static_cast<int32_t>(!!(transform & Transform::HFlip)));
flipCtrls.set(V4L2_CID_VFLIP,
static_cast<int32_t>(!!(format->transform &
Transform::VFlip)));
static_cast<int32_t>(!!(transform & Transform::VFlip)));
int ret = subdev_->setControls(&flipCtrls);
if (ret)