summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlistair Strachan <alistair.strachan@imgtec.com>2017-01-11 19:26:59 -0800
committerDaniel Cardenas <danielcar@google.com>2017-02-14 10:20:40 -0800
commit2892c7487da7780e0135978e709359f6d75e19b8 (patch)
treebb2e26c36667f4f3d257b40f901ab036f1f36688
parent61050a01c800b1948a0b02f6a487b8fb1c957e40 (diff)
downloadutils-2892c7487da7780e0135978e709359f6d75e19b8.tar.gz
Remove use of deprecated gralloc APIs.
In gralloc v1, the lock/unlock methods that do not take a sync fence have been removed. Port the utils/ISV module to use the newer methods which are also available in gralloc v0. This change also ports utils/ISV to use the new GPU DDK interface. Test: Manual, youtube video worked Bug: 34625842 Change-Id: Ie664a8ae2e96b54d53389a389352810a44dfeadd
-rw-r--r--ISV/Android.mk2
-rw-r--r--ISV/base/isv_bufmanager.cpp22
-rw-r--r--ISV/include/isv_bufmanager.h4
3 files changed, 24 insertions, 4 deletions
diff --git a/ISV/Android.mk b/ISV/Android.mk
index 07cf4c7..168b532 100644
--- a/ISV/Android.mk
+++ b/ISV/Android.mk
@@ -26,9 +26,11 @@ LOCAL_SHARED_LIBRARIES := \
libva-android \
libmrm_omx_adaptor \
libmedia \
+ libsync \
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/include \
+ system/core/libsync/include \
$(call include-path-for, frameworks-openmax) \
$(TARGET_OUT_HEADERS)/libmedia_utils_vpp \
$(TARGET_OUT_HEADERS)/display \
diff --git a/ISV/base/isv_bufmanager.cpp b/ISV/base/isv_bufmanager.cpp
index 3b02ab4..8e5aa2d 100644
--- a/ISV/base/isv_bufmanager.cpp
+++ b/ISV/base/isv_bufmanager.cpp
@@ -22,6 +22,7 @@
#include "isv_bufmanager.h"
#ifndef TARGET_VPP_USE_GEN
#include "hal_public.h"
+#include <sync/sync.h>
#endif
//#define LOG_NDEBUG 0
@@ -69,12 +70,12 @@ status_t ISVBuffer::initBufferInfo(uint32_t hackFormat)
}
int32_t err = 0;
+#ifdef TARGET_VPP_USE_GEN
if (!mpGralloc) {
err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, (hw_module_t const**)&mpGralloc);
if (0 != err)
return UNKNOWN_ERROR;
}
-#ifdef TARGET_VPP_USE_GEN
ufo_buffer_details_t info;
memset(&info, 0, sizeof(ufo_buffer_details_t));
@@ -88,6 +89,11 @@ status_t ISVBuffer::initBufferInfo(uint32_t hackFormat)
mStride = info.pitch;
mColorFormat = info.format;
#else
+ if (!mpGralloc) {
+ err = gralloc_open_img(&mpGralloc);
+ if (0 != err)
+ return UNKNOWN_ERROR;
+ }
IMG_native_handle_t* grallocHandle = (IMG_native_handle_t*)mGrallocHandle;
mStride = grallocHandle->aiStride[0];
mSurfaceHeight = grallocHandle->iHeight;
@@ -126,9 +132,13 @@ status_t ISVBuffer::clearIfNeed()
if ((mFlags & ISV_BUFFER_NEED_CLEAR) && mpGralloc) {
int32_t usage = GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN;
void *vaddr[GRALLOC_SUB_BUFFER_MAX];
+ const gralloc1_rect_t r = {
+ .width = (int32_t)mStride,
+ .height = (int32_t)mSurfaceHeight
+ };
+ int err, releaseFence = -1;
- int32_t err = mpGralloc->lock(mpGralloc, (buffer_handle_t)mGrallocHandle, usage, 0, 0, mStride, mSurfaceHeight, &vaddr[0]);
-
+ err = gralloc_lock_async_img(mpGralloc, (buffer_handle_t)mGrallocHandle, usage, &r, &vaddr[0], -1);
if (0 != err) {
ALOGE("%s: get graphic buffer ptr failed", __func__);
return UNKNOWN_ERROR;
@@ -140,7 +150,11 @@ status_t ISVBuffer::clearIfNeed()
memcpy(ptr, random_buf, sizeof(random_buf));
ptr += sizeof(random_buf);
}
- mpGralloc->unlock(mpGralloc, (buffer_handle_t)mGrallocHandle);
+ gralloc_unlock_async_img(mpGralloc, (buffer_handle_t)mGrallocHandle, &releaseFence);
+ if (releaseFence >= 0) {
+ sync_wait(releaseFence, -1);
+ close(releaseFence);
+ }
ALOGD_IF(ISV_BUFFER_MANAGER_DEBUG, "%s: clear isv buffer %p finished, buffer size %d", __func__, this, buffer_size);
mFlags &= ~ISV_BUFFER_NEED_CLEAR;
}
diff --git a/ISV/include/isv_bufmanager.h b/ISV/include/isv_bufmanager.h
index 18c3209..7b0bfb0 100644
--- a/ISV/include/isv_bufmanager.h
+++ b/ISV/include/isv_bufmanager.h
@@ -134,7 +134,11 @@ private:
ISV_BUFFERTYPE mType;
int32_t mSurface;
uint32_t mFlags;
+#ifdef TARGET_VPP_USE_GEN
gralloc_module_t* mpGralloc;
+#else
+ const hw_device_t* mpGralloc;
+#endif
};
class ISVBufferManager: public RefBase