From 34f9d5d69265777b8bb27f98cfa9855494e1266a Mon Sep 17 00:00:00 2001 From: espenfjo Date: Sat, 1 Dec 2012 18:52:36 +0100 Subject: [PATCH] exynos4: libhwcomposer: update for new api version --- exynos4/hal/libhwcomposer/Android.mk | 14 +- exynos4/hal/libhwcomposer/SecHWC.cpp | 542 ++++++++----- exynos4/hal/libhwcomposer/SecHWCUtils.cpp | 897 +--------------------- exynos4/hal/libhwcomposer/SecHWCUtils.h | 144 ++-- 4 files changed, 437 insertions(+), 1160 deletions(-) diff --git a/exynos4/hal/libhwcomposer/Android.mk b/exynos4/hal/libhwcomposer/Android.mk index 902a72f6..ae93dc51 100644 --- a/exynos4/hal/libhwcomposer/Android.mk +++ b/exynos4/hal/libhwcomposer/Android.mk @@ -23,12 +23,8 @@ LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw LOCAL_SHARED_LIBRARIES := liblog libcutils libEGL \ libGLESv1_CM -ifeq ($(BOARD_USE_V4L2_ION),true) -LOCAL_SHARED_LIBRARIES += libion -endif - LOCAL_C_INCLUDES := \ - $(LOCAL_PATH)/../include + $(TARGET_HAL_PATH)/include LOCAL_SRC_FILES := SecHWCLog.cpp SecHWCUtils.cpp SecHWC.cpp @@ -75,14 +71,6 @@ LOCAL_CFLAGS += -DSTD_1080P endif endif -ifeq ($(BOARD_USE_V4L2),true) -LOCAL_CFLAGS += -DBOARD_USE_V4L2 -endif - -ifeq ($(BOARD_USE_V4L2_ION),true) -LOCAL_CFLAGS += -DBOARD_USE_V4L2_ION -endif - LOCAL_MODULE := hwcomposer.$(TARGET_BOARD_PLATFORM) LOCAL_MODULE_TAGS := optional include $(BUILD_SHARED_LIBRARY) diff --git a/exynos4/hal/libhwcomposer/SecHWC.cpp b/exynos4/hal/libhwcomposer/SecHWC.cpp index b76a8859..704e5b80 100644 --- a/exynos4/hal/libhwcomposer/SecHWC.cpp +++ b/exynos4/hal/libhwcomposer/SecHWC.cpp @@ -27,6 +27,8 @@ #include #include +#include +#include #include "SecHWCUtils.h" @@ -63,7 +65,7 @@ static struct hw_module_methods_t hwc_module_methods = { hwc_module_t HAL_MODULE_INFO_SYM = { common: { tag: HARDWARE_MODULE_TAG, - version_major: 1, + version_major: 2, version_minor: 0, id: HWC_HARDWARE_MODULE_ID, name: "Samsung S5PC21X hwcomposer module", @@ -74,8 +76,8 @@ hwc_module_t HAL_MODULE_INFO_SYM = { /*****************************************************************************/ -static void dump_layer(hwc_layer_t const* l) { - ALOGD("\ttype=%d, flags=%08x, handle=%p, tr=%02x, blend=%04x, " +static void dump_layer(hwc_layer_1_t const* l) { + SEC_HWC_Log(HWC_LOG_DEBUG,"\ttype=%d, flags=%08x, handle=%p, tr=%02x, blend=%04x, " "{%d,%d,%d,%d}, {%d,%d,%d,%d}", l->compositionType, l->flags, l->handle, l->transform, l->blending, l->sourceCrop.left, @@ -88,7 +90,7 @@ static void dump_layer(hwc_layer_t const* l) { l->displayFrame.bottom); } -void calculate_rect(struct hwc_win_info_t *win, hwc_layer_t *cur, +void calculate_rect(struct hwc_win_info_t *win, hwc_layer_1_t *cur, sec_rect *rect) { rect->x = cur->displayFrame.left; @@ -118,7 +120,7 @@ void calculate_rect(struct hwc_win_info_t *win, hwc_layer_t *cur, } } -static int set_src_dst_img_rect(hwc_layer_t *cur, +static int set_src_dst_img_rect(hwc_layer_1_t *cur, struct hwc_win_info_t *win, struct sec_img *src_img, struct sec_img *dst_img, @@ -194,62 +196,62 @@ static int set_src_dst_img_rect(hwc_layer_t *cur, src_rect->x = (0 - cur->displayFrame.left) *(src_img->w) - /(cur->displayFrame.right - cur->displayFrame.left + 1); - if (cur->displayFrame.right + 1 > win->lcd_info.xres) { + /(cur->displayFrame.right - cur->displayFrame.left); + if (cur->displayFrame.right > win->lcd_info.xres) { src_rect->w = - (cur->sourceCrop.right - cur->sourceCrop.left + 1) - + (cur->sourceCrop.right - cur->sourceCrop.left) - src_rect->x - (cur->displayFrame.right - win->lcd_info.xres) *(src_img->w) - /(cur->displayFrame.right - cur->displayFrame.left + 1); + /(cur->displayFrame.right - cur->displayFrame.left); } else { src_rect->w = - (cur->sourceCrop.right - cur->sourceCrop.left + 1) - + (cur->sourceCrop.right - cur->sourceCrop.left) - src_rect->x; } } else { src_rect->x = cur->sourceCrop.left; - if (cur->displayFrame.right + 1 > win->lcd_info.xres) { + if (cur->displayFrame.right > win->lcd_info.xres) { src_rect->w = - (cur->sourceCrop.right - cur->sourceCrop.left + 1) - + (cur->sourceCrop.right - cur->sourceCrop.left) - src_rect->x - (cur->displayFrame.right - win->lcd_info.xres) *(src_img->w) - /(cur->displayFrame.right - cur->displayFrame.left + 1); + /(cur->displayFrame.right - cur->displayFrame.left); } else { src_rect->w = - (cur->sourceCrop.right - cur->sourceCrop.left + 1); + (cur->sourceCrop.right - cur->sourceCrop.left); } } if (cur->displayFrame.top < 0) { src_rect->y = (0 - cur->displayFrame.top) *(src_img->h) - /(cur->displayFrame.bottom - cur->displayFrame.top + 1); - if (cur->displayFrame.bottom + 1 > win->lcd_info.yres) { + /(cur->displayFrame.bottom - cur->displayFrame.top); + if (cur->displayFrame.bottom > win->lcd_info.yres) { src_rect->h = - (cur->sourceCrop.bottom - cur->sourceCrop.top + 1) - + (cur->sourceCrop.bottom - cur->sourceCrop.top) - src_rect->y - (cur->displayFrame.bottom - win->lcd_info.yres) *(src_img->h) - /(cur->displayFrame.bottom - cur->displayFrame.top + 1); + /(cur->displayFrame.bottom - cur->displayFrame.top); } else { src_rect->h = - (cur->sourceCrop.bottom - cur->sourceCrop.top + 1) - + (cur->sourceCrop.bottom - cur->sourceCrop.top) - src_rect->y; } } else { src_rect->y = cur->sourceCrop.top; - if (cur->displayFrame.bottom + 1 > win->lcd_info.yres) { + if (cur->displayFrame.bottom > win->lcd_info.yres) { src_rect->h = - (cur->sourceCrop.bottom - cur->sourceCrop.top + 1) - + (cur->sourceCrop.bottom - cur->sourceCrop.top) - src_rect->y - (cur->displayFrame.bottom - win->lcd_info.yres) *(src_img->h) - /(cur->displayFrame.bottom - cur->displayFrame.top + 1); + /(cur->displayFrame.bottom - cur->displayFrame.top); } else { src_rect->h = - (cur->sourceCrop.bottom - cur->sourceCrop.top + 1); + (cur->sourceCrop.bottom - cur->sourceCrop.top); } } @@ -301,7 +303,7 @@ static int set_src_dst_img_rect(hwc_layer_t *cur, return 0; } -static int get_hwc_compos_decision(hwc_layer_t* cur, int iter, int win_cnt) +static int get_hwc_compos_decision(hwc_layer_1_t* cur, int iter, int win_cnt) { if(cur->flags & HWC_SKIP_LAYER || !cur->handle) { SEC_HWC_Log(HWC_LOG_DEBUG, "%s::is_skip_layer %d cur->handle %x ", @@ -351,36 +353,6 @@ static int get_hwc_compos_decision(hwc_layer_t* cur, int iter, int win_cnt) } } -#ifdef SUB_TITLES_HWC - else if ((win_cnt > 0) && - (prev_handle->usage & GRALLOC_USAGE_EXTERNAL_DISP)) { - switch (prev_handle->format) { - case HAL_PIXEL_FORMAT_RGBA_8888: - case HAL_PIXEL_FORMAT_RGBX_8888: - case HAL_PIXEL_FORMAT_BGRA_8888: - case HAL_PIXEL_FORMAT_RGB_888: - case HAL_PIXEL_FORMAT_RGB_565: - case HAL_PIXEL_FORMAT_RGBA_5551: - case HAL_PIXEL_FORMAT_RGBA_4444: - compositionType = HWC_OVERLAY; - break; - default: - compositionType = HWC_FRAMEBUFFER; - break; - } - - SEC_HWC_Log(HWC_LOG_DEBUG, "2nd iter###%s:: compositionType %d bpp %d" - " format %x src[%d %d %d %d] dst[%d %d %d %d] srcImg[%d %d]", - __func__, compositionType, prev_handle->bpp, - prev_handle->format, - cur->sourceCrop.left, cur->sourceCrop.right, - cur->sourceCrop.top, cur->sourceCrop.bottom, - cur->displayFrame.left, cur->displayFrame.right, - cur->displayFrame.top, cur->displayFrame.bottom, - prev_handle->width, prev_handle->height); - } -#endif - SEC_HWC_Log(HWC_LOG_DEBUG, "%s::compositionType(%d)=>0:FB,1:OVERLAY \r\n" " format(0x%x),magic(0x%x),flags(%d),size(%d),offset(%d)" @@ -404,7 +376,7 @@ static void reset_win_rect_info(hwc_win_info_t *win) } -static int assign_overlay_window(struct hwc_context_t *ctx, hwc_layer_t *cur, +static int assign_overlay_window(struct hwc_context_t *ctx, hwc_layer_1_t *cur, int win_idx, int layer_idx) { struct hwc_win_info_t *win; @@ -453,15 +425,139 @@ static int assign_overlay_window(struct hwc_context_t *ctx, hwc_layer_t *cur, return 0; } -static int hwc_prepare(hwc_composer_device_t *dev, hwc_layer_list_t* list) +#ifdef SKIP_DUMMY_UI_LAY_DRAWING +static void get_hwc_ui_lay_skipdraw_decision(struct hwc_context_t* ctx, + hwc_display_contents_1_t* list) { - struct hwc_context_t* ctx = (struct hwc_context_t*)dev; - int overlay_win_cnt = 0; - int compositionType = 0; - int ret; + private_handle_t *prev_handle; + hwc_layer_1_t* cur; + int num_of_fb_lay_skip = 0; + int fb_lay_tot = ctx->num_of_fb_layer + ctx->num_of_fb_lay_skip; + + if (fb_lay_tot > NUM_OF_DUMMY_WIN) + return; + + if (fb_lay_tot < 1) { +#ifdef GL_WA_OVLY_ALL + ctx->ui_skip_frame_cnt++; + if (ctx->ui_skip_frame_cnt >= THRES_FOR_SWAP) { + ctx->ui_skip_frame_cnt = 0; + ctx->num_of_fb_layer_prev = 1; + } +#endif + return; + } + + if (ctx->fb_lay_skip_initialized) { + for (int cnt = 0; cnt < fb_lay_tot; cnt++) { + cur = &list->hwLayers[ctx->win_virt[cnt].layer_index]; + if (ctx->win_virt[cnt].layer_prev_buf == (uint32_t)cur->handle) + num_of_fb_lay_skip++; + } +#ifdef GL_WA_OVLY_ALL + if (ctx->ui_skip_frame_cnt >= THRES_FOR_SWAP) + num_of_fb_lay_skip = 0; +#endif + if (num_of_fb_lay_skip != fb_lay_tot) { + ctx->num_of_fb_layer = fb_lay_tot; + ctx->num_of_fb_lay_skip = 0; +#ifdef GL_WA_OVLY_ALL + ctx->ui_skip_frame_cnt = 0; +#endif + for (int cnt = 0; cnt < fb_lay_tot; cnt++) { + cur = &list->hwLayers[ctx->win_virt[cnt].layer_index]; + ctx->win_virt[cnt].layer_prev_buf = (uint32_t)cur->handle; + cur->compositionType = HWC_FRAMEBUFFER; + ctx->win_virt[cnt].status = HWC_WIN_FREE; + } + } else { + ctx->num_of_fb_layer = 0; + ctx->num_of_fb_lay_skip = fb_lay_tot; +#ifdef GL_WA_OVLY_ALL + ctx->ui_skip_frame_cnt++; +#endif + for (int cnt = 0; cnt < fb_lay_tot; cnt++) { + cur = &list->hwLayers[ctx->win_virt[cnt].layer_index]; + cur->compositionType = HWC_OVERLAY; + ctx->win_virt[cnt].status = HWC_WIN_RESERVED; + } + } + } else { + ctx->num_of_fb_lay_skip = 0; + for (int i = 0; i < list->numHwLayers ; i++) { + if(num_of_fb_lay_skip >= NUM_OF_DUMMY_WIN) + break; + + cur = &list->hwLayers[i]; + if (cur->handle) { + prev_handle = (private_handle_t *)(cur->handle); + + switch (prev_handle->format) { + case HAL_PIXEL_FORMAT_RGBA_8888: + case HAL_PIXEL_FORMAT_BGRA_8888: + case HAL_PIXEL_FORMAT_RGBX_8888: + case HAL_PIXEL_FORMAT_RGB_565: + cur->compositionType = HWC_FRAMEBUFFER; + ctx->win_virt[num_of_fb_lay_skip].layer_prev_buf = + (uint32_t)cur->handle; + ctx->win_virt[num_of_fb_lay_skip].layer_index = i; + ctx->win_virt[num_of_fb_lay_skip].status = HWC_WIN_FREE; + num_of_fb_lay_skip++; + break; + default: + break; + } + } else { + cur->compositionType = HWC_FRAMEBUFFER; + } + } + + if (num_of_fb_lay_skip == fb_lay_tot) + ctx->fb_lay_skip_initialized = 1; + } - //if geometry is not changed, there is no need to do any work here - if (!list || (!(list->flags & HWC_GEOMETRY_CHANGED))) + return; + +} +#endif + +static int hwc_prepare(hwc_composer_device_1_t *dev, size_t numDisplays, hwc_display_contents_1_t** displays) +{ + + for (uint32_t i = 0; i < numDisplays; i++) { + hwc_display_contents_1_t *list = displays[i]; + struct hwc_context_t* ctx = (struct hwc_context_t*)dev; + int overlay_win_cnt = 0; + int compositionType = 0; + int ret; +#if defined(BOARD_USES_HDMI) + android::SecHdmiClient *mHdmiClient = android::SecHdmiClient::getInstance(); + int hdmi_cable_status = (int)mHdmiClient->getHdmiCableStatus(); + + ctx->hdmi_cable_status = hdmi_cable_status; +#endif + +#ifdef SKIP_DUMMY_UI_LAY_DRAWING + if ((list && (!(list->flags & HWC_GEOMETRY_CHANGED))) && + (ctx->num_of_hwc_layer > 0)) { + get_hwc_ui_lay_skipdraw_decision(ctx, list); + return 0; + } + ctx->fb_lay_skip_initialized = 0; + ctx->num_of_fb_lay_skip = 0; +#ifdef GL_WA_OVLY_ALL + ctx->ui_skip_frame_cnt = 0; +#endif + + for (int i = 0; i < NUM_OF_DUMMY_WIN; i++) { + ctx->win_virt[i].layer_prev_buf = 0; + ctx->win_virt[i].layer_index = -1; + ctx->win_virt[i].status = HWC_WIN_FREE; + } +#endif + + //if geometry is not changed, there is no need to do any work here + if (!list || (!(list->flags & HWC_GEOMETRY_CHANGED))) return 0; //all the windows are free here.... @@ -473,9 +569,27 @@ static int hwc_prepare(hwc_composer_device_t *dev, hwc_layer_list_t* list) ctx->num_of_hwc_layer = 0; ctx->num_of_fb_layer = 0; ctx->num_2d_blit_layer = 0; + ctx->num_of_ext_disp_video_layer = 0; + + for (int i = 0; i < list->numHwLayers; i++) { + hwc_layer_1_t *cur = &list->hwLayers[i]; + private_handle_t *prev_handle = NULL; + if (cur->handle) { + prev_handle = (private_handle_t *)(cur->handle); + SEC_HWC_Log(HWC_LOG_DEBUG, "prev_handle->usage = %d", prev_handle->usage); + if (prev_handle->usage & GRALLOC_USAGE_EXTERNAL_DISP) { + ctx->num_of_ext_disp_layer++; + if ((prev_handle->usage & GRALLOC_USAGE_EXTERNAL_DISP) || + check_yuv_format((unsigned int)prev_handle->format) == 1) { + ctx->num_of_ext_disp_video_layer++; + } + } + } + } for (int i = 0; i < list->numHwLayers ; i++) { - hwc_layer_t* cur = &list->hwLayers[i]; + hwc_layer_1_t* cur = &list->hwLayers[i]; + private_handle_t *prev_handle = (private_handle_t *)(cur->handle); if (overlay_win_cnt < NUM_OF_WIN) { compositionType = get_hwc_compos_decision(cur, 0, overlay_win_cnt); @@ -486,7 +600,7 @@ static int hwc_prepare(hwc_composer_device_t *dev, hwc_layer_list_t* list) } else { ret = assign_overlay_window(ctx, cur, overlay_win_cnt, i); if (ret != 0) { - ALOGE("assign_overlay_window fail, change to frambuffer"); + SEC_HWC_Log(HWC_LOG_ERROR, "assign_overlay_window fail, change to frambuffer"); cur->compositionType = HWC_FRAMEBUFFER; ctx->num_of_fb_layer++; continue; @@ -501,32 +615,29 @@ static int hwc_prepare(hwc_composer_device_t *dev, hwc_layer_list_t* list) cur->compositionType = HWC_FRAMEBUFFER; ctx->num_of_fb_layer++; } - } - -#ifdef SUB_TITLES_HWC - for (int i = 0; i < list->numHwLayers ; i++) { - if (overlay_win_cnt < NUM_OF_WIN) { - hwc_layer_t* cur = &list->hwLayers[i]; - if (get_hwc_compos_decision(cur, 1, overlay_win_cnt) == HWC_OVERLAY) { - ret = assign_overlay_window(ctx, cur, overlay_win_cnt, i); - if (ret == 0) { - cur->compositionType = HWC_OVERLAY; - cur->hints = HWC_HINT_CLEAR_FB; - overlay_win_cnt++; - ctx->num_of_hwc_layer++; - ctx->num_of_fb_layer--; - ctx->num_2d_blit_layer = 1; - } +#if defined(BOARD_USES_HDMI) + SEC_HWC_Log(HWC_LOG_DEBUG, "ext disp vid = %d, cable status = %d, composition type = %d", + ctx->num_of_ext_disp_video_layer, ctx->hdmi_cable_status, compositionType); + if (ctx->num_of_ext_disp_video_layer >= 2) { + if ((ctx->hdmi_cable_status) && + (compositionType == HWC_OVERLAY) && + (prev_handle->usage & GRALLOC_USAGE_EXTERNAL_DISP)) { + cur->compositionType = HWC_FRAMEBUFFER; + ctx->num_of_hwc_layer--; + overlay_win_cnt--; + ctx->num_of_fb_layer++; + cur->hints = 0; } } - else - break; - } #endif + } #if defined(BOARD_USES_HDMI) - android::SecHdmiClient *mHdmiClient = android::SecHdmiClient::getInstance(); + mHdmiClient = android::SecHdmiClient::getInstance(); mHdmiClient->setHdmiHwcLayer(ctx->num_of_hwc_layer); + if (ctx->num_of_ext_disp_video_layer > 1) { + mHdmiClient->setExtDispLayerNum(0); + } #endif if (list->numHwLayers != (ctx->num_of_fb_layer + ctx->num_of_hwc_layer)) @@ -542,27 +653,27 @@ static int hwc_prepare(hwc_composer_device_t *dev, hwc_layer_list_t* list) reset_win_rect_info(&ctx->win[i]); } } - + } return 0; } -static int hwc_set(hwc_composer_device_t *dev, - hwc_display_t dpy, - hwc_surface_t sur, - hwc_layer_list_t* list) +static int hwc_set(hwc_composer_device_1_t *dev, + size_t numDisplays, + hwc_display_contents_1_t** displays) { struct hwc_context_t *ctx = (struct hwc_context_t *)dev; int skipped_window_mask = 0; - hwc_layer_t* cur; + hwc_layer_1_t* cur; struct hwc_win_info_t *win; int ret; int pmem_phyaddr; - static int egl_check; - int egl_run = 0; struct sec_img src_img; struct sec_img dst_img; struct sec_rect src_work_rect; struct sec_rect dst_work_rect; + bool need_swap_buffers = ctx->num_of_fb_layer > 0; + for (uint32_t i = 0; i < numDisplays; i++) { + hwc_display_contents_1_t* list = displays[i]; memset(&src_img, 0, sizeof(src_img)); memset(&dst_img, 0, sizeof(dst_img)); @@ -582,14 +693,45 @@ static int hwc_set(hwc_composer_device_t *dev, ctx->win[i].status = HWC_WIN_FREE; } ctx->num_of_hwc_layer = 0; + need_swap_buffers = true; - if (sur == NULL && dpy == NULL) + if (list->sur == NULL && list->dpy == NULL) { +#ifdef SKIP_DUMMY_UI_LAY_DRAWING + ctx->fb_lay_skip_initialized = 0; +#endif return HWC_EGL_ERROR; + } } if(ctx->num_of_hwc_layer > NUM_OF_WIN) ctx->num_of_hwc_layer = NUM_OF_WIN; + /* + * H/W composer documentation states: + * There is an implicit layer containing opaque black + * pixels behind all the layers in the list. + * It is the responsibility of the hwcomposer module to make + * sure black pixels are output (or blended from). + * + * Since we're using a blitter, we need to erase the frame-buffer when + * switching to all-overlay mode. + * + */ + if (ctx->num_of_hwc_layer && + ctx->num_of_fb_layer==0 && ctx->num_of_fb_layer_prev) { +#ifdef SKIP_DUMMY_UI_LAY_DRAWING + if (ctx->num_of_fb_lay_skip == 0) +#endif + { + glDisable(GL_SCISSOR_TEST); + glClearColor(0, 0, 0, 0); + glClear(GL_COLOR_BUFFER_BIT); + glEnable(GL_SCISSOR_TEST); + need_swap_buffers = true; + } + } + ctx->num_of_fb_layer_prev = ctx->num_of_fb_layer; + //compose hardware layers here for (int i = 0; i < ctx->num_of_hwc_layer - ctx->num_2d_blit_layer; i++) { win = &ctx->win[i]; @@ -603,7 +745,7 @@ static int hwc_set(hwc_composer_device_t *dev, * double buffered (2 or more) this buffer is already rendered. * It is the redundant src buffer for FIMC rendering. */ - ALOGD("SKIP FIMC rendering for Layer%d", win->layer_index); + #if defined(BOARD_USES_HDMI) skip_hdmi_rendering = 1; #endif @@ -646,33 +788,6 @@ static int hwc_set(hwc_composer_device_t *dev, } } -#ifdef SUB_TITLES_HWC - if (ctx->num_2d_blit_layer) { - g2d_rect srcRect; - g2d_rect dstRect; - - win = &ctx->win[ctx->num_of_hwc_layer - 1]; - cur = &list->hwLayers[win->layer_index]; - set_src_dst_g2d_rect(cur, win, &srcRect, &dstRect); - ret = runG2d(ctx, &srcRect, &dstRect, - cur->transform); - if (ret < 0) { - SEC_HWC_Log(HWC_LOG_ERROR, "%s::runG2d fail : ret=%d\n", - __func__, ret); - skipped_window_mask |= (1 << (ctx->num_of_hwc_layer - 1)); - goto g2d_error; - } - - window_pan_display(win); - - win->buf_index = (win->buf_index + 1) % NUM_OF_WIN_BUF; - if (win->power_state == 0) - window_show(win); - } - -g2d_error: -#endif - if (skipped_window_mask) { //turn off the free windows for (int i = 0; i < NUM_OF_WIN; i++) { @@ -683,7 +798,7 @@ g2d_error: } } - if (0 < ctx->num_of_fb_layer) { + if (need_swap_buffers) { #ifdef CHECK_EGL_FPS check_fps(); #endif @@ -691,17 +806,7 @@ g2d_error: unsigned char pixels[4]; glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels); #endif - egl_check = 1; - egl_run = 1; - } else { - if (egl_check == 1) { - egl_check = 0; - egl_run = 1; - } - } - - if (egl_run == 1) { - EGLBoolean sucess = eglSwapBuffers((EGLDisplay)dpy, (EGLSurface)sur); + EGLBoolean sucess = eglSwapBuffers((EGLDisplay)list->dpy, (EGLSurface)list->sur); if (!sucess) return HWC_EGL_ERROR; } @@ -732,14 +837,14 @@ g2d_error: // To support S3D video playback (automatic TV mode change to 3D mode) if (ctx->num_of_hwc_layer == 1) { if (src_img.usage != prev_usage) - mHdmiClient->setHdmiResolution(DEFAULT_HDMI_RESOLUTION_VALUE); // V4L2_STD_1080P_60 + mHdmiClient->setHdmiResolution(DEFAULT_HDMI_RESOLUTION_VALUE, android::SecHdmiClient::HDMI_2D); // V4L2_STD_1080P_60 if ((src_img.usage & GRALLOC_USAGE_PRIVATE_SBS_LR) || (src_img.usage & GRALLOC_USAGE_PRIVATE_SBS_RL)) - mHdmiClient->setHdmiResolution(7209601); // V4L2_STD_TVOUT_720P_60_SBS_HALF + mHdmiClient->setHdmiResolution(DEFAULT_HDMI_S3D_SBS_RESOLUTION_VALUE, android::SecHdmiClient::HDMI_S3D_SBS); // V4L2_STD_TVOUT_720P_60_SBS_HALF else if ((src_img.usage & GRALLOC_USAGE_PRIVATE_TB_LR) || (src_img.usage & GRALLOC_USAGE_PRIVATE_TB_RL)) - mHdmiClient->setHdmiResolution(1080924); // V4L2_STD_TVOUT_1080P_24_TB + mHdmiClient->setHdmiResolution(DEFAULT_HDMI_S3D_TB_RESOLUTION_VALUE, android::SecHdmiClient::HDMI_S3D_TB); // V4L2_STD_TVOUT_1080P_24_TB prev_usage = src_img.usage; } else { @@ -747,7 +852,7 @@ g2d_error: (prev_usage & GRALLOC_USAGE_PRIVATE_SBS_RL) || (prev_usage & GRALLOC_USAGE_PRIVATE_TB_LR) || (prev_usage & GRALLOC_USAGE_PRIVATE_TB_RL)) - mHdmiClient->setHdmiResolution(DEFAULT_HDMI_RESOLUTION_VALUE); // V4L2_STD_1080P_60 + mHdmiClient->setHdmiResolution(DEFAULT_HDMI_RESOLUTION_VALUE, android::SecHdmiClient::HDMI_2D); // V4L2_STD_1080P_60 prev_usage = 0; } @@ -756,8 +861,7 @@ g2d_error: if ((src_img.format == HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP_TILED)|| (src_img.format == HAL_PIXEL_FORMAT_CUSTOM_YCrCb_420_SP)) { ADDRS * addr = (ADDRS *)(src_img.base); - - mHdmiClient->blit2Hdmi(src_img.w, src_img.h, + mHdmiClient->blit2Hdmi(src_work_rect.w, src_work_rect.h, src_img.format, (unsigned int)addr->addr_y, (unsigned int)addr->addr_cbcr, (unsigned int)addr->addr_cbcr, 0, 0, @@ -767,7 +871,7 @@ g2d_error: (src_img.format == HAL_PIXEL_FORMAT_YCrCb_420_SP) || (src_img.format == HAL_PIXEL_FORMAT_YCbCr_420_P) || (src_img.format == HAL_PIXEL_FORMAT_YV12)) { - mHdmiClient->blit2Hdmi(src_img.w, src_img.h, + mHdmiClient->blit2Hdmi(src_work_rect.w, src_work_rect.h, src_img.format, (unsigned int)ctx->fimc.params.src.buf_addr_phy_rgb_y, (unsigned int)ctx->fimc.params.src.buf_addr_phy_cb, @@ -776,13 +880,90 @@ g2d_error: android::SecHdmiClient::HDMI_MODE_VIDEO, ctx->num_of_hwc_layer); } else { - ALOGE("%s: Unsupported format = %d", __func__, src_img.format); + SEC_HWC_Log(HWC_LOG_ERROR, "%s: Unsupported format = %d", __func__, src_img.format); } } #endif + } + return 0; +} + +static void hwc_registerProcs(struct hwc_composer_device_1* dev, + hwc_procs_t const* procs) +{ + struct hwc_context_t* ctx = (struct hwc_context_t*)dev; + ctx->procs = const_cast(procs); +} + +static int hwc_query(struct hwc_composer_device_1* dev, + int what, int* value) +{ + struct hwc_context_t* ctx = (struct hwc_context_t*)dev; + + switch (what) { + case HWC_BACKGROUND_LAYER_SUPPORTED: + // we don't support the background layer yet + value[0] = 0; + break; + case HWC_VSYNC_PERIOD: + // vsync period in nanosecond + value[0] = 1000000000.0 / 57; + break; + default: + // unsupported query + return -EINVAL; + } return 0; } +static int hwc_eventControl(struct hwc_composer_device_1* dev, int dpy, + int event, int enabled) +{ + struct hwc_context_t* ctx = (struct hwc_context_t*)dev; + + switch (event) { + case HWC_EVENT_VSYNC: + int val = !!enabled; + int err = ioctl(ctx->win[0].fd, S3CFB_SET_VSYNC_INT, &val); + if (err < 0) + return -errno; + + return 0; + } + return -EINVAL; +} + + +static void *hwc_vsync_sysfs_loop(void *data) +{ + static char buf[4096]; + int vsync_timestamp_fd; + fd_set exceptfds; + int res; + int64_t timestamp = 0; + hwc_context_t * ctx = (hwc_context_t *)(data); + + vsync_timestamp_fd = open("/sys/devices/platform/samsung-pd.2/s3cfb.0/vsync_time", O_RDONLY); + char thread_name[64] = "hwcVsyncThread"; + prctl(PR_SET_NAME, (unsigned long) &thread_name, 0, 0, 0); + setpriority(PRIO_PROCESS, 0, -20); + memset(buf, 0, sizeof(buf)); + + SEC_HWC_Log(HWC_LOG_DEBUG,"Using sysfs mechanism for VSYNC notification"); + + FD_ZERO(&exceptfds); + FD_SET(vsync_timestamp_fd, &exceptfds); + do { + ssize_t len = read(vsync_timestamp_fd, buf, sizeof(buf)); + timestamp = strtoull(buf, NULL, 0); + ctx->procs->vsync(ctx->procs, 0, timestamp); + select(vsync_timestamp_fd + 1, NULL, NULL, &exceptfds, NULL); + lseek(vsync_timestamp_fd, 0, SEEK_SET); + } while (1); + + return NULL; +} + static int hwc_device_close(struct hw_device_t *dev) { struct hwc_context_t* ctx = (struct hwc_context_t*)dev; @@ -793,23 +974,7 @@ static int hwc_device_close(struct hw_device_t *dev) SEC_HWC_Log(HWC_LOG_ERROR, "%s::destroyFimc fail", __func__); ret = -1; } -#ifdef SUB_TITLES_HWC - if (destroyG2d(&ctx->g2d) < 0) { - SEC_HWC_Log(HWC_LOG_ERROR, "%s::destroyG2d() fail", __func__); - ret = -1; - } -#endif - if (destroyMem(&ctx->s3c_mem) < 0) { - SEC_HWC_Log(HWC_LOG_ERROR, "%s::destroyMem fail", __func__); - ret = -1; - } -#ifdef USE_HW_PMEM - if (destroyPmem(&ctx->sec_pmem) < 0) { - SEC_HWC_Log(HWC_LOG_ERROR, "%s::destroyPmem fail", __func__); - ret = -1; - } -#endif for (i = 0; i < NUM_OF_WIN; i++) { if (window_close(&ctx->win[i]) < 0) SEC_HWC_Log(HWC_LOG_DEBUG, "%s::window_close() fail", __func__); @@ -819,11 +984,17 @@ static int hwc_device_close(struct hw_device_t *dev) } return ret; } - +static int hwc_blank(struct hwc_composer_device_1 *dev, int dpy, int blank) +{ + // We're using an older method of screen blanking based on + // early_suspend in the kernel. No need to do anything here. + return 0; +} static int hwc_device_open(const struct hw_module_t* module, const char* name, struct hw_device_t** device) { int status = 0; + int err = 0; struct hwc_win_info_t *win; if (strcmp(name, HWC_HARDWARE_COMPOSER)) @@ -836,22 +1007,21 @@ static int hwc_device_open(const struct hw_module_t* module, const char* name, memset(dev, 0, sizeof(*dev)); /* initialize the procs */ - dev->device.common.tag = HARDWARE_DEVICE_TAG; - dev->device.common.version = 0; - dev->device.common.module = const_cast(module); - dev->device.common.close = hwc_device_close; - - dev->device.prepare = hwc_prepare; - dev->device.set = hwc_set; - + dev->device.common.tag = HARDWARE_DEVICE_TAG; + dev->device.common.version = HWC_DEVICE_API_VERSION_1_0; + dev->device.common.module = const_cast(module); + dev->device.common.close = hwc_device_close; + dev->device.prepare = hwc_prepare; + dev->device.set = hwc_set; + dev->device.eventControl = hwc_eventControl; + dev->device.blank = hwc_blank; + dev->device.query = hwc_query; + dev->device.registerProcs = hwc_registerProcs; *device = &dev->device.common; //initializing memset(&(dev->fimc), 0, sizeof(s5p_fimc_t)); - memset(&(dev->s3c_mem), 0, sizeof(struct s3c_mem_t)); -#ifdef USE_HW_PMEM - memset(&(dev->sec_pmem), 0, sizeof(sec_pmem_t)); -#endif + /* open WIN0 & WIN1 here */ for (int i = 0; i < NUM_OF_WIN; i++) { if (window_open(&(dev->win[i]), i) < 0) { @@ -902,18 +1072,6 @@ static int hwc_device_open(const struct hw_module_t* module, const char* name, } -#ifdef USE_HW_PMEM - if (createPmem(&dev->sec_pmem, PMEM_SIZE) < 0) { - SEC_HWC_Log(HWC_LOG_ERROR, "%s::initPmem(%d) fail", __func__, PMEM_SIZE); - } -#endif - - if (createMem(&dev->s3c_mem, 0, 0) < 0) { - SEC_HWC_Log(HWC_LOG_ERROR, "%s::createMem() fail (size=0)", __func__); - status = -EINVAL; - goto err; - } - //create PP if (createFimc(&dev->fimc) < 0) { SEC_HWC_Log(HWC_LOG_ERROR, "%s::creatFimc() fail", __func__); @@ -921,13 +1079,12 @@ static int hwc_device_open(const struct hw_module_t* module, const char* name, goto err; } -#ifdef SUB_TITLES_HWC - if (createG2d(&dev->g2d) < 0) { - SEC_HWC_Log(HWC_LOG_ERROR, "%s::createG2d() fail", __func__); - status = -EINVAL; + err = pthread_create(&dev->vsync_thread, NULL, hwc_vsync_sysfs_loop, dev); + if (err) { + SEC_HWC_Log(HWC_LOG_ERROR, "%s::pthread_create() failed : %s", __func__, strerror(err)); + status = -err; goto err; } -#endif SEC_HWC_Log(HWC_LOG_DEBUG, "%s:: hwc_device_open: SUCCESS", __func__); @@ -936,17 +1093,6 @@ static int hwc_device_open(const struct hw_module_t* module, const char* name, err: if (destroyFimc(&dev->fimc) < 0) SEC_HWC_Log(HWC_LOG_ERROR, "%s::destroyFimc() fail", __func__); -#ifdef SUB_TITLES_HWC - if (destroyG2d(&dev->g2d) < 0) - SEC_HWC_Log(HWC_LOG_ERROR, "%s::destroyG2d() fail", __func__); -#endif - if (destroyMem(&dev->s3c_mem) < 0) - SEC_HWC_Log(HWC_LOG_ERROR, "%s::destroyMem() fail", __func__); - -#ifdef USE_HW_PMEM - if (destroyPmem(&dev->sec_pmem) < 0) - SEC_HWC_Log(HWC_LOG_ERROR, "%s::destroyPmem() fail", __func__); -#endif for (int i = 0; i < NUM_OF_WIN; i++) { if (window_close(&dev->win[i]) < 0) diff --git a/exynos4/hal/libhwcomposer/SecHWCUtils.cpp b/exynos4/hal/libhwcomposer/SecHWCUtils.cpp index 5214e409..6351bbf3 100644 --- a/exynos4/hal/libhwcomposer/SecHWCUtils.cpp +++ b/exynos4/hal/libhwcomposer/SecHWCUtils.cpp @@ -25,14 +25,8 @@ */ #include "SecHWCUtils.h" - -#ifdef BOARD_USE_V4L2_ION -#define V4L2_BUF_TYPE_OUTPUT V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE -#define V4L2_BUF_TYPE_CAPTURE V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE -#else #define V4L2_BUF_TYPE_OUTPUT V4L2_BUF_TYPE_VIDEO_OUTPUT #define V4L2_BUF_TYPE_CAPTURE V4L2_BUF_TYPE_VIDEO_CAPTURE -#endif #define EXYNOS4_ALIGN( value, base ) (((value) + ((base) - 1)) & ~((base) - 1)) @@ -40,7 +34,7 @@ #ifdef CHECK_FPS #include #include -#define CHK_FRAME_CNT 30 +#define CHK_FRAME_CNT 57 void check_fps() { @@ -59,7 +53,7 @@ void check_fps() memcpy(&tick_old, &tick, sizeof(timeval)); if (cnt == (10 + CHK_FRAME_CNT)) { FPS = 1000*CHK_FRAME_CNT/total; - LOGE("[FPS]:%d\n", FPS); + ALOGE("[FPS]:%d\n", FPS); total = 0; cnt = 10; } @@ -77,10 +71,6 @@ struct yuv_fmt_list yuv_list[] = { { "V4L2_PIX_FMT_NV21X", "YUV420/2P/MSB_CBCR", V4L2_PIX_FMT_NV21X, 12, 2 }, { "V4L2_PIX_FMT_NV12X", "YUV420/2P/MSB_CRCB", V4L2_PIX_FMT_NV12X, 12, 2 }, { "V4L2_PIX_FMT_YUV420", "YUV420/3P", V4L2_PIX_FMT_YUV420, 12, 3 }, -#ifdef BOARD_USE_V4L2_ION - { "V4L2_PIX_FMT_YUV420M", "YUV420/3P", V4L2_PIX_FMT_YUV420M, 12, 3 }, - { "V4L2_PIX_FMT_NV12M", "YUV420/2P", V4L2_PIX_FMT_NV12M, 12, 2 }, -#endif { "V4L2_PIX_FMT_YUYV", "YUV422/1P/YCBYCR", V4L2_PIX_FMT_YUYV, 16, 1 }, { "V4L2_PIX_FMT_YVYU", "YUV422/1P/YCRYCB", V4L2_PIX_FMT_YVYU, 16, 1 }, { "V4L2_PIX_FMT_UYVY", "YUV422/1P/CBYCRY", V4L2_PIX_FMT_UYVY, 16, 1 }, @@ -110,18 +100,10 @@ int window_open(struct hwc_win_info_t *win, int id) switch (id) { case 0: -#ifdef BOARD_USE_V4L2_ION - real_id = 2; -#else real_id = 3; -#endif break; case 1: -#ifdef BOARD_USE_V4L2_ION - real_id = 1; -#else real_id = 4; -#endif break; default: SEC_HWC_Log(HWC_LOG_ERROR, "%s::id(%d) is weird", __func__, id); @@ -166,11 +148,6 @@ int window_close(struct hwc_win_info_t *win) if (0 < win->fd) { -#ifdef BOARD_USE_V4L2_ION - ion_unmap((void *)win->addr[0], ALIGN(win->size * NUM_OF_WIN_BUF, PAGE_SIZE)); - ion_free(win->ion_fd); -#endif - #ifdef ENABLE_FIMD_VSYNC int vsync = 0; if (ioctl(win->fd, S3CFB_SET_VSYNC_INT, &vsync) < 0) @@ -232,26 +209,9 @@ int window_get_info(struct hwc_win_info_t *win, int win_num) win->size = win->fix_info.line_length * win->var_info.yres; -#ifdef BOARD_USE_V4L2_ION - struct s3c_fb_user_ion_client ion_handle; - void *ion_start_addr; - - if (ioctl(win->fd, S3CFB_GET_ION_USER_HANDLE, &ion_handle) < 0) { - SEC_HWC_Log(HWC_LOG_ERROR, "Get fb ion client is failed\n"); - return -1; - } - - win->ion_fd = ion_handle.fd; - ion_start_addr = ion_map(win->ion_fd, ALIGN(win->size * NUM_OF_WIN_BUF, PAGE_SIZE), 0); -#endif - for (int j = 0; j < NUM_OF_WIN_BUF; j++) { temp_size = win->size * j; -#ifdef BOARD_USE_V4L2_ION - win->addr[j] = (uint32_t)ion_start_addr + temp_size; -#else win->addr[j] = win->fix_info.smem_start + temp_size; -#endif SEC_HWC_Log(HWC_LOG_DEBUG, "%s::win-%d add[%d] %x ", __func__, win_num, j, win->addr[j]); } @@ -268,16 +228,9 @@ int window_pan_display(struct hwc_win_info_t *win) struct fb_var_screeninfo *lcd_info = &(win->lcd_info); #ifdef ENABLE_FIMD_VSYNC -#ifdef BOARD_USE_V4L2_ION - int fimd_num = 0; - if (ioctl(win->fd, FBIO_WAITFORVSYNC, &fimd_num) < 0) - SEC_HWC_Log(HWC_LOG_ERROR, "%s::FBIO_WAITFORVSYNC fail(%s)", - __func__, strerror(errno)); -#else if (ioctl(win->fd, FBIO_WAITFORVSYNC, 0) < 0) SEC_HWC_Log(HWC_LOG_ERROR, "%s::FBIO_WAITFORVSYNC fail(%s)", __func__, strerror(errno)); -#endif #endif lcd_info->yoffset = lcd_info->yres * win->buf_index; @@ -339,25 +292,10 @@ int fimc_v4l2_set_src(int fd, unsigned int hw_ver, s5p_fimc_img_info *src) struct v4l2_crop crop; struct v4l2_requestbuffers req; -#ifdef BOARD_USE_V4L2_ION - /* You MUST initialize structure for v4l2 */ - memset(&fmt, 0, sizeof(fmt)); - memset(&cropcap, 0, sizeof(cropcap)); - memset(&crop, 0, sizeof(crop)); - memset(&req, 0, sizeof(req)); - - /* To set size & format for source image (DMA-INPUT) */ - fmt.fmt.pix_mp.num_planes = src->planes; - fmt.fmt.pix_mp.width = src->full_width; - fmt.fmt.pix_mp.height = src->full_height; - fmt.fmt.pix_mp.pixelformat = src->color_space; - fmt.fmt.pix_mp.field = V4L2_FIELD_ANY; -#else fmt.fmt.pix.width = src->full_width; fmt.fmt.pix.height = src->full_height; fmt.fmt.pix.pixelformat = src->color_space; fmt.fmt.pix.field = V4L2_FIELD_NONE; -#endif fmt.type = V4L2_BUF_TYPE_OUTPUT; if (ioctl(fd, VIDIOC_S_FMT, &fmt) < 0) { @@ -370,10 +308,6 @@ int fimc_v4l2_set_src(int fd, unsigned int hw_ver, s5p_fimc_img_info *src) crop.type = V4L2_BUF_TYPE_OUTPUT; crop.c.width = src->width; crop.c.height = src->height; -#ifdef BOARD_USE_V4L2_ION - crop.c.left = src->start_x; - crop.c.top = src->start_y; -#else if (0x50 <= hw_ver) { crop.c.left = src->start_x; crop.c.top = src->start_y; @@ -382,8 +316,6 @@ int fimc_v4l2_set_src(int fd, unsigned int hw_ver, s5p_fimc_img_info *src) crop.c.top = 0; } -#endif - if (ioctl(fd, VIDIOC_S_CROP, &crop) < 0) { SEC_HWC_Log(HWC_LOG_ERROR, "%s::Error in video VIDIOC_S_CROP :" "crop.c.left : (%d), crop.c.top : (%d), crop.c.width : (%d), crop.c.height : (%d)", @@ -410,27 +342,10 @@ int fimc_v4l2_set_dst(int fd, s5p_fimc_img_info *dst, struct v4l2_format sFormat; struct v4l2_control vc; struct v4l2_framebuffer fbuf; -#ifdef BOARD_USE_V4L2_ION - struct v4l2_crop crop; - struct v4l2_requestbuffers req; -#endif int ret; -#ifdef BOARD_USE_V4L2_ION - /* You MUST initialize structure for v4l2 */ - memset(&sFormat, 0, sizeof(sFormat)); - memset(&vc, 0, sizeof(vc)); - memset(&fbuf, 0, sizeof(fbuf)); - memset(&crop, 0, sizeof(crop)); - memset(&req, 0, sizeof(req)); -#endif - /* set rotation configuration */ -#ifdef BOARD_USE_V4L2_ION - vc.id = V4L2_CID_ROTATE; -#else vc.id = V4L2_CID_ROTATION; -#endif vc.value = rotation; ret = ioctl(fd, VIDIOC_S_CTRL, &vc); @@ -463,45 +378,6 @@ int fimc_v4l2_set_dst(int fd, s5p_fimc_img_info *dst, return -1; } -#ifdef BOARD_USE_V4L2_ION - /* set destination */ - sFormat.type = V4L2_BUF_TYPE_CAPTURE; - sFormat.fmt.pix_mp.width = dst->full_width; - sFormat.fmt.pix_mp.height = dst->full_height; - sFormat.fmt.pix_mp.pixelformat = dst->color_space; - sFormat.fmt.pix_mp.num_planes = dst->planes; - sFormat.fmt.pix.field = V4L2_FIELD_ANY; - - ret = ioctl(fd, VIDIOC_S_FMT, &sFormat); - if (ret < 0) { - SEC_HWC_Log(HWC_LOG_ERROR, "%s::Error in video VIDIOC_S_FMT (%d)", __func__, ret); - return -1; - } - - /* set destination window */ - crop.type = V4L2_BUF_TYPE_CAPTURE; - crop.c.left = dst->start_x; - crop.c.top = dst->start_y; - crop.c.width = dst->width; - crop.c.height = dst->height; - - ret = ioctl(fd, VIDIOC_S_CROP, &crop); - if (ret < 0) { - SEC_HWC_Log(HWC_LOG_ERROR, "%s::Error in video VIDIOC_S_CROP (%d)", __func__, ret); - return -1; - } - - /* input buffer type */ - req.count = 1; - req.type = V4L2_BUF_TYPE_CAPTURE; - req.memory = V4L2_MEMORY_USERPTR; - - ret = ioctl (fd, VIDIOC_REQBUFS, &req); - if (ret < 0) { - SEC_HWC_Log(HWC_LOG_ERROR, "%s::Error in VIDIOC_REQBUFS (%d)", __func__, ret); - return -1; - } -#else /* set size, format & address for destination image (DMA-OUTPUT) */ ret = ioctl(fd, VIDIOC_G_FBUF, &fbuf); if (ret < 0) { @@ -532,7 +408,6 @@ int fimc_v4l2_set_dst(int fd, s5p_fimc_img_info *dst, SEC_HWC_Log(HWC_LOG_ERROR, "%s::Error in video VIDIOC_S_FMT (%d)", __func__, ret); return -1; } -#endif return 0; } @@ -549,34 +424,15 @@ int fimc_v4l2_stream_on(int fd, enum v4l2_buf_type type) int fimc_v4l2_queue(int fd, struct fimc_buf *fimc_buf, enum v4l2_buf_type type, int index) { -#ifdef BOARD_USE_V4L2_ION - struct v4l2_plane plane[3]; - int i; -#endif struct v4l2_buffer buf; int ret; -#ifdef BOARD_USE_V4L2_ION - buf.length = fimc_buf->planes; -#else buf.length = 0; buf.m.userptr = (unsigned long)fimc_buf; -#endif buf.memory = V4L2_MEMORY_USERPTR; buf.index = index; buf.type = type; -#ifdef BOARD_USE_V4L2_ION - if (buf.type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE || - buf.type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { - for (i = 0; i < buf.length; i++) { - plane[i].m.userptr = fimc_buf->base[i]; - plane[i].length = fimc_buf->size[i]; - } - } - buf.m.planes = plane; -#endif - ret = ioctl(fd, VIDIOC_QBUF, &buf); if (0 > ret) { SEC_HWC_Log(HWC_LOG_ERROR, "Error in VIDIOC_QBUF : (%d)", ret); @@ -589,14 +445,7 @@ int fimc_v4l2_queue(int fd, struct fimc_buf *fimc_buf, enum v4l2_buf_type type, int fimc_v4l2_dequeue(int fd, struct fimc_buf *fimc_buf, enum v4l2_buf_type type) { struct v4l2_buffer buf; -#ifdef BOARD_USE_V4L2_ION - struct v4l2_plane plane[3]; -#endif -#ifdef BOARD_USE_V4L2_ION - buf.m.planes = plane; - buf.length = fimc_buf->planes; -#endif buf.memory = V4L2_MEMORY_USERPTR; buf.type = type; @@ -654,27 +503,6 @@ int fimc_handle_oneshot(int fd, struct fimc_buf *fimc_src_buf, struct fimc_buf * check_fps(); #endif -#ifdef BOARD_USE_V4L2_ION - if (fimc_v4l2_queue(fd, fimc_src_buf, V4L2_BUF_TYPE_OUTPUT, 0) < 0) { - SEC_HWC_Log(HWC_LOG_ERROR, "Fail : SRC v4l2_queue()"); - return -1; - } - - if (fimc_v4l2_queue(fd, fimc_dst_buf, V4L2_BUF_TYPE_CAPTURE, 0) < 0) { - SEC_HWC_Log(HWC_LOG_ERROR, "Fail : DST v4l2_queue()"); - return -2; - } - - if (fimc_v4l2_stream_on(fd, V4L2_BUF_TYPE_OUTPUT) < 0) { - SEC_HWC_Log(HWC_LOG_ERROR, "Fail : SRC v4l2_stream_on()"); - return -3; - } - - if (fimc_v4l2_stream_on(fd, V4L2_BUF_TYPE_CAPTURE) < 0) { - SEC_HWC_Log(HWC_LOG_ERROR, "Fail : DST v4l2_stream_on()"); - return -4; - } -#else if (fimc_v4l2_stream_on(fd, V4L2_BUF_TYPE_OUTPUT) < 0) { SEC_HWC_Log(HWC_LOG_ERROR, "Fail : SRC v4l2_stream_on()"); return -5; @@ -684,38 +512,19 @@ int fimc_handle_oneshot(int fd, struct fimc_buf *fimc_src_buf, struct fimc_buf * SEC_HWC_Log(HWC_LOG_ERROR, "Fail : SRC v4l2_queue()"); goto STREAM_OFF; } -#endif if (fimc_v4l2_dequeue(fd, fimc_src_buf, V4L2_BUF_TYPE_OUTPUT) < 0) { SEC_HWC_Log(HWC_LOG_ERROR, "Fail : SRC v4l2_dequeue()"); return -6; } -#ifdef BOARD_USE_V4L2_ION - if (fimc_v4l2_dequeue(fd, fimc_dst_buf, V4L2_BUF_TYPE_CAPTURE) < 0) { - SEC_HWC_Log(HWC_LOG_ERROR, "Fail : DST v4l2_dequeue()"); - return -7; - } -#endif STREAM_OFF: if (fimc_v4l2_stream_off(fd, V4L2_BUF_TYPE_OUTPUT) < 0) { SEC_HWC_Log(HWC_LOG_ERROR, "Fail : SRC v4l2_stream_off()"); return -8; } -#ifdef BOARD_USE_V4L2_ION - if (fimc_v4l2_stream_off(fd, V4L2_BUF_TYPE_CAPTURE) < 0) { - SEC_HWC_Log(HWC_LOG_ERROR, "Fail : DST v4l2_stream_off()"); - return -9; - } -#endif if (fimc_v4l2_clr_buf(fd, V4L2_BUF_TYPE_OUTPUT) < 0) { SEC_HWC_Log(HWC_LOG_ERROR, "Fail : SRC v4l2_clr_buf()"); return -10; } -#ifdef BOARD_USE_V4L2_ION - if (fimc_v4l2_clr_buf(fd, V4L2_BUF_TYPE_CAPTURE)< 0) { - SEC_HWC_Log(HWC_LOG_ERROR, "Fail : DST v4l2_clr_buf()"); - return -11; - } -#endif return 0; } @@ -823,17 +632,11 @@ static int get_src_phys_addr(struct hwc_context_t *ctx, sec_img *src_img, sec_rect *src_rect) { s5p_fimc_t *fimc = &ctx->fimc; - struct s3c_mem_alloc *ptr_mem_alloc = &ctx->s3c_mem.mem_alloc[0]; - struct s3c_mem_dma_param s3c_mem_dma; -#ifdef USE_HW_PMEM - sec_pmem_alloc_t *pm_alloc = &ctx->sec_pmem.sec_pmem_alloc[0]; -#endif unsigned int src_virt_addr = 0; unsigned int src_phys_addr = 0; unsigned int src_frame_size = 0; - struct pmem_region region; ADDRS * addr; // error check routine @@ -884,61 +687,16 @@ static int get_src_phys_addr(struct hwc_context_t *ctx, } break; default: -#ifdef BOARD_USE_V4L2_ION - fimc->params.src.buf_addr_phy_rgb_y = src_img->base; - fimc->params.src.buf_addr_phy_cb = src_img->base + src_img->uoffset; - fimc->params.src.buf_addr_phy_cr = src_img->base + src_img->uoffset + src_img->voffset; - src_phys_addr = fimc->params.src.buf_addr_phy_rgb_y; - break; -#endif if (src_img->usage & GRALLOC_USAGE_HW_FIMC1) { fimc->params.src.buf_addr_phy_rgb_y = src_img->paddr; fimc->params.src.buf_addr_phy_cb = src_img->paddr + src_img->uoffset; fimc->params.src.buf_addr_phy_cr = src_img->paddr + src_img->uoffset + src_img->voffset; src_phys_addr = fimc->params.src.buf_addr_phy_rgb_y; - break; - } - // copy - src_frame_size = FRAME_SIZE(src_img->format, src_img->w, src_img->h); - if (src_frame_size == 0) { - SEC_HWC_Log(HWC_LOG_ERROR, "%s::FRAME_SIZE fail", __func__); - return 0; - } - -#ifdef USE_HW_PMEM - if (0 <= checkPmem(&ctx->sec_pmem, 0, src_frame_size)) { - src_virt_addr = pm_alloc->virt_addr; - src_phys_addr = pm_alloc->phys_addr; - pm_alloc->size = src_frame_size; - } else -#endif - if (0 <= checkMem(&ctx->s3c_mem, 0, src_frame_size)) { - src_virt_addr = ptr_mem_alloc->vir_addr; - src_phys_addr = ptr_mem_alloc->phy_addr; - ptr_mem_alloc->size = src_frame_size; - } else { - SEC_HWC_Log(HWC_LOG_ERROR, "%s::check_mem fail", __func__); - return 0; - } - if ((src_img->format == HAL_PIXEL_FORMAT_YCbCr_420_P) || - (src_img->format == HAL_PIXEL_FORMAT_YV12) || - (src_img->format == HAL_PIXEL_FORMAT_YCbCr_420_SP) || - (src_img->format == HAL_PIXEL_FORMAT_YCrCb_420_SP)) { - if (memcpy_rect((void *)src_virt_addr, (void*)((unsigned int)src_img->base), - src_img->f_w, src_img->f_h, src_rect->w, src_rect->h, src_img->format) != 0) - return 0; } else { - memcpy((void *)src_virt_addr, (void*)((unsigned int)src_img->base), src_frame_size); + SEC_HWC_Log(HWC_LOG_ERROR, "%s::\nformat = 0x%x : Not " + "GRALLOC_USAGE_HW_FIMC1 can not supported\n", + __func__, src_img->format); } - -#ifdef USE_HW_PMEM - if (pm_alloc->size == src_frame_size) { - region.offset = 0; - region.len = src_frame_size; - if (ioctl(ctx->sec_pmem.pmem_master_fd, PMEM_CACHE_FLUSH, ®ion) < 0) - SEC_HWC_Log(HWC_LOG_ERROR, "%s::pmem cache flush fail ", __func__); - } -#endif break; } } @@ -946,19 +704,6 @@ static int get_src_phys_addr(struct hwc_context_t *ctx, return src_phys_addr; } -static int get_dst_phys_addr(struct hwc_context_t *ctx, sec_img *dst_img, - sec_rect *dst_rect, int *dst_memcpy_flag) -{ - unsigned int dst_phys_addr = 0; - - if (HWC_PHYS_MEM_TYPE == dst_img->mem_type && 0 != dst_img->base) - dst_phys_addr = dst_img->base; - else - dst_phys_addr = dst_img->base; - - return dst_phys_addr; -} - static inline int rotateValueHAL2PP(unsigned char transform) { int rotate_flag = transform & 0x7; @@ -1049,11 +794,7 @@ static inline int multipleOf16(int number) static inline int widthOfPP(unsigned int ver, int pp_color_format, int number) { -#ifdef BOARD_USE_V4L2_ION - if (1) { -#else if (0x50 <= ver) { -#endif switch (pp_color_format) { /* 422 1/2/3 plane */ case V4L2_PIX_FMT_YUYV: @@ -1156,7 +897,7 @@ static unsigned int get_yuv_planes(unsigned int fmt) return yuv_list[sel].planes; } -static int runcFimcCore(struct hwc_context_t *ctx, +static int runFimcCore(struct hwc_context_t *ctx, unsigned int src_phys_addr, sec_img *src_img, sec_rect *src_rect, uint32_t src_color_space, unsigned int dst_phys_addr, sec_img *dst_img, sec_rect *dst_rect, @@ -1168,18 +909,12 @@ static int runcFimcCore(struct hwc_context_t *ctx, struct fimc_buf fimc_src_buf; int src_bpp, src_planes; -#ifdef BOARD_USE_V4L2_ION - struct fimc_buf fimc_dst_buf; - int dst_bpp, dst_planes; - unsigned int src_frame_size = 0; - unsigned int dst_frame_size = 0; -#endif unsigned int frame_size = 0; bool src_cbcr_order = true; int rotate_value = rotateValueHAL2PP(transform); - int hflip = hflipValueHAL2PP(transform); - int vflip = vflipValueHAL2PP(transform); + int hflip = 0; + int vflip = 0; /* 1. param(fimc config)->src information * - src_img,src_rect => s_fw,s_fh,s_w,s_h,s_x,s_y @@ -1193,17 +928,6 @@ static int runcFimcCore(struct hwc_context_t *ctx, params->src.color_space = src_color_space; params->src.buf_addr_phy_rgb_y = src_phys_addr; -#ifdef BOARD_USE_V4L2_ION - params->dst.full_width = dst_img->f_w; - params->dst.full_height = dst_img->f_h; - params->dst.width = widthOfPP(fimc->hw_ver, dst_color_space, dst_rect->w); - params->dst.height = heightOfPP(dst_color_space, dst_rect->h); - params->dst.start_x = dst_rect->x; - params->dst.start_y = dst_rect->y; - params->dst.color_space = dst_color_space; - params->dst.buf_addr_phy_rgb_y = dst_phys_addr; -#endif - /* check src minimum */ if (src_rect->w < 16 || src_rect->h < 8) { SEC_HWC_Log(HWC_LOG_ERROR, @@ -1217,13 +941,13 @@ static int runcFimcCore(struct hwc_context_t *ctx, return -1; } -#ifdef BOARD_USE_V4L2_ION -#else /* 2. param(fimc config)->dst information * - dst_img,dst_rect,rot => d_fw,d_fh,d_w,d_h,d_x,d_y */ switch (rotate_value) { case 0: + hflip = hflipValueHAL2PP(transform); + vflip = vflipValueHAL2PP(transform); params->dst.full_width = dst_img->f_w; params->dst.full_height = dst_img->f_h; @@ -1235,6 +959,8 @@ static int runcFimcCore(struct hwc_context_t *ctx, params->dst.height = heightOfPP(dst_color_space, dst_rect->h); break; case 90: + hflip = vflipValueHAL2PP(transform); + vflip = hflipValueHAL2PP(transform); params->dst.full_width = dst_img->f_h; params->dst.full_height = dst_img->f_w; @@ -1277,10 +1003,9 @@ static int runcFimcCore(struct hwc_context_t *ctx, break; } params->dst.color_space = dst_color_space; -#endif SEC_HWC_Log(HWC_LOG_DEBUG, - "runcFimcCore()::" + "runFimcCore()::" "SRC f.w(%d),f.h(%d),x(%d),y(%d),w(%d),h(%d)=>" "DST f.w(%d),f.h(%d),x(%d),y(%d),w(%d),h(%d)", params->src.full_width, params->src.full_height, @@ -1320,35 +1045,6 @@ static int runcFimcCore(struct hwc_context_t *ctx, * - set input buffer * - set buffer type (V4L2_MEMORY_USERPTR) */ -#ifdef BOARD_USE_V4L2_ION - switch (dst_img->format) { - case HAL_PIXEL_FORMAT_RGBA_8888: - case HAL_PIXEL_FORMAT_RGBX_8888: - case HAL_PIXEL_FORMAT_RGB_888: - case HAL_PIXEL_FORMAT_BGRA_8888: - dst_planes = 1; - dst_bpp = 32; - break; - - case HAL_PIXEL_FORMAT_RGB_565: - case HAL_PIXEL_FORMAT_RGBA_5551: - case HAL_PIXEL_FORMAT_RGBA_4444: - dst_planes = 1; - dst_bpp = 16; - break; - } - - dst_frame_size = params->dst.width * params->dst.height ; - params->dst.planes = dst_planes; - - if (dst_planes == 1) { - fimc_dst_buf.base[0] = params->dst.buf_addr_phy_rgb_y; - if (dst_bpp == 32) - fimc_dst_buf.size[0] = dst_frame_size * 4; - else if (dst_bpp == 16) - fimc_dst_buf.size[0] = dst_frame_size * 2; - } -#endif if (fimc_v4l2_set_dst(fimc->dev_fd, ¶ms->dst, rotate_value, hflip, vflip, dst_phys_addr) < 0) { SEC_HWC_Log(HWC_LOG_ERROR, "fimc_v4l2_set_dst is failed\n"); @@ -1361,16 +1057,13 @@ static int runcFimcCore(struct hwc_context_t *ctx, * - set input buffer * - set buffer type (V4L2_MEMORY_USERPTR) */ -#ifndef BOARD_USE_V4L2_ION if (fimc_v4l2_set_src(fimc->dev_fd, fimc->hw_ver, ¶ms->src) < 0) { SEC_HWC_Log(HWC_LOG_ERROR, "fimc_v4l2_set_src is failed\n"); return -1; } -#endif /* 5. Set input dma address (Y/RGB, Cb, Cr) * - zero copy : mfc, camera - * - memcpy to pmem : SW dec(420P), video editor(YV12) */ switch (src_img->format) { case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP: @@ -1390,32 +1083,9 @@ static int runcFimcCore(struct hwc_context_t *ctx, case HAL_PIXEL_FORMAT_RGB_565: case HAL_PIXEL_FORMAT_YV12: default: - if (src_img->format == HAL_PIXEL_FORMAT_YV12) + if (src_img->format == HAL_PIXEL_FORMAT_YV12){ src_cbcr_order = false; - -#ifdef BOARD_USE_V4L2_ION - fimc_src_buf.base[0] = params->src.buf_addr_phy_rgb_y; - if (src_cbcr_order == true) { - fimc_src_buf.base[1] = params->src.buf_addr_phy_cb; - fimc_src_buf.base[2] = params->src.buf_addr_phy_cr; - } else { - fimc_src_buf.base[1] = params->src.buf_addr_phy_cr; - fimc_src_buf.base[2] = params->src.buf_addr_phy_cb; } - SEC_HWC_Log(HWC_LOG_DEBUG, - "runFimcCore - Y=0x%X, U=0x%X, V=0x%X\n", - fimc_src_buf.base[0], fimc_src_buf.base[1],fimc_src_buf.base[2]); - src_frame_size = params->src.full_width * params->src.full_height; - fimc_src_buf.size[0] = src_frame_size; - fimc_src_buf.size[1] = src_frame_size >> 2; - fimc_src_buf.size[2] = src_frame_size >> 2; - SEC_HWC_Log(HWC_LOG_DEBUG, - "runFimcCore - Y_length=%d, U_length=%d, V_length=%d\n", - fimc_src_buf.size[0], fimc_src_buf.size[1],fimc_src_buf.size[2]); - src_planes = get_yuv_planes(src_color_space); - - break; -#endif if (src_img->usage & GRALLOC_USAGE_HW_FIMC1) { fimc_src_buf.base[0] = params->src.buf_addr_phy_rgb_y; @@ -1432,108 +1102,20 @@ static int runcFimcCore(struct hwc_context_t *ctx, fimc_src_buf.base[0], fimc_src_buf.base[1],fimc_src_buf.base[2]); break; } - - /* set source Y image */ - fimc_src_buf.base[0] = params->src.buf_addr_phy_rgb_y; - /* set source Cb,Cr images for 2 or 3 planes */ - src_bpp = get_yuv_bpp(src_color_space); - src_planes = get_yuv_planes(src_color_space); - if (2 == src_planes) { /* 2 planes */ - frame_size = params->src.full_width * params->src.full_height; - params->src.buf_addr_phy_cb = - params->src.buf_addr_phy_rgb_y + frame_size; - /* CbCr */ - fimc_src_buf.base[1] = params->src.buf_addr_phy_cb; - } else if (3 == src_planes) { /* 3 planes */ - frame_size = params->src.full_width * params->src.full_height; - params->src.buf_addr_phy_cb = - params->src.buf_addr_phy_rgb_y + frame_size; - if (12 == src_bpp) - params->src.buf_addr_phy_cr = - params->src.buf_addr_phy_cb + (frame_size >> 2); - else - params->src.buf_addr_phy_cr = - params->src.buf_addr_phy_cb + (frame_size >> 1); - /* Cb, Cr */ - if (src_cbcr_order == true) { - fimc_src_buf.base[1] = params->src.buf_addr_phy_cb; - fimc_src_buf.base[2] = params->src.buf_addr_phy_cr; - } - else { - fimc_src_buf.base[2] = params->src.buf_addr_phy_cb; - fimc_src_buf.base[1] = params->src.buf_addr_phy_cr; - } - } - break; } /* 6. Run FIMC * - stream on => queue => dequeue => stream off => clear buf */ -#ifdef BOARD_USE_V4L2_ION - int ret = 0; - params->src.planes = src_planes; - - if (fimc_v4l2_set_src(fimc->dev_fd, fimc->hw_ver, ¶ms->src) < 0) { - SEC_HWC_Log(HWC_LOG_ERROR, "fimc_v4l2_set_src is failed\n"); - return -1; - } - - fimc_src_buf.planes = src_planes; - fimc_dst_buf.planes = dst_planes; - - ret = fimc_handle_oneshot(fimc->dev_fd, &fimc_src_buf, &fimc_dst_buf); - - if (ret < 0) { - SEC_HWC_Log(HWC_LOG_ERROR,"fimc_handle_oneshot = %d\n",ret); - if (ret == -2) { - fimc_v4l2_clr_buf(fimc->dev_fd, V4L2_BUF_TYPE_OUTPUT); - } else if (ret == -3) { - fimc_v4l2_clr_buf(fimc->dev_fd, V4L2_BUF_TYPE_OUTPUT); - fimc_v4l2_clr_buf(fimc->dev_fd, V4L2_BUF_TYPE_CAPTURE); - } - return ret; - } -#else if (fimc_handle_oneshot(fimc->dev_fd, &fimc_src_buf, NULL) < 0) { + ALOGE("fimcrun fail"); fimc_v4l2_clr_buf(fimc->dev_fd, V4L2_BUF_TYPE_OUTPUT); return -1; } -#endif return 0; } -#ifdef SUB_TITLES_HWC -int createG2d(sec_g2d_t *g2d) -{ - g2d->dev_fd = open(SEC_G2D_DEV_NAME, O_RDWR); - - if (g2d->dev_fd <= 0) { - SEC_HWC_Log(HWC_LOG_ERROR, "%s::G2d open error (%d)", __func__, errno); - goto err; - } - - return 0; -err: - if (0 < g2d->dev_fd) - close(g2d->dev_fd); - g2d->dev_fd =0; - - return -1; -} - -int destroyG2d(sec_g2d_t *g2d) -{ - // close - if (0 < g2d->dev_fd) - close(g2d->dev_fd); - g2d->dev_fd = 0; - - return 0; -} -#endif - int createFimc(s5p_fimc_t *fimc) { struct v4l2_capability cap; @@ -1575,8 +1157,6 @@ int createFimc(s5p_fimc_t *fimc) goto err; } -#ifdef BOARD_USE_V4L2_ION -#else vc.id = V4L2_CID_FIMC_VERSION; vc.value = 0; @@ -1585,7 +1165,6 @@ int createFimc(s5p_fimc_t *fimc) goto err; } fimc->hw_ver = vc.value; -#endif return 0; @@ -1622,7 +1201,6 @@ int runFimc(struct hwc_context_t *ctx, unsigned int src_phys_addr = 0; unsigned int dst_phys_addr = 0; int rotate_value = 0; - int flag_force_memcpy = 0; int32_t src_color_space; int32_t dst_color_space; @@ -1632,7 +1210,7 @@ int runFimc(struct hwc_context_t *ctx, return -1; /* 2. destination address and size */ - dst_phys_addr = get_dst_phys_addr(ctx, dst_img, dst_rect, &flag_force_memcpy); + dst_phys_addr = dst_img->base; if (0 == dst_phys_addr) return -2; @@ -1645,433 +1223,38 @@ int runFimc(struct hwc_context_t *ctx, return -4; /* 4. FIMC: src_rect of src_img => dst_rect of dst_img */ - if (runcFimcCore(ctx, src_phys_addr, src_img, src_rect, + if (runFimcCore(ctx, src_phys_addr, src_img, src_rect, (uint32_t)src_color_space, dst_phys_addr, dst_img, dst_rect, (uint32_t)dst_color_space, transform) < 0) return -5; - if (flag_force_memcpy == 1) { -#ifdef USE_HW_PMEM - if (0 != ctx->sec_pmem.sec_pmem_alloc[1].size) { - struct s3c_mem_dma_param s3c_mem_dma; - - s3c_mem_dma.src_addr = - (unsigned long)(ctx->sec_pmem.sec_pmem_alloc[1].virt_addr); - s3c_mem_dma.size = ctx->sec_pmem.sec_pmem_alloc[1].size; - - ioctl(ctx->s3c_mem.fd, S3C_MEM_CACHE_INVAL, &s3c_mem_dma); - - memcpy((void*)((unsigned int)dst_img->base), - (void *)(ctx->sec_pmem.sec_pmem_alloc[1].virt_addr), - ctx->sec_pmem.sec_pmem_alloc[1].size); - } else -#endif - { - struct s3c_mem_alloc *ptr_mem_alloc = &ctx->s3c_mem.mem_alloc[1]; - struct s3c_mem_dma_param s3c_mem_dma; - - s3c_mem_dma.src_addr = (unsigned long)ptr_mem_alloc->vir_addr; - s3c_mem_dma.size = ptr_mem_alloc->size; - - ioctl(ctx->s3c_mem.fd, S3C_MEM_CACHE_INVAL, &s3c_mem_dma); - - memcpy((void*)((unsigned int)dst_img->base), - (void *)ptr_mem_alloc->vir_addr, ptr_mem_alloc->size); - } - } - return 0; } -#ifdef SUB_TITLES_HWC -static int get_g2d_src_phys_addr(struct hwc_context_t *ctx, g2d_rect *src_rect) -{ - sec_g2d_t *g2d = &ctx->g2d; - struct s3c_mem_alloc *ptr_mem_alloc = &ctx->s3c_mem.mem_alloc[0]; -#ifdef USE_HW_PMEM - sec_pmem_alloc_t *pm_alloc = &ctx->sec_pmem.sec_pmem_alloc[0]; -#endif - - unsigned int src_virt_addr = 0; - unsigned int src_phys_addr = 0; - unsigned int src_frame_size = 0; - - struct pmem_region region; - - // error check routine - if (0 == src_rect->virt_addr) { - SEC_HWC_Log(HWC_LOG_ERROR, "%s invalid src address\n", __func__); - return 0; - } - - src_frame_size = FRAME_SIZE(src_rect->color_format, - src_rect->full_w, src_rect->full_h); - if (src_frame_size == 0) { - SEC_HWC_Log(HWC_LOG_ERROR, "%s::FRAME_SIZE fail", __func__); - return 0; - } - -#ifdef USE_HW_PMEM - if (0 <= checkPmem(&ctx->sec_pmem, 0, src_frame_size)) { - src_virt_addr = pm_alloc->virt_addr; - src_phys_addr = pm_alloc->phys_addr; - pm_alloc->size = src_frame_size; - } else -#endif - if (0 <= checkMem(&ctx->s3c_mem, 0, src_frame_size)) { - src_virt_addr = ptr_mem_alloc->vir_addr; - src_phys_addr = ptr_mem_alloc->phy_addr; - ptr_mem_alloc->size = src_frame_size; - } else { - SEC_HWC_Log(HWC_LOG_ERROR, "%s::check_mem fail", __func__); - return 0; - } - memcpy((void *)src_virt_addr, (void*)((unsigned int)src_rect->virt_addr), src_frame_size); - - return src_phys_addr; -} - -int get_HAL_2_G2D_FORMAT(int format) -{ - switch (format) { - case HAL_PIXEL_FORMAT_RGBA_8888: return G2D_ABGR_8888; - case HAL_PIXEL_FORMAT_RGBX_8888: return G2D_XBGR_8888; - case HAL_PIXEL_FORMAT_BGRA_8888: return G2D_ARGB_8888; - case HAL_PIXEL_FORMAT_RGB_888: return G2D_PACKED_BGR_888; - case HAL_PIXEL_FORMAT_RGB_565: return G2D_RGB_565; - case HAL_PIXEL_FORMAT_RGBA_5551: return G2D_RGBA_5551; - case HAL_PIXEL_FORMAT_RGBA_4444: return G2D_RGBA_4444; - default: - return -1; - } -} - -static inline int rotateValueHAL2G2D(unsigned char transform) -{ - int rotate_flag = transform & 0x7; - - switch (rotate_flag) { - case HAL_TRANSFORM_ROT_90: return G2D_ROT_90; - case HAL_TRANSFORM_ROT_180: return G2D_ROT_180; - case HAL_TRANSFORM_ROT_270: return G2D_ROT_270; +int check_yuv_format(unsigned int color_format) { + switch (color_format) { + case HAL_PIXEL_FORMAT_YV12: + case HAL_PIXEL_FORMAT_YCbCr_422_SP: + case HAL_PIXEL_FORMAT_YCrCb_420_SP: + case HAL_PIXEL_FORMAT_YCbCr_422_I: + case HAL_PIXEL_FORMAT_YCbCr_422_P: + case HAL_PIXEL_FORMAT_YCbCr_420_P: + case HAL_PIXEL_FORMAT_YCbCr_420_I: + case HAL_PIXEL_FORMAT_CbYCrY_422_I: + case HAL_PIXEL_FORMAT_CbYCrY_420_I: + case HAL_PIXEL_FORMAT_YCbCr_420_SP: + case HAL_PIXEL_FORMAT_YCrCb_422_SP: + case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP: + case HAL_PIXEL_FORMAT_CUSTOM_YCrCb_420_SP: + case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP_TILED: + case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_SP: + case HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_SP: + case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_I: + case HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_I: + case HAL_PIXEL_FORMAT_CUSTOM_CbYCrY_422_I: + case HAL_PIXEL_FORMAT_CUSTOM_CrYCbY_422_I: + return 1; default: - return G2D_ROT_0; - } -} - -int runG2d(struct hwc_context_t *ctx, g2d_rect *src_rect, g2d_rect *dst_rect, - uint32_t transform) -{ - sec_g2d_t * g2d = &ctx->g2d; - g2d_flag flag = {G2D_ROT_0, G2D_ALPHA_BLENDING_OPAQUE, 0, 0, 0, 0, 0, 0}; - int rotate_value = 0; - - // 1 : source address and size - src_rect->phys_addr = get_g2d_src_phys_addr(ctx, src_rect); - if (0 == src_rect->phys_addr) - return -1; - - // 2 : destination address and size - if (0 == dst_rect->phys_addr) - return -2; - - // check whether g2d supports the src format - src_rect->color_format = get_HAL_2_G2D_FORMAT(src_rect->color_format); - if (0 > src_rect->color_format) - return -3; - - dst_rect->color_format = get_HAL_2_G2D_FORMAT(dst_rect->color_format); - if (0 > dst_rect->color_format) - return -4; - - flag.rotate_val = rotateValueHAL2G2D(transform); - - // scale and rotate and alpha with FIMG - if(stretchSecFimg(src_rect, dst_rect, &flag) < 0) - return -5; - - return 0; -} -#endif - -int createMem(struct s3c_mem_t *mem, unsigned int index, unsigned int size) -{ - struct s3c_mem_alloc *ptr_mem_alloc; - struct s3c_mem_alloc mem_alloc_info; - - if (index >= NUM_OF_MEM_OBJ) { - SEC_HWC_Log(HWC_LOG_ERROR, "%s::invalid index (%d >= %d)", - __func__, index, NUM_OF_MEM_OBJ); - goto err; - } - - ptr_mem_alloc = &mem->mem_alloc[index]; - - if (mem->fd <= 0) { - mem->fd = open(S3C_MEM_DEV_NAME, O_RDWR); - if (mem->fd <= 0) { - SEC_HWC_Log(HWC_LOG_ERROR, "%s::open(%s) fail(%s)", - __func__, S3C_MEM_DEV_NAME, strerror(errno)); - goto err; - } - } - - // kcoolsw : what the hell of this line?? - if (0 == size) return 0; - - mem_alloc_info.size = size; - - if (ioctl(mem->fd, S3C_MEM_CACHEABLE_ALLOC, &mem_alloc_info) < 0) { - SEC_HWC_Log(HWC_LOG_ERROR, "%s::S3C_MEM_ALLOC(size : %d) fail", - __func__, mem_alloc_info.size); - goto err; } - - ptr_mem_alloc->phy_addr = mem_alloc_info.phy_addr; - ptr_mem_alloc->vir_addr = mem_alloc_info.vir_addr; - ptr_mem_alloc->size = mem_alloc_info.size; - - return 0; - -err: - if (0 < mem->fd) - close(mem->fd); - mem->fd = 0; - - return 0; -} - -int destroyMem(struct s3c_mem_t *mem) -{ - int i; - struct s3c_mem_alloc *ptr_mem_alloc; - - if (mem->fd <= 0) { - SEC_HWC_Log(HWC_LOG_ERROR, "%s::invalied fd(%d) fail", __func__, mem->fd); - return -1; - } - - for (i = 0; i < NUM_OF_MEM_OBJ; i++) { - ptr_mem_alloc = &mem->mem_alloc[i]; - - if (0 != ptr_mem_alloc->vir_addr) { - if (ioctl(mem->fd, S3C_MEM_FREE, ptr_mem_alloc) < 0) { - SEC_HWC_Log(HWC_LOG_ERROR, "%s::S3C_MEM_FREE fail", __func__); - return -1; - } - - ptr_mem_alloc->phy_addr = 0; - ptr_mem_alloc->vir_addr = 0; - ptr_mem_alloc->size = 0; - } - } - - close(mem->fd); - mem->fd = 0; - - return 0; -} - -int checkMem(struct s3c_mem_t *mem, unsigned int index, unsigned int size) -{ - int ret; - struct s3c_mem_alloc *ptr_mem_alloc; - struct s3c_mem_alloc mem_alloc_info; - - if (index >= NUM_OF_MEM_OBJ) { - SEC_HWC_Log(HWC_LOG_ERROR, "%s::invalid index (%d >= %d)", __func__, - index, NUM_OF_MEM_OBJ); - return -1; - } - - if (mem->fd <= 0) { - ret = createMem(mem, index, size); - return ret; - } - - ptr_mem_alloc = &mem->mem_alloc[index]; - - if (ptr_mem_alloc->size < (int)size) { - if (0 < ptr_mem_alloc->size) { - // free allocated mem - if (ioctl(mem->fd, S3C_MEM_FREE, ptr_mem_alloc) < 0) { - SEC_HWC_Log(HWC_LOG_ERROR, "%s::S3C_MEM_FREE fail", __func__); - return -1; - } - } - - // allocate mem with requested size - mem_alloc_info.size = size; - if (ioctl(mem->fd, S3C_MEM_CACHEABLE_ALLOC, &mem_alloc_info) < 0) { - SEC_HWC_Log(HWC_LOG_ERROR, "%s::S3C_MEM_ALLOC(size : %d) fail", - __func__, mem_alloc_info.size); - return -1; - } - - ptr_mem_alloc->phy_addr = mem_alloc_info.phy_addr; - ptr_mem_alloc->vir_addr = mem_alloc_info.vir_addr; - ptr_mem_alloc->size = mem_alloc_info.size; - } - - return 0; } - -#ifdef USE_HW_PMEM -int createPmem(sec_pmem_t *pm, unsigned int buf_size) -{ - int master_fd, err = 0, i; - void *base; - unsigned int phys_base; - size_t size, sub_size[NUM_OF_MEM_OBJ]; - struct pmem_region region; - - master_fd = open(PMEM_DEVICE_DEV_NAME, O_RDWR, 0); - if (master_fd < 0) { - pm->pmem_master_fd = -1; - if (EACCES == errno) { - return 0; - } else { - SEC_HWC_Log(HWC_LOG_ERROR, "%s::open(%s) fail(%s)", - __func__, PMEM_DEVICE_DEV_NAME, strerror(errno)); - return -errno; - } - } - - if (ioctl(master_fd, PMEM_GET_TOTAL_SIZE, ®ion) < 0) { - SEC_HWC_Log(HWC_LOG_ERROR, "PMEM_GET_TOTAL_SIZE failed, default mode"); - size = 8<<20; // 8 MiB - } else { - size = region.len; - } - - base = mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, master_fd, 0); - if (base == MAP_FAILED) { - SEC_HWC_Log(HWC_LOG_ERROR, "[%s] mmap failed : %d (%s)", __func__, - errno, strerror(errno)); - base = 0; - close(master_fd); - master_fd = -1; - return -errno; - } - - if (ioctl(master_fd, PMEM_GET_PHYS, ®ion) < 0) { - SEC_HWC_Log(HWC_LOG_ERROR, "PMEM_GET_PHYS failed, limp mode"); - region.offset = 0; - } - - pm->pmem_master_fd = master_fd; - pm->pmem_master_base = base; - pm->pmem_total_size = size; - //pm->pmem_master_phys_base = region.offset; - phys_base = region.offset; - - // sec_pmem_alloc[0] for temporary buffer for source - sub_size[0] = buf_size; - sub_size[0] = roundUpToPageSize(sub_size[0]); - - for (i = 0; i < NUM_OF_MEM_OBJ; i++) { - sec_pmem_alloc_t *pm_alloc = &(pm->sec_pmem_alloc[i]); - int fd, ret; - int offset = i ? sub_size[i-1] : 0; - struct pmem_region sub = { offset, sub_size[i] }; - - // create the "sub-heap" - if (0 > (fd = open(PMEM_DEVICE_DEV_NAME, O_RDWR, 0))) { - SEC_HWC_Log(HWC_LOG_ERROR, - "[%s][index=%d] open failed (%dL) : %d (%s)", - __func__, i, __LINE__, errno, strerror(errno)); - return -errno; - } - - // connect to it - if (0 != (ret = ioctl(fd, PMEM_CONNECT, pm->pmem_master_fd))) { - SEC_HWC_Log(HWC_LOG_ERROR, - "[%s][index=%d] ioctl(PMEM_CONNECT) failed : %d (%s)", - __func__, i, errno, strerror(errno)); - close(fd); - return -errno; - } - - // make it available to the client process - if (0 != (ret = ioctl(fd, PMEM_MAP, &sub))) { - SEC_HWC_Log(HWC_LOG_ERROR, - "[%s][index=%d] ioctl(PMEM_MAP) failed : %d (%s)", - __func__, i, errno, strerror(errno)); - close(fd); - return -errno; - } - - pm_alloc->fd = fd; - pm_alloc->total_size = sub_size[i]; - pm_alloc->offset = offset; - pm_alloc->virt_addr = (unsigned int)base + (unsigned int)offset; - pm_alloc->phys_addr = (unsigned int)phys_base + (unsigned int)offset; - -#if defined (PMEM_DEBUG) - SEC_HWC_Log(HWC_LOG_DEBUG, "[%s] pm_alloc[%d] fd=%d total_size=%d " - "offset=0x%x virt_addr=0x%x phys_addr=0x%x", - __func__, i, pm_alloc->fd, pm_alloc->total_size, - pm_alloc->offset, pm_alloc->virt_addr, pm_alloc->phys_addr); -#endif - } - - return err; -} - -int destroyPmem(sec_pmem_t *pm) -{ - int i, err; - - for (i=0; isec_pmem_alloc[i]); - - if (0 <= pm_alloc->fd) { - struct pmem_region sub = { pm_alloc->offset, pm_alloc->total_size }; - - if (0 > (err = ioctl(pm_alloc->fd, PMEM_UNMAP, &sub))) - SEC_HWC_Log(HWC_LOG_ERROR, - "[%s][index=%d] ioctl(PMEM_UNMAP) failed : %d (%s)", - __func__, i, errno, strerror(errno)); -#if defined (PMEM_DEBUG) - else - SEC_HWC_Log(HWC_LOG_DEBUG, - "[%s] pm_alloc[%d] unmap fd=%d total_size=%d offset=0x%x", - __func__, i, pm_alloc->fd, pm_alloc->total_size, - pm_alloc->offset); -#endif - close(pm_alloc->fd); - - pm_alloc->fd = -1; - pm_alloc->total_size = 0; - pm_alloc->offset = 0; - pm_alloc->virt_addr = 0; - pm_alloc->phys_addr = 0; - } - } - - if (0 <= pm->pmem_master_fd) { - munmap(pm->pmem_master_base, pm->pmem_total_size); - close(pm->pmem_master_fd); - pm->pmem_master_fd = -1; - } - - pm->pmem_master_base = 0; - pm->pmem_total_size = 0; - - return 0; -} - -int checkPmem(sec_pmem_t *pm, unsigned int index, unsigned int requested_size) -{ - sec_pmem_alloc_t *pm_alloc = &(pm->sec_pmem_alloc[index]); - - if (0 < pm_alloc->virt_addr && - requested_size <= (unsigned int)(pm_alloc->total_size)) - return 0; - - pm_alloc->size = 0; - return -1; -} - -#endif diff --git a/exynos4/hal/libhwcomposer/SecHWCUtils.h b/exynos4/hal/libhwcomposer/SecHWCUtils.h index 98730038..ac1c9ef4 100644 --- a/exynos4/hal/libhwcomposer/SecHWCUtils.h +++ b/exynos4/hal/libhwcomposer/SecHWCUtils.h @@ -17,8 +17,8 @@ /* * * @author Rama, Meka(v.meka@samsung.com) - Sangwoo, Park(sw5771.park@samsung.com) - Jamie, Oh (jung-min.oh@samsung.com) + Sangwoo, Park(sw5771.park@samsung.com) + Jamie, Oh (jung-min.oh@samsung.com) * @date 2011-03-11 * */ @@ -34,33 +34,33 @@ #include #include -#ifdef BOARD_USE_V4L2_ION -#include -#include "s5p_fimc_v4l2.h" -#include "sec_utils_v4l2.h" -#else #include +#include "videodev2.h" #include "s5p_fimc.h" #include "sec_utils.h" -#endif - -#include #include #include +#include #include #include "linux/fb.h" #include "s3c_lcd.h" -#include "s3c_mem.h" #include "sec_format.h" -#define HWC_DEBUG +#define HWC_DEBUG 1 #if defined(BOARD_USES_FIMGAPI) #include "sec_g2d.h" -//#define SUB_TITLES_HWC #endif +#define SKIP_DUMMY_UI_LAY_DRAWING + +#ifdef SKIP_DUMMY_UI_LAY_DRAWING +#define GL_WA_OVLY_ALL +#define THRES_FOR_SWAP (3427) /* 60sec in Frames. 57fps * 60 = 3427 */ +#endif + +#define NUM_OF_DUMMY_WIN (4) #define NUM_OF_WIN (2) #define NUM_OF_WIN_BUF (2) #define NUM_OF_MEM_OBJ (1) @@ -72,27 +72,14 @@ #define MAX_RESIZING_RATIO_LIMIT (63) #ifdef SAMSUNG_EXYNOS4x12 -#ifdef BOARD_USE_V4L2_ION -#define PP_DEVICE_DEV_NAME "/dev/video4" -#else #define PP_DEVICE_DEV_NAME "/dev/video3" #endif -#endif #ifdef SAMSUNG_EXYNOS4210 #define PP_DEVICE_DEV_NAME "/dev/video1" #endif - -#define S3C_MEM_DEV_NAME "/dev/s3c-mem" -#define PMEM_DEVICE_DEV_NAME "/dev/pmem_gpu1" - -#ifdef BOARD_USE_V4L2_ION -#undef USE_HW_PMEM -#else -#define USE_HW_PMEM -#endif - -#define PMEM_SIZE (1920 * 1280 * 2) +/* cacheable configuration */ +#define V4L2_CID_CACHEABLE (V4L2_CID_BASE+40) struct sec_rect { int32_t x; @@ -127,34 +114,6 @@ inline int SEC_MAX(int x, int y) return ((x > y) ? x : y); } -struct s3c_mem_t { - int fd; - struct s3c_mem_alloc mem_alloc[NUM_OF_MEM_OBJ]; -}; - -#ifdef USE_HW_PMEM -typedef struct __sec_pmem_alloc { - int fd; - int total_size; - int offset; - int size; - unsigned int virt_addr; - unsigned int phys_addr; -} sec_pmem_alloc_t; - -typedef struct __sec_pmem { - int pmem_master_fd; - void *pmem_master_base; - int pmem_total_size; - sec_pmem_alloc_t sec_pmem_alloc[NUM_OF_MEM_OBJ]; -} sec_pmem_t; - -inline size_t roundUpToPageSize(size_t x) -{ - return (x + (PAGE_SIZE-1)) & ~(PAGE_SIZE-1); -} -#endif - struct hwc_win_info_t { int fd; int size; @@ -167,9 +126,6 @@ struct hwc_win_info_t { int layer_index; int status; int vsync; -#ifdef BOARD_USE_V4L2_ION - int ion_fd; -#endif struct fb_fix_screeninfo fix_info; struct fb_var_screeninfo var_info; @@ -187,24 +143,46 @@ enum { HWC_VIRT_MEM_TYPE, }; +#ifdef SKIP_DUMMY_UI_LAY_DRAWING +struct hwc_ui_lay_info{ + uint32_t layer_prev_buf; + int layer_index; + int status; +}; +#endif + struct hwc_context_t { - hwc_composer_device_t device; + hwc_composer_device_1_t device; /* our private state goes below here */ struct hwc_win_info_t win[NUM_OF_WIN]; - struct fb_var_screeninfo lcd_info; - s5p_fimc_t fimc; -#ifdef SUB_TITLES_HWC - sec_g2d_t g2d; +#ifdef SKIP_DUMMY_UI_LAY_DRAWING + struct hwc_ui_lay_info win_virt[NUM_OF_DUMMY_WIN]; + int fb_lay_skip_initialized; + int num_of_fb_lay_skip; +#ifdef GL_WA_OVLY_ALL + int ui_skip_frame_cnt; #endif - struct s3c_mem_t s3c_mem; -#ifdef USE_HW_PMEM - sec_pmem_t sec_pmem; #endif + + struct fb_var_screeninfo lcd_info; + s5p_fimc_t fimc; + hwc_procs_t *procs; + pthread_t uevent_thread; + pthread_t vsync_thread; + int num_of_fb_layer; int num_of_hwc_layer; - int num_2d_blit_layer; + int num_of_fb_layer_prev; + int num_2d_blit_layer; uint32_t layer_prev_buf[NUM_OF_WIN]; + + int num_of_ext_disp_layer; + int num_of_ext_disp_video_layer; + +#ifdef BOARD_USES_HDMI + int hdmi_cable_status; +#endif }; typedef enum _LOG_LEVEL { @@ -220,8 +198,8 @@ typedef enum _LOG_LEVEL { #else #define SEC_HWC_Log(a, ...) \ do { \ - if (a == HWC_LOG_ERROR) \ - ((void)_SEC_HWC_Log(a, SEC_HWC_LOG_TAG, __VA_ARGS__)); \ + if (a == HWC_LOG_ERROR) \ + ((void)_SEC_HWC_Log(a, SEC_HWC_LOG_TAG, __VA_ARGS__)); \ } while (0) #endif @@ -305,27 +283,9 @@ int window_get_global_lcd_info(int fd, struct fb_var_screeninfo *lcd_info); int createFimc (s5p_fimc_t *fimc); int destroyFimc(s5p_fimc_t *fimc); int runFimc(struct hwc_context_t *ctx, - struct sec_img *src_img, struct sec_rect *src_rect, - struct sec_img *dst_img, struct sec_rect *dst_rect, - uint32_t transform); - -#ifdef SUB_TITLES_HWC -int runG2d(struct hwc_context_t *ctx, - g2d_rect *src_rect, g2d_rect *dst_rect, - uint32_t transform); - -int destroyG2d(sec_g2d_t *g2d); -int createG2d(sec_g2d_t *g2d); -#endif - -int createMem (struct s3c_mem_t *mem, unsigned int index, unsigned int size); -int destroyMem(struct s3c_mem_t *mem); -int checkMem (struct s3c_mem_t *mem, unsigned int index, unsigned int size); - -#ifdef USE_HW_PMEM -int createPmem (sec_pmem_t *pm, unsigned int size); -int destroyPmem(sec_pmem_t *pm); -int checkPmem (sec_pmem_t *pm, unsigned int index, unsigned int size); -#endif + struct sec_img *src_img, struct sec_rect *src_rect, + struct sec_img *dst_img, struct sec_rect *dst_rect, + uint32_t transform); +int check_yuv_format(unsigned int color_format); #endif /* ANDROID_SEC_HWC_UTILS_H_*/