From 579f81f4ae03605052a094535df04e160d690b90 Mon Sep 17 00:00:00 2001 From: Rohit Sekhar Date: Wed, 20 Sep 2023 17:46:13 +0530 Subject: [PATCH] camera: Make overrideFormat from reserved fields opt-in Change-Id: Ic0025ae5a4d359074e25692e1913eb98f47bbcec --- camera/device/3.2/default/Android.bp | 5 ++++- camera/device/3.2/default/CameraDeviceSession.cpp | 5 ++++- camera/device/3.2/default/convert.cpp | 4 ++++ camera/device/3.3/default/Android.bp | 5 ++++- camera/device/3.3/default/convert.cpp | 2 ++ 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/camera/device/3.2/default/Android.bp b/camera/device/3.2/default/Android.bp index 00e59ec783..7af517f56e 100644 --- a/camera/device/3.2/default/Android.bp +++ b/camera/device/3.2/default/Android.bp @@ -10,7 +10,10 @@ package { cc_library_shared { name: "camera.device@3.2-impl", - defaults: ["hidl_defaults"], + defaults: [ + "hidl_defaults", + "camera_override_format_from_reserved_defaults", + ], proprietary: true, srcs: [ "CameraDevice.cpp", diff --git a/camera/device/3.2/default/CameraDeviceSession.cpp b/camera/device/3.2/default/CameraDeviceSession.cpp index 896c35843a..6e5c714251 100644 --- a/camera/device/3.2/default/CameraDeviceSession.cpp +++ b/camera/device/3.2/default/CameraDeviceSession.cpp @@ -927,11 +927,14 @@ bool CameraDeviceSession::preProcessConfigurationLocked( mCirculatingBuffers.emplace(stream.mId, CirculatingBuffers{}); } else { // width/height must not change, but usage/rotation might need to change - // format might change and get updated with overrideFormat + // format might change and get updated with TARGET_CAMERA_OVERRIDE_FORMAT_FROM_RESERVED if (mStreamMap[id].stream_type != (int) requestedConfiguration.streams[i].streamType || mStreamMap[id].width != requestedConfiguration.streams[i].width || mStreamMap[id].height != requestedConfiguration.streams[i].height || +#ifndef TARGET_CAMERA_OVERRIDE_FORMAT_FROM_RESERVED + mStreamMap[id].format != (int) requestedConfiguration.streams[i].format || +#endif mStreamMap[id].data_space != mapToLegacyDataspace( static_cast ( requestedConfiguration.streams[i].dataSpace))) { diff --git a/camera/device/3.2/default/convert.cpp b/camera/device/3.2/default/convert.cpp index cb64f396f2..fdbc204556 100644 --- a/camera/device/3.2/default/convert.cpp +++ b/camera/device/3.2/default/convert.cpp @@ -74,8 +74,10 @@ void convertFromHidl(const Stream &src, Camera3Stream* dst) { dst->data_space = (android_dataspace_t) src.dataSpace; dst->rotation = (int) src.rotation; dst->usage = (uint32_t) src.usage; +#ifdef TARGET_CAMERA_OVERRIDE_FORMAT_FROM_RESERVED dst->reserved[0] = NULL; dst->reserved[1] = NULL; +#endif // Fields to be filled by HAL (max_buffers, priv) are initialized to 0 dst->max_buffers = 0; dst->priv = 0; @@ -99,6 +101,7 @@ void convertToHidl(const Camera3Stream* src, HalStream* dst) { __FUNCTION__, src->stream_type); } +#ifdef TARGET_CAMERA_OVERRIDE_FORMAT_FROM_RESERVED HalStream* halStream = NULL; if (src->reserved[0] != NULL) { halStream = (HalStream*)(src->reserved[0]); @@ -115,6 +118,7 @@ void convertToHidl(const Camera3Stream* src, HalStream* dst) { dst->consumerUsage = (BufferUsageFlags)halStream->consumerUsage; } } +#endif } void convertToHidl(const camera3_stream_configuration_t& src, HalStreamConfiguration* dst) { diff --git a/camera/device/3.3/default/Android.bp b/camera/device/3.3/default/Android.bp index 5bc2b51d18..32bbdf62c7 100644 --- a/camera/device/3.3/default/Android.bp +++ b/camera/device/3.3/default/Android.bp @@ -10,7 +10,10 @@ package { cc_library_shared { name: "camera.device@3.3-impl", - defaults: ["hidl_defaults"], + defaults: [ + "hidl_defaults", + "camera_override_format_from_reserved_defaults", + ], proprietary: true, srcs: [ "CameraDevice.cpp", diff --git a/camera/device/3.3/default/convert.cpp b/camera/device/3.3/default/convert.cpp index ac17d837d7..9b6caf0360 100644 --- a/camera/device/3.3/default/convert.cpp +++ b/camera/device/3.3/default/convert.cpp @@ -48,6 +48,7 @@ void convertToHidl(const Camera3Stream* src, HalStream* dst) { __FUNCTION__, src->stream_type); } +#ifdef TARGET_CAMERA_OVERRIDE_FORMAT_FROM_RESERVED HalStream* halStream = NULL; if (src->reserved[0] != NULL) { halStream = (HalStream*)(src->reserved[0]); @@ -63,6 +64,7 @@ void convertToHidl(const Camera3Stream* src, HalStream* dst) { dst->v3_2.consumerUsage = (BufferUsageFlags)halStream->v3_2.consumerUsage; } } +#endif } void convertToHidl(const camera3_stream_configuration_t& src, HalStreamConfiguration* dst) {