OSDN Git Service

Open the DRM device of the primary framebuffer (fb0) 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 android-x86-9.0-r2
authorChih-Wei Huang <cwhuang@linux.org.tw>
Mon, 14 Jan 2019 05:16:42 +0000 (13:16 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Mon, 14 Jan 2019 05:16:42 +0000 (13:16 +0800)
With the new added drmOpenByFB function in libdrm, it's easy to find
the correct DRM device of the primary framebuffer.

Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
gralloc_gbm.cpp

index 3ac2abc..bc7f72d 100644 (file)
@@ -34,6 +34,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <assert.h>
+#include <xf86drm.h>
 
 #include <hardware/gralloc.h>
 #include <system/graphics.h>
@@ -313,8 +314,11 @@ struct gbm_device *gbm_dev_create(bool master)
        char path[PROPERTY_VALUE_MAX];
        int fd;
 
-       property_get("gralloc.gbm.device", path, master ? "/dev/dri/card0" : "/dev/dri/renderD128");
-       fd = open(path, O_RDWR | O_CLOEXEC);
+       if (property_get("gralloc.gbm.device", path, NULL) > 0)
+               fd = open(path, O_RDWR | O_CLOEXEC);
+       else
+               fd = drmOpenByFB(0, master ? DRM_NODE_PRIMARY : DRM_NODE_RENDER);
+
        if (fd < 0) {
                ALOGE("failed to open %s", path);
                return NULL;