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

Commit 28ee1955 authored by Simon Shields's avatar Simon Shields
Browse files

libui: gralloc1 getphys implementation for samsung OMX

Change-Id: I68d6b621e12a6f98dee94daab174adb390cce44e
parent 12f58910
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -117,6 +117,10 @@ public:
            gralloc1_consumer_usage_t consumerUsage,
            const gralloc1_rect_t* accessRegion, struct android_ycbcr* outData,
            const sp<Fence>& acquireFence);
#ifdef EXYNOS4_ENHANCEMENTS
    gralloc1_error_t getphys(buffer_handle_t buffer,
            void **paddr);
#endif

    gralloc1_error_t unlock(buffer_handle_t buffer, sp<Fence>* outFence);

@@ -208,6 +212,10 @@ private:
                GRALLOC1_FUNCTION_LOCK_YCBCR> lockYCbCr;
        FunctionLoader<GRALLOC1_PFN_UNLOCK,
                GRALLOC1_FUNCTION_UNLOCK> unlock;
#ifdef EXYNOS4_ENHANCEMENTS
        FunctionLoader<GRALLOC1_PFN_GETPHYS,
                GRALLOC1_FUNCTION_GETPHYS> getphys;
#endif

        // Adapter-only functions
        FunctionLoader<GRALLOC1_PFN_RETAIN_GRAPHIC_BUFFER,
+13 −1
Original line number Diff line number Diff line
@@ -102,6 +102,14 @@ private:
    }
    std::string mCachedDump;

#ifdef EXYNOS4_ENHANCEMENTS
    static int32_t getphysHook(gralloc1_device_t* device,
            buffer_handle_t handle,
            void **paddr) {
        return getAdapter(device)->getphys(device, handle, paddr);
    }
#endif

    // Buffer descriptor lifecycle functions

    class Descriptor;
@@ -335,7 +343,11 @@ private:
    static gralloc1_error_t allocateWithIdHook(gralloc1_device_t* device,
            gralloc1_buffer_descriptor_t descriptors,
            gralloc1_backing_store_t id, buffer_handle_t* outBuffer);

#ifdef EXYNOS4_ENHANCEMENTS
    gralloc1_error_t getphys(gralloc1_device_t* device,
            buffer_handle_t buffer,
            void **paddr);
#endif
    gralloc1_error_t retain(const std::shared_ptr<Buffer>& buffer);
    gralloc1_error_t release(const std::shared_ptr<Buffer>& buffer);

+13 −0
Original line number Diff line number Diff line
@@ -261,6 +261,14 @@ gralloc1_error_t Device::lockYCbCr(buffer_handle_t buffer,
            consumerUsage, accessRegion, outData, acquireFence);
}

#ifdef EXYNOS4_ENHANCEMENTS
gralloc1_error_t Device::getphys(buffer_handle_t buffer, void** paddr)
{
    int32_t intError = mFunctions.getphys(mDevice, buffer, paddr);
    return static_cast<gralloc1_error_t>(intError);
}
#endif

gralloc1_error_t Device::unlock(buffer_handle_t buffer, sp<Fence>* outFence)
{
    int32_t fenceFd = -1;
@@ -348,6 +356,11 @@ bool Device::loadFunctions()
    if (!mFunctions.unlock.load(mDevice, true)) {
        return false;
    }
#ifdef EXYNOS4_ENHANCEMENTS
    if (!mFunctions.getphys.load(mDevice, true)) {
        return false;
    }
#endif

    if (hasCapability(GRALLOC1_CAPABILITY_ON_ADAPTER)) {
        // These should always be present on the adapter
+25 −0
Original line number Diff line number Diff line
@@ -154,6 +154,10 @@ gralloc1_function_pointer_t Gralloc1On0Adapter::doGetFunction(
                    &Gralloc1On0Adapter::lockYCbCr>);
        case GRALLOC1_FUNCTION_UNLOCK:
            return asFP<GRALLOC1_PFN_UNLOCK>(unlockHook);
#ifdef EXYNOS4_ENHANCEMENTS
        case GRALLOC1_FUNCTION_GETPHYS:
            return asFP<GRALLOC1_PFN_GETPHYS>(getphysHook);
#endif
        case GRALLOC1_FUNCTION_INVALID:
            ALOGE("Invalid function descriptor");
            return nullptr;
@@ -285,6 +289,27 @@ gralloc1_error_t Gralloc1On0Adapter::allocateWithIdHook(
    return error;
}

#ifdef EXYNOS4_ENHANCEMENTS
gralloc1_error_t Gralloc1On0Adapter::getphys(
        gralloc1_device_t* device,
        buffer_handle_t handle,
        void **paddr)
{
    gralloc1_error_t err;
    auto adapter = getAdapter(device);
    int res = mModule->getphys(mModule, handle, paddr);

    if (res) {
        ALOGE("getphys(%p) fail %d(%s)", handle, res, strerror(-res));
        err = GRALLOC1_ERROR_UNDEFINED;
    } else {
        err = GRALLOC1_ERROR_NONE;
    }

    return err;
}
#endif

gralloc1_error_t Gralloc1On0Adapter::retain(
        const std::shared_ptr<Buffer>& buffer)
{
+1 −1
Original line number Diff line number Diff line
@@ -292,7 +292,7 @@ status_t GraphicBufferMapper::getphys(buffer_handle_t handle, void** paddr)
{
    status_t err;

    err = mAllocMod->getphys(mAllocMod, handle, paddr);
    err = mDevice->getphys(handle, paddr);

    ALOGW_IF(err, "getphys(%p) fail %d(%s)", handle, err, strerror(-err));
    return err;