forked from enlightenment/efl
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
This commit is contained in:
commit
e16c4097d4
237
configure.ac
237
configure.ac
|
@ -2899,6 +2899,123 @@ EFL_LIB_END([Eldbus])
|
|||
#### End of Eldbus
|
||||
|
||||
|
||||
#### Eeze
|
||||
have_libmount_new="no"
|
||||
have_libmount_old="no"
|
||||
have_eeze_mount="no"
|
||||
|
||||
EFL_LIB_START_OPTIONAL([Eeze], [test "${have_linux}" = "yes"])
|
||||
|
||||
### Additional options to configure
|
||||
AC_ARG_WITH([mount],
|
||||
[AS_HELP_STRING([--with-mount], [specify mount bin @<:@default=detect@:>@])],
|
||||
[with_eeze_mount=$withval], [with_eeze_mount="detect"])
|
||||
AC_ARG_WITH([umount],
|
||||
[AS_HELP_STRING([--with-umount], [specify umount bin @<:@default=detect@:>@])],
|
||||
[with_eeze_umount=$withval], [with_eeze_umount="detect"])
|
||||
AC_ARG_WITH([eject],
|
||||
[AS_HELP_STRING([--with-eject], [specify eject bin @<:@default=detect@:>@])],
|
||||
[with_eeze_eject=$withval], [with_eeze_eject="detect"])
|
||||
|
||||
### Default values
|
||||
|
||||
### Checks for programs
|
||||
|
||||
### Checks for libraries
|
||||
EFL_INTERNAL_DEPEND_PKG([EEZE], [eina])
|
||||
EFL_INTERNAL_DEPEND_PKG([EEZE], [ecore])
|
||||
EFL_INTERNAL_DEPEND_PKG([EEZE], [eo])
|
||||
EFL_INTERNAL_DEPEND_PKG([EEZE], [ecore-file])
|
||||
EFL_INTERNAL_DEPEND_PKG([EEZE], [ecore-con])
|
||||
EFL_INTERNAL_DEPEND_PKG([EEZE], [eet])
|
||||
|
||||
EFL_DEPEND_PKG([EEZE], [UDEV], [libudev >= 148])
|
||||
|
||||
AC_ARG_ENABLE([libmount],
|
||||
[AS_HELP_STRING([--disable-libmount],[disable libmount support. @<:@default=enabled@:>@])],
|
||||
[
|
||||
if test "x${enableval}" = "xyes" ; then
|
||||
want_libmount="yes"
|
||||
else
|
||||
want_libmount="no"
|
||||
CFOPT_WARNING="xyes"
|
||||
fi
|
||||
],
|
||||
[want_libmount="yes"])
|
||||
|
||||
EFL_OPTIONAL_DEPEND_PKG([EEZE], [${want_libmount}],
|
||||
[EEZE_MOUNT], [mount >= 2.18.0])
|
||||
EFL_ADD_FEATURE([EEZE], [libmount], [${have_eeze_mount}])
|
||||
|
||||
PKG_CHECK_EXISTS([mount < 2.19.0],
|
||||
[have_libmount_old="yes"],
|
||||
[have_libmount_old="no"])
|
||||
AC_MSG_CHECKING([Use old libmount API (before 2.19.0)])
|
||||
AC_MSG_RESULT([${have_libmount_old}])
|
||||
|
||||
PKG_CHECK_EXISTS([mount == 2.19.0],
|
||||
[have_libmount_219="yes"],
|
||||
[have_libmount_219="no"])
|
||||
AC_MSG_CHECKING([Use libmount 2.19.0 API])
|
||||
AC_MSG_RESULT([${have_libmount_219}])
|
||||
|
||||
PKG_CHECK_EXISTS([mount > 2.19.0],
|
||||
[have_libmount_new="yes"],
|
||||
[have_libmount_new="no"])
|
||||
AC_MSG_CHECKING([Use new libmount API (newer than 2.19.0)])
|
||||
AC_MSG_RESULT([${have_libmount_new}])
|
||||
|
||||
if test "x${have_libmount_old}" = "xyes"; then
|
||||
AC_DEFINE_UNQUOTED([OLD_LIBMOUNT], [1], [using first version of libmount])
|
||||
fi
|
||||
|
||||
## modules
|
||||
if test "${want_tizen}" = "yes"; then
|
||||
PKG_CHECK_MODULES([TIZEN_SENSOR], [capi-system-sensor >= 0.1.17])
|
||||
fi
|
||||
EFL_ADD_FEATURE([EEZE], [tizen])
|
||||
|
||||
EFL_EVAL_PKGS([EEZE])
|
||||
|
||||
### Checks for header files
|
||||
|
||||
### Checks for types
|
||||
|
||||
### Checks for structures
|
||||
|
||||
### Checks for compiler characteristics
|
||||
|
||||
### Checks for linker characteristics
|
||||
|
||||
### Checks for library functions
|
||||
|
||||
### Checks for binaries
|
||||
if test "x$with_eeze_mount" = "xdetect"; then
|
||||
AC_PATH_PROG([with_eeze_mount], [mount], [])
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED([EEZE_MOUNT_BIN], ["$with_eeze_mount"], [mount bin to use])
|
||||
|
||||
if test "x$with_eeze_umount" = "xdetect";then
|
||||
AC_PATH_PROG([with_eeze_umount], [umount], [])
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED([EEZE_UNMOUNT_BIN], ["$with_eeze_umount"], [umount bin to use])
|
||||
|
||||
if test "x$with_eeze_eject" = "xdetect";then
|
||||
AC_PATH_PROG([with_eeze_eject], [eject], [])
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED([EEZE_EJECT_BIN], ["$with_eeze_eject"], [eject bin to use])
|
||||
|
||||
EFL_LIB_END_OPTIONAL([Eeze])
|
||||
|
||||
AM_CONDITIONAL([EEZE_LIBMOUNT_AFTER_219],
|
||||
[test "x${have_libmount_new}" = "xyes"])
|
||||
AM_CONDITIONAL([EEZE_LIBMOUNT_BEFORE_219],
|
||||
[test "x${have_libmount_old}" = "xyes"])
|
||||
AM_CONDITIONAL([HAVE_EEZE_MOUNT], [test "x${have_eeze_mount}" = "xyes"])
|
||||
AM_CONDITIONAL([HAVE_EEZE_TIZEN], [test "x${want_tizen}" = "xyes"])
|
||||
#### End of Eeze
|
||||
|
||||
|
||||
#### Ecore_Drm
|
||||
EFL_LIB_START_OPTIONAL([Ecore_Drm], [test "${want_drm}" = "yes"])
|
||||
|
||||
|
@ -2916,10 +3033,11 @@ AC_SUBST([SUID_LDFLAGS])
|
|||
EFL_INTERNAL_DEPEND_PKG([ECORE_DRM], [ecore])
|
||||
EFL_INTERNAL_DEPEND_PKG([ECORE_DRM], [ecore-input])
|
||||
EFL_INTERNAL_DEPEND_PKG([ECORE_DRM], [eldbus])
|
||||
EFL_INTERNAL_DEPEND_PKG([ECORE_DRM], [eeze])
|
||||
EFL_INTERNAL_DEPEND_PKG([ECORE_DRM], [eo])
|
||||
EFL_INTERNAL_DEPEND_PKG([ECORE_DRM], [eina])
|
||||
|
||||
EFL_DEPEND_PKG([ECORE_DRM], [DRM], [libudev >= 148 libdrm >= 2.4 xkbcommon >= 0.3.0 libsystemd-login >= 192 gbm])
|
||||
EFL_DEPEND_PKG([ECORE_DRM], [DRM], [libdrm >= 2.4 xkbcommon >= 0.3.0 libsystemd-login >= 192 gbm])
|
||||
|
||||
EFL_EVAL_PKGS([ECORE_DRM])
|
||||
|
||||
|
@ -3574,123 +3692,6 @@ EFL_LIB_END_OPTIONAL([Ecore_Imf_Evas])
|
|||
#### End of Ecore_Imf_Evas
|
||||
|
||||
|
||||
#### Eeze
|
||||
have_libmount_new="no"
|
||||
have_libmount_old="no"
|
||||
have_eeze_mount="no"
|
||||
|
||||
EFL_LIB_START_OPTIONAL([Eeze], [test "${have_linux}" = "yes"])
|
||||
|
||||
### Additional options to configure
|
||||
AC_ARG_WITH([mount],
|
||||
[AS_HELP_STRING([--with-mount], [specify mount bin @<:@default=detect@:>@])],
|
||||
[with_eeze_mount=$withval], [with_eeze_mount="detect"])
|
||||
AC_ARG_WITH([umount],
|
||||
[AS_HELP_STRING([--with-umount], [specify umount bin @<:@default=detect@:>@])],
|
||||
[with_eeze_umount=$withval], [with_eeze_umount="detect"])
|
||||
AC_ARG_WITH([eject],
|
||||
[AS_HELP_STRING([--with-eject], [specify eject bin @<:@default=detect@:>@])],
|
||||
[with_eeze_eject=$withval], [with_eeze_eject="detect"])
|
||||
|
||||
### Default values
|
||||
|
||||
### Checks for programs
|
||||
|
||||
### Checks for libraries
|
||||
EFL_INTERNAL_DEPEND_PKG([EEZE], [eina])
|
||||
EFL_INTERNAL_DEPEND_PKG([EEZE], [ecore])
|
||||
EFL_INTERNAL_DEPEND_PKG([EEZE], [eo])
|
||||
EFL_INTERNAL_DEPEND_PKG([EEZE], [ecore-file])
|
||||
EFL_INTERNAL_DEPEND_PKG([EEZE], [ecore-con])
|
||||
EFL_INTERNAL_DEPEND_PKG([EEZE], [eet])
|
||||
|
||||
EFL_DEPEND_PKG([EEZE], [UDEV], [libudev >= 148])
|
||||
|
||||
AC_ARG_ENABLE([libmount],
|
||||
[AS_HELP_STRING([--disable-libmount],[disable libmount support. @<:@default=enabled@:>@])],
|
||||
[
|
||||
if test "x${enableval}" = "xyes" ; then
|
||||
want_libmount="yes"
|
||||
else
|
||||
want_libmount="no"
|
||||
CFOPT_WARNING="xyes"
|
||||
fi
|
||||
],
|
||||
[want_libmount="yes"])
|
||||
|
||||
EFL_OPTIONAL_DEPEND_PKG([EEZE], [${want_libmount}],
|
||||
[EEZE_MOUNT], [mount >= 2.18.0])
|
||||
EFL_ADD_FEATURE([EEZE], [libmount], [${have_eeze_mount}])
|
||||
|
||||
PKG_CHECK_EXISTS([mount < 2.19.0],
|
||||
[have_libmount_old="yes"],
|
||||
[have_libmount_old="no"])
|
||||
AC_MSG_CHECKING([Use old libmount API (before 2.19.0)])
|
||||
AC_MSG_RESULT([${have_libmount_old}])
|
||||
|
||||
PKG_CHECK_EXISTS([mount == 2.19.0],
|
||||
[have_libmount_219="yes"],
|
||||
[have_libmount_219="no"])
|
||||
AC_MSG_CHECKING([Use libmount 2.19.0 API])
|
||||
AC_MSG_RESULT([${have_libmount_219}])
|
||||
|
||||
PKG_CHECK_EXISTS([mount > 2.19.0],
|
||||
[have_libmount_new="yes"],
|
||||
[have_libmount_new="no"])
|
||||
AC_MSG_CHECKING([Use new libmount API (newer than 2.19.0)])
|
||||
AC_MSG_RESULT([${have_libmount_new}])
|
||||
|
||||
if test "x${have_libmount_old}" = "xyes"; then
|
||||
AC_DEFINE_UNQUOTED([OLD_LIBMOUNT], [1], [using first version of libmount])
|
||||
fi
|
||||
|
||||
## modules
|
||||
if test "${want_tizen}" = "yes"; then
|
||||
PKG_CHECK_MODULES([TIZEN_SENSOR], [capi-system-sensor >= 0.1.17])
|
||||
fi
|
||||
EFL_ADD_FEATURE([EEZE], [tizen])
|
||||
|
||||
EFL_EVAL_PKGS([EEZE])
|
||||
|
||||
### Checks for header files
|
||||
|
||||
### Checks for types
|
||||
|
||||
### Checks for structures
|
||||
|
||||
### Checks for compiler characteristics
|
||||
|
||||
### Checks for linker characteristics
|
||||
|
||||
### Checks for library functions
|
||||
|
||||
### Checks for binaries
|
||||
if test "x$with_eeze_mount" = "xdetect"; then
|
||||
AC_PATH_PROG([with_eeze_mount], [mount], [])
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED([EEZE_MOUNT_BIN], ["$with_eeze_mount"], [mount bin to use])
|
||||
|
||||
if test "x$with_eeze_umount" = "xdetect";then
|
||||
AC_PATH_PROG([with_eeze_umount], [umount], [])
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED([EEZE_UNMOUNT_BIN], ["$with_eeze_umount"], [umount bin to use])
|
||||
|
||||
if test "x$with_eeze_eject" = "xdetect";then
|
||||
AC_PATH_PROG([with_eeze_eject], [eject], [])
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED([EEZE_EJECT_BIN], ["$with_eeze_eject"], [eject bin to use])
|
||||
|
||||
EFL_LIB_END_OPTIONAL([Eeze])
|
||||
|
||||
AM_CONDITIONAL([EEZE_LIBMOUNT_AFTER_219],
|
||||
[test "x${have_libmount_new}" = "xyes"])
|
||||
AM_CONDITIONAL([EEZE_LIBMOUNT_BEFORE_219],
|
||||
[test "x${have_libmount_old}" = "xyes"])
|
||||
AM_CONDITIONAL([HAVE_EEZE_MOUNT], [test "x${have_eeze_mount}" = "xyes"])
|
||||
AM_CONDITIONAL([HAVE_EEZE_TIZEN], [test "x${want_tizen}" = "xyes"])
|
||||
#### End of Eeze
|
||||
|
||||
|
||||
#### Ecore_Evas
|
||||
EFL_LIB_START_OPTIONAL([Ecore_Evas], [test "x${build_gui}" = "xyes"])
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ typedef struct _Ecore_Drm_Output_Mode Ecore_Drm_Output_Mode;
|
|||
/* opaque structure to represent a drm output */
|
||||
typedef struct _Ecore_Drm_Output Ecore_Drm_Output;
|
||||
|
||||
/* opaque structure to represent a drm udev input */
|
||||
/* opaque structure to represent a drm input */
|
||||
typedef struct _Ecore_Drm_Input Ecore_Drm_Input;
|
||||
|
||||
/* opaque structure to represent a drm evdev input */
|
||||
|
|
|
@ -9,7 +9,6 @@ static int _ecore_drm_init_count = 0;
|
|||
static char *sid;
|
||||
|
||||
/* external variables */
|
||||
struct udev *udev;
|
||||
int _ecore_drm_log_dom = -1;
|
||||
|
||||
/**
|
||||
|
@ -72,13 +71,13 @@ ecore_drm_init(void)
|
|||
/* try to init dbus */
|
||||
if (!_ecore_drm_dbus_init(sid)) goto dbus_err;
|
||||
|
||||
/* try to init udev */
|
||||
if (!(udev = udev_new())) goto udev_err;
|
||||
/* try to init eeze */
|
||||
if (!eeze_init()) goto eeze_err;
|
||||
|
||||
/* return init count */
|
||||
return _ecore_drm_init_count;
|
||||
|
||||
udev_err:
|
||||
eeze_err:
|
||||
_ecore_drm_dbus_shutdown();
|
||||
dbus_err:
|
||||
free(sid);
|
||||
|
@ -106,8 +105,8 @@ ecore_drm_shutdown(void)
|
|||
/* if we are still in use, decrement init count and get out */
|
||||
if (--_ecore_drm_init_count != 0) return _ecore_drm_init_count;
|
||||
|
||||
/* close udev handle */
|
||||
if (udev) udev_unref(udev);
|
||||
/* close eeze */
|
||||
eeze_shutdown();
|
||||
|
||||
/* cleanup dbus */
|
||||
_ecore_drm_dbus_shutdown();
|
||||
|
|
|
@ -151,131 +151,84 @@ EAPI Ecore_Drm_Device *
|
|||
ecore_drm_device_find(const char *name, const char *seat)
|
||||
{
|
||||
Ecore_Drm_Device *dev = NULL;
|
||||
struct udev_enumerate *uenum;
|
||||
struct udev_list_entry *uentry;
|
||||
struct udev_device *udevice, *tmpdevice = NULL, *pcidevice;
|
||||
const char *path = NULL, *devseat = NULL;
|
||||
Eina_Bool found = EINA_FALSE;
|
||||
Eina_List *devs, *l;
|
||||
const char *device, *tmpdevice;
|
||||
|
||||
/* check for existing udev reference */
|
||||
if (!udev) return NULL;
|
||||
/* try to get a list of drm devics */
|
||||
if (!(devs = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRM, name)))
|
||||
return NULL;
|
||||
|
||||
/* setup udev enumerator */
|
||||
uenum = udev_enumerate_new(udev);
|
||||
udev_enumerate_add_match_subsystem(uenum, "drm");
|
||||
udev_enumerate_add_match_subsystem(uenum, "card[0-9]*");
|
||||
DBG("Find Drm Device: %s", name);
|
||||
|
||||
/* ask udev for list of drm devices */
|
||||
udev_enumerate_scan_devices(uenum);
|
||||
|
||||
/* loop list of returned devices */
|
||||
udev_list_entry_foreach(uentry, udev_enumerate_get_list_entry(uenum))
|
||||
EINA_LIST_FOREACH(devs, l, device)
|
||||
{
|
||||
/* get device path */
|
||||
path = udev_list_entry_get_name(uentry);
|
||||
const char *devpath;
|
||||
const char *devseat;
|
||||
const char *devparent;
|
||||
|
||||
/* get udev device */
|
||||
if (!(udevice = udev_device_new_from_syspath(udev, path)))
|
||||
if (!(devpath = eeze_udev_syspath_get_devpath(device)))
|
||||
continue;
|
||||
|
||||
/* if we are looking for a certain device, then compare names */
|
||||
if (name)
|
||||
{
|
||||
if (strcmp(name, udev_device_get_devnode(udevice)))
|
||||
{
|
||||
udev_device_unref(udevice);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
DBG("Found Drm Device");
|
||||
DBG("\tDevice: %s", device);
|
||||
DBG("\tDevpath: %s", devpath);
|
||||
|
||||
/* get this devices' seat */
|
||||
devseat = udev_device_get_property_value(udevice, "ID_SEAT");
|
||||
if (!devseat) devseat = "seat0";
|
||||
if ((name) && (strcmp(name, devpath))) goto cont;
|
||||
|
||||
/* if we are looking for a device on a certain seat, compare it */
|
||||
if (seat)
|
||||
{
|
||||
if (strcmp(seat, devseat))
|
||||
{
|
||||
udev_device_unref(udevice);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* no seat name passed to use. check default */
|
||||
if (strcmp(devseat, "seat0"))
|
||||
{
|
||||
udev_device_unref(udevice);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (!(devseat = eeze_udev_syspath_get_property(device, "ID_SEAT")))
|
||||
devseat = eina_stringshare_add("seat0");
|
||||
|
||||
/* try to find the boot_vga attribute */
|
||||
if ((pcidevice =
|
||||
udev_device_get_parent_with_subsystem_devtype(udevice, "pci", NULL)))
|
||||
if ((seat) && (strcmp(seat, devseat)))
|
||||
goto cont;
|
||||
else if (strcmp(devseat, "seat0"))
|
||||
goto cont;
|
||||
|
||||
devparent = eeze_udev_syspath_get_parent_filtered(device, "pci", NULL);
|
||||
if (devparent)
|
||||
{
|
||||
const char *id;
|
||||
|
||||
if ((id = udev_device_get_sysattr_value(pcidevice, "boot_vga")))
|
||||
if ((id = eeze_udev_syspath_get_sysattr(devparent, "boot_vga")))
|
||||
{
|
||||
if (!strcmp(id, "1"))
|
||||
{
|
||||
if (tmpdevice) udev_device_unref(tmpdevice);
|
||||
tmpdevice = udevice;
|
||||
break;
|
||||
}
|
||||
if (!strcmp(id, "1")) found = EINA_TRUE;
|
||||
eina_stringshare_del(id);
|
||||
}
|
||||
|
||||
eina_stringshare_del(devparent);
|
||||
}
|
||||
|
||||
if (!tmpdevice)
|
||||
tmpdevice = udevice;
|
||||
else
|
||||
udev_device_unref(udevice);
|
||||
}
|
||||
|
||||
/* destroy the enumerator */
|
||||
udev_enumerate_unref(uenum);
|
||||
|
||||
if (tmpdevice)
|
||||
{
|
||||
DBG("Found Drm Device");
|
||||
DBG("\tFilename: %s", udev_device_get_devnode(tmpdevice));
|
||||
DBG("\tDriver: %s", udev_device_get_driver(tmpdevice));
|
||||
DBG("\tDevpath: %s", udev_device_get_devpath(tmpdevice));
|
||||
DBG("\tSyspath: %s", udev_device_get_syspath(tmpdevice));
|
||||
DBG("\tSysname: %s", udev_device_get_sysname(tmpdevice));
|
||||
|
||||
/* try to allocate space for return device structure */
|
||||
if ((dev = calloc(1, sizeof(Ecore_Drm_Device))))
|
||||
cont:
|
||||
eina_stringshare_del(devpath);
|
||||
if (found)
|
||||
{
|
||||
const char *id, *seat_id;
|
||||
|
||||
/* set device name */
|
||||
dev->drm.name =
|
||||
eina_stringshare_add(udev_device_get_devnode(tmpdevice));
|
||||
|
||||
/* set device path */
|
||||
dev->drm.path =
|
||||
eina_stringshare_add(udev_device_get_syspath(tmpdevice));
|
||||
|
||||
/* store id for this device */
|
||||
if ((id = udev_device_get_sysnum(tmpdevice)))
|
||||
dev->id = atoi(id);
|
||||
|
||||
/* set dev seat_id */
|
||||
seat_id = udev_device_get_property_value(tmpdevice, "ID_SEAT");
|
||||
if (!seat_id) seat_id = "seat0";
|
||||
|
||||
dev->seat = eina_stringshare_add(seat_id);
|
||||
|
||||
/* dev->format = GBM_FORMAT_XRGB8888; */
|
||||
dev->format = 0;
|
||||
dev->use_hw_accel = EINA_FALSE;
|
||||
tmpdevice = eina_stringshare_add(device);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* release device reference */
|
||||
udev_device_unref(tmpdevice);
|
||||
EINA_LIST_FREE(devs, device)
|
||||
eina_stringshare_del(device);
|
||||
|
||||
if (!found) return NULL;
|
||||
|
||||
if ((dev = calloc(1, sizeof(Ecore_Drm_Device))))
|
||||
{
|
||||
dev->drm.name = eeze_udev_syspath_get_devpath(tmpdevice);
|
||||
dev->drm.path = eina_stringshare_add(tmpdevice);
|
||||
|
||||
dev->id = eeze_udev_syspath_get_sysnum(tmpdevice);
|
||||
|
||||
dev->seat = eeze_udev_syspath_get_property(tmpdevice, "ID_SEAT");
|
||||
if (!dev->seat) dev->seat = eina_stringshare_add("seat0");
|
||||
|
||||
dev->format = 0;
|
||||
dev->use_hw_accel = EINA_FALSE;
|
||||
|
||||
DBG("Using Drm Device: %s", dev->drm.name);
|
||||
}
|
||||
|
||||
eina_stringshare_del(tmpdevice);
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ _cb_device_opened(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending
|
|||
|
||||
if (!(d = data)) return;
|
||||
|
||||
DBG("Device Opened: %s", d->node);
|
||||
/* DBG("Input Device Opened: %s", d->node); */
|
||||
|
||||
/* DBUS_TYPE_UNIX_FD == 'h' */
|
||||
if (!eldbus_message_arguments_get(msg, "hb", &fd, &b))
|
||||
|
@ -142,37 +142,43 @@ _seat_get(Ecore_Drm_Input *input, const char *seat)
|
|||
}
|
||||
|
||||
static Eina_Bool
|
||||
_device_add(Ecore_Drm_Input *input, struct udev_device *device)
|
||||
_device_add(Ecore_Drm_Input *input, const char *device)
|
||||
{
|
||||
Ecore_Drm_Device_Open_Data *data;
|
||||
Ecore_Drm_Seat *seat;
|
||||
const char *dev_seat, *wl_seat;
|
||||
const char *node;
|
||||
char n[PATH_MAX];
|
||||
Ecore_Drm_Device_Open_Data *data;
|
||||
const char *devseat, *wlseat;
|
||||
|
||||
if (!(dev_seat = udev_device_get_property_value(device, "ID_SEAT")))
|
||||
dev_seat = "seat0";
|
||||
DBG("Add Input Device: %s", device);
|
||||
|
||||
if (strcmp(dev_seat, input->seat)) return EINA_FALSE;
|
||||
if (!(devseat = eeze_udev_syspath_get_property(device, "ID_SEAT")))
|
||||
devseat = eina_stringshare_add("seat0");
|
||||
|
||||
if (!(wl_seat = udev_device_get_property_value(device, "WL_SEAT")))
|
||||
wl_seat = "seat0";
|
||||
if (strcmp(devseat, input->seat)) goto seat_err;
|
||||
|
||||
if (!(seat = _seat_get(input, wl_seat)))
|
||||
return EINA_FALSE;
|
||||
if (!(wlseat = eeze_udev_syspath_get_property(device, "WL_SEAT")))
|
||||
wlseat = eina_stringshare_add("seat0");
|
||||
|
||||
node = udev_device_get_devnode(device);
|
||||
strcpy(n, node);
|
||||
if (!(seat = _seat_get(input, wlseat)))
|
||||
{
|
||||
ERR("\tCould not get matching seat");
|
||||
goto seat_get_err;
|
||||
}
|
||||
|
||||
if (!(data = calloc(1, sizeof(Ecore_Drm_Device_Open_Data))))
|
||||
return EINA_FALSE;
|
||||
goto seat_get_err;
|
||||
|
||||
data->seat = seat;
|
||||
data->node = eina_stringshare_add(n);
|
||||
data->node = eeze_udev_syspath_get_devpath(device);
|
||||
|
||||
_ecore_drm_dbus_device_open(n, _cb_device_opened, data);
|
||||
_ecore_drm_dbus_device_open(data->node, _cb_device_opened, data);
|
||||
|
||||
return EINA_TRUE;
|
||||
|
||||
seat_get_err:
|
||||
eina_stringshare_del(wlseat);
|
||||
seat_err:
|
||||
eina_stringshare_del(devseat);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -200,79 +206,61 @@ _device_remove(Ecore_Drm_Input *input, const char *device)
|
|||
}
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_cb_input_event(void *data, Ecore_Fd_Handler *hdlr EINA_UNUSED)
|
||||
static void
|
||||
_cb_input_event(const char *device, Eeze_Udev_Event event, void *data, Eeze_Udev_Watch *watch EINA_UNUSED)
|
||||
{
|
||||
Ecore_Drm_Input *input;
|
||||
struct udev_device *udevice;
|
||||
const char *act;
|
||||
|
||||
if (!(input = data)) return EINA_FALSE;
|
||||
if (!(input = data)) return;
|
||||
|
||||
if (!(udevice = udev_monitor_receive_device(input->monitor)))
|
||||
return EINA_TRUE;
|
||||
|
||||
if (!(act = udev_device_get_action(udevice))) return EINA_TRUE;
|
||||
|
||||
if (strncmp("event", udev_device_get_sysname(udevice), 5) != 0)
|
||||
goto err;
|
||||
|
||||
if (!strcmp(act, "add"))
|
||||
_device_add(input, udevice);
|
||||
else if (!strcmp(act, "remove"))
|
||||
switch (event)
|
||||
{
|
||||
const char *node;
|
||||
case EEZE_UDEV_EVENT_ADD:
|
||||
_device_add(input, device);
|
||||
break;
|
||||
case EEZE_UDEV_EVENT_REMOVE:
|
||||
{
|
||||
const char *node;
|
||||
|
||||
node = udev_device_get_devnode(udevice);
|
||||
|
||||
_device_remove(input, node);
|
||||
node = eeze_udev_syspath_get_devpath(device);
|
||||
_device_remove(input, node);
|
||||
eina_stringshare_del(node);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return EINA_TRUE;
|
||||
|
||||
err:
|
||||
if (udevice) udev_device_unref(udevice);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_devices_add(Ecore_Drm_Input *input)
|
||||
{
|
||||
struct udev_enumerate *uenum;
|
||||
struct udev_list_entry *uentry;
|
||||
struct udev_device *udevice;
|
||||
const char *path, *name;
|
||||
Eina_List *devices;
|
||||
Eina_Bool found = EINA_FALSE;
|
||||
const char *device;
|
||||
|
||||
uenum = udev_enumerate_new(udev);
|
||||
udev_enumerate_add_match_subsystem(uenum, "input");
|
||||
udev_enumerate_scan_devices(uenum);
|
||||
|
||||
udev_list_entry_foreach(uentry, udev_enumerate_get_list_entry(uenum))
|
||||
/* NB: This really sucks !! We cannot 'OR' diferent device types
|
||||
* together for eeze_udev_find_by_type
|
||||
*
|
||||
* For now, just find by 'NONE" and we'll filter for input devices by
|
||||
* running tests */
|
||||
devices = eeze_udev_find_by_type(EEZE_UDEV_TYPE_NONE, NULL);
|
||||
EINA_LIST_FREE(devices, device)
|
||||
{
|
||||
path = udev_list_entry_get_name(uentry);
|
||||
udevice = udev_device_new_from_syspath(udev, path);
|
||||
name = udev_device_get_sysname(udevice);
|
||||
|
||||
if (strncmp("event", name, 5) != 0)
|
||||
if ((eeze_udev_syspath_is_mouse(device)) ||
|
||||
(eeze_udev_syspath_is_kbd(device)) ||
|
||||
(eeze_udev_syspath_is_touchpad(device)) ||
|
||||
(eeze_udev_syspath_is_joystick(device)))
|
||||
{
|
||||
udev_device_unref(udevice);
|
||||
continue;
|
||||
if (!_device_add(input, device))
|
||||
ERR("\tFailed to add device");
|
||||
else
|
||||
found = EINA_TRUE;
|
||||
}
|
||||
|
||||
if (!_device_add(input, udevice))
|
||||
{
|
||||
udev_device_unref(udevice);
|
||||
continue;
|
||||
}
|
||||
|
||||
found = EINA_TRUE;
|
||||
|
||||
udev_device_unref(udevice);
|
||||
eina_stringshare_del(device);
|
||||
}
|
||||
|
||||
udev_enumerate_unref(uenum);
|
||||
|
||||
if (!found)
|
||||
{
|
||||
ERR("No Input Devices Found");
|
||||
|
@ -289,7 +277,7 @@ ecore_drm_inputs_create(Ecore_Drm_Device *dev)
|
|||
Ecore_Drm_Input *input;
|
||||
|
||||
/* check for valid device */
|
||||
if ((!dev) || (!udev)) return EINA_FALSE;
|
||||
if (!dev) return EINA_FALSE;
|
||||
|
||||
/* try to allocate space for input structure */
|
||||
if (!(input = calloc(1, sizeof(Ecore_Drm_Input))))
|
||||
|
@ -340,55 +328,31 @@ ecore_drm_inputs_enable(Ecore_Drm_Input *input)
|
|||
/* check for valid input */
|
||||
if (!input) return EINA_FALSE;
|
||||
|
||||
if (!input->monitor)
|
||||
input->monitor = udev_monitor_new_from_netlink(udev, "udev");
|
||||
|
||||
if (!input->monitor)
|
||||
if (!input->watch)
|
||||
{
|
||||
ERR("Could not create udev monitor: %m");
|
||||
return EINA_FALSE;
|
||||
}
|
||||
int events = 0;
|
||||
|
||||
/* setup input filter */
|
||||
udev_monitor_filter_add_match_subsystem_devtype(input->monitor,
|
||||
"input", NULL);
|
||||
|
||||
/* try to enable receiving udev events */
|
||||
if (udev_monitor_enable_receiving(input->monitor))
|
||||
{
|
||||
ERR("Could not bind udev monitor: %m");
|
||||
udev_monitor_unref(input->monitor);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
/* save the fd */
|
||||
if ((input->fd = udev_monitor_get_fd(input->monitor)) < 0)
|
||||
{
|
||||
ERR("Input monitor has no fd: %m");
|
||||
udev_monitor_unref(input->monitor);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
/* create fd handler */
|
||||
if (!input->hdlr)
|
||||
{
|
||||
input->hdlr =
|
||||
ecore_main_fd_handler_add(input->fd, ECORE_FD_READ,
|
||||
_cb_input_event, input, NULL, NULL);
|
||||
}
|
||||
|
||||
if (!input->hdlr)
|
||||
{
|
||||
ERR("Failed to setup input fd handler: %m");
|
||||
udev_monitor_unref(input->monitor);
|
||||
return EINA_FALSE;
|
||||
events = (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE);
|
||||
/* NB: This really sucks !! We cannot 'OR' diferent device types
|
||||
* together for eeze_udev_watch_add :(
|
||||
*
|
||||
* For now, just put a 'watch' on mouse type as this (in effect) does
|
||||
* what we need by internally by adding a subsystem match for 'input' */
|
||||
if (!(input->watch =
|
||||
eeze_udev_watch_add(EEZE_UDEV_TYPE_MOUSE, events,
|
||||
_cb_input_event, input)))
|
||||
{
|
||||
ERR("Could not create Eeze_Udev_Watch for input");
|
||||
return EINA_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* try to add devices */
|
||||
if (!_devices_add(input))
|
||||
{
|
||||
ERR("Could not add input devices");
|
||||
udev_monitor_unref(input->monitor);
|
||||
eeze_udev_watch_del(input->watch);
|
||||
input->watch = NULL;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
|
@ -403,13 +367,11 @@ ecore_drm_inputs_disable(Ecore_Drm_Input *input)
|
|||
{
|
||||
if (!input) return;
|
||||
|
||||
if (input->monitor) udev_monitor_unref(input->monitor);
|
||||
input->monitor = NULL;
|
||||
|
||||
if (input->hdlr) ecore_main_fd_handler_del(input->hdlr);
|
||||
input->hdlr = NULL;
|
||||
if (input->watch) eeze_udev_watch_del(input->watch);
|
||||
input->watch = NULL;
|
||||
|
||||
input->enabled = EINA_FALSE;
|
||||
input->suspended = EINA_TRUE;
|
||||
|
||||
ecore_drm_inputs_destroy(input->dev);
|
||||
}
|
||||
|
|
|
@ -291,69 +291,63 @@ _ecore_drm_output_mode_add(Ecore_Drm_Output *output, drmModeModeInfo *info)
|
|||
}
|
||||
|
||||
static Ecore_Drm_Backlight *
|
||||
_ecore_drm_backlight_init(Ecore_Drm_Device *dev, uint32_t conn_type)
|
||||
_ecore_drm_backlight_init(Ecore_Drm_Device *dev EINA_UNUSED, uint32_t conn_type)
|
||||
{
|
||||
Ecore_Drm_Backlight *backlight = NULL;
|
||||
Ecore_Drm_Backlight_Type type = 0;
|
||||
struct udev_enumerate *enumerate;
|
||||
struct udev_device *device;
|
||||
struct udev_list_entry *item, *first;
|
||||
const char *dev_type, *backlight_path;
|
||||
int ret;
|
||||
Eina_List *devs, *l;
|
||||
Eina_Bool found = EINA_FALSE;
|
||||
const char *device, *devtype, *tmpdevice;
|
||||
|
||||
enumerate = udev_enumerate_new(udev);
|
||||
if (!enumerate) return NULL;
|
||||
if (!(devs = eeze_udev_find_by_type(EEZE_UDEV_TYPE_BACKLIGHT, NULL)))
|
||||
devs = eeze_udev_find_by_type(EEZE_UDEV_TYPE_LEDS, NULL);
|
||||
|
||||
udev_enumerate_add_match_subsystem(enumerate, "backlight");
|
||||
ret = udev_enumerate_scan_devices(enumerate);
|
||||
if (ret < 0)
|
||||
if (!devs) return NULL;
|
||||
|
||||
EINA_LIST_FOREACH(devs, l, device)
|
||||
{
|
||||
udev_enumerate_add_match_subsystem(enumerate, "leds");
|
||||
ret = udev_enumerate_scan_devices(enumerate);
|
||||
if (ret < 0)
|
||||
{
|
||||
udev_enumerate_unref(enumerate);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (!(devtype = eeze_udev_syspath_get_sysattr(device, "type")))
|
||||
continue;
|
||||
|
||||
first = udev_enumerate_get_list_entry(enumerate);
|
||||
udev_list_entry_foreach(item, first)
|
||||
{
|
||||
backlight_path = udev_list_entry_get_name(item);
|
||||
device = udev_device_new_from_syspath(udev, backlight_path);
|
||||
|
||||
dev_type = udev_device_get_sysattr_value(device, "type");
|
||||
if (!dev_type)
|
||||
{
|
||||
udev_device_unref(device);
|
||||
udev_enumerate_unref(enumerate);
|
||||
return NULL;
|
||||
}
|
||||
if (!strcmp(dev_type, "raw"))
|
||||
if (!strcmp(devtype, "raw"))
|
||||
type = ECORE_DRM_BACKLIGHT_RAW;
|
||||
else if (!strcmp(dev_type, "platform"))
|
||||
else if (!strcmp(devtype, "platform"))
|
||||
type = ECORE_DRM_BACKLIGHT_PLATFORM;
|
||||
else if (!strcmp(dev_type, "firmware"))
|
||||
else if (!strcmp(devtype, "firmware"))
|
||||
type = ECORE_DRM_BACKLIGHT_FIRMWARE;
|
||||
|
||||
if (conn_type != DRM_MODE_CONNECTOR_LVDS &&
|
||||
conn_type != DRM_MODE_CONNECTOR_eDP)
|
||||
if ((conn_type != DRM_MODE_CONNECTOR_LVDS) &&
|
||||
(conn_type != DRM_MODE_CONNECTOR_eDP))
|
||||
{
|
||||
if (type != ECORE_DRM_BACKLIGHT_RAW)
|
||||
{
|
||||
udev_device_unref(device);
|
||||
udev_enumerate_unref(enumerate);
|
||||
return NULL;
|
||||
}
|
||||
if (type != ECORE_DRM_BACKLIGHT_RAW) goto cont;
|
||||
}
|
||||
udev_device_unref(device);
|
||||
}
|
||||
udev_enumerate_unref(enumerate);
|
||||
|
||||
backlight = (Ecore_Drm_Backlight *)malloc(sizeof(Ecore_Drm_Backlight));
|
||||
backlight->type = type;
|
||||
backlight->dir_path = eina_stringshare_add(backlight_path);
|
||||
found = EINA_TRUE;
|
||||
cont:
|
||||
eina_stringshare_del(devtype);
|
||||
if (found)
|
||||
{
|
||||
tmpdevice = eina_stringshare_add(device);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
EINA_LIST_FREE(devs, device)
|
||||
eina_stringshare_del(device);
|
||||
|
||||
if (!found) return NULL;
|
||||
|
||||
if ((backlight = calloc(1, sizeof(Ecore_Drm_Backlight))))
|
||||
{
|
||||
backlight->type = type;
|
||||
/* NB: This sets backlight directory path to /dev/...
|
||||
* Am not sure yet if this is the desired path, or if we want the
|
||||
* actual /sys path. If we want Just the syspath then 'tmpdevice' is
|
||||
* already equal to that */
|
||||
backlight->dir_path = eeze_udev_syspath_get_devpath(tmpdevice);
|
||||
}
|
||||
|
||||
eina_stringshare_del(tmpdevice);
|
||||
|
||||
return backlight;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
# include <sys/stat.h>
|
||||
# include <sys/ioctl.h>
|
||||
|
||||
# include <libudev.h>
|
||||
# include <linux/input.h>
|
||||
//# include <libinput.h>
|
||||
# include <systemd/sd-login.h>
|
||||
|
@ -37,6 +36,7 @@
|
|||
/* # include <GLES2/gl2ext.h> */
|
||||
/* # endif */
|
||||
|
||||
# include <Eeze.h>
|
||||
# include <Eldbus.h>
|
||||
# include <Ecore_Drm.h>
|
||||
|
||||
|
@ -86,8 +86,6 @@ extern int _ecore_drm_log_dom;
|
|||
#define WRN(...) EINA_LOG_DOM_WARN(_ecore_drm_log_dom, __VA_ARGS__)
|
||||
#define CRIT(...) EINA_LOG_DOM_CRIT(_ecore_drm_log_dom, __VA_ARGS__)
|
||||
|
||||
extern struct udev *udev;
|
||||
|
||||
struct _Ecore_Drm_Output_Mode
|
||||
{
|
||||
unsigned int flags;
|
||||
|
@ -161,7 +159,7 @@ struct _Ecore_Drm_Input
|
|||
{
|
||||
int fd;
|
||||
const char *seat;
|
||||
struct udev_monitor *monitor;
|
||||
Eeze_Udev_Watch *watch;
|
||||
Ecore_Fd_Handler *hdlr;
|
||||
Ecore_Drm_Device *dev;
|
||||
|
||||
|
|
Loading…
Reference in New Issue