Commit graph

200 commits

Author SHA1 Message Date
Jacopo Mondi
d150860129 android: camera_device: Return AE FPS range
The result metadata reports an arbitrary {30, 30} FPS range for the
AE algorithm.

The actual FPS range should be returned in the Request::metadata, but
as libcamera currently does not support that feature temporarily work
around the issue and return the FPS range requested by the camera
framework.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-03-09 08:57:53 +01:00
Jacopo Mondi
238fb27911 android: camera_device: Use AE FPS range in template
The request template returned by requestTemplatePreview() uses an
arbitrary {15, 30} Auto-Exposure algorithm FPS range. Use the one
calculated at static metadata creation time, which is consistent with
the camera limits.

Once template generation will be performed inspecting the requested
capture intent, the FPS range over which the AE algorithm can range
shall be tuned accordingly.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-03-09 08:57:36 +01:00
Jacopo Mondi
edd4b1dab2 android: camera_device: Compute frame durations
Use the FrameDuration control reported by pipeline handlers to register
the Auto-Exposure routine FPS range, the minimum stream frame durations
and the sensor maximum frame duration.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-03-09 08:57:09 +01:00
Laurent Pinchart
de1b994bba android: camera_device: Update gralloc usage flags for streams
When configuring streams, the camera HAL is supposed to update the
gralloc usage flags to reflect the operations it will need to do on the
stream buffers. Failure to do so leads to incorrect format selection by
gralloc for the HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED format, as
gralloc will not take into consideration the need of the camera to
access the buffers.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2021-03-05 22:22:47 +02:00
Jacopo Mondi
a725baf4b3 android: Move buffer mapping to CameraStream
The destination buffer for the post-processing component is
currently first mapped in the CameraDevice class and then passed
to CameraStream which simply calls the post-processor interface.

Move the mapping to CameraStream::process() to tie the buffer
mapping to the lifetime of the CameraBuffer instance.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-03-03 09:50:13 +01:00
Jacopo Mondi
d5473c9626 android: camera_device: Rename buffer fields
The buffers passed to the post processor are currently named 'buffer'
and 'mapped', names that do not convey their role.

Use 'src' and 'dest' instead.

Cosmetic change only.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-03-03 09:50:13 +01:00
Jacopo Mondi
64c17f73a0 android: Introduce CameraBuffer interface
In order to provide support for different memory backends,
move the MappedCamera3Buffer class definition outside of the
CameraDevice class to its own file and rename it in CameraBuffer.

The interface defined in camera_buffer.h will be implemented by
different backends that will be placed in the src/android/mm
subdirectory.

Provide a first implementation for the 'generic android' backend
which matches the existing one.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-03-03 09:50:12 +01:00
Paul Elder
3d39df27a7 android: camera_device: Set the camera location to Front if External
Our android HAL implementation currently does not support external
cameras, so if the camera location property is external, set it to
front.

This allows the following CTS test to pass:
- android.hardware.camera2.cts.CameraManagerTest#testCameraManagerGetDeviceIdList

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-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>
2021-02-24 19:38:50 +09:00
Jacopo Mondi
756fcbaaf2 android: camera_device: Calculate MAX_JPEG_SIZE
Calculate the JPEG maximum size using the maximum preview format size
multiplied by a 1.5 factor.

The same multiplication factor is used in the existing HAL
implementations in ChromeOS.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-02-08 11:04:21 +01:00
Jacopo Mondi
f29601efc4 android: camera_device: Report HOT_PIXEL_MAP_MODE as OFF
The CaptureResultTest#testCameraCaptureResultAllKeys enforces the
presence of the ANDROID_STATISTICS_HOT_PIXEL_MAP_MODE result
metadata.

Report ANDROID_STATISTICS_HOT_PIXEL_MAP_MODE_OFF as the Camera HAL
does not support the generation of an hot pixel correction map.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-02-05 13:25:30 +01:00
Jacopo Mondi
5360d807b4 android: camera_device: Report sensor test pattern mode
The CaptureResultTest#testCameraCaptureResultAllKeys enforces the
presence of the ANDROID_SENSOR_TEST_PATTERN_MODE result metadata.

Report the only supported value of ANDROID_SENSOR_TEST_PATTERN_MODE_OFF.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-02-05 13:24:22 +01:00
Jacopo Mondi
9690d082ec android: camera_device: Report AF_MODE_OFF in template
The CaptureResultTest#testCameraCaptureResultAllKeys CTS test
enforces the presence of the auto focus mode in the preview
request template.

Add the only supported mode AF_MODE_OFF in the generated template.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-02-05 13:08:01 +01:00
Jacopo Mondi
f266c0eb9c android: camera_device: Use AF_MODE_OFF in scene override
The camera HAL does currently list AF_MODE_OFF as the only supported
auto-focus mode in the ANDROID_CONTROL_AF_AVAILABLE_MODES static
metadata. For this reason reporting AF_MODE_AUTO as scene override
is wrong.

At the moment scene override is disabled in the Camera HAL, but this
is worth a fix nonetheless.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-02-05 13:07:05 +01:00
Jacopo Mondi
e9c2875aea android: camera_device: Report AE_EXPOSURE_COMPENSATION
The CaptureResultTest#testCameraCaptureResultAllKeys enforces the
presence of the ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION result
metadata.

Report 0 as the current value for
ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION in the result metadata
pack.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-02-05 13:06:45 +01:00
Jacopo Mondi
520c3664bc android: camera_device: Report COLOR_CORRECTION_ABERRATION_MODE
The CaptureResultTest#testCameraCaptureResultAllKeys enforces the
presence of the ANDROID_COLOR_CORRECTION_ABERRATION_MODE result
metadata.

Report the only supported value of
ANDROID_COLOR_CORRECTION_ABERRATION_MODE_OFF.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-02-05 13:03:36 +01:00
Jacopo Mondi
9e807050be android: camera_device: Generate JPEG thumbnail sizes
The list of the available thumbnail sizes is generated from the
list of available JPEG resolution, one for each aspect ratio.

This change fixes the CTS test
android.hardware.cts.CameraTest#testJpegThumbnailSize

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-02-04 18:21:18 +01:00
Jacopo Mondi
00982fbd25 android: camera_device: Fix wrong comment
Fix a wrong comment.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-02-04 18:20:01 +01:00
Jacopo Mondi
bc6440792b libcamera: Improve Request life cycle tracking
The current logging to track the status of a Request when running the
Android camera HAL provide the following information:

When a Request is queued to libcamera:
HAL camera_device.cpp:1776 '\_SB_.PCI0.I2C2.CAM0': Queueing Request to libcamera with 1 HAL streams

When a Request completes:
Request request.cpp:268 Request has completed - cookie: 138508601719648

The queueing of a Request reports the number of streams it contains
while the completion of a Request reports the address of the associated
cookie.

This makes very hard to keep track of what Requests have completed, as
the logging associated with a queue/complete event does not allow to identify
a Request easily.

Add two more printouts to make it easier to track a Request life cycle.
To make it possible to print the Request cookie in the CameraDevice
class add a method to access it from the CameraRequest class.

The result looks like the following trace:

Request request.cpp:92 Created request - cookie: 140701719392768
HAL camera_device.cpp:1710 '\_SB_.PCI0.I2C2.CAM0': Queueing request 140701719392768 with 1 streams
HAL camera_device.cpp:1747 '\_SB_.PCI0.I2C2.CAM0': 0 - (4160x3104)[0x00000023] -> (4160x3104)[NV12] (direct)
...
Request request.cpp:268 Request has completed - cookie: 140701719392768
HAL camera_device.cpp:1800 '\_SB_.PCI0.I2C2.CAM0': Request 140701719392768 completed with 1 streams..

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-02-02 18:50:03 +01:00
Jacopo Mondi
94d42ce014 android: camera_device: Use reference to settings
In preparation to use the keys part of a capture request to
fill in the result metadata, create a reference to
descriptor_->settings_.

While at it, move the 'ret' variable declaration to the beginning of
the function and rename it in 'found', as it will be used in many
places and move the \todo comment up as it applies to all metadata
whose value is copied from settings.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-02-02 13:09:51 +01:00
Jacopo Mondi
da4b325f41 android: camera_device: Add missing request keys
The Camera HAL does not report all the Request keys which are
mandatory for the advertised BACKWARD_COMPATIBLE capabilities
level. Add them.

This fixes the CTS test:
android.hardware.camera2.cts.StaticMetadataTest#testCapabilities

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-02-02 13:09:50 +01:00
Jacopo Mondi
6741ab8919 android: camera_device: Alphabetically sort keys
The vectors of available characteristics, request and result keys
are not sorted. This makes more complex than necessary spotting
duplication of keys.

Re-sort the vectors initializer lists alphabetically.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-02-02 13:09:50 +01:00
Paul Elder
78f49d5e34 android: camera_device: Fix exposure time tag in exif and android
The ExposureTime libcamera control is in microseconds while android and
our exif component use nanoseconds. Convert it appropriately.

CTS also expects the ExposureTime exif tag to match the ExposureTime set
in the android result metadata. Fix it.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2021-02-01 09:41:40 +09:00
Paul Elder
958c80a4f1 android: camera_device: Set AE precapture trigger according to request
Set the AE precapture triggler tag in the android result metadata
according to what was passed in the request metadata.

This allows the following CTS test to pass:
- android.hardware.camera2.cts.StillCaptureTest#testAePrecaptureTriggerCancelJpegCapture

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2021-01-29 19:30:19 +09:00
Paul Elder
a6de3f0203 android: camera_device: Cache request metadata
The settings in an android capture request may be null, in which case
the settings from the most recently submitted capture request should be
used. Cache the request settings to achieve this.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2021-01-27 12:07:17 +09:00
Paul Elder
1264628d3c android: jpeg: Configure thumbnailer based on request metadata
Configure the thumbnailer based on the thumbnail parameters given by the
android request metadata. Only the thumbnail encoder needs to be
configured, and since it is only used at post-processing time, move the
configuration out of the post-processor constructor and into the
processing step.

Also set the following android result metadata tags:
- ANDROID_JPEG_THUMBNAIL_SIZE
- ANDROID_JPEG_THUMBNAIL_QUALITY

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-01-27 12:07:14 +09:00
Paul Elder
abfabdd6e7 android: Set result metadata and EXIF fields based on request metadata
Set the following android result metadata:
- ANDROID_LENS_FOCAL_LENGTH
- ANDROID_LENS_APERTURE
- ANDROID_JPEG_GPS_TIMESTAMP
- ANDROID_JPEG_GPS_COORDINATES
- ANDROID_JPEG_GPS_PROCESSING_METHOD

And the following EXIF fields:
- GPSDatestamp
- GPSTimestamp
- GPSLocation
  - GPSLatitudeRef
  - GPSLatitude
  - GPSLongitudeRef
  - GPSLongitude
  - GPSAltitudeRef
  - GPSAltitude
- GPSProcessingMethod
- FocalLength
- ExposureTime
- FNumber
- ISO
- Flash
- WhiteBalance
- SubsecTime
- SubsecTimeOriginal
- SubsecTimeDigitized

Based on android request metadata.

This allows the following CTS tests to pass:
- android.hardware.camera2.cts.StillCaptureTest#testFocalLengths
- android.hardware.camera2.cts.StillCaptureTest#testJpegExif

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2021-01-27 12:07:08 +09:00
Paul Elder
229653a59b android: camera_device: Load make and model from platform settings
In ChromeOS the camera make and model is saved in
/var/cache/camera/camera.prop. Load and save these values at
construction time, if available.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2021-01-27 12:07:05 +09:00
Jacopo Mondi
3e979d7266 android: camera_device: Report the required dynamic metadata
The list of dynamic metadata reported by the Camera HAL is currently
very limited.

Augment the number of reported metadata in order to fix errors
reported by the android.hardware.camera2.cts.CaptureRequestTest test
module.

The test module still fails in 2 tests because of the missing
android.sensor.info.maxFrameDuration static metadata.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-01-25 15:20:36 +01:00
Jacopo Mondi
af088b88f5 android: camera_device: Support AWB_AUTO
Claim support for the AWB_AUTO mode in the
ANDROID_CONTROL_AWB_AVAILABLE_MODES static metadata.

This fixes the CTS test error:
android.hardware.camera2.cts.CaptureRequestTest#testAwbModeAndLock fail
The static info key 'android.control.awbAvailableModes'
All camera devices must support AUTO mode

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-01-25 15:20:36 +01:00
Jacopo Mondi
bb2b400638 android: camera_device: Handle SCALER_CROP_REGION
Handle the SCALER_CROP_REGION control and dynamic metadata by
translating it from the Android format to the associated libcamera
control when processing a request, and the other way around when
handling a request completion.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-01-25 15:20:36 +01:00
Jacopo Mondi
31a1a628cd android: camera_device: Register MAX_DIGITAL_ZOOM
Register the ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM static metadata
inspecting the ScalerCrop control's limits.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-01-25 15:20:36 +01:00
Jacopo Mondi
c9705a5e4b android: camera_device: Report EXPOSURE_TIME
Instead of reporting a fake value in the dynamic metadata for the
EXPOSURE_TIME control, use the value provided by the pipeline.

The metadata is only meaningfull in FULL mode.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-01-25 14:55:45 +01:00
Jacopo Mondi
753d7536b7 android: camera_device: Register EXPOSURE_TIME_RANGE
Register the EXPOSURE_TIME_RANGE static metadata inspecting the
ExposureTime control limits as reported by the camera.

If such information is not available, do not register the property.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-01-25 14:55:45 +01:00
Jacopo Mondi
9e6eece622 android: camera_device: Clone settings in request descriptor
When a Camera3RequestDescriptor instance is created to wrap a
camera3_capture_request_t the settings associated with the request
are cloned for later re-use.

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-01-22 10:37:33 +01:00
Jacopo Mondi
4b18b82c4f android: camera_device: Copy camera3 buffers in descriptor
The camera3_stream_buffer_t instances part of a capture request contain
information on the stream for which capture has been requested (size,
format and fences) and a handle to the stream's memory buffers.

This information is copied in the descriptor one piece at the time while
processing the camera3 streams to be re-used at request completion time.

Simplify the code by copying the stream information in the descriptor
at construction time.

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-01-22 10:36:09 +01:00
Jacopo Mondi
dd1cd532ca android: camera_device: Pass camera3 request to descriptor
The Camera3RequestDescriptor class can access the number of buffers
and the frame number from the camera3_capture_request_t instead of
having the caller passing them to the constructor.

This change allows to access other fields of the capture request, such
as the capture settings.

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-01-22 10:35:53 +01:00
Jacopo Mondi
cda41ff754 android: camera_device: Do not default pixel array properties
Now that the pixel array properties have been defaulted in the
CameraSensor class (or in the pipeline handler, for the UVC use case),
they will always be reported by the libcamera::Camera and there's no
need to default them in the Camera HAL.

Remove defaults and assume properties are always there.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-01-18 10:39:14 +01:00
Niklas Söderlund
35de31e027 android: camera_device: Only advertise RAW support if RAW16 is available
The Android camera2 API defines a RAW capture capability ([1]) for
devices that support "outputting RAW buffers and metadata for
interpreting them". This capability requires the camera device to
support RAW_SENSOR ([2]) as an output format. Despite what its name may
sound like, the RAW_SENSOR format is defined as a 16 bits RAW format,
not an opaque implementation-dependent format (which is instead called
RAW_PRIVATE). Devices may additionally support the RAW10 and RAW12
formats, but that isn't enough to claim RAW capture capability.

To comply with the API requirements, only report the
ANDROID_REQUEST_AVAILABLE_CAPABILITIES_RAW capability when 16-bit RAW is
supported.

[1] https://developer.android.com/reference/android/hardware/camera2/CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_RAW
[2] https://developer.android.com/reference/android/graphics/ImageFormat#RAW_SENSOR

Suggested-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Tested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-01-04 13:35:05 +01:00
Jacopo Mondi
0ed0532457 android: camera_device: Simplify properties.get()
When accessing the value of a property by reading the properties
ControlList content with ControlList::get<>() it is not necessary to
specify the template type as it is already conveyed by the Control
instance provided as first argument.

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-12-30 11:22:53 +01:00
Jacopo Mondi
cb35ed23f3 android: camera_device: Report ColorFilterArrangement
Conditionally report the ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT
property inspecting the draft property reported by the libcamera Camera.

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-12-30 11:22:52 +01:00
Jacopo Mondi
eec6c54134 android: camera_device: Report number of out streams
Report the number of supported output streams through the
ANDROID_REQUEST_MAX_NUM_OUTPUT_STREAMS static metadata.

The camera HAL currently supports:
- 1 optional RAW stream
- 2 YUV streams
- 1 JPEG stream

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-12-18 17:48:49 +01:00
Jacopo Mondi
3535e0c104 android: camera_device: Report pipeline depth
Report the pipeline depth in the capture results if the pipeline
reports it.

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-12-18 17:48:31 +01:00
Laurent Pinchart
bd4894d259 android: camera_device: Replace auto with explicit type
The auto keyword facilitates writing code. It avoids typing out very
long types, which can make the code more readable, but it can also have
a negative impact on readability as it requires the reader (including
reviewers) to look up the type of the variable.

Replace one occurrence of auto with the explicit type where doing so
doesn't require a long type name.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2020-12-14 15:35:03 +02:00
Jacopo Mondi
008f2a55d1 android: camera_device: Temporary fix sensor properties
The ChromeOS camera service, which is the current main user of the
Android Camera HAL, fails to start if the pixel array properties are
not registered.

As the sensor driver for the Soraka test device have not yet been
updated to report their pixel array properties through the V4L2
selection API, temporary fix the gap by re-establishing the default
properties values removed by commit 1889cdc2e9 ("android: camera_device:
Initialize pixel array properties")

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-12-14 08:39:03 +01:00
Hirokazu Honda
26d90af082 android: camera_device: Reorder configurations before requesting
This reorders Camera3Configs before executing
CameraConfiguration::validate() to make it easier for the Camera
to satisfy the Android framework request.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Umang Jain <email@uajain.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Add blank line and fix compilation on gcc 7.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-12-11 15:10:49 +02:00
Hirokazu Honda
2bc6ba2e1f android: camera_device: Use Camera3StreamConfig in configureStreams()
Use the newly introduced Camera3StreamConfig to associate the
Android requested streams with the associated StreamConfiguration
in a vector of configurations.

This change prepares to sort the vector of configuration before using
it to configure the Camera and populate the streams_ vector.

No functional changes intended.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Umang Jain <email@uajain.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-12-11 14:13:38 +02:00
Hirokazu Honda
c2df74364f android: camera_device: Introduce Camera3StreamConfig
Camera3StreamConfig is a new class to store camera3_stream and
types with associated StreamConfiguration.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Umang Jain <email@uajain.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-12-11 14:12:35 +02:00
Jacopo Mondi
8fed613562 android: camera_device: Stop camera when re-configuring it
The Android camera device HAL3 specification does not require a
camera to go through any explicit close() call between configurations.
It is legitimate for a camera to be configured, a number of requests
processed and then re-configured again without any explicit stop.

The libcamera Android camera HAL starts the Camera at the first handled
request, and only stops it at camera close time. This means that two
camera configuration attempts in the same streaming session are only
interleaved by capture requests handling.

The libcamera::Camera state machine requires the Camera to be stopped
before any configuration take place, and this currently doesn't happen.

Fix this by stopping the camera and the associated worker thread if
a configuration attempt is performed while the Camera is in running
state.

This patch fixes cros_camera_test:
Camera3PreviewTest/Camera3SinglePreviewTest.Camera3BasicPreviewTest/0

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-12-07 14:26:42 +01:00
Jacopo Mondi
1889cdc2e9 android: camera_device: Initialize pixel array properties
Initialize pixel array properties in the Android camera HAL
inspecting the camera properties.

If the camera does not provide any suitable property, not static
metadata is registered to the Android framework.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-12-07 14:26:33 +01:00
Jacopo Mondi
c5b732b2ca android: camera_device: Check capture_request validity
Make sure the 'camera3_capture_request_t *' provided to
CameraDevice::processCaptureRequest() is valid before attempting to
access it.

This patch fixes cros_camera_test:
Camera3FrameTest/Camera3InvalidRequestTest.NullOrUnconfiguredRequest/*

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