summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNaushir Patuck <naush@raspberrypi.com>2021-11-01 09:15:07 +0000
committerKieran Bingham <kieran.bingham@ideasonboard.com>2021-11-02 12:08:45 +0000
commit5acc21fd04fa8568eea9a0bc59e0e614acfbaf7c (patch)
tree0edff4aeff642bfd3d9e40d2579a457eeb981788 /src
parent91bd175c8f43bf66a039f9979ed89103808aef0b (diff)
pipeline: raspberrypi: Apply sensor flips at the start of configure()
Sensor flips might change the Bayer order of the requested format. The existing code would set a sensor format along with the appropriate Unicam and ISP input formats, but reset the latter two on start() once the flips had been requested. We can now set the sensor flips just before we set the sensor mode in configure(), thereby not needing the second pair of format sets in start(). Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r--src/libcamera/pipeline/raspberrypi/raspberrypi.cpp51
1 files changed, 16 insertions, 35 deletions
diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
index 1634ca98..e078b8b9 100644
--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
@@ -598,14 +598,26 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)
}
}
+ /*
+ * Configure the H/V flip controls based on the combination of
+ * the sensor and user transform.
+ */
+ if (data->supportsFlips_) {
+ const RPiCameraConfiguration *rpiConfig =
+ static_cast<const RPiCameraConfiguration *>(config);
+ ControlList controls;
+
+ controls.set(V4L2_CID_HFLIP,
+ static_cast<int32_t>(!!(rpiConfig->combinedTransform_ & Transform::HFlip)));
+ controls.set(V4L2_CID_VFLIP,
+ static_cast<int32_t>(!!(rpiConfig->combinedTransform_ & Transform::VFlip)));
+ data->setSensorControls(controls);
+ }
+
/* First calculate the best sensor mode we can use based on the user request. */
V4L2VideoDevice::Formats fmts = data->unicam_[Unicam::Image].dev()->formats();
V4L2DeviceFormat sensorFormat = findBestMode(fmts, rawStream ? sensorSize : maxSize);
- /*
- * Unicam image output format. The ISP input format gets set at start,
- * just in case we have swapped bayer orders due to flips.
- */
ret = data->unicam_[Unicam::Image].dev()->setFormat(&sensorFormat);
if (ret)
return ret;
@@ -620,10 +632,6 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)
LOG(RPI, Info) << "Sensor: " << camera->id()
<< " - Selected mode: " << sensorFormat.toString();
- /*
- * This format may be reset on start() if the bayer order has changed
- * because of flips in the sensor.
- */
ret = data->isp_[Isp::Input].dev()->setFormat(&sensorFormat);
if (ret)
return ret;
@@ -843,18 +851,6 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls)
return ret;
}
- /*
- * IPA configure may have changed the sensor flips - hence the bayer
- * order. Get the sensor format and set the ISP input now.
- */
- V4L2DeviceFormat sensorFormat;
- data->unicam_[Unicam::Image].dev()->getFormat(&sensorFormat);
- ret = data->isp_[Isp::Input].dev()->setFormat(&sensorFormat);
- if (ret) {
- stop(camera);
- return ret;
- }
-
/* Enable SOF event generation. */
data->unicam_[Unicam::Image].dev()->setFrameStartEnabled(true);
@@ -1253,10 +1249,6 @@ int RPiCameraData::loadIPA(ipa::RPi::SensorConfig *sensorConfig)
int RPiCameraData::configureIPA(const CameraConfiguration *config)
{
- /* We know config must be an RPiCameraConfiguration. */
- const RPiCameraConfiguration *rpiConfig =
- static_cast<const RPiCameraConfiguration *>(config);
-
std::map<unsigned int, IPAStream> streamConfig;
std::map<unsigned int, ControlInfoMap> entityControls;
ipa::RPi::IPAConfig ipaConfig;
@@ -1307,17 +1299,6 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config)
return -EPIPE;
}
- /*
- * Configure the H/V flip controls based on the combination of
- * the sensor and user transform.
- */
- if (supportsFlips_) {
- controls.set(V4L2_CID_HFLIP,
- static_cast<int32_t>(!!(rpiConfig->combinedTransform_ & Transform::HFlip)));
- controls.set(V4L2_CID_VFLIP,
- static_cast<int32_t>(!!(rpiConfig->combinedTransform_ & Transform::VFlip)));
- }
-
if (!controls.empty())
setSensorControls(controls);