diff options
author | Chris Michael <cp.michael@samsung.com> | 2014-01-29 08:35:34 +0000 |
---|---|---|
committer | Chris Michael <cp.michael@samsung.com> | 2014-01-29 15:27:23 +0000 |
commit | e5825f2d41e06dfe9e66edbbaa9b13a403318871 (patch) | |
tree | e8c30e0953e40ff406d9a49f03cc0887632b25d4 | |
parent | c09abfc763f416141c39fc6c3decdd7316e640d1 (diff) | |
download | efl-e5825f2d41e06dfe9e66edbbaa9b13a403318871.tar.gz |
When we mmap the fb memory, map for read And write.
Add function to return a fb object from a bo.
Signed-off-by: Chris Michael <cp.michael@samsung.com>
-rw-r--r-- | src/lib/ecore_drm/ecore_drm_fb.c | 62 |
1 files changed, 61 insertions, 1 deletions
diff --git a/src/lib/ecore_drm/ecore_drm_fb.c b/src/lib/ecore_drm/ecore_drm_fb.c index 7395274e25..9fe4e6983a 100644 --- a/src/lib/ecore_drm/ecore_drm_fb.c +++ b/src/lib/ecore_drm/ecore_drm_fb.c @@ -33,6 +33,7 @@ ecore_drm_fb_create(Ecore_Drm_Device *dev, int width, int height) goto create_err; } + fb->from_client = EINA_TRUE; fb->hdl = carg.handle; fb->stride = carg.pitch; fb->size = carg.size; @@ -54,7 +55,8 @@ ecore_drm_fb_create(Ecore_Drm_Device *dev, int width, int height) } fb->mmap = - mmap(0, fb->size, PROT_WRITE, MAP_SHARED, dev->drm.fd, marg.offset); + mmap(0, fb->size, PROT_WRITE | PROT_READ, MAP_SHARED, + dev->drm.fd, marg.offset); if (fb->mmap == MAP_FAILED) { ERR("Could not mmap framebuffer space: %m"); @@ -90,3 +92,61 @@ ecore_drm_fb_destroy(Ecore_Drm_Fb *fb) drmIoctl(fb->fd, DRM_IOCTL_MODE_DESTROY_DUMB, &darg); free(fb); } + +#ifdef HAVE_GBM +static void +_ecore_drm_fb_user_data_destroy(struct gbm_bo *bo EINA_UNUSED, void *data) +{ + Ecore_Drm_Fb *fb; + + if (!(fb = data)) return; + ecore_drm_fb_destroy(fb); + /* free(data); */ +} + +Ecore_Drm_Fb * +_ecore_drm_fb_bo_get(Ecore_Drm_Device *dev, struct gbm_bo *bo) +{ + Ecore_Drm_Fb *fb; + unsigned int width, height; + unsigned int h[4], p[4], o[4]; + int ret = -1; + + if ((fb = gbm_bo_get_user_data(bo))) return fb; + + if (!(fb = calloc(1, sizeof(Ecore_Drm_Fb)))) return NULL; + + fb->bo = bo; + + width = gbm_bo_get_width(bo); + height = gbm_bo_get_height(bo); + fb->stride = gbm_bo_get_stride(bo); + fb->hdl = gbm_bo_get_handle(bo).u32; + fb->size = (fb->stride * height); + fb->fd = dev->drm.fd; + + h[0] = fb->hdl; + p[0] = fb->stride; + o[0] = 0; + + ret = drmModeAddFB2(dev->drm.fd, width, height, dev->format, h, p, o, + &fb->id, 0); + if (ret) + { + ret = drmModeAddFB(dev->drm.fd, width, height, 24, 32, + fb->stride, fb->hdl, &fb->id); + + } + + if (ret) + { + ERR("Error during ModeAddFb"); + free(fb); + return NULL; + } + + gbm_bo_set_user_data(bo, fb, _ecore_drm_fb_user_data_destroy); + + return fb; +} +#endif |