android: camera_device: Prepare for non-mandatory formats

When probing what formats a libcamera Camera supports we want to allow
to probe for non-mandatory formats. Add a new flag to indicate if a
format in camera3FormatsMap is mandatory or not.

All current defined formats are mandatory.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Niklas Söderlund 2020-07-28 19:43:12 +02:00
parent 70b65c6590
commit 8c1fedcb78

View file

@ -46,6 +46,7 @@ const std::vector<Size> camera3Resolutions = {
*/ */
struct Camera3Format { struct Camera3Format {
std::vector<PixelFormat> libcameraFormats; std::vector<PixelFormat> libcameraFormats;
bool mandatory;
const char *name; const char *name;
}; };
@ -57,11 +58,13 @@ const std::map<int, const Camera3Format> camera3FormatsMap = {
{ {
HAL_PIXEL_FORMAT_BLOB, { HAL_PIXEL_FORMAT_BLOB, {
{ formats::MJPEG }, { formats::MJPEG },
true,
"BLOB" "BLOB"
} }
}, { }, {
HAL_PIXEL_FORMAT_YCbCr_420_888, { HAL_PIXEL_FORMAT_YCbCr_420_888, {
{ formats::NV12, formats::NV21 }, { formats::NV12, formats::NV21 },
true,
"YCbCr_420_888" "YCbCr_420_888"
} }
}, { }, {
@ -71,6 +74,7 @@ const std::map<int, const Camera3Format> camera3FormatsMap = {
*/ */
HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, { HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, {
{ formats::NV12, formats::NV21 }, { formats::NV12, formats::NV21 },
true,
"IMPLEMENTATION_DEFINED" "IMPLEMENTATION_DEFINED"
} }
}, },
@ -281,7 +285,7 @@ int CameraDevice::initializeStreamConfigurations()
break; break;
} }
} }
if (!mappedFormat.isValid()) { if (camera3Format.mandatory && !mappedFormat.isValid()) {
LOG(HAL, Error) << "Failed to map Android format " LOG(HAL, Error) << "Failed to map Android format "
<< camera3Format.name << " (" << camera3Format.name << " ("
<< utils::hex(androidFormat) << ")"; << utils::hex(androidFormat) << ")";