summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2014-09-23 15:50:44 -0400
committerChris Michael <cp.michael@samsung.com>2014-09-23 15:50:44 -0400
commite16c4097d4086386c07b4ce4e71738f1f48e61ac (patch)
tree7a3229ed107d5c50e1764ac0a3b805a0d2cb21c0
parent30c6aed053ad7898cbe96aac9d74e6d4a27d9cc1 (diff)
parente19fbbcd457d26bb3c110cf7699216874b24ab4b (diff)
Merge branch 'devs/devilhorns/ecore_drm_eeze'
ecore-drm: Port existing ecore-drm to use Eeze ecore-drm now uses Eeze library for udev device functions. This removes the existing dependency on udev and makes use of our own library (Eeze) to find, list, watch, and otherwise deal with udev devices. This is the last of the ecore-drm code that needs porting NB: Ecore-Drm Now uses Eeze for udev and Eldbus for dbus functionality. @feature
-rw-r--r--configure.ac237
-rw-r--r--src/lib/ecore_drm/Ecore_Drm.h2
-rw-r--r--src/lib/ecore_drm/ecore_drm.c11
-rw-r--r--src/lib/ecore_drm/ecore_drm_device.c149
-rw-r--r--src/lib/ecore_drm/ecore_drm_inputs.c202
-rw-r--r--src/lib/ecore_drm/ecore_drm_output.c92
-rw-r--r--src/lib/ecore_drm/ecore_drm_private.h6
7 files changed, 303 insertions, 396 deletions
diff --git a/configure.ac b/configure.ac
index ac8ae99298..411b946a55 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2899,6 +2899,123 @@ EFL_LIB_END([Eldbus])
2899#### End of Eldbus 2899#### End of Eldbus
2900 2900
2901 2901
2902#### Eeze
2903have_libmount_new="no"
2904have_libmount_old="no"
2905have_eeze_mount="no"
2906
2907EFL_LIB_START_OPTIONAL([Eeze], [test "${have_linux}" = "yes"])
2908
2909### Additional options to configure
2910AC_ARG_WITH([mount],
2911 [AS_HELP_STRING([--with-mount], [specify mount bin @<:@default=detect@:>@])],
2912 [with_eeze_mount=$withval], [with_eeze_mount="detect"])
2913AC_ARG_WITH([umount],
2914 [AS_HELP_STRING([--with-umount], [specify umount bin @<:@default=detect@:>@])],
2915 [with_eeze_umount=$withval], [with_eeze_umount="detect"])
2916AC_ARG_WITH([eject],
2917 [AS_HELP_STRING([--with-eject], [specify eject bin @<:@default=detect@:>@])],
2918 [with_eeze_eject=$withval], [with_eeze_eject="detect"])
2919
2920### Default values
2921
2922### Checks for programs
2923
2924### Checks for libraries
2925EFL_INTERNAL_DEPEND_PKG([EEZE], [eina])
2926EFL_INTERNAL_DEPEND_PKG([EEZE], [ecore])
2927EFL_INTERNAL_DEPEND_PKG([EEZE], [eo])
2928EFL_INTERNAL_DEPEND_PKG([EEZE], [ecore-file])
2929EFL_INTERNAL_DEPEND_PKG([EEZE], [ecore-con])
2930EFL_INTERNAL_DEPEND_PKG([EEZE], [eet])
2931
2932EFL_DEPEND_PKG([EEZE], [UDEV], [libudev >= 148])
2933
2934AC_ARG_ENABLE([libmount],
2935 [AS_HELP_STRING([--disable-libmount],[disable libmount support. @<:@default=enabled@:>@])],
2936 [
2937 if test "x${enableval}" = "xyes" ; then
2938 want_libmount="yes"
2939 else
2940 want_libmount="no"
2941 CFOPT_WARNING="xyes"
2942 fi
2943 ],
2944 [want_libmount="yes"])
2945
2946EFL_OPTIONAL_DEPEND_PKG([EEZE], [${want_libmount}],
2947 [EEZE_MOUNT], [mount >= 2.18.0])
2948EFL_ADD_FEATURE([EEZE], [libmount], [${have_eeze_mount}])
2949
2950PKG_CHECK_EXISTS([mount < 2.19.0],
2951 [have_libmount_old="yes"],
2952 [have_libmount_old="no"])
2953AC_MSG_CHECKING([Use old libmount API (before 2.19.0)])
2954AC_MSG_RESULT([${have_libmount_old}])
2955
2956PKG_CHECK_EXISTS([mount == 2.19.0],
2957 [have_libmount_219="yes"],
2958 [have_libmount_219="no"])
2959AC_MSG_CHECKING([Use libmount 2.19.0 API])
2960AC_MSG_RESULT([${have_libmount_219}])
2961
2962PKG_CHECK_EXISTS([mount > 2.19.0],
2963 [have_libmount_new="yes"],
2964 [have_libmount_new="no"])
2965AC_MSG_CHECKING([Use new libmount API (newer than 2.19.0)])
2966AC_MSG_RESULT([${have_libmount_new}])
2967
2968if test "x${have_libmount_old}" = "xyes"; then
2969 AC_DEFINE_UNQUOTED([OLD_LIBMOUNT], [1], [using first version of libmount])
2970fi
2971
2972## modules
2973if test "${want_tizen}" = "yes"; then
2974 PKG_CHECK_MODULES([TIZEN_SENSOR], [capi-system-sensor >= 0.1.17])
2975fi
2976EFL_ADD_FEATURE([EEZE], [tizen])
2977
2978EFL_EVAL_PKGS([EEZE])
2979
2980### Checks for header files
2981
2982### Checks for types
2983
2984### Checks for structures
2985
2986### Checks for compiler characteristics
2987
2988### Checks for linker characteristics
2989
2990### Checks for library functions
2991
2992### Checks for binaries
2993if test "x$with_eeze_mount" = "xdetect"; then
2994 AC_PATH_PROG([with_eeze_mount], [mount], [])
2995fi
2996AC_DEFINE_UNQUOTED([EEZE_MOUNT_BIN], ["$with_eeze_mount"], [mount bin to use])
2997
2998if test "x$with_eeze_umount" = "xdetect";then
2999 AC_PATH_PROG([with_eeze_umount], [umount], [])
3000fi
3001AC_DEFINE_UNQUOTED([EEZE_UNMOUNT_BIN], ["$with_eeze_umount"], [umount bin to use])
3002
3003if test "x$with_eeze_eject" = "xdetect";then
3004 AC_PATH_PROG([with_eeze_eject], [eject], [])
3005fi
3006AC_DEFINE_UNQUOTED([EEZE_EJECT_BIN], ["$with_eeze_eject"], [eject bin to use])
3007
3008EFL_LIB_END_OPTIONAL([Eeze])
3009
3010AM_CONDITIONAL([EEZE_LIBMOUNT_AFTER_219],
3011 [test "x${have_libmount_new}" = "xyes"])
3012AM_CONDITIONAL([EEZE_LIBMOUNT_BEFORE_219],
3013 [test "x${have_libmount_old}" = "xyes"])
3014AM_CONDITIONAL([HAVE_EEZE_MOUNT], [test "x${have_eeze_mount}" = "xyes"])
3015AM_CONDITIONAL([HAVE_EEZE_TIZEN], [test "x${want_tizen}" = "xyes"])
3016#### End of Eeze
3017
3018
2902#### Ecore_Drm 3019#### Ecore_Drm
2903EFL_LIB_START_OPTIONAL([Ecore_Drm], [test "${want_drm}" = "yes"]) 3020EFL_LIB_START_OPTIONAL([Ecore_Drm], [test "${want_drm}" = "yes"])
2904 3021
@@ -2916,10 +3033,11 @@ AC_SUBST([SUID_LDFLAGS])
2916EFL_INTERNAL_DEPEND_PKG([ECORE_DRM], [ecore]) 3033EFL_INTERNAL_DEPEND_PKG([ECORE_DRM], [ecore])
2917EFL_INTERNAL_DEPEND_PKG([ECORE_DRM], [ecore-input]) 3034EFL_INTERNAL_DEPEND_PKG([ECORE_DRM], [ecore-input])
2918EFL_INTERNAL_DEPEND_PKG([ECORE_DRM], [eldbus]) 3035EFL_INTERNAL_DEPEND_PKG([ECORE_DRM], [eldbus])
3036EFL_INTERNAL_DEPEND_PKG([ECORE_DRM], [eeze])
2919EFL_INTERNAL_DEPEND_PKG([ECORE_DRM], [eo]) 3037EFL_INTERNAL_DEPEND_PKG([ECORE_DRM], [eo])
2920EFL_INTERNAL_DEPEND_PKG([ECORE_DRM], [eina]) 3038EFL_INTERNAL_DEPEND_PKG([ECORE_DRM], [eina])
2921 3039
2922EFL_DEPEND_PKG([ECORE_DRM], [DRM], [libudev >= 148 libdrm >= 2.4 xkbcommon >= 0.3.0 libsystemd-login >= 192 gbm]) 3040EFL_DEPEND_PKG([ECORE_DRM], [DRM], [libdrm >= 2.4 xkbcommon >= 0.3.0 libsystemd-login >= 192 gbm])
2923 3041
2924EFL_EVAL_PKGS([ECORE_DRM]) 3042EFL_EVAL_PKGS([ECORE_DRM])
2925 3043
@@ -3574,123 +3692,6 @@ EFL_LIB_END_OPTIONAL([Ecore_Imf_Evas])
3574#### End of Ecore_Imf_Evas 3692#### End of Ecore_Imf_Evas
3575 3693
3576 3694
3577#### Eeze
3578have_libmount_new="no"
3579have_libmount_old="no"
3580have_eeze_mount="no"
3581
3582EFL_LIB_START_OPTIONAL([Eeze], [test "${have_linux}" = "yes"])
3583
3584### Additional options to configure
3585AC_ARG_WITH([mount],
3586 [AS_HELP_STRING([--with-mount], [specify mount bin @<:@default=detect@:>@])],
3587 [with_eeze_mount=$withval], [with_eeze_mount="detect"])
3588AC_ARG_WITH([umount],
3589 [AS_HELP_STRING([--with-umount], [specify umount bin @<:@default=detect@:>@])],
3590 [with_eeze_umount=$withval], [with_eeze_umount="detect"])
3591AC_ARG_WITH([eject],
3592 [AS_HELP_STRING([--with-eject], [specify eject bin @<:@default=detect@:>@])],
3593 [with_eeze_eject=$withval], [with_eeze_eject="detect"])
3594
3595### Default values
3596
3597### Checks for programs
3598
3599### Checks for libraries
3600EFL_INTERNAL_DEPEND_PKG([EEZE], [eina])
3601EFL_INTERNAL_DEPEND_PKG([EEZE], [ecore])
3602EFL_INTERNAL_DEPEND_PKG([EEZE], [eo])
3603EFL_INTERNAL_DEPEND_PKG([EEZE], [ecore-file])
3604EFL_INTERNAL_DEPEND_PKG([EEZE], [ecore-con])
3605EFL_INTERNAL_DEPEND_PKG([EEZE], [eet])
3606
3607EFL_DEPEND_PKG([EEZE], [UDEV], [libudev >= 148])
3608
3609AC_ARG_ENABLE([libmount],
3610 [AS_HELP_STRING([--disable-libmount],[disable libmount support. @<:@default=enabled@:>@])],
3611 [
3612 if test "x${enableval}" = "xyes" ; then
3613 want_libmount="yes"
3614 else
3615 want_libmount="no"
3616 CFOPT_WARNING="xyes"
3617 fi
3618 ],
3619 [want_libmount="yes"])
3620
3621EFL_OPTIONAL_DEPEND_PKG([EEZE], [${want_libmount}],
3622 [EEZE_MOUNT], [mount >= 2.18.0])
3623EFL_ADD_FEATURE([EEZE], [libmount], [${have_eeze_mount}])
3624
3625PKG_CHECK_EXISTS([mount < 2.19.0],
3626 [have_libmount_old="yes"],
3627 [have_libmount_old="no"])
3628AC_MSG_CHECKING([Use old libmount API (before 2.19.0)])
3629AC_MSG_RESULT([${have_libmount_old}])
3630
3631PKG_CHECK_EXISTS([mount == 2.19.0],
3632 [have_libmount_219="yes"],
3633 [have_libmount_219="no"])
3634AC_MSG_CHECKING([Use libmount 2.19.0 API])
3635AC_MSG_RESULT([${have_libmount_219}])
3636
3637PKG_CHECK_EXISTS([mount > 2.19.0],
3638 [have_libmount_new="yes"],
3639 [have_libmount_new="no"])
3640AC_MSG_CHECKING([Use new libmount API (newer than 2.19.0)])
3641AC_MSG_RESULT([${have_libmount_new}])
3642
3643if test "x${have_libmount_old}" = "xyes"; then
3644 AC_DEFINE_UNQUOTED([OLD_LIBMOUNT], [1], [using first version of libmount])
3645fi
3646
3647## modules
3648if test "${want_tizen}" = "yes"; then
3649 PKG_CHECK_MODULES([TIZEN_SENSOR], [capi-system-sensor >= 0.1.17])
3650fi
3651EFL_ADD_FEATURE([EEZE], [tizen])
3652
3653EFL_EVAL_PKGS([EEZE])
3654
3655### Checks for header files
3656
3657### Checks for types
3658
3659### Checks for structures
3660
3661### Checks for compiler characteristics
3662
3663### Checks for linker characteristics
3664
3665### Checks for library functions
3666
3667### Checks for binaries
3668if test "x$with_eeze_mount" = "xdetect"; then
3669 AC_PATH_PROG([with_eeze_mount], [mount], [])
3670fi
3671AC_DEFINE_UNQUOTED([EEZE_MOUNT_BIN], ["$with_eeze_mount"], [mount bin to use])
3672
3673if test "x$with_eeze_umount" = "xdetect";then
3674 AC_PATH_PROG([with_eeze_umount], [umount], [])
3675fi
3676AC_DEFINE_UNQUOTED([EEZE_UNMOUNT_BIN], ["$with_eeze_umount"], [umount bin to use])
3677
3678if test "x$with_eeze_eject" = "xdetect";then
3679 AC_PATH_PROG([with_eeze_eject], [eject], [])
3680fi
3681AC_DEFINE_UNQUOTED([EEZE_EJECT_BIN], ["$with_eeze_eject"], [eject bin to use])
3682
3683EFL_LIB_END_OPTIONAL([Eeze])
3684
3685AM_CONDITIONAL([EEZE_LIBMOUNT_AFTER_219],
3686 [test "x${have_libmount_new}" = "xyes"])
3687AM_CONDITIONAL([EEZE_LIBMOUNT_BEFORE_219],
3688 [test "x${have_libmount_old}" = "xyes"])
3689AM_CONDITIONAL([HAVE_EEZE_MOUNT], [test "x${have_eeze_mount}" = "xyes"])
3690AM_CONDITIONAL([HAVE_EEZE_TIZEN], [test "x${want_tizen}" = "xyes"])
3691#### End of Eeze
3692
3693
3694#### Ecore_Evas 3695#### Ecore_Evas
3695EFL_LIB_START_OPTIONAL([Ecore_Evas], [test "x${build_gui}" = "xyes"]) 3696EFL_LIB_START_OPTIONAL([Ecore_Evas], [test "x${build_gui}" = "xyes"])
3696 3697
diff --git a/src/lib/ecore_drm/Ecore_Drm.h b/src/lib/ecore_drm/Ecore_Drm.h
index c5730b5236..81d6bf92ad 100644
--- a/src/lib/ecore_drm/Ecore_Drm.h
+++ b/src/lib/ecore_drm/Ecore_Drm.h
@@ -129,7 +129,7 @@ typedef struct _Ecore_Drm_Output_Mode Ecore_Drm_Output_Mode;
129/* opaque structure to represent a drm output */ 129/* opaque structure to represent a drm output */
130typedef struct _Ecore_Drm_Output Ecore_Drm_Output; 130typedef struct _Ecore_Drm_Output Ecore_Drm_Output;
131 131
132/* opaque structure to represent a drm udev input */ 132/* opaque structure to represent a drm input */
133typedef struct _Ecore_Drm_Input Ecore_Drm_Input; 133typedef struct _Ecore_Drm_Input Ecore_Drm_Input;
134 134
135/* opaque structure to represent a drm evdev input */ 135/* opaque structure to represent a drm evdev input */
diff --git a/src/lib/ecore_drm/ecore_drm.c b/src/lib/ecore_drm/ecore_drm.c
index 79d2b7888e..95a210365d 100644
--- a/src/lib/ecore_drm/ecore_drm.c
+++ b/src/lib/ecore_drm/ecore_drm.c
@@ -9,7 +9,6 @@ static int _ecore_drm_init_count = 0;
9static char *sid; 9static char *sid;
10 10
11/* external variables */ 11/* external variables */
12struct udev *udev;
13int _ecore_drm_log_dom = -1; 12int _ecore_drm_log_dom = -1;
14 13
15/** 14/**
@@ -72,13 +71,13 @@ ecore_drm_init(void)
72 /* try to init dbus */ 71 /* try to init dbus */
73 if (!_ecore_drm_dbus_init(sid)) goto dbus_err; 72 if (!_ecore_drm_dbus_init(sid)) goto dbus_err;
74 73
75 /* try to init udev */ 74 /* try to init eeze */
76 if (!(udev = udev_new())) goto udev_err; 75 if (!eeze_init()) goto eeze_err;
77 76
78 /* return init count */ 77 /* return init count */
79 return _ecore_drm_init_count; 78 return _ecore_drm_init_count;
80 79
81udev_err: 80eeze_err:
82 _ecore_drm_dbus_shutdown(); 81 _ecore_drm_dbus_shutdown();
83dbus_err: 82dbus_err:
84 free(sid); 83 free(sid);
@@ -106,8 +105,8 @@ ecore_drm_shutdown(void)
106 /* if we are still in use, decrement init count and get out */ 105 /* if we are still in use, decrement init count and get out */
107 if (--_ecore_drm_init_count != 0) return _ecore_drm_init_count; 106 if (--_ecore_drm_init_count != 0) return _ecore_drm_init_count;
108 107
109 /* close udev handle */ 108 /* close eeze */
110 if (udev) udev_unref(udev); 109 eeze_shutdown();
111 110
112 /* cleanup dbus */ 111 /* cleanup dbus */
113 _ecore_drm_dbus_shutdown(); 112 _ecore_drm_dbus_shutdown();
diff --git a/src/lib/ecore_drm/ecore_drm_device.c b/src/lib/ecore_drm/ecore_drm_device.c
index c571b9333b..4b7c4e3017 100644
--- a/src/lib/ecore_drm/ecore_drm_device.c
+++ b/src/lib/ecore_drm/ecore_drm_device.c
@@ -151,131 +151,84 @@ EAPI Ecore_Drm_Device *
151ecore_drm_device_find(const char *name, const char *seat) 151ecore_drm_device_find(const char *name, const char *seat)
152{ 152{
153 Ecore_Drm_Device *dev = NULL; 153 Ecore_Drm_Device *dev = NULL;
154 struct udev_enumerate *uenum; 154 Eina_Bool found = EINA_FALSE;
155 struct udev_list_entry *uentry; 155 Eina_List *devs, *l;
156 struct udev_device *udevice, *tmpdevice = NULL, *pcidevice; 156 const char *device, *tmpdevice;
157 const char *path = NULL, *devseat = NULL;
158 157
159 /* check for existing udev reference */ 158 /* try to get a list of drm devics */
160 if (!udev) return NULL; 159 if (!(devs = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRM, name)))
160 return NULL;
161 161
162 /* setup udev enumerator */ 162 DBG("Find Drm Device: %s", name);
163 uenum = udev_enumerate_new(udev);
164 udev_enumerate_add_match_subsystem(uenum, "drm");
165 udev_enumerate_add_match_subsystem(uenum, "card[0-9]*");
166 163
167 /* ask udev for list of drm devices */ 164 EINA_LIST_FOREACH(devs, l, device)
168 udev_enumerate_scan_devices(uenum);
169
170 /* loop list of returned devices */
171 udev_list_entry_foreach(uentry, udev_enumerate_get_list_entry(uenum))
172 { 165 {
173 /* get device path */ 166 const char *devpath;
174 path = udev_list_entry_get_name(uentry); 167 const char *devseat;
168 const char *devparent;
175 169
176 /* get udev device */ 170 if (!(devpath = eeze_udev_syspath_get_devpath(device)))
177 if (!(udevice = udev_device_new_from_syspath(udev, path)))
178 continue; 171 continue;
179 172
180 /* if we are looking for a certain device, then compare names */ 173 DBG("Found Drm Device");
181 if (name) 174 DBG("\tDevice: %s", device);
182 { 175 DBG("\tDevpath: %s", devpath);
183 if (strcmp(name, udev_device_get_devnode(udevice)))
184 {
185 udev_device_unref(udevice);
186 continue;
187 }
188 }
189 176
190 /* get this devices' seat */ 177 if ((name) && (strcmp(name, devpath))) goto cont;
191 devseat = udev_device_get_property_value(udevice, "ID_SEAT");
192 if (!devseat) devseat = "seat0";
193 178
194 /* if we are looking for a device on a certain seat, compare it */ 179 if (!(devseat = eeze_udev_syspath_get_property(device, "ID_SEAT")))
195 if (seat) 180 devseat = eina_stringshare_add("seat0");
196 {
197 if (strcmp(seat, devseat))
198 {
199 udev_device_unref(udevice);
200 continue;
201 }
202 }
203 else
204 {
205 /* no seat name passed to use. check default */
206 if (strcmp(devseat, "seat0"))
207 {
208 udev_device_unref(udevice);
209 continue;
210 }
211 }
212 181
213 /* try to find the boot_vga attribute */ 182 if ((seat) && (strcmp(seat, devseat)))
214 if ((pcidevice = 183 goto cont;
215 udev_device_get_parent_with_subsystem_devtype(udevice, "pci", NULL))) 184 else if (strcmp(devseat, "seat0"))
185 goto cont;
186
187 devparent = eeze_udev_syspath_get_parent_filtered(device, "pci", NULL);
188 if (devparent)
216 { 189 {
217 const char *id; 190 const char *id;
218 191
219 if ((id = udev_device_get_sysattr_value(pcidevice, "boot_vga"))) 192 if ((id = eeze_udev_syspath_get_sysattr(devparent, "boot_vga")))
220 { 193 {
221 if (!strcmp(id, "1")) 194 if (!strcmp(id, "1")) found = EINA_TRUE;
222 { 195 eina_stringshare_del(id);
223 if (tmpdevice) udev_device_unref(tmpdevice);
224 tmpdevice = udevice;
225 break;
226 }
227 } 196 }
197
198 eina_stringshare_del(devparent);
228 } 199 }
229 200
230 if (!tmpdevice) 201cont:
231 tmpdevice = udevice; 202 eina_stringshare_del(devpath);
232 else 203 if (found)
233 udev_device_unref(udevice); 204 {
205 tmpdevice = eina_stringshare_add(device);
206 break;
207 }
234 } 208 }
235 209
236 /* destroy the enumerator */ 210 EINA_LIST_FREE(devs, device)
237 udev_enumerate_unref(uenum); 211 eina_stringshare_del(device);
238 212
239 if (tmpdevice) 213 if (!found) return NULL;
240 {
241 DBG("Found Drm Device");
242 DBG("\tFilename: %s", udev_device_get_devnode(tmpdevice));
243 DBG("\tDriver: %s", udev_device_get_driver(tmpdevice));
244 DBG("\tDevpath: %s", udev_device_get_devpath(tmpdevice));
245 DBG("\tSyspath: %s", udev_device_get_syspath(tmpdevice));
246 DBG("\tSysname: %s", udev_device_get_sysname(tmpdevice));
247
248 /* try to allocate space for return device structure */
249 if ((dev = calloc(1, sizeof(Ecore_Drm_Device))))
250 {
251 const char *id, *seat_id;
252 214
253 /* set device name */ 215 if ((dev = calloc(1, sizeof(Ecore_Drm_Device))))
254 dev->drm.name = 216 {
255 eina_stringshare_add(udev_device_get_devnode(tmpdevice)); 217 dev->drm.name = eeze_udev_syspath_get_devpath(tmpdevice);
256 218 dev->drm.path = eina_stringshare_add(tmpdevice);
257 /* set device path */
258 dev->drm.path =
259 eina_stringshare_add(udev_device_get_syspath(tmpdevice));
260 219
261 /* store id for this device */ 220 dev->id = eeze_udev_syspath_get_sysnum(tmpdevice);
262 if ((id = udev_device_get_sysnum(tmpdevice)))
263 dev->id = atoi(id);
264 221
265 /* set dev seat_id */ 222 dev->seat = eeze_udev_syspath_get_property(tmpdevice, "ID_SEAT");
266 seat_id = udev_device_get_property_value(tmpdevice, "ID_SEAT"); 223 if (!dev->seat) dev->seat = eina_stringshare_add("seat0");
267 if (!seat_id) seat_id = "seat0";
268 224
269 dev->seat = eina_stringshare_add(seat_id); 225 dev->format = 0;
226 dev->use_hw_accel = EINA_FALSE;
270 227
271 /* dev->format = GBM_FORMAT_XRGB8888; */ 228 DBG("Using Drm Device: %s", dev->drm.name);
272 dev->format = 0;
273 dev->use_hw_accel = EINA_FALSE;
274 }
275 } 229 }
276 230
277 /* release device reference */ 231 eina_stringshare_del(tmpdevice);
278 udev_device_unref(tmpdevice);
279 232
280 return dev; 233 return dev;
281} 234}
diff --git a/src/lib/ecore_drm/ecore_drm_inputs.c b/src/lib/ecore_drm/ecore_drm_inputs.c
index 0774b8fc34..cec69135c2 100644
--- a/src/lib/ecore_drm/ecore_drm_inputs.c
+++ b/src/lib/ecore_drm/ecore_drm_inputs.c
@@ -87,7 +87,7 @@ _cb_device_opened(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending
87 87
88 if (!(d = data)) return; 88 if (!(d = data)) return;
89 89
90 DBG("Device Opened: %s", d->node); 90 /* DBG("Input Device Opened: %s", d->node); */
91 91
92 /* DBUS_TYPE_UNIX_FD == 'h' */ 92 /* DBUS_TYPE_UNIX_FD == 'h' */
93 if (!eldbus_message_arguments_get(msg, "hb", &fd, &b)) 93 if (!eldbus_message_arguments_get(msg, "hb", &fd, &b))
@@ -142,37 +142,43 @@ _seat_get(Ecore_Drm_Input *input, const char *seat)
142} 142}
143 143
144static Eina_Bool 144static Eina_Bool
145_device_add(Ecore_Drm_Input *input, struct udev_device *device) 145_device_add(Ecore_Drm_Input *input, const char *device)
146{ 146{
147 Ecore_Drm_Device_Open_Data *data;
148 Ecore_Drm_Seat *seat; 147 Ecore_Drm_Seat *seat;
149 const char *dev_seat, *wl_seat; 148 Ecore_Drm_Device_Open_Data *data;
150 const char *node; 149 const char *devseat, *wlseat;
151 char n[PATH_MAX];
152 150
153 if (!(dev_seat = udev_device_get_property_value(device, "ID_SEAT"))) 151 DBG("Add Input Device: %s", device);
154 dev_seat = "seat0";
155 152
156 if (strcmp(dev_seat, input->seat)) return EINA_FALSE; 153 if (!(devseat = eeze_udev_syspath_get_property(device, "ID_SEAT")))
154 devseat = eina_stringshare_add("seat0");
157 155
158 if (!(wl_seat = udev_device_get_property_value(device, "WL_SEAT"))) 156 if (strcmp(devseat, input->seat)) goto seat_err;
159 wl_seat = "seat0";
160 157
161 if (!(seat = _seat_get(input, wl_seat))) 158 if (!(wlseat = eeze_udev_syspath_get_property(device, "WL_SEAT")))
162 return EINA_FALSE; 159 wlseat = eina_stringshare_add("seat0");
163 160
164 node = udev_device_get_devnode(device); 161 if (!(seat = _seat_get(input, wlseat)))
165 strcpy(n, node); 162 {
163 ERR("\tCould not get matching seat");
164 goto seat_get_err;
165 }
166 166
167 if (!(data = calloc(1, sizeof(Ecore_Drm_Device_Open_Data)))) 167 if (!(data = calloc(1, sizeof(Ecore_Drm_Device_Open_Data))))
168 return EINA_FALSE; 168 goto seat_get_err;
169 169
170 data->seat = seat; 170 data->seat = seat;
171 data->node = eina_stringshare_add(n); 171 data->node = eeze_udev_syspath_get_devpath(device);
172 172
173 _ecore_drm_dbus_device_open(n, _cb_device_opened, data); 173 _ecore_drm_dbus_device_open(data->node, _cb_device_opened, data);
174 174
175 return EINA_TRUE; 175 return EINA_TRUE;
176
177seat_get_err:
178 eina_stringshare_del(wlseat);
179seat_err:
180 eina_stringshare_del(devseat);
181 return EINA_FALSE;
176} 182}
177 183
178static void 184static void
@@ -200,79 +206,61 @@ _device_remove(Ecore_Drm_Input *input, const char *device)
200 } 206 }
201} 207}
202 208
203static Eina_Bool 209static void
204_cb_input_event(void *data, Ecore_Fd_Handler *hdlr EINA_UNUSED) 210_cb_input_event(const char *device, Eeze_Udev_Event event, void *data, Eeze_Udev_Watch *watch EINA_UNUSED)
205{ 211{
206 Ecore_Drm_Input *input; 212 Ecore_Drm_Input *input;
207 struct udev_device *udevice;
208 const char *act;
209
210 if (!(input = data)) return EINA_FALSE;
211
212 if (!(udevice = udev_monitor_receive_device(input->monitor)))
213 return EINA_TRUE;
214
215 if (!(act = udev_device_get_action(udevice))) return EINA_TRUE;
216 213
217 if (strncmp("event", udev_device_get_sysname(udevice), 5) != 0) 214 if (!(input = data)) return;
218 goto err;
219 215
220 if (!strcmp(act, "add")) 216 switch (event)
221 _device_add(input, udevice);
222 else if (!strcmp(act, "remove"))
223 { 217 {
224 const char *node; 218 case EEZE_UDEV_EVENT_ADD:
225 219 _device_add(input, device);
226 node = udev_device_get_devnode(udevice); 220 break;
221 case EEZE_UDEV_EVENT_REMOVE:
222 {
223 const char *node;
227 224
228 _device_remove(input, node); 225 node = eeze_udev_syspath_get_devpath(device);
226 _device_remove(input, node);
227 eina_stringshare_del(node);
228 }
229 break;
230 default:
231 break;
229 } 232 }
230
231 return EINA_TRUE;
232
233err:
234 if (udevice) udev_device_unref(udevice);
235 return EINA_TRUE;
236} 233}
237 234
238static Eina_Bool 235static Eina_Bool
239_devices_add(Ecore_Drm_Input *input) 236_devices_add(Ecore_Drm_Input *input)
240{ 237{
241 struct udev_enumerate *uenum; 238 Eina_List *devices;
242 struct udev_list_entry *uentry;
243 struct udev_device *udevice;
244 const char *path, *name;
245 Eina_Bool found = EINA_FALSE; 239 Eina_Bool found = EINA_FALSE;
246 240 const char *device;
247 uenum = udev_enumerate_new(udev); 241
248 udev_enumerate_add_match_subsystem(uenum, "input"); 242 /* NB: This really sucks !! We cannot 'OR' diferent device types
249 udev_enumerate_scan_devices(uenum); 243 * together for eeze_udev_find_by_type
250 244 *
251 udev_list_entry_foreach(uentry, udev_enumerate_get_list_entry(uenum)) 245 * For now, just find by 'NONE" and we'll filter for input devices by
246 * running tests */
247 devices = eeze_udev_find_by_type(EEZE_UDEV_TYPE_NONE, NULL);
248 EINA_LIST_FREE(devices, device)
252 { 249 {
253 path = udev_list_entry_get_name(uentry); 250 if ((eeze_udev_syspath_is_mouse(device)) ||
254 udevice = udev_device_new_from_syspath(udev, path); 251 (eeze_udev_syspath_is_kbd(device)) ||
255 name = udev_device_get_sysname(udevice); 252 (eeze_udev_syspath_is_touchpad(device)) ||
256 253 (eeze_udev_syspath_is_joystick(device)))
257 if (strncmp("event", name, 5) != 0)
258 {
259 udev_device_unref(udevice);
260 continue;
261 }
262
263 if (!_device_add(input, udevice))
264 { 254 {
265 udev_device_unref(udevice); 255 if (!_device_add(input, device))
266 continue; 256 ERR("\tFailed to add device");
257 else
258 found = EINA_TRUE;
267 } 259 }
268 260
269 found = EINA_TRUE; 261 eina_stringshare_del(device);
270
271 udev_device_unref(udevice);
272 } 262 }
273 263
274 udev_enumerate_unref(uenum);
275
276 if (!found) 264 if (!found)
277 { 265 {
278 ERR("No Input Devices Found"); 266 ERR("No Input Devices Found");
@@ -289,7 +277,7 @@ ecore_drm_inputs_create(Ecore_Drm_Device *dev)
289 Ecore_Drm_Input *input; 277 Ecore_Drm_Input *input;
290 278
291 /* check for valid device */ 279 /* check for valid device */
292 if ((!dev) || (!udev)) return EINA_FALSE; 280 if (!dev) return EINA_FALSE;
293 281
294 /* try to allocate space for input structure */ 282 /* try to allocate space for input structure */
295 if (!(input = calloc(1, sizeof(Ecore_Drm_Input)))) 283 if (!(input = calloc(1, sizeof(Ecore_Drm_Input))))
@@ -340,55 +328,31 @@ ecore_drm_inputs_enable(Ecore_Drm_Input *input)
340 /* check for valid input */ 328 /* check for valid input */
341 if (!input) return EINA_FALSE; 329 if (!input) return EINA_FALSE;
342 330
343 if (!input->monitor) 331 if (!input->watch)
344 input->monitor = udev_monitor_new_from_netlink(udev, "udev");
345
346 if (!input->monitor)
347 {
348 ERR("Could not create udev monitor: %m");
349 return EINA_FALSE;
350 }
351
352 /* setup input filter */
353 udev_monitor_filter_add_match_subsystem_devtype(input->monitor,
354 "input", NULL);
355
356 /* try to enable receiving udev events */
357 if (udev_monitor_enable_receiving(input->monitor))
358 {
359 ERR("Could not bind udev monitor: %m");
360 udev_monitor_unref(input->monitor);
361 return EINA_FALSE;
362 }
363
364 /* save the fd */
365 if ((input->fd = udev_monitor_get_fd(input->monitor)) < 0)
366 { 332 {
367 ERR("Input monitor has no fd: %m"); 333 int events = 0;
368 udev_monitor_unref(input->monitor); 334
369 return EINA_FALSE; 335 events = (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE);
370 } 336 /* NB: This really sucks !! We cannot 'OR' diferent device types
371 337 * together for eeze_udev_watch_add :(
372 /* create fd handler */ 338 *
373 if (!input->hdlr) 339 * For now, just put a 'watch' on mouse type as this (in effect) does
374 { 340 * what we need by internally by adding a subsystem match for 'input' */
375 input->hdlr = 341 if (!(input->watch =
376 ecore_main_fd_handler_add(input->fd, ECORE_FD_READ, 342 eeze_udev_watch_add(EEZE_UDEV_TYPE_MOUSE, events,
377 _cb_input_event, input, NULL, NULL); 343 _cb_input_event, input)))
378 } 344 {
379 345 ERR("Could not create Eeze_Udev_Watch for input");
380 if (!input->hdlr) 346 return EINA_FALSE;
381 { 347 }
382 ERR("Failed to setup input fd handler: %m");
383 udev_monitor_unref(input->monitor);
384 return EINA_FALSE;
385 } 348 }
386 349
387 /* try to add devices */ 350 /* try to add devices */
388 if (!_devices_add(input)) 351 if (!_devices_add(input))
389 { 352 {
390 ERR("Could not add input devices"); 353 ERR("Could not add input devices");
391 udev_monitor_unref(input->monitor); 354 eeze_udev_watch_del(input->watch);
355 input->watch = NULL;
392 return EINA_FALSE; 356 return EINA_FALSE;
393 } 357 }
394 358
@@ -403,13 +367,11 @@ ecore_drm_inputs_disable(Ecore_Drm_Input *input)
403{ 367{
404 if (!input) return; 368 if (!input) return;
405 369
406 if (input->monitor) udev_monitor_unref(input->monitor); 370 if (input->watch) eeze_udev_watch_del(input->watch);
407 input->monitor = NULL; 371 input->watch = NULL;
408
409 if (input->hdlr) ecore_main_fd_handler_del(input->hdlr);
410 input->hdlr = NULL;
411 372
412 input->enabled = EINA_FALSE; 373 input->enabled = EINA_FALSE;
413 input->suspended = EINA_TRUE; 374 input->suspended = EINA_TRUE;
375
414 ecore_drm_inputs_destroy(input->dev); 376 ecore_drm_inputs_destroy(input->dev);
415} 377}
diff --git a/src/lib/ecore_drm/ecore_drm_output.c b/src/lib/ecore_drm/ecore_drm_output.c
index 105440e101..8f85f8bf7e 100644
--- a/src/lib/ecore_drm/ecore_drm_output.c
+++ b/src/lib/ecore_drm/ecore_drm_output.c
@@ -291,69 +291,63 @@ _ecore_drm_output_mode_add(Ecore_Drm_Output *output, drmModeModeInfo *info)
291} 291}
292 292
293static Ecore_Drm_Backlight * 293static Ecore_Drm_Backlight *
294_ecore_drm_backlight_init(Ecore_Drm_Device *dev, uint32_t conn_type) 294_ecore_drm_backlight_init(Ecore_Drm_Device *dev EINA_UNUSED, uint32_t conn_type)
295{ 295{
296 Ecore_Drm_Backlight *backlight = NULL; 296 Ecore_Drm_Backlight *backlight = NULL;
297 Ecore_Drm_Backlight_Type type = 0; 297 Ecore_Drm_Backlight_Type type = 0;
298 struct udev_enumerate *enumerate; 298 Eina_List *devs, *l;
299 struct udev_device *device; 299 Eina_Bool found = EINA_FALSE;
300 struct udev_list_entry *item, *first; 300 const char *device, *devtype, *tmpdevice;
301 const char *dev_type, *backlight_path; 301
302 int ret; 302 if (!(devs = eeze_udev_find_by_type(EEZE_UDEV_TYPE_BACKLIGHT, NULL)))
303 303 devs = eeze_udev_find_by_type(EEZE_UDEV_TYPE_LEDS, NULL);
304 enumerate = udev_enumerate_new(udev);
305 if (!enumerate) return NULL;
306
307 udev_enumerate_add_match_subsystem(enumerate, "backlight");
308 ret = udev_enumerate_scan_devices(enumerate);
309 if (ret < 0)
310 {
311 udev_enumerate_add_match_subsystem(enumerate, "leds");
312 ret = udev_enumerate_scan_devices(enumerate);
313 if (ret < 0)
314 {
315 udev_enumerate_unref(enumerate);
316 return NULL;
317 }
318 }
319 304
320 first = udev_enumerate_get_list_entry(enumerate); 305 if (!devs) return NULL;
321 udev_list_entry_foreach(item, first) 306
307 EINA_LIST_FOREACH(devs, l, device)
322 { 308 {
323 backlight_path = udev_list_entry_get_name(item); 309 if (!(devtype = eeze_udev_syspath_get_sysattr(device, "type")))
324 device = udev_device_new_from_syspath(udev, backlight_path); 310 continue;
325 311
326 dev_type = udev_device_get_sysattr_value(device, "type"); 312 if (!strcmp(devtype, "raw"))
327 if (!dev_type)
328 {
329 udev_device_unref(device);
330 udev_enumerate_unref(enumerate);
331 return NULL;
332 }
333 if (!strcmp(dev_type, "raw"))
334 type = ECORE_DRM_BACKLIGHT_RAW; 313 type = ECORE_DRM_BACKLIGHT_RAW;
335 else if (!strcmp(dev_type, "platform")) 314 else if (!strcmp(devtype, "platform"))
336 type = ECORE_DRM_BACKLIGHT_PLATFORM; 315 type = ECORE_DRM_BACKLIGHT_PLATFORM;
337 else if (!strcmp(dev_type, "firmware")) 316 else if (!strcmp(devtype, "firmware"))
338 type = ECORE_DRM_BACKLIGHT_FIRMWARE; 317 type = ECORE_DRM_BACKLIGHT_FIRMWARE;
339 318
340 if (conn_type != DRM_MODE_CONNECTOR_LVDS && 319 if ((conn_type != DRM_MODE_CONNECTOR_LVDS) &&
341 conn_type != DRM_MODE_CONNECTOR_eDP) 320 (conn_type != DRM_MODE_CONNECTOR_eDP))
342 { 321 {
343 if (type != ECORE_DRM_BACKLIGHT_RAW) 322 if (type != ECORE_DRM_BACKLIGHT_RAW) goto cont;
344 { 323 }
345 udev_device_unref(device); 324
346 udev_enumerate_unref(enumerate); 325 found = EINA_TRUE;
347 return NULL; 326cont:
348 } 327 eina_stringshare_del(devtype);
328 if (found)
329 {
330 tmpdevice = eina_stringshare_add(device);
331 break;
349 } 332 }
350 udev_device_unref(device);
351 } 333 }
352 udev_enumerate_unref(enumerate);
353 334
354 backlight = (Ecore_Drm_Backlight *)malloc(sizeof(Ecore_Drm_Backlight)); 335 EINA_LIST_FREE(devs, device)
355 backlight->type = type; 336 eina_stringshare_del(device);
356 backlight->dir_path = eina_stringshare_add(backlight_path); 337
338 if (!found) return NULL;
339
340 if ((backlight = calloc(1, sizeof(Ecore_Drm_Backlight))))
341 {
342 backlight->type = type;
343 /* NB: This sets backlight directory path to /dev/...
344 * Am not sure yet if this is the desired path, or if we want the
345 * actual /sys path. If we want Just the syspath then 'tmpdevice' is
346 * already equal to that */
347 backlight->dir_path = eeze_udev_syspath_get_devpath(tmpdevice);
348 }
349
350 eina_stringshare_del(tmpdevice);
357 351
358 return backlight; 352 return backlight;
359} 353}
diff --git a/src/lib/ecore_drm/ecore_drm_private.h b/src/lib/ecore_drm/ecore_drm_private.h
index 6eac7bf639..2f0904dd66 100644
--- a/src/lib/ecore_drm/ecore_drm_private.h
+++ b/src/lib/ecore_drm/ecore_drm_private.h
@@ -19,7 +19,6 @@
19# include <sys/stat.h> 19# include <sys/stat.h>
20# include <sys/ioctl.h> 20# include <sys/ioctl.h>
21 21
22# include <libudev.h>
23# include <linux/input.h> 22# include <linux/input.h>
24//# include <libinput.h> 23//# include <libinput.h>
25# include <systemd/sd-login.h> 24# include <systemd/sd-login.h>
@@ -37,6 +36,7 @@
37/* # include <GLES2/gl2ext.h> */ 36/* # include <GLES2/gl2ext.h> */
38/* # endif */ 37/* # endif */
39 38
39# include <Eeze.h>
40# include <Eldbus.h> 40# include <Eldbus.h>
41# include <Ecore_Drm.h> 41# include <Ecore_Drm.h>
42 42
@@ -86,8 +86,6 @@ extern int _ecore_drm_log_dom;
86#define WRN(...) EINA_LOG_DOM_WARN(_ecore_drm_log_dom, __VA_ARGS__) 86#define WRN(...) EINA_LOG_DOM_WARN(_ecore_drm_log_dom, __VA_ARGS__)
87#define CRIT(...) EINA_LOG_DOM_CRIT(_ecore_drm_log_dom, __VA_ARGS__) 87#define CRIT(...) EINA_LOG_DOM_CRIT(_ecore_drm_log_dom, __VA_ARGS__)
88 88
89extern struct udev *udev;
90
91struct _Ecore_Drm_Output_Mode 89struct _Ecore_Drm_Output_Mode
92{ 90{
93 unsigned int flags; 91 unsigned int flags;
@@ -161,7 +159,7 @@ struct _Ecore_Drm_Input
161{ 159{
162 int fd; 160 int fd;
163 const char *seat; 161 const char *seat;
164 struct udev_monitor *monitor; 162 Eeze_Udev_Watch *watch;
165 Ecore_Fd_Handler *hdlr; 163 Ecore_Fd_Handler *hdlr;
166 Ecore_Drm_Device *dev; 164 Ecore_Drm_Device *dev;
167 165