exynos4: update gralloc from insignal, modify it to work with libsecion

tirimbino
codeworkx 12 years ago
parent d573d9b5a1
commit 1030fe0ae8
  1. 11
      exynos4/hal/include/gralloc_priv.h
  2. 7
      exynos4/hal/libgralloc_ump/Android.mk
  3. 36
      exynos4/hal/libgralloc_ump/alloc_device.cpp
  4. 16
      exynos4/hal/libgralloc_ump/framebuffer_device.cpp
  5. 4
      exynos4/hal/libgralloc_ump/gralloc_module.cpp

@ -47,17 +47,6 @@
#define GRALLOC_ARM_UMP_MODULE 1 #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_handle_t;
struct private_module_t { struct private_module_t {

@ -26,7 +26,7 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_PRELINK_MODULE := false LOCAL_PRELINK_MODULE := false
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw 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 # Include the UMP header files
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../include LOCAL_C_INCLUDES += $(LOCAL_PATH)/../include
@ -36,8 +36,9 @@ LOCAL_SRC_FILES := \
alloc_device.cpp \ alloc_device.cpp \
framebuffer_device.cpp framebuffer_device.cpp
LOCAL_MODULE_TAGS := eng LOCAL_MODULE := gralloc.$(TARGET_BOARD_PLATFORM)
LOCAL_MODULE := gralloc.$(TARGET_DEVICE) LOCAL_MODULE_TAGS := optional
LOCAL_CFLAGS:= -DLOG_TAG=\"gralloc\" -DGRALLOC_32_BITS -DSTANDARD_LINUX_SCREEN LOCAL_CFLAGS:= -DLOG_TAG=\"gralloc\" -DGRALLOC_32_BITS -DSTANDARD_LINUX_SCREEN
#LOCAL_CFLAGS+= -DMALI_VSYNC_EVENT_REPORT_ENABLE #LOCAL_CFLAGS+= -DMALI_VSYNC_EVENT_REPORT_ENABLE

@ -80,6 +80,9 @@
#define OMX_COLOR_FormatYUV420SemiPlanar 0x15 #define OMX_COLOR_FormatYUV420SemiPlanar 0x15
#endif #endif
#define PFX_NODE_MEM "/dev/exynos-mem"
static int gMemfd = 0;
bool ion_dev_open = true; bool ion_dev_open = true;
static pthread_mutex_t l_surface= PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t l_surface= PTHREAD_MUTEX_INITIALIZER;
static int buffer_offset = 0; 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)); hnd->voffset = (EXYNOS4_ALIGN((EXYNOS4_ALIGN((hnd->width >> 1), 16) * EXYNOS4_ALIGN((hnd->height >> 1), 16)), 4096));
buffer_offset += size; 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; return 0;
} else { } else {
ion_buffer ion_fd = 0; 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->height = h;
hnd->bpp = bpp; hnd->bpp = bpp;
hnd->stride = stride; hnd->stride = stride;
hnd->uoffset = ((EXYNOS4_ALIGN(hnd->width, 16) * EXYNOS4_ALIGN(hnd->height, 16))); if(hnd->format == HAL_PIXEL_FORMAT_YV12) {
hnd->voffset = ((EXYNOS4_ALIGN((hnd->width >> 1), 16) * EXYNOS4_ALIGN((hnd->height >> 1), 16))); 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; return 0;
} else { } else {
ALOGE("gralloc_alloc_buffer() failed to allocate handle"); 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 HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP_TILED:
case OMX_COLOR_FormatYUV420Planar: case OMX_COLOR_FormatYUV420Planar:
case OMX_COLOR_FormatYUV420SemiPlanar: 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) if(usage & GRALLOC_USAGE_HW_FIMC1)
size += PAGE_SIZE * 2; size += PAGE_SIZE * 2;
break; 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; int index = (hnd->base - m->framebuffer->base) / bufferSize;
m->bufferMask &= ~(1<<index); m->bufferMask &= ~(1<<index);
close(hnd->fd); 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) { } else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_UMP) {
#ifdef USE_PARTIAL_FLUSH #ifdef USE_PARTIAL_FLUSH
if (!release_rect((int)hnd->ump_id)) if (!release_rect((int)hnd->ump_id))

@ -418,18 +418,28 @@ int framebuffer_device_open(hw_module_t const* module, const char* name, hw_devi
alloc_device_t* gralloc_device; alloc_device_t* gralloc_device;
status = gralloc_open(module, &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; return status;
}
private_module_t* m = (private_module_t*)module; private_module_t* m = (private_module_t*)module;
status = init_frame_buffer(m); status = init_frame_buffer(m);
if (status < 0) { if (status < 0) {
ALOGE("Fail to init framebuffer");
free(dev);
gralloc_close(gralloc_device); gralloc_close(gralloc_device);
return status; return status;
} }
/* initialize our state here */
framebuffer_device_t *dev = new framebuffer_device_t;
memset(dev, 0, sizeof(*dev)); memset(dev, 0, sizeof(*dev));
/* initialize the procs */ /* initialize the procs */

@ -335,6 +335,10 @@ static int gralloc_unregister_buffer(gralloc_module_t const* module, buffer_hand
gralloc_unmap(module, handle); gralloc_unmap(module, handle);
pthread_mutex_unlock(&s_map_lock); pthread_mutex_unlock(&s_map_lock);
if (0 < gMemfd) {
close(gMemfd);
gMemfd = 0;
}
return 0; return 0;
} else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION) { } else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION) {
ump_mapped_pointer_release((ump_handle)hnd->ump_mem_handle); ump_mapped_pointer_release((ump_handle)hnd->ump_mem_handle);

Loading…
Cancel
Save