summaryrefslogtreecommitdiff
path: root/src/lib/ecore_drm2
diff options
context:
space:
mode:
authorDerek Foreman <derekf@osg.samsung.com>2017-08-03 14:56:19 -0500
committerDerek Foreman <derekf@osg.samsung.com>2017-08-09 14:56:58 -0500
commitd8a9b895bb3c3e70c4b56441c0c34b981381a8d0 (patch)
tree7d14273fb4af8ab7d53f8369e54fe85a3fac4311 /src/lib/ecore_drm2
parent9b9d704292258f1ee1412cc3f2f2ae638bb5237c (diff)
ecore_drm2: Merge ecore_drm2_device_find and ecore_drm2_device_open
There's never a reason to find a device and not open it, so all callers end up calling these two functions back to back.
Diffstat (limited to 'src/lib/ecore_drm2')
-rw-r--r--src/lib/ecore_drm2/Ecore_Drm2.h19
-rw-r--r--src/lib/ecore_drm2/ecore_drm2_device.c41
2 files changed, 18 insertions, 42 deletions
diff --git a/src/lib/ecore_drm2/Ecore_Drm2.h b/src/lib/ecore_drm2/Ecore_Drm2.h
index 81c3ace6a8..d90ee99dc2 100644
--- a/src/lib/ecore_drm2/Ecore_Drm2.h
+++ b/src/lib/ecore_drm2/Ecore_Drm2.h
@@ -166,30 +166,17 @@ EAPI int ecore_drm2_event_handle(Ecore_Drm2_Device *dev, Ecore_Drm2_Context *drm
166 */ 166 */
167 167
168/** 168/**
169 * Try to find a drm device on a given seat 169 * Try to open the Ecore_Drm2_Device for a given seat
170 * 170 *
171 * @param seat 171 * @param seat
172 * @param tty 172 * @param tty
173 * @param sync
174 * 173 *
175 * @return A newly allocated Ecore_Drm2_Device on success, NULL otherwise 174 * @return An Ecore_Drm2_Device or NULL on failure.
176 * 175 *
177 * @ingroup Ecore_Drm2_Device_Group 176 * @ingroup Ecore_Drm2_Device_Group
178 * @since 1.18 177 * @since 1.18
179 */ 178 */
180EAPI Ecore_Drm2_Device *ecore_drm2_device_find(const char *seat, unsigned int tty); 179EAPI Ecore_Drm2_Device *ecore_drm2_device_open(const char *seat, unsigned int tty);
181
182/**
183 * Try to open a given Ecore_Drm2_Device
184 *
185 * @param device
186 *
187 * @return A valid file descriptor if open succeeds, -1 otherwise.
188 *
189 * @ingroup Ecore_Drm2_Device_Group
190 * @since 1.18
191 */
192EAPI int ecore_drm2_device_open(Ecore_Drm2_Device *device);
193 180
194/** 181/**
195 * Close an open Ecore_Drm2_Device 182 * Close an open Ecore_Drm2_Device
diff --git a/src/lib/ecore_drm2/ecore_drm2_device.c b/src/lib/ecore_drm2/ecore_drm2_device.c
index aa8917ce4e..42a21c0742 100644
--- a/src/lib/ecore_drm2/ecore_drm2_device.c
+++ b/src/lib/ecore_drm2/ecore_drm2_device.c
@@ -593,43 +593,29 @@ _drm2_atomic_state_free(Ecore_Drm2_Atomic_State *state)
593} 593}
594 594
595EAPI Ecore_Drm2_Device * 595EAPI Ecore_Drm2_Device *
596ecore_drm2_device_find(const char *seat, unsigned int tty) 596ecore_drm2_device_open(const char *seat, unsigned int tty)
597{ 597{
598 Ecore_Drm2_Device *dev; 598 Ecore_Drm2_Device *device;
599 599
600 dev = calloc(1, sizeof(Ecore_Drm2_Device)); 600 device = calloc(1, sizeof(Ecore_Drm2_Device));
601 if (!dev) return NULL; 601 if (!device) return NULL;
602 602
603 dev->em = elput_manager_connect(seat, tty); 603 device->em = elput_manager_connect(seat, tty);
604 if (!dev->em) 604 if (!device->em)
605 { 605 {
606 ERR("Could not connect to input manager"); 606 ERR("Could not connect to input manager");
607 goto man_err; 607 goto man_err;
608 } 608 }
609 609
610 dev->path = _drm2_device_find(dev->em, seat); 610 device->path = _drm2_device_find(device->em, seat);
611 if (!dev->path) 611 if (!device->path)
612 { 612 {
613 ERR("Could not find drm device on seat %s", seat); 613 ERR("Could not find drm device on seat %s", seat);
614 goto path_err; 614 goto path_err;
615 } 615 }
616 616
617 return dev;
618
619path_err:
620 elput_manager_disconnect(dev->em);
621man_err:
622 free(dev);
623 return NULL;
624}
625
626EAPI int
627ecore_drm2_device_open(Ecore_Drm2_Device *device)
628{
629 EINA_SAFETY_ON_NULL_RETURN_VAL(device, -1);
630
631 device->fd = elput_manager_open(device->em, device->path, -1); 617 device->fd = elput_manager_open(device->em, device->path, -1);
632 if (device->fd < 0) goto open_err; 618 if (device->fd < 0) goto path_err;
633 619
634 if (!elput_input_init(device->em)) 620 if (!elput_input_init(device->em))
635 { 621 {
@@ -681,12 +667,15 @@ ecore_drm2_device_open(Ecore_Drm2_Device *device)
681 ecore_event_handler_add(ELPUT_EVENT_DEVICE_CHANGE, 667 ecore_event_handler_add(ELPUT_EVENT_DEVICE_CHANGE,
682 _cb_device_change, device); 668 _cb_device_change, device);
683 669
684 return device->fd; 670 return device;
685 671
686input_err: 672input_err:
687 elput_manager_close(device->em, device->fd); 673 elput_manager_close(device->em, device->fd);
688open_err: 674path_err:
689 return -1; 675 elput_manager_disconnect(device->em);
676man_err:
677 free(device);
678 return NULL;
690} 679}
691 680
692EAPI void 681EAPI void