summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2015-04-07 11:08:19 -0400
committerChris Michael <cp.michael@samsung.com>2015-04-08 14:03:48 -0400
commit25927cb5c7ed088067a1024859b71d54622b6f3f (patch)
treec19e1d13209248fd9a5fd2fdb0b93947b4474731
parent52752072ae6eadd0b19ac1787cdb8133d0f2fa04 (diff)
ecore-drm: Move Eeze Udev Watch to Drm Device
Summary: Move the Eeze udev watch to inside the ecore_drm_device. This allows us to only create One watch to catch all output changes. No need for more than one watch (one per output) as was done previously @fix Signed-off-by: Chris Michael <cp.michael@samsung.com>
-rw-r--r--src/lib/ecore_drm/Ecore_Drm.h3
-rw-r--r--src/lib/ecore_drm/ecore_drm_device.c20
-rw-r--r--src/lib/ecore_drm/ecore_drm_output.c66
-rw-r--r--src/lib/ecore_drm/ecore_drm_private.h3
4 files changed, 39 insertions, 53 deletions
diff --git a/src/lib/ecore_drm/Ecore_Drm.h b/src/lib/ecore_drm/Ecore_Drm.h
index 5c4dd8b045..e5357d510e 100644
--- a/src/lib/ecore_drm/Ecore_Drm.h
+++ b/src/lib/ecore_drm/Ecore_Drm.h
@@ -24,6 +24,7 @@
24#endif // ifdef _MSC_VER 24#endif // ifdef _MSC_VER
25 25
26#include <Ecore.h> 26#include <Ecore.h>
27#include <Eeze.h>
27 28
28typedef enum _Ecore_Drm_Evdev_Capabilities 29typedef enum _Ecore_Drm_Evdev_Capabilities
29{ 30{
@@ -110,6 +111,8 @@ struct _Ecore_Drm_Device
110 struct xkb_context *xkb_ctx; 111 struct xkb_context *xkb_ctx;
111 112
112 unsigned int window; 113 unsigned int window;
114
115 Eeze_Udev_Watch *watch;
113}; 116};
114 117
115struct _Ecore_Drm_Event_Activate 118struct _Ecore_Drm_Event_Activate
diff --git a/src/lib/ecore_drm/ecore_drm_device.c b/src/lib/ecore_drm/ecore_drm_device.c
index 917a02b117..69a8e1c05f 100644
--- a/src/lib/ecore_drm/ecore_drm_device.c
+++ b/src/lib/ecore_drm/ecore_drm_device.c
@@ -87,6 +87,15 @@ _ecore_drm_device_cb_idle(void *data)
87 return ECORE_CALLBACK_RENEW; 87 return ECORE_CALLBACK_RENEW;
88} 88}
89 89
90static void
91_ecore_drm_device_cb_output_event(const char *device EINA_UNUSED, Eeze_Udev_Event event EINA_UNUSED, void *data, Eeze_Udev_Watch *watch EINA_UNUSED)
92{
93 Ecore_Drm_Device *dev;
94
95 if (!(dev = data)) return;
96 _ecore_drm_outputs_update(dev);
97}
98
90/** 99/**
91 * @defgroup Ecore_Drm_Device_Group Device manipulation functions 100 * @defgroup Ecore_Drm_Device_Group Device manipulation functions
92 * 101 *
@@ -261,6 +270,7 @@ EAPI Eina_Bool
261ecore_drm_device_open(Ecore_Drm_Device *dev) 270ecore_drm_device_open(Ecore_Drm_Device *dev)
262{ 271{
263 uint64_t caps; 272 uint64_t caps;
273 int events = 0;
264 274
265 /* check for valid device */ 275 /* check for valid device */
266 if ((!dev) || (!dev->drm.name)) return EINA_FALSE; 276 if ((!dev) || (!dev->drm.name)) return EINA_FALSE;
@@ -299,6 +309,13 @@ ecore_drm_device_open(Ecore_Drm_Device *dev)
299 return EINA_FALSE; 309 return EINA_FALSE;
300 } 310 }
301 311
312 events = (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE |
313 EEZE_UDEV_EVENT_CHANGE);
314
315 dev->watch =
316 eeze_udev_watch_add(EEZE_UDEV_TYPE_DRM, events,
317 _ecore_drm_device_cb_output_event, NULL);
318
302 dev->drm.hdlr = 319 dev->drm.hdlr =
303 ecore_main_fd_handler_add(dev->drm.fd, ECORE_FD_READ, 320 ecore_main_fd_handler_add(dev->drm.fd, ECORE_FD_READ,
304 _ecore_drm_device_cb_event, dev, NULL, NULL); 321 _ecore_drm_device_cb_event, dev, NULL, NULL);
@@ -326,6 +343,9 @@ ecore_drm_device_close(Ecore_Drm_Device *dev)
326 /* check for valid device */ 343 /* check for valid device */
327 if (!dev) return EINA_FALSE; 344 if (!dev) return EINA_FALSE;
328 345
346 /* delete udev watch */
347 if (dev->watch) eeze_udev_watch_del(dev->watch);
348
329 /* close xkb context */ 349 /* close xkb context */
330 if (dev->xkb_ctx) xkb_context_unref(dev->xkb_ctx); 350 if (dev->xkb_ctx) xkb_context_unref(dev->xkb_ctx);
331 351
diff --git a/src/lib/ecore_drm/ecore_drm_output.c b/src/lib/ecore_drm/ecore_drm_output.c
index fc2cd5ee97..dc873749bc 100644
--- a/src/lib/ecore_drm/ecore_drm_output.c
+++ b/src/lib/ecore_drm/ecore_drm_output.c
@@ -24,9 +24,6 @@ static const char *conn_types[] =
24 24
25EAPI int ECORE_DRM_EVENT_OUTPUT = 0; 25EAPI int ECORE_DRM_EVENT_OUTPUT = 0;
26 26
27/* local functions */
28static void _ecore_drm_output_event(const char *device, Eeze_Udev_Event event EINA_UNUSED, void *data, Eeze_Udev_Watch *watch EINA_UNUSED);
29
30static void 27static void
31_ecore_drm_output_edid_parse_string(const uint8_t *data, char text[]) 28_ecore_drm_output_edid_parse_string(const uint8_t *data, char text[])
32{ 29{
@@ -517,9 +514,6 @@ _ecore_drm_output_free(Ecore_Drm_Output *output)
517 /* check for valid output */ 514 /* check for valid output */
518 if (!output) return; 515 if (!output) return;
519 516
520 /* delete any added udev watch */
521 if (output->watch) eeze_udev_watch_del(output->watch);
522
523 /* delete the backlight struct */ 517 /* delete the backlight struct */
524 if (output->backlight) 518 if (output->backlight)
525 _ecore_drm_output_backlight_shutdown(output->backlight); 519 _ecore_drm_output_backlight_shutdown(output->backlight);
@@ -596,19 +590,18 @@ finish:
596 _ecore_drm_output_frame_finish(output); 590 _ecore_drm_output_frame_finish(output);
597} 591}
598 592
599static void 593void
600_ecore_drm_update_outputs(Ecore_Drm_Output *output) 594_ecore_drm_outputs_update(Ecore_Drm_Device *dev)
601{ 595{
602 Ecore_Drm_Output *new_output; 596 Ecore_Drm_Output *new_output;
603 drmModeConnector *connector; 597 drmModeConnector *connector;
604 drmModeRes *res; 598 drmModeRes *res;
605 drmModeCrtc *crtc; 599 drmModeCrtc *crtc;
606 int x = 0, y = 0; 600 int x = 0, y = 0, i;
607 uint32_t connected = 0, disconnects = 0; 601 uint32_t connected = 0, disconnects = 0;
608 int i;
609 Eina_List *l; 602 Eina_List *l;
610 603
611 res = drmModeGetResources(output->drm_fd); 604 res = drmModeGetResources(dev->drm.fd);
612 if (!res) 605 if (!res)
613 { 606 {
614 ERR("Could not get resources for drm card: %m"); 607 ERR("Could not get resources for drm card: %m");
@@ -619,7 +612,7 @@ _ecore_drm_update_outputs(Ecore_Drm_Output *output)
619 { 612 {
620 int connector_id = res->connectors[i]; 613 int connector_id = res->connectors[i];
621 614
622 connector = drmModeGetConnector(output->drm_fd, connector_id); 615 connector = drmModeGetConnector(dev->drm.fd, connector_id);
623 if (connector == NULL) 616 if (connector == NULL)
624 continue; 617 continue;
625 618
@@ -631,28 +624,27 @@ _ecore_drm_update_outputs(Ecore_Drm_Output *output)
631 624
632 connected |= (1 << connector_id); 625 connected |= (1 << connector_id);
633 626
634 if (!(output->dev->conn_allocator & (1 << connector_id))) 627 if (!(dev->conn_allocator & (1 << connector_id)))
635 { 628 {
636 drmModeEncoder *enc; 629 drmModeEncoder *enc;
637 int events = 0;
638 630
639 if (!(new_output = _ecore_drm_output_create(output->dev, res, connector, x, y))) 631 if (!(new_output = _ecore_drm_output_create(dev, res, connector, x, y)))
640 { 632 {
641 drmModeFreeConnector(connector); 633 drmModeFreeConnector(connector);
642 _ecore_drm_output_free(new_output); 634 _ecore_drm_output_free(new_output);
643 continue; 635 continue;
644 } 636 }
645 637
646 new_output->drm_fd = output->dev->drm.fd; 638 new_output->drm_fd = dev->drm.fd;
647 639
648 if (!(enc = drmModeGetEncoder(new_output->dev->drm.fd, connector->encoder_id))) 640 if (!(enc = drmModeGetEncoder(dev->drm.fd, connector->encoder_id)))
649 { 641 {
650 drmModeFreeConnector(connector); 642 drmModeFreeConnector(connector);
651 _ecore_drm_output_free(new_output); 643 _ecore_drm_output_free(new_output);
652 continue; 644 continue;
653 } 645 }
654 646
655 if (!(crtc = drmModeGetCrtc(new_output->dev->drm.fd, enc->crtc_id))) 647 if (!(crtc = drmModeGetCrtc(dev->drm.fd, enc->crtc_id)))
656 { 648 {
657 drmModeFreeEncoder(enc); 649 drmModeFreeEncoder(enc);
658 drmModeFreeConnector(connector); 650 drmModeFreeConnector(connector);
@@ -665,23 +657,16 @@ _ecore_drm_update_outputs(Ecore_Drm_Output *output)
665 drmModeFreeCrtc(crtc); 657 drmModeFreeCrtc(crtc);
666 drmModeFreeEncoder(enc); 658 drmModeFreeEncoder(enc);
667 659
668 events = (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE | 660 dev->outputs = eina_list_append(dev->outputs, new_output);
669 EEZE_UDEV_EVENT_CHANGE);
670
671 new_output->watch =
672 eeze_udev_watch_add(EEZE_UDEV_TYPE_DRM, events,
673 _ecore_drm_output_event, new_output);
674
675 output->dev->outputs =
676 eina_list_append(output->dev->outputs, new_output);
677 } 661 }
678 drmModeFreeConnector(connector); 662
663 drmModeFreeConnector(connector);
679 } 664 }
680 665
681 disconnects = output->dev->conn_allocator & ~connected; 666 disconnects = dev->conn_allocator & ~connected;
682 if (disconnects) 667 if (disconnects)
683 { 668 {
684 EINA_LIST_FOREACH(output->dev->outputs, l, new_output) 669 EINA_LIST_FOREACH(dev->outputs, l, new_output)
685 { 670 {
686 if (disconnects & (1 << new_output->conn_id)) 671 if (disconnects & (1 << new_output->conn_id))
687 { 672 {
@@ -694,15 +679,6 @@ _ecore_drm_update_outputs(Ecore_Drm_Output *output)
694} 679}
695 680
696static void 681static void
697_ecore_drm_output_event(const char *device EINA_UNUSED, Eeze_Udev_Event event EINA_UNUSED, void *data, Eeze_Udev_Watch *watch EINA_UNUSED)
698{
699 Ecore_Drm_Output *output;
700
701 if (!(output = data)) return;
702 _ecore_drm_update_outputs(output);
703}
704
705static void
706_ecore_drm_event_output_free(void *data EINA_UNUSED, void *event) 682_ecore_drm_event_output_free(void *data EINA_UNUSED, void *event)
707{ 683{
708 Ecore_Drm_Event_Output *e = event; 684 Ecore_Drm_Event_Output *e = event;
@@ -796,8 +772,6 @@ ecore_drm_outputs_create(Ecore_Drm_Device *dev)
796 772
797 for (i = 0; i < res->count_connectors; i++) 773 for (i = 0; i < res->count_connectors; i++)
798 { 774 {
799 int events = 0;
800
801 /* get the connector */ 775 /* get the connector */
802 if (!(conn = drmModeGetConnector(dev->drm.fd, res->connectors[i]))) 776 if (!(conn = drmModeGetConnector(dev->drm.fd, res->connectors[i])))
803 continue; 777 continue;
@@ -838,16 +812,6 @@ ecore_drm_outputs_create(Ecore_Drm_Device *dev)
838 drmModeFreeCrtc(crtc); 812 drmModeFreeCrtc(crtc);
839 drmModeFreeEncoder(enc); 813 drmModeFreeEncoder(enc);
840 814
841 events = (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE |
842 EEZE_UDEV_EVENT_CHANGE);
843
844 output->watch =
845 eeze_udev_watch_add(EEZE_UDEV_TYPE_DRM, events,
846 _ecore_drm_output_event, output);
847
848 if (!output->watch)
849 ERR("Could not create Eeze_Udev_Watch for drm output");
850
851 dev->outputs = eina_list_append(dev->outputs, output); 815 dev->outputs = eina_list_append(dev->outputs, output);
852 } 816 }
853 817
diff --git a/src/lib/ecore_drm/ecore_drm_private.h b/src/lib/ecore_drm/ecore_drm_private.h
index 7b8e4f1074..2d202552f1 100644
--- a/src/lib/ecore_drm/ecore_drm_private.h
+++ b/src/lib/ecore_drm/ecore_drm_private.h
@@ -34,7 +34,6 @@
34# include <systemd/sd-login.h> 34# include <systemd/sd-login.h>
35# endif 35# endif
36 36
37# include <Eeze.h>
38# include <Eldbus.h> 37# include <Eldbus.h>
39# include <Ecore_Drm.h> 38# include <Ecore_Drm.h>
40 39
@@ -114,7 +113,6 @@ struct _Ecore_Drm_Output
114 unsigned int crtc_id; 113 unsigned int crtc_id;
115 unsigned int conn_id; 114 unsigned int conn_id;
116 drmModeCrtcPtr crtc; 115 drmModeCrtcPtr crtc;
117 Eeze_Udev_Watch *watch;
118 116
119 int x, y, phys_width, phys_height; 117 int x, y, phys_width, phys_height;
120 int drm_fd; 118 int drm_fd;
@@ -262,6 +260,7 @@ void _ecore_drm_fb_destroy(Ecore_Drm_Fb *fb);
262void _ecore_drm_output_fb_release(Ecore_Drm_Output *output, Ecore_Drm_Fb *fb); 260void _ecore_drm_output_fb_release(Ecore_Drm_Output *output, Ecore_Drm_Fb *fb);
263void _ecore_drm_output_repaint_start(Ecore_Drm_Output *output); 261void _ecore_drm_output_repaint_start(Ecore_Drm_Output *output);
264void _ecore_drm_output_frame_finish(Ecore_Drm_Output *output); 262void _ecore_drm_output_frame_finish(Ecore_Drm_Output *output);
263void _ecore_drm_outputs_update(Ecore_Drm_Device *dev);
265 264
266Eina_Bool _ecore_drm_logind_connect(Ecore_Drm_Device *dev); 265Eina_Bool _ecore_drm_logind_connect(Ecore_Drm_Device *dev);
267void _ecore_drm_logind_disconnect(Ecore_Drm_Device *dev); 266void _ecore_drm_logind_disconnect(Ecore_Drm_Device *dev);