<div dir="ltr"><div dir="ltr">Hi David,<div><br></div><div>Thank you for your patch.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 13 Jan 2022 at 14:16, David Plowman <<a href="mailto:david.plowman@raspberrypi.com">david.plowman@raspberrypi.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">We clear the V4L2_CID_HFLIP and V4L2_CID_VFLIP controls immediately<br>
after opening the camera device. This means the camera's Bayer format<br>
and mbus codes will be in the sensor's "native" order, and we document<br>
this to be the case so that it can be relied upon.<br>
<br>
Clearing the flips is harmless where sensor flips do not affect the<br>
Bayer order.<br>
<br>
This also fixes a bug in the Raspberry Pi pipeline handler where the<br>
native Bayer order was being computed wrongly, but the new behaviour<br>
here will be helpful to other pipeline handlers too. A subsequent<br>
commit will tidy up the Raspberry Pi pipeline handler in this area as<br>
it can now be simplified.<br>
<br>
Signed-off-by: David Plowman <<a href="mailto:david.plowman@raspberrypi.com" target="_blank">david.plowman@raspberrypi.com</a>><br>
Fixes: 83a512816189 (pipeline: raspberrypi: Convert the pipeline handler to use media controller)<br></blockquote><div><br></div><div>Reviewed-by: Naushir Patuck <<a href="mailto:naush@raspberrypi.com">naush@raspberrypi.com</a>> </div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
---<br>
src/libcamera/camera_sensor.cpp | 16 ++++++++++++++++<br>
1 file changed, 16 insertions(+)<br>
<br>
diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp<br>
index c3999d35..64f7f12c 100644<br>
--- a/src/libcamera/camera_sensor.cpp<br>
+++ b/src/libcamera/camera_sensor.cpp<br>
@@ -107,6 +107,17 @@ int CameraSensor::init()<br>
if (ret < 0)<br>
return ret;<br>
<br>
+ /*<br>
+ * Clear any flips to be sure we get the "native" Bayer order. This is<br>
+ * harmless for sensors where the flips don't affect the Bayer order.<br>
+ */<br>
+ ControlList ctrls(subdev_->controls());<br>
+ if (subdev_->controls().find(V4L2_CID_HFLIP) != subdev_->controls().end())<br>
+ ctrls.set(V4L2_CID_HFLIP, 0);<br>
+ if (subdev_->controls().find(V4L2_CID_VFLIP) != subdev_->controls().end())<br>
+ ctrls.set(V4L2_CID_VFLIP, 0);<br>
+ subdev_->setControls(&ctrls);<br>
+<br>
/* Enumerate, sort and cache media bus codes and sizes. */<br>
formats_ = subdev_->formats(pad_);<br>
if (formats_.empty()) {<br>
@@ -461,6 +472,11 @@ int CameraSensor::initProperties()<br>
/**<br>
* \fn CameraSensor::mbusCodes()<br>
* \brief Retrieve the media bus codes supported by the camera sensor<br>
+ *<br>
+ * Any Bayer formats are listed using the sensor's native Bayer order,<br>
+ * that is, with the effect of V4L2_CID_HFLIP and V4L2_CID_VFLIP undone<br>
+ * (where these controls exist).<br>
+ *<br>
* \return The supported media bus codes sorted in increasing order<br>
*/<br>
<br>
-- <br>
2.30.2<br>
<br>
</blockquote></div></div>