diff options
author | Daniel Cardenas <danielcar@google.com> | 2017-02-23 04:31:07 +0000 |
---|---|---|
committer | Daniel Cardenas <danielcar@google.com> | 2017-02-23 04:31:07 +0000 |
commit | 098d51ceb6eb2ef08c89224446163aa17aee7cbc (patch) | |
tree | d67c54f2268514d7b971114d1728e0a90ef8cdc4 | |
parent | 0f0b7895526d78458d8c4a09faaaa646e5fc7466 (diff) | |
download | psb_video-098d51ceb6eb2ef08c89224446163aa17aee7cbc.tar.gz |
Revert "Remove use of deprecated gralloc APIs."
This reverts commit 0f0b7895526d78458d8c4a09faaaa646e5fc7466.
Change-Id: I19c3bcd70b0b989c9205940d24d20e8092604ae7
-rw-r--r-- | src/Android.mk | 3 | ||||
-rw-r--r-- | src/android/psb_gralloc.cpp | 100 |
2 files changed, 50 insertions, 53 deletions
diff --git a/src/Android.mk b/src/Android.mk index 8ec21ab..5cbe6b5 100644 --- a/src/Android.mk +++ b/src/Android.mk @@ -44,7 +44,6 @@ LOCAL_CFLAGS := \ LOCAL_C_INCLUDES := \ $(call include-path-for, libhardware)/hardware \ - system/core/libsync/include \ $(TARGET_OUT_HEADERS)/libva \ $(TARGET_OUT_HEADERS)/libttm \ $(TARGET_OUT_HEADERS)/libwsbm \ @@ -54,7 +53,7 @@ LOCAL_C_INCLUDES := \ $(LOCAL_PATH)/hwdefs LOCAL_SHARED_LIBRARIES += libdl libdrm libwsbm libcutils \ - libutils libbinder libhardware liblog libsync + libutils libbinder libhardware liblog LOCAL_SRC_FILES := \ object_heap.c \ diff --git a/src/android/psb_gralloc.cpp b/src/android/psb_gralloc.cpp index d304ac3..a920fd5 100644 --- a/src/android/psb_gralloc.cpp +++ b/src/android/psb_gralloc.cpp @@ -36,9 +36,9 @@ #include <hardware/hardware.h> #ifdef BAYTRAIL #include <ufo/gralloc.h> -#else +#endif +#ifndef BAYTRAIL #include <hal/hal_public.h> -#include <sync/sync.h> #endif using namespace android; @@ -49,19 +49,16 @@ using namespace android; #define LOG_TAG "pvr_drv_video" -#ifdef BAYTRAIL -static const gralloc_module_t *mGralloc; -#else -static const hw_device_t *mGralloc; -#endif +static hw_module_t const *module; +static gralloc_module_t *mAllocMod; /* get by force hw_module_t */ int gralloc_lock(buffer_handle_t handle, - int usage, int left, int top, int width, int height, - void** vaddr) + int usage, int left, int top, int width, int height, + void** vaddr) { int err, j; - if (!mGralloc) { + if (!mAllocMod) { ALOGW("%s: gralloc module has not been initialized. Should initialize it first", __func__); if (gralloc_init()) { ALOGE("%s: can't find the %s module", __func__, GRALLOC_HARDWARE_MODULE_ID); @@ -69,20 +66,36 @@ int gralloc_lock(buffer_handle_t handle, } } -#ifdef BAYTRAIL - err = mGralloc->lock(mGralloc, handle, usage, - left, top, width, height, - vaddr); -#else - const gralloc1_rect_t r = { - .left = left, - .top = top, - .width = width, - .height = height - }; - err = gralloc_lock_async_img(mGralloc, handle, usage, &r, vaddr, -1); -#endif + err = mAllocMod->lock(mAllocMod, handle, usage, + left, top, width, height, + vaddr); ALOGV("gralloc_lock: handle is %p, usage is %x, vaddr is %p.\n", handle, usage, *vaddr); + +//#ifdef BAYTRAIL +#if 0 + unsigned char *tmp_buffer = (unsigned char *)(*vaddr); + int dst_stride; + if (width <= 512) + dst_stride = 512; + else if (width <= 1024) + dst_stride = 1024; + else if (width <= 1280) + dst_stride = 1280; + else if (width <= 2048) + dst_stride = 2048; + + int align_h = 32; + int dsth = (height + align_h - 1) & ~(align_h - 1); + LOGD("width is %d, dst_stride is %d, dsth is %d.\n", + width, dst_stride, dsth); + + for (j = 0; j < dst_stride * dsth * 3 / 2; j = j + 4096) { + *(tmp_buffer + j) = 0xa5; + if (*(tmp_buffer + j) != 0xa5) + LOGE("access page failed, width is %d, dst_stride is %d, dsth is %d.\n", + width, dst_stride, dsth); + } +#endif if (err){ ALOGE("lock(...) failed %d (%s).\n", err, strerror(-err)); return -1; @@ -97,7 +110,7 @@ int gralloc_unlock(buffer_handle_t handle) { int err; - if (!mGralloc) { + if (!mAllocMod) { ALOGW("%s: gralloc module has not been initialized. Should initialize it first", __func__); if (gralloc_init()) { ALOGE("%s: can't find the %s module", __func__, GRALLOC_HARDWARE_MODULE_ID); @@ -105,16 +118,7 @@ int gralloc_unlock(buffer_handle_t handle) } } -#ifdef BAYTRAIL - err = mGralloc->unlock(mGralloc, handle); -#else - int releaseFence = -1; - err = gralloc_unlock_async_img(mGralloc, handle, &releaseFence); - if (releaseFence >= 0) { - sync_wait(releaseFence, -1); - close(releaseFence); - } -#endif + err = mAllocMod->unlock(mAllocMod, handle); if (err) { ALOGE("unlock(...) failed %d (%s)", err, strerror(-err)); return -1; @@ -129,7 +133,7 @@ int gralloc_register(buffer_handle_t handle) { int err = 0; - if (!mGralloc) { + if (!mAllocMod) { ALOGW("%s: gralloc module has not been initialized.", __func__); if (gralloc_init()) { ALOGE("%s: can't find the %s module", __func__, @@ -138,7 +142,7 @@ int gralloc_register(buffer_handle_t handle) } } - err = gralloc_register_img(mGralloc, handle); + err = mAllocMod->registerBuffer(mAllocMod, handle); if (err) { ALOGE("%s failed with %d (%s).\n", __func__, err, strerror(-err)); return -1; @@ -153,7 +157,7 @@ int gralloc_unregister(buffer_handle_t handle) { int err = 0; - if (!mGralloc) { + if (!mAllocMod) { ALOGW("%s: gralloc module has not been initialized.", __func__); if (gralloc_init()) { ALOGE("%s: can't find the %s module", __func__, @@ -162,7 +166,7 @@ int gralloc_unregister(buffer_handle_t handle) } } - err = gralloc_unregister_img(mGralloc, handle); + err = mAllocMod->unregisterBuffer(mAllocMod, handle); if (err) { ALOGE("%s failed with %d (%s).\n", __func__, err, strerror(-err)); return -1; @@ -175,18 +179,13 @@ int gralloc_unregister(buffer_handle_t handle) int gralloc_init(void) { - int err; - -#ifdef BAYTRAIL - err = hw_get_module(GRALLOC_HW_MODULE_ID, (const hw_module_t **)&mGralloc); -#else - err = gralloc_open_img(&mGralloc); -#endif + int err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module); if (err) { ALOGE("FATAL: can't find the %s module", GRALLOC_HARDWARE_MODULE_ID); return -1; } else ALOGD("hw_get_module returned\n"); + mAllocMod = (gralloc_module_t *)module; return 0; } @@ -194,14 +193,13 @@ int gralloc_init(void) int gralloc_getdisplaystatus(buffer_handle_t handle, int* status) { int err; - -#ifdef BAYTRAIL - *status = mGralloc->perform(mGralloc, INTEL_UFO_GRALLOC_MODULE_PERFORM_GET_BO_STATUS, handle); - err = 0; -#else +#ifndef BAYTRAIL uint32_t _status = 0U; - err = gralloc_get_display_status_img(mGralloc, handle, &_status); + err = mAllocMod->perform(mAllocMod, GRALLOC_MODULE_GET_DISPLAY_STATUS_IMG, handle, &_status); *status = (int)_status; +#else + err = 0; + *status = mAllocMod->perform(mAllocMod, INTEL_UFO_GRALLOC_MODULE_PERFORM_GET_BO_STATUS, handle); #endif if (err){ ALOGE("gralloc_getdisplaystatus(...) failed %d (%s).\n", err, strerror(-err)); |