summaryrefslogtreecommitdiffstats
path: root/minui/graphics_adf.cpp
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2016-08-08 19:55:15 +0200
committerGerrit Code Review <noreply-gerritcodereview@google.com>2016-08-08 19:55:15 +0200
commit629bde8c6cba137a0d72845090ba07a2f0e84e65 (patch)
tree7faae016e5cfbc09e3e0f3e135e87a1e7e6847d9 /minui/graphics_adf.cpp
parentMerge "Further compress the text images with zopflipng" (diff)
parentRecovery mode UI flicker (diff)
downloadandroid_bootable_recovery-629bde8c6cba137a0d72845090ba07a2f0e84e65.tar
android_bootable_recovery-629bde8c6cba137a0d72845090ba07a2f0e84e65.tar.gz
android_bootable_recovery-629bde8c6cba137a0d72845090ba07a2f0e84e65.tar.bz2
android_bootable_recovery-629bde8c6cba137a0d72845090ba07a2f0e84e65.tar.lz
android_bootable_recovery-629bde8c6cba137a0d72845090ba07a2f0e84e65.tar.xz
android_bootable_recovery-629bde8c6cba137a0d72845090ba07a2f0e84e65.tar.zst
android_bootable_recovery-629bde8c6cba137a0d72845090ba07a2f0e84e65.zip
Diffstat (limited to 'minui/graphics_adf.cpp')
-rw-r--r--minui/graphics_adf.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/minui/graphics_adf.cpp b/minui/graphics_adf.cpp
index a72e40b58..3c3541094 100644
--- a/minui/graphics_adf.cpp
+++ b/minui/graphics_adf.cpp
@@ -26,11 +26,13 @@
#include <sys/mman.h>
#include <adf/adf.h>
+#include <sync/sync.h>
#include "graphics.h"
struct adf_surface_pdata {
GRSurface base;
+ int fence_fd;
int fd;
__u32 offset;
__u32 pitch;
@@ -55,6 +57,7 @@ static void adf_blank(minui_backend *backend, bool blank);
static int adf_surface_init(adf_pdata *pdata, drm_mode_modeinfo *mode, adf_surface_pdata *surf) {
memset(surf, 0, sizeof(*surf));
+ surf->fence_fd = -1;
surf->fd = adf_interface_simple_buffer_alloc(pdata->intf_fd, mode->hdisplay,
mode->vdisplay, pdata->format, &surf->offset, &surf->pitch);
if (surf->fd < 0)
@@ -194,6 +197,23 @@ static GRSurface* adf_init(minui_backend *backend)
return ret;
}
+static void adf_sync(adf_surface_pdata *surf)
+{
+ unsigned int warningTimeout = 3000;
+
+ if (surf == NULL)
+ return;
+
+ if (surf->fence_fd >= 0){
+ int err = sync_wait(surf->fence_fd, warningTimeout);
+ if (err < 0)
+ perror("adf sync fence wait error\n");
+
+ close(surf->fence_fd);
+ surf->fence_fd = -1;
+ }
+}
+
static GRSurface* adf_flip(minui_backend *backend)
{
adf_pdata *pdata = (adf_pdata *)backend;
@@ -203,9 +223,10 @@ static GRSurface* adf_flip(minui_backend *backend)
surf->base.width, surf->base.height, pdata->format, surf->fd,
surf->offset, surf->pitch, -1);
if (fence_fd >= 0)
- close(fence_fd);
+ surf->fence_fd = fence_fd;
pdata->current_surface = (pdata->current_surface + 1) % pdata->n_surfaces;
+ adf_sync(&pdata->surfaces[pdata->current_surface]);
return &pdata->surfaces[pdata->current_surface].base;
}
@@ -219,6 +240,7 @@ static void adf_blank(minui_backend *backend, bool blank)
static void adf_surface_destroy(adf_surface_pdata *surf)
{
munmap(surf->base.data, surf->pitch * surf->base.height);
+ close(surf->fence_fd);
close(surf->fd);
}