libcamera: simple: Detect Bayer pattern change during configure()

Bayer pattern on the sensor can change while configuring it with the
intended capture format. This is due to the transform being applied on
the sensor which supports [v/h]flips.

During configure(), the simple pipeline handler does not detect any
bayer pattern changes that can arise due to the transformations being
applied via SimpleCameraData:setupFormats(). In such cases, the video
node will be configured in-correctly, without realising the bayer
pattern has changed on the sensor, for the given capture format.

This patch detects the bayer pattern change after the sensor has
been configured and retrieves the corresponding V4L2 pixel format
to correctly configure the video node and the input to converter or
Soft-ISP.

Signed-off-by: Umang Jain <uajain@igalia.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Tested-by: Milan Zamazal <mzamazal@redhat.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Umang Jain
2025-08-12 13:00:55 +05:30
committed by Kieran Bingham
parent 18732fecf1
commit 7e8c274d18
+15 -3
View File
@@ -1423,8 +1423,20 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)
if (ret < 0)
return ret;
/* Configure the video node. */
V4L2PixelFormat videoFormat = video->toV4L2PixelFormat(pipeConfig->captureFormat);
/* Configure the video node, taking into account any Bayer pattern change. */
V4L2PixelFormat videoFormat;
if (format.code == pipeConfig->code) {
videoFormat = video->toV4L2PixelFormat(pipeConfig->captureFormat);
} else {
/*
* Bayer pattern has changed because of the transform that was applied on
* the sensor. Get the V4L2PixelFormat corresponding to the configured Bayer
* pattern.
*/
BayerFormat cfgBayer = BayerFormat::fromPixelFormat(pipeConfig->captureFormat);
cfgBayer.order = data->sensor_->bayerOrder(config->combinedTransform());
videoFormat = cfgBayer.toV4L2PixelFormat();
}
V4L2DeviceFormat captureFormat;
captureFormat.fourcc = videoFormat;
@@ -1466,7 +1478,7 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)
return 0;
StreamConfiguration inputCfg;
inputCfg.pixelFormat = pipeConfig->captureFormat;
inputCfg.pixelFormat = videoFormat.toPixelFormat();
inputCfg.size = pipeConfig->captureSize;
inputCfg.stride = captureFormat.planes[0].bpl;
inputCfg.bufferCount = kNumInternalBuffers;