--- src/tslib.c.orig	2011-05-31 02:29:49.000000000 +0200
+++ src/tslib.c	2011-05-31 03:35:18.000000000 +0200
@@ -106,7 +106,11 @@
 }
 
 static Bool
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
+ConvertProc( InputInfoPtr local,
+#else
 ConvertProc( LocalDevicePtr local,
+#endif
 			 int first,
 			 int num,
 			 int v0,
@@ -135,7 +139,11 @@
     return t;
 }
 
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
+static void ReadInput (InputInfoPtr local)
+#else
 static void ReadInput (LocalDevicePtr local)
+#endif
 {
 	struct ts_priv *priv = (struct ts_priv *) (local->private);
 	struct ts_sample samp;
@@ -382,7 +390,11 @@
 					       axiswidth - 1,	/* max val */
 					       axiswidth,	/* resolution */
 					       0,		/* min_res */
-					       axiswidth);	/* max_res */
+					       axiswidth	/* max_res */
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
+					       ,Absolute
+#endif
+					       );
 
 		InitValuatorAxisStruct(device, 1,
 #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
@@ -392,7 +404,11 @@
 					       axisheight - 1,	/* max val */
 					       axisheight,	/* resolution */
 					       0,		/* min_res */
-					       axisheight);	/* max_res */
+					       axisheight	/* max_res */
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
+					       ,Absolute
+#endif
+					       );
 
 		if (InitProximityClassDeviceStruct (device) == FALSE) {
 			ErrorF ("Unable to allocate EVTouch touchscreen ProximityClassDeviceStruct\n");
@@ -439,53 +455,96 @@
 	xf86DeleteInput(pInfo, 0);
 }
 
+
+/*
+ * xf86TslibPreInit --
+ *
+ * replacement for xf86TslibInit.
+ */
+static int
+xf86TslibPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags);
+
 /*
  * xf86TslibInit --
  *
  * called when the module subsection is found in XF86Config
  */
-static InputInfoPtr
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12
+static IinputInfoPtr
 xf86TslibInit(InputDriverPtr drv, IDevPtr dev, int flags)
 {
-	struct ts_priv *priv;
-	char *s;
 	InputInfoPtr pInfo;
 
-	priv = xcalloc (1, sizeof (struct ts_priv));
-        if (!priv)
-                return NULL;
-
-	if (!(pInfo = xf86AllocateInput(drv, 0))) {
-		xfree(priv);
+	if (!(pInfo = xf86AllocateInput(drv, 0)))
 		return NULL;
-	}
 
 	/* Initialise the InputInfoRec. */
 	pInfo->name = dev->identifier;
-	pInfo->type_name = XI_TOUCHSCREEN;
 	pInfo->flags =
 	    XI86_KEYBOARD_CAPABLE | XI86_POINTER_CAPABLE |
 	    XI86_SEND_DRAG_EVENTS;
-	pInfo->device_control = xf86TslibControlProc;
-	pInfo->read_input = ReadInput;
+	pInfo->close_proc = NULL;
+	pInfo->conversion_proc = ConvertProc;
+	pInfo->reverse_conversion_proc = NULL;
 #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) == 0
 	pInfo->motion_history_proc = xf86GetMotionEvents;
 	pInfo->history_size = 0;
 #endif
-	pInfo->control_proc = NULL;
-	pInfo->close_proc = NULL;
-	pInfo->switch_mode = NULL;
-	pInfo->conversion_proc = ConvertProc;
-	pInfo->reverse_conversion_proc = NULL;
-	pInfo->dev = NULL;
 	pInfo->private_flags = 0;
 	pInfo->always_core_feedback = 0;
 	pInfo->conf_idev = dev;
-	pInfo->private = priv;
+	/* FIXME: Is initialization to 0 needed? */
+	pInfo->control_proc = NULL;
+	pInfo->switch_mode = NULL;
+	pInfo->dev = NULL;
 
 	/* Collect the options, and process the common options. */
 	xf86CollectInputOptions(pInfo, NULL, NULL);
 	xf86ProcessCommonOptions(pInfo, pInfo->options);
+ 	
+	/*
+	 * FIXME: is true dev->commonOptions == pInfo->options ?
+	 * if not similar rutine below in xf86TslibPreInit will fail!
+	 * In case of failre is necesary do some hacking. ...
+	s = xf86CheckStrOption(dev->commonOptions, "path", NULL);
+  	if (!s)
+		s = xf86CheckStrOption(dev->commonOptions, "Device", NULL);
+	*/
+
+	if (xf86TslibPreInit(drv, pInfo, flags) == Success)
+	{
+		/* Mark the device configured */
+		pInfo->flags |= XI86_CONFIGURED;
+		/* Return the configured device */
+		return (pInfo);
+	}
+	
+	xf86DeleteInput(pInfo, 0);
+	return NULL;
+}
+#else
+static int
+xf86TslibInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
+{
+	return xf86TslibPreInit(drv, pInfo, flags);
+}
+#endif
+
+static int
+xf86TslibPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
+{
+	int rc = BadAlloc;
+	char *s;
+	struct ts_priv *priv;
+
+	priv = calloc (1, sizeof (struct ts_priv));
+        if (!priv)
+		goto error;
+
+	pInfo->type_name = XI_TOUCHSCREEN;
+	pInfo->device_control = xf86TslibControlProc;
+	pInfo->read_input = ReadInput;
+	pInfo->private = priv;
 
 	priv->screen_num = xf86SetIntOption(pInfo->options, "ScreenNumber", 0 );
 
@@ -510,23 +569,22 @@
 		priv->rotate = TSLIB_ROTATE_NONE;
 	}
 
- 	s = xf86CheckStrOption(dev->commonOptions, "path", NULL);
+ 	s = xf86CheckStrOption(pInfo->options, "path", NULL);
   	if (!s)
-		s = xf86CheckStrOption(dev->commonOptions, "Device", NULL);
+		s = xf86CheckStrOption(pInfo->options, "Device", NULL);
  
 	priv->ts = ts_open(s, 1);
-	xfree(s);
+	free(s);
 
+	rc = BadMatch;
 	if (!priv->ts) {
 		ErrorF("ts_open failed (device=%s)\n",s);
-		xf86DeleteInput(pInfo, 0);
-		return NULL;
+		goto error;
 	}
 
 	if (ts_config(priv->ts)) {
 		ErrorF("ts_config failed\n");
-		xf86DeleteInput(pInfo, 0);
-		return NULL;
+		goto error;
 	}
 
 	pInfo->fd = ts_fd(priv->ts);
@@ -536,11 +594,14 @@
 		priv->state = BUTTON_EMULATION_OFF;
 	}
 
-	/* Mark the device configured */
-	pInfo->flags |= XI86_CONFIGURED;
+	return Success;
+
+error:
+	if (pInfo->private)
+		free(pInfo->private);
+	pInfo->private = NULL;
 
-	/* Return the configured device */
-	return (pInfo);
+	return rc;
 }
 
 _X_EXPORT InputDriverRec TSLIB_DRIVER = {
