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

Commit 7dc54f92 authored by Harish Mahendrakar's avatar Harish Mahendrakar
Browse files

C2AllocatorGralloc: Limit Gralloc4Mapper_lock to T and above

Gralloc4Mapper_lock() returns few wrong parameters when called
on few devices running older Android versions as part of mainline
module.

Since this function was added in Android T to support vendor P010
format and P010 support is Android T and above, this function is
now limited to devices running Android T and above.

Bug: 237366327
Test: atest CtsMediaCodecTestCases:EncodeVirtualDisplayTest \
 CtsMediaV2TestCases:android.mediav2.cts.CodecEncoderSurfaceTest

Change-Id: I58590098d47bb3eb6d871235c200a5bb82faed25
parent fdcf4bda
Loading
Loading
Loading
Loading
+10 −4
Original line number Original line Diff line number Diff line
@@ -54,6 +54,10 @@ namespace /* unnamed */ {
    static_assert((~C2MemoryUsage::PLATFORM_MASK & PASSTHROUGH_USAGE_MASK) == 0, "");
    static_assert((~C2MemoryUsage::PLATFORM_MASK & PASSTHROUGH_USAGE_MASK) == 0, "");
} // unnamed
} // unnamed


static bool isAtLeastT() {
    return android_get_device_api_level() >= __ANDROID_API_T__;
}

C2MemoryUsage C2AndroidMemoryUsage::FromGrallocUsage(uint64_t usage) {
C2MemoryUsage C2AndroidMemoryUsage::FromGrallocUsage(uint64_t usage) {
    // gralloc does not support WRITE_PROTECTED
    // gralloc does not support WRITE_PROTECTED
    return C2MemoryUsage(
    return C2MemoryUsage(
@@ -760,11 +764,13 @@ c2_status_t C2AllocationGralloc::map(
        default: {
        default: {
            // We don't know what it is, let's try to lock it with gralloc4
            // We don't know what it is, let's try to lock it with gralloc4
            android_ycbcr ycbcrLayout;
            android_ycbcr ycbcrLayout;
            if (isAtLeastT()) {
                c2_status_t status = Gralloc4Mapper_lock(
                c2_status_t status = Gralloc4Mapper_lock(
                        const_cast<native_handle_t*>(mBuffer), grallocUsage, rect, layout, addr);
                        const_cast<native_handle_t*>(mBuffer), grallocUsage, rect, layout, addr);
                if (status == C2_OK) {
                if (status == C2_OK) {
                    break;
                    break;
                }
                }
            }


            // fallback to lockYCbCr
            // fallback to lockYCbCr
            status_t err = GraphicBufferMapper::get().lockYCbCr(
            status_t err = GraphicBufferMapper::get().lockYCbCr(