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

Commit afd69c42 authored by Ethan Chen's avatar Ethan Chen
Browse files

Camera: Support obtaining camera memory from MemoryHeapIon

* Exynos 5 devices want the ION file descriptor from MemoryHeapIon

Change-Id: I9e445cf24c15713f713181667e7b7caa1a96592e
parent 91236891
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -78,6 +78,10 @@ ifeq ($(BOARD_CAMERA_MSG_MGMT),true)
    LOCAL_CFLAGS += -DCAMERA_MSG_MGMT
endif

ifeq ($(BOARD_NEEDS_MEMORYHEAPION),true)
    LOCAL_CFLAGS += -DUSE_MEMORY_HEAP_ION
endif

LOCAL_MODULE:= libcameraservice

include $(BUILD_SHARED_LIBRARY)
+21 −0
Original line number Diff line number Diff line
@@ -26,6 +26,9 @@
#include <camera/CameraParameters.h>
#include <system/window.h>
#include <hardware/camera.h>
#ifdef USE_MEMORY_HEAP_ION
#include <binder/MemoryHeapIon.h>
#endif

namespace android {

@@ -493,7 +496,11 @@ private:
                         mBufSize(buf_size),
                         mNumBufs(num_buffers)
        {
#ifdef USE_MEMORY_HEAP_ION
            mHeap = new MemoryHeapIon(fd, buf_size * num_buffers);
#else
            mHeap = new MemoryHeapBase(fd, buf_size * num_buffers);
#endif
            commonInitialization();
        }

@@ -501,7 +508,11 @@ private:
                         mBufSize(buf_size),
                         mNumBufs(num_buffers)
        {
#ifdef USE_MEMORY_HEAP_ION
            mHeap = new MemoryHeapIon(buf_size * num_buffers);
#else
            mHeap = new MemoryHeapBase(buf_size * num_buffers);
#endif
            commonInitialization();
        }

@@ -533,14 +544,24 @@ private:
        camera_memory_t handle;
    };

#ifdef USE_MEMORY_HEAP_ION
    static camera_memory_t* __get_memory(int fd, size_t buf_size, uint_t num_bufs,
                                         void *ion_fd)
    {
#else
    static camera_memory_t* __get_memory(int fd, size_t buf_size, uint_t num_bufs,
                                         void *user __attribute__((unused)))
    {
#endif
        CameraHeapMemory *mem;
        if (fd < 0)
            mem = new CameraHeapMemory(buf_size, num_bufs);
        else
            mem = new CameraHeapMemory(fd, buf_size, num_bufs);
#ifdef USE_MEMORY_HEAP_ION
        if (ion_fd)
            *((int *) ion_fd) = mem->mHeap->getHeapID();
#endif
        mem->incStrong(mem);
        return &mem->handle;
    }