summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcodeworkx <codeworkx@cyanogenmod.org>2012-12-01 18:45:44 +0100
committercodeworkx <codeworkx@cyanogenmod.org>2012-12-01 18:45:44 +0100
commit1030fe0ae8322353c0e376c7ecfbd0db32636668 (patch)
treedcc37f59df605b953f35ea1963786971c6e2e3fa
parentd573d9b5a18cb47ed2b091099872790ae59bfffa (diff)
downloadhardware_samsung-1030fe0ae8322353c0e376c7ecfbd0db32636668.zip
hardware_samsung-1030fe0ae8322353c0e376c7ecfbd0db32636668.tar.gz
hardware_samsung-1030fe0ae8322353c0e376c7ecfbd0db32636668.tar.bz2
exynos4: update gralloc from insignal, modify it to work with libsecion
-rw-r--r--exynos4/hal/include/gralloc_priv.h11
-rw-r--r--exynos4/hal/libgralloc_ump/Android.mk7
-rw-r--r--exynos4/hal/libgralloc_ump/alloc_device.cpp36
-rw-r--r--exynos4/hal/libgralloc_ump/framebuffer_device.cpp16
-rw-r--r--exynos4/hal/libgralloc_ump/gralloc_module.cpp4
5 files changed, 54 insertions, 20 deletions
diff --git a/exynos4/hal/include/gralloc_priv.h b/exynos4/hal/include/gralloc_priv.h
index 871a84f..8ffd161 100644
--- a/exynos4/hal/include/gralloc_priv.h
+++ b/exynos4/hal/include/gralloc_priv.h
@@ -47,17 +47,6 @@
#define GRALLOC_ARM_UMP_MODULE 1
-enum {
- /* SEC Private usage , for HWC to set HDMI S3D format */
- /* HDMI should display this buffer as S3D SBS LR/RL*/
- GRALLOC_USAGE_PRIVATE_SBS_LR = 0x00400000,
- GRALLOC_USAGE_PRIVATE_SBS_RL = 0x00200000,
-
- /* HDMI should display this buffer as 3D TB LR/RL*/
- GRALLOC_USAGE_PRIVATE_TB_LR = 0x00100000,
- GRALLOC_USAGE_PRIVATE_TB_RL = 0x00080000,
-};
-
struct private_handle_t;
struct private_module_t {
diff --git a/exynos4/hal/libgralloc_ump/Android.mk b/exynos4/hal/libgralloc_ump/Android.mk
index 005c817..9fa7352 100644
--- a/exynos4/hal/libgralloc_ump/Android.mk
+++ b/exynos4/hal/libgralloc_ump/Android.mk
@@ -26,7 +26,7 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_PRELINK_MODULE := false
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
-LOCAL_SHARED_LIBRARIES := liblog libcutils libUMP libGLESv1_CM libsamsungion
+LOCAL_SHARED_LIBRARIES := liblog libcutils libUMP libGLESv1_CM libsecion
# Include the UMP header files
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../include
@@ -36,8 +36,9 @@ LOCAL_SRC_FILES := \
alloc_device.cpp \
framebuffer_device.cpp
-LOCAL_MODULE_TAGS := eng
-LOCAL_MODULE := gralloc.$(TARGET_DEVICE)
+LOCAL_MODULE := gralloc.$(TARGET_BOARD_PLATFORM)
+LOCAL_MODULE_TAGS := optional
+
LOCAL_CFLAGS:= -DLOG_TAG=\"gralloc\" -DGRALLOC_32_BITS -DSTANDARD_LINUX_SCREEN
#LOCAL_CFLAGS+= -DMALI_VSYNC_EVENT_REPORT_ENABLE
diff --git a/exynos4/hal/libgralloc_ump/alloc_device.cpp b/exynos4/hal/libgralloc_ump/alloc_device.cpp
index 953f017..42a14e7 100644
--- a/exynos4/hal/libgralloc_ump/alloc_device.cpp
+++ b/exynos4/hal/libgralloc_ump/alloc_device.cpp
@@ -80,6 +80,9 @@
#define OMX_COLOR_FormatYUV420SemiPlanar 0x15
#endif
+#define PFX_NODE_MEM "/dev/exynos-mem"
+static int gMemfd = 0;
+
bool ion_dev_open = true;
static pthread_mutex_t l_surface= PTHREAD_MUTEX_INITIALIZER;
static int buffer_offset = 0;
@@ -152,6 +155,19 @@ static int gralloc_alloc_buffer(alloc_device_t* dev, size_t size, int usage,
hnd->voffset = (EXYNOS4_ALIGN((EXYNOS4_ALIGN((hnd->width >> 1), 16) * EXYNOS4_ALIGN((hnd->height >> 1), 16)), 4096));
buffer_offset += size;
+ if (gMemfd == 0) {
+ gMemfd = open(PFX_NODE_MEM, O_RDWR);
+ if (gMemfd < 0) {
+ ALOGE("%s:: %s exynos-mem open error\n", __func__, PFX_NODE_MEM);
+ return false;
+ }
+ }
+
+ size_t size = FIMC1_RESERVED_SIZE * 1024;
+
+ void *mappedAddress = mmap(0, size,
+ PROT_READ|PROT_WRITE, MAP_SHARED, gMemfd, (hnd->paddr - hnd->offset));
+ hnd->base = intptr_t(mappedAddress) + hnd->offset;
return 0;
} else {
ion_buffer ion_fd = 0;
@@ -229,8 +245,13 @@ static int gralloc_alloc_buffer(alloc_device_t* dev, size_t size, int usage,
hnd->height = h;
hnd->bpp = bpp;
hnd->stride = stride;
- hnd->uoffset = ((EXYNOS4_ALIGN(hnd->width, 16) * EXYNOS4_ALIGN(hnd->height, 16)));
- hnd->voffset = ((EXYNOS4_ALIGN((hnd->width >> 1), 16) * EXYNOS4_ALIGN((hnd->height >> 1), 16)));
+ if(hnd->format == HAL_PIXEL_FORMAT_YV12) {
+ hnd->uoffset = ((EXYNOS4_ALIGN(hnd->width, 16) * hnd->height));
+ hnd->voffset = ((EXYNOS4_ALIGN((hnd->width >> 1), 16) * (hnd->height >> 1)));
+ } else {
+ hnd->uoffset = ((EXYNOS4_ALIGN(hnd->width, 16) * EXYNOS4_ALIGN(hnd->height, 16)));
+ hnd->voffset = ((EXYNOS4_ALIGN((hnd->width >> 1), 16) * EXYNOS4_ALIGN((hnd->height >> 1), 16)));
+ }
return 0;
} else {
ALOGE("gralloc_alloc_buffer() failed to allocate handle");
@@ -355,7 +376,7 @@ static int alloc_device_alloc(alloc_device_t* dev, int w, int h, int format,
case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP_TILED:
case OMX_COLOR_FormatYUV420Planar:
case OMX_COLOR_FormatYUV420SemiPlanar:
- size = stride * vstride * 2;
+ size = stride * vstride + EXYNOS4_ALIGN((w / 2), 16) * EXYNOS4_ALIGN((h / 2), 16) * 2;
if(usage & GRALLOC_USAGE_HW_FIMC1)
size += PAGE_SIZE * 2;
break;
@@ -424,6 +445,15 @@ static int alloc_device_free(alloc_device_t* dev, buffer_handle_t handle)
int index = (hnd->base - m->framebuffer->base) / bufferSize;
m->bufferMask &= ~(1<<index);
close(hnd->fd);
+ } else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_IOCTL) {
+ void* base = (void*)(intptr_t(hnd->base) - hnd->offset);
+ size_t size = FIMC1_RESERVED_SIZE * 1024;
+ if (munmap(base, size) < 0)
+ ALOGE("Could not unmap %s", strerror(errno));
+ if (0 < gMemfd) {
+ close(gMemfd);
+ gMemfd = 0;
+ }
} else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_UMP) {
#ifdef USE_PARTIAL_FLUSH
if (!release_rect((int)hnd->ump_id))
diff --git a/exynos4/hal/libgralloc_ump/framebuffer_device.cpp b/exynos4/hal/libgralloc_ump/framebuffer_device.cpp
index 03c2606..2059af8 100644
--- a/exynos4/hal/libgralloc_ump/framebuffer_device.cpp
+++ b/exynos4/hal/libgralloc_ump/framebuffer_device.cpp
@@ -418,18 +418,28 @@ int framebuffer_device_open(hw_module_t const* module, const char* name, hw_devi
alloc_device_t* gralloc_device;
status = gralloc_open(module, &gralloc_device);
- if (status < 0)
+ if (status < 0) {
+ ALOGE("Fail to Open gralloc device");
return status;
+ }
+
+ /* initialize our state here */
+ framebuffer_device_t *dev = (framebuffer_device_t *)malloc(sizeof(framebuffer_device_t));
+ if (dev == NULL) {
+ ALOGE("Failed to allocate memory for dev");
+ gralloc_close(gralloc_device);
+ return status;
+ }
private_module_t* m = (private_module_t*)module;
status = init_frame_buffer(m);
if (status < 0) {
+ ALOGE("Fail to init framebuffer");
+ free(dev);
gralloc_close(gralloc_device);
return status;
}
- /* initialize our state here */
- framebuffer_device_t *dev = new framebuffer_device_t;
memset(dev, 0, sizeof(*dev));
/* initialize the procs */
diff --git a/exynos4/hal/libgralloc_ump/gralloc_module.cpp b/exynos4/hal/libgralloc_ump/gralloc_module.cpp
index 16fe2ec..f448f7b 100644
--- a/exynos4/hal/libgralloc_ump/gralloc_module.cpp
+++ b/exynos4/hal/libgralloc_ump/gralloc_module.cpp
@@ -335,6 +335,10 @@ static int gralloc_unregister_buffer(gralloc_module_t const* module, buffer_hand
gralloc_unmap(module, handle);
pthread_mutex_unlock(&s_map_lock);
+ if (0 < gMemfd) {
+ close(gMemfd);
+ gMemfd = 0;
+ }
return 0;
} else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION) {
ump_mapped_pointer_release((ump_handle)hnd->ump_mem_handle);