aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Cardenas <danielcar@google.com>2017-02-23 04:35:09 +0000
committerDaniel Cardenas <danielcar@google.com>2017-02-23 04:35:09 +0000
commitbf7b37e34b1bdebf5e063271a7f1cf6469412e85 (patch)
tree305cc7b430851694e4abbc40e3a6016c1d6b4c7a
parent407c8ca2b11d9e95d54dce98e347cae2f923ee2f (diff)
downloadlibmix-bf7b37e34b1bdebf5e063271a7f1cf6469412e85.tar.gz
Revert "Remove use of deprecated gralloc APIs."
This reverts commit 407c8ca2b11d9e95d54dce98e347cae2f923ee2f. Change-Id: I18fab02c71f6e874584b9068cc8a4b6a6f487e5f
-rw-r--r--videoencoder/Android.mk2
-rw-r--r--videoencoder/VideoEncoderUtils.cpp97
2 files changed, 57 insertions, 42 deletions
diff --git a/videoencoder/Android.mk b/videoencoder/Android.mk
index 828a968..2971ba2 100644
--- a/videoencoder/Android.mk
+++ b/videoencoder/Android.mk
@@ -34,7 +34,7 @@ endif
LOCAL_C_INCLUDES := \
$(TARGET_OUT_HEADERS)/libva \
$(call include-path-for, frameworks-native) \
- $(TARGET_OUT_HEADERS)/pvr/hal
+ $(TARGET_OUT_HEADERS)/pvr
ifeq ($(ENABLE_IMG_GRAPHICS),)
LOCAL_C_INCLUDES += \
diff --git a/videoencoder/VideoEncoderUtils.cpp b/videoencoder/VideoEncoderUtils.cpp
index b2b5c34..05569f0 100644
--- a/videoencoder/VideoEncoderUtils.cpp
+++ b/videoencoder/VideoEncoderUtils.cpp
@@ -20,41 +20,52 @@
#include <va/va_drmcommon.h>
#ifdef IMG_GFX
-#include "hal_public.h"
+#include <hal/hal_public.h>
+#include <hardware/gralloc.h>
#include <sync/sync.h>
//#define GFX_DUMP
#define OMX_INTEL_COLOR_FormatYUV420PackedSemiPlanar 0x7FA00E00
-static const hw_device_t *gGralloc;
+static hw_module_t const *gModule = NULL;
+static gralloc_module_t const *gAllocMod = NULL; /* get by force hw_module_t */
+static alloc_device_t *gAllocDev = NULL;
static int gfx_init(void) {
- int err = gralloc_open_img(&gGralloc);
+ int err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &gModule);
if (err) {
LOG_E("FATAL: can't find the %s module", GRALLOC_HARDWARE_MODULE_ID);
return -1;
} else
LOG_V("hw_get_module returned\n");
+ gAllocMod = (gralloc_module_t const *)gModule;
return 0;
}
static int gfx_alloc(uint32_t w, uint32_t h, int format,
- int usage, buffer_handle_t* handle, int32_t* stride) {
+ int usage, buffer_handle_t* handle, int32_t* stride) {
int err;
- if (!gGralloc) {
- if (gfx_init()) {
- LOG_E("can't find the %s module", GRALLOC_HARDWARE_MODULE_ID);
+ if (!gAllocDev) {
+ if (!gModule) {
+ if (gfx_init()) {
+ LOG_E("can't find the %s module", GRALLOC_HARDWARE_MODULE_ID);
+ return -1;
+ }
+ }
+
+ err = gralloc_open(gModule, &gAllocDev);
+ if (err) {
+ LOG_E("FATAL: gralloc open failed\n");
return -1;
}
}
- err = gralloc_device_alloc_img(gGralloc, w, h, format, usage, handle,
- stride);
+ err = gAllocDev->alloc(gAllocDev, w, h, format, usage, handle, stride);
if (err) {
LOG_E("alloc(%u, %u, %d, %08x, ...) failed %d (%s)\n",
w, h, format, usage, err, strerror(-err));
@@ -67,14 +78,22 @@ static int gfx_free(buffer_handle_t handle) {
int err;
- if (!gGralloc) {
- if (gfx_init()) {
- LOG_E("can't find the %s module", GRALLOC_HARDWARE_MODULE_ID);
+ if (!gAllocDev) {
+ if (!gModule) {
+ if (gfx_init()) {
+ LOG_E("can't find the %s module", GRALLOC_HARDWARE_MODULE_ID);
+ return -1;
+ }
+ }
+
+ err = gralloc_open(gModule, &gAllocDev);
+ if (err) {
+ LOG_E("FATAL: gralloc open failed\n");
return -1;
}
}
- err = gralloc_device_free_img(gGralloc, handle);
+ err = gAllocDev->free(gAllocDev, handle);
if (err) {
LOG_E("free(...) failed %d (%s)\n", err, strerror(-err));
}
@@ -83,30 +102,22 @@ static int gfx_free(buffer_handle_t handle) {
}
static int gfx_lock(buffer_handle_t handle, int usage,
- int left, int top, int width, int height, void** vaddr) {
+ int left, int top, int width, int height, void** vaddr) {
int err;
- if (!gGralloc) {
+ if (!gAllocMod) {
if (gfx_init()) {
LOG_E("can't find the %s module", GRALLOC_HARDWARE_MODULE_ID);
return -1;
}
}
- const gralloc1_rect_t r = {
- .left = left,
- .top = top,
- .width = width,
- .height = height
- };
+ err = gAllocMod->lock(gAllocMod, handle, usage,
+ left, top, width, height, vaddr);
+ LOG_V("gfx_lock: handle is %x, usage is %x, vaddr is %x.\n", (unsigned int)handle, usage, (unsigned int)*vaddr);
- err = gralloc_lock_async_img(gGralloc, handle, usage, &r, vaddr, -1);
-
- LOG_V("gfx_lock: handle is %x, usage is %x, vaddr is %x.\n",
- (unsigned int)handle, usage, (unsigned int)*vaddr);
-
- if (err) {
+ if (err){
LOG_E("lock(...) failed %d (%s).\n", err, strerror(-err));
return -1;
} else
@@ -117,20 +128,16 @@ static int gfx_lock(buffer_handle_t handle, int usage,
static int gfx_unlock(buffer_handle_t handle) {
- int err, releaseFence = -1;
+ int err;
- if (!gGralloc) {
+ if (!gAllocMod) {
if (gfx_init()) {
LOG_E("can't find the %s module", GRALLOC_HARDWARE_MODULE_ID);
return -1;
}
}
- err = gralloc_unlock_async_img(gGralloc, handle, &releaseFence);
- if (releaseFence >= 0) {
- sync_wait(releaseFence, -1);
- close(releaseFence);
- }
+ err = gAllocMod->unlock(gAllocMod, handle);
if (err) {
LOG_E("unlock(...) failed %d (%s)", err, strerror(-err));
return -1;
@@ -143,21 +150,29 @@ static int gfx_unlock(buffer_handle_t handle) {
static int gfx_Blit(buffer_handle_t src, buffer_handle_t dest,
int w, int h, int , int )
{
- int err, releaseFence = -1;
+ int err;
- if (!gGralloc) {
+ if (!gAllocMod) {
if (gfx_init()) {
LOG_E("can't find the %s module", GRALLOC_HARDWARE_MODULE_ID);
return -1;
}
}
- err = gralloc_blit_handle_to_handle_img(gGralloc, src, dest, w, h, 0, 0,
- 0, -1, &releaseFence);
- if (releaseFence >= 0) {
- sync_wait(releaseFence, -1);
- close(releaseFence);
+#ifdef MRFLD_GFX
+ {
+ int fenceFd;
+ err = gAllocMod->perform(gAllocMod, GRALLOC_MODULE_BLIT_HANDLE_TO_HANDLE_IMG, src, dest, w, h, 0, 0, 0, -1, &fenceFd);
+ if (!err) {
+ sync_wait(fenceFd, -1);
+ close(fenceFd);
+ }
}
+#else
+ IMG_gralloc_module_public_t* GrallocMod = (IMG_gralloc_module_public_t*)gModule;
+ err = GrallocMod->Blit2(GrallocMod, src, dest, w, h, 0, 0);
+#endif
+
if (err) {
LOG_E("Blit failed %d (%s)", err, strerror(-err));
return -1;