2014-03-06 01:43:48 -08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "ecore_drm_private.h"
|
|
|
|
#include <dlfcn.h>
|
|
|
|
|
2015-04-08 07:41:26 -07:00
|
|
|
#define INSIDE(x, y, xx, yy, ww, hh) \
|
|
|
|
(((x) < ((xx) + (ww))) && ((y) < ((yy) + (hh))) && \
|
|
|
|
((x) >= (xx)) && ((y) >= (yy)))
|
|
|
|
|
ecore-drm: add ecore_drm_devices_get to get the list of drm devices
Summary:
when enlightenment is working as wayland display server, enlightenment
changes KDSETMODE to KD_GRAPHICS in _ecore_drm_tty_setup(). However,
when enlightenment is killed by SIGSEGV, it doesn't changes KDSETMODE
to KD_TEXT because englightenment process doesn't call ecore_drm_tty_close().
To make possible enlightenment call ecore_drm_tty_close(), drm devices
should be exposed.
When enlightenment is killed by SIGSEGV, it will get drm devices with
ecore_drm_device_get_list(), and will call ecore_drm_launcher_disconnect(),
and ecore_drm_launcher_disconnect will call ecore_drm_tty_close() internally.
@feature
Change-Id: I1c594739ec96660a09cee77b823ace6548ee5282
Reviewers: zmike, cedric, raster, gwanglim, devilhorns
Subscribers: cedric
Differential Revision: https://phab.enlightenment.org/D2159
2015-03-17 06:30:59 -07:00
|
|
|
static Eina_List *drm_devices;
|
2015-04-08 10:50:50 -07:00
|
|
|
static int flip_count = 0;
|
ecore-drm: add ecore_drm_devices_get to get the list of drm devices
Summary:
when enlightenment is working as wayland display server, enlightenment
changes KDSETMODE to KD_GRAPHICS in _ecore_drm_tty_setup(). However,
when enlightenment is killed by SIGSEGV, it doesn't changes KDSETMODE
to KD_TEXT because englightenment process doesn't call ecore_drm_tty_close().
To make possible enlightenment call ecore_drm_tty_close(), drm devices
should be exposed.
When enlightenment is killed by SIGSEGV, it will get drm devices with
ecore_drm_device_get_list(), and will call ecore_drm_launcher_disconnect(),
and ecore_drm_launcher_disconnect will call ecore_drm_tty_close() internally.
@feature
Change-Id: I1c594739ec96660a09cee77b823ace6548ee5282
Reviewers: zmike, cedric, raster, gwanglim, devilhorns
Subscribers: cedric
Differential Revision: https://phab.enlightenment.org/D2159
2015-03-17 06:30:59 -07:00
|
|
|
|
2014-03-06 01:43:48 -08:00
|
|
|
static void
|
|
|
|
_ecore_drm_device_cb_page_flip(int fd EINA_UNUSED, unsigned int frame EINA_UNUSED, unsigned int sec EINA_UNUSED, unsigned int usec EINA_UNUSED, void *data)
|
|
|
|
{
|
2015-04-08 10:50:50 -07:00
|
|
|
Ecore_Drm_Pageflip_Callback *cb;
|
2014-03-06 01:43:48 -08:00
|
|
|
|
2015-05-04 08:41:25 -07:00
|
|
|
/* DBG("Drm Page Flip Event"); */
|
2014-03-06 01:43:48 -08:00
|
|
|
|
2015-04-08 10:50:50 -07:00
|
|
|
if (!(cb = data)) return;
|
2014-03-06 01:43:48 -08:00
|
|
|
|
2015-04-08 10:50:50 -07:00
|
|
|
flip_count++;
|
|
|
|
if (flip_count < cb->count) return;
|
2014-03-06 01:43:48 -08:00
|
|
|
|
2015-05-13 11:33:08 -07:00
|
|
|
cb->dev->current = cb->dev->next;
|
|
|
|
cb->dev->next = NULL;
|
|
|
|
|
2015-04-08 10:50:50 -07:00
|
|
|
flip_count = 0;
|
|
|
|
if (cb->func) cb->func(cb->data);
|
|
|
|
/* free(cb); */
|
|
|
|
|
|
|
|
/* Ecore_Drm_Output *output; */
|
|
|
|
|
|
|
|
/* DBG("Drm Page Flip Event"); */
|
|
|
|
|
|
|
|
/* if (!(output = data)) return; */
|
|
|
|
|
|
|
|
/* if (output->pending_flip) */
|
|
|
|
/* { */
|
|
|
|
/* if (output->dev->current) */
|
|
|
|
/* ecore_drm_output_fb_release(output, output->dev->current); */
|
|
|
|
/* output->dev->current = output->dev->next; */
|
|
|
|
/* output->dev->next = NULL; */
|
|
|
|
/* } */
|
|
|
|
|
|
|
|
/* output->pending_flip = EINA_FALSE; */
|
|
|
|
/* if (output->pending_destroy) */
|
|
|
|
/* { */
|
|
|
|
/* output->pending_destroy = EINA_FALSE; */
|
|
|
|
/* ecore_drm_output_free(output); */
|
|
|
|
/* } */
|
|
|
|
/* else if (!output->pending_vblank) */
|
|
|
|
/* ecore_drm_output_repaint(output); */
|
2014-03-06 01:43:48 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_ecore_drm_device_cb_vblank(int fd EINA_UNUSED, unsigned int frame EINA_UNUSED, unsigned int sec EINA_UNUSED, unsigned int usec EINA_UNUSED, void *data)
|
|
|
|
{
|
|
|
|
Ecore_Drm_Sprite *sprite;
|
|
|
|
Ecore_Drm_Output *output;
|
|
|
|
|
2015-05-04 08:41:25 -07:00
|
|
|
/* DBG("Drm VBlank Event"); */
|
2014-03-06 01:43:48 -08:00
|
|
|
|
|
|
|
if (!(sprite = data)) return;
|
|
|
|
|
|
|
|
output = sprite->output;
|
|
|
|
output->pending_vblank = EINA_FALSE;
|
|
|
|
|
|
|
|
ecore_drm_output_fb_release(output, sprite->current_fb);
|
|
|
|
sprite->current_fb = sprite->next_fb;
|
|
|
|
sprite->next_fb = NULL;
|
|
|
|
|
|
|
|
if (!output->pending_flip) _ecore_drm_output_frame_finish(output);
|
|
|
|
}
|
|
|
|
|
2015-04-20 09:15:13 -07:00
|
|
|
#if 0
|
2015-04-20 09:14:27 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_ecore_drm_device_cb_idle(void *data)
|
|
|
|
{
|
|
|
|
Ecore_Drm_Device *dev;
|
|
|
|
Ecore_Drm_Output *output;
|
|
|
|
Eina_List *l;
|
|
|
|
|
|
|
|
if (!(dev = data)) return ECORE_CALLBACK_CANCEL;
|
|
|
|
|
|
|
|
if (!dev->active) return ECORE_CALLBACK_RENEW;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(dev->outputs, l, output)
|
|
|
|
{
|
|
|
|
if ((!output->enabled) || (!output->need_repaint)) continue;
|
|
|
|
if (output->repaint_scheduled) continue;
|
|
|
|
_ecore_drm_output_repaint_start(output);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
2015-04-20 09:15:13 -07:00
|
|
|
#endif
|
2014-03-06 01:43:48 -08:00
|
|
|
|
2015-04-07 08:08:19 -07:00
|
|
|
static void
|
|
|
|
_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)
|
|
|
|
{
|
|
|
|
Ecore_Drm_Device *dev;
|
|
|
|
|
|
|
|
if (!(dev = data)) return;
|
|
|
|
_ecore_drm_outputs_update(dev);
|
|
|
|
}
|
|
|
|
|
2014-03-06 01:43:48 -08:00
|
|
|
/**
|
|
|
|
* @defgroup Ecore_Drm_Device_Group Device manipulation functions
|
|
|
|
*
|
|
|
|
* Functions that deal with finding, opening, closing, and otherwise using
|
|
|
|
* the DRM device itself.
|
|
|
|
*/
|
|
|
|
|
|
|
|
EAPI Ecore_Drm_Device *
|
|
|
|
ecore_drm_device_find(const char *name, const char *seat)
|
|
|
|
{
|
|
|
|
Ecore_Drm_Device *dev = NULL;
|
2014-09-23 10:13:25 -07:00
|
|
|
Eina_Bool found = EINA_FALSE;
|
2014-10-08 07:06:45 -07:00
|
|
|
Eina_Bool platform = EINA_FALSE;
|
2014-09-23 10:13:25 -07:00
|
|
|
Eina_List *devs, *l;
|
2014-09-24 06:06:47 -07:00
|
|
|
const char *device;
|
2014-03-06 01:43:48 -08:00
|
|
|
|
2014-09-23 10:13:25 -07:00
|
|
|
/* try to get a list of drm devics */
|
|
|
|
if (!(devs = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRM, name)))
|
|
|
|
return NULL;
|
2014-03-06 01:43:48 -08:00
|
|
|
|
2014-09-23 10:13:25 -07:00
|
|
|
DBG("Find Drm Device: %s", name);
|
2014-03-06 01:43:48 -08:00
|
|
|
|
2014-09-23 10:13:25 -07:00
|
|
|
EINA_LIST_FOREACH(devs, l, device)
|
2014-03-06 01:43:48 -08:00
|
|
|
{
|
2014-09-23 10:13:25 -07:00
|
|
|
const char *devpath;
|
|
|
|
const char *devseat;
|
|
|
|
const char *devparent;
|
2014-03-06 01:43:48 -08:00
|
|
|
|
2014-09-23 10:13:25 -07:00
|
|
|
if (!(devpath = eeze_udev_syspath_get_devpath(device)))
|
2014-03-06 01:43:48 -08:00
|
|
|
continue;
|
|
|
|
|
2014-09-23 10:13:25 -07:00
|
|
|
DBG("Found Drm Device");
|
|
|
|
DBG("\tDevice: %s", device);
|
|
|
|
DBG("\tDevpath: %s", devpath);
|
2014-03-06 01:43:48 -08:00
|
|
|
|
2014-09-23 10:13:25 -07:00
|
|
|
if ((name) && (strcmp(name, devpath))) goto cont;
|
2014-03-06 01:43:48 -08:00
|
|
|
|
2014-09-23 10:13:25 -07:00
|
|
|
if (!(devseat = eeze_udev_syspath_get_property(device, "ID_SEAT")))
|
|
|
|
devseat = eina_stringshare_add("seat0");
|
|
|
|
|
|
|
|
if ((seat) && (strcmp(seat, devseat)))
|
|
|
|
goto cont;
|
|
|
|
else if (strcmp(devseat, "seat0"))
|
|
|
|
goto cont;
|
2014-03-06 01:43:48 -08:00
|
|
|
|
2014-09-23 10:13:25 -07:00
|
|
|
devparent = eeze_udev_syspath_get_parent_filtered(device, "pci", NULL);
|
2014-10-08 06:31:37 -07:00
|
|
|
if (!devparent)
|
|
|
|
{
|
|
|
|
devparent =
|
|
|
|
eeze_udev_syspath_get_parent_filtered(device, "platform", NULL);
|
2014-10-08 07:06:45 -07:00
|
|
|
platform = EINA_TRUE;
|
2014-10-08 06:31:37 -07:00
|
|
|
}
|
|
|
|
|
2014-09-23 10:13:25 -07:00
|
|
|
if (devparent)
|
2014-03-06 01:43:48 -08:00
|
|
|
{
|
2014-10-08 07:06:45 -07:00
|
|
|
if (!platform)
|
2014-03-06 01:43:48 -08:00
|
|
|
{
|
2014-10-08 07:06:45 -07:00
|
|
|
const char *id;
|
|
|
|
|
|
|
|
if ((id = eeze_udev_syspath_get_sysattr(devparent, "boot_vga")))
|
|
|
|
{
|
|
|
|
if (!strcmp(id, "1")) found = EINA_TRUE;
|
|
|
|
eina_stringshare_del(id);
|
|
|
|
}
|
2014-03-06 01:43:48 -08:00
|
|
|
}
|
2014-10-08 07:06:45 -07:00
|
|
|
else
|
|
|
|
found = EINA_TRUE;
|
2014-09-23 10:13:25 -07:00
|
|
|
|
|
|
|
eina_stringshare_del(devparent);
|
2014-03-06 01:43:48 -08:00
|
|
|
}
|
|
|
|
|
2014-09-23 10:13:25 -07:00
|
|
|
cont:
|
|
|
|
eina_stringshare_del(devpath);
|
2014-09-24 06:06:47 -07:00
|
|
|
if (found) break;
|
2014-03-06 01:43:48 -08:00
|
|
|
}
|
|
|
|
|
2014-09-24 06:06:47 -07:00
|
|
|
if (!found) goto out;
|
2014-03-06 01:43:48 -08:00
|
|
|
|
2014-09-23 10:13:25 -07:00
|
|
|
if ((dev = calloc(1, sizeof(Ecore_Drm_Device))))
|
|
|
|
{
|
2014-09-24 06:06:47 -07:00
|
|
|
dev->drm.name = eeze_udev_syspath_get_devpath(device);
|
|
|
|
dev->drm.path = eina_stringshare_add(device);
|
2014-03-06 01:43:48 -08:00
|
|
|
|
2014-09-24 06:06:47 -07:00
|
|
|
dev->id = eeze_udev_syspath_get_sysnum(device);
|
2014-03-06 01:43:48 -08:00
|
|
|
|
2014-09-24 06:06:47 -07:00
|
|
|
dev->seat = eeze_udev_syspath_get_property(device, "ID_SEAT");
|
2014-09-23 10:13:25 -07:00
|
|
|
if (!dev->seat) dev->seat = eina_stringshare_add("seat0");
|
2014-03-06 01:43:48 -08:00
|
|
|
|
2015-01-22 09:36:00 -08:00
|
|
|
dev->vt = 0;
|
2014-09-23 10:13:25 -07:00
|
|
|
dev->format = 0;
|
|
|
|
dev->use_hw_accel = EINA_FALSE;
|
2015-01-22 09:36:00 -08:00
|
|
|
dev->session = NULL;
|
2014-03-06 01:43:48 -08:00
|
|
|
|
2014-09-23 10:13:25 -07:00
|
|
|
DBG("Using Drm Device: %s", dev->drm.name);
|
ecore-drm: add ecore_drm_devices_get to get the list of drm devices
Summary:
when enlightenment is working as wayland display server, enlightenment
changes KDSETMODE to KD_GRAPHICS in _ecore_drm_tty_setup(). However,
when enlightenment is killed by SIGSEGV, it doesn't changes KDSETMODE
to KD_TEXT because englightenment process doesn't call ecore_drm_tty_close().
To make possible enlightenment call ecore_drm_tty_close(), drm devices
should be exposed.
When enlightenment is killed by SIGSEGV, it will get drm devices with
ecore_drm_device_get_list(), and will call ecore_drm_launcher_disconnect(),
and ecore_drm_launcher_disconnect will call ecore_drm_tty_close() internally.
@feature
Change-Id: I1c594739ec96660a09cee77b823ace6548ee5282
Reviewers: zmike, cedric, raster, gwanglim, devilhorns
Subscribers: cedric
Differential Revision: https://phab.enlightenment.org/D2159
2015-03-17 06:30:59 -07:00
|
|
|
|
|
|
|
drm_devices = eina_list_append(drm_devices, dev);
|
2014-03-06 01:43:48 -08:00
|
|
|
}
|
|
|
|
|
2014-09-24 06:06:47 -07:00
|
|
|
out:
|
|
|
|
EINA_LIST_FREE(devs, device)
|
|
|
|
eina_stringshare_del(device);
|
2014-03-06 01:43:48 -08:00
|
|
|
|
|
|
|
return dev;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
ecore_drm_device_free(Ecore_Drm_Device *dev)
|
|
|
|
{
|
|
|
|
Ecore_Drm_Output *output;
|
2015-04-07 11:07:12 -07:00
|
|
|
unsigned int i = 0;
|
2014-03-06 01:43:48 -08:00
|
|
|
|
|
|
|
/* check for valid device */
|
|
|
|
if (!dev) return;
|
|
|
|
|
2015-04-07 11:07:12 -07:00
|
|
|
for (; i < ALEN(dev->dumb); i++)
|
|
|
|
{
|
|
|
|
if (dev->dumb[i]) ecore_drm_fb_destroy(dev->dumb[i]);
|
|
|
|
dev->dumb[i] = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ecore_drm_inputs_destroy(dev);
|
|
|
|
|
2014-03-06 01:43:48 -08:00
|
|
|
/* free outputs */
|
|
|
|
EINA_LIST_FREE(dev->outputs, output)
|
|
|
|
ecore_drm_output_free(output);
|
|
|
|
|
|
|
|
/* free crtcs */
|
|
|
|
if (dev->crtcs) free(dev->crtcs);
|
|
|
|
|
|
|
|
/* free device name */
|
|
|
|
if (dev->drm.name) eina_stringshare_del(dev->drm.name);
|
|
|
|
|
|
|
|
/* free device path */
|
|
|
|
if (dev->drm.path) eina_stringshare_del(dev->drm.path);
|
|
|
|
|
|
|
|
/* free device seat */
|
|
|
|
if (dev->seat) eina_stringshare_del(dev->seat);
|
|
|
|
|
2015-01-22 09:36:00 -08:00
|
|
|
/* free session */
|
|
|
|
free(dev->session);
|
|
|
|
|
ecore-drm: add ecore_drm_devices_get to get the list of drm devices
Summary:
when enlightenment is working as wayland display server, enlightenment
changes KDSETMODE to KD_GRAPHICS in _ecore_drm_tty_setup(). However,
when enlightenment is killed by SIGSEGV, it doesn't changes KDSETMODE
to KD_TEXT because englightenment process doesn't call ecore_drm_tty_close().
To make possible enlightenment call ecore_drm_tty_close(), drm devices
should be exposed.
When enlightenment is killed by SIGSEGV, it will get drm devices with
ecore_drm_device_get_list(), and will call ecore_drm_launcher_disconnect(),
and ecore_drm_launcher_disconnect will call ecore_drm_tty_close() internally.
@feature
Change-Id: I1c594739ec96660a09cee77b823ace6548ee5282
Reviewers: zmike, cedric, raster, gwanglim, devilhorns
Subscribers: cedric
Differential Revision: https://phab.enlightenment.org/D2159
2015-03-17 06:30:59 -07:00
|
|
|
drm_devices = eina_list_remove(drm_devices, dev);
|
|
|
|
|
2014-03-06 01:43:48 -08:00
|
|
|
/* free structure */
|
|
|
|
free(dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Eina_Bool
|
|
|
|
ecore_drm_device_open(Ecore_Drm_Device *dev)
|
|
|
|
{
|
|
|
|
uint64_t caps;
|
2015-04-07 08:08:19 -07:00
|
|
|
int events = 0;
|
2015-10-30 13:00:32 -07:00
|
|
|
drmVersionPtr ver;
|
2014-03-06 01:43:48 -08:00
|
|
|
|
|
|
|
/* check for valid device */
|
|
|
|
if ((!dev) || (!dev->drm.name)) return EINA_FALSE;
|
|
|
|
|
2014-12-09 06:36:42 -08:00
|
|
|
/* DRM device node is needed immediately to keep going. */
|
2015-01-22 09:36:00 -08:00
|
|
|
dev->drm.fd =
|
|
|
|
_ecore_drm_launcher_device_open_no_pending(dev->drm.name, O_RDWR);
|
2014-03-06 01:43:48 -08:00
|
|
|
if (dev->drm.fd < 0) return EINA_FALSE;
|
|
|
|
|
|
|
|
DBG("Opened Device %s : %d", dev->drm.name, dev->drm.fd);
|
|
|
|
|
2015-10-30 13:00:32 -07:00
|
|
|
ver = drmGetVersion(dev->drm.fd);
|
|
|
|
if (ver)
|
|
|
|
{
|
|
|
|
DBG("\tDriver Name: %s", ver->name);
|
|
|
|
DBG("\tDriver Date: %s", ver->date);
|
|
|
|
DBG("\tDriver Description: %s", ver->desc);
|
|
|
|
DBG("\tDriver Version: %d.%d.%d",
|
|
|
|
ver->version_major, ver->version_minor,
|
|
|
|
ver->version_patchlevel);
|
|
|
|
drmFreeVersion(ver);
|
|
|
|
}
|
|
|
|
|
2015-05-06 08:31:57 -07:00
|
|
|
/* set client capabilities to 'universal planes' so drm core will expose
|
|
|
|
* the full universal plane list (including primary & cursor planes) */
|
|
|
|
drmSetClientCap(dev->drm.fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
|
|
|
|
|
2014-03-06 01:43:48 -08:00
|
|
|
if (!drmGetCap(dev->drm.fd, DRM_CAP_TIMESTAMP_MONOTONIC, &caps))
|
|
|
|
{
|
|
|
|
if (caps == 1)
|
|
|
|
dev->drm.clock = CLOCK_MONOTONIC;
|
|
|
|
else
|
|
|
|
dev->drm.clock = CLOCK_REALTIME;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-06-27 06:30:35 -07:00
|
|
|
ERR("Could not get TIMESTAMP_MONOTONIC device capabilities: %m");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Without DUMB_BUFFER we can't do software rendering on DRM. Fail without it
|
|
|
|
* until we have rock solid hardware accelerated DRM on all drivers */
|
|
|
|
if (drmGetCap(dev->drm.fd, DRM_CAP_DUMB_BUFFER, &caps) < 0 || !caps)
|
|
|
|
{
|
|
|
|
ERR("Could not get DUMB_BUFFER device capabilities: %m");
|
|
|
|
return EINA_FALSE;
|
2014-03-06 01:43:48 -08:00
|
|
|
}
|
|
|
|
|
2014-03-10 02:56:24 -07:00
|
|
|
/* try to create xkb context */
|
|
|
|
if (!(dev->xkb_ctx = xkb_context_new(0)))
|
|
|
|
{
|
|
|
|
ERR("Failed to create xkb context: %m");
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2015-04-07 11:30:43 -07:00
|
|
|
memset(&dev->drm_ctx, 0, sizeof(dev->drm_ctx));
|
|
|
|
dev->drm_ctx.version = DRM_EVENT_CONTEXT_VERSION;
|
|
|
|
dev->drm_ctx.page_flip_handler = _ecore_drm_device_cb_page_flip;
|
|
|
|
dev->drm_ctx.vblank_handler = _ecore_drm_device_cb_vblank;
|
|
|
|
|
2015-04-07 08:08:19 -07:00
|
|
|
events = (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE |
|
|
|
|
EEZE_UDEV_EVENT_CHANGE);
|
|
|
|
|
|
|
|
dev->watch =
|
|
|
|
eeze_udev_watch_add(EEZE_UDEV_TYPE_DRM, events,
|
2015-04-16 07:51:56 -07:00
|
|
|
_ecore_drm_device_cb_output_event, dev);
|
2015-04-07 08:08:19 -07:00
|
|
|
|
2015-04-08 10:50:50 -07:00
|
|
|
/* dev->drm.idler = */
|
|
|
|
/* ecore_idle_enterer_add(_ecore_drm_device_cb_idle, dev); */
|
2014-03-06 01:43:48 -08:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Eina_Bool
|
|
|
|
ecore_drm_device_close(Ecore_Drm_Device *dev)
|
|
|
|
{
|
|
|
|
/* check for valid device */
|
2015-04-24 09:51:34 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(dev, EINA_FALSE);
|
2014-03-06 01:43:48 -08:00
|
|
|
|
2015-04-07 08:08:19 -07:00
|
|
|
/* delete udev watch */
|
|
|
|
if (dev->watch) eeze_udev_watch_del(dev->watch);
|
|
|
|
|
2014-03-10 02:56:24 -07:00
|
|
|
/* close xkb context */
|
|
|
|
if (dev->xkb_ctx) xkb_context_unref(dev->xkb_ctx);
|
|
|
|
|
2014-12-09 06:36:42 -08:00
|
|
|
_ecore_drm_launcher_device_close(dev->drm.name, dev->drm.fd);
|
2014-03-06 01:43:48 -08:00
|
|
|
|
|
|
|
/* reset device fd */
|
|
|
|
dev->drm.fd = -1;
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2015-04-22 16:34:19 -07:00
|
|
|
EAPI const Eina_List *
|
ecore-drm: add ecore_drm_devices_get to get the list of drm devices
Summary:
when enlightenment is working as wayland display server, enlightenment
changes KDSETMODE to KD_GRAPHICS in _ecore_drm_tty_setup(). However,
when enlightenment is killed by SIGSEGV, it doesn't changes KDSETMODE
to KD_TEXT because englightenment process doesn't call ecore_drm_tty_close().
To make possible enlightenment call ecore_drm_tty_close(), drm devices
should be exposed.
When enlightenment is killed by SIGSEGV, it will get drm devices with
ecore_drm_device_get_list(), and will call ecore_drm_launcher_disconnect(),
and ecore_drm_launcher_disconnect will call ecore_drm_tty_close() internally.
@feature
Change-Id: I1c594739ec96660a09cee77b823ace6548ee5282
Reviewers: zmike, cedric, raster, gwanglim, devilhorns
Subscribers: cedric
Differential Revision: https://phab.enlightenment.org/D2159
2015-03-17 06:30:59 -07:00
|
|
|
ecore_drm_devices_get(void)
|
|
|
|
{
|
|
|
|
return drm_devices;
|
|
|
|
}
|
|
|
|
|
2014-03-06 01:43:48 -08:00
|
|
|
EAPI Eina_Bool
|
|
|
|
ecore_drm_device_master_get(Ecore_Drm_Device *dev)
|
|
|
|
{
|
2014-07-15 06:38:25 -07:00
|
|
|
drm_magic_t mag;
|
2014-03-06 01:43:48 -08:00
|
|
|
|
|
|
|
/* check for valid device */
|
|
|
|
if ((!dev) || (dev->drm.fd < 0)) return EINA_FALSE;
|
|
|
|
|
|
|
|
/* get if we are master or not */
|
2014-07-15 06:38:25 -07:00
|
|
|
if ((drmGetMagic(dev->drm.fd, &mag) == 0) &&
|
|
|
|
(drmAuthMagic(dev->drm.fd, mag) == 0))
|
|
|
|
return EINA_TRUE;
|
2014-03-06 01:43:48 -08:00
|
|
|
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Eina_Bool
|
|
|
|
ecore_drm_device_master_set(Ecore_Drm_Device *dev)
|
|
|
|
{
|
|
|
|
/* check for valid device */
|
|
|
|
if ((!dev) || (dev->drm.fd < 0)) return EINA_FALSE;
|
|
|
|
|
|
|
|
DBG("Set Master On Fd: %d", dev->drm.fd);
|
|
|
|
|
2014-07-15 06:38:25 -07:00
|
|
|
drmSetMaster(dev->drm.fd);
|
2014-03-06 01:43:48 -08:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Eina_Bool
|
|
|
|
ecore_drm_device_master_drop(Ecore_Drm_Device *dev)
|
|
|
|
{
|
|
|
|
/* check for valid device */
|
|
|
|
if ((!dev) || (dev->drm.fd < 0)) return EINA_FALSE;
|
|
|
|
|
|
|
|
DBG("Drop Master On Fd: %d", dev->drm.fd);
|
|
|
|
|
2014-07-15 06:38:25 -07:00
|
|
|
drmDropMaster(dev->drm.fd);
|
2014-03-06 01:43:48 -08:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI int
|
|
|
|
ecore_drm_device_fd_get(Ecore_Drm_Device *dev)
|
|
|
|
{
|
2015-04-24 09:51:34 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(dev, -1);
|
2014-03-06 01:43:48 -08:00
|
|
|
return dev->drm.fd;
|
|
|
|
}
|
2014-03-10 05:36:21 -07:00
|
|
|
|
|
|
|
EAPI void
|
2014-03-18 00:24:32 -07:00
|
|
|
ecore_drm_device_window_set(Ecore_Drm_Device *dev, unsigned int window)
|
2014-03-10 05:36:21 -07:00
|
|
|
{
|
|
|
|
/* check for valid device */
|
2015-04-24 09:51:34 -07:00
|
|
|
EINA_SAFETY_ON_TRUE_RETURN((!dev) || (dev->drm.fd < 0));
|
2014-03-10 05:36:21 -07:00
|
|
|
|
|
|
|
dev->window = window;
|
|
|
|
}
|
2014-03-12 02:26:43 -07:00
|
|
|
|
|
|
|
EAPI const char *
|
|
|
|
ecore_drm_device_name_get(Ecore_Drm_Device *dev)
|
|
|
|
{
|
|
|
|
/* check for valid device */
|
2015-04-24 09:51:34 -07:00
|
|
|
EINA_SAFETY_ON_TRUE_RETURN_VAL((!dev) || (dev->drm.fd < 0), NULL);
|
2014-03-12 02:26:43 -07:00
|
|
|
|
|
|
|
return dev->drm.name;
|
|
|
|
}
|
2015-03-04 08:46:22 -08:00
|
|
|
|
|
|
|
EAPI void
|
|
|
|
ecore_drm_device_pointer_xy_get(Ecore_Drm_Device *dev, int *x, int *y)
|
|
|
|
{
|
|
|
|
Ecore_Drm_Seat *seat;
|
|
|
|
Ecore_Drm_Evdev *edev;
|
|
|
|
Eina_List *l, *ll;
|
|
|
|
|
|
|
|
if (x) *x = 0;
|
|
|
|
if (y) *y = 0;
|
|
|
|
|
|
|
|
/* check for valid device */
|
2015-04-24 09:51:34 -07:00
|
|
|
EINA_SAFETY_ON_TRUE_RETURN((!dev) || (dev->drm.fd < 0));
|
2015-03-04 08:46:22 -08:00
|
|
|
|
|
|
|
EINA_LIST_FOREACH(dev->seats, l, seat)
|
|
|
|
{
|
|
|
|
EINA_LIST_FOREACH(seat->devices, ll, edev)
|
|
|
|
{
|
ecore-drm: Add logical pointer x, y variable in seat for reflecting multiple pointer's movement
Summary: When one pointer moves, we should update the position of other devices.
Test Plan:
(1) Two pointer devices are connected.
(2) Move the cursor to (x, y) position using "device 1".
(3) When you move the cursor using "device 2", the cursor doesn't start from (x, y) position. This causes discontinuous mouse motion.
Reviewers: raster, zmike, gwanglim, stefan_schmidt, devilhorns, ManMower
Reviewed By: devilhorns, ManMower
Subscribers: cedric, Jeon, input.hacker, jpeg
Differential Revision: https://phab.enlightenment.org/D3384
2015-11-30 08:05:07 -08:00
|
|
|
if (!libinput_device_has_capability(edev->device,
|
2015-03-04 08:46:22 -08:00
|
|
|
LIBINPUT_DEVICE_CAP_POINTER))
|
|
|
|
continue;
|
|
|
|
|
ecore-drm: Add logical pointer x, y variable in seat for reflecting multiple pointer's movement
Summary: When one pointer moves, we should update the position of other devices.
Test Plan:
(1) Two pointer devices are connected.
(2) Move the cursor to (x, y) position using "device 1".
(3) When you move the cursor using "device 2", the cursor doesn't start from (x, y) position. This causes discontinuous mouse motion.
Reviewers: raster, zmike, gwanglim, stefan_schmidt, devilhorns, ManMower
Reviewed By: devilhorns, ManMower
Subscribers: cedric, Jeon, input.hacker, jpeg
Differential Revision: https://phab.enlightenment.org/D3384
2015-11-30 08:05:07 -08:00
|
|
|
if (x) *x = seat->ptr.dx;
|
|
|
|
if (y) *y = seat->ptr.dy;
|
2015-03-04 08:46:22 -08:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-04-07 11:07:12 -07:00
|
|
|
|
|
|
|
EAPI Eina_Bool
|
|
|
|
ecore_drm_device_software_setup(Ecore_Drm_Device *dev)
|
|
|
|
{
|
|
|
|
unsigned int i = 0;
|
|
|
|
int w = 0, h = 0;
|
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(dev, EINA_FALSE);
|
|
|
|
|
|
|
|
/* destroy any old buffers */
|
|
|
|
for (; i < ALEN(dev->dumb); i++)
|
|
|
|
{
|
|
|
|
if (dev->dumb[i]) ecore_drm_fb_destroy(dev->dumb[i]);
|
|
|
|
dev->dumb[i] = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get screen size */
|
|
|
|
ecore_drm_outputs_geometry_get(dev, NULL, NULL, &w, &h);
|
|
|
|
|
|
|
|
/* create new buffers */
|
|
|
|
for (i = 0; i < ALEN(dev->dumb); i++)
|
|
|
|
{
|
|
|
|
if (!(dev->dumb[i] = ecore_drm_fb_create(dev, w, h)))
|
|
|
|
{
|
|
|
|
ERR("Could not create dumb framebuffer: %m");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
DBG("Ecore_Drm_Device Created Dumb Buffer");
|
|
|
|
DBG("\tFb: %d", dev->dumb[i]->id);
|
|
|
|
DBG("\tHandle: %d", dev->dumb[i]->hdl);
|
|
|
|
DBG("\tStride: %d", dev->dumb[i]->stride);
|
|
|
|
DBG("\tSize: %d", dev->dumb[i]->size);
|
|
|
|
DBG("\tW: %d\tH: %d", dev->dumb[i]->w, dev->dumb[i]->h);
|
|
|
|
}
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
|
|
|
|
err:
|
|
|
|
for (i = 0; i < ALEN(dev->dumb); i++)
|
|
|
|
{
|
|
|
|
if (dev->dumb[i]) ecore_drm_fb_destroy(dev->dumb[i]);
|
|
|
|
dev->dumb[i] = NULL;
|
|
|
|
}
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
2015-04-08 07:41:26 -07:00
|
|
|
|
|
|
|
EAPI Ecore_Drm_Output *
|
|
|
|
ecore_drm_device_output_find(Ecore_Drm_Device *dev, int x, int y)
|
|
|
|
{
|
|
|
|
Ecore_Drm_Output *output;
|
|
|
|
Eina_List *l;
|
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(dev, NULL);
|
2015-04-24 09:51:34 -07:00
|
|
|
EINA_SAFETY_ON_TRUE_RETURN_VAL((x < 0) || (y < 0), NULL);
|
2015-04-08 07:41:26 -07:00
|
|
|
|
|
|
|
EINA_LIST_FOREACH(dev->outputs, l, output)
|
|
|
|
{
|
|
|
|
int ox = 0, oy = 0;
|
|
|
|
int ow = 0, oh = 0;
|
|
|
|
|
|
|
|
if (!output->cloned)
|
|
|
|
{
|
|
|
|
ox = output->x;
|
|
|
|
oy = output->y;
|
|
|
|
}
|
|
|
|
|
|
|
|
ow = output->current_mode->width;
|
|
|
|
oh = output->current_mode->height;
|
|
|
|
|
|
|
|
if (INSIDE(x, y, ox, oy, ow, oh))
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2015-05-04 10:25:15 -07:00
|
|
|
|
|
|
|
EAPI void
|
|
|
|
ecore_drm_screen_size_range_get(Ecore_Drm_Device *dev, int *minw, int *minh, int *maxw, int *maxh)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(dev);
|
|
|
|
|
|
|
|
if (minw) *minw = dev->min_width;
|
|
|
|
if (minh) *minh = dev->min_height;
|
|
|
|
if (maxw) *maxw = dev->max_width;
|
|
|
|
if (maxh) *maxh = dev->max_height;
|
|
|
|
}
|
2015-05-07 08:31:46 -07:00
|
|
|
|
|
|
|
EAPI Ecore_Drm_Output *
|
|
|
|
ecore_drm_device_output_name_find(Ecore_Drm_Device *dev, const char *name)
|
|
|
|
{
|
|
|
|
Ecore_Drm_Output *output;
|
|
|
|
Eina_List *l;
|
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(dev, NULL);
|
2015-05-07 08:37:54 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
|
2015-05-07 08:31:46 -07:00
|
|
|
|
|
|
|
EINA_LIST_FOREACH(dev->outputs, l, output)
|
|
|
|
if ((output->name) && (!strcmp(name, output->name)))
|
|
|
|
return output;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2015-12-29 06:03:43 -08:00
|
|
|
|
|
|
|
EAPI Eina_Bool
|
|
|
|
ecore_drm_device_pointer_left_handed_set(Ecore_Drm_Device *dev, Eina_Bool left_handed)
|
|
|
|
{
|
|
|
|
Ecore_Drm_Seat *seat = NULL;
|
|
|
|
Ecore_Drm_Evdev *edev = NULL;
|
|
|
|
Eina_List *l = NULL, *l2 = NULL;
|
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(dev, EINA_FALSE);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(dev->seats, EINA_FALSE);
|
|
|
|
|
|
|
|
if (dev->left_handed == left_handed)
|
|
|
|
return EINA_TRUE;
|
|
|
|
dev->left_handed = !!left_handed;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(dev->seats, l, seat)
|
|
|
|
{
|
|
|
|
EINA_LIST_FOREACH(seat->devices, l2, edev)
|
|
|
|
{
|
|
|
|
if (libinput_device_has_capability(edev->device,
|
|
|
|
LIBINPUT_DEVICE_CAP_POINTER))
|
|
|
|
{
|
|
|
|
if (libinput_device_config_left_handed_set(edev->device, (int)left_handed) !=
|
|
|
|
LIBINPUT_CONFIG_STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
WRN("Failed to set left hand mode about device: %s\n",
|
|
|
|
libinput_device_get_name(edev->device));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|