[libcamera-devel] [PATCH 3/3] android: camera_device: Report RAW capability if supported

Jacopo Mondi jacopo at jmondi.org
Wed Jul 29 10:51:06 CEST 2020


Hi Niklas,

On Tue, Jul 28, 2020 at 08:55:48PM +0200, Niklas Söderlund wrote:
> Probe the libcamera Camera for RAW support and if supported report RAW
> capability in the static metadata reported to Android.
>
> Signed-off-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
> ---
>  src/android/camera_device.cpp | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index 95a563b1aafe86de..76c128564550419a 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -15,6 +15,7 @@
>  #include <libcamera/formats.h>
>  #include <libcamera/property_ids.h>
>
> +#include "libcamera/internal/formats.h"
>  #include "libcamera/internal/log.h"
>  #include "libcamera/internal/utils.h"
>
> @@ -727,6 +728,15 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()
>  	std::vector<uint8_t> availableCapabilities = {
>  		ANDROID_REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE,
>  	};
> +
> +	/* Report if camera supports RAW. */
> +	std::unique_ptr<CameraConfiguration> cameraConfig =
> +		camera_->generateConfiguration({ StillCaptureRaw });
> +	const PixelFormatInfo &info =
> +		PixelFormatInfo::info(cameraConfig->at(0).pixelFormat);
> +	if (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW)
> +		availableCapabilities.push_back(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_RAW);
> +

The documentation reports

"RAW (v3.2) [optional]
The camera device supports outputting RAW buffers and metadata for
interpreting them.  Devices supporting the RAW capability allow both
for saving DNG files, and for direct application processing of raw
sensor images.

RAW_SENSOR is supported as an output format.
The maximum available resolution for RAW_SENSOR streams will match
either the value in android.sensor.info.pixelArraySize or
android.sensor.info.preCorrectionActiveArraySize.  All DNG-related
optional metadata entries are provided by the camera device."

Searching the documentation I see a few mentions of RAW_SENSOR and
"supported as an output format" might means that we just need to
report one RAW streams as part of the
ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT property as
we're doing already.

The size check might instead be faulty. Currently the list of
resolutions to test against a format to construct the
streamConfigurations_ output formats map is taken from

	std::unique_ptr<CameraConfiguration> cameraConfig =
		camera_->generateConfiguration({ StillCapture });
	StreamConfiguration &cfg = cameraConfig->at(0);
	const Size maxRes = cfg.size;

Hence, it's not the pixelArraySize. It will, as there's a comment
above the preceeding block that says:
	 * \todo Get this from the camera properties once defined

But at the moment, it's not. I wonder if we should record a todo for
raw or just let this happen.

Anyway, I encourage to run CTS and cros_camera_test once new features
are advertised to the camera service to know if all the required
properties are actually there.

Thanks
  j

>  	staticMetadata_->addEntry(ANDROID_REQUEST_AVAILABLE_CAPABILITIES,
>  				  availableCapabilities.data(),
>  				  availableCapabilities.size());
> --
> 2.27.0
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel


More information about the libcamera-devel mailing list