diff options
Diffstat (limited to 'libs/binder/IMemory.cpp')
-rw-r--r-- | libs/binder/IMemory.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/libs/binder/IMemory.cpp b/libs/binder/IMemory.cpp index cd2451a..8fea1b2 100644 --- a/libs/binder/IMemory.cpp +++ b/libs/binder/IMemory.cpp @@ -32,6 +32,10 @@ #include <binder/Parcel.h> #include <utils/CallStack.h> +#ifdef USE_V4L2_ION +#include "ion.h" +#endif + #define VERBOSE 0 namespace android { @@ -301,6 +305,14 @@ void BpMemoryHeap::assertReallyMapped() const ALOGE_IF(err, "binder=%p transaction failed fd=%d, size=%ld, err=%d (%s)", asBinder().get(), parcel_fd, size, err, strerror(-err)); +#ifdef USE_V4L2_ION + int ion_client = -1; + if (flags & USE_ION_FD) { + ion_client = ion_client_create(); + ALOGE_IF(ion_client < 0, "BpMemoryHeap : ion client creation error"); + } +#endif + int fd = dup( parcel_fd ); ALOGE_IF(fd==-1, "cannot dup fd=%d, size=%ld, err=%d (%s)", parcel_fd, size, err, strerror(errno)); @@ -313,7 +325,16 @@ void BpMemoryHeap::assertReallyMapped() const Mutex::Autolock _l(mLock); if (mHeapId == -1) { mRealHeap = true; - mBase = mmap(0, size, access, MAP_SHARED, fd, offset); + +#ifdef USE_V4L2_ION + if (flags & USE_ION_FD) { + if (ion_client < 0) + mBase = MAP_FAILED; + else + mBase = ion_map(fd, size, offset); + } else +#endif + mBase = mmap(0, size, access, MAP_SHARED, fd, offset); if (mBase == MAP_FAILED) { ALOGE("cannot map BpMemoryHeap (binder=%p), size=%ld, fd=%d (%s)", asBinder().get(), size, fd, strerror(errno)); @@ -325,6 +346,12 @@ void BpMemoryHeap::assertReallyMapped() const android_atomic_write(fd, &mHeapId); } } +#ifdef USE_V4L2_ION + if (ion_client < 0) + ion_client = -1; + else + ion_client_destroy(ion_client); +#endif } } |