[libcamera-devel] [PATCH 2/3] android: camera_device: Report pipeline depth

Laurent Pinchart laurent.pinchart at ideasonboard.com
Thu Dec 10 19:32:29 CET 2020


Hi Jacopo,

Thank you for the patch.

On Wed, Dec 09, 2020 at 06:35:18PM +0100, Jacopo Mondi wrote:
> Report the pipeline depth in the capture results if the pipeline
> reports it.
> 
> Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
> ---
>  src/android/camera_device.cpp | 21 ++++++++++++++++-----
>  src/android/camera_device.h   |  4 ++--
>  src/android/camera_worker.h   |  1 +
>  3 files changed, 19 insertions(+), 7 deletions(-)
> 
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index 872c7b18ee49..13194d1ea5cc 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -550,10 +550,10 @@ std::tuple<uint32_t, uint32_t> CameraDevice::calculateStaticMetadataSize()
>  {
>  	/*
>  	 * \todo Keep this in sync with the actual number of entries.
> -	 * Currently: 51 entries, 687 bytes of static metadata
> +	 * Currently: 52 entries, 698 bytes of static metadata
>  	 */
>  	uint32_t numEntries = 52;
> -	uint32_t byteSize = 694;
> +	uint32_t byteSize = 698;
>  
>  	/*
>  	 * Calculate space occupation in bytes for dynamically built metadata
> @@ -1046,6 +1046,7 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()
>  		ANDROID_CONTROL_AWB_STATE,
>  		ANDROID_CONTROL_AWB_LOCK,
>  		ANDROID_LENS_STATE,
> +		ANDROID_REQUEST_PIPELINE_DEPTH,
>  		ANDROID_SCALER_CROP_REGION,
>  		ANDROID_SENSOR_TIMESTAMP,
>  		ANDROID_SENSOR_ROLLING_SHUTTER_SKEW,
> @@ -1554,7 +1555,7 @@ void CameraDevice::requestComplete(Request *request)
>  	 * pipeline handlers) timestamp in the Request itself.
>  	 */
>  	uint64_t timestamp = buffers.begin()->second->metadata().timestamp;
> -	resultMetadata = getResultMetadata(descriptor->frameNumber_, timestamp);
> +	resultMetadata = getResultMetadata(descriptor, timestamp);
>  
>  	/* Handle any JPEG compression. */
>  	for (unsigned int i = 0; i < descriptor->numBuffers_; ++i) {
> @@ -1672,15 +1673,17 @@ void CameraDevice::notifyError(uint32_t frameNumber, camera3_stream_t *stream)
>   * Produce a set of fixed result metadata.
>   */
>  std::unique_ptr<CameraMetadata>
> -CameraDevice::getResultMetadata([[maybe_unused]] int frame_number,
> +CameraDevice::getResultMetadata(Camera3RequestDescriptor *descriptor,
>  				int64_t timestamp)
>  {
> +	const ControlList &metadata = descriptor->request_->request()->metadata();
> +
>  	/*
>  	 * \todo Keep this in sync with the actual number of entries.
>  	 * Currently: 18 entries, 62 bytes
>  	 */
>  	std::unique_ptr<CameraMetadata> resultMetadata =
> -		std::make_unique<CameraMetadata>(18, 62);
> +		std::make_unique<CameraMetadata>(19, 63);
>  	if (!resultMetadata->isValid()) {
>  		LOG(HAL, Error) << "Failed to allocate static metadata";
>  		return nullptr;
> @@ -1730,6 +1733,14 @@ CameraDevice::getResultMetadata([[maybe_unused]] int frame_number,
>  	resultMetadata->addEntry(ANDROID_STATISTICS_SCENE_FLICKER,
>  				 &scene_flicker, 1);
>  
> +	/* Add metadata tags reported by libcamera. */
> +	if (metadata.contains(controls::draft::PipelineDepth)) {
> +		uint8_t pipeline_depth =
> +			metadata.get<int32_t>(controls::draft::PipelineDepth);
> +		resultMetadata->addEntry(ANDROID_REQUEST_PIPELINE_DEPTH,
> +					 &pipeline_depth, 1);
> +	}
> +
>  	/*
>  	 * Return the result metadata pack even is not valid: get() will return
>  	 * nullptr.
> diff --git a/src/android/camera_device.h b/src/android/camera_device.h
> index 45efcf477436..07d3a846f8e1 100644
> --- a/src/android/camera_device.h
> +++ b/src/android/camera_device.h
> @@ -105,8 +105,8 @@ private:
>  	void notifyError(uint32_t frameNumber, camera3_stream_t *stream);
>  	CameraMetadata *requestTemplatePreview();
>  	libcamera::PixelFormat toPixelFormat(int format) const;
> -	std::unique_ptr<CameraMetadata> getResultMetadata(int frame_number,
> -							  int64_t timestamp);
> +	std::unique_ptr<CameraMetadata> getResultMetadata(
> +		Camera3RequestDescriptor *descriptor, int64_t timestamp);
>  
>  	unsigned int id_;
>  	camera3_device_t camera3Device_;
> diff --git a/src/android/camera_worker.h b/src/android/camera_worker.h
> index fff5021708d7..9417a816c214 100644
> --- a/src/android/camera_worker.h
> +++ b/src/android/camera_worker.h
> @@ -25,6 +25,7 @@ public:
>  	CaptureRequest(libcamera::Camera *camera, uint64_t cookie);
>  
>  	const std::vector<int> &fences() const { return acquireFences_; }
> +	const libcamera::Request *request() const { return request_.get(); }

As the caller of this function only uses it to access metadata, would it
make sense to instead have

	const libcamera::ControlList &metadata() const { return request_->metadata(); }

the same we way have addBuffer() to hide the request ? We could then
possibly drop patch 1/3.

>  	void addBuffer(libcamera::Stream *stream,
>  		       libcamera::FrameBuffer *buffer, int fence);

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list