Display: Use new APIs for pmem in overlay
Change-Id: I021abfd4500c5cf24891e2b7e4335d65033b8b50
This commit is contained in:
parent
ef62685ddd
commit
7f94fa6694
@ -18,7 +18,7 @@ LOCAL_PATH := $(call my-dir)
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_PRELINK_MODULE := false
|
||||
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)
|
||||
LOCAL_SHARED_LIBRARIES := liblog libcutils libutils
|
||||
LOCAL_SHARED_LIBRARIES := liblog libcutils libutils libmemalloc
|
||||
LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
|
||||
LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
|
||||
LOCAL_C_INCLUDES += hardware/qcom/display/libgralloc
|
||||
@ -27,11 +27,6 @@ LOCAL_SRC_FILES := \
|
||||
overlayLibUI.cpp \
|
||||
LOCAL_CFLAGS:= -DLOG_TAG=\"OverlayLib\"
|
||||
|
||||
ifeq ($(TARGET_USES_ION),true)
|
||||
LOCAL_CFLAGS += -DUSE_ION
|
||||
LOCAL_SHARED_LIBRARIES += libmemalloc
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET_USE_HDMI_AS_PRIMARY),true)
|
||||
LOCAL_CFLAGS += -DHDMI_AS_PRIMARY
|
||||
endif
|
||||
|
@ -1395,9 +1395,10 @@ bool OverlayControlChannel::getSize(int& size) const {
|
||||
OverlayDataChannel::OverlayDataChannel() : mNoRot(false), mFD(-1), mRotFD(-1),
|
||||
mPmemFD(-1), mPmemAddr(0), mUpdateDataChannel(0)
|
||||
{
|
||||
#ifdef USE_ION
|
||||
mAlloc = gralloc::IAllocController::getInstance();
|
||||
#endif
|
||||
//XXX: getInstance(false) implies that it should only
|
||||
// use the kernel allocator. Change it to something
|
||||
// more descriptive later.
|
||||
mAlloc = gralloc::IAllocController::getInstance(false);
|
||||
}
|
||||
|
||||
OverlayDataChannel::~OverlayDataChannel() {
|
||||
@ -1453,7 +1454,6 @@ bool OverlayDataChannel::mapRotatorMemory(int num_buffers, bool uiChannel, int r
|
||||
{
|
||||
mPmemAddr = MAP_FAILED;
|
||||
|
||||
#ifdef USE_ION
|
||||
alloc_data data;
|
||||
data.base = 0;
|
||||
data.fd = -1;
|
||||
@ -1462,10 +1462,13 @@ bool OverlayDataChannel::mapRotatorMemory(int num_buffers, bool uiChannel, int r
|
||||
data.align = getpagesize();
|
||||
data.uncached = true;
|
||||
|
||||
int err = mAlloc->allocate(data, GRALLOC_USAGE_PRIVATE_ADSP_HEAP|
|
||||
GRALLOC_USAGE_PRIVATE_SMI_HEAP, 0);
|
||||
int allocFlags = GRALLOC_USAGE_PRIVATE_ADSP_HEAP;
|
||||
if((requestType == NEW_REQUEST) && !uiChannel)
|
||||
allocFlags |= GRALLOC_USAGE_PRIVATE_SMI_HEAP;
|
||||
|
||||
int err = mAlloc->allocate(data, allocFlags, 0);
|
||||
if(err) {
|
||||
reportError("Cant allocate from ION");
|
||||
reportError("Cant allocate rotatory memory");
|
||||
close(mFD);
|
||||
mFD = -1;
|
||||
close(mRotFD);
|
||||
@ -1475,40 +1478,7 @@ bool OverlayDataChannel::mapRotatorMemory(int num_buffers, bool uiChannel, int r
|
||||
mPmemFD = data.fd;
|
||||
mPmemAddr = data.base;
|
||||
mBufferType = data.allocType;
|
||||
#else
|
||||
|
||||
if((requestType == NEW_REQUEST) && !uiChannel) {
|
||||
mPmemFD = open("/dev/pmem_smipool", O_RDWR | O_SYNC);
|
||||
if(mPmemFD >= 0)
|
||||
mPmemAddr = (void *) mmap(NULL, mPmemOffset * num_buffers, PROT_READ | PROT_WRITE,
|
||||
MAP_SHARED, mPmemFD, 0);
|
||||
}
|
||||
|
||||
if (mPmemAddr == MAP_FAILED) {
|
||||
mPmemFD = open("/dev/pmem_adsp", O_RDWR | O_SYNC);
|
||||
if (mPmemFD < 0) {
|
||||
reportError("Cant open pmem_adsp ");
|
||||
close(mFD);
|
||||
mFD = -1;
|
||||
close(mRotFD);
|
||||
mRotFD = -1;
|
||||
return false;
|
||||
} else {
|
||||
mPmemAddr = (void *) mmap(NULL, mPmemOffset * num_buffers, PROT_READ | PROT_WRITE,
|
||||
MAP_SHARED, mPmemFD, 0);
|
||||
if (mPmemAddr == MAP_FAILED) {
|
||||
reportError("Cant map pmem_adsp ");
|
||||
close(mFD);
|
||||
mFD = -1;
|
||||
close(mPmemFD);
|
||||
mPmemFD = -1;
|
||||
close(mRotFD);
|
||||
mRotFD = -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// Set this flag if source memory is fb
|
||||
if(uiChannel)
|
||||
mRotData.src.flags |= MDP_MEMORY_ID_TYPE_FB;
|
||||
@ -1553,13 +1523,8 @@ bool OverlayDataChannel::closeDataChannel() {
|
||||
return true;
|
||||
|
||||
if (!mNoRot && mRotFD > 0) {
|
||||
#ifdef USE_ION
|
||||
sp<IMemAlloc> memalloc = mAlloc->getAllocator(mBufferType);
|
||||
memalloc->free_buffer(mPmemAddr, mPmemOffset * mNumBuffers, 0, mPmemFD);
|
||||
#else
|
||||
munmap(mPmemAddr, mPmemOffset * mNumBuffers);
|
||||
close(mPmemFD);
|
||||
#endif
|
||||
close(mPmemFD);
|
||||
mPmemFD = -1;
|
||||
close(mRotFD);
|
||||
@ -1612,14 +1577,8 @@ bool OverlayDataChannel::queueBuffer(uint32_t offset) {
|
||||
|
||||
// Unmap the old PMEM memory after the queueBuffer has returned
|
||||
if (oldPmemFD != -1 && oldPmemAddr != MAP_FAILED) {
|
||||
#ifdef USE_ION
|
||||
sp<IMemAlloc> memalloc = mAlloc->getAllocator(mBufferType);
|
||||
memalloc->free_buffer(oldPmemAddr, oldPmemOffset * mNumBuffers, 0, oldPmemFD);
|
||||
#else
|
||||
munmap(oldPmemAddr, oldPmemOffset * mNumBuffers);
|
||||
close(oldPmemFD);
|
||||
#endif
|
||||
|
||||
oldPmemFD = -1;
|
||||
}
|
||||
return result;
|
||||
|
@ -302,6 +302,16 @@ status_t OVHelper::getOVInfo(mdp_overlay& ovInfo) {
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
Rotator::Rotator() : mFD(NO_INIT), mSessionID(NO_INIT), mPmemFD(-1)
|
||||
{
|
||||
mAlloc = gralloc::IAllocController::getInstance(false);
|
||||
}
|
||||
|
||||
Rotator::~Rotator()
|
||||
{
|
||||
closeRotSession();
|
||||
}
|
||||
|
||||
status_t Rotator::startRotSession(msm_rotator_img_info& rotInfo,
|
||||
int size, int numBuffers) {
|
||||
status_t ret = ALREADY_EXISTS;
|
||||
@ -319,7 +329,7 @@ status_t Rotator::startRotSession(msm_rotator_img_info& rotInfo,
|
||||
return NO_INIT;
|
||||
}
|
||||
|
||||
#ifdef USE_ION
|
||||
mSessionID = rotInfo.session_id;
|
||||
alloc_data data;
|
||||
data.base = 0;
|
||||
data.fd = -1;
|
||||
@ -328,33 +338,16 @@ status_t Rotator::startRotSession(msm_rotator_img_info& rotInfo,
|
||||
data.align = getpagesize();
|
||||
data.uncached = true;
|
||||
|
||||
int err = mAlloc->allocate(data, GRALLOC_USAGE_PRIVATE_ADSP_HEAP|
|
||||
GRALLOC_USAGE_PRIVATE_SMI_HEAP, 0);
|
||||
int err = mAlloc->allocate(data, GRALLOC_USAGE_PRIVATE_SMI_HEAP, 0);
|
||||
|
||||
if(err) {
|
||||
LOGE("Cant allocate from ION");
|
||||
LOGE("%s: Can't allocate rotator memory", __func__);
|
||||
closeRotSession();
|
||||
return NO_INIT;
|
||||
}
|
||||
mPmemFD = data.fd;
|
||||
mPmemAddr = data.base;
|
||||
mBufferType = data.allocType;
|
||||
#else
|
||||
mSessionID = rotInfo.session_id;
|
||||
mPmemFD = open("/dev/pmem_adsp", O_RDWR | O_SYNC);
|
||||
if (mPmemFD < 0) {
|
||||
closeRotSession();
|
||||
return NO_INIT;
|
||||
}
|
||||
|
||||
mSize = size;
|
||||
mPmemAddr = (void *) mmap(NULL, mSize* mNumBuffers, PROT_READ | PROT_WRITE,
|
||||
MAP_SHARED, mPmemFD, 0);
|
||||
if (mPmemAddr == MAP_FAILED) {
|
||||
closeRotSession();
|
||||
return NO_INIT;
|
||||
}
|
||||
#endif
|
||||
|
||||
mCurrentItem = 0;
|
||||
for (int i = 0; i < mNumBuffers; i++)
|
||||
@ -369,13 +362,8 @@ status_t Rotator::closeRotSession() {
|
||||
if (mSessionID != NO_INIT && mFD != NO_INIT) {
|
||||
ioctl(mFD, MSM_ROTATOR_IOCTL_FINISH, &mSessionID);
|
||||
close(mFD);
|
||||
#ifdef USE_ION
|
||||
sp<IMemAlloc> memalloc = mAlloc->getAllocator(mBufferType);
|
||||
memalloc->free_buffer(mPmemAddr, mSize * mNumBuffers, 0, mPmemFD);
|
||||
#else
|
||||
munmap(mPmemAddr, mSize * mNumBuffers);
|
||||
close(mPmemFD);
|
||||
#endif
|
||||
close(mPmemFD);
|
||||
}
|
||||
|
||||
|
@ -107,13 +107,8 @@ class Rotator {
|
||||
Rotator& operator=(const Rotator& objRotator);
|
||||
|
||||
public:
|
||||
explicit Rotator() : mFD(NO_INIT), mSessionID(NO_INIT), mPmemFD(-1)
|
||||
{
|
||||
#ifdef USE_ION
|
||||
mAlloc = gralloc::IAllocController::getInstance();
|
||||
#endif
|
||||
}
|
||||
~Rotator() { closeRotSession(); }
|
||||
explicit Rotator();
|
||||
~Rotator();
|
||||
status_t startRotSession(msm_rotator_img_info& rotInfo, int size,
|
||||
int numBuffers = max_num_buffers);
|
||||
status_t closeRotSession();
|
||||
|
Loading…
x
Reference in New Issue
Block a user