ecore-drm Add hooks for updating wl_output when outputs are hotplugged
authorDerek Foreman <derekf@osg.samsung.com>
Thu, 19 Feb 2015 19:47:34 +0000 (14:47 -0500)
committerBoram Park <boram1288.park@samsung.com>
Fri, 17 Apr 2015 05:47:15 +0000 (14:47 +0900)
Summary:
This provides callbacks to any bound wl_output listeners when a
display is hotplugged.

NOTE: Currently we don't receive hotplug events
ANOTHER NOTE: We don't yet handle display removal

Reviewers: devilhorns, zmike

Reviewed By: devilhorns, zmike

Subscribers: cedric

Maniphest Tasks: T2131

Differential Revision: https://phab.enlightenment.org/D2006

src/lib/ecore_drm/Ecore_Drm.h
src/lib/ecore_drm/ecore_drm.c
src/lib/ecore_drm/ecore_drm_output.c
src/lib/ecore_drm/ecore_drm_private.h

index e34a3121de7e224d7daa795d7cf4d42bdf5a2ae0..2cf79e251d864c4130db0cded72ac3c90009d1b4 100644 (file)
@@ -134,6 +134,19 @@ struct _Ecore_Drm_Event_Vblank
    void        *data;
 };
 
+struct _Ecore_Drm_Event_Output
+{
+   int x, y;
+   int w, h;
+   int phys_width, phys_height;
+   unsigned int refresh;
+   int subpixel_order;
+   int transform;
+   const char *make;
+   const char *model;
+   Eina_Bool plug : 1;
+};
+
 /* opaque structure to represent a drm device */
 typedef struct _Ecore_Drm_Device Ecore_Drm_Device;
 
@@ -164,10 +177,16 @@ typedef struct _Ecore_Drm_Event_Page_Flip Ecore_Drm_Event_Page_Flip;
 /* sturcture to inform drm vblank */
 typedef struct _Ecore_Drm_Event_Vblank Ecore_Drm_Event_Vblank;
 
+/* structure to inform drm output plug events */
+/** @since 1.14 */
+typedef struct _Ecore_Drm_Event_Output Ecore_Drm_Event_Output;
+
 EAPI extern int ECORE_DRM_EVENT_ACTIVATE;
 EAPI extern int ECORE_DRM_EVENT_PAGE_FLIP;
 EAPI extern int ECORE_DRM_EVENT_VBLANK;
 
+EAPI extern int ECORE_DRM_EVENT_OUTPUT; /**< @since 1.14 */
+
 /**
  * @file
  * @brief Ecore functions for dealing with drm, virtual terminals
index 9ca2b80d237a90777724f9b76c1f6c7512e7208e..28b872c117cb63b9e4620f0f661bd5e5d8b285ec 100644 (file)
@@ -93,6 +93,7 @@ ecore_drm_init(void)
    ECORE_DRM_EVENT_ACTIVATE = ecore_event_type_new();
    ECORE_DRM_EVENT_PAGE_FLIP = ecore_event_type_new();
    ECORE_DRM_EVENT_VBLANK = ecore_event_type_new();
+   ECORE_DRM_EVENT_OUTPUT = ecore_event_type_new();
 
    /* return init count */
    return _ecore_drm_init_count;
index f871dc0752ab86e9655078e9e789fb547fd81ad9..da84e75eb073f89e8f1981eb1877962205e08150 100644 (file)
@@ -13,6 +13,8 @@ static const char *conn_types[] =
    "DP", "HDMI", "HDMI", "TV", "eDP",
 };
 
+EAPI int ECORE_DRM_EVENT_OUTPUT = 0;
+
 /* local functions */
 
 static Eina_Bool 
@@ -360,6 +362,8 @@ _ecore_drm_output_create(Ecore_Drm_Device *dev, drmModeRes *res, drmModeConnecto
    output->backlight = 
      _ecore_drm_output_backlight_init(output, conn->connector_type);
 
+   _ecore_drm_event_output_send(output, EINA_TRUE);
+
    return output;
 
 mode_err:
@@ -581,6 +585,41 @@ _ecore_drm_output_event(const char *device EINA_UNUSED, Eeze_Udev_Event event EI
      _ecore_drm_update_outputs(output);
 }
 
+static void
+_ecore_drm_event_output_free(void *data EINA_UNUSED, void *event)
+{
+   Ecore_Drm_Event_Output *e = event;
+
+   eina_stringshare_del(e->make);
+   eina_stringshare_del(e->model);
+   free(event);
+}
+
+void
+_ecore_drm_event_output_send(const Ecore_Drm_Output *output, Eina_Bool plug)
+{
+   Ecore_Drm_Event_Output *e;
+
+   if (!(e = calloc(1, sizeof(Ecore_Drm_Event_Output)))) return;
+   e->plug = plug;
+   if (plug)
+     {
+        e->w = output->current_mode->width;
+        e->h = output->current_mode->height;
+        e->x = output->x;
+        e->y = output->y;
+        e->phys_width = 0;
+        e->phys_height = 0;
+        e->refresh = output->current_mode->refresh;
+        e->subpixel_order = output->subpixel;
+        e->make = eina_stringshare_ref(output->make);
+        e->model = eina_stringshare_ref(output->model);
+        e->transform = 0;
+     }
+   ecore_event_add(ECORE_DRM_EVENT_OUTPUT, e,
+                   _ecore_drm_event_output_free, NULL);
+}
+
 /* public functions */
 
 /**
index 444b1c06e8773d0e1b59db5bf98628ba9d247841..03a7c275433d97c0718dba0e4a8c3a06bf7119ba 100644 (file)
@@ -234,6 +234,7 @@ struct _Ecore_Drm_Sprite
 typedef void (*Ecore_Drm_Open_Cb)(void *data, int fd, Eina_Bool b);
 
 void _ecore_drm_event_activate_send(Eina_Bool active);
+void _ecore_drm_event_output_send(const Ecore_Drm_Output *output, Eina_Bool plug);
 
 Eina_Bool _ecore_drm_launcher_device_open(const char *device, Ecore_Drm_Open_Cb callback, void *data, int flags);
 int _ecore_drm_launcher_device_open_no_pending(const char *device, int flags);