ecore_drm2: Use library function instead of ioctl for addfb2
authorDerek Foreman <derekf@osg.samsung.com>
Tue, 21 Mar 2017 19:21:14 +0000 (14:21 -0500)
committerChris Michael <cp.michael@samsung.com>
Tue, 18 Apr 2017 11:55:10 +0000 (07:55 -0400)
Minor clean up.

src/lib/ecore_drm2/ecore_drm2.c
src/lib/ecore_drm2/ecore_drm2_fb.c
src/lib/ecore_drm2/ecore_drm2_private.h

index b60641e..d3de6f3 100644 (file)
@@ -41,6 +41,7 @@ void (*sym_drmModeFreePlaneResources)(drmModePlaneResPtr ptr) = NULL;
 void *(*sym_drmModeGetPlane)(int fd, uint32_t plane_id) = NULL;
 void (*sym_drmModeFreePlane)(drmModePlanePtr ptr) = NULL;
 int (*sym_drmModeAddFB)(int fd, uint32_t width, uint32_t height, uint8_t depth, uint8_t bpp, uint32_t pitch, uint32_t bo_handle, uint32_t *buf_id) = NULL;
+int (*sym_drmModeAddFB2)(int fd, uint32_t width, uint32_t height, uint32_t pixel_format, uint32_t bo_handles[4], uint32_t pitches[4], uint32_t offsets[4], uint32_t *buf_id, uint32_t flags) = NULL;
 int (*sym_drmModeRmFB)(int fd, uint32_t bufferId) = NULL;
 int (*sym_drmModePageFlip)(int fd, uint32_t crtc_id, uint32_t fb_id, uint32_t flags, void *user_data) = NULL;
 int (*sym_drmModeDirtyFB)(int fd, uint32_t bufferId, drmModeClipPtr clips, uint32_t num_clips) = NULL;
@@ -117,6 +118,7 @@ _ecore_drm2_link(void)
         SYM(drm_lib, drmModeGetPlane);
         SYM(drm_lib, drmModeFreePlane);
         SYM(drm_lib, drmModeAddFB);
+        SYM(drm_lib, drmModeAddFB2);
         SYM(drm_lib, drmModeRmFB);
         SYM(drm_lib, drmModePageFlip);
         SYM(drm_lib, drmModeDirtyFB);
index fe27508..ef61887 100644 (file)
@@ -3,30 +3,18 @@
 static Eina_Bool
 _fb2_create(Ecore_Drm2_Fb *fb)
 {
-   drm_mode_fb_cmd2 cmd;
    uint32_t hdls[4] = { 0 }, pitches[4] = { 0 }, offsets[4] = { 0 };
-   uint64_t modifiers[4] = { 0 };
+   int r;
 
    hdls[0] = fb->hdl;
    pitches[0] = fb->stride;
    offsets[0] = 0;
-   modifiers[0] = 0;
-
-   memset(&cmd, 0, sizeof(drm_mode_fb_cmd2));
-   cmd.fb_id = 0;
-   cmd.width = fb->w;
-   cmd.height = fb->h;
-   cmd.pixel_format = fb->format;
-   cmd.flags = 0;
-   memcpy(cmd.handles, hdls, 4 * sizeof(hdls[0]));
-   memcpy(cmd.pitches, pitches, 4 * sizeof(pitches[0]));
-   memcpy(cmd.offsets, offsets, 4 * sizeof(offsets[0]));
-   memcpy(cmd.modifier, modifiers, 4 * sizeof(modifiers[0]));
-
-   if (sym_drmIoctl(fb->fd, DRM_IOCTL_MODE_ADDFB2, &cmd))
-     return EINA_FALSE;
 
-   fb->id = cmd.fb_id;
+   r = sym_drmModeAddFB2(fb->fd, fb->w, fb->h, fb->format, hdls,
+                         pitches, offsets, &fb->id, 0);
+
+   if (r)
+     return EINA_FALSE;
 
    return EINA_TRUE;
 }
index 0ddc80a..ea0ab19 100644 (file)
@@ -831,6 +831,7 @@ extern void (*sym_drmModeFreePlaneResources)(drmModePlaneResPtr ptr);
 extern void *(*sym_drmModeGetPlane)(int fd, uint32_t plane_id);
 extern void (*sym_drmModeFreePlane)(drmModePlanePtr ptr);
 extern int (*sym_drmModeAddFB)(int fd, uint32_t width, uint32_t height, uint8_t depth, uint8_t bpp, uint32_t pitch, uint32_t bo_handle, uint32_t *buf_id);
+extern int (*sym_drmModeAddFB2)(int fd, uint32_t width, uint32_t height, uint32_t pixel_format, uint32_t bo_handles[4], uint32_t pitches[4], uint32_t offsets[4], uint32_t *buf_id, uint32_t flags);
 extern int (*sym_drmModeRmFB)(int fd, uint32_t bufferId);
 extern int (*sym_drmModePageFlip)(int fd, uint32_t crtc_id, uint32_t fb_id, uint32_t flags, void *user_data);
 extern int (*sym_drmModeDirtyFB)(int fd, uint32_t bufferId, drmModeClipPtr clips, uint32_t num_clips);