summaryrefslogtreecommitdiff
path: root/src/android/camera_device.cpp
AgeCommit message (Collapse)Author
2021-01-18android: camera_device: Do not default pixel array propertiesJacopo Mondi
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-04android: camera_device: Only advertise RAW support if RAW16 is availableNiklas Söderlund
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>
2020-12-30android: camera_device: Simplify properties.get()Jacopo Mondi
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-30android: camera_device: Report ColorFilterArrangementJacopo Mondi
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-18android: camera_device: Report number of out streamsJacopo Mondi
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-18android: camera_device: Report pipeline depthJacopo Mondi
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-14android: camera_device: Replace auto with explicit typeLaurent Pinchart
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-14android: camera_device: Temporary fix sensor propertiesJacopo Mondi
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 1889cdc2e91c ("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-11android: camera_device: Reorder configurations before requestingHirokazu Honda
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-11android: camera_device: Use Camera3StreamConfig in configureStreams()Hirokazu Honda
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-11android: camera_device: Introduce Camera3StreamConfigHirokazu Honda
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-07android: camera_device: Stop camera when re-configuring itJacopo Mondi
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-07android: camera_device: Initialize pixel array propertiesJacopo Mondi
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-02android: camera_device: Check capture_request validityJacopo Mondi
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-02android: camera_mode: Reserve 'data' vectorsJacopo Mondi
The CameraDevice::getStaticMetadata() function populates the entries for Android's static metadata by walking the ControlInfo supported values reported by the libcamera pipeline. The number of entries to be passed to Android is computed using the vector's size which is initialized at vector creation time to the maximum number of available entries. In order to report the correct number of metadata do not create the vector with the largest possible number of elements but only reserve space for them using std::vector::reserve() which does not modify the vector's size. This patch fixes cros_camera_test: Camera3DeviceTest/Camera3DeviceDefaultSettings.ConstructDefaultSettings/1 Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-10-28android: camera_device: Mark toPixelFormat() a const functionHirokazu Honda
CameraDevice::toPixelFormat() doesn't change the state of the CameraDevice. Marks it a const function so that it can be called in const functions. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-10-28android: camera_device: Fix crash of accessing a missing map elementHirokazu Honda
std::map::at() searches std::map by the given key. The commit e1f9fdb8a5bd ("android: camera_device: Remove shadowing FrameBuffer usage") uses it with 0 to intend to accessing the first element of the map, but actually access the element whose key is nullptr. This causes the crash because the map doesn't have the element with nullptr. This fixes the issue by replacing the std::map::at() operation by std::map::begin(). Signed-off-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> [Kieran: Updated commit message] Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-10-26android: camera_device: Handle LENS_SHADING_MAP_MODESJacopo Mondi
Register the ANDROID_STATISTICS_INFO_AVAILABLE_LENS_SHADING_MAP_MODES static metadata property inspecting the values retuned by the pipeline handler. Add one entry and reserve in static metadata pack enough space to support all the 2 available lens shading map modes Android defines. 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-10-26android: camera_device: Handle COLOR_CORRECTION_ABERRATION_MODEJacopo Mondi
Register the ANDROID_COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES static metadata property inspecting the values retuned by the pipeline handler. Reserve in the static metadata pack enough space to support all the 3 available color correction aberration modes Android defines. 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-10-26android: camera_device: Handle NOISE_REDUCTION_MODESJacopo Mondi
Register the ANDROID_NOISE_REDUCTION_AVAILABLE_NOISE_REDUCTION_MODES static metadata property inspecting the values retuned by the pipeline handler. Reserve in the static metadata pack enough space to support all the 5 available noise reduction modes Android defines. 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-10-26android: camera_device: Report PIPELINE_MAX_DEPTHJacopo Mondi
Register the ANDROID_REQUEST_PIPELINE_MAX_DEPTH static property inspecting the value reported by the pipeline handler. If the Camera does not report any suitable value, default the static property to 2. 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-10-21android: camera_device: Remove shadowing FrameBuffer usageKieran Bingham
A FrameBuffer *buffer is used to obtain the 'first' buffer from a request which is used purely to identify the timestamp from the metadata in two locations. Rather than keep the FrameBuffer instance around, which then causes further usages of FrameBuffers to be shadowed, store the timestamp locally. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-10-21android: camera_device: use member style on Camera3RequestDescriptorKieran Bingham
Use the postfixed '_' member variable naming style for the Camera3RequestDescriptor structure, which in turn ensures that variable shadowing does not occur in the member initializer list of the constructor. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-10-21android: camera_device: Use existing variable definitionsKieran Bingham
Prevent variable shadowing by removing the redeclaration of variables with the same name (and type) where the existing variable can be reused. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-10-20android: Omit extra semicolonsHirokazu Honda
The end semicolons with LOG_DECLARE_CATEGORY and LOG_DEFINE_CATEGORY are unnecessary. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-10-16android: jpeg: Port to PostProcessor interfaceUmang Jain
Port the CameraStream's JPEG-encoding bits to PostProcessorJpeg. This encapsulates the encoder and EXIF generation code into the PostProcessorJpeg layer and removes these specifics related to JPEG, from the CameraStream itself. Signed-off-by: Umang Jain <email@uajain.com> Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.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> Change-Id: Id9e6e9b2bec83493a90e5e126298a2bb2ed2232a
2020-10-14android: camera_device: Queue request using WorkerJacopo Mondi
Add a CameraWorker class member to the CameraDevice class and queue capture requests to it to delegate its handling. Start and stop the CameraWorker when the libcamera::Camera is started or stopped. Tie the CaptureRequest lifetime to the Camera3RequestDescriptor's one by storing it as unique_ptr<> in the descriptor to simplify handling of request creation and deletion. 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-10-12libcamera, android, cam, gstreamer, qcam, v4l2: Reuse RequestPaul Elder
Allow reuse of the Request object by implementing reuse(). This means the applications now have the responsibility of freeing the Request objects, so make all libcamera users (cam, qcam, v4l2-compat, gstreamer, android) do so. Signed-off-by: Paul Elder <paul.elder@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-10-07android: camera_device: Clear streams_ at stop timeJacopo Mondi
When the CameraDevice is stopped, we need to clear the vector of CameraStream instances to make sure they get deleted and all the resources they have acquired get released. Reviewed-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: Jacopo Mondi <jacopo@jmondi.org>
2020-10-07android: camera_device: Add stream mapping logJacopo Mondi
To ease following how Android streams get mapped to libcamera ones add a (quite verbose) printout before queueing a request to libcamera. The output looks like: 0 - (320x240)[0x00000022] -> (320x240)[NV12] (direct) 1 - (640x480)[0x00000021] -> (640x480)[NV12] (internal) Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@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-07android: camera_device: Use CameraStream buffersJacopo Mondi
Now that CameraStream that require internal memory allocation have been instrumented with a FrameBuffer pool, use them to create intermediate buffers in the CameraDevice. Reviewed-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: Jacopo Mondi <jacopo@jmondi.org>
2020-10-07android: camera_stream: Create buffer poolJacopo Mondi
Add a FrameBufferAllocator class member to the CameraStream class. The allocator is constructed for CameraStream instances that needs internal allocation and automatically deleted. Allocate FrameBuffers using the allocator_ class member in the CameraStream class at CameraStream::configure() time and add two methods to the CameraStream class to get and put FrameBuffer pointers from the pool of allocated buffers. As buffer allocation can take place only after the Camera has been configured, move the CameraStream configuration loop in the CameraDevice class after camera_->configure() call. The newly created pool will be used to provide buffers to CameraStream that need to provide memory to libcamera where to deliver frames. 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-10-07android: camera_device: Make CameraStream configuration nicerJacopo Mondi
Loop over the CameraStream instances and use their interface to perform CameraStream configuration. Modify CameraStream::configure() to configure the android stream buffer count and to retrieve the StreamConfiguration by index instead of receiving it as a parameter. 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-10-07android: camera_stream: Fetch format and size from configurationJacopo Mondi
Fetch the format and size of the libcamera::StreamConfiguration associated with a CameraStream by accessing the configuration by index. This removes the need to store the libcamera stream format and sizes as class members and avoid duplicating information that might get out of sync. It also allows to remove the StreamConfiguration from the constructor parameters list, as it can be identified by its index. While at it, re-order the constructor parameters order. 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-07android: camera_stream: Retrieve Stream and ConfigurationJacopo Mondi
It's a common pattern to access the libcamera::Stream and libcamera::StreamConfiguration using the CameraStream instance's index. Add two methods to the CameraStream to shorten access to the two fields. This allows removing the index() method from the class interface. 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-07android: camera_device: Move processing to CameraStreamJacopo Mondi
Move the JPEG processing procedure to the individual CameraStream by augmenting the class with a CameraStream::process() method. This allows removing the CameraStream::encoder() method. 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-07android: camera_stream: Construct with Android streamJacopo Mondi
Pass the android camera3_stream_t, and a libcamera::StreamConfiguration to identify the source and destination parameters of this stream. Pass a CameraDevice pointer to the CameraStream constructor to allow retrieval of the StreamConfiguration associated with the CameraStream. Also change the format on which the CameraDevice performs checks to decide if post-processing is required, as the libcamera facing format is not meaningful anymore, but the Android requested format should be used instead. Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-10-07android: camera_stream: Delegate Encoder constructionJacopo Mondi
Delegate the construction of the encoder to the CameraStream class for streams that need post-processing. Reviewed-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: Jacopo Mondi <jacopo@jmondi.org>
2020-10-07android: camera_stream: Add CameraStream::TypeJacopo Mondi
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-07android: camera_stream: Break out CameraStreamJacopo Mondi
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-09-30libcamera: stream: Rename StillCaptureRaw to RawNiklas Söderlund
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-18android: camera_device: Make CameraStream a classJacopo Mondi
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-18android: camera_device: Set Encoder at constructionJacopo Mondi
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-18android: camera_device: Rework CameraStream handlingJacopo Mondi
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-18android: camera_device: Use Android formatJacopo Mondi
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-18android: camera_device: Get rid of stream counterJacopo Mondi
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-18android: camera_device: Generate RAW resolutionsJacopo Mondi
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-18android: camera_device: Break out size calculationJacopo Mondi
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-18android: camera_device: Add debug to stream initializationJacopo Mondi
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-18android: camera_device: Generate JPEG sizesJacopo Mondi
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>