aboutsummaryrefslogtreecommitdiffstats
path: root/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_vsync.c
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2011-10-21 05:40:59 +0000
committerCarsten Haitzler <raster@rasterman.com>2011-10-21 05:40:59 +0000
commit37e2ab21c1b8913922126ca5ce30647051c9b2f3 (patch)
tree7f9bcfc1eb57d67d19e93167529bac1a10671c32 /legacy/ecore/src/lib/ecore_x/xlib/ecore_x_vsync.c
parentran ecrustify on ecore. some manual fixing too. (diff)
downloadefl-37e2ab21c1b8913922126ca5ce30647051c9b2f3.tar.gz
ecrustify on ecore-x.
SVN revision: 64239
Diffstat (limited to 'legacy/ecore/src/lib/ecore_x/xlib/ecore_x_vsync.c')
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_vsync.c182
1 files changed, 103 insertions, 79 deletions
diff --git a/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_vsync.c b/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_vsync.c
index 53a9fb8bf2..f05429885b 100644
--- a/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_vsync.c
+++ b/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_vsync.c
@@ -25,13 +25,13 @@ typedef unsigned int drm_magic_t;
typedef enum
{
- DRM_VBLANK_ABSOLUTE = 0x00000000,
- DRM_VBLANK_RELATIVE = 0x00000001,
- DRM_VBLANK_EVENT = 0x04000000,
- DRM_VBLANK_FLIP = 0x08000000,
- DRM_VBLANK_NEXTONMISS = 0x10000000,
- DRM_VBLANK_SECONDARY = 0x20000000,
- DRM_VBLANK_SIGNAL = 0x40000000
+ DRM_VBLANK_ABSOLUTE = 0x00000000,
+ DRM_VBLANK_RELATIVE = 0x00000001,
+ DRM_VBLANK_EVENT = 0x04000000,
+ DRM_VBLANK_FLIP = 0x08000000,
+ DRM_VBLANK_NEXTONMISS = 0x10000000,
+ DRM_VBLANK_SECONDARY = 0x20000000,
+ DRM_VBLANK_SIGNAL = 0x40000000
}
drmVBlankSeqType;
@@ -61,48 +61,67 @@ typedef union _drmVBlank
typedef struct _drmEventContext
{
int version;
- void (*vblank_handler)(int fd, unsigned int sequence, unsigned int tv_sec, unsigned int tv_usec, void *user_data);
- void (*page_flip_handler)(int fd, unsigned int sequence, unsigned int tv_sec, unsigned int tv_usec, void *user_data);
+ void (*vblank_handler)(int fd,
+ unsigned int sequence,
+ unsigned int tv_sec,
+ unsigned int tv_usec,
+ void *user_data);
+ void (*page_flip_handler)(int fd,
+ unsigned int sequence,
+ unsigned int tv_sec,
+ unsigned int tv_usec,
+ void *user_data);
} drmEventContext;
-static int (*sym_drmClose) (int fd) = NULL;
-static int (*sym_drmGetMagic) (int fd, drm_magic_t * magic) = NULL;
-static int (*sym_drmWaitVBlank) (int fd, drmVBlank *vbl) = NULL;
-static int (*sym_drmHandleEvent) (int fd, drmEventContext *evctx) = NULL;
+static int (*sym_drmClose)(int fd) = NULL;
+static int (*sym_drmGetMagic)(int fd,
+ drm_magic_t *magic) = NULL;
+static int (*sym_drmWaitVBlank)(int fd,
+ drmVBlank *vbl) = NULL;
+static int (*sym_drmHandleEvent)(int fd,
+ drmEventContext *evctx) = NULL;
//// dri
-static Bool (*sym_DRI2QueryExtension) (Display *display, int *eventBase, int *errorBase) = NULL;
-static Bool (*sym_DRI2QueryVersion) (Display *display, int *major, int *minor) = NULL;
-static Bool (*sym_DRI2Connect) (Display *display, XID window, char **driverName, char **deviceName) = NULL;
-static Bool (*sym_DRI2Authenticate) (Display *display, XID window, drm_magic_t magic) = NULL;
-
+static Bool (*sym_DRI2QueryExtension)(Display *display,
+ int *eventBase,
+ int *errorBase) = NULL;
+static Bool (*sym_DRI2QueryVersion)(Display *display,
+ int *major,
+ int *minor) = NULL;
+static Bool (*sym_DRI2Connect)(Display *display,
+ XID window,
+ char **driverName,
+ char **deviceName) = NULL;
+static Bool (*sym_DRI2Authenticate)(Display *display,
+ XID window,
+ drm_magic_t magic) = NULL;
//// dri/drm data needed
-static int dri2_event = 0;
-static int dri2_error = 0;
-static int dri2_major = 0;
-static int dri2_minor = 0;
-static char *device_name = 0;
-static char *driver_name = 0;
-static drm_magic_t drm_magic;
-
-static int drm_fd = -1;
-static int drm_event_is_busy = 0;
-static int drm_animators_interval = 1;
-static drmEventContext drm_evctx;
+static int dri2_event = 0;
+static int dri2_error = 0;
+static int dri2_major = 0;
+static int dri2_minor = 0;
+static char *device_name = 0;
+static char *driver_name = 0;
+static drm_magic_t drm_magic;
+
+static int drm_fd = -1;
+static int drm_event_is_busy = 0;
+static int drm_animators_interval = 1;
+static drmEventContext drm_evctx;
static Ecore_Fd_Handler *dri_drm_fdh = NULL;
-static void *dri_lib = NULL;
-static void *drm_lib = NULL;
+static void *dri_lib = NULL;
+static void *drm_lib = NULL;
-static Window dri_drm_vsync_root = 0;
+static Window dri_drm_vsync_root = 0;
static void
_dri_drm_tick_schedule(void)
{
drmVBlank vbl;
-
+
vbl.request.type = DRM_VBLANK_RELATIVE | DRM_VBLANK_EVENT;
vbl.request.sequence = drm_animators_interval;
vbl.request.signal = 0;
@@ -123,16 +142,19 @@ _dri_drm_tick_end(void *data __UNUSED__)
}
static void
-_dri_drm_vblank_handler(int fd __UNUSED__, unsigned int frame __UNUSED__,
- unsigned int sec __UNUSED__,
- unsigned int usec __UNUSED__, void *data __UNUSED__)
+_dri_drm_vblank_handler(int fd __UNUSED__,
+ unsigned int frame __UNUSED__,
+ unsigned int sec __UNUSED__,
+ unsigned int usec __UNUSED__,
+ void *data __UNUSED__)
{
ecore_animator_custom_tick();
if (drm_event_is_busy) _dri_drm_tick_schedule();
}
static Eina_Bool
-_dri_drm_cb(void *data __UNUSED__, Ecore_Fd_Handler *fd_handler __UNUSED__)
+_dri_drm_cb(void *data __UNUSED__,
+ Ecore_Fd_Handler *fd_handler __UNUSED__)
{
sym_drmHandleEvent(drm_fd, &drm_evctx);
return ECORE_CALLBACK_RENEW;
@@ -146,36 +168,36 @@ static int
_dri_drm_link(void)
{
const char *drm_libs[] =
- {
- "libdrm.so.2",
- "libdrm.so.1",
- "libdrm.so.0",
- "libdrm.so",
- NULL,
- };
+ {
+ "libdrm.so.2",
+ "libdrm.so.1",
+ "libdrm.so.0",
+ "libdrm.so",
+ NULL,
+ };
const char *dri_libs[] =
- {
- "libdri2.so.2",
- "libdri2.so.1",
- "libdri2.so.0",
- "libdri2.so",
- "libGL.so.4",
- "libGL.so.3",
- "libGL.so.2",
- "libGL.so.1",
- "libGL.so.0",
- "libGL.so",
- NULL,
- };
+ {
+ "libdri2.so.2",
+ "libdri2.so.1",
+ "libdri2.so.0",
+ "libdri2.so",
+ "libGL.so.4",
+ "libGL.so.3",
+ "libGL.so.2",
+ "libGL.so.1",
+ "libGL.so.0",
+ "libGL.so",
+ NULL,
+ };
int i, fail;
-#define SYM(lib, xx) \
- do { \
- sym_ ## xx = dlsym(lib, #xx); \
- if (!(sym_ ## xx)) { \
- fprintf(stderr, "%s\n", dlerror()); \
- fail = 1; \
- } \
- } while (0)
+#define SYM(lib, xx) \
+ do { \
+ sym_ ## xx = dlsym(lib, #xx); \
+ if (!(sym_ ## xx)) { \
+ fprintf(stderr, "%s\n", dlerror()); \
+ fail = 1; \
+ } \
+ } while (0)
if (dri_lib) return 1;
for (i = 0; drm_libs[i]; i++)
@@ -227,16 +249,16 @@ static int
_dri_drm_init(void)
{
if (!sym_DRI2QueryExtension(_ecore_x_disp, &dri2_event, &dri2_error))
- return 0;
+ return 0;
if (!sym_DRI2QueryVersion(_ecore_x_disp, &dri2_major, &dri2_minor))
- return 0;
+ return 0;
if (dri2_major < 2)
- return 0;
+ return 0;
if (!sym_DRI2Connect(_ecore_x_disp, dri_drm_vsync_root, &driver_name, &device_name))
- return 0;
+ return 0;
drm_fd = open(device_name, O_RDWR);
if (drm_fd < 0)
- return 0;
+ return 0;
sym_drmGetMagic(drm_fd, &drm_magic);
if (!sym_DRI2Authenticate(_ecore_x_disp, dri_drm_vsync_root, drm_magic))
{
@@ -248,8 +270,8 @@ _dri_drm_init(void)
drm_evctx.version = DRM_EVENT_CONTEXT_VERSION;
drm_evctx.vblank_handler = _dri_drm_vblank_handler;
drm_evctx.page_flip_handler = NULL;
-
- dri_drm_fdh = ecore_main_fd_handler_add(drm_fd, ECORE_FD_READ,
+
+ dri_drm_fdh = ecore_main_fd_handler_add(drm_fd, ECORE_FD_READ,
_dri_drm_cb, NULL, NULL, NULL);
if (!dri_drm_fdh)
{
@@ -274,6 +296,7 @@ _dri_drm_shutdown(void)
dri_drm_fdh = NULL;
}
}
+
#endif
EAPI Eina_Bool
@@ -281,7 +304,7 @@ ecore_x_vsync_animator_tick_source_set(Ecore_X_Window win)
{
#ifdef ECORE_X_VSYNC_DRI2
Ecore_X_Window root;
-
+
root = ecore_x_window_root_get(win);
if (root != dri_drm_vsync_root)
{
@@ -301,9 +324,9 @@ ecore_x_vsync_animator_tick_source_set(Ecore_X_Window win)
return EINA_FALSE;
}
ecore_animator_custom_source_tick_begin_callback_set
- (_dri_drm_tick_begin, NULL);
+ (_dri_drm_tick_begin, NULL);
ecore_animator_custom_source_tick_end_callback_set
- (_dri_drm_tick_end, NULL);
+ (_dri_drm_tick_end, NULL);
ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_CUSTOM);
}
else
@@ -312,9 +335,9 @@ ecore_x_vsync_animator_tick_source_set(Ecore_X_Window win)
{
_dri_drm_shutdown();
ecore_animator_custom_source_tick_begin_callback_set
- (NULL, NULL);
+ (NULL, NULL);
ecore_animator_custom_source_tick_end_callback_set
- (NULL, NULL);
+ (NULL, NULL);
ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_TIMER);
}
}
@@ -323,5 +346,6 @@ ecore_x_vsync_animator_tick_source_set(Ecore_X_Window win)
#else
return EINA_FALSE;
win = 0;
-#endif
+#endif
}
+