DRM code is moved to widget-service. 80/39980/2 submit/tizen_mobile/20150527.071719
authorSung-jae Park <nicesj.park@samsung.com>
Wed, 27 May 2015 06:47:30 +0000 (15:47 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Wed, 27 May 2015 07:11:45 +0000 (16:11 +0900)
Change-Id: I15478f9b84d0223d609bed73263aae43d77d13cf

CMakeLists.txt
packaging/data-provider-master.spec
src/buffer_handler.c
src/buffer_handler_wayland.c

index 42b3793..e55ea62 100644 (file)
@@ -24,7 +24,6 @@ pkg_check_modules(pkg REQUIRED
        pkgmgr-info
        libsystemd-daemon
        libtbm
-       libdrm
 )
 
 IF (LIVEBOX)
@@ -37,18 +36,17 @@ IF (X11_SUPPORT)
 pkg_check_modules(pkg_extra REQUIRED
        ecore-x
        x11
-       libdri2
        xfixes
-       dri2proto
        xext
        xdamage
+       libdri2
+       dri2proto
 )
 ENDIF (X11_SUPPORT)
 
 IF (WAYLAND_SUPPORT)
 pkg_check_modules(pkg_extra REQUIRED
        ecore-wayland
-       wayland-client
 )
 ENDIF (WAYLAND_SUPPORT)
 
index aa5106f..75bfde6 100644 (file)
@@ -4,7 +4,7 @@ Name: data-provider-master
 Summary: Master service provider for widgetes
 Version: 1.1.7
 Release: 1
-Group: HomeTF/widget
+Group: Applications/Core Applications
 License: Flora License, Version 1.1
 Source0: %{name}-%{version}.tar.gz
 Source1001: %{name}.manifest
@@ -21,19 +21,17 @@ BuildRequires: pkgconfig(bundle)
 
 %if %{with wayland}
 BuildRequires: pkgconfig(ecore-wayland)
-BuildRequires: pkgconfig(wayland-client)
 %else
 BuildRequires: pkgconfig(ecore-x)
 BuildRequires: pkgconfig(x11)
-BuildRequires: pkgconfig(libdri2)
 BuildRequires: pkgconfig(xfixes)
-BuildRequires: pkgconfig(dri2proto)
 BuildRequires: pkgconfig(xext)
+BuildRequires: pkgconfig(libdri2)
 BuildRequires: pkgconfig(xdamage)
+BuildRequires: pkgconfig(dri2proto)
 %endif
 
 BuildRequires: pkgconfig(libtbm)
-BuildRequires: pkgconfig(libdrm)
 BuildRequires: pkgconfig(ecore)
 BuildRequires: pkgconfig(eina)
 BuildRequires: pkgconfig(com-core)
index 3800d2a..2d569d3 100644 (file)
@@ -36,8 +36,6 @@
 #include <X11/extensions/XShm.h>
 
 #include <dri2.h>
-#include <xf86drm.h>
-#include <xf86drmMode.h>
 #include <tbm_bufmgr.h>
 
 #include <dlog.h>
@@ -96,14 +94,10 @@ struct buffer_info
 
 static struct {
        tbm_bufmgr slp_bufmgr;
-       int evt_base;
-       int err_base;
        int fd;
        Eina_List *pixmap_list;
 } s_info = {
        .slp_bufmgr = NULL,
-       .evt_base = 0,
-       .err_base = 0,
        .fd = -1,
        .pixmap_list = NULL,
 };
@@ -470,7 +464,7 @@ static inline int load_shm_buffer(struct buffer_info *info)
        buffer->type = WIDGET_FB_TYPE_SHM;
        buffer->refcnt = id;
        buffer->state = WIDGET_FB_STATE_CREATED; /*!< Needless */
-       buffer->info = (void *)size; /*!< Use this field to indicates the size of SHM */
+       buffer->info = (void *)((long)size); /*!< Use this field to indicates the size of SHM */
 
        len = strlen(SCHEMA_SHM) + 30; /* strlen("shm://") + 30 */
 
@@ -1264,70 +1258,24 @@ EAPI void buffer_handler_flush(struct buffer_info *info)
 
 HAPI int buffer_handler_init(void)
 {
-       int dri2Major, dri2Minor;
-       char *driverName, *deviceName;
-       drm_magic_t magic;
-
-       if (!DRI2QueryExtension(ecore_x_display_get(), &s_info.evt_base, &s_info.err_base)) {
-               ErrPrint("DRI2 is not supported\n");
-               return WIDGET_ERROR_NONE;
-       }
-
-       if (!DRI2QueryVersion(ecore_x_display_get(), &dri2Major, &dri2Minor)) {
-               ErrPrint("DRI2 is not supported\n");
-               s_info.evt_base = 0;
-               s_info.err_base = 0;
-               return WIDGET_ERROR_NONE;
-       }
-
-       if (!DRI2Connect(ecore_x_display_get(), DefaultRootWindow(ecore_x_display_get()), &driverName, &deviceName)) {
-               ErrPrint("DRI2 is not supported\n");
-               s_info.evt_base = 0;
-               s_info.err_base = 0;
-               return WIDGET_ERROR_NONE;
-       }
+       int ret;
 
        if (WIDGET_CONF_USE_SW_BACKEND) {
                DbgPrint("Fallback to the S/W Backend\n");
-               s_info.evt_base = 0;
-               s_info.err_base = 0;
-               DbgFree(deviceName);
-               DbgFree(driverName);
                return WIDGET_ERROR_NONE;
        }
 
-       s_info.fd = open(deviceName, O_RDWR);
-       DbgFree(deviceName);
-       DbgFree(driverName);
-       if (s_info.fd < 0) {
-               ErrPrint("Failed to open a drm device: (%d)\n", errno);
-               s_info.evt_base = 0;
-               s_info.err_base = 0;
-               return WIDGET_ERROR_NONE;
-       }
-
-       drmGetMagic(s_info.fd, &magic);
-       DbgPrint("DRM Magic: 0x%X\n", magic);
-       if (!DRI2Authenticate(ecore_x_display_get(), DefaultRootWindow(ecore_x_display_get()), (unsigned int)magic)) {
-               ErrPrint("Failed to do authenticate for DRI2\n");
-               if (close(s_info.fd) < 0) {
-                       ErrPrint("close: %d\n", errno);
-               }
-               s_info.fd = -1;
-               s_info.evt_base = 0;
-               s_info.err_base = 0;
+       ret = widget_util_get_drm_fd(ecore_x_display_get(), &s_info.fd);
+       if (ret != WIDGET_ERROR_NONE || s_info.fd < 0) {
+               ErrPrint("Fallback to the S/W Backend\n");
                return WIDGET_ERROR_NONE;
        }
 
        s_info.slp_bufmgr = tbm_bufmgr_init(s_info.fd);
        if (!s_info.slp_bufmgr) {
                ErrPrint("Failed to init bufmgr\n");
-               if (close(s_info.fd) < 0) {
-                       ErrPrint("close: %d\n", errno);
-               }
+               widget_util_release_drm_fd(s_info.fd);
                s_info.fd = -1;
-               s_info.evt_base = 0;
-               s_info.err_base = 0;
                return WIDGET_ERROR_NONE;
        }
 
@@ -1336,18 +1284,16 @@ HAPI int buffer_handler_init(void)
 
 HAPI int buffer_handler_fini(void)
 {
-       if (s_info.fd >= 0) {
-               if (close(s_info.fd) < 0) {
-                       ErrPrint("close: %d\n", errno);
-               }
-               s_info.fd = -1;
-       }
-
        if (s_info.slp_bufmgr) {
                tbm_bufmgr_deinit(s_info.slp_bufmgr);
                s_info.slp_bufmgr = NULL;
        }
 
+       if (s_info.fd >= 0) {
+               widget_util_release_drm_fd(s_info.fd);
+               s_info.fd = -1;
+       }
+
        return WIDGET_ERROR_NONE;
 }
 
@@ -1488,7 +1434,7 @@ EAPI int buffer_handler_raw_size(widget_fb_t buffer)
                return WIDGET_ERROR_INVALID_PARAMETER;
        }
 
-       return (int)buffer->info;
+       return (int)((long)buffer->info);
 }
 
 EAPI widget_fb_t buffer_handler_raw_open(enum widget_fb_type widget_fb_type, void *resource)
@@ -1497,13 +1443,13 @@ EAPI widget_fb_t buffer_handler_raw_open(enum widget_fb_type widget_fb_type, voi
 
        switch (widget_fb_type) {
        case WIDGET_FB_TYPE_SHM:
-               handle = raw_open_shm((int)resource);
+               handle = raw_open_shm((int)((long)resource));
                break;
        case WIDGET_FB_TYPE_FILE:
                handle = raw_open_file(resource);
                break;
        case WIDGET_FB_TYPE_PIXMAP:
-               handle = raw_open_pixmap((unsigned int)resource);
+               handle = raw_open_pixmap((unsigned int)((long)resource));
                break;
        default:
                handle = NULL;
index 1fdb33a..0792c5c 100644 (file)
@@ -29,8 +29,6 @@
 #include <Ecore.h>
 #include <Ecore_Wayland.h> /* wayland_client.h is included by this header */
 
-#include <xf86drm.h>
-#include <xf86drmMode.h>
 #include <tbm_bufmgr.h>
 
 #include <dlog.h>
@@ -580,16 +578,23 @@ EAPI void buffer_handler_flush(struct buffer_info *info)
 
 HAPI int buffer_handler_init(void)
 {
+       int ret;
+
        if (WIDGET_CONF_USE_SW_BACKEND) {
                DbgPrint("Fallback to the S/W Backend\n");
                return WIDGET_ERROR_NONE;
        }
 
-       /**
-        * Use the -1 for default FD handler.
-        */
-       s_info.slp_bufmgr = tbm_bufmgr_init(-1);
+       ret = widget_util_get_drm_fd(ecore_wl_display_get(), &s_info.fd);
+       if (ret != WIDGET_ERROR_NONE || s_info.fd < 0) {
+               ErrPrint("Fallback to the S/W Backend\n");
+               return WIDGET_ERROR_NONE;
+       }
+
+       s_info.slp_bufmgr = tbm_bufmgr_init(s_info.fd);
        if (!s_info.slp_bufmgr) {
+               widget_util_release_drm_fd(s_info.fd);
+               s_info.fd = -1;
                return WIDGET_ERROR_NONE;
        }
 
@@ -598,15 +603,16 @@ HAPI int buffer_handler_init(void)
 
 HAPI int buffer_handler_fini(void)
 {
-       /**
-        * @TODO
-        * Implement this for wayland
-        */
        if (s_info.slp_bufmgr) {
                tbm_bufmgr_deinit(s_info.slp_bufmgr);
                s_info.slp_bufmgr = NULL;
        }
 
+       if (s_info.fd >= 0) {
+               widget_util_release_drm_fd(s_info.fd);
+               s_info.fd = -1;
+       }
+
        return WIDGET_ERROR_NONE;
 }