<div dir="ltr"><div dir="ltr">Hi Jacopo,<div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 3 Nov 2022 at 11:50, Jacopo Mondi via libcamera-devel <<a href="mailto:libcamera-devel@lists.libcamera.org">libcamera-devel@lists.libcamera.org</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">Hi David<br>
<br>
On Thu, Nov 03, 2022 at 10:40:25AM +0000, David Plowman via libcamera-devel wrote:<br>
> Hi everyone<br>
><br>
> (Warning: may affect all pipeline handlers!)<br>
><br>
> I wanted to start the ball rolling on this. The problem is that when<br>
> we enumerate the cameras in the system, we try to set some of the<br>
> controls (specifically the HFLIP and VFLIP ones, and also later<br>
> HBLANK). But this will fail if we don't "own" the camera, for example,<br>
> it is already in use elsewhere.<br>
<br>
Feels like I'm missing one point here..<br>
<br>
How do you get to CameraSensor::init() if your pipeline handler<br>
acquires the unicam media device at the very beginning of match() ?<br>
<br>
I understand we allow multiple application acquire the same PH as the<br>
ph might register multiple cameras, but why is this a problem at<br>
match() time ?<br></blockquote><div><br></div><div>In match(), the rpi, rkisp and ipu3 pipeline handlers call CameraSensor::init() as part of the Camera object registration.  This call is unconditional assuming we can enumerate and register the sensor. </div><div><br></div><div>Not sure if that answers your question though?</div><div><br></div><div>Naush</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
><br>
> These patches address just the flip bits and not the HBLANK, though I<br>
> think the latter is a more straightforward problem. The flip bits are<br>
> troublesome because they affect the reported Bayer orders.<br>
><br>
> So here the idea is to store the formats in the sensor's native Bayer<br>
> order, as we were doing before. Only we can't reset the flip bits now,<br>
> we have to query them and transform any Bayer formats the sensor gives<br>
> us back into the native order. Two patches implement this:<br>
><br>
> 1. The first patch adds a function to turn BayerFormats back into mbus<br>
> codes. I couldn't see that we had functions to do this already, but<br>
> please correct me if I missed something!<br>
><br>
> 2. The second patch queries the flip bits and transforms any<br>
> BayerFormats back into the native order to be stored.<br>
><br>
> As I said, this potentially affects all pipeline handlers, which is<br>
> why I left it "RFC" for the moment. I did take a look through them all<br>
> to see what we might need to do:<br>
><br>
> raspberrypi.cpp<br>
><br>
> I think this PH is OK. We assume we're given the native Bayer order<br>
> and transform it according to the final sensor transform, setting the<br>
> flip bits every time. We update the format in any raw stream to match.<br>
><br>
> uvcvideo.cpp, simple.cpp<br>
><br>
> These appear to hardcode the transform to the Identity. I think mostly<br>
> they should be OK because the formats here won't be raw and you can't<br>
> have raw streams (?). Probably they should clear the flip bits to zero<br>
> where these controls exist, perhaps someone who knows more about them<br>
> could comment.<br>
><br>
> rkisp1.cpp:<br>
><br>
> Seems to force the transform to the Identity as well. So I think this<br>
> is like the above ones, it should be OK though it probably needs to<br>
> clear the sensor flip bits as well.<br>
><br>
> ipu3.cpp:<br>
><br>
> This one does handle transforms and appears to set the flip bits, so<br>
> that's good. I couldn't see it transforming the Bayer order for raw<br>
> streams correctly, so that probably wants checking. (To be fair, this<br>
> looks suspect already and is not made worse by these changes!)<br>
><br>
> Thoughts and opinions gratefully received, as always.<br>
><br>
> Thanks!<br>
> David<br>
><br>
> David Plowman (2):<br>
>   libcamera: bayer_format: Add toMbusCode method<br>
>   libcamera: camera_sensor: Do not clear camera flips when listing<br>
>     formats<br>
><br>
>  include/libcamera/internal/bayer_format.h |  1 +<br>
>  src/libcamera/bayer_format.cpp            | 12 ++++++<br>
>  src/libcamera/camera_sensor.cpp           | 51 +++++++++++++++++++----<br>
>  3 files changed, 56 insertions(+), 8 deletions(-)<br>
><br>
> --<br>
> 2.30.2<br>
><br>
</blockquote></div></div>