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

Commit 3a069359 authored by John Stultz's avatar John Stultz
Browse files

Codec2: Add sys-prop to allow dmabuf heap usage to be forced



This patch adds support for a debug.c2.use_dmabufheaps=1 sysprop
which can be used to force DMABUF Heaps to be used even when
/dev/ion is present.

In the case the override is specified, but there is no
/dev/dma_heap/system device, the override will be ignored and
it will fall back to ION.

This will allow vendors to test DMABUF Heap implementations
while allowing other parts of the system to continue to use ION.

Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
Change-Id: I1cbbd8e201d11c4a47b89c9a45fe6dda53241355
parent 2610b34b
Loading
Loading
Loading
Loading
+20 −6
Original line number Diff line number Diff line
@@ -102,16 +102,30 @@ C2PlatformAllocatorStoreImpl::C2PlatformAllocatorStoreImpl() {
}

static bool using_ion(void) {
    static int cached_result = -1;

    if (cached_result == -1) {
    static int cached_result = []()->int {
        struct stat buffer;
        cached_result = (stat("/dev/ion", &buffer) == 0);
        if (cached_result)
        int ret = (stat("/dev/ion", &buffer) == 0);

        if (property_get_int32("debug.c2.use_dmabufheaps", 0)) {
            /*
             * Double check that the system heap is present so we
             * can gracefully fail back to ION if we cannot satisfy
             * the override
             */
            ret = (stat("/dev/dma_heap/system", &buffer) != 0);
            if (ret)
                ALOGE("debug.c2.use_dmabufheaps set, but no system heap. Ignoring override!");
            else
                ALOGD("debug.c2.use_dmabufheaps set, forcing DMABUF Heaps");
        }

        if (ret)
            ALOGD("Using ION\n");
        else
            ALOGD("Using DMABUF Heaps\n");
    }
        return ret;
    }();

    return (cached_result == 1);
}