• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqt誰得cocoapythonrubywindowsphpgameguibathyscaphec翻訳omegatframework計画中(planning stage)twitterdombtronvb.nettestarduinodirectxpreviewerゲームエンジン

external/gbm_gralloc


Commit MetaInfo

Revisionc8de380a3c3ba2737702bceb4741cba8663fea4a (tree)
Time2018-11-01 07:01:46
Authorlambdadroid <lambdadroid@gmai...>
Commiterlambdadroid

Log Message

Add simple framebuffer HAL implementation using drm_framebuffer

Change Summary

Incremental Difference

--- a/Android.mk
+++ b/Android.mk
@@ -32,6 +32,8 @@ LOCAL_SHARED_LIBRARIES := \
3232 liblog \
3333 libcutils
3434
35+LOCAL_STATIC_LIBRARIES := libdrm_framebuffer
36+
3537 LOCAL_EXPORT_C_INCLUDE_DIRS := \
3638 $(LOCAL_PATH)
3739
--- a/gralloc.cpp
+++ b/gralloc.cpp
@@ -35,6 +35,7 @@
3535 #include <system/graphics.h>
3636
3737 #include <gbm.h>
38+#include <drm_framebuffer.h>
3839
3940 #include "gralloc_drm.h"
4041 #include "gralloc_gbm_priv.h"
@@ -44,18 +45,19 @@ struct gbm_module_t {
4445
4546 pthread_mutex_t mutex;
4647 struct gbm_device *gbm;
48+ struct drm_framebuffer *fb;
4749 };
4850
4951 /*
5052 * Initialize the DRM device object
5153 */
52-static int gbm_init(struct gbm_module_t *dmod)
54+static int gbm_init(struct gbm_module_t *dmod, bool master = false)
5355 {
5456 int err = 0;
5557
5658 pthread_mutex_lock(&dmod->mutex);
5759 if (!dmod->gbm) {
58- dmod->gbm = gbm_dev_create();
60+ dmod->gbm = gbm_dev_create(master);
5961 if (!dmod->gbm)
6062 err = -EINVAL;
6163 }
@@ -105,6 +107,8 @@ static int gbm_mod_register_buffer(const gralloc_module_t *mod,
105107
106108 pthread_mutex_lock(&dmod->mutex);
107109 err = gralloc_gbm_handle_register(handle, dmod->gbm);
110+ if (err == 0 && dmod->fb)
111+ drm_framebuffer_import(dmod->fb, handle);
108112 pthread_mutex_unlock(&dmod->mutex);
109113
110114 return err;
@@ -218,6 +222,19 @@ static int gbm_mod_open_gpu0(struct gbm_module_t *dmod, hw_device_t **dev)
218222 return 0;
219223 }
220224
225+static int gbm_mod_open_fb0(struct gbm_module_t *dmod, hw_device_t **dev)
226+{
227+ int err = gbm_init(dmod, true);
228+ if (err)
229+ return err;
230+
231+ pthread_mutex_lock(&dmod->mutex);
232+ err = drm_framebuffer_open(gbm_device_get_fd(dmod->gbm), &dmod->fb, dev);
233+ pthread_mutex_unlock(&dmod->mutex);
234+
235+ return err;
236+}
237+
221238 static int gbm_mod_open(const struct hw_module_t *mod,
222239 const char *name, struct hw_device_t **dev)
223240 {
@@ -226,6 +243,8 @@ static int gbm_mod_open(const struct hw_module_t *mod,
226243
227244 if (strcmp(name, GRALLOC_HARDWARE_GPU0) == 0)
228245 err = gbm_mod_open_gpu0(dmod, dev);
246+ else if (strcmp(name, GRALLOC_HARDWARE_FB0) == 0)
247+ err = gbm_mod_open_fb0(dmod, dev);
229248 else
230249 err = -EINVAL;
231250
--- a/gralloc_gbm.cpp
+++ b/gralloc_gbm.cpp
@@ -306,13 +306,13 @@ void gbm_dev_destroy(struct gbm_device *gbm)
306306 close(fd);
307307 }
308308
309-struct gbm_device *gbm_dev_create(void)
309+struct gbm_device *gbm_dev_create(bool master)
310310 {
311311 struct gbm_device *gbm;
312312 char path[PROPERTY_VALUE_MAX];
313313 int fd;
314314
315- property_get("gralloc.gbm.device", path, "/dev/dri/renderD128");
315+ property_get("gralloc.gbm.device", path, master ? "/dev/dri/card0" : "/dev/dri/renderD128");
316316 fd = open(path, O_RDWR | O_CLOEXEC);
317317 if (fd < 0) {
318318 ALOGE("failed to open %s", path);
--- a/gralloc_gbm_priv.h
+++ b/gralloc_gbm_priv.h
@@ -46,7 +46,7 @@ int gralloc_gbm_get_gem_handle(buffer_handle_t handle);
4646 int gralloc_gbm_bo_lock(buffer_handle_t handle, int x, int y, int w, int h, int enable_write, void **addr);
4747 int gralloc_gbm_bo_unlock(buffer_handle_t handle);
4848
49-struct gbm_device *gbm_dev_create(void);
49+struct gbm_device *gbm_dev_create(bool master);
5050 void gbm_dev_destroy(struct gbm_device *gbm);
5151
5252 #ifdef __cplusplus