[libcamera-devel,v2,0/2] Make sensor use its native Bayer order
mbox series

Message ID 20220113141558.5805-1-david.plowman@raspberrypi.com
Headers show
Series
  • Make sensor use its native Bayer order
Related show

Message

David Plowman Jan. 13, 2022, 2:15 p.m. UTC
Hi everyone

This patch is a replacement for a patch formerly titled "Fix
calculation of sensor's native Bayer order".

In this version we resolve an anomaly where the Bayer orders in
CameraSensor::init() were not well-defined - they can depend on
whatever hflip/vflip settings the camera happens to have when
opened.

A bug was introduced when the Raspberry Pi moved over to using media
controller whereby it ended up getting the wrong native Bayer order
(it was trying to clear the h/vflip bits, only it was too late because
the sensor had already cached the formats).

So anyway, the consequence of this was that the Bayer order in any raw
stream would frequently be wrong, meaning it would also be incorrect
in DNG files which is how I noticed it - the tuning tool was producing
garbage!

I also suspect that other pipeline handlers (e.g. IPU3) may have
similar problems, I don't know if anyone has tested the behaviour of
DNG files when different transforms are requested of the
sensor. Perhaps someone can enlighten me on that? But the change in
this patch set seems like it will be helpful to other PHs as well.

So there are 2 commits here:

1. The first commit resets the h/vflip bits of the sensor when it is
opened, so that we know we shall get the true native Bayer order.

2. The 2nd commit just simplifies the RPi implementation a little, now
that we can rely on the sensor's formats using the native order.

I'm definitely open to suggestions on this - my previous attempt left
the camera sensor alone and made the PH reverse engineer the true
Bayer order from the current formats and the sensor's current flip
settings. But this seems a bit fussy, particularly when other pipeline
handlers must surely copy this somewhat ugly behaviour (or not work).

Thanks!
David

David Plowman (2):
  libcamera: camera_sensor: Clear camera flips after opening the device
  pipeline: raspberrypi: Simplify calculation of sensor's native Bayer
    order

 src/libcamera/camera_sensor.cpp                  | 16 ++++++++++++++++
 .../pipeline/raspberrypi/raspberrypi.cpp         |  9 ++-------
 2 files changed, 18 insertions(+), 7 deletions(-)