+++ /dev/null
-/*
- * xserver-xorg-input-evdev-multitouch
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Sung-Jin Park <sj76.park@samsung.com>
- * Sangjin LEE <lsj119@samsung.com>
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of Red Hat
- * not be used in advertising or publicity pertaining to distribution
- * of the software without specific, written prior permission. Red
- * Hat makes no representations about the suitability of this software
- * for any purpose. It is provided "as is" without express or implied
- * warranty.
- *
- * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
- * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef _SYNC_DEBUG_H
-#define _SYNC_DEBUG_H
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/shm.h>
-#include <sys/ipc.h>
-#include <sys/ioctl.h>
-#include <time.h>
-#include <sys/time.h>
-#include <stdarg.h>
-#include <semaphore.h>
-
-#ifdef __GNUC__
-#define MAY_NOT_BE_USED __attribute__ ((unused))
-#else
-#define MAY_NOT_BE_USED
-#endif
-
-
-#define SYNC_DEBUG_SHM_KEY 0xDEAD2012
-#define SHM_MESG_SIZE ( 1024 * 1024 )
-
-#ifndef CLOCK_MONOTONIC
-#define CLOCK_MONOTONIC 1
-#endif
-
-typedef struct {
- int initialized;
-
- sem_t sem;
-
- int count;
-
- int cur_pos;
-
- int isLogging;
-
- int isPrintEnabled;
-
- unsigned long tvStart;
-
- int _shmid;
-
- char debug_msg[0];
-} VSYNC_DEBUG_INFO;
-
-static volatile VSYNC_DEBUG_INFO * _vsync_debug = NULL;
-
-static int
-_vsync_debug_init(void)
-{
- int shmid = 0;
-
- struct shmid_ds ds;
-
- shmid = shmget(SYNC_DEBUG_SHM_KEY, SHM_MESG_SIZE, IPC_CREAT | IPC_RMID);
- if (shmid < 0)
- {
- fprintf(stderr, "\tError : shmget size:%d\n", SHM_MESG_SIZE);
- goto bail;
- }
-
- if (shmctl(shmid, IPC_STAT, &ds) < 0)
- {
- fprintf(stderr, "\tError : shmctl\n");
- goto bail;
- }
-
- if (ds.shm_segsz < SHM_MESG_SIZE)
- {
- fprintf(stderr, "\tError : size check\n");
- goto bail;
- }
-
- _vsync_debug = shmat(shmid, NULL, 0);
- if (_vsync_debug == (void *) -1)
- {
- fprintf(stderr, "\tError : shmat\n");
- goto bail;
- }
-
- return shmid;
-
-bail:
- fprintf(stderr, "VSYNC_DEBUG.... Error\n");
-
- if (_vsync_debug != NULL && _vsync_debug != (void *) -1)
- shmdt((void*)_vsync_debug);
-
- return -1;
-}
-
-static unsigned long
-_vsync_debug_get_time(void)
-{
- struct timespec tp;
-
- if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
- return (tp.tv_sec * 1000) + (tp.tv_nsec / 1000000L);
-
- return 0;
-}
-
-static void
-_vsync_debug_lock(void)
-{
- if (sem_wait((sem_t *) &_vsync_debug->sem) < 0)
- fprintf(stderr, "sem_wait error\n");
-}
-
-
-static void
-_vsync_debug_unlock(void)
-{
- if (sem_post((sem_t *) &_vsync_debug->sem) < 0)
- fprintf(stderr, "sem_post error\n");
-}
-
-static void
-_vsync_debug_set_slot(int isSync, const char * format, va_list args)
-{
- unsigned long cur_time;
-
- if (_vsync_debug == NULL)
- _vsync_debug_init();
-
- if (!_vsync_debug->initialized)
- return;
-
- if (! _vsync_debug->isLogging)
- return;
-
- if (!_vsync_debug->isPrintEnabled)
- return;
-
- if (_vsync_debug->cur_pos > SHM_MESG_SIZE - 1024)
- return;
-
- cur_time = _vsync_debug_get_time();
-
- _vsync_debug_lock();
-
- if (isSync)
- {
- _vsync_debug->count++;
- _vsync_debug->cur_pos += sprintf((char *) _vsync_debug->debug_msg + _vsync_debug->cur_pos, "\e[32m");
-
- }
- _vsync_debug->cur_pos += sprintf((char *) _vsync_debug->debug_msg + _vsync_debug->cur_pos, "%6ld ", cur_time);
- _vsync_debug->cur_pos += vsprintf((char *) _vsync_debug->debug_msg + _vsync_debug->cur_pos, format, args);
- _vsync_debug->debug_msg[_vsync_debug->cur_pos++] = '\n';
- _vsync_debug->debug_msg[_vsync_debug->cur_pos] = '\0';
-
- if (isSync)
- _vsync_debug->cur_pos += sprintf((char *) _vsync_debug->debug_msg + _vsync_debug->cur_pos, "\e[0m");
-
- _vsync_debug_unlock();
-}
-
-static void MAY_NOT_BE_USED
-vsync_debug_start(void)
-{
- if (_vsync_debug == NULL)
- _vsync_debug_init();
-
- if (!_vsync_debug->initialized)
- return;
-
- _vsync_debug->isLogging = 1;
- _vsync_debug->tvStart = _vsync_debug_get_time();
-}
-
-static void MAY_NOT_BE_USED
-vsync_debug_stop(void)
-{
- unsigned long tvStop;
-
- if (_vsync_debug == NULL)
- _vsync_debug_init();
-
- if (!_vsync_debug->initialized)
- return;
-
- _vsync_debug->isLogging = 0;
- tvStop = _vsync_debug_get_time();
-
- _vsync_debug_lock();
- if (_vsync_debug->isPrintEnabled)
- {
- //Print Debug
- fprintf(stderr, "VSYNC DEBUG: count:%d, start:%6ld, end:%6ld\n", _vsync_debug->count, _vsync_debug->tvStart, tvStop);
- fprintf(stderr, "%s\n", _vsync_debug->debug_msg);
- }
- _vsync_debug->cur_pos = 0;
- _vsync_debug->debug_msg[0] = '\0';
- _vsync_debug_unlock();
-}
-
-static void MAY_NOT_BE_USED
-vsync_debug_set_sync(const char * format, ...)
-{
- va_list args;
-
- va_start(args, format);
-
- _vsync_debug_set_slot(1, format, args);
-
- va_end(args);
-}
-
-static void MAY_NOT_BE_USED
-vsync_debug_set_slot(const char * format, ...)
-{
- va_list args;
-
- va_start(args, format);
-
- _vsync_debug_set_slot(0, format, args);
-
- va_end(args);
-}
-
-static void MAY_NOT_BE_USED
-vsync_debug_set_enable(int bEnable)
-{
- if (_vsync_debug == NULL)
- _vsync_debug_init();
-
- if (!_vsync_debug->initialized)
- return;
-
- _vsync_debug->isPrintEnabled = bEnable;
-}
-
-static void MAY_NOT_BE_USED
-vsync_debug_master_init(void)
-{
- int shmid = _vsync_debug_init();
-
- _vsync_debug->_shmid = shmid;
-
- if (sem_init((sem_t *) &_vsync_debug->sem, 1, 1) < 0)
- {
- fprintf(stderr, "\tError : sem_init\n");
- goto bail;
- }
-
- _vsync_debug->initialized = 1;
-
- return;
-bail:
- fprintf(stderr, "VSYNC_DEBUG.... master Error\n");
-}
-
-static void MAY_NOT_BE_USED
-vsync_debug_master_close(void)
-{
- if (_vsync_debug == NULL)
- return;
-
- if (shmctl(_vsync_debug->_shmid, IPC_RMID, NULL) < 0)
- {
- fprintf(stderr, "\tError : shmctl(IPC_RMID)\n");
- }
- if (shmdt((void*)_vsync_debug) < 0)
- {
- fprintf(stderr, "\tError : shmdt\n");
- }
-
- _vsync_debug = NULL;
-}
-
-#endif /* _SYNC_DEBUG_H */
-
+++ /dev/null
-/*
- * xserver-xorg-input-evdev-multitouch
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Sung-Jin Park <sj76.park@samsung.com>
- * Sangjin LEE <lsj119@samsung.com>
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of Red Hat
- * not be used in advertising or publicity pertaining to distribution
- * of the software without specific, written prior permission. Red
- * Hat makes no representations about the suitability of this software
- * for any purpose. It is provided "as is" without express or implied
- * warranty.
- *
- * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
- * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef _SYNC_INPUT_LIB_H
-#define _SYNC_INPUT_LIB_H
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/shm.h>
-#include <sys/ipc.h>
-
-#define SYNC_INPUT_SHM_KEY 0xDEAD2010
-
-typedef struct {
- /* EVDEVMULTITOUCHh providing functions FBDEV will use */
- void (*sync)(int vsync_cnt);
-
- /* FBDEV providing functions EVDEVMULTITOUCHh will use */
- void * sync_arg;
- void (*start_sync)(void * sync_arg);
- void (*stop_sync)(void * sync_arg);
-
- /* for internal use only */
- int _shmid;
-
- int _reserved[16];
-} VSYNC_INPUT_DISPATCH_TABLE;
-
-static volatile VSYNC_INPUT_DISPATCH_TABLE *
-vsync_input_init(void)
-{
- VSYNC_INPUT_DISPATCH_TABLE * table = NULL;
- int shmid = 0;
-
- struct shmid_ds ds;
-
- shmid = shmget(SYNC_INPUT_SHM_KEY, sizeof(VSYNC_INPUT_DISPATCH_TABLE), IPC_CREAT);
- if (shmid < 0)
- goto bail;
-
- if (shmctl(shmid, IPC_STAT, &ds) < 0)
- goto bail;
-
- if (ds.shm_segsz < sizeof(VSYNC_INPUT_DISPATCH_TABLE))
- goto bail;
-
- table = shmat(shmid, NULL, 0);
- if (table == (void *) -1)
- goto bail;
-
- table->_shmid = shmid;
-
- return table;
-
-bail:
- if (shmid >= 0)
- shmctl(shmid, IPC_RMID, NULL);
-
- if (table != NULL && table != (void *) -1)
- shmdt(table);
-
- return NULL;
-}
-
-static int
-#ifdef __GNUC__
-__attribute__ ((unused))
-#endif
-vsync_input_close(volatile VSYNC_INPUT_DISPATCH_TABLE * table)
-{
- if (table == NULL)
- return -1;
-
- shmdt((void *) table);
-
- return 0;
-}
-
-static int
-#ifdef __GNUC__
-__attribute__ ((unused))
-#endif
-vsync_input_destroy(volatile VSYNC_INPUT_DISPATCH_TABLE * table)
-{
- if (table == NULL)
- return -1;
-
- shmctl(table->_shmid, IPC_RMID, NULL);
- shmdt((void *) table);
-
- return 0;
-}
-
-#endif /* _SYNC_INPUT_LIB_H */
#include <xkbsrv.h>
#include "evdevmultitouch.h"
-#include "vsync_input_protocol.h"
-#include "vsync_debug_info.h"
#ifdef HAVE_PROPERTIES
#include <X11/Xatom.h>
NULL
};
-int poll_control(char cmd);
-void sync_poll(int vsync_counter);
#ifdef _F_GESTURE_EXTENSION_
extern void mieqEnqueue(DeviceIntPtr pDev, InternalEvent *e);
static void EvdevMultitouchFrameSync(InputInfoPtr pInfo, MTSyncType sync);
static void EvdevMultitouchProcessEvent(InputInfoPtr pInfo, struct input_event *ev);
static void EvdevMultitouchEndOfMultiTouch(InputInfoPtr pInfo,EvdevMultitouchDataMTPtr pData);
static void EvdevMultitouchSetMultitouch(InputInfoPtr pInfo, int num_multitouch);
-static void EvdevMultitouchSetUsePoll(InputInfoPtr pInfo, BOOL use_poll);
static void EvdevMultitouchGetGrabInfo(InputInfoPtr pInfo, BOOL val);
static void EvdevMultitouchSetResolution(InputInfoPtr pInfo, int num_resolution, int resolution[4]);
static void EvdevMultitouchSetCalibration(InputInfoPtr pInfo, int num_calibration, int calibration[4]);
static Atom prop_btn_label = 0;
static Atom prop_tracking_id = 0;
static Atom prop_multitouch = 0;
-static Atom prop_use_poll = 0;
static Atom prop_transform = 0;
static Atom prop_grabinfo = 0;
#endif
-static InputInfoPtr pCreatorInfo = NULL;
-volatile VSYNC_INPUT_DISPATCH_TABLE *vsync_input_table = NULL;
-
-int g_syspoll_fd = -1;
int g_pressed = 0;
-
-int
-poll_control(char cmd)
-{
- if( g_syspoll_fd < 0 )
- return 0;
-
- write(g_syspoll_fd, &cmd, 1);
-
- return 1;
-}
-
-void
-sync_poll(int vsync_counter)
-{
- if( g_pressed )
- {
- vsync_debug_set_slot("Poll before");
- poll_control(POLL_REQUEST);
- vsync_debug_set_slot("Poll after");
- }
-}
+static InputInfoPtr pCreatorInfo = NULL;
/* All devices the evdevmultitouch driver has allocated and knows about.
* MAXDEVICES is safe as null-terminated array, as two devices (VCP and VCK)
#ifdef _F_GESTURE_EXTENSION_
EvdevMultitouchFrameSync(pInfo, MTOUCH_FRAME_SYNC_BEGIN);
#endif//_F_GESTURE_EXTENSION_
- if(vsync_input_table)
- {
- vsync_input_table->start_sync(vsync_input_table->sync_arg);
- vsync_debug_start();
- }
}
EvdevMultitouchQueueButtonEvent(pSubdev, 1, 1);
pEvdevMultitouchSubdev->touch_state = 1;
if( !num_of_pressed )
{
g_pressed = 0;
- if(vsync_input_table)
- {
- vsync_input_table->stop_sync(vsync_input_table->sync_arg);
- vsync_debug_stop();
- }
}
EvdevMultitouchQueueButtonEvent(pSubdev, 1, 0);
pEvdevMultitouchSubdev->touch_state = 0;
#ifdef _F_GESTURE_EXTENSION_
EvdevMultitouchFrameSync(pInfo, MTOUCH_FRAME_SYNC_BEGIN);
#endif//_F_GESTURE_EXTENSION_
- if(vsync_input_table)
- {
- vsync_input_table->start_sync(vsync_input_table->sync_arg);
- vsync_debug_start();
- }
}
}
else
{
g_pressed = 0;
- if(vsync_input_table)
- {
- vsync_input_table->stop_sync(vsync_input_table->sync_arg);
- vsync_debug_stop();
- }
EvdevMultitouchQueueButtonEvent(pSubdev, 1, 0);
pEvdevMultitouchSubdev->touch_state = 0;
pEvdevMultitouchSubdev->evtime = 0;
} else {
EvdevMultitouchProcessValuators(pInfo, v, &num_v, &first_v);
- vsync_debug_set_slot("Input %d %d %d", 1, v[0], v[1]);
-
EvdevMultitouchPostRelativeMotionEvents(pInfo, &num_v, &first_v, v);
EvdevMultitouchPostAbsoluteMotionEvents(pInfo, &num_v, &first_v, v);
EvdevMultitouchPostQueuedEvents(pInfo, &num_v, &first_v, v);
pEvdevMultitouch->multitouch_setting_timer = TimerSet(pEvdevMultitouch->multitouch_setting_timer, 0, 100, EvdevMultitouchMultitouchSettingTimer, pInfo);
}
- if( pEvdevMultitouch->use_poll != TRUE )
- return Success;
-
- EvdevMultitouchSetUsePoll(pInfo, TRUE);
-
return Success;
}
pInfo = device->public.devicePrivate;
pEvdevMultitouch = pInfo->private;
-
- if( pEvdevMultitouch->use_poll != TRUE )
- return;
-
- EvdevMultitouchSetUsePoll(pInfo, FALSE);
}
static int
break;
}
}
- xf86RemoveEnabledDevice(pInfo);
+ if (pInfo->fd >= 0)
+ {
+ xf86RemoveEnabledDevice(pInfo);
+ }
}
pEvdevMultitouch->min_maj = 0;
pEvdevMultitouch->flags &= ~EVDEVMULTITOUCH_INITIALIZED;
ErrorF("[X11][%s] Failed to Change device property !\n", __FUNCTION__);
}
-static void
-EvdevMultitouchSetUsePoll(InputInfoPtr pInfo, BOOL use_poll)
-{
- EvdevMultitouchPtr pEvdevMultitouch = pInfo->private;
-
- if( use_poll == TRUE )
- {
- if( !EvdevMultitouchIsCoreDevice(pInfo) )//master only
- goto out;
-
- if( !vsync_input_table)
- {
- vsync_input_table = vsync_input_init();
- if( !vsync_input_table )
- {
- ErrorF("[SetUsePoll] Failed to init vsync input ...\n");
- goto out;
- }
- }
-
- g_syspoll_fd = open(SYSFS_POLL, O_WRONLY);
- if( g_syspoll_fd < 0 )
- {
- g_syspoll_fd = -1;
- ErrorF("[SetUsePoll] Failed to open %s ...\n", SYSFS_POLL);
- goto out;
- }
-
- vsync_input_table->sync = sync_poll;
- vsync_input_table->stop_sync(vsync_input_table->sync_arg);
- poll_control(POLL_ENABLE);
- pEvdevMultitouch->use_poll = use_poll;
- }
- else if( use_poll == FALSE )
- {
- if( !EvdevMultitouchIsCoreDevice(pInfo) )//master only
- goto out;
-
- if( !vsync_input_table)
- goto out;
-
- vsync_input_table->stop_sync(vsync_input_table->sync_arg);
- vsync_input_table->sync = NULL;
- vsync_input_close(vsync_input_table);
- vsync_input_table = NULL;
- poll_control(POLL_DISABLE);
- close(g_syspoll_fd);
- g_syspoll_fd = -1;
- pEvdevMultitouch->use_poll = use_poll;
- }
- else
- ErrorF("\n[SetUsePoll] Unknown value for use_poll (%d)\n", use_poll);
-
-out:
- return;
-}
-
Bool
IsMaster(DeviceIntPtr dev)
{
pEvdevMultitouch->invert_y = xf86SetBoolOption(pInfo->options, "InvertY", FALSE);
pEvdevMultitouch->num_multitouch = xf86SetIntOption(pInfo->options, "MultiTouch", 0);
pEvdevMultitouch->swap_axes = xf86SetBoolOption(pInfo->options, "SwapAxes", FALSE);
- pEvdevMultitouch->use_poll = xf86SetBoolOption(pInfo->options, "UsePoll", FALSE);
str = xf86CheckStrOption(pInfo->options, "Calibration", NULL);
if (str) {
if( EvdevMultitouchIsCoreDevice(pInfo) )//master only
{
- /* flag to use poll */
- prop_use_poll = MakeAtom(EVDEVMULTITOUCH_PROP_USE_POLL, strlen(EVDEVMULTITOUCH_PROP_USE_POLL), TRUE);
- rc = XIChangeDeviceProperty(dev, prop_use_poll, XA_INTEGER, 8, PropModeReplace, 1, &pEvdevMultitouch->use_poll, FALSE);
- if (rc != Success)
- return;
-
- XISetDevicePropertyDeletable(dev, prop_use_poll, FALSE);
-
/* matrix to transform */
prop_transform = MakeAtom(EVDEVMULTITOUCH_PROP_TRANSFORM, strlen(EVDEVMULTITOUCH_PROP_TRANSFORM), TRUE);
rc = XIChangeDeviceProperty(dev, prop_transform, XIGetKnownProperty(XATOM_FLOAT), 32, PropModeReplace, 9, pEvdevMultitouch->transform, FALSE);
if (pEvdevMultitouch->num_multitouch != data)
EvdevMultitouchSetMultitouch(pInfo,data);
}
- } else if (atom == prop_use_poll)
- {
- BOOL data;
- if (val->format != 8 || val->type != XA_INTEGER || val->size != 1)
- return BadMatch;
- if (!checkonly) {
- data = *((BOOL*)val->data);
- if (pEvdevMultitouch->use_poll != data)
- EvdevMultitouchSetUsePoll(pInfo,(BOOL)data);
- }
- }
- else if (atom == prop_transform)
+ } else if (atom == prop_transform)
{
float *f;
if (val->format != 32 || val->type != XIGetKnownProperty(XATOM_FLOAT) || val->size != 9)
#define MAX_VALUATORS 36
#endif
-#define MAX_VALUATORS_MT 5 //currently if MAXDEVICES == 40
-
+#define MAX_VALUATORS_MT 10
#define DEFAULT_TIMEOUT 100
#define EVDEVMULTITOUCH_PROP_TRACKING_ID "EvdevMultitouch Tracking ID"
#define EVDEVMULTITOUCH_PROP_MULTITOUCH_SUBDEVICES "EvdevMultitouch MultiTouch"
-#define EVDEVMULTITOUCH_PROP_USE_POLL "EvdevMultitouch Use Poll"
#define EVDEVMULTITOUCH_PROP_TRANSFORM "EvdevMultitouch Transform Matrix"
#define EVDEVMULTITOUCH_PROP_GRABINFO "EvdevMultitouch Grab Info"
BOOL mt_slot_supported;
BOOL sync_mt;
BOOL associated;
- BOOL use_poll;//polling_with_vsync
float transform[9];
BOOL use_transform;