Skip to content

Commit

Permalink
Merge branch 'cm-11.0' of git://github.com/CyanogenMod/android_framew…
Browse files Browse the repository at this point in the history
…orks_native into cm-11.0
  • Loading branch information
GDsouza committed Jul 18, 2014
2 parents 35ba537 + d7df45b commit ed0b230
Show file tree
Hide file tree
Showing 22 changed files with 617 additions and 35 deletions.
4 changes: 4 additions & 0 deletions include/binder/IMemory.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ class IMemoryHeap : public IInterface
// flags returned by getFlags()
enum {
READ_ONLY = 0x00000001,
#ifdef USE_MEMORY_HEAP_ION
USE_ION_FD = 0x00008000
#else
USE_ION_FD = 0x00000008
#endif
};

virtual int getHeapID() const = 0;
Expand Down
15 changes: 15 additions & 0 deletions include/binder/MemoryHeapIon.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@
#include <binder/MemoryHeapBase.h>
#include <stdlib.h>

#define MHB_ION_HEAP_SYSTEM_CONTIG_MASK (1 << 1)
#define MHB_ION_HEAP_EXYNOS_CONTIG_MASK (1 << 4)
#define MHB_ION_HEAP_EXYNOS_MASK (1 << 5)
#define MHB_ION_HEAP_SYSTEM_MASK (1 << 6)

#define MHB_ION_FLAG_CACHED (1 << 16)
#define MHB_ION_FLAG_CACHED_NEEDS_SYNC (1 << 17)
#define MHB_ION_FLAG_PRESERVE_KMAP (1 << 18)

#define MHB_ION_EXYNOS_VIDEO_MASK (1 << 21)
#define MHB_ION_EXYNOS_MFC_INPUT_MASK (1 << 25)
#define MHB_ION_EXYNOS_MFC_OUTPUT_MASK (1 << 26)
#define MHB_ION_EXYNOS_GSC_MASK (1 << 27)
#define MHB_ION_EXYNOS_FIMD_VIDEO_MASK (1 << 28)

namespace android {

class MemoryHeapIon : public MemoryHeapBase
Expand Down
14 changes: 7 additions & 7 deletions libs/binder/IMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,10 @@ void BpMemoryHeap::assertReallyMapped() const
asBinder().get(), parcel_fd, size, err, strerror(-err));

#ifdef USE_MEMORY_HEAP_ION
int ion_client = -1;
ion_client ion_client_num = -1;
if (flags & USE_ION_FD) {
ion_client = ion_client_create();
ALOGE_IF(ion_client < 0, "BpMemoryHeap : ion client creation error");
ion_client_num = ion_client_create();
ALOGE_IF(ion_client_num < 0, "BpMemoryHeap : ion client creation error");
}
#endif

Expand All @@ -326,7 +326,7 @@ void BpMemoryHeap::assertReallyMapped() const

#ifdef USE_MEMORY_HEAP_ION
if (flags & USE_ION_FD) {
if (ion_client < 0)
if (ion_client_num < 0)
mBase = MAP_FAILED;
else
mBase = ion_map(fd, size, offset);
Expand All @@ -345,10 +345,10 @@ void BpMemoryHeap::assertReallyMapped() const
}
}
#ifdef USE_MEMORY_HEAP_ION
if (ion_client < 0)
ion_client = -1;
if (ion_client_num < 0)
ion_client_num = -1;
else
ion_client_destroy(ion_client);
ion_client_destroy(ion_client_num);
#endif
}
}
Expand Down
80 changes: 78 additions & 2 deletions libs/binder/MemoryHeapIon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,96 @@
#include <sys/mman.h>
#include "ion.h"

#define HEAP_MASK_FILTER ((1 << 16) - (2))
#define FLAG_MASK_FILTER (~(HEAP_MASK_FILTER) - (1))

namespace android {

uint32_t ion_HeapMask_valid_check(uint32_t flags)
{
uint32_t heap_mask, result;
result = 0;

heap_mask = flags & HEAP_MASK_FILTER;

switch(heap_mask) {
case MHB_ION_HEAP_SYSTEM_MASK:
return ION_HEAP_SYSTEM_MASK;
case MHB_ION_HEAP_SYSTEM_CONTIG_MASK:
return ION_HEAP_SYSTEM_CONTIG_MASK;
case MHB_ION_HEAP_EXYNOS_CONTIG_MASK:
return ION_HEAP_EXYNOS_CONTIG_MASK;
case MHB_ION_HEAP_EXYNOS_MASK:
return ION_HEAP_EXYNOS_MASK;
default:
ALOGE("MemoryHeapIon : Heap Mask flag is default (flags:%x)", flags);
return 0;
break;
}
ALOGE("MemoryHeapIon : Heap Mask flag is wrong (flags:%x)", flags);
return 0;
}

uint32_t ion_FlagMask_valid_check(uint32_t flags)
{
uint32_t flag_mask, result;
result = 0;

flag_mask = flags & FLAG_MASK_FILTER;

if (flag_mask & MHB_ION_FLAG_CACHED)
result |= ION_FLAG_CACHED;
if (flag_mask & MHB_ION_FLAG_CACHED_NEEDS_SYNC)
result |= ION_FLAG_CACHED_NEEDS_SYNC;
if (flag_mask & MHB_ION_FLAG_PRESERVE_KMAP)
result |= ION_FLAG_PRESERVE_KMAP;
if (flag_mask & MHB_ION_EXYNOS_VIDEO_MASK)
result |= ION_EXYNOS_VIDEO_MASK;
if (flag_mask & MHB_ION_EXYNOS_MFC_INPUT_MASK)
result |= ION_EXYNOS_MFC_INPUT_MASK;
if (flag_mask & MHB_ION_EXYNOS_MFC_OUTPUT_MASK)
result |= ION_EXYNOS_MFC_OUTPUT_MASK;
if (flag_mask & MHB_ION_EXYNOS_GSC_MASK)
result |= ION_EXYNOS_GSC_MASK;
if (flag_mask & MHB_ION_EXYNOS_FIMD_VIDEO_MASK)
result |= ION_EXYNOS_FIMD_VIDEO_MASK;

return result;
}

MemoryHeapIon::MemoryHeapIon(size_t size, uint32_t flags, char const *name):MemoryHeapBase()
{
void* base = NULL;
int fd = -1;
uint32_t isReadOnly, heapMask, flagMask;

mIonClient = ion_client_create();

if (mIonClient < 0) {
ALOGE("MemoryHeapIon : ION client creation failed : %s", strerror(errno));
mIonClient = -1;
} else {
fd = ion_alloc(mIonClient, size, 0, ION_HEAP_SYSTEM_MASK, ION_FLAG_CACHED | ION_FLAG_CACHED_NEEDS_SYNC | ION_FLAG_PRESERVE_KMAP);
isReadOnly = flags & (IMemoryHeap::READ_ONLY);
heapMask = ion_HeapMask_valid_check(flags);
flagMask = ion_FlagMask_valid_check(flags);

if (heapMask) {
ALOGD("MemoryHeapIon : Allocated with size:%d, heap:0x%X , flag:0x%X", size, heapMask, flagMask);
fd = ion_alloc(mIonClient, size, 0, heapMask, flagMask);
if (fd < 0) {
ALOGE("MemoryHeapIon : ION Reserve memory allocation failed(size[%u]) : %s", size, strerror(errno));
if (errno == ENOMEM) { // Out of reserve memory. So re-try allocating in system heap
ALOGD("MemoryHeapIon : Re-try Allocating in default heap - SYSTEM heap");
fd = ion_alloc(mIonClient, size, 0, ION_HEAP_SYSTEM_MASK, ION_FLAG_CACHED | ION_FLAG_CACHED_NEEDS_SYNC | ION_FLAG_PRESERVE_KMAP);
}
}
} else {
fd = ion_alloc(mIonClient, size, 0, ION_HEAP_SYSTEM_MASK, ION_FLAG_CACHED | ION_FLAG_CACHED_NEEDS_SYNC | ION_FLAG_PRESERVE_KMAP);
ALOGD("MemoryHeapIon : Allocated with default heap - SYSTEM heap");
}

flags = isReadOnly | heapMask | flagMask;

if (fd < 0) {
ALOGE("MemoryHeapIon : ION memory allocation failed(size[%u]) : %s", size, strerror(errno));
} else {
Expand All @@ -63,7 +139,7 @@ MemoryHeapIon::MemoryHeapIon(size_t size, uint32_t flags, char const *name):Memo
if (base != MAP_FAILED) {
init(fd, base, size, flags, NULL);
} else {
ALOGE("MemoryHeapIon : mmap failed(size[%u], fd[%d]) : %s", size, fd, strerror(errno));
ALOGE("MemoryHeapIon : ION mmap failed(size[%u], fd[%d]) : %s", size, fd, strerror(errno));
ion_free(fd);
}
}
Expand Down
8 changes: 6 additions & 2 deletions libs/gui/Surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,9 @@ int Surface::queueBuffer(android_native_buffer_t* buffer, int fenceFd) {
&numPendingBuffers);

mConsumerRunningBehind = (numPendingBuffers >= 2);

#ifdef QCOM_BSP
mDirtyRect.clear();
#endif
return err;
}

Expand Down Expand Up @@ -877,7 +879,9 @@ status_t Surface::lock(

{ // scope for the lock
Mutex::Autolock lock(mMutex);
mSlots[backBufferSlot].dirtyRegion = newDirtyRegion;
if (backBufferSlot >= 0) {
mSlots[backBufferSlot].dirtyRegion = newDirtyRegion;
}
}

if (inOutDirtyBounds) {
Expand Down
5 changes: 4 additions & 1 deletion libs/gui/SurfaceControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@ status_t SurfaceControl::writeSurfaceToParcel(
if (control != NULL) {
bp = control->mGraphicBufferProducer;
}
return parcel->writeStrongBinder(bp->asBinder());
if (bp != NULL) {
return parcel->writeStrongBinder(bp->asBinder());
}
return NO_INIT;
}

sp<Surface> SurfaceControl::getSurface() const
Expand Down
4 changes: 3 additions & 1 deletion libs/ui/Region.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,9 @@ SharedBuffer const* Region::getSharedBuffer(size_t* count) const {
size_t numRects = isRect() ? 1 : mStorage.size() - 1;
count[0] = numRects;
}
sb->acquire();
if (sb != NULL) {
sb->acquire();
}
return sb;
}

Expand Down
8 changes: 8 additions & 0 deletions opengl/libs/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ endif
ifeq ($(TARGET_BOARD_PLATFORM), omap4)
LOCAL_CFLAGS += -DWORKAROUND_BUG_10194508=1
endif
ifeq ($(BOARD_EGL_SYSTEMUI_PBSIZE_HACK),true)
# see Loader.cpp for details
LOCAL_CFLAGS += -DSYSTEMUI_PBSIZE_HACK=1
endif
ifeq ($(BOARD_EGL_WORKAROUND_BUG_10194508),true)
LOCAL_CFLAGS += -DWORKAROUND_BUG_10194508=1
endif
Expand All @@ -66,6 +70,10 @@ ifneq ($(MAX_EGL_CACHE_SIZE),)
LOCAL_CFLAGS += -DMAX_EGL_CACHE_SIZE=$(MAX_EGL_CACHE_SIZE)
endif

ifeq ($(BOARD_USE_BGRA_8888),true)
LOCAL_CFLAGS += -DUSE_BGRA_8888=1
endif

LOCAL_REQUIRED_MODULES := $(egl.cfg_config_module)
egl.cfg_config_module :=

Expand Down
29 changes: 29 additions & 0 deletions opengl/libs/EGL/Loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,35 @@ void *Loader::load_driver(const char* kind,
ALOGE_IF(!getProcAddress,
"can't find eglGetProcAddress() in %s", driver_absolute_path);

#ifdef SYSTEMUI_PBSIZE_HACK
#warning "SYSTEMUI_PBSIZE_HACK enabled"
/*
* TODO: replace SYSTEMUI_PBSIZE_HACK by something less hackish
*
* Here we adjust the PB size from its default value to 512KB which
* is the minimum acceptable for the systemui process.
* We do this on low-end devices only because it allows us to enable
* h/w acceleration in the systemui process while keeping the
* memory usage down.
*
* Obviously, this is the wrong place and wrong way to make this
* adjustment, but at the time of this writing this was the safest
* solution.
*/
const char *cmdline = getProcessCmdline();
if (strstr(cmdline, "systemui")) {
void *imgegl = dlopen("/vendor/lib/libIMGegl.so", RTLD_LAZY);
if (imgegl) {
unsigned int *PVRDefaultPBS =
(unsigned int *)dlsym(imgegl, "PVRDefaultPBS");
if (PVRDefaultPBS) {
ALOGD("setting default PBS to 512KB, was %d KB", *PVRDefaultPBS / 1024);
*PVRDefaultPBS = 512*1024;
}
}
}
#endif

egl_t* egl = &cnx->egl;
__eglMustCastToProperFunctionPointerType* curr =
(__eglMustCastToProperFunctionPointerType*)egl;
Expand Down
8 changes: 8 additions & 0 deletions opengl/libs/EGL/eglApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,13 +460,21 @@ EGLSurface eglCreateWindowSurface( EGLDisplay dpy, EGLConfig config,
}
#else
// by default, just pick RGBA_8888
#ifdef USE_BGRA_8888
EGLint format = HAL_PIXEL_FORMAT_BGRA_8888;
#else
EGLint format = HAL_PIXEL_FORMAT_RGBA_8888;
#endif

EGLint a = 0;
cnx->egl.eglGetConfigAttrib(iDpy, config, EGL_ALPHA_SIZE, &a);
if (a > 0) {
// alpha-channel requested, there's really only one suitable format
#ifdef USE_BGRA_8888
format = HAL_PIXEL_FORMAT_BGRA_8888;
#else
format = HAL_PIXEL_FORMAT_RGBA_8888;
#endif
} else {
EGLint r, g, b;
r = g = b = 0;
Expand Down
6 changes: 6 additions & 0 deletions services/surfaceflinger/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,15 @@ endif
ifeq ($(TARGET_USES_QCOM_BSP), true)
ifneq ($(TARGET_QCOM_DISPLAY_VARIANT),)
LOCAL_C_INCLUDES += hardware/qcom/display-$(TARGET_QCOM_DISPLAY_VARIANT)/libgralloc
LOCAL_C_INCLUDES += hardware/qcom/display-$(TARGET_QCOM_DISPLAY_VARIANT)/libqdutils
ifeq ($(TARGET_QCOM_DISPLAY_VARIANT),caf-new)
LOCAL_CFLAGS += -DQCOM_B_FAMILY
endif
else
LOCAL_C_INCLUDES += hardware/qcom/display/$(TARGET_BOARD_PLATFORM)/libgralloc
LOCAL_C_INCLUDES += hardware/qcom/display/$(TARGET_BOARD_PLATFORM)/libqdutils
endif
LOCAL_SHARED_LIBRARIES += libqdutils
LOCAL_CFLAGS += -DQCOM_BSP
endif

Expand Down
14 changes: 13 additions & 1 deletion services/surfaceflinger/DisplayDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,14 @@ DisplayDevice::DisplayDevice(
mDisplayName = "Virtual Screen"; // e.g. Overlay #n
break;
}
char property[PROPERTY_VALUE_MAX];
int panelOrientation = DisplayState::eOrientationDefault;
// Set the panel orientation from the property.
property_get("persist.panel.orientation", property, "0");
panelOrientation = atoi(property) / 90;

// initialize the display orientation transform.
setProjection(DisplayState::eOrientationDefault, mViewport, mFrame);
setProjection(panelOrientation, mViewport, mFrame);
}

DisplayDevice::~DisplayDevice() {
Expand All @@ -141,6 +146,13 @@ DisplayDevice::~DisplayDevice() {
}
}

#ifdef QCOM_BSP
void DisplayDevice::eglSwapPreserved(bool enable) const {
int swapValue = enable ? EGL_BUFFER_PRESERVED : EGL_BUFFER_DESTROYED;
eglSurfaceAttrib(mDisplay, mSurface, EGL_SWAP_BEHAVIOR, swapValue);
}
#endif

void DisplayDevice::disconnect(HWComposer& hwc) {
if (mHwcDisplayId >= 0) {
hwc.disconnectDisplay(mHwcDisplayId);
Expand Down
6 changes: 6 additions & 0 deletions services/surfaceflinger/DisplayDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ class DisplayDevice : public LightRefBase<DisplayDevice>
void dump(String8& result) const;
int getHardwareOrientation();

#ifdef QCOM_BSP
/* To set egl atribute, EGL_SWAP_BEHAVIOR value
* (EGL_BUFFER_PRESERVED/EGL_BUFFER_DESTROYED)
*/
void eglSwapPreserved(bool status) const;
#endif
private:
/*
* Constants, set during initialization
Expand Down
Loading

0 comments on commit ed0b230

Please sign in to comment.