Commit graph

76 commits

Author SHA1 Message Date
Jacopo Mondi
94c4d49ebe android: camera_stream: Add CameraStream::Type
Define the CameraStream::Type enumeration and assign it to
each CameraStream instance at construction time.

The CameraStream type will be used to decide if memory needs to be
allocated on its behalf or if the stream is backed by memory externally
allocated by the Android framework.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-10-07 16:07:44 +02:00
Jacopo Mondi
5cf64b26a2 android: camera_stream: Break out CameraStream
Break CameraStream out of the CameraDevice class.

No functional changes, only the code is moved.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-10-07 16:07:43 +02:00
Niklas Söderlund
dbe8d271e7 libcamera: stream: Rename StillCaptureRaw to Raw
With the buffer copy removed from all pipelines for raw capture
rename StillCaptureRaw to Raw to better describe the role.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2020-09-30 14:01:01 +02:00
Jacopo Mondi
45fe8e99c8 android: camera_device: Make CameraStream a class
Complete the transformation of CameraStream into a class and provide
a read-only interface that allows to access its parameters but not
modify them at run-time.

No functional changes intended but this change aims to make the code
more robust by enforcing a stricter interface in the CameraStream class.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-09-18 11:31:56 +02:00
Jacopo Mondi
facadb188e android: camera_device: Set Encoder at construction
Make the CameraStream encoder a private unique pointer and require its
initialization at construction time. This ties the encoder lifetime to
the CameraStream it has been created with, allowing to remove the
CameraStream destructor.

This change dis-allow creating a CameraStream and set the Encoder later,
which shall not happen now that we create CameraStream once we have all
the required information in place.

No functional changes intended but this change aims to make the code
more robust enforcing a stricter CameraStream interface.

Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-09-18 11:31:56 +02:00
Jacopo Mondi
c82f944399 android: camera_device: Rework CameraStream handling
The CameraDevice::streams_ vector of CameraStream instances is
currently mostly accessed by index. The current implementation
creates all the CameraStream during the first loop that inspects the
camera3_stream instances and then update the index of the
StreamConfiguration associated with the CameraStream during a second
loop that inspects MJPEG streams. A third loop creates the JPEG encoder
associated with camera streams that produce MJPEG format.

As the index-based association is hard to follow and rather fragile,
rework the creation and handling of CameraStream:

1) Make the StreamConfiguration index a constructor parameter and a
   private struct member. This disallows the creation of CameraStream
   without a StreamConfiguration index assigned.

2) Create CameraStream only after the associated StreamConfiguration
   has been identified. The first loop creates CameraStream for non-JPEG
   streams, the second for the JPEG ones after having identified the
   associated StreamConfiguration. Since we have just created the
   CameraStream, create the JPEG encoder at the same time instead of
   deferring it.

This change removes all accesses by index to the CameraDevice::streams_
vector.

No functional changes intended, but this change aims to make the code
easier to follow and more robust.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-09-18 11:31:56 +02:00
Jacopo Mondi
f868f08c21 android: camera_device: Use Android format
When iterating the camera3_stream_t received from the Android camera
framework to identify the MJPEG streams, the format check was performed
on the CameraStream created when iterating the non-MJPEG streams and not
on the format actually requested by Android. As the next patches will
remove the creation of CameraStream instances for MJPEG streams, use the
camera3_stream format to prepare for that.

Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-09-18 11:31:56 +02:00
Jacopo Mondi
5b64f64745 android: camera_device: Get rid of stream counter
Use the size() method of the CameraConfiguration class to retrieve the
index of the StreamConfiguration associated with a CameraStream and get
rid of the custom counter.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-09-18 11:31:56 +02:00
Jacopo Mondi
4961033ac9 android: camera_device: Generate RAW resolutions
The resolutions supported for the RAW formats cannot be tested from
a list of known sizes like the processed ones. This is mainly due to the
fact RAW streams are produced by capturing frames at the CSI-2 receiver
output and their size corresponds to the sensor's native sizes.

In order to obtain the RAW frame size generate a temporary
CameraConfiguration for the Role::StillCaptureRAW role and inspect the
map of StreamFormats returned by the pipeline handler.

Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-09-18 11:31:55 +02:00
Jacopo Mondi
bfee6316fc android: camera_device: Break out size calculation
As the RAW stream sizes needs to be calculated differently from the
processed one, break out the procedure to calculate the processed
(RGB/YUV) resolutions from initializeStreamConfigurations() in order to
prepare for RAW sizes calculation.

Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-09-18 11:31:55 +02:00
Jacopo Mondi
af264ec750 android: camera_device: Add debug to stream initialization
Add debug printouts to the CameraDevice::initializeStreamConfigurations()
function that help to follow the process of building the stream
configurations map.

Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-09-18 11:31:55 +02:00
Jacopo Mondi
843565c6ec android: camera_device: Generate JPEG sizes
When producing the list of image resolutions to claim as supported by the
camera HAL, the JPEG stream was assumed to be 'always valid' as, at the
time, there was no JPEG support in place at all.

With the introduction of support for JPEG compression, reporting
non-valid sizes as supported obviously causes troubles.

In order to avoid reporting non-supported resolutions as supported,
produce the list of available JPEG sizes by using the ones supported
by the YCbCr_420_888 format, from which the JPEG stream is encoded.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-09-18 11:31:55 +02:00
Jacopo Mondi
3533fd4271 android: camera_device: Refuse unsupported formats
The current implementation of CameraDevice::initializeStreamConfigurations()
fails if an image format marked as mandatory is not supported by the
libcamera::Camera device, but erroneously accepts non-mandatory
non-supported formats in the list of accepted ones.

Fix this by ignoring non supported image formats which are not marked as
mandatory.

Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-09-18 11:31:55 +02:00
Umang Jain
6f09a619cc android: jpeg: Support an initial set of EXIF metadata tags
Create a Exif object with various metadata tags set, just before
the encoder starts to encode the frame. The object is passed
directly as libcamera::Span<> to make sure EXIF tags can be set
in a single place i.e. in CameraDevice and the encoder only has
the job to write the data in the final output.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Umang Jain <email@uajain.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>
2020-09-10 07:12:47 +03:00
Umang Jain
e917655d06 android: camera_device: Fix value of orientation metadata
Android's orientation metadata cannot have identical numerical
value to libcamera's rotation property. This is due to the fact
that libcamera's rotation property specifies the correction angle
in anticlockwise direction whereas Android's orientation metadata
specifies the value in clockwise direction. Fix that by computing
corresponding value for clockwise direction from libcamera's rotation
property.

Signed-off-by: Umang Jain <email@uajain.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-09-10 07:12:46 +03:00
Jacopo Mondi
9ac8f3e96f android: camera_device: Fix spelling in comment
Just a small spelling fix: s/re-allcoation/reallocation

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-09-08 14:48:16 +02:00
Laurent Pinchart
dbafe16da7 meson: Remove -Wno-unused-parameter
We build libcamera with -Wno-unused-parameter and this doesn't cause
much issue internally. However, it prevents catching unused parameters
in inline functions defined in public headers. This can lead to
compilation warnings for applications compiled without
-Wno-unused-parameter.

To catch those issues, remove -Wno-unused-parameter and fix all the
related warnings with [[maybe_unused]].

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-08-25 02:58:04 +03:00
Umang Jain
f8e2813ffe android: camera_device: Make CameraDevice a shared object
CameraDevice needs to be wrapper into the std::shared_ptr instead
of std::unique_ptr to enable refcounting. The refcounting will help
us to support hotplug and hot-unplug CameraHalManager operations
in the subsequent commit.

Signed-off-by: Umang Jain <email@uajain.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-08-23 20:46:08 +03:00
Niklas Söderlund
dac8e9552c libcamera: request: Declare a using directive for map of buffers
Declare a using directive for the map of Stream to FrameBuffer. Update
all users of Request::buffers() to use the new usage directive.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-08-14 13:19:15 +02:00
Kieran Bingham
83ae84eb13 android: camera_device: Support MJPEG stream construction
MJPEG streams must be created referencing a libcamera stream.
This stream may already be provided by the request configuration,
in which case the existing stream is utilised.

If no compatible stream is available to encode, a new stream is requested
from the libcamera configuration.

Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-08-06 15:46:25 +01:00
Kieran Bingham
c09aee4ccb android: camera_device: Generate ResultMetadata earlier
Generate the ResultMetadata before performing JPEG compression so that
JPEG specific metadata can be added to the metadata when it has been
processed.

Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-08-06 15:44:02 +01:00
Kieran Bingham
9f07aebde8 android: camera_device: Report configuration changes from validate()
When we call validate on a configuration, if there are any adjustments
on the configuration, we fail without showing why.

Display the stream configuration after the validate stage to aid
debugging stream startup failures.

Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-08-06 15:44:02 +01:00
Kieran Bingham
6bc652ee1c android: camera_device: Query plane length
Use lseek to query the length of planes where possible rather than leaving
the plane.length as zero, which prevents mapping buffers for software
processing.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-08-06 15:44:02 +01:00
Kieran Bingham
f4c65be7b3 android: camera_device: Only construct required planes
The camera3buffer describes the number of filedescriptors given.
Don't try to construct more planes than that.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-08-06 15:44:02 +01:00
Kieran Bingham
8ad1b9ca22 android: camera_device: Report an error in notifyError()
If an error is generated, try to be verbose about it in the libcamera logs.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-08-06 15:44:01 +01:00
Kieran Bingham
98986e0b57 android: camera_device: Fix trivial spelling
Fix the spelling of 'successfully' reported in an error message.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-08-06 15:44:01 +01:00
Umang Jain
035ee23910 android: camera_device: Initialize 'id_' field in constructor
A 'id' is passed when a new CameraDevice is constructed in order for
unique identification. Failing to initialize it,  will lead to the
issue of garbage return value via CameraDevice::id().

Signed-off-by: Umang Jain <email@uajain.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>
2020-08-06 12:57:06 +01:00
Niklas Söderlund
2e7c80a4f9 libcamera: camera: Rename name() to id()
Rename Camera::name() to camera::id() to better describe what it
represents, a unique and stable ID for the camera. While at it improve
the documentation for the camera ID to describe it needs to be stable
for a camera between resets of the system.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-08-05 20:07:13 +02:00
Jacopo Mondi
09b1d0fced android: camera_device: Fix preview template
Add 5 controls to the generate preview template to comply with the
camera3 specification.

This change fixes CTS 9.0.r12 test:
android.hardware.camera2.cts.CameraDeviceTest#testCameraDevicePreviewTemplate

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-05 14:36:44 +02:00
Jacopo Mondi
8a02d4451c android: camera_device: Break-out request template
Currently the request template returned from
CameraDevice::constructDefaultRequestSettings() is the same for all
the supported template types.

To prepare to adjust the template depending on the use case, break out
the template generation to a dedicated function that supports the
PREVIEW use case. All the other template types use the
requestTemplatePreview() function and just update the capture intent
property.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-05 14:33:52 +02:00
Niklas Söderlund
7876d631d9 android: camera_device: Report RAW capability if supported
Probe the libcamera Camera for RAW support and if supported report RAW
capability in the static metadata reported to Android.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-03 23:44:09 +02:00
Niklas Söderlund
d4de037a8a android: camera_device: Map HAL RAW to libcamera RAW formats
Add a mapping from HAL RAW formats to the direct equivalent of libcamera
formats. With this change it is possible to capture RAW images as long
as the hardware can deliver frames in a format that is native to the
HAL.

More work is needed to deal with unpacked 8, 10 and 12 RAW formats as
they don't directly map to a native HAL format. Nor do they belong in
the RAW_OPAQUE category as the content format is generic and not
uncommonly supported by hardware.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-08-03 23:44:09 +02:00
Niklas Söderlund
8c1fedcb78 android: camera_device: Prepare for non-mandatory formats
When probing what formats a libcamera Camera supports we want to allow
to probe for non-mandatory formats. Add a new flag to indicate if a
format in camera3FormatsMap is mandatory or not.

All current defined formats are mandatory.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-08-03 23:44:09 +02:00
Niklas Söderlund
a2a6f95bff android: camera_device: Add ANDROID_REQUEST_MAX_NUM_INPUT_STREAMS
Define the ANDROID_REQUEST_MAX_NUM_INPUT_STREAMS to zero to inform users
the HAL does not support any reprocessing.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-07-24 19:03:52 +02:00
Niklas Söderlund
3312af649a android: camera_device: Remove scaler format information from Camera3Format
The scaler format information was only used for the
ANDROID_SCALER_AVAILABLE_FORMATS tag which is deprecated and removed. As
it has no other users remove it.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-07-24 19:03:52 +02:00
Niklas Söderlund
142a9ee3f8 android: camera_device: Use HAL_PIXEL_FORMAT_* defines for formats
The documentation says the HAL_PIXEL_FORMAT_* defines shall be used for
formats instead of ANDROID_SCALER_AVAILABLE_FORMATS_* for the
ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS and
ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS tags.

This have worked in the past as the numerical value of the two sets are
the same for the formats supported.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-07-24 19:03:52 +02:00
Niklas Söderlund
3530614fbf android: camera_device: Remove ANDROID_SCALER_AVAILABLE_FORMATS
According to the documentation the tag
ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS deprecates the
ANDROID_SCALER_AVAILABLE_FORMATS tag. As the HAL implements both tags
remove the deprecated one.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-07-24 19:03:52 +02:00
Kieran Bingham
61f4296ac7 android: camera_device: Remove single buffer restriction.
A capture request is no longer limited to a single output buffer.
Remove the limitation, but (for now) keep the check to ensure that
at least one buffer is always provided.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2020-07-07 11:50:51 +01:00
Kieran Bingham
0cfdf737dc android: camera_device: Add buffers for each stream to Requests
Construct a FrameBuffer for every buffer given in the camera3Request
and add it to the libcamera Request on the appropriate stream.

The correct stream is obtained from the private data of the camera3_stream
associated with the camera3_buffer.

Comments regarding supporting only one buffer are now removed, and
FrameBuffers have their lifetime tracked in the Camera3RequestDescriptor
to ensure they are released when the Request is completed.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2020-07-07 11:50:51 +01:00
Kieran Bingham
2f34f5ef06 android: camera_device: Maintain a vector of CameraStream
Introduce a vector storing a CameraStream to track and maintain
state between an Android stream (camera3_stream_t) and a libcamera
Stream.

Only the index of the libcamera stream is stored, to facilitate identifying
the correct index for both the StreamConfiguration and Stream vectors.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2020-07-06 23:58:42 +01:00
Kieran Bingham
eac0542c5e android: camera_device: Create the Request and Camera3RequestDescriptor together
Move the construction of the Request higher in the code flow so that
multiple buffers and streams can be added where required.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2020-07-06 23:58:42 +01:00
Kieran Bingham
74ab442dcf android: camera_device: Simplify FrameBuffer construction from a buffer_handle_t
Move the code which constructs a FrameBuffer from the Android buffer handle
to it's own function to simplify the code flow and readability.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2020-07-06 23:58:42 +01:00
Kieran Bingham
0a9244ed37 android: camera_device: Support multiple stream configurations
Create an initial Camera Configuration using an empty role set, and
populate the StreamConfigurations manually from each of the streams
given by the Android camera3_stream_configuration_t stream_list.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2020-07-06 23:58:42 +01:00
Kieran Bingham
43e3b8002b android: camera_device: Provide a toPixelFormat helper
Rather than converting pixelformats through the map, and then
dereferencing the iterator later, create a helper to explicitly return a
PixelFormat type.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2020-07-06 23:58:42 +01:00
Laurent Pinchart
8b7e073e6e libcamera: Replace explicit DRM FourCCs with libcamera formats
Use the new pixel format constants to replace usage of macros from
drm_fourcc.h.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-06-18 13:26:58 +03:00
Laurent Pinchart
7a88b212e0 android: camera_device: Use std::make_tuple()
Until N4387 (https://wg21.link/N4387, applied as a defect report for
C++11), a function could not return a tuple using
copy-list-initialization. This affects gcc-5 that was released before
N4387 was integrated, and causes a compilation error:

../../src/android/camera_device.cpp: In member function ‘std::tuple<unsigned int, unsigned int> CameraDevice::calculateStaticMetadataSize()’:
../../src/android/camera_device.cpp:391:32: error: converting to ‘std::tuple<unsigned int, unsigned int>’ from initializer list would use explicit constructor ‘constexpr std::tuple<_T1, _T2>::tuple(_U1&&, _U2&&) [with _U1 = unsigned int&; _U2 = unsigned int&; <template-parameter-2-3> = void; _T1 = unsigned int; _T2 = unsigned int]’
  return { numEntries, byteSize };

Fix it by using std::make_tuple().

Fixes: a80d38109f ("android: camera_device: Calculate metadata size")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-06-10 16:48:08 +03:00
Jacopo Mondi
82d9331efd android: camera_device: Translate Android format
Translate the Android format code to the libcamera format code
at stream configuration time, using the translation map built at
camera device initialization time.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-06-08 23:01:55 +02:00
Jacopo Mondi
bde7b98cac android: camera_device: Replace hardcoded stream configuration
Replace the hardcoded stream configuration map with the information
collected at CameraDevice initialization time.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-06-08 23:01:54 +02:00
Jacopo Mondi
a80d38109f android: camera_device: Calculate metadata size
As we move to have more and more dynamically generated static metadata
entries, the size of the metadata buffer has to be calculated
dynamically inspecting the information collected from the camera.

Provide a method to perform metadata buffers size calculation and
use it when generating camera static metadata.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-06-08 23:01:54 +02:00
Jacopo Mondi
117588b371 android: camera_device: Initialize stream configuration
Initialize the stream configuration map by applying the Android Camera3
requested resolutions and formats to the libcamera Camera device.

For each required format test a list of required and optional
resolutions, construct a map to translate from Android format to the
libcamera formats and store the available stream configuration to
be provided to the Android framework through static metadata.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-06-08 23:01:54 +02:00