README | 20 ++ configure.ac | 25 --- man/mutouch.man | 2 src/Makefile.am | 2 src/xf86MuTouch.c | 447 ++++++++++++++++++++---------------------------------- 5 files changed, 198 insertions(+), 298 deletions(-)
New commits: commit 42d5a96fc6cd69f3b787b5030386e0bcbb9b0cab Author: Peter Hutterer <[email protected]> Date: Tue Jun 28 11:32:14 2011 +1000 mutouch 1.3.0 Signed-off-by: Peter Hutterer <[email protected]> diff --git a/configure.ac b/configure.ac index f070450..9aaaa07 100644 --- a/configure.ac +++ b/configure.ac @@ -22,7 +22,7 @@ AC_PREREQ(2.57) AC_INIT([xf86-input-mutouch], - 1.2.99, + 1.3.0, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xf86-input-mutouch) commit 7efc947e3cb2fe254f5b44bd1a0f4629fb777a95 Author: Peter Hutterer <[email protected]> Date: Tue Jun 28 00:57:57 2011 +1000 Don't reset the stored device's private Storing references to the finger/stylus pInfo is dangerous as-is, but accessing them during the UnInit is suboptimal. This pInfo may have been freed already. Signed-off-by: Peter Hutterer <[email protected]> diff --git a/src/xf86MuTouch.c b/src/xf86MuTouch.c index d382b19..290fa11 100644 --- a/src/xf86MuTouch.c +++ b/src/xf86MuTouch.c @@ -1044,8 +1044,6 @@ xf86MuTUninit(InputDriverPtr drv, MuTPrivatePtr priv = (MuTPrivatePtr) pInfo->private; if (priv) { - priv->stylus->private = NULL; - priv->finger->private = NULL; free(priv->input_dev); free(priv); pInfo->private = NULL; commit d23472b709fafd48f8403e6ea97918c06cc3caaf Author: Peter Hutterer <[email protected]> Date: Tue Jun 28 00:45:11 2011 +1000 Don't free pInfo in Uninit. Just free priv, reset the pointer to NULL and let the server do the rest. Signed-off-by: Peter Hutterer <[email protected]> diff --git a/src/xf86MuTouch.c b/src/xf86MuTouch.c index aaf16df..d382b19 100644 --- a/src/xf86MuTouch.c +++ b/src/xf86MuTouch.c @@ -1048,9 +1048,8 @@ xf86MuTUninit(InputDriverPtr drv, priv->finger->private = NULL; free(priv->input_dev); free(priv); + pInfo->private = NULL; } - free(pInfo->name); - free(pInfo); xf86DeleteInput(pInfo, 0); } commit 9aaaf67f5e0bb7419c24df041a75bb93e2f7c601 Author: Peter Hutterer <[email protected]> Date: Tue Jun 28 00:43:18 2011 +1000 Don't call DEVICE_OFF during Uninit The server will do it for us before anyway. Signed-off-by: Peter Hutterer <[email protected]> diff --git a/src/xf86MuTouch.c b/src/xf86MuTouch.c index 01fb684..aaf16df 100644 --- a/src/xf86MuTouch.c +++ b/src/xf86MuTouch.c @@ -1043,8 +1043,6 @@ xf86MuTUninit(InputDriverPtr drv, { MuTPrivatePtr priv = (MuTPrivatePtr) pInfo->private; - xf86MuTControl(pInfo->dev, DEVICE_OFF); - if (priv) { priv->stylus->private = NULL; priv->finger->private = NULL; commit 041959f3fcdc473cb92437227522b2e986a1055e Author: Peter Hutterer <[email protected]> Date: Tue Jun 28 00:38:38 2011 +1000 Don't free pInfo on PreInit failure. The server does it for us. Make sure we reset the private pointer to NULL though. Signed-off-by: Peter Hutterer <[email protected]> diff --git a/src/xf86MuTouch.c b/src/xf86MuTouch.c index 15b4d51..01fb684 100644 --- a/src/xf86MuTouch.c +++ b/src/xf86MuTouch.c @@ -1232,9 +1232,7 @@ xf86MuTInit(InputDriverPtr drv, free(priv->input_dev); } free(priv); - } - if (pInfo) { - free(pInfo); + pInfo->private = NULL; } return rc; } commit ea50c9d3a593d6dd2a45a12b39fe9c248ea25309 Author: Peter Hutterer <[email protected]> Date: Tue Jun 28 00:37:45 2011 +1000 Require server 1.10 instead of manual ABI checks. Signed-off-by: Peter Hutterer <[email protected]> diff --git a/configure.ac b/configure.ac index a252306..f070450 100644 --- a/configure.ac +++ b/configure.ac @@ -57,7 +57,7 @@ XORG_DRIVER_CHECK_EXT(RANDR, randrproto) XORG_DRIVER_CHECK_EXT(XINPUT, inputproto) # Checks for pkg-config packages -PKG_CHECK_MODULES(XORG, [xorg-server >= 1.9.0] xproto $REQUIRED_MODULES) +PKG_CHECK_MODULES(XORG, [xorg-server >= 1.10.0] xproto $REQUIRED_MODULES) sdkdir=$(pkg-config --variable=sdkdir xorg-server) # Checks for libraries. diff --git a/src/xf86MuTouch.c b/src/xf86MuTouch.c index 5ef11e8..15b4d51 100644 --- a/src/xf86MuTouch.c +++ b/src/xf86MuTouch.c @@ -59,9 +59,6 @@ #include "xf86Module.h" -#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12 -#error "Need server with input ABI 12" -#endif /* *************************************************************************** * commit 29c3cb19938df97fd4a968ac010f48a2e25a3b72 Author: Peter Hutterer <[email protected]> Date: Tue Jun 28 00:35:13 2011 +1000 s/MicroTouch/MuTouch I don't know what the difference is but we had a microtouch driver. Having this driver spit out MicroTouch error messages is suboptimal. Signed-off-by: Peter Hutterer <[email protected]> diff --git a/src/xf86MuTouch.c b/src/xf86MuTouch.c index cc9dcb3..5ef11e8 100644 --- a/src/xf86MuTouch.c +++ b/src/xf86MuTouch.c @@ -25,7 +25,7 @@ ******************************************************************************* ******************************************************************************* * - * This driver is able to deal with MicroTouch serial controllers using + * This driver is able to deal with MuTouch serial controllers using * firmware set 2. This includes (but may not be limited to) Serial/SMT3 * and TouchPen controllers. The only data format supported is Mode Tablet * as it is the only available with these controllers. Anyway this is not a big @@ -270,7 +270,7 @@ xf86MuTReadInput(InputInfoPtr pInfo) (char *) (priv->rec_buf + priv->num_old_bytes), MuT_BUFFER_SIZE - priv->num_old_bytes)); if (num_bytes < 0) { - Error("System error while reading from MicroTouch touchscreen."); + Error("System error while reading from MuTouch touchscreen."); return; } @@ -355,7 +355,7 @@ xf86MuTReadInput(InputInfoPtr pInfo) if (!whinged) { whinged++; - ErrorF("MicroTouch screen sent %s event, but that device is not configured.\n", + ErrorF("MuTouch screen sent %s event, but that device is not configured.\n", (state & MuT_WHICH_DEVICE)?"stylus":"finger"); ErrorF("You might want to consider altering your config accordingly.\n"); } @@ -430,7 +430,7 @@ xf86MuTSendPacket(unsigned char *packet, packet[5], packet[6], packet[7], packet[8], packet[9])); SYSCALL(result = write(fd, packet, len+2)); if (result != len+2) { - DBG(5, ErrorF("System error while sending to MicroTouch touchscreen.\n")); + DBG(5, ErrorF("System error while sending to MuTouch touchscreen.\n")); return !Success; } else { @@ -486,7 +486,7 @@ xf86MuTGetReply(unsigned char *buffer, * Okay, give up. */ if (num_bytes < 0) { - Error("System error while reading from MicroTouch touchscreen."); + Error("System error while reading from MuTouch touchscreen."); return !Success; } DBG(4, ErrorF("Read %d bytes of reply\n", num_bytes)); @@ -624,7 +624,7 @@ xf86MuTPrintIdent(unsigned char *packet) { int vers, rev; - xf86Msg(X_PROBED, "MicroTouch touchscreen is a "); + xf86Msg(X_PROBED, "MuTouch touchscreen is a "); if (strncmp((char *) &packet[1], MuT_TOUCH_PEN_IDENT, 2) == 0) { xf86Msg(X_NONE, "TouchPen"); } @@ -636,7 +636,7 @@ xf86MuTPrintIdent(unsigned char *packet) } xf86Msg(X_NONE, ", connected through a serial port.\n"); sscanf((char *) &packet[3], "%2d%2d", &vers, &rev); - xf86Msg(X_PROBED, "MicroTouch controller firmware revision is %d.%d.\n", vers, rev); + xf86Msg(X_PROBED, "MuTouch controller firmware revision is %d.%d.\n", vers, rev); } @@ -652,7 +652,7 @@ xf86MuTPrintIdent(unsigned char *packet) static void xf86MuTPrintHwStatus(unsigned char *packet) { - xf86Msg(X_PROBED, "MicroTouch status of errors: %c%c.\n", packet[7], packet[8]); + xf86Msg(X_PROBED, "MuTouch status of errors: %c%c.\n", packet[7], packet[8]); } @@ -696,7 +696,7 @@ xf86MuTControl(DeviceIntPtr dev, case DEVICE_INIT: { - DBG(2, ErrorF("MicroTouch %s init...\n", id_string)); + DBG(2, ErrorF("MuTouch %s init...\n", id_string)); if (priv->screen_no >= screenInfo.numScreens || priv->screen_no < 0) { @@ -762,7 +762,7 @@ xf86MuTControl(DeviceIntPtr dev, Bool already_open = FALSE; char *report_what = ""; - DBG(2, ErrorF("MicroTouch %s on...\n", id_string)); + DBG(2, ErrorF("MuTouch %s on...\n", id_string)); /* * Try to see if the port has already been opened either @@ -789,10 +789,10 @@ xf86MuTControl(DeviceIntPtr dev, } if (!already_open) { - DBG(2, ErrorF("MicroTouch touchscreen opening : %s\n", priv->input_dev)); + DBG(2, ErrorF("MuTouch touchscreen opening : %s\n", priv->input_dev)); pInfo->fd = xf86OpenSerial(pInfo->options); if (pInfo->fd < 0) { - Error("Unable to open MicroTouch touchscreen device"); + Error("Unable to open MuTouch touchscreen device"); return !Success; } memset(req, 0, MuT_PACKET_SIZE); @@ -809,7 +809,7 @@ xf86MuTControl(DeviceIntPtr dev, strncpy((char *) &req[1], MuT_OUTPUT_IDENT, strlen(MuT_OUTPUT_IDENT)); if (xf86MuTSendCommand(req, strlen(MuT_OUTPUT_IDENT), reply, pInfo->fd) != Success) { - ErrorF("Unable to ask MicroTouch touchscreen identification\n"); + ErrorF("Unable to ask MuTouch touchscreen identification\n"); goto not_success; } xf86MuTPrintIdent(reply); @@ -817,7 +817,7 @@ xf86MuTControl(DeviceIntPtr dev, strncpy((char *) &req[1], MuT_UNIT_TYPE, strlen(MuT_UNIT_TYPE)); if (xf86MuTSendCommand(req, strlen(MuT_UNIT_TYPE), reply, pInfo->fd) != Success) { - ErrorF("Unable to ask MicroTouch touchscreen status\n"); + ErrorF("Unable to ask MuTouch touchscreen status\n"); goto not_success; } xf86MuTPrintHwStatus(reply); @@ -829,14 +829,14 @@ xf86MuTControl(DeviceIntPtr dev, strncpy((char *) &req[1], MuT_FORMAT_TABLET, strlen(MuT_FORMAT_TABLET)); if (xf86MuTSendCommand(req, strlen(MuT_FORMAT_TABLET), NULL, pInfo->fd) != Success) { - ErrorF("Unable to switch MicroTouch touchscreen to Tablet Format\n"); + ErrorF("Unable to switch MuTouch touchscreen to Tablet Format\n"); goto not_success; } memset(req, 0, MuT_PACKET_SIZE); strncpy((char *) &req[1], MuT_MODE_STREAM, strlen(MuT_MODE_STREAM)); if (xf86MuTSendCommand(req, strlen(MuT_MODE_STREAM), NULL, pInfo->fd) != Success) { - ErrorF("Unable to switch MicroTouch touchscreen to Stream Mode\n"); + ErrorF("Unable to switch MuTouch touchscreen to Stream Mode\n"); goto not_success; } @@ -844,7 +844,7 @@ xf86MuTControl(DeviceIntPtr dev, strncpy((char *) &req[1], MuT_PEN_ONLY, strlen(MuT_PEN_ONLY)); if (xf86MuTSendCommand(req, strlen(MuT_PEN_ONLY), NULL, pInfo->fd) != Success) { - ErrorF("Unable to change MicroTouch touchscreen to pen mode\n"); + ErrorF("Unable to change MuTouch touchscreen to pen mode\n"); goto not_success; } /* goto not_success;*/ @@ -876,7 +876,7 @@ xf86MuTControl(DeviceIntPtr dev, memset(req, 0, MuT_PACKET_SIZE); strncpy((char *) &req[1], report_what, strlen(report_what)); if (xf86MuTSendCommand(req, strlen(report_what), NULL, pInfo->fd) != Success) { - ErrorF("Unable to change MicroTouch touchscreen to %s\n", + ErrorF("Unable to change MuTouch touchscreen to %s\n", (strcmp(report_what, MuT_PEN_FINGER) == 0) ? "Pen & Finger" : ((strcmp(report_what, MuT_PEN_ONLY) == 0) ? "Pen Only" : "Finger Only")); goto not_success; @@ -892,7 +892,7 @@ xf86MuTControl(DeviceIntPtr dev, req[2+strlen(MuT_SET_FREQUENCY)] = '0'; req[3+strlen(MuT_SET_FREQUENCY)] = (priv->frequency<=9?'0':'A'-10)+priv->frequency; if (xf86MuTSendCommand(req, strlen((char *) &req[1]), NULL, pInfo->fd) != Success) { - ErrorF("Unable to set MicroTouch ThruGlass frquency to %d\n", priv->frequency); + ErrorF("Unable to set MuTouch ThruGlass frquency to %d\n", priv->frequency); goto not_success; } } @@ -911,7 +911,7 @@ xf86MuTControl(DeviceIntPtr dev, * Deactivate the device. */ case DEVICE_OFF: - DBG(2, ErrorF("MicroTouch %s off...\n", id_string)); + DBG(2, ErrorF("MuTouch %s off...\n", id_string)); dev->public.on = FALSE; DBG(2, ErrorF("Done\n")); return Success; @@ -921,7 +921,7 @@ xf86MuTControl(DeviceIntPtr dev, * Close the port and free all the resources. */ case DEVICE_CLOSE: - DBG(2, ErrorF("MicroTouch %s close...\n", id_string)); + DBG(2, ErrorF("MuTouch %s close...\n", id_string)); dev->public.on = FALSE; if (pInfo->fd >= 0) { xf86RemoveEnabledDevice(pInfo); @@ -1011,7 +1011,7 @@ xf86MuTAllocate(InputDriverPtr drv, static int xf86MuTAllocateFinger(InputDriverPtr drv, InputInfoPtr pInfo) { - int rc = xf86MuTAllocate(drv, pInfo, XI_FINGER, "MicroTouch Finger", FINGER_ID); + int rc = xf86MuTAllocate(drv, pInfo, XI_FINGER, "MuTouch Finger", FINGER_ID); if (rc == Success) { ((MuTPrivatePtr) pInfo->private)->finger = pInfo; @@ -1030,7 +1030,7 @@ xf86MuTAllocateFinger(InputDriverPtr drv, InputInfoPtr pInfo) static int xf86MuTAllocateStylus(InputDriverPtr drv, InputInfoPtr pInfo) { - int rc = xf86MuTAllocate(drv, pInfo, XI_STYLUS, "MicroTouch Stylus", STYLUS_ID); + int rc = xf86MuTAllocate(drv, pInfo, XI_STYLUS, "MuTouch Stylus", STYLUS_ID); if (rc == Success) { ((MuTPrivatePtr) pInfo->private)->stylus = pInfo; @@ -1090,7 +1090,7 @@ xf86MuTInit(InputDriverPtr drv, rc = xf86MuTAllocateStylus(drv, pInfo); } else { - xf86Msg(X_ERROR, "%s: Type field missing in Microtouch module config,\n" + xf86Msg(X_ERROR, "%s: Type field missing in MuTouch module config,\n" "Must be stylus or finger\n", pInfo->name); goto init_err; } @@ -1101,7 +1101,7 @@ xf86MuTInit(InputDriverPtr drv, str = xf86FindOptionValue(pInfo->options, "Device"); if (!str) { - xf86Msg(X_ERROR, "%s: No Device specified in Microtouch module config.\n", + xf86Msg(X_ERROR, "%s: No Device specified in MuTouch module config.\n", pInfo->name); rc = BadValue; goto init_err; @@ -1119,7 +1119,7 @@ xf86MuTInit(InputDriverPtr drv, if ((pInfo != current) && (current->device_control == xf86MuTControl) && (strcmp(((MuTPrivatePtr) (current->private))->input_dev, priv->input_dev) == 0)) { - xf86Msg(X_CONFIG, "MicroTouch config detected a device share between %s and %s\n", + xf86Msg(X_CONFIG, "MuTouch config detected a device share between %s and %s\n", pInfo->name, current->name); free(priv->input_dev); free(priv); @@ -1137,7 +1137,7 @@ xf86MuTInit(InputDriverPtr drv, current = current->next; } if (!current) { - xf86Msg(X_CONFIG, "MicroTouch %s input device: %s\n", pInfo->name, priv->input_dev); + xf86Msg(X_CONFIG, "MuTouch %s input device: %s\n", pInfo->name, priv->input_dev); } /* Process the common options. */ @@ -1147,30 +1147,30 @@ xf86MuTInit(InputDriverPtr drv, if (str) { pInfo->name = strdup(str); } - xf86Msg(X_CONFIG, "Microtouch X device name: %s\n", pInfo->name); + xf86Msg(X_CONFIG, "MuTouch X device name: %s\n", pInfo->name); priv->screen_no = xf86SetIntOption(pInfo->options, "ScreenNo", 0); - xf86Msg(X_CONFIG, "Microtouch associated screen: %d\n", priv->screen_no); + xf86Msg(X_CONFIG, "MuTouch associated screen: %d\n", priv->screen_no); priv->max_x = xf86SetIntOption(pInfo->options, "MaxX", 3000); - xf86Msg(X_CONFIG, "Microtouch maximum x position: %d\n", priv->max_x); + xf86Msg(X_CONFIG, "MuTouch maximum x position: %d\n", priv->max_x); priv->min_x = xf86SetIntOption(pInfo->options, "MinX", 0); - xf86Msg(X_CONFIG, "Microtouch minimum x position: %d\n", priv->min_x); + xf86Msg(X_CONFIG, "MuTouch minimum x position: %d\n", priv->min_x); priv->max_y = xf86SetIntOption(pInfo->options, "MaxY", 3000); - xf86Msg(X_CONFIG, "Microtouch maximum y position: %d\n", priv->max_y); + xf86Msg(X_CONFIG, "MuTouch maximum y position: %d\n", priv->max_y); priv->min_y = xf86SetIntOption(pInfo->options, "MinY", 0); - xf86Msg(X_CONFIG, "Microtouch minimum y position: %d\n", priv->min_y); + xf86Msg(X_CONFIG, "MuTouch minimum y position: %d\n", priv->min_y); priv->frequency = xf86SetIntOption(pInfo->options, "Frequency", 0); - xf86Msg(X_CONFIG, "Microtouch ThruGlass frequency is: %d\n", priv->frequency); + xf86Msg(X_CONFIG, "MuTouch ThruGlass frequency is: %d\n", priv->frequency); priv->swap_axes = xf86SetBoolOption(pInfo->options, "SwapXY", 0); if (priv->swap_axes) { - xf86Msg(X_CONFIG, "Microtouch %s device will work with X and Y axes swapped\n", + xf86Msg(X_CONFIG, "MuTouch %s device will work with X and Y axes swapped\n", pInfo->name); } debug_level = xf86SetIntOption(pInfo->options, "DebugLevel", 0); if (debug_level) { #if DEBUG - xf86Msg(X_CONFIG, "Microtouch debug level sets to %d\n", debug_level); + xf86Msg(X_CONFIG, "MuTouch debug level sets to %d\n", debug_level); #else - xf86Msg(X_INFO, "Microtouch debug not available\n"); + xf86Msg(X_INFO, "MuTouch debug not available\n"); #endif } str = xf86SetStrOption(pInfo->options, "PortraitMode", "Landscape"); @@ -1181,14 +1181,14 @@ xf86MuTInit(InputDriverPtr drv, portrait = -1; } else if (strcmp(str, "Landscape") != 0) { - xf86Msg(X_ERROR, "Microtouch portrait mode should be: Portrait, Landscape or PortraitCCW"); + xf86Msg(X_ERROR, "MuTouch portrait mode should be: Portrait, Landscape or PortraitCCW"); str = "Landscape"; } - xf86Msg(X_CONFIG, "Microtouch device will work in %s mode\n", str); + xf86Msg(X_CONFIG, "MuTouch device will work in %s mode\n", str); if (priv->max_x - priv->min_x <= 0) { int tmp; - xf86Msg(X_INFO, "MicroTouch: reverse x mode (minimum x position >= maximum x position)\n"); + xf86Msg(X_INFO, "MuTouch: reverse x mode (minimum x position >= maximum x position)\n"); tmp = priv->max_x; /* X server doesn't do inverted by itself*/ priv->max_x = priv->min_x; priv->min_x = tmp; @@ -1198,7 +1198,7 @@ xf86MuTInit(InputDriverPtr drv, if (priv->max_y - priv->min_y <= 0) { int tmp; - xf86Msg(X_INFO, "MicroTouch: reverse y mode (minimum y position >= maximum y position)\n"); + xf86Msg(X_INFO, "MuTouch: reverse y mode (minimum y position >= maximum y position)\n"); tmp = priv->max_y; priv->max_y = priv->min_y; priv->min_y = tmp; commit 7de3fd29eaa2f7532658f706ee0471dde34f16d6 Author: Julien Cristau <[email protected]> Date: Sat Apr 17 16:07:29 2010 +0200 Don't clobber CFLAGS CFLAGS is a user variable, don't set it from configure. diff --git a/configure.ac b/configure.ac index 4b0e04d..a252306 100644 --- a/configure.ac +++ b/configure.ac @@ -60,9 +60,6 @@ XORG_DRIVER_CHECK_EXT(XINPUT, inputproto) PKG_CHECK_MODULES(XORG, [xorg-server >= 1.9.0] xproto $REQUIRED_MODULES) sdkdir=$(pkg-config --variable=sdkdir xorg-server) -CFLAGS="$CFLAGS $XORG_CFLAGS "' -I$(top_srcdir)/src' -AC_SUBST([CFLAGS]) - # Checks for libraries. # Checks for header files. diff --git a/src/Makefile.am b/src/Makefile.am index 5ddc0b7..194d9c6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -29,3 +29,5 @@ @DRIVER_NAME@_drv_ladir = @inputdir@ @DRIVER_NAME@_drv_la_SOURCES = xf86MuTouch.c + +AM_CFLAGS = $(XORG_CFLAGS) commit 24029451c591d324fc6e4a64d0bba70841bb1725 Author: Peter Hutterer <[email protected]> Date: Fri Dec 3 09:07:38 2010 +1000 Support input ABI 12 Signed-off-by: Peter Hutterer <[email protected]> Reviewed-by: Cyril Brulebois <[email protected]> diff --git a/src/xf86MuTouch.c b/src/xf86MuTouch.c index 4312256..cc9dcb3 100644 --- a/src/xf86MuTouch.c +++ b/src/xf86MuTouch.c @@ -59,6 +59,9 @@ #include "xf86Module.h" +#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12 +#error "Need server with input ABI 12" +#endif /* *************************************************************************** * @@ -727,12 +730,14 @@ xf86MuTControl(DeviceIntPtr dev, priv->min_x, priv->max_x, 9500, 0 /* min_res */, - 9500 /* max_res */); + 9500 /* max_res */, + Absolute); InitValuatorAxisStruct(dev, 1, axis_labels[1], priv->min_y, priv->max_y, 10500, 0 /* min_res */, - 10500 /* max_res */); + 10500 /* max_res */, + Absolute); } if (InitFocusClassDeviceStruct(dev) == FALSE) { @@ -953,26 +958,17 @@ xf86MuTControl(DeviceIntPtr dev, * *************************************************************************** */ -static InputInfoPtr +static int xf86MuTAllocate(InputDriverPtr drv, + InputInfoPtr pInfo, char *name, char *type_name, int flag) { - InputInfoPtr pInfo = xf86AllocateInput(drv, 0); MuTPrivatePtr priv = (MuTPrivatePtr) malloc(sizeof(MuTPrivateRec)); - if (!pInfo) { - if (priv) { - free(priv); - } - return NULL; - } if (!priv) { - if (pInfo) { - free(pInfo); - } - return NULL; + return BadAlloc; } priv->input_dev = strdup(MuT_PORT); @@ -992,19 +988,16 @@ xf86MuTAllocate(InputDriverPtr drv, priv->frequency = 0; priv->device_type = flag; - pInfo->name = name; pInfo->flags = 0 /* XI86_NO_OPEN_ON_INIT */; pInfo->device_control = xf86MuTControl; pInfo->read_input = xf86MuTReadInput; pInfo->control_proc = NULL; pInfo->switch_mode = NULL; pInfo->fd = -1; - pInfo->atom = 0; - pInfo->dev = NULL; pInfo->private = priv; pInfo->type_name = type_name; - return pInfo; + return Success; } @@ -1015,15 +1008,15 @@ xf86MuTAllocate(InputDriverPtr drv, * *************************************************************************** */ -static InputInfoPtr -xf86MuTAllocateFinger(InputDriverPtr drv) +static int +xf86MuTAllocateFinger(InputDriverPtr drv, InputInfoPtr pInfo) { - InputInfoPtr pInfo = xf86MuTAllocate(drv, XI_FINGER, "MicroTouch Finger", FINGER_ID); + int rc = xf86MuTAllocate(drv, pInfo, XI_FINGER, "MicroTouch Finger", FINGER_ID); - if (pInfo) { + if (rc == Success) { ((MuTPrivatePtr) pInfo->private)->finger = pInfo; } - return pInfo; + return rc; } @@ -1034,15 +1027,15 @@ xf86MuTAllocateFinger(InputDriverPtr drv) * *************************************************************************** */ -static InputInfoPtr -xf86MuTAllocateStylus(InputDriverPtr drv) +static int +xf86MuTAllocateStylus(InputDriverPtr drv, InputInfoPtr pInfo) { - InputInfoPtr pInfo = xf86MuTAllocate(drv, XI_STYLUS, "MicroTouch Stylus", STYLUS_ID); + int rc = xf86MuTAllocate(drv, pInfo, XI_STYLUS, "MicroTouch Stylus", STYLUS_ID); - if (pInfo) { + if (rc == Success) { ((MuTPrivatePtr) pInfo->private)->stylus = pInfo; } - return pInfo; + return rc; } @@ -1067,7 +1060,7 @@ xf86MuTUninit(InputDriverPtr drv, xf86DeleteInput(pInfo, 0); } -static const char *default_options[] = { +static char *default_options[] = { "BaudRate", "9600", "StopBits", "1", "DataBits", "8", @@ -1078,49 +1071,39 @@ static const char *default_options[] = { NULL }; -static InputInfoPtr +static int xf86MuTInit(InputDriverPtr drv, - IDevPtr dev, + InputInfoPtr pInfo, int flags) { - InputInfoPtr pInfo=NULL, fake_pInfo=NULL, current; + InputInfoPtr current; MuTPrivatePtr priv=NULL; char *str; int portrait=0; + int rc = Success; - fake_pInfo = (InputInfoPtr) calloc(1, sizeof(InputInfoRec)); - if (!fake_pInfo) { - goto init_err; - } - fake_pInfo->conf_idev = dev; - - xf86CollectInputOptions(fake_pInfo, default_options, NULL); - - str = xf86FindOptionValue(fake_pInfo->options, "Type"); + str = xf86FindOptionValue(pInfo->options, "Type"); if (str && (xf86NameCmp(str, "finger") == 0)) { - pInfo = xf86MuTAllocateFinger(drv); + rc = xf86MuTAllocateFinger(drv, pInfo); } else if (str && (xf86NameCmp(str, "stylus") == 0)) { - pInfo = xf86MuTAllocateStylus(drv); + rc = xf86MuTAllocateStylus(drv, pInfo); } else { xf86Msg(X_ERROR, "%s: Type field missing in Microtouch module config,\n" - "Must be stylus or finger\n", dev->identifier); + "Must be stylus or finger\n", pInfo->name); goto init_err; } - if (!pInfo) { + if (rc != Success) { goto init_err; } priv = pInfo->private; - pInfo->options = fake_pInfo->options; - pInfo->conf_idev = fake_pInfo->conf_idev; - free(fake_pInfo); - fake_pInfo = NULL; str = xf86FindOptionValue(pInfo->options, "Device"); if (!str) { xf86Msg(X_ERROR, "%s: No Device specified in Microtouch module config.\n", - dev->identifier); + pInfo->name); + rc = BadValue; goto init_err; } priv->input_dev = strdup(str); @@ -1244,14 +1227,9 @@ xf86MuTInit(InputDriverPtr drv, priv->swap_axes = (priv->swap_axes==0) ? 1 : 0; } - /* mark the device configured */ - pInfo->flags |= XI86_CONFIGURED; - return pInfo; + return Success; init_err: - if (fake_pInfo) { - free(fake_pInfo); - } if (priv) { if (priv->input_dev) { free(priv->input_dev); @@ -1261,7 +1239,7 @@ xf86MuTInit(InputDriverPtr drv, if (pInfo) { free(pInfo); } - return NULL; + return rc; } _X_EXPORT InputDriverRec MUTOUCH = { @@ -1271,6 +1249,7 @@ _X_EXPORT InputDriverRec MUTOUCH = { xf86MuTInit, /* pre-init */ xf86MuTUninit, /* un-init */ NULL, /* module */ + default_options, }; static pointer commit f7c4418ae0313b35d528fe28cfaf7899bc96e029 Author: Peter Hutterer <[email protected]> Date: Fri Dec 3 09:06:16 2010 +1000 Replace use of private_flags with driver-internal device_type. private_flags is removed in input ABI 12 but it's not needed anyway. Signed-off-by: Peter Hutterer <[email protected]> Reviewed-by: Cyril Brulebois <[email protected]> diff --git a/src/xf86MuTouch.c b/src/xf86MuTouch.c index 2cc8398..4312256 100644 --- a/src/xf86MuTouch.c +++ b/src/xf86MuTouch.c @@ -196,7 +196,7 @@ static int debug_level = 0; */ #define FINGER_ID 1 #define STYLUS_ID 2 -#define DEVICE_ID(flags) ((flags) & 0x03) +#define DEVICE_ID(pInfo) (((MuTPrivatePtr)(pInfo)->private)->device_type) typedef struct _MuTPrivateRec { char *input_dev; /* The touchscreen input tty */ @@ -217,6 +217,7 @@ typedef struct _MuTPrivateRec { InputInfoPtr stylus; /* Stylus device ptr associated with the hw. */ int swap_axes; /* Swap X an Y axes if != 0 */ unsigned char rec_buf[MuT_BUFFER_SIZE]; /* Receive buffer. */ + int device_type; /* FINGER_ID or STYLUS_ID */ } MuTPrivateRec, *MuTPrivatePtr; @@ -684,7 +685,7 @@ xf86MuTControl(DeviceIntPtr dev, unsigned char map[] = { 0, 1 }; unsigned char req[MuT_PACKET_SIZE]; unsigned char reply[MuT_BUFFER_SIZE]; - char *id_string = DEVICE_ID(pInfo->private_flags) == FINGER_ID ? "finger" : "stylus"; + char *id_string = DEVICE_ID(pInfo) == FINGER_ID ? "finger" : "stylus"; Atom btn_label; Atom axis_labels[2] = { 0, 0 }; @@ -766,7 +767,7 @@ xf86MuTControl(DeviceIntPtr dev, already_open = TRUE; } else { - switch (DEVICE_ID(pInfo->private_flags)) { + switch (DEVICE_ID(pInfo)) { case FINGER_ID: if (priv->stylus && priv->stylus->fd >= 0) { already_open = TRUE; @@ -849,7 +850,7 @@ xf86MuTControl(DeviceIntPtr dev, * Select Pen / Finger reports depending on which devices are * currently on. */ - switch (DEVICE_ID(pInfo->private_flags)) { + switch (DEVICE_ID(pInfo)) { case FINGER_ID: if (priv->stylus && priv->stylus->dev->public.on) { report_what = MuT_PEN_FINGER; @@ -924,7 +925,7 @@ xf86MuTControl(DeviceIntPtr dev, /* * Need some care to close the port only once. */ - switch (DEVICE_ID(pInfo->private_flags)) { + switch (DEVICE_ID(pInfo)) { case FINGER_ID: if (priv->stylus) { priv->stylus->fd = -1; @@ -989,6 +990,7 @@ xf86MuTAllocate(InputDriverPtr drv, priv->finger = NULL; priv->swap_axes = 0; priv->frequency = 0; + priv->device_type = flag; pInfo->name = name; pInfo->flags = 0 /* XI86_NO_OPEN_ON_INIT */; @@ -1000,7 +1002,6 @@ xf86MuTAllocate(InputDriverPtr drv, pInfo->atom = 0; pInfo->dev = NULL; pInfo->private = priv; - pInfo->private_flags = flag; pInfo->type_name = type_name; return pInfo; @@ -1140,7 +1141,7 @@ xf86MuTInit(InputDriverPtr drv, free(priv->input_dev); free(priv); priv = pInfo->private = current->private; - switch (DEVICE_ID(pInfo->private_flags)) { + switch (DEVICE_ID(pInfo)) { case FINGER_ID: priv->finger = pInfo; break; commit 3390adfb0c4cec5914a1c4e05bb95a6140fe6d31 Author: Peter Hutterer <[email protected]> Date: Thu Dec 2 15:42:33 2010 +1000 Drop driver-specific motion history size handling. Signed-off-by: Peter Hutterer <[email protected]> Reviewed-by: Cyril Brulebois <[email protected]> diff --git a/src/xf86MuTouch.c b/src/xf86MuTouch.c index 445b3e2..2cc8398 100644 --- a/src/xf86MuTouch.c +++ b/src/xf86MuTouch.c @@ -717,7 +717,7 @@ xf86MuTControl(DeviceIntPtr dev, * screen to fit one meter. */ if (InitValuatorClassDeviceStruct(dev, 2, axis_labels, - pInfo->history_size, Absolute) == FALSE) { + GetMotionHistorySize(), Absolute) == FALSE) { ErrorF("Unable to allocate ValuatorClassDeviceStruct\n"); return !Success; } @@ -1002,7 +1002,6 @@ xf86MuTAllocate(InputDriverPtr drv, pInfo->private = priv; pInfo->private_flags = flag; pInfo->type_name = type_name; - pInfo->history_size = 0; return pInfo; } commit 9c887eceeb7f6bb1f9005bc2aeedeaa0a5d77ec4 Author: Peter Hutterer <[email protected]> Date: Thu Dec 2 15:42:11 2010 +1000 Drop close_proc, conversion_proc, reverse_conversion_proc All three are not called by the server anymore. Signed-off-by: Peter Hutterer <[email protected]> Reviewed-by: Cyril Brulebois <[email protected]> diff --git a/src/xf86MuTouch.c b/src/xf86MuTouch.c index d733e4a..445b3e2 100644 --- a/src/xf86MuTouch.c +++ b/src/xf86MuTouch.c @@ -220,62 +220,6 @@ typedef struct _MuTPrivateRec { } MuTPrivateRec, *MuTPrivatePtr; - - -/* - *************************************************************************** - * - * xf86MuTConvert -- - * Convert extended valuators to x and y suitable for core motion - * events. Return True if ok and False if the requested conversion - * can't be done for the specified valuators. - * - *************************************************************************** - */ -static Bool -xf86MuTConvert(InputInfoPtr pInfo, - int first, - int num, - int v0, - int v1, - int v2, - int v3, - int v4, - int v5, - int *x, - int *y) -{ - MuTPrivatePtr priv = (MuTPrivatePtr) pInfo->private; - int width = priv->max_x - priv->min_x; - int height = priv->max_y - priv->min_y; - int input_x, input_y; - - if (first != 0 || num != 2) - return FALSE; - - if (priv->swap_axes) { - input_x = v1; - input_y = v0; - } - else { - input_x = v0; - input_y = v1; - } - *x = (priv->screen_width * (input_x - priv->min_x)) / width; - *y = (priv->screen_height - - (priv->screen_height * (input_y - priv->min_y)) / height); - - /* - * Need to check if still on the correct screen. - * This call is here so that this work can be done after - * calib and before posting the event. - */ - xf86XInputSetScreen(pInfo, priv->screen_no, *x, *y); - - return TRUE; -} - - /* *************************************************************************** * @@ -1051,10 +995,7 @@ xf86MuTAllocate(InputDriverPtr drv, pInfo->device_control = xf86MuTControl; pInfo->read_input = xf86MuTReadInput; pInfo->control_proc = NULL; - pInfo->close_proc = NULL; pInfo->switch_mode = NULL; - pInfo->conversion_proc = xf86MuTConvert; - pInfo->reverse_conversion_proc = NULL; pInfo->fd = -1; pInfo->atom = 0; pInfo->dev = NULL; commit 69ea6552035603f1813c80caa14cd8fba2778102 Author: Peter Hutterer <[email protected]> Date: Thu Dec 2 15:38:46 2010 +1000 Drop libc wrappers for free, malloc Signed-off-by: Peter Hutterer <[email protected]> Reviewed-by: Cyril Brulebois <[email protected]> diff --git a/src/xf86MuTouch.c b/src/xf86MuTouch.c index 6215e15..d733e4a 100644 --- a/src/xf86MuTouch.c +++ b/src/xf86MuTouch.c @@ -800,7 +800,7 @@ xf86MuTControl(DeviceIntPtr dev, xf86MotionHistoryAllocate(pInfo); /* - * This once has caused the server to crash after doing an xalloc & strcpy ?? + * This once has caused the server to crash after doing an malloc & strcpy ?? */ DBG(2, ErrorF("Done.\n")); @@ -1015,17 +1015,17 @@ xf86MuTAllocate(InputDriverPtr drv, int flag) -- To UNSUBSCRIBE, email to [email protected] with a subject of "unsubscribe". Trouble? Contact [email protected] Archive: http://lists.debian.org/[email protected]

