Commit graph

2762 commits

Author SHA1 Message Date
Laurent Pinchart
a81ccba6a2 libcamera: base: class: Expose Extensible private data to other classes
Despite sharing the same name, the private data class created by the
Extensible design pattern and the C++ private access specifier have
different goals. The latter specifies class members private to the
class, while the former stores data not visible to the application.

There are use cases for accessing the private data class from other
classes inside libcamera. Make this possible by exposing public _d()
functions in the class deriving from Extensible. This won't allow access
to the private data by applications as the definition of the Private
class isn't visible outside of libcamera.

The _d() functions need to be defined as template functions to delay
their evaluation, as the static_cast() operator in the Extensible::_d()
functions needs the Private class to be fully defined. The template
argument is defaulted and ignored, as only its presence is required to
delay evaluation.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-07-12 19:59:19 +03:00
Naushir Patuck
37e31b2c6b ipa: raspberrypi: Make variable names consistent
s/DefaultAnalogueGain/defaultAnalogueGain/
s/DefaultExposureTime/defaultExposureTime/

Change these for consistency with the other static const variables.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-07-12 15:57:17 +03:00
Naushir Patuck
523236e4ac ipa: raspberrypi: Increase the default max frame duration to 250s
With the recent change to allow long exposures on the imx477, the existing 100s
limit was not adequate.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-07-12 15:57:15 +03:00
Naushir Patuck
9c0f6a22a2 pipeline: raspberrypi: Use priority write for vblank when writing sensor ctrls
When directly writing controls to the sensor device, ensure that VBLANK is
written ahead of and before the EXPOSURE control. This is the same priority
write mechanism used in DelayedControls.

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: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-07-12 15:57:12 +03:00
Naushir Patuck
6d89e33814 ipa: raspberrypi: Allow long exposure modes for imx477.
Update the imx477 CamHelper to use long exposure modes if needed.
This is done by overloading the CamHelper::GetVBlanking function to return a
frame length (and vblank value) computed using a scaling factor when the value
would be larger than what the sensor register could otherwise hold.

CamHelperImx477::Prepare is also overloaded to ensure that the "device.status"
metadata returns the right value if the long exposure scaling factor is used.
The scaling factor is unfortunately not returned back in metadata.

With the current imx477 driver, we can achieve a maximum exposure time of approx
127 seconds since the HBLANK control is read-only.

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: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-07-12 15:57:10 +03:00
Naushir Patuck
2d6a9b3592 ipa: raspberrypi: Add frame_length to DeviceStatus
Store the frame length into the DeviceStatus struct. The value is extracted
from embedded data when available, or calculated from the VBLANK value passed
from DelayedControls otherwise.

Update imx477 and imx219 CamHelper classes to extract the frame length from the
embedded data buffer.

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: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-07-12 15:57:07 +03:00
Naushir Patuck
f24d83720f ipa: raspberrypi: Add an operator<< to struct DeviceStatus
Add an operator<< overload to log all fields in DeviceStatus, and remove the
manual logging statements in the IPA and CamHelper.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-07-12 15:57:05 +03:00
Naushir Patuck
df8cafaf87 ipa: raspberrypi: Add a constructor struct DeviceStatus
The constructor sets all fields to 0. This replaces the memset(0) and default
value initialisation usage in the agc and lux controllers respectively.

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: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-07-12 15:57:02 +03:00
Naushir Patuck
ace5e21feb ipa: raspberrypi: Make device_status.h C++ only header, and update comments
This header file is no longer C compatible, so remove the extern "C"
declaration.

Replace C++ style comments with C style based on libcamera guidelines.

There are no functional changes in this commit.

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: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-07-12 15:56:57 +03:00
Laurent Pinchart
6a31a8d8e2 libcamera: buffer: Rename buffer.h to framebuffer.h
libcamera names header files based on the classes they define. The
buffer.h file is an exception. Rename it to framebuffer.h.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-07-11 17:42:02 +03:00
Laurent Pinchart
da9b6bb196 base: thread: Fix recursive calls to dispatchMessages()
There are use cases for calling the dispatchMessages() function
recursively, from within a message handler. This can be used, for
instance, to force delivery of messages posted to a thread concurrently
to stopping the thread. This currently causes access, in the outer
dispatchMessages() call, to iterators that have been invalidated by
erasing list elements in the recursive call, leading to undefined
behaviour (most likely double-free or other crashes).

Fix it by only erasing messages from the list at the end of the outer
call, identified using a recursion counter.

Bug: https://bugs.libcamera.org/show_bug.cgi?id=26
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Tested-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-07-11 17:42:02 +03:00
Laurent Pinchart
1f7f7a72ed test: message: Test recursive Thread::dispatchMessages() calls
The Thread::dispatchMessages() function needs to support recursive
calls, for instance to allow flushing delivery of invoked methods. Add a
corresponding test, which currently fails with a double free.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-07-11 17:41:59 +03:00
Laurent Pinchart
4c63bb4938 base: thread: Document the postMessage() function as thread-safe
The Thread::postMessage() function is thread-safe, document it as such.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-07-11 17:22:49 +03:00
Jean-Michel Hautbois
f23f3922b3 ipa: libipa: Fixups in CameraSensorHelpers
A few lines needed to be wrapped under 80 lines.
Remove some unneeded documentation and minor typos.

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-07-09 21:20:22 +02:00
Umang Jain
89219aea93 utils: ipc: proxy: Reset ControlSerializer during IPA configure
ControlSerializer should be reset during IPA (re)configuration,
so that it doesn't look up stale deserialized cache built from
consecutive previous runs. This is already recommended in
ControlSerializer docs but the implementation seems missing.

The stale cache lookup seems to the core issue with Bug #58.

Bug: https://bugs.libcamera.org/show_bug.cgi?id=58
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-07-09 22:56:27 +05:30
Laurent Pinchart
fb970d9cde libcamera: transform: Document Transform enumerators as such
Due to a bug in Doxygen that didn't properly handle enum class
enumerators when defined in a namespace, the Transform enumerators were
documented with free-formed text.

The issue has been fixed in Doxygen commit 309b397be106 ("issue #8281:
Out-of-line documentation of scoped enums in the same namespace"). We
can now fix the documentation.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
2021-07-06 19:58:36 +03:00
Laurent Pinchart
fb37998816 libcamera: device_enumerator: Drop inclusion of linux/media.h
device_enumerator.h doesn't need to include linux/media.h. Drop
inclusion of the header.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Tested-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2021-07-06 19:58:36 +03:00
Laurent Pinchart
fcccd7991f libcamera: media_device: Rename valid() function to isValid()
We use isValid() instead of valid() through the code base, make
MediaDevice consistent.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2021-07-06 19:58:36 +03:00
Laurent Pinchart
fe70472e9b android: Disable copy and move for CameraDevice
Instances of the CameraDevice class should never be copied or moved, as
they represent resources, Disable copying and moving for the class.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2021-07-06 19:58:36 +03:00
Laurent Pinchart
2c661f360b android: Disable copy and move for CameraHalManager
The CameraHalManager should be instantiated once only, and never copied
or moved. Disable copying and moving.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2021-07-06 19:58:36 +03:00
Nícolas F. R. A. Prado
143b252462 lc-compliance: Add list and filter parameters
Add a --list parameter that lists all current tests (by mapping to
googletest's --gtest_list_tests).

Add a --filter 'filterString' parameter that filters the tests to run
(by mapping to googletest's --gtest_filter).

While at it, add to the help message that further googletest options can
be passed through the environment.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-07-06 12:41:03 +02:00
Nícolas F. R. A. Prado
bc87163779 lc-compliance: Refactor using Googletest
Refactor lc-compliance using Googletest as the test framework.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-07-06 12:40:58 +02:00
Nícolas F. R. A. Prado
e5c51e1fcf lc-compliance: Add Environment singleton
Add a singleton Environment class in order to make the camera available
inside all tests. This is needed for the Googletest refactor, otherwise
the tests, which are statically declared, won't be able to access the
camera.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-07-06 12:40:53 +02:00
Nícolas F. R. A. Prado
034e0e81a2 lc-compliance: Make SimpleCapture::stop() idempotent
Make SimpleCapture::stop() be able to be called multiple times and at
any point so that it can be called from the destructor and an assert
failure can return immediately.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-07-06 12:40:47 +02:00
Nícolas F. R. A. Prado
b0bf6b0aa9 libcamera: camera: Make stop() idempotent
Make Camera::stop() idempotent so that it can be called in any state and
consecutive times. When called in any state other than CameraRunning, it
is a no-op. This simplifies the cleanup path for applications.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-07-06 12:40:41 +02:00
Laurent Pinchart
d7415bc4e4 ipa: raspberrypi: Drop unneeded [[maybe_unused]]
The [[maybe_unused]] in the IMX477 camera helper isn't needed. This had
been pointed out by Naush during review, but I failed to update the code
before pushing.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
2021-07-02 16:30:06 +03:00
Naushir Patuck
579f55b108 ipa: raspberrypi: Generalise the SMIA metadata parser
Instead of having each CamHelper subclass the MdParserSmia, change the
implementation of MdParserSmia to be more generic. The MdParserSmia now gets
given a list of registers to search for and helper functions are used to compute
exposure lines and gain codes from these registers.

Update the imx219 and imx477 CamHelpers by using this new mechanism.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-06-30 23:16:18 +03:00
Naushir Patuck
d3ea8e7885 ipa: raspberrypi: Use a unique_ptr for the metadata parser
The derived CamHelper class now allocates a metadata parser object through a
unique_ptr that is passed to the base class constructor. This automates the
lifetime management of the parser object.

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: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-06-30 23:16:18 +03:00
Jean-Michel Hautbois
9d44551404 libcamera: pipeline_handler: Hide implementation detail comment from doxygen
The comment is a implementation detail and does not belong to API
documentation. Move it inside the function.

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-06-30 07:57:38 +02:00
Andrey Konovalov
43fd7d0fc8 qcam: viewfinder_gl: Add support for RAW8 Bayer formats
This integrates the vertex and the fragment shaders by Morgan McGuire
into qcam.

Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-06-30 04:09:10 +03:00
Andrey Konovalov
e4be72d0ca qcam: viewfinder_gl: Set the vertex shader file name in selectFormat()
In preparation to extend the supported formats, make it possible
to use different vertex fragment files depending on the format.
Make "identity.vert" the default choice.

Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-06-30 04:08:10 +03:00
Andrey Konovalov
babb5a4c8b qcam: viewfinder_gl: Use SPDX-License-Identifier in bayer_8.* shaders
bayer_8.* vertex and fragment shaders carry the copy of the 2-Clause
BSD License. Replace it with the SPDX-License-Identifier.

Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-06-30 04:08:04 +03:00
Andrey Konovalov
12ad227efa qcam: viewfinder_gl: Fix wrong comment in bayer_8.frag
Fetching into value[2] corresponds to E0, and fetching into value[3] - to
F0. The fetch()-es themselves are correct, but the comments were not.

Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-06-30 04:07:58 +03:00
Andrey Konovalov
831b3f8132 qcam: viewfinder_gl: Copy the shaders for RAW8 Bayer format from motmot
This commit copies the shaders from:

e36d515805

Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>
Acked-by: Paul Elder <paul.elder@ideasonboard.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-06-30 04:07:58 +03:00
Andrey Konovalov
6424e86407 qcam: viewfinder_gl: Add support for RAW12 packed formats
All the four Bayer orders are supported.
The 4 LS bits of the 12-bit colour values are dropped as the RGBA
format we convert into has only 8 bits per colour.

Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-06-30 04:07:58 +03:00
Andrey Konovalov
c4259493dc qcam: viewfinder_gl: Add shader to render packed RAW10 formats
The shader supports all 4 packed RAW10 variants.
Simple bi-linear Bayer interpolation of nearest pixels is implemented.
The 2 LS bits of the 10-bit colour values are dropped as the RGBA
format we convert into has only 8 bits per colour.

The texture coordinates passed to the fragment shader are adjusted
to point to the nearest pixel in the image. This prevents artifacts
when the image is scaled from the frame resolution to the window size.

Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-06-30 04:07:58 +03:00
Andrey Konovalov
fa52c0f22f qcam: viewfinder_gl: Change uniform float tex_stepx to vec2 tex_step
In preparation to extend the supported formats, extend the tex_stepx
uniform to cover the steps between texels in both horizontal and
vertical directions.

Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-06-30 04:07:54 +03:00
Laurent Pinchart
12809ff171 libcamera: pipeline: simple: converter: Improve error message
When the configuration of the converter fails due to format mismatch,
the error messages only indicates that a failure occurred. Improve it to
ease debugging by printing the requested and obtained formats.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2021-06-29 00:43:46 +03:00
Laurent Pinchart
535820fe51 libcamera: pipeline: simple: Log pipeline topology
Log the topology for each valid discovered pipeline to aid debugging.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2021-06-29 00:43:46 +03:00
David Plowman
ec5d3142a9 libcamera: ipa: raspberrypi: Add support for ov9281 sensor
The necessary tuning file and CamHelper is added for the ov9281 sensor.

The ov9281 is a 1280x800 monochrome global shutter sensor. To enable
it, please add

dtoverlay=ov9281

to the /boot/config.txt file and reboot the Pi.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-06-28 19:34:46 +03:00
David Plowman
87998e064d libcamera: ipa: raspberrypi: Demote warnings about lack of AWB results
Warnings about the lack of AWB status results are demoted to being
just "Debug". With monochrome sensors becoming more common this would
otherwise overwhelm the console output, and in practice nothing is
really lost as it is normally very evident if AWB is failing to run.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-06-28 19:33:47 +03:00
David Plowman
bdf04cca08 libcamera: Add support for monochrome sensors
This commit adds support for monochrome (greyscale) raw sensors. These
are sensors that have no colour filter array, so all pixels are the
same and there are no distinct colour channels.

These sensors still require many of an ISP's processing stages, such
as denoise, tone mapping, but not those that involve colours (such as
demosaic, or colour matrices).

Signed-off-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: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-06-28 19:33:42 +03:00
Jean-Michel Hautbois
8738d539f4 ipa: ipu3: Initialize CameraSensorHelper at IPU3 init stage
In order for the CameraSensorHelper to be instantiated, we need to find
its factory using the camera sensor model name stored in
IPASettings::sensorModel. As we don't need to do it at each configure
call (the sensor is not changing in-between), implement the init call in
IPAIPU3 to do that.

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-06-28 10:54:43 +02:00
Jean-Michel Hautbois
32677e1220 ipa: Create a camera sensor helper class
For various sensor operations, it may be needed to do sensor specific
computations, like analogue gain or vertical blanking.

This commit introduces a new camera sensor helper in libipa which aims
to solve this specific issue.
It is based on the MIPI alliance Specification for Camera Command Set
and implements, for now, only the analogue "Global gain" mode.
Setting analogue gain for a specific sensor is not a straightforward
operation, as one needs to know how the gain is calculated for it.

Three helpers are created in this patch: imx219, ov5670 and ov5693.

Adding a new sensor is pretty straightforward as one only needs to
implement the sub-class for it and register that class to the
CameraSensorHelperFactory.

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2021-06-28 10:48:33 +02:00
Laurent Pinchart
1684c3f930 android: camera_device: Fix null pointer dereference
Commit 7532caa2c7 ("android: camera_device: Reset config_ if
Camera::configure() fails") reworked the configuration sequence to
ensure that the CameraConfiguration pointers gets reset when
configuration fails. This inadvertently causes a null pointer
dereference, as the CameraStream constructor accesses the camera
configuration through CameraDevice::cameraConfiguration() before the
internal config_ pointer is set.

Fix this by passing the configuration pointer explicitly to the
CameraStream constructor.

Fixes: 7532caa2c7 ("android: camera_device: Reset config_ if Camera::configure() fails")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Tested-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Tested-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
2021-06-28 10:51:57 +03:00
Laurent Pinchart
d3fef99844 libcamera: utils: Only enable utils::hex() for integer arguments
The utils::hex() function is defined as a function template that has
implementations for integer arguments only. When given a different
argument type, the compiler will not catch the issue, but linking will
fail:

src/libcamera/libcamera.so.p/camera_sensor.cpp.o: in function `libcamera::CameraSensor::validateSensorDriver()':
camera_sensor.cpp:(.text+0x1e6b): undefined reference to `libcamera::utils::_hex libcamera::utils::hex<libcamera::ControlId const*>(libcamera::ControlId const*, unsigned int)'

Move the failure to compilation time by enabling the function for
integer arguments only. This provides better diagnostics:

../../src/libcamera/camera_sensor.cpp: In member function ‘int libcamera::CameraSensor::validateSensorDriver()’:
../../src/libcamera/camera_sensor.cpp:199:77: error: no matching function for call to ‘hex(const libcamera::ControlId*&)’

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2021-06-28 08:07:51 +03:00
Laurent Pinchart
9fcef36be6 libcamera: device_enumerator: Fix include order for internal headers
The device_enumerator_sysfs.h and device_enumerator_udev.h internal
headers are not at the correct location. Fix it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2021-06-28 08:07:35 +03:00
Hirokazu Honda
b8732a80fe android: camera_device: Check if a request is configured on processCaptureRequest()
Add a check on processCaptureRequest() if a given capture
request contains a camera stream that has been configured.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-06-28 07:51:36 +03:00
Laurent Pinchart
4510638e5d android: mm: cros_camera_buffer: Drop undefined functions
The CameraBuffer::Private::planeAddr() functions are declared but not
defined (and of course not used). Drop them.

Fixes: d8d6a78f22 ("android: Introduce Chromium OS buffer manager")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2021-06-28 07:45:52 +03:00
Laurent Pinchart
7532caa2c7 android: camera_device: Reset config_ if Camera::configure() fails
The config_ pointer is reset in all error paths of the
CameraDevice::configureStreams() function, except when
Camera::configure() fails. Fix it by using a local unique pointer to
store the configuration until the end of the function, to avoid similar
issues in the future.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2021-06-28 07:02:44 +03:00