overlay: Enable ION for rotator
Change-Id: I08f1cd0f8d49812ba8723a137913e386365c946a
This commit is contained in:
parent
049cef0c8c
commit
b4684bce38
@ -19,14 +19,20 @@ LOCAL_PATH := $(call my-dir)
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_PRELINK_MODULE := false
|
||||
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)
|
||||
LOCAL_SHARED_LIBRARIES := liblog libcutils
|
||||
LOCAL_SHARED_LIBRARIES := liblog libcutils libutils
|
||||
LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
|
||||
LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
|
||||
LOCAL_C_INCLUDES += hardware/msm7k/libgralloc-qsd8k
|
||||
LOCAL_C_INCLUDES += hardware/qcom/display/libgralloc
|
||||
LOCAL_SRC_FILES := \
|
||||
overlayLib.cpp \
|
||||
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
|
||||
@ -41,7 +47,7 @@ LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
|
||||
LOCAL_SHARED_LIBRARIES := liblog liboverlay libcutils
|
||||
LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
|
||||
LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
|
||||
LOCAL_C_INCLUDES += hardware/msm7k/libgralloc-qsd8k
|
||||
LOCAL_C_INCLUDES += hardware/qcom/display/libgralloc
|
||||
LOCAL_SRC_FILES := overlay.cpp
|
||||
LOCAL_MODULE := overlay.default
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
@ -26,6 +26,10 @@ static inline size_t ALIGN(size_t x, size_t align) {
|
||||
}
|
||||
|
||||
using namespace overlay;
|
||||
using android::sp;
|
||||
using gralloc::IMemAlloc;
|
||||
using gralloc::IonController;
|
||||
using gralloc::alloc_data;
|
||||
|
||||
#ifdef HDMI_AS_PRIMARY
|
||||
bool Overlay::sHDMIAsPrimary = true;
|
||||
@ -1406,7 +1410,11 @@ bool OverlayControlChannel::getSize(int& size) const {
|
||||
}
|
||||
|
||||
OverlayDataChannel::OverlayDataChannel() : mNoRot(false), mFD(-1), mRotFD(-1),
|
||||
mPmemFD(-1), mPmemAddr(0), mUpdateDataChannel(0) {
|
||||
mPmemFD(-1), mPmemAddr(0), mUpdateDataChannel(0)
|
||||
{
|
||||
#ifdef USE_ION
|
||||
mAlloc = gralloc::IAllocController::getInstance();
|
||||
#endif
|
||||
}
|
||||
|
||||
OverlayDataChannel::~OverlayDataChannel() {
|
||||
@ -1462,6 +1470,30 @@ 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;
|
||||
data.offset = 0;
|
||||
data.size = mPmemOffset * num_buffers;
|
||||
data.align = getpagesize();
|
||||
data.uncached = true;
|
||||
|
||||
int err = mAlloc->allocate(data, GRALLOC_USAGE_PRIVATE_ADSP_HEAP|
|
||||
GRALLOC_USAGE_PRIVATE_SMI_HEAP, 0);
|
||||
if(err) {
|
||||
reportError("Cant allocate from ION");
|
||||
close(mFD);
|
||||
mFD = -1;
|
||||
close(mRotFD);
|
||||
mRotFD = -1;
|
||||
return false;
|
||||
}
|
||||
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)
|
||||
@ -1493,6 +1525,7 @@ bool OverlayDataChannel::mapRotatorMemory(int num_buffers, bool uiChannel, int r
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// Set this flag if source memory is fb
|
||||
if(uiChannel)
|
||||
mRotData.src.flags |= MDP_MEMORY_ID_TYPE_FB;
|
||||
@ -1537,8 +1570,13 @@ 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);
|
||||
@ -1591,8 +1629,14 @@ 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;
|
||||
|
@ -40,6 +40,9 @@
|
||||
#include <sys/mman.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <hardware/overlay.h>
|
||||
#include <utils/RefBase.h>
|
||||
#include <alloc_controller.h>
|
||||
#include <memalloc.h>
|
||||
|
||||
#define HW_OVERLAY_MAGNIFICATION_LIMIT 8
|
||||
#define HW_OVERLAY_MINIFICATION_LIMIT HW_OVERLAY_MAGNIFICATION_LIMIT
|
||||
@ -215,6 +218,8 @@ class OverlayDataChannel {
|
||||
int mCurrentItem;
|
||||
int mNumBuffers;
|
||||
int mUpdateDataChannel;
|
||||
android::sp<gralloc::IAllocController> mAlloc;
|
||||
int mBufferType;
|
||||
|
||||
bool openDevices(int fbnum = -1, bool uichannel = false, int num_buffers = 2);
|
||||
bool mapRotatorMemory(int num_buffers, bool uiChannel, int requestType);
|
||||
|
@ -19,6 +19,10 @@
|
||||
#include "gralloc_priv.h"
|
||||
#define LOG_TAG "OverlayUI"
|
||||
|
||||
using android::sp;
|
||||
using gralloc::IMemAlloc;
|
||||
using gralloc::alloc_data;
|
||||
|
||||
namespace {
|
||||
/* helper functions */
|
||||
bool checkOVState(int w, int h, int format, int orientation,
|
||||
@ -315,6 +319,27 @@ status_t Rotator::startRotSession(msm_rotator_img_info& rotInfo,
|
||||
return NO_INIT;
|
||||
}
|
||||
|
||||
#ifdef USE_ION
|
||||
alloc_data data;
|
||||
data.base = 0;
|
||||
data.fd = -1;
|
||||
data.offset = 0;
|
||||
data.size = mSize * mNumBuffers;
|
||||
data.align = getpagesize();
|
||||
data.uncached = true;
|
||||
|
||||
int err = mAlloc->allocate(data, GRALLOC_USAGE_PRIVATE_ADSP_HEAP|
|
||||
GRALLOC_USAGE_PRIVATE_SMI_HEAP, 0);
|
||||
|
||||
if(err) {
|
||||
LOGE("Cant allocate from ION");
|
||||
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) {
|
||||
@ -329,6 +354,7 @@ status_t Rotator::startRotSession(msm_rotator_img_info& rotInfo,
|
||||
closeRotSession();
|
||||
return NO_INIT;
|
||||
}
|
||||
#endif
|
||||
|
||||
mCurrentItem = 0;
|
||||
for (int i = 0; i < mNumBuffers; i++)
|
||||
@ -343,8 +369,14 @@ 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);
|
||||
}
|
||||
|
||||
mFD = NO_INIT;
|
||||
|
@ -101,11 +101,18 @@ class Rotator {
|
||||
int mCurrentItem;
|
||||
int mNumBuffers;
|
||||
int mSize;
|
||||
android::sp<gralloc::IAllocController> mAlloc;
|
||||
int mBufferType;
|
||||
Rotator(const Rotator& objROtator);
|
||||
Rotator& operator=(const Rotator& objRotator);
|
||||
|
||||
public:
|
||||
explicit Rotator() : mFD(NO_INIT), mSessionID(NO_INIT), mPmemFD(-1) { };
|
||||
explicit Rotator() : mFD(NO_INIT), mSessionID(NO_INIT), mPmemFD(-1)
|
||||
{
|
||||
#ifdef USE_ION
|
||||
mAlloc = gralloc::IAllocController::getInstance();
|
||||
#endif
|
||||
}
|
||||
~Rotator() { closeRotSession(); }
|
||||
status_t startRotSession(msm_rotator_img_info& rotInfo, int size,
|
||||
int numBuffers = max_num_buffers);
|
||||
|
Loading…
x
Reference in New Issue
Block a user