OSDN Git Service

Fix cooperating with hwcomposer android-x86-7.1-r4 android-x86-8.1-r1 android-x86-8.1-r2 android-x86-8.1-r3 android-x86-8.1-r4 android-x86-8.1-r5 android-x86-9.0-r1
authorChih-Wei Huang <cwhuang@linux.org.tw>
Thu, 10 Jan 2019 17:46:51 +0000 (01:46 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Thu, 10 Jan 2019 17:46:51 +0000 (01:46 +0800)
When hwcomposer is available, framebuffer_close() will be called.
Thus the allocated struct drm_framebuffer is just freed. However,
the gralloc still holds a pointer referring to the freed struct
drm_framebuffer. As a result, the following errors are repeated:

01-11 00:28:47.088  1103  1103 E drm-fb  : Failed to get handle from prime fd: 9
01-11 00:28:48.062  1103  1103 E drm-fb  : Failed to get handle from prime fd: 9

This patch fixes it by setting the pointer to NULL.

drm_framebuffer.c

index c862f26..4c9871f 100644 (file)
@@ -47,6 +47,7 @@ struct drm_framebuffer {
 
        uint32_t current_fb, next_fb;
        drmEventContext evctx;
+       struct drm_framebuffer **fb_out;
 };
 
 static drmModeConnectorPtr fb0_find_connector(int fd, drmModeResPtr res)
@@ -287,6 +288,9 @@ static int fb0_set_swap_interval(
 
 static int fb0_close(struct hw_device_t *dev)
 {
+       struct drm_framebuffer *fb = (struct drm_framebuffer *) dev;
+       *fb->fb_out = NULL;
+
        free(dev);
        return 0;
 }
@@ -316,6 +320,7 @@ int drm_framebuffer_open(int fd, struct drm_framebuffer **fb_out, struct hw_devi
        fb->device.post = fb0_post;
        fb->device.compositionComplete = fb0_composition_complete;
        fb->device.enableScreen = fb0_enable_screen;
+       fb->fb_out = fb_out;
 
        *fb_out = fb;
        *dev = &fb->device.common;