Commit graph

4213 commits

Author SHA1 Message Date
Sophie Friedrich
a146e05125 libcamera: camera_manager: Stop exponential explosive calls to createPipelineHandlers
Currently the function `createPipelineHandlers` connects itself to the
`devicesAdded` signal at the end of each call. As the Signal object
supports multiple non-unique listeners connected to it, the former
function would be called exponentially often with each new emitted event
on `devicesAdded` (i.e. with udev plugging in a new camera)

Fix it by connecting the createPipelineHandlers() slot to `devicesAdded`
signal in CameraManager::Private::init() instead. This will prevent the
slot getting connected multiple times to the `devicesAdded` signal.

Signed-off-by: Sophie Friedrich <dev@flowerpot.me>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-03-06 14:35:17 +02:00
Advait Dhamorikar
cee03cd183 Documentation: guides: pipeline-handler: Fix spelling error
The pipeline handler writers guide incorrectly references the
VividCameradata::init() impelementation with a spelling error.

Fix spelling of "impelementation" in the pipeline handler development
guide.

Signed-off-by: Advait Dhamorikar <advaitdhamorikar@gmail.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>
2023-03-06 13:10:54 +02:00
Matthias Fend
dbe96a2a6b libcamera: Keep using syslog for isolated IPA modules
Currently it is not possible to display debug output from an isolated IPA
module. The standard  descriptors are all closed and any specified log
file is explicitly deactivated for the IPA module. Since libcamera and the
isolated IPA module are separate processes, they cannot write to the same
file. However, if syslog is used, then this would be possible.

If syslog is specified as a log file, then this is left as it is for the
isolated IPA module.

Signed-off-by: Matthias Fend <matthias.fend@emfend.at>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Tested-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2023-03-01 16:46:08 +01:00
Paul Elder
51396ab512 utils: checkstyle.py: Don't run commit title checker on staged commits
When creating a new commit, there is no title, so the title checker
complains that the title isn't compliant and the commit cannot be
created if checkstyle is run as a pre-commit hook. Fix this by skipping
the title checker when run on staged changes.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-03-01 17:20:05 +09:00
Barnabás Pőcze
58e0b6e18c apps: Return std::optional<> from StreamKeyValueParser::parseRole()
Instead of having bool return type and an out parameter, use
std::optional<libcamera::StreamRole> to return from
StreamKeyValueParser::parseRole().

Meanwhile at it, re-word an existing comment to make it lucid.

Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
2023-02-15 01:32:05 +05:30
David Plowman
02f0492c55 pipeline: raspberrypi: Always use ColorSpace::Raw for raw streams
Commit 613d540267 ("pipeline: raspberrypi: Fix handling of colour
spaces") adjusts the colorspace to ColorSpace::Raw for raw streams.
However, if the colorspace is not requested for raw streams(nullopt),
we should still set the colorspace to ColorSpace::Raw, for raw streams.

Fixes: 613d540267 ("pipeline: raspberrypi: Fix handling of colour spaces")
Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
2023-02-15 01:32:03 +05:30
Pavel Machek
3f8bcc1a36 Documentation: Small typo fix
Out should really be output.

Signed-off-by: Pavel Machek <pavel@ucw.cz>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-02-12 20:01:25 +02:00
Harvey Yang
2403f5141f android: jpeg: Add JEA implementation
This patch adds JEA implementation to replace libjpeg in CrOS platform,
where hardware accelerator is available.

Signed-off-by: Harvey Yang <chenghaoyang@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-02-10 00:47:42 +02:00
Harvey Yang
8702b9dac7 android: jpeg: Pass StreamBuffer to Encoder::encoder
To prepare for support of the JEA encoder in a following commit, which
will need to access the buffer_handle_t of the destination buffer, pass
the StreamBuffer to the Encoder::encoder() function. As the StreamBuffer
contains the source FrameBuffer and the destination Span, drop them from
the function arguments and access them directly from the StreamBuffer.

Signed-off-by: Harvey Yang <chenghaoyang@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Han-Lin Chen <hanlinchen@chromium.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-02-10 00:47:42 +02:00
Harvey Yang
7a44534c4f android: jpeg: Add meson.build in src/android/jpeg
To further control sources in jpeg to build based on the platform, this
patch adds meson.build in src/android/jpeg directory.

Signed-off-by: Harvey Yang <chenghaoyang@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Han-Lin Chen <hanlinchen@chromium.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-02-10 00:47:42 +02:00
Harvey Yang
b64fa1363c android: framebuffer: Add HALFrameBuffer and replace FrameBuffer
HALFrameBuffer is derived from FrameBuffer with access to
buffer_handle_t, which is needed for JEA usage.

Signed-off-by: Harvey Yang <chenghaoyang@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Han-Lin Chen <hanlinchen@chromium.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-02-10 00:47:41 +02:00
Harvey Yang
4843bfa66d libcamera: framebuffer: Allow inheritance of FrameBuffer
To add buffer_handle_t access in android, this patch allows inheritance
of FrameBuffer to add a derived class in android.

Signed-off-by: Harvey Yang <chenghaoyang@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Han-Lin Chen <hanlinchen@chromium.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-02-10 00:47:41 +02:00
Jacopo Mondi
85befa816e libcamera: Remove transform from V4L2SubdeviceFormat
Commit 6f6e1bf704 ("libcamera: camera_sensor: Apply flips at
setFormat()") extended the CameraSensor::setFormat() function
to apply vertical/horizontal flips on the sensor based on the
supplied Transform. To pass the Transform to the function the
V4L2SubdeviceFormat structure has been augmented with a Transform
member.

However as the newly added Transform is not used at all in the
V4L2Subdevice class, it should not be part of V4L2SubdeviceFormat.

Fix that by removing the transform field from V4L2SubdeviceFormat
and pass it as an explicit parameter to CameraSensor::setFormat().

Fixes: 6f6e1bf704 ("libcamera: camera_sensor: Apply flips at setFormat())
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-02-09 23:40:15 +01:00
Laurent Pinchart
3aa42f36c0 pipeline: raspberrypi: Drop unused code
Commit 1a614866a2 ("libcamera: camera_sensor: Validate Transform") has
removed usage of the RPiCameraData::supportsFlips_ but hasn't removed
the field itself, nor its initialization. Drop those as they're unused.

Fixes: 1a614866a2 ("libcamera: camera_sensor: Validate Transform")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2023-02-09 21:40:48 +02:00
Laurent Pinchart
9cc5cbadc2 pipeline: ipu3: Drop unused code
Commit 1a614866a2 ("libcamera: camera_sensor: Validate Transform") has
removed usage of the IPU3CameraData::rotationTransform_ but hasn't
removed the field itself, nor its initialization. Drop those as they're
unused.

Fixes: 1a614866a2 ("libcamera: camera_sensor: Validate Transform")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2023-02-09 21:40:47 +02:00
Laurent Pinchart
ec392360f6 libcamera: camera_sensor: Fix typo in comment
Fix a typo introduced in a comment when refactoring transformation
handling in the CameraSensor class.

Fixes: 1a614866a2 ("libcamera: camera_sensor: Validate Transform")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2023-02-09 21:40:45 +02:00
Laurent Pinchart
fb344abda9 libcamera: camera_sensor: Demote flip support message to Debug
The CameraSensor::validateSensorDriver() function prints a Warning
message when the camera sensor doesn't support flips. We don't mandate
flip support and can run without it without any problem, so a warning is
too harsh. Demote it to a Debug message.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2023-02-09 21:40:41 +02:00
Umang Jain
e72b121d65 libcamera: internal: tracepoints: Use correct include directive
libcamera uses double quotes "..." for #include directives for
internal headers.

While at it, move the request internal header include to the right
location.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-02-09 19:39:54 +05:30
Naushir Patuck
61b43e50e7 ipa: raspberrypi: Normalise region sums to 16-bits
The VC4 ISP uses a pipeline bit-depth of 13-bits. The AGC algorithm needs to
know this bit-depth when computing the Y value for the image.

Instead of hardcoding the VC4 bit-depth in the AGC source code, normalise all
region sums to 16-bits when filling the Statistics structure. AWB and ALSC are
agnostic about pipeline depth, so do not need changing.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-02-09 13:11:44 +00:00
Naushir Patuck
6d60f264d1 ipa: raspberrypi: Use the generic statistics structure in the algorithms
Repurpose the StatisticsPtr type from being a shared_ptr<bcm2835_isp_stats> to
shared_ptr<RPiController::Statistics>. This removes any hardware specific header
files and structures from the algorithms source code.

Add a new function in the Raspberry Pi IPA to populate the generic statistics
structure from the values provided by the hardware in the bcm2835_isp_stats
structure.

Update the Lux, AWB, AGC, ALSC, Contrast, and Focus algorithms to use the
generic statistics structure appropriately in their calculations. Additionally,
remove references to any hardware specific headers and defines in these source
files.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Tested-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-02-09 13:11:30 +00:00
Naushir Patuck
e8dd0fdc83 ipa: raspberrypi: awb: Delay release of the statistics buffer
Release the statistics buffer after running the through the AWB calculations.
Only the "counted" statistics are copied out to a local structure, so keeping
the statistics buffer allows the algorithm to see the "uncounted" statistics as
well.

This is currently handled by hard-coding the total number of statistics regions
regions based on the structure definition in the bcm2835_isp_stats structure.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-02-09 11:33:52 +00:00
Naushir Patuck
f0c0468b3b ipa: raspberrypi: histogram: Add a constructor for an empty histogram
Add a default constructor to the RPiController::Histogram class that creates
an empty histogram. Since this is a cumulative histogram, push a value of 0 into
the first (and only) bin to signify this.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-02-09 11:33:52 +00:00
Naushir Patuck
312bd707bd ipa: raspberrypi: Generalise statistics
At present, the controller algorithms access the bcm2835_isp_stats structure,
which is hardware specific. It would be desirable to abstract out the statistics
structure to remove hardware specific headers from the algorithms source files.

Define a new templated RegionStats class that encompasses region based
statistics generated by the ISP. For the VC4 ISP, this can be used to hold
RGB sums and focus FoM values.

Define a new Statistics structure that holds all the VC4 ISP statistics output.
This includes AGC histograms, AGC/AWB region sums and focus FoM regions.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-02-09 11:33:52 +00:00
Kieran Bingham
6cf637eb25 libcamera v0.0.4
Bugfixes:
 * libcamera: yaml_parser: Use C locale
 * libcamera: base: utils: Support C libraries lacking locale support
 * py: cam.py: Fix duplicate metadata output if more than one stream
 * libcamera: camera: Fix validateColorSpaces to choose main colour space
 * pipeline: raspberrypi: Fix handling of colour spaces

Core:
 * test: Fix/Enable testing with ASan
 * test: Remove redundant pipeline tests
 * meson: Only build pipeline handlers needed in host architecture
 * meson: Add 'all' choice to pipelines option
 * utils: checkstyle.py: Add commit title checker
 * libcamera: ipa_module: Relax ipaModuleInfo symbol size check
 * pipeline: Support configuration file paths

ipa:
 * camera_sensor: Improve h/v flip handling
 * camera_sensor: Add AR0521 Sensor support
 * camera_sensor: Add OV4689 Sensor support
 * camera_sensor: Add support for OmniVision OV8858
 * raspberrypi: Support Autofocus with PDAF
 * raspberrypi: Support for the Sony IMX708 sensor
 * rkisp1: Raise maximum analogue gain

pipeline:
 * raspberrypi: Support parameters from a configuration file
 * raspberrypi: Add a parameter to disable startup drop frames
 * libcamera: rkisp1: Add support for Transform

apps:
 * gstreamer: Add bayer8 support to libcamerasrc
 * qcam: Show string representation of pixel format

ABI Compliance:
 * abi-compliance-checker reports 100% ABI and API compatibility with
   with v0.0.3

Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-02-01 00:44:16 +00:00
Naushir Patuck
b47ecacc78 pipeline: raspberrypi: Add a parameter to disable startup drop frames
Add a new pipeline config parameter "disable_startup_frame_drops" to
disable any startup drop frames, overriding the IPA request.

When this parameter is set, it allows the pipeline handler to run with
no internally allocated Unicam buffers ("min_unicam_buffers").

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: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-01-31 16:54:36 +00:00
Naushir Patuck
8c53b2498b pipeline: raspberrypi: Read config parameters from a file
Add the ability to read the platform configuration parameters from a
config file provided by the user through the LIBCAMERA_RPI_CONFIG_FILE
environment variable. Use the PipelineHandler::configurationFile()
helper to determine the full path of the file.

Provide an example configuration file named example.yaml. Currently two
parameters are available through the json file:

"min_unicam_buffers" The minimum number of internal Unicam buffers to
allocate.

"min_total_unicam_buffers" The minimum number of internal + external
Unicam buffers that must be allocated.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-01-31 16:54:36 +00:00
Naushir Patuck
8b267c24a0 pipeline: raspberrypi: Reorder startup drop frame initialisation
Reorder the code such that the IPA requested startup drop frames count is
available before the pipeline handler allocates any stream buffers.

This will be used in a subsequent change to stop Unicam buffer allocations if
there are no startup drop frames required and the application has configured a
raw stream and always provides buffers for it.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-01-31 16:54:36 +00:00
Naushir Patuck
375bc787f4 pipeline: raspberrypi: Add a pipeline config structure
Add a configuration structure to store platform specific parameters used by
the pipeline handler. Currently, these only store Unicam buffer counts,
replacing the hardcoded static values in the source code.

In subsequent commits, more parameters will be added to the configuration
structure, and parameters will be read in through a config file.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-01-31 16:54:36 +00:00
Naushir Patuck
de4aac5abd libcamera: pipeline: Add a platform configuration file helper
Add a new helper function PipelineHandler::configurationFile() that returns
the full path of a named configuration file. This configuration file may be read
by pipeline handlers for platform specific configuration parameters on
initialisation.

The mechanism for searching for the configuration file is similar to the IPA
configuration file:

- In the source tree if libcamera is not installed
- Otherwise in standard system locations (etc and share directories).

When stored in the source tree, configuration files shall be located in a 'data'
subdirectory of their respective pipeline handler directory.

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: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-01-31 16:54:36 +00:00
Naushir Patuck
322334dae7 libcamera: pipeline: build: Add pipeline_data_dir variable
Add a pipeline_data_dir variable to the meson build files. This variable
points to the location of pipeline handler specific configuration files
on the filesystem.

Signed-off-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: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-01-31 16:54:36 +00:00
David Plowman
613d540267 pipeline: raspberrypi: Fix handling of colour spaces
We implement a custom validateColorSpaces method that forces all
(non-raw) streams to same colour space, whilst distinguishing RGB
streams from YUV ones, as the former must have the YCbCr encoding and
range over-written.

When we apply the colour space, we always send the full YUV version as
that gets converted correctly to what our hardware drivers expect. It
is also careful to check what comes back as the YCbCr information gets
overwritten again on the way back.

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: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
2023-01-31 15:10:41 +05:30
Nick Hollinghurst
952ef94ed7 ipa: raspberrypi: Add support for the Sony IMX708 sensor
Add support for Raspberry Pi Camera 3 modules (Sony IMX708 camera sensor) to the
Raspberry Pi IPA. These modules are available in either normal or wide angle
lens, both with IR or no IR cut options, giving a total for 4 variants. Provide
IQ tuning files for all four variants.

The IMX708 camera helper additionally parses PDAF and HDR histogram data that
is provided in the embedded data stream from Unicam.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-01-30 16:30:44 +00:00
Nick Hollinghurst
2fb0f25019 libcamera: camera_sensor: Add Sony IMX708 sensor properties
Add CameraSensorProperties for the Sony IMX708 sensor.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-01-30 16:30:44 +00:00
Naushir Patuck
9b0db2aa43 ipa: raspberrypi: Add lens position to DeviceStatus
Add the current frame's lens position (in dioptres) to the DeviceStatus
structure. This value is obtained from the AfAlgorithm::getLensPosition()
member function. Return this lens position back to the pipeline handler to
store in the metadata field of the request.

As a drive-by, fixup some inaccurate comments in the DeviceStatus structure.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Nick Hollinghurst nick.hollinghurst@raspberrypi.com
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-01-30 16:30:44 +00:00
Nick Hollinghurst
cc010b0c35 ipa: raspberrypi: First version of autofocus algorithm using PDAF
Provide the first version of the Raspberry Pi autofocus algorithm. This
implementation uses a hybrid of contrast detect autofocus (CDAF) and phase
detect autofocus (PDAF) statistics. PDAF is always preferred over CDAF due to
having less "hunting" behavior.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-01-30 16:30:44 +00:00
Nick Hollinghurst
8418473c51 ipa: raspberrypi: Handle autofocus algorithm results
Handle the results returned from the autofocus algorithm by updating lens
actuator position to the desired value. Update the Request metadata with the
algorithm status to provide back to the application.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-01-30 16:30:43 +00:00
Nick Hollinghurst
a38c0502b4 ipa: raspberrypi: Handle autofocus controls
Add handlers for all autofocus related libcamera controls. Translate these
controls to the RPiController autofocus algorithm API.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-01-30 16:30:43 +00:00
Naushir Patuck
3caa0dde0e ipa: raspberrypi: Include autofocus controls in the IPA ControlInfoMap
Add all the autofocus controls handled by the IPA into the ControlInfoMap if
a controllable lens actuator is present.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-01-30 16:30:43 +00:00
Naushir Patuck
aa2028e42f ipa: raspberrypi: Reorder header file inclusion
Reorder the libcamera/request header file inclusion to match the libcamera
guidelines.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-01-30 16:30:43 +00:00
Nick Hollinghurst
23aefee337 ipa: raspberrypi: Add autofocus algorithm interface headers
Add a new AfAlgorithm class that defines the interface for the Raspberry Pi
autofocus algorithm.

Add an AfStatus structure that returns the results of the autofocus algorithm
back to the IPA.

Add a structure for PDAF statistics provided by supported sensors for use with
an autofocus algorithm. This structure is currently based on the IMX708's PDAF
"Type 1" statistics.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-01-30 16:30:43 +00:00
Nick Hollinghurst
6290deea02 ipa: mojom: raspberrypi: Add setLensControls() function
Add a setLensControls() function to the IPA/pipeline handler interface. This
will be used in a future commit to control the lens actuator position from an
autofocus algorithm.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-01-30 16:30:43 +00:00
Naushir Patuck
b9923747ad pipeline: ipa: raspberrypi: Validate lens controls
Pass the available lens controls to the IPA through the configure() function.
Validate that the V4L2_CID_FOCUS_ABSOLUTE does exist. If it doesn't, log a
warning message, and do not advertise focus related controls from the IPA.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-01-30 16:30:43 +00:00
Naushir Patuck
c204a67bae pipeline: ipa: raspberrypi: Replace entityControls
Replace the legacy entityControls map passed into ipa::configure() with explicit
fields for sensor and ISP controls. This removes any ambiguity over which set of
controls corresponds with specific integer keys.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-01-30 16:30:43 +00:00
Naushir Patuck
d70c38dca8 pipeline: ipa: raspberrypi: Remove unused streamConfig
Remove the streamConfig parameter from the ipa::configure() call, it is never
used.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-01-30 16:30:43 +00:00
Naushir Patuck
a0701930a8 pipeline: ipa: raspberrypi: Check if lens actuator is available
Check if a lens actuator is available by the presense of the lens driver entity
in the pipeline handler. Pass this result to the IPA on init.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-01-30 16:30:43 +00:00
Kieran Bingham
8f85c024f9 meson: Rework automatic pipeline selection
The supported pipelines are listed in three places: the
meson_options.txt file, the defined array when a user selects
-Dpipelines="all", and arrays defined when the default
-Dpipelines="auto" is selected.

This can be hard to maintain and error prone.

Rework the definition of pipeline selection to a single table which
specifies the architecture(s) that the pipeline handler supports and
iterate it to handle the special cases for 'all', 'auto' and 'test'.

The current behaviour such that 'all' takes precedence over 'auto' is
maintained, and 'test' is now extended such that additional test
pipeline handlers can easily be introduced.

The existing implementation defines the i.MX8-ISI and RKISP1 pipeline
handlers as only supported by 'aarch64'. This conversion changes the
behaviour such that those pipeline handlers are now supported on both
'arm' and 'aarch64' as each of those platforms could support a 32-bit
ARM build.

Suggested-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-01-30 16:30:43 +00:00
David Plowman
4133dbe2b3 pipeline: raspberrypi: Improve the values reported in the ScalerCrop control
Previously the x,y offsets in the min/max ScalerCrop control values
were zero. Here we make them the same as the sensor's analogue crop
offset which is I think less misleading.

With this change, it also seems reasonable to advertise the default
scaler crop value to be the true default that you will get. This makes
it possible for applications to see what that value will be without
having to start the camera and wait for frames.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-01-30 16:30:43 +00:00
Jacopo Mondi
bb35ac92e4 documentation: sensor_drivers: Document H/V flip
Briefly document the optional requirement support for H/V flip controls.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
2023-01-30 12:04:17 +01:00
Jacopo Mondi
517017c49a libcamera: rkisp1: Add support for Transform
Add support for Transform to the RkISP1 pipeline handler.

The pipeline rotates using the sensor's V/H flips, hence use the
CameraSensor helpers to handle transformation requests from
applications.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-01-30 12:04:03 +01:00
Jacopo Mondi
6f6e1bf704 libcamera: camera_sensor: Apply flips at setFormat()
Augment the CameraSensor::setFormat() function to configure horizontal
and vertical flips before applying the image format on the sensor.

Applying flips before format is crucial as they might change the Bayer
pattern ordering.

To allow users of the CameraSensor class to specify a Transform,
add to the V4L2SubdeviceFormat class a 'transform' member, by
default initialized to Transform::Identity.

Moving the handling of H/V flips to the CameraSensor class allows to
remove quite some boilerplate code from the IPU3 and RaspberryPi
pipeline handlers.

No functional changes intended.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
2023-01-30 11:04:50 +01:00