Commit graph

1699 commits

Author SHA1 Message Date
Niklas Söderlund
3d4b7b0059 libcamera: delayed_controls: Add helper for controls that apply with a delay
Some sensor controls take effect with a delay as the sensor needs time
to adjust, for example exposure. Add an optional helper DelayedControls
to help pipelines deal with such controls.

The idea is to provide a queue of controls towards the V4L2 device and
apply individual controls with the specified delay with the aim to get
predictable and retrievable control values for any given frame. To do
this the queue of controls needs to be at least as deep as the control
with the largest delay.

The DelayedControls needs to be informed of every start of exposure.
This can be emulated but the helper is designed to be used with this
event being provide by the kernel through V4L2 events.

This helper is based on StaggeredCtrl from the Raspberry Pi pipeline
handler but expands on its API. This helpers aims to replace the
Raspberry Pi implementations and mimics it behavior perfectly.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
2021-01-29 15:35:28 +01: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
ab72e6641c android: jpeg: Set thumbnail and JPEG quality based on request
Set the thumbnail quality and the JPEG quality based on the android
request metadata.

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:21 +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
Paul Elder
3a3f6ae22e android: jpeg: exif: Add functions for setting various values
Add functions for setting the following EXIF fields:

- GPSDatestamp
- GPSTimestamp
- GPSLocation
  - GPSLatitudeRef
  - GPSLatitude
  - GPSLongitudeRef
  - GPSLongitude
  - GPSAltitudeRef
  - GPSAltitude
- GPSProcessingMethod
- FocalLength
- ExposureTime
- FNumber
- ISO
- Flash
- WhiteBalance
- SubsecTime
- SubsecTimeOriginal
- SubsecTimeDigitized

These are in preparation for fixing the following CTS tests:

- 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:06:59 +09:00
Paul Elder
e5b6774422 android: jpeg: exif: Fix setOrientation EXIF values
The input to setOrientation is angle clockwise from the sensor
orientation, while the EXIF output values were swapped for 90
and 270 degrees.

From the EXIF spec:

6 = The 0th row is the visual right-hand side of the image, and the
    0th column is the visual top.
8 = The 0th row is the visual left-hand side of the image, and the
    0th column is the visual bottom.

6 should be 90 degrees clockwise, while 8 should 270 degrees clockwise.
Fix this.

As Android defines the rotation as the clockwise angle by which the
image needs to be rotated to appear in the correct orientation on the
device screen, the previous values would be correct if the input angle
was from the camera orientation. Since the correct input should be the
requested JPEG orientation, these new values are the correct ones.

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:06:55 +09:00
Paul Elder
d81e26d360 android: jpeg: exif: Expand setString to support different encodings
GPSProcessingMethod and UserComment in EXIF tags can be in UTF-16.
Expand setString to take an encoding when the field type is undefined.
Update callers accordingly.

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:06:51 +09:00
David Plowman
a258aa4615 ipa: raspberrypi: Remove legacy Rasberry Pi logging
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-01-26 10:46:12 +02:00
David Plowman
d97b1bcd2a ipa: raspberrypi: Replace Raspberry Pi debug with libcamera debug
This commit deals with all the "small" algorithms (that is, not
Agc/Awb/Alsc). A few unnecessary debug messages have also been
removed.

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-01-26 10:46:10 +02:00
David Plowman
eb605eab5b ipa: raspberrypi: awb: Replace Raspberry Pi debug with libcamera debug
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-01-26 10:46:07 +02:00
David Plowman
b2186c2b89 ipa: raspberrypi: alsc: Replace Raspberry Pi debug with libcamera debug
Some unhelpful debug messages have been removed.

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-01-26 10:46:06 +02:00
David Plowman
15d3970c0c ipa: raspberrypi: controller: Replace Raspberry Pi debug with libcamera debug
Some unhelpful debug statements have been removed.

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-01-26 10:45:58 +02: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
953403288e libcamera: ipu3: Report ScalerCrop in metadata
Report in the Request metadata the scaler crop region as requested by
application through the request controls. No actual scaling is applied
in the pipeline at the moment.

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
2cd841491e libcamera: ipu3: Register ScalerCrop control
Register the ScalerCrop control in the ImgU pipeline handler computed
by using the Viewfinder [1280x720] pipeline output configuration and
the sensor resolution as parameters.

The ScalerCrop control limits should be updated every time a new
configuration is applied to the sensor.

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
bc79e06531 libcamera: ipu3: Register Exposure control
Calculate the controls::Exposure limits at camera registration time
and register it in the list of camera supported controls.

Cache the default exposure value to report it in the request metadata.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-01-25 14:55:43 +01:00
Jacopo Mondi
021752924b libcamera: camera_sensor: Make V4L2_CID_EXPOSURE mandatory
Add the V4L2_CID_EXPOSURE control to the list of mandatory controls the
sensor driver has to report and document this new requirement.

While at it, re-sort the mandatory V4L2 controls in alphabetical
order in the CameraSensor class and remove the above comment as
the usage of the controls is better reported in the documentation.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-01-25 14:54:04 +01:00
Jacopo Mondi
db19dcb75d libcamera: CameraSensor: Mention V4L2 in get/setControls()
The current CameraSensor interface for reading and writing controls
is currently based on V4L2 controls.

Mention that more clearly in the documentation and, while at it, re-sort
the documentation to match the methods declaration order.

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 14:53:16 +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
b9369a0e60 android: camera_metadata: Add defaul constructor
Add a default constructor that initializes a non valid CameraMetadata
to allow embedding instances of the class in other types.

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:07 +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
Paul Elder
5e2596006b android: camera_metadata: Add copy constructor and getEntry
Add a copy constructor and assignment operator to CameraMetadata, as well
a constructor from camera_metadata_t. Also add a function getEntry to
allow getting metadata entries from CameraMetadata. This allows us to
use CameraMetadata for reading from camera_metadata_t.

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-01-22 10:35:28 +01:00
Naushir Patuck
7b4ed981c7 ipa: raspberrypi: config: Update shutter speeds for imx219/477 and ov5647
Set the maximum shutter speed for the normal exposure profile to 66ms,
allowing viewfinder framerates to go down to approx. 15fps.

Set the maximum shutter speed for the sport exposure profile to 33ms,
limiting the minimum framerate to approx. 30fps.

Add a long exposure profile to allow shutter speeds of up to 120ms.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Tested-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-01-20 14:13:51 +02:00
Naushir Patuck
92b8ccc42a libcamera: raspberrypi: Add control of sensor vblanking
Add support for setting V4L2_CID_VBLANK appropriately when setting
V4L2_CID_EXPOSURE. This will allow adaptive framerates during
viewfinder use cases (e.g. when the exposure time goes above 33ms, we
can reduce the framerate to lower than 30fps).

The minimum and maximum frame durations are provided via libcamera
controls, and will prioritise exposure time limits over any AGC request.

V4L2_CID_VBLANK is controlled through the staggered writer, just like
the exposure and gain controls.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Tested-by: David Plowman <david.plowman@raspberrypi.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-01-20 14:13:50 +02:00
Naushir Patuck
6232ec3c16 libcamera: controls: Add frame duration control
Add an int64_t array control (controls::FrameDurations) to specify the
minimum and maximum (in that order) frame duration to be used by the
camera sensor.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Tested-by: David Plowman <david.plowman@raspberrypi.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-01-20 14:13:50 +02: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
Jacopo Mondi
db6a3bfa6e libcamera: camera_sensor: Initialize VIMC properties
The VIMC driver does not yet support all the features required
for all sensor drivers. As it is the main testing platforms and the
driver changes might take a long time to land in the developments
and testing platforms, temporary close the gap by skipping driver
validation and initializing properties with static information such
as the sensor resolution.

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
Jacopo Mondi
a1a20998ac libcamera: media_object: Add a const version of dev()
Add a const version of the MediaObject::dev() method to be able to
retrieve a pointer to a const MediaDevice from a constant instance of
a MediaObject sub-class.

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
Jacopo Mondi
89b495c054 libcamera: uvc: Initialize the pixel array properties
Initialize the pixel array properties in the UVC pipeline handler as
they're now initialized in the CameraSensor class, which the UVC
pipeline handler does not use.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-01-18 10:39:14 +01:00
Jacopo Mondi
c35123e6f9 libcamera: camera_sensor: Do not default 'rotation'
The 'rotation' property is not critical. Only register it if the
sensor driver reports it.

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
Jacopo Mondi
87ceac9c8c libcamera: camera_sensor: Default 'location' to External
If the sensor driver does not report the camera location default it
to 'External' instead of 'Front'.

As the camera location is used to construct the camera unique name
presented to the user, it makes more sense to report multiple 'External'
cameras instead of multiple 'Front' ones.

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:13 +01:00
Jacopo Mondi
8deb7e4331 libcamera: camera_sensor: Default analogue crop rectangle
As support for the V4L2_SEL_TGT_CROP selection target used to read the
sensor analogue crop rectangle is schedule to become mandatory but is
still optional, use the sensor's active area size as fallback value to
allow the creation of the CameraSensorInfo in the case the driver does
not support it.

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:13 +01:00
Jacopo Mondi
125ee6ddd6 libcamera: camera_sensor: Provide fall-back for sensor properties
Support for the V4L2 selection API is currently optional in the
CameraSensor class. Properties registered by using values read through
that API are defaulted in several different places (the Android camera
HAL or the CameraSensor class).

In the future support for the selection API will be made mandatory, but to
give time to sensor drivers in all test platforms to be updated, use
sensor resolution as fallback values for sensor pixel array properties
and cache them as class member variables.

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-18 10:39:13 +01:00
Jacopo Mondi
8502d4c52d libcamera: camera_sensor: Validate driver support
The CameraSensor class requires the sensor driver to report
information through V4L2 controls and through the V4L2 selection API,
and uses that information to register Camera properties and to
construct CameraSensorInfo class instances to provide them to the IPA.

Currently, validation of the kernel support happens each time a
feature is requested, with slighly similar debug/error messages
output to the user in case a feature is not supported.

Rationalize this by validating the sensor driver requirements in a
single function

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-01-18 10:39:13 +01:00
Niklas Söderlund
7415c139cd libcamera: sysfs: Fix directory exists check
The scope of File::exists() was changed to only validate that a file
exists and is therefore not usable to check if a directory exists. This
breaks the persistent name generation for DT based systems as it uses
File::exists() to check for directories, fix this by using stat()
directly.

On Scarlet the persistent names of the cameras are impacted by this and
where incorrectly reported as:

    $ cam -l
    Available cameras:
    1: Internal front camera (platform/ff160000.i2c/i2c-7/7-003c ov2685)
    2: Internal front camera (platform/ff160000.i2c/i2c-7/7-0036 ov5695

While the expected ones are restored with this fix:

    $ cam -l
    Available cameras:
    1: Internal front camera (/base/i2c@ff160000/camera@3c)
    2: Internal front camera (/base/i2c@ff160000/camera@36)

Fixes: 8f4e16f014 ("test: file: Check that directories are not treated as files")
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-01-13 13:20:06 +01:00
Umang Jain
44058f1c68 libcamera: pipelines: ipu3: Simplify error bail out path on start()
On the bail out path, always ensure that ImgU and CIO2 are stopped
before freeing the buffers. V4L2VideoDevice class guarantees that
calling stop() without having to call start() is harmless, hence use
this guarantee to simplify error paths.

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>
2021-01-12 14:07:58 +00:00
Kieran Bingham
c0bad607ce libcamera: v4l2_videodevice: Track streaming state
Track the state of streamon/streamoff calls to simplify error paths.

Ensuring that streamOff() can be called on non-streaming streams
facilitates simpler error code paths, where a set of devices can all
call streamOff regardless of their initialisation state.

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: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-01-12 14:06:56 +00:00
Sebastian Fricke
5988661c90 libcamera: camera: Fix-typo
s/chance/change/

Signed-off-by: Sebastian Fricke <sebastian.fricke.linux@gmail.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>
2021-01-05 06:19:04 +00: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
Kieran Bingham
0e6cd15b06 src: meson: Simplify v4l2 enablement
Simplify the src level meson file by moving the declaration of the v4l2
subdir to match the other invocations, making use of 'subdir_done()' to
break out if the adaptation layer is not enabled.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-12-30 15:31:53 +00:00
Kieran Bingham
85f01678a0 src: meson: Re-order subdir layout
Move the android subdir below the configuration options to keep all
subdirs together.

Add a comment explaining why android must come first, and some padding
to group the libcamera and ipa components, applications, and remaining
adaptation layers.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-12-30 15:31:49 +00:00