2014-03-06 01:43:48 -08:00
|
|
|
#ifndef _ECORE_DRM_PRIVATE_H
|
|
|
|
# define _ECORE_DRM_PRIVATE_H
|
|
|
|
|
2014-09-18 08:39:29 -07:00
|
|
|
# ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
# endif
|
|
|
|
|
2014-03-06 01:43:48 -08:00
|
|
|
# include "Ecore.h"
|
|
|
|
# include "ecore_private.h"
|
|
|
|
# include "Ecore_Input.h"
|
|
|
|
|
|
|
|
# include <stdio.h>
|
|
|
|
# include <stdlib.h>
|
|
|
|
# include <string.h>
|
|
|
|
# include <unistd.h>
|
|
|
|
# include <errno.h>
|
|
|
|
# include <fcntl.h>
|
2014-07-15 06:27:19 -07:00
|
|
|
# include <sys/mman.h>
|
|
|
|
# include <sys/stat.h>
|
|
|
|
# include <sys/ioctl.h>
|
2014-03-06 01:43:48 -08:00
|
|
|
|
2015-01-22 09:42:06 -08:00
|
|
|
# include <linux/vt.h>
|
|
|
|
# include <linux/kd.h>
|
|
|
|
# include <linux/major.h>
|
2014-03-06 01:43:48 -08:00
|
|
|
# include <linux/input.h>
|
2014-12-09 07:00:29 -08:00
|
|
|
# include <libinput.h>
|
2014-03-10 01:32:49 -07:00
|
|
|
# include <xkbcommon/xkbcommon.h>
|
2014-03-06 01:43:48 -08:00
|
|
|
|
2015-08-25 01:52:47 -07:00
|
|
|
# ifdef HAVE_SYSTEMD
|
2015-01-22 09:42:06 -08:00
|
|
|
# include <systemd/sd-login.h>
|
|
|
|
# endif
|
|
|
|
|
2014-09-18 08:35:20 -07:00
|
|
|
# include <Eldbus.h>
|
2014-03-06 01:43:48 -08:00
|
|
|
# include <Ecore_Drm.h>
|
|
|
|
|
2014-03-06 03:08:55 -08:00
|
|
|
# define NUM_FRAME_BUFFERS 2
|
|
|
|
|
2014-03-06 01:43:48 -08:00
|
|
|
# ifndef DRM_MAJOR
|
|
|
|
# define DRM_MAJOR 226
|
|
|
|
# endif
|
|
|
|
|
|
|
|
# ifndef DRM_CAP_TIMESTAMP_MONOTONIC
|
|
|
|
# define DRM_CAP_TIMESTAMP_MONOTONIC 0x6
|
|
|
|
# endif
|
|
|
|
|
|
|
|
# ifdef ECORE_DRM_DEFAULT_LOG_COLOR
|
|
|
|
# undef ECORE_DRM_DEFAULT_LOG_COLOR
|
|
|
|
# endif
|
|
|
|
# define ECORE_DRM_DEFAULT_LOG_COLOR EINA_COLOR_BLUE
|
|
|
|
|
|
|
|
# define EVDEV_SEAT_POINTER (1 << 0)
|
|
|
|
# define EVDEV_SEAT_KEYBOARD (1 << 1)
|
|
|
|
# define EVDEV_SEAT_TOUCH (1 << 2)
|
|
|
|
|
|
|
|
# ifdef ERR
|
|
|
|
# undef ERR
|
|
|
|
# endif
|
|
|
|
# ifdef DBG
|
|
|
|
# undef DBG
|
|
|
|
# endif
|
|
|
|
# ifdef INF
|
|
|
|
# undef INF
|
|
|
|
# endif
|
|
|
|
# ifdef WRN
|
|
|
|
# undef WRN
|
|
|
|
# endif
|
|
|
|
# ifdef CRIT
|
|
|
|
# undef CRIT
|
|
|
|
# endif
|
|
|
|
|
|
|
|
extern int _ecore_drm_log_dom;
|
|
|
|
|
2015-04-07 08:18:18 -07:00
|
|
|
# define EVDEV_MAX_SLOTS 32
|
2014-06-06 08:40:33 -07:00
|
|
|
|
2015-04-07 08:18:18 -07:00
|
|
|
# define ERR(...) EINA_LOG_DOM_ERR(_ecore_drm_log_dom, __VA_ARGS__)
|
|
|
|
# define DBG(...) EINA_LOG_DOM_DBG(_ecore_drm_log_dom, __VA_ARGS__)
|
|
|
|
# define INF(...) EINA_LOG_DOM_INFO(_ecore_drm_log_dom, __VA_ARGS__)
|
|
|
|
# define WRN(...) EINA_LOG_DOM_WARN(_ecore_drm_log_dom, __VA_ARGS__)
|
|
|
|
# define CRIT(...) EINA_LOG_DOM_CRIT(_ecore_drm_log_dom, __VA_ARGS__)
|
2014-03-06 01:43:48 -08:00
|
|
|
|
2015-04-07 11:05:10 -07:00
|
|
|
# define ALEN(array) (sizeof(array) / sizeof(array)[0])
|
|
|
|
|
2015-04-08 10:41:57 -07:00
|
|
|
typedef struct _Ecore_Drm_Pageflip_Callback
|
|
|
|
{
|
2015-05-13 11:33:08 -07:00
|
|
|
Ecore_Drm_Device *dev;
|
2015-04-08 10:41:57 -07:00
|
|
|
Ecore_Drm_Pageflip_Cb func;
|
|
|
|
void *data;
|
|
|
|
int count;
|
|
|
|
} Ecore_Drm_Pageflip_Callback;
|
|
|
|
|
2014-09-23 05:28:08 -07:00
|
|
|
typedef enum _Ecore_Drm_Backlight_Type
|
|
|
|
{
|
|
|
|
ECORE_DRM_BACKLIGHT_RAW,
|
|
|
|
ECORE_DRM_BACKLIGHT_PLATFORM,
|
|
|
|
ECORE_DRM_BACKLIGHT_FIRMWARE
|
|
|
|
} Ecore_Drm_Backlight_Type;
|
|
|
|
|
|
|
|
typedef struct _Ecore_Drm_Backlight
|
|
|
|
{
|
2014-09-24 06:58:57 -07:00
|
|
|
const char *device;
|
|
|
|
double brightness_max;
|
|
|
|
double brightness_actual;
|
|
|
|
double brightness;
|
|
|
|
|
2014-09-23 05:28:08 -07:00
|
|
|
Ecore_Drm_Backlight_Type type;
|
|
|
|
} Ecore_Drm_Backlight;
|
|
|
|
|
2014-03-06 01:43:48 -08:00
|
|
|
struct _Ecore_Drm_Output
|
|
|
|
{
|
|
|
|
Ecore_Drm_Device *dev;
|
|
|
|
unsigned int crtc_id;
|
|
|
|
unsigned int conn_id;
|
2015-05-04 11:22:10 -07:00
|
|
|
unsigned int conn_type;
|
2014-03-06 01:43:48 -08:00
|
|
|
drmModeCrtcPtr crtc;
|
2015-04-07 08:41:21 -07:00
|
|
|
drmModePropertyPtr dpms;
|
2014-03-06 01:43:48 -08:00
|
|
|
|
2015-03-04 11:52:04 -08:00
|
|
|
int x, y, phys_width, phys_height;
|
2014-03-06 01:43:48 -08:00
|
|
|
|
2015-04-07 09:13:32 -07:00
|
|
|
int pipe;
|
2014-03-06 01:43:48 -08:00
|
|
|
const char *make, *model, *name;
|
|
|
|
unsigned int subpixel;
|
2015-04-07 10:03:28 -07:00
|
|
|
uint16_t gamma;
|
2014-03-06 01:43:48 -08:00
|
|
|
|
|
|
|
Ecore_Drm_Output_Mode *current_mode;
|
|
|
|
Eina_List *modes;
|
|
|
|
|
2015-05-12 08:56:52 -07:00
|
|
|
unsigned char *edid_blob;
|
2015-05-04 12:03:47 -07:00
|
|
|
|
2015-03-04 11:52:04 -08:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
char eisa[13];
|
|
|
|
char monitor[13];
|
|
|
|
char pnp[5];
|
|
|
|
char serial[13];
|
|
|
|
} edid;
|
|
|
|
|
2014-09-23 05:28:08 -07:00
|
|
|
Ecore_Drm_Backlight *backlight;
|
2015-04-07 09:13:32 -07:00
|
|
|
|
2015-05-06 09:15:56 -07:00
|
|
|
Eina_Bool primary : 1;
|
2015-05-04 11:13:21 -07:00
|
|
|
Eina_Bool connected : 1;
|
2015-04-07 09:13:32 -07:00
|
|
|
Eina_Bool enabled : 1;
|
|
|
|
Eina_Bool cloned : 1;
|
2015-04-07 10:03:28 -07:00
|
|
|
Eina_Bool need_repaint : 1;
|
|
|
|
Eina_Bool repaint_scheduled : 1;
|
|
|
|
Eina_Bool pending_destroy : 1;
|
|
|
|
Eina_Bool pending_flip : 1;
|
|
|
|
Eina_Bool pending_vblank : 1;
|
2014-03-06 01:43:48 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _Ecore_Drm_Seat
|
|
|
|
{
|
|
|
|
// struct libinput_seat *seat;
|
|
|
|
const char *name;
|
|
|
|
Ecore_Drm_Input *input;
|
|
|
|
Eina_List *devices;
|
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
|
|
|
struct
|
|
|
|
{
|
|
|
|
int ix, iy;
|
|
|
|
double dx, dy;
|
|
|
|
} ptr;
|
2014-03-06 01:43:48 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _Ecore_Drm_Input
|
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
Ecore_Drm_Device *dev;
|
2014-12-09 12:11:46 -08:00
|
|
|
struct libinput *libinput;
|
|
|
|
|
|
|
|
Ecore_Fd_Handler *hdlr;
|
2014-03-06 01:43:48 -08:00
|
|
|
|
|
|
|
Eina_Bool enabled : 1;
|
|
|
|
Eina_Bool suspended : 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _Ecore_Drm_Evdev
|
|
|
|
{
|
|
|
|
Ecore_Drm_Seat *seat;
|
2014-12-09 12:11:46 -08:00
|
|
|
struct libinput_device *device;
|
|
|
|
|
|
|
|
const char *path;
|
2014-03-06 01:43:48 -08:00
|
|
|
int fd;
|
|
|
|
|
2014-06-06 08:40:33 -07:00
|
|
|
int mt_slot;
|
|
|
|
|
2015-01-13 07:29:05 -08:00
|
|
|
Ecore_Drm_Output *output;
|
2014-12-10 07:15:10 -08:00
|
|
|
|
2014-12-09 12:11:46 -08:00
|
|
|
/* struct */
|
|
|
|
/* { */
|
|
|
|
/* int min_x, min_y; */
|
|
|
|
/* int max_x, max_y; */
|
|
|
|
/* double rel_w, rel_h; */
|
|
|
|
/* struct */
|
|
|
|
/* { */
|
|
|
|
/* int x[2]; */
|
|
|
|
/* int y[2]; */
|
|
|
|
/* Eina_Bool down : 1; */
|
|
|
|
/* } pt[EVDEV_MAX_SLOTS]; */
|
|
|
|
/* } abs; */
|
2014-03-06 01:43:48 -08:00
|
|
|
|
2014-03-11 01:41:08 -07:00
|
|
|
struct
|
|
|
|
{
|
2015-02-27 07:40:38 -08:00
|
|
|
int ix, iy;
|
2015-04-16 09:47:29 -07:00
|
|
|
int minx, miny, maxw, maxh;
|
2015-02-27 07:40:38 -08:00
|
|
|
double dx, dy;
|
2014-03-11 01:41:08 -07:00
|
|
|
unsigned int last, prev;
|
2015-04-24 10:40:32 -07:00
|
|
|
uint32_t threshold;
|
2014-03-11 01:41:08 -07:00
|
|
|
Eina_Bool did_double : 1;
|
|
|
|
Eina_Bool did_triple : 1;
|
2014-12-09 12:11:46 -08:00
|
|
|
uint32_t prev_button, last_button;
|
2014-03-11 01:41:08 -07:00
|
|
|
} mouse;
|
|
|
|
|
2014-03-10 02:56:00 -07:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
struct xkb_keymap *keymap;
|
|
|
|
struct xkb_state *state;
|
|
|
|
xkb_mod_mask_t ctrl_mask;
|
|
|
|
xkb_mod_mask_t alt_mask;
|
|
|
|
xkb_mod_mask_t shift_mask;
|
|
|
|
xkb_mod_mask_t win_mask;
|
|
|
|
xkb_mod_mask_t scroll_mask;
|
|
|
|
xkb_mod_mask_t num_mask;
|
|
|
|
xkb_mod_mask_t caps_mask;
|
|
|
|
xkb_mod_mask_t altgr_mask;
|
|
|
|
unsigned int modifiers;
|
2014-03-10 06:31:18 -07:00
|
|
|
unsigned int depressed, latched, locked, group;
|
2014-03-10 02:56:00 -07:00
|
|
|
} xkb;
|
|
|
|
|
2015-12-28 06:18:05 -08:00
|
|
|
Eina_Hash *key_remap_hash;
|
|
|
|
Eina_Bool key_remap_enabled : 1;
|
|
|
|
|
2014-12-09 12:11:46 -08:00
|
|
|
/* Ecore_Drm_Evdev_Capabilities caps; */
|
2014-03-06 01:43:48 -08:00
|
|
|
Ecore_Drm_Seat_Capabilities seat_caps;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _Ecore_Drm_Sprite
|
|
|
|
{
|
|
|
|
Ecore_Drm_Fb *current_fb, *next_fb;
|
|
|
|
Ecore_Drm_Output *output;
|
|
|
|
|
|
|
|
int drm_fd;
|
|
|
|
|
|
|
|
unsigned int crtcs;
|
|
|
|
unsigned int plane_id;
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
int x, y;
|
|
|
|
unsigned int w, h;
|
|
|
|
} src, dest;
|
|
|
|
|
|
|
|
unsigned int num_formats;
|
|
|
|
unsigned int formats[];
|
|
|
|
};
|
|
|
|
|
2014-12-09 06:36:42 -08:00
|
|
|
typedef void (*Ecore_Drm_Open_Cb)(void *data, int fd, Eina_Bool b);
|
|
|
|
|
2014-12-10 09:12:21 -08:00
|
|
|
void _ecore_drm_event_activate_send(Eina_Bool active);
|
|
|
|
|
2014-12-09 06:36:42 -08:00
|
|
|
Eina_Bool _ecore_drm_launcher_device_open(const char *device, Ecore_Drm_Open_Cb callback, void *data, int flags);
|
|
|
|
int _ecore_drm_launcher_device_open_no_pending(const char *device, int flags);
|
|
|
|
void _ecore_drm_launcher_device_close(const char *device, int fd);
|
2015-01-22 09:42:06 -08:00
|
|
|
int _ecore_drm_launcher_device_flags_set(int fd, int flags);
|
2014-03-06 01:43:48 -08:00
|
|
|
|
2015-01-05 06:08:27 -08:00
|
|
|
Eina_Bool _ecore_drm_tty_switch(Ecore_Drm_Device *dev, int activate_vt);
|
|
|
|
|
2014-12-09 12:11:46 -08:00
|
|
|
Ecore_Drm_Evdev *_ecore_drm_evdev_device_create(Ecore_Drm_Seat *seat, struct libinput_device *device);
|
2014-03-06 01:43:48 -08:00
|
|
|
void _ecore_drm_evdev_device_destroy(Ecore_Drm_Evdev *evdev);
|
2014-12-09 12:11:46 -08:00
|
|
|
Eina_Bool _ecore_drm_evdev_event_process(struct libinput_event *event);
|
2014-03-06 01:43:48 -08:00
|
|
|
|
|
|
|
Ecore_Drm_Fb *_ecore_drm_fb_create(Ecore_Drm_Device *dev, int width, int height);
|
|
|
|
void _ecore_drm_fb_destroy(Ecore_Drm_Fb *fb);
|
|
|
|
|
|
|
|
void _ecore_drm_output_fb_release(Ecore_Drm_Output *output, Ecore_Drm_Fb *fb);
|
|
|
|
void _ecore_drm_output_repaint_start(Ecore_Drm_Output *output);
|
|
|
|
void _ecore_drm_output_frame_finish(Ecore_Drm_Output *output);
|
2015-04-07 08:08:19 -07:00
|
|
|
void _ecore_drm_outputs_update(Ecore_Drm_Device *dev);
|
2015-05-13 07:19:32 -07:00
|
|
|
void _ecore_drm_output_render_enable(Ecore_Drm_Output *output);
|
|
|
|
void _ecore_drm_output_render_disable(Ecore_Drm_Output *output);
|
2014-03-06 01:43:48 -08:00
|
|
|
|
2015-01-22 09:42:06 -08:00
|
|
|
Eina_Bool _ecore_drm_logind_connect(Ecore_Drm_Device *dev);
|
|
|
|
void _ecore_drm_logind_disconnect(Ecore_Drm_Device *dev);
|
|
|
|
void _ecore_drm_logind_restore(Ecore_Drm_Device *dev);
|
|
|
|
Eina_Bool _ecore_drm_logind_device_open(const char *device, Ecore_Drm_Open_Cb callback, void *data);
|
|
|
|
int _ecore_drm_logind_device_open_no_pending(const char *device);
|
|
|
|
void _ecore_drm_logind_device_close(const char *device);
|
|
|
|
|
|
|
|
int _ecore_drm_dbus_init(Ecore_Drm_Device *dev);
|
|
|
|
int _ecore_drm_dbus_shutdown(void);
|
|
|
|
int _ecore_drm_dbus_device_take(uint32_t major, uint32_t minor, Ecore_Drm_Open_Cb callback, void *data);
|
|
|
|
int _ecore_drm_dbus_device_take_no_pending(uint32_t major, uint32_t minor, Eina_Bool *paused_out, double timeout);
|
|
|
|
void _ecore_drm_dbus_device_release(uint32_t major, uint32_t minor);
|
2015-01-22 10:16:19 -08:00
|
|
|
Eina_Bool _ecore_drm_dbus_session_take(void);
|
|
|
|
Eina_Bool _ecore_drm_dbus_session_release(void);
|
2015-01-22 09:42:06 -08:00
|
|
|
|
ecore-drm: Fix failure of setting/closing evdev->fd which causes fd leak
Summary:
When a input device is plugged in, _cb_open_restricted() is called before creating evdev.
So setting fd value on evdev was failed in _cb_open_restricted() and also closing evdev->fd was invalid.
Using a eina_hash which has 'path-fd' pairs, we can find fd value after evdev is created.
@fix
Test Plan:
(1) Multiple input devices are connected. Their evdev->fd remains zero or initial value.
(2) When one of those devices are plugged out, fd leak would happen.
Reviewers: raster, zmike, gwanglim, stefan_schmidt, devilhorns, ManMower
Subscribers: cedric, jpeg, Jeon, input.hacker
Differential Revision: https://phab.enlightenment.org/D3428
2015-12-15 07:02:49 -08:00
|
|
|
void _ecore_drm_inputs_init(void);
|
|
|
|
void _ecore_drm_inputs_shutdown(void);
|
2014-03-06 01:43:48 -08:00
|
|
|
#endif
|