forked from enlightenment/efl
Merge branch 'devs/devilhorns/ecore_drm'
ecore-drm: Merge rewrite of ecore-drm input/dbus handling to use Eldbus library. Previous ecore-drm code relied on dbus itself. This changes the code (internally) to rely on Eldbus library and thus makes ecore-drm input handling asynchronous. @fix
This commit is contained in:
commit
9d50d23e12
77
configure.ac
77
configure.ac
|
@ -2861,6 +2861,44 @@ EFL_EVAL_PKGS([ECORE_WAYLAND])
|
||||||
EFL_LIB_END_OPTIONAL([Ecore_Wayland])
|
EFL_LIB_END_OPTIONAL([Ecore_Wayland])
|
||||||
#### End of Ecore_Wayland
|
#### End of Ecore_Wayland
|
||||||
|
|
||||||
|
|
||||||
|
#### Eldbus
|
||||||
|
EFL_LIB_START([Eldbus])
|
||||||
|
|
||||||
|
### Additional options to configure
|
||||||
|
|
||||||
|
### Default values
|
||||||
|
|
||||||
|
### Checks for programs
|
||||||
|
|
||||||
|
## Compatibility layers
|
||||||
|
EFL_PLATFORM_DEPEND([ELDBUS], [evil])
|
||||||
|
|
||||||
|
### Checks for libraries
|
||||||
|
EFL_INTERNAL_DEPEND_PKG([ELDBUS], [ecore])
|
||||||
|
EFL_INTERNAL_DEPEND_PKG([ELDBUS], [eo])
|
||||||
|
EFL_INTERNAL_DEPEND_PKG([ELDBUS], [eina])
|
||||||
|
|
||||||
|
EFL_DEPEND_PKG([ELDBUS], [DBUS], [dbus-1])
|
||||||
|
|
||||||
|
EFL_EVAL_PKGS([ELDBUS])
|
||||||
|
|
||||||
|
### Checks for header files
|
||||||
|
|
||||||
|
### Checks for types
|
||||||
|
|
||||||
|
### Checks for structures
|
||||||
|
|
||||||
|
### Checks for compiler characteristics
|
||||||
|
|
||||||
|
### Checks for linker characteristics
|
||||||
|
|
||||||
|
### Checks for library functions
|
||||||
|
|
||||||
|
EFL_LIB_END([Eldbus])
|
||||||
|
#### End of Eldbus
|
||||||
|
|
||||||
|
|
||||||
#### Ecore_Drm
|
#### Ecore_Drm
|
||||||
EFL_LIB_START_OPTIONAL([Ecore_Drm], [test "${want_drm}" = "yes"])
|
EFL_LIB_START_OPTIONAL([Ecore_Drm], [test "${want_drm}" = "yes"])
|
||||||
|
|
||||||
|
@ -2877,10 +2915,11 @@ AC_SUBST([SUID_LDFLAGS])
|
||||||
### Checks for libraries
|
### Checks for libraries
|
||||||
EFL_INTERNAL_DEPEND_PKG([ECORE_DRM], [ecore])
|
EFL_INTERNAL_DEPEND_PKG([ECORE_DRM], [ecore])
|
||||||
EFL_INTERNAL_DEPEND_PKG([ECORE_DRM], [ecore-input])
|
EFL_INTERNAL_DEPEND_PKG([ECORE_DRM], [ecore-input])
|
||||||
|
EFL_INTERNAL_DEPEND_PKG([ECORE_DRM], [eldbus])
|
||||||
EFL_INTERNAL_DEPEND_PKG([ECORE_DRM], [eo])
|
EFL_INTERNAL_DEPEND_PKG([ECORE_DRM], [eo])
|
||||||
EFL_INTERNAL_DEPEND_PKG([ECORE_DRM], [eina])
|
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 dbus-1 gbm])
|
EFL_DEPEND_PKG([ECORE_DRM], [DRM], [libudev >= 148 libdrm >= 2.4 xkbcommon >= 0.3.0 libsystemd-login >= 192 gbm])
|
||||||
|
|
||||||
EFL_EVAL_PKGS([ECORE_DRM])
|
EFL_EVAL_PKGS([ECORE_DRM])
|
||||||
|
|
||||||
|
@ -3881,42 +3920,6 @@ if test "x${want_eo_id}" = "xyes" ; then
|
||||||
AC_DEFINE([HAVE_EO_ID], [1], [Have eo id])
|
AC_DEFINE([HAVE_EO_ID], [1], [Have eo id])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#### Eldbus
|
|
||||||
EFL_LIB_START([Eldbus])
|
|
||||||
|
|
||||||
### Additional options to configure
|
|
||||||
|
|
||||||
### Default values
|
|
||||||
|
|
||||||
### Checks for programs
|
|
||||||
|
|
||||||
## Compatibility layers
|
|
||||||
EFL_PLATFORM_DEPEND([ELDBUS], [evil])
|
|
||||||
|
|
||||||
### Checks for libraries
|
|
||||||
EFL_INTERNAL_DEPEND_PKG([ELDBUS], [ecore])
|
|
||||||
EFL_INTERNAL_DEPEND_PKG([ELDBUS], [eo])
|
|
||||||
EFL_INTERNAL_DEPEND_PKG([ELDBUS], [eina])
|
|
||||||
|
|
||||||
EFL_DEPEND_PKG([ELDBUS], [DBUS], [dbus-1])
|
|
||||||
|
|
||||||
EFL_EVAL_PKGS([ELDBUS])
|
|
||||||
|
|
||||||
### Checks for header files
|
|
||||||
|
|
||||||
### Checks for types
|
|
||||||
|
|
||||||
### Checks for structures
|
|
||||||
|
|
||||||
### Checks for compiler characteristics
|
|
||||||
|
|
||||||
### Checks for linker characteristics
|
|
||||||
|
|
||||||
### Checks for library functions
|
|
||||||
|
|
||||||
EFL_LIB_END([Eldbus])
|
|
||||||
#### End of Eldbus
|
|
||||||
|
|
||||||
|
|
||||||
#### Efreet
|
#### Efreet
|
||||||
EFL_LIB_START([Efreet])
|
EFL_LIB_START([Efreet])
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -70,7 +70,7 @@ _device_configure(Ecore_Drm_Evdev *edev)
|
||||||
if ((edev->caps & (EVDEV_MOTION_ABS | EVDEV_MOTION_REL)) &&
|
if ((edev->caps & (EVDEV_MOTION_ABS | EVDEV_MOTION_REL)) &&
|
||||||
(edev->caps & EVDEV_BUTTON))
|
(edev->caps & EVDEV_BUTTON))
|
||||||
{
|
{
|
||||||
DBG("Input device %s is a pointer", edev->name);
|
DBG("\tInput device %s is a pointer", edev->name);
|
||||||
edev->seat_caps |= EVDEV_SEAT_POINTER;
|
edev->seat_caps |= EVDEV_SEAT_POINTER;
|
||||||
|
|
||||||
/* FIXME: make this configurable */
|
/* FIXME: make this configurable */
|
||||||
|
@ -81,7 +81,7 @@ _device_configure(Ecore_Drm_Evdev *edev)
|
||||||
|
|
||||||
if (edev->caps & EVDEV_KEYBOARD)
|
if (edev->caps & EVDEV_KEYBOARD)
|
||||||
{
|
{
|
||||||
DBG("Input device %s is a keyboard", edev->name);
|
DBG("\tInput device %s is a keyboard", edev->name);
|
||||||
edev->seat_caps |= EVDEV_SEAT_KEYBOARD;
|
edev->seat_caps |= EVDEV_SEAT_KEYBOARD;
|
||||||
_device_keyboard_setup(edev);
|
_device_keyboard_setup(edev);
|
||||||
ret = EINA_TRUE;
|
ret = EINA_TRUE;
|
||||||
|
@ -89,7 +89,7 @@ _device_configure(Ecore_Drm_Evdev *edev)
|
||||||
|
|
||||||
if (edev->caps & EVDEV_TOUCH)
|
if (edev->caps & EVDEV_TOUCH)
|
||||||
{
|
{
|
||||||
DBG("Input device %s is a touchpad", edev->name);
|
DBG("\tInput device %s is a touchpad", edev->name);
|
||||||
edev->seat_caps |= EVDEV_SEAT_TOUCH;
|
edev->seat_caps |= EVDEV_SEAT_TOUCH;
|
||||||
ret = EINA_TRUE;
|
ret = EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
@ -786,7 +786,7 @@ _ecore_drm_evdev_device_create(Ecore_Drm_Seat *seat, const char *path, int fd)
|
||||||
|
|
||||||
if (!_device_configure(edev))
|
if (!_device_configure(edev))
|
||||||
{
|
{
|
||||||
ERR("Could not configure input device: %s", name);
|
ERR("\tCould not configure input device: %s", name);
|
||||||
_ecore_drm_evdev_device_destroy(edev);
|
_ecore_drm_evdev_device_destroy(edev);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -798,7 +798,7 @@ _ecore_drm_evdev_device_create(Ecore_Drm_Seat *seat, const char *path, int fd)
|
||||||
_cb_device_data, edev, NULL, NULL);
|
_cb_device_data, edev, NULL, NULL);
|
||||||
if (!edev->hdlr)
|
if (!edev->hdlr)
|
||||||
{
|
{
|
||||||
ERR("Could not create fd handler");
|
ERR("\tCould not create fd handler");
|
||||||
_ecore_drm_evdev_device_destroy(edev);
|
_ecore_drm_evdev_device_destroy(edev);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,121 @@
|
||||||
|
|
||||||
#include "ecore_drm_private.h"
|
#include "ecore_drm_private.h"
|
||||||
|
|
||||||
|
typedef struct _Ecore_Drm_Device_Open_Data Ecore_Drm_Device_Open_Data;
|
||||||
|
struct _Ecore_Drm_Device_Open_Data
|
||||||
|
{
|
||||||
|
Ecore_Drm_Seat *seat;
|
||||||
|
const char *node;
|
||||||
|
};
|
||||||
|
|
||||||
/* local functions */
|
/* local functions */
|
||||||
|
static int
|
||||||
|
_device_flags_set(int fd)
|
||||||
|
{
|
||||||
|
int ret, fl;
|
||||||
|
/* char name[256] = "unknown"; */
|
||||||
|
|
||||||
|
if (fd < 0)
|
||||||
|
{
|
||||||
|
ERR("Failed to take device");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((fl = fcntl(fd, F_GETFL)) < 0)
|
||||||
|
{
|
||||||
|
ERR("Failed to get file flags: %m");
|
||||||
|
goto flag_err;
|
||||||
|
}
|
||||||
|
|
||||||
|
fl = (O_RDWR | O_NONBLOCK);
|
||||||
|
|
||||||
|
if ((ret = fcntl(fd, F_SETFL, fl)) < 0)
|
||||||
|
{
|
||||||
|
ERR("Failed to set file flags: %m");
|
||||||
|
goto flag_err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((fl = fcntl(fd, F_GETFD)) < 0)
|
||||||
|
{
|
||||||
|
ERR("Failed to get file fd: %m");
|
||||||
|
goto flag_err;
|
||||||
|
}
|
||||||
|
|
||||||
|
fl &= ~FD_CLOEXEC;
|
||||||
|
|
||||||
|
if ((ret = fcntl(fd, F_SETFD, fl)) < 0)
|
||||||
|
{
|
||||||
|
ERR("Failed to set file fds: %m");
|
||||||
|
goto flag_err;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* if (ioctl(fd, EVIOCGNAME(sizeof(name)), name) < 0) */
|
||||||
|
/* { */
|
||||||
|
/* ERR("Could not get device name: %m"); */
|
||||||
|
/* goto flag_err; */
|
||||||
|
/* } */
|
||||||
|
/* else */
|
||||||
|
/* { */
|
||||||
|
/* name[sizeof(name) - 1] = '\0'; */
|
||||||
|
/* DBG("%s Opened", name); */
|
||||||
|
/* } */
|
||||||
|
|
||||||
|
return fd;
|
||||||
|
|
||||||
|
flag_err:
|
||||||
|
close(fd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_cb_device_opened(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED)
|
||||||
|
{
|
||||||
|
Ecore_Drm_Device_Open_Data *d;
|
||||||
|
Ecore_Drm_Evdev *edev;
|
||||||
|
Eina_Bool b = EINA_FALSE;
|
||||||
|
const char *errname, *errmsg;
|
||||||
|
int fd = -1;
|
||||||
|
|
||||||
|
if (eldbus_message_error_get(msg, &errname, &errmsg))
|
||||||
|
{
|
||||||
|
ERR("Eldbus Message Error: %s %s", errname, errmsg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(d = data)) return;
|
||||||
|
|
||||||
|
DBG("Device Opened: %s", d->node);
|
||||||
|
|
||||||
|
/* DBUS_TYPE_UNIX_FD == 'h' */
|
||||||
|
if (!eldbus_message_arguments_get(msg, "hb", &fd, &b))
|
||||||
|
{
|
||||||
|
ERR("\tCould not get UNIX_FD from eldbus message: %d %d", fd, b);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(fd = _device_flags_set(fd)))
|
||||||
|
{
|
||||||
|
ERR("\tCould not set fd flags");
|
||||||
|
goto release;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(edev = _ecore_drm_evdev_device_create(d->seat, d->node, fd)))
|
||||||
|
{
|
||||||
|
ERR("\tCould not create evdev device: %s", d->node);
|
||||||
|
goto release;
|
||||||
|
}
|
||||||
|
|
||||||
|
d->seat->devices = eina_list_append(d->seat->devices, edev);
|
||||||
|
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
release:
|
||||||
|
_ecore_drm_dbus_device_close(d->node);
|
||||||
|
cleanup:
|
||||||
|
eina_stringshare_del(d->node);
|
||||||
|
free(d);
|
||||||
|
}
|
||||||
|
|
||||||
static Ecore_Drm_Seat *
|
static Ecore_Drm_Seat *
|
||||||
_seat_get(Ecore_Drm_Input *input, const char *seat)
|
_seat_get(Ecore_Drm_Input *input, const char *seat)
|
||||||
{
|
{
|
||||||
|
@ -30,12 +144,11 @@ _seat_get(Ecore_Drm_Input *input, const char *seat)
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_device_add(Ecore_Drm_Input *input, struct udev_device *device)
|
_device_add(Ecore_Drm_Input *input, struct udev_device *device)
|
||||||
{
|
{
|
||||||
Ecore_Drm_Evdev *edev;
|
Ecore_Drm_Device_Open_Data *data;
|
||||||
Ecore_Drm_Seat *seat;
|
Ecore_Drm_Seat *seat;
|
||||||
const char *dev_seat, *wl_seat;
|
const char *dev_seat, *wl_seat;
|
||||||
const char *node;
|
const char *node;
|
||||||
char n[PATH_MAX];
|
char n[PATH_MAX];
|
||||||
int fd = -1;
|
|
||||||
|
|
||||||
if (!(dev_seat = udev_device_get_property_value(device, "ID_SEAT")))
|
if (!(dev_seat = udev_device_get_property_value(device, "ID_SEAT")))
|
||||||
dev_seat = "seat0";
|
dev_seat = "seat0";
|
||||||
|
@ -51,25 +164,13 @@ _device_add(Ecore_Drm_Input *input, struct udev_device *device)
|
||||||
node = udev_device_get_devnode(device);
|
node = udev_device_get_devnode(device);
|
||||||
strcpy(n, node);
|
strcpy(n, node);
|
||||||
|
|
||||||
fd = _ecore_drm_dbus_device_open(n);
|
if (!(data = calloc(1, sizeof(Ecore_Drm_Device_Open_Data))))
|
||||||
if (fd < 0)
|
|
||||||
{
|
|
||||||
ERR("FAILED TO OPEN %s: %m", n);
|
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
/* DBG("Opened Restricted Input: %s %d", node, fd); */
|
data->seat = seat;
|
||||||
|
data->node = eina_stringshare_add(n);
|
||||||
|
|
||||||
if (!(edev = _ecore_drm_evdev_device_create(seat, node, fd)))
|
_ecore_drm_dbus_device_open(n, _cb_device_opened, data);
|
||||||
{
|
|
||||||
ERR("Could not create evdev device: %s", node);
|
|
||||||
close(fd);
|
|
||||||
return EINA_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
seat->devices = eina_list_append(seat->devices, edev);
|
|
||||||
|
|
||||||
/* TODO: finish */
|
|
||||||
|
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
@ -106,8 +207,6 @@ _cb_input_event(void *data, Ecore_Fd_Handler *hdlr EINA_UNUSED)
|
||||||
struct udev_device *udevice;
|
struct udev_device *udevice;
|
||||||
const char *act;
|
const char *act;
|
||||||
|
|
||||||
DBG("Input Event");
|
|
||||||
|
|
||||||
if (!(input = data)) return EINA_FALSE;
|
if (!(input = data)) return EINA_FALSE;
|
||||||
|
|
||||||
if (!(udevice = udev_monitor_receive_device(input->monitor)))
|
if (!(udevice = udev_monitor_receive_device(input->monitor)))
|
||||||
|
@ -119,17 +218,13 @@ _cb_input_event(void *data, Ecore_Fd_Handler *hdlr EINA_UNUSED)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
if (!strcmp(act, "add"))
|
if (!strcmp(act, "add"))
|
||||||
{
|
|
||||||
DBG("\tDevice Added");
|
|
||||||
_device_add(input, udevice);
|
_device_add(input, udevice);
|
||||||
}
|
|
||||||
else if (!strcmp(act, "remove"))
|
else if (!strcmp(act, "remove"))
|
||||||
{
|
{
|
||||||
const char *node;
|
const char *node;
|
||||||
|
|
||||||
node = udev_device_get_devnode(udevice);
|
node = udev_device_get_devnode(udevice);
|
||||||
|
|
||||||
DBG("\tDevice Removed: %s", node);
|
|
||||||
_device_remove(input, node);
|
_device_remove(input, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
#ifndef _ECORE_DRM_PRIVATE_H
|
#ifndef _ECORE_DRM_PRIVATE_H
|
||||||
# define _ECORE_DRM_PRIVATE_H
|
# define _ECORE_DRM_PRIVATE_H
|
||||||
|
|
||||||
|
# ifdef HAVE_CONFIG_H
|
||||||
|
# include "config.h"
|
||||||
|
# endif
|
||||||
|
|
||||||
# include "Ecore.h"
|
# include "Ecore.h"
|
||||||
# include "ecore_private.h"
|
# include "ecore_private.h"
|
||||||
# include "Ecore_Input.h"
|
# include "Ecore_Input.h"
|
||||||
|
@ -18,7 +22,6 @@
|
||||||
# include <libudev.h>
|
# include <libudev.h>
|
||||||
# include <linux/input.h>
|
# include <linux/input.h>
|
||||||
//# include <libinput.h>
|
//# include <libinput.h>
|
||||||
# include <dbus/dbus.h>
|
|
||||||
# include <systemd/sd-login.h>
|
# include <systemd/sd-login.h>
|
||||||
# include <xkbcommon/xkbcommon.h>
|
# include <xkbcommon/xkbcommon.h>
|
||||||
|
|
||||||
|
@ -34,6 +37,7 @@
|
||||||
/* # include <GLES2/gl2ext.h> */
|
/* # include <GLES2/gl2ext.h> */
|
||||||
/* # endif */
|
/* # endif */
|
||||||
|
|
||||||
|
# include <Eldbus.h>
|
||||||
# include <Ecore_Drm.h>
|
# include <Ecore_Drm.h>
|
||||||
|
|
||||||
# define NUM_FRAME_BUFFERS 2
|
# define NUM_FRAME_BUFFERS 2
|
||||||
|
@ -227,9 +231,9 @@ struct _Ecore_Drm_Sprite
|
||||||
unsigned int formats[];
|
unsigned int formats[];
|
||||||
};
|
};
|
||||||
|
|
||||||
Eina_Bool _ecore_drm_dbus_init(const char *session);
|
int _ecore_drm_dbus_init(const char *session);
|
||||||
void _ecore_drm_dbus_shutdown(void);
|
int _ecore_drm_dbus_shutdown(void);
|
||||||
int _ecore_drm_dbus_device_open(const char *device);
|
void _ecore_drm_dbus_device_open(const char *device, Eldbus_Message_Cb callback, const void *data);
|
||||||
void _ecore_drm_dbus_device_close(const char *device);
|
void _ecore_drm_dbus_device_close(const char *device);
|
||||||
|
|
||||||
Ecore_Drm_Evdev *_ecore_drm_evdev_device_create(Ecore_Drm_Seat *seat, const char *path, int fd);
|
Ecore_Drm_Evdev *_ecore_drm_evdev_device_create(Ecore_Drm_Seat *seat, const char *path, int fd);
|
||||||
|
|
Loading…
Reference in New Issue