Commit f9a06538 authored by Henrik Rydberg's avatar Henrik Rydberg Committed by Peter Hutterer

ReadDevDimensions on opened device

The auto-dev probing requires opening the device locally to determine the type of device, so
that the right protocol can be assigned. However, all other setup work should be performed
during initialization of the assigned and opened device. This patch moves the
read-device-dimensions functionality from some special cases during the probe process to
the initialization routine, where it can be used for all supported devices.
Signed-off-by: Henrik Rydberg's avatarHenrik Rydberg <rydberg@euromail.se>
Signed-off-by: default avatarPeter Hutterer <peter.hutterer@redhat.com>
parent 3097bb31
......@@ -263,5 +263,5 @@ struct SynapticsProtocolOperations alps_proto_operations = {
ALPSQueryHardware,
ALPSReadHwState,
ALPSAutoDevProbe,
NULL /* ProbeDevice */
NULL /* ReadDevDimensions */
};
......@@ -110,13 +110,13 @@ event_query_is_touchpad(int fd)
/* Query device for axis ranges */
static void
event_query_axis_ranges(int fd, LocalDevicePtr local)
event_query_axis_ranges(LocalDevicePtr local)
{
SynapticsPrivate *priv = (SynapticsPrivate *)local->private;
struct input_absinfo abs;
int rc;
SYSCALL(rc = ioctl(fd, EVIOCGABS(ABS_X), &abs));
SYSCALL(rc = ioctl(local->fd, EVIOCGABS(ABS_X), &abs));
if (rc == 0)
{
xf86Msg(X_INFO, "%s: x-axis range %d - %d\n", local->name,
......@@ -127,7 +127,7 @@ event_query_axis_ranges(int fd, LocalDevicePtr local)
xf86Msg(X_ERROR, "%s: failed to query axis range (%s)\n", local->name,
strerror(errno));
SYSCALL(rc = ioctl(fd, EVIOCGABS(ABS_Y), &abs));
SYSCALL(rc = ioctl(local->fd, EVIOCGABS(ABS_Y), &abs));
if (rc == 0)
{
xf86Msg(X_INFO, "%s: y-axis range %d - %d\n", local->name,
......@@ -306,28 +306,13 @@ static int EventDevOnly(const struct dirent *dir) {
}
/**
* Probe the given device name for axis ranges, if appropriate.
* Probe the open device for dimensions.
*/
static Bool
EventProbeDevice(LocalDevicePtr local, char* device)
static void
EventReadDevDimensions(LocalDevicePtr local)
{
int fd;
SYSCALL(fd = open(device, O_RDONLY));
if (fd < 0)
goto out;
if (!event_query_is_touchpad(fd))
goto out;
event_query_axis_ranges(fd, local);
out:
if (fd >= 0)
SYSCALL(close(fd));
/* Always return TRUE, PreInit will complain for us if necessary */
return TRUE;
if (event_query_is_touchpad(local->fd))
event_query_axis_ranges(local);
}
static Bool
......@@ -367,7 +352,6 @@ EventAutoDevProbe(LocalDevicePtr local)
local->name, fname);
local->options =
xf86ReplaceStrOption(local->options, "Device", fname);
event_query_axis_ranges(fd, local);
}
SYSCALL(close(fd));
}
......@@ -388,5 +372,5 @@ struct SynapticsProtocolOperations event_proto_operations = {
EventQueryHardware,
EventReadHwState,
EventAutoDevProbe,
EventProbeDevice
EventReadDevDimensions
};
......@@ -759,5 +759,5 @@ struct SynapticsProtocolOperations psaux_proto_operations = {
PS2QueryHardware,
PS2ReadHwState,
PS2AutoDevProbe,
NULL /* ProbeDevice */
NULL /* ReadDevDimensions */
};
......@@ -178,5 +178,5 @@ struct SynapticsProtocolOperations psm_proto_operations = {
PSMQueryHardware,
PSMReadHwState,
PSMAutoDevProbe,
NULL /* ProbeDevice */
NULL /* ReadDevDimensions */
};
......@@ -125,6 +125,7 @@ static Bool DeviceOn(DeviceIntPtr);
static Bool DeviceOff(DeviceIntPtr);
static Bool DeviceClose(DeviceIntPtr);
static Bool QueryHardware(LocalDevicePtr);
static void ReadDevDimensions(LocalDevicePtr);
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 3
void InitDeviceProperties(LocalDevicePtr local);
......@@ -185,9 +186,7 @@ SetDeviceAndProtocol(LocalDevicePtr local)
}
if (device && strstr(device, "/dev/input/event")) {
#ifdef BUILD_EVENTCOMM
if (event_proto_operations.ProbeDevice &&
event_proto_operations.ProbeDevice(local, device))
proto = SYN_PROTO_EVENT;
proto = SYN_PROTO_EVENT;
#endif
} else {
str_par = xf86FindOptionValue(local->options, "Protocol");
......@@ -533,6 +532,9 @@ SynapticsPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
priv->tap_button_state = TBS_BUTTON_UP;
priv->touch_on.millis = 0;
/* read hardware dimensions */
ReadDevDimensions(local);
/* install shared memory or normal memory for parameters */
priv->shm_config = xf86SetBoolOption(local->options, "SHMConfig", FALSE);
......@@ -2137,6 +2139,15 @@ ConvertProc(LocalDevicePtr local,
}
static void
ReadDevDimensions(LocalDevicePtr local)
{
SynapticsPrivate *priv = (SynapticsPrivate *) local->private;
if (priv->proto_ops->ReadDevDimensions)
priv->proto_ops->ReadDevDimensions(local);
}
static Bool
QueryHardware(LocalDevicePtr local)
{
......
......@@ -96,7 +96,7 @@ struct SynapticsProtocolOperations {
struct SynapticsProtocolOperations *proto_ops,
struct CommData *comm, struct SynapticsHwState *hwRet);
Bool (*AutoDevProbe)(LocalDevicePtr local);
Bool (*ProbeDevice)(LocalDevicePtr local, char* name);
void (*ReadDevDimensions)(LocalDevicePtr local);
};
extern struct SynapticsProtocolOperations psaux_proto_operations;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment