From 35de31e0277142247ca37660ccf75fbaa213fd0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Date: Thu, 31 Dec 2020 00:11:59 +0100 Subject: android: camera_device: Only advertise RAW support if RAW16 is available MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Niklas Söderlund Tested-by: Laurent Pinchart Reviewed-by: Laurent Pinchart --- src/android/camera_device.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 7678d448..23be2a59 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1099,7 +1099,9 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() if (cameraConfig && !cameraConfig->empty()) { const PixelFormatInfo &info = PixelFormatInfo::info(cameraConfig->at(0).pixelFormat); - if (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW) { + /* Only advertise RAW support if RAW16 is possible. */ + if (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW && + info.bitsPerPixel == 16) { rawStreamAvailable = true; availableCapabilities.push_back(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_RAW); } -- cgit v1.2.1