camera: Make overrideFormat from reserved fields opt-in

Change-Id: Ic0025ae5a4d359074e25692e1913eb98f47bbcec
This commit is contained in:
Rohit Sekhar 2023-09-20 17:46:13 +05:30 committed by zlewchan
parent df1c0cd96e
commit 579f81f4ae
5 changed files with 18 additions and 3 deletions

View file

@ -10,7 +10,10 @@ package {
cc_library_shared { cc_library_shared {
name: "camera.device@3.2-impl", name: "camera.device@3.2-impl",
defaults: ["hidl_defaults"], defaults: [
"hidl_defaults",
"camera_override_format_from_reserved_defaults",
],
proprietary: true, proprietary: true,
srcs: [ srcs: [
"CameraDevice.cpp", "CameraDevice.cpp",

View file

@ -927,11 +927,14 @@ bool CameraDeviceSession::preProcessConfigurationLocked(
mCirculatingBuffers.emplace(stream.mId, CirculatingBuffers{}); mCirculatingBuffers.emplace(stream.mId, CirculatingBuffers{});
} else { } else {
// width/height must not change, but usage/rotation might need to change // 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 != if (mStreamMap[id].stream_type !=
(int) requestedConfiguration.streams[i].streamType || (int) requestedConfiguration.streams[i].streamType ||
mStreamMap[id].width != requestedConfiguration.streams[i].width || mStreamMap[id].width != requestedConfiguration.streams[i].width ||
mStreamMap[id].height != requestedConfiguration.streams[i].height || 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 != mStreamMap[id].data_space !=
mapToLegacyDataspace( static_cast<android_dataspace_t> ( mapToLegacyDataspace( static_cast<android_dataspace_t> (
requestedConfiguration.streams[i].dataSpace))) { requestedConfiguration.streams[i].dataSpace))) {

View file

@ -74,8 +74,10 @@ void convertFromHidl(const Stream &src, Camera3Stream* dst) {
dst->data_space = (android_dataspace_t) src.dataSpace; dst->data_space = (android_dataspace_t) src.dataSpace;
dst->rotation = (int) src.rotation; dst->rotation = (int) src.rotation;
dst->usage = (uint32_t) src.usage; dst->usage = (uint32_t) src.usage;
#ifdef TARGET_CAMERA_OVERRIDE_FORMAT_FROM_RESERVED
dst->reserved[0] = NULL; dst->reserved[0] = NULL;
dst->reserved[1] = NULL; dst->reserved[1] = NULL;
#endif
// Fields to be filled by HAL (max_buffers, priv) are initialized to 0 // Fields to be filled by HAL (max_buffers, priv) are initialized to 0
dst->max_buffers = 0; dst->max_buffers = 0;
dst->priv = 0; dst->priv = 0;
@ -99,6 +101,7 @@ void convertToHidl(const Camera3Stream* src, HalStream* dst) {
__FUNCTION__, src->stream_type); __FUNCTION__, src->stream_type);
} }
#ifdef TARGET_CAMERA_OVERRIDE_FORMAT_FROM_RESERVED
HalStream* halStream = NULL; HalStream* halStream = NULL;
if (src->reserved[0] != NULL) { if (src->reserved[0] != NULL) {
halStream = (HalStream*)(src->reserved[0]); halStream = (HalStream*)(src->reserved[0]);
@ -115,6 +118,7 @@ void convertToHidl(const Camera3Stream* src, HalStream* dst) {
dst->consumerUsage = (BufferUsageFlags)halStream->consumerUsage; dst->consumerUsage = (BufferUsageFlags)halStream->consumerUsage;
} }
} }
#endif
} }
void convertToHidl(const camera3_stream_configuration_t& src, HalStreamConfiguration* dst) { void convertToHidl(const camera3_stream_configuration_t& src, HalStreamConfiguration* dst) {

View file

@ -10,7 +10,10 @@ package {
cc_library_shared { cc_library_shared {
name: "camera.device@3.3-impl", name: "camera.device@3.3-impl",
defaults: ["hidl_defaults"], defaults: [
"hidl_defaults",
"camera_override_format_from_reserved_defaults",
],
proprietary: true, proprietary: true,
srcs: [ srcs: [
"CameraDevice.cpp", "CameraDevice.cpp",

View file

@ -48,6 +48,7 @@ void convertToHidl(const Camera3Stream* src, HalStream* dst) {
__FUNCTION__, src->stream_type); __FUNCTION__, src->stream_type);
} }
#ifdef TARGET_CAMERA_OVERRIDE_FORMAT_FROM_RESERVED
HalStream* halStream = NULL; HalStream* halStream = NULL;
if (src->reserved[0] != NULL) { if (src->reserved[0] != NULL) {
halStream = (HalStream*)(src->reserved[0]); 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; dst->v3_2.consumerUsage = (BufferUsageFlags)halStream->v3_2.consumerUsage;
} }
} }
#endif
} }
void convertToHidl(const camera3_stream_configuration_t& src, HalStreamConfiguration* dst) { void convertToHidl(const camera3_stream_configuration_t& src, HalStreamConfiguration* dst) {