Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e8ecda97 authored by Shuzhen Wang's avatar Shuzhen Wang
Browse files

Camera: Allow different kinds of IMPLEMENTATION_DEFINED surfaces to share

Do not guard against mismatching usage flag and data space for
IMPLEMENTATION_DEFINED formats, so that different formats can share
the same stream if HAL support is available.

Test: Camera CTS
Bug: 33777818
Change-Id: I62a1f458c06ae417c9a2c407d433319a1158fdcc
parent 5ea3c115
Loading
Loading
Loading
Loading
+16 −17
Original line number Diff line number Diff line
@@ -867,6 +867,7 @@ binder::Status CameraDeviceClient::createSurfaceFromGbp(
        ALOGE("%s: %s", __FUNCTION__, msg.string());
        return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT, msg.string());
    }
    if (format != HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED) {
        if (dataSpace != streamInfo.dataSpace) {
            String8 msg = String8::format("Camera %s:Surface dataSpace doesn't match: %d vs %d",
                    mCameraIdStr.string(), dataSpace, streamInfo.dataSpace);
@@ -874,17 +875,15 @@ binder::Status CameraDeviceClient::createSurfaceFromGbp(
            return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT, msg.string());
        }
        //At the native side, there isn't a way to check whether 2 surfaces come from the same
    //surface class type. Use usage flag to approximate the comparison. Treat
    //different preview surface usage flags as the same.
    int32_t previewUsageMask =
            GraphicBuffer::USAGE_HW_TEXTURE | GraphicBuffer::USAGE_HW_COMPOSER;
    if ((consumerUsage & ~previewUsageMask) != (streamInfo.consumerUsage & ~previewUsageMask)) {
        //surface class type. Use usage flag to approximate the comparison.
        if (consumerUsage != streamInfo.consumerUsage) {
            String8 msg = String8::format(
                    "Camera %s:Surface usage flag doesn't match 0x%x vs 0x%x",
                    mCameraIdStr.string(), consumerUsage, streamInfo.consumerUsage);
            ALOGE("%s: %s", __FUNCTION__, msg.string());
            return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT, msg.string());
        }
    }
    return binder::Status::ok();
}