mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-13 15:29:45 +03:00
android: camera_device: Configure one stream for identical stream requests
An Android HAL client may request multiple identical streams. It is redundant that a native camera device produces a separate stream for each of the identical requests. Configure the camera with a single stream in that case. The other identical HAL streams will be produced by the YUV post-processor. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
13b76d6209
commit
d165f7da34
1 changed files with 29 additions and 0 deletions
|
@ -618,6 +618,35 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* While gralloc usage flags are supposed to report usage
|
||||||
|
* patterns to select a suitable buffer allocation strategy, in
|
||||||
|
* practice they're also used to make other decisions, such as
|
||||||
|
* selecting the actual format for the IMPLEMENTATION_DEFINED
|
||||||
|
* HAL pixel format. To avoid issues, we thus have to set the
|
||||||
|
* GRALLOC_USAGE_HW_CAMERA_WRITE flag unconditionally, even for
|
||||||
|
* streams that will be produced in software.
|
||||||
|
*/
|
||||||
|
stream->usage |= GRALLOC_USAGE_HW_CAMERA_WRITE;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If a CameraStream with the same size and format of the
|
||||||
|
* current stream has already been requested, associate the two.
|
||||||
|
*/
|
||||||
|
auto iter = std::find_if(
|
||||||
|
streamConfigs.begin(), streamConfigs.end(),
|
||||||
|
[size, format](const Camera3StreamConfig &streamConfig) {
|
||||||
|
return streamConfig.config.size == size &&
|
||||||
|
streamConfig.config.pixelFormat == format;
|
||||||
|
});
|
||||||
|
if (iter != streamConfigs.end()) {
|
||||||
|
/* Add usage to copy the buffer in streams[0] to stream. */
|
||||||
|
iter->streams[0].stream->usage |= GRALLOC_USAGE_SW_READ_OFTEN;
|
||||||
|
stream->usage |= GRALLOC_USAGE_SW_WRITE_OFTEN;
|
||||||
|
iter->streams.push_back({ stream, CameraStream::Type::Mapped });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
Camera3StreamConfig streamConfig;
|
Camera3StreamConfig streamConfig;
|
||||||
streamConfig.streams = { { stream, CameraStream::Type::Direct } };
|
streamConfig.streams = { { stream, CameraStream::Type::Direct } };
|
||||||
streamConfig.config.size = size;
|
streamConfig.config.size = size;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue