From patchwork Fri Jan 10 00:01:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clinton Sprain X-Patchwork-Id: 3463881 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 766719F374 for ; Fri, 10 Jan 2014 00:09:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 712FF200F0 for ; Fri, 10 Jan 2014 00:09:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5612E2010B for ; Fri, 10 Jan 2014 00:09:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755551AbaAJAJh (ORCPT ); Thu, 9 Jan 2014 19:09:37 -0500 Received: from mail-ig0-f179.google.com ([209.85.213.179]:34648 "EHLO mail-ig0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753753AbaAJAJd (ORCPT ); Thu, 9 Jan 2014 19:09:33 -0500 Received: by mail-ig0-f179.google.com with SMTP id hk11so9070337igb.0 for ; Thu, 09 Jan 2014 16:09:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=41hxsRsQXsBvQ6nGG/ztsnTkDofAXCWZskc25CSg1hg=; b=sokhnUHx/2lHbw8tmSYuskYnWC7J4WcPfpuL6iPSn4koCxp81VdBVWaaz+HZ9hj95r PpPqrznuwuTsDwiunE+3n3RkIm6kATMatD1Rdws5/lw8OFu4JBnZ1HL7XdXRDvpbau/d +YccqIQtzPv/RzwVHBoiKGRcdHpxW8k1YBZ77KoXkoHhQbPZK6jV7y6XFLsm+Rcc1Vbf ORFpPdZA6STH+JydlbUfuTB8L5TmnSAKf0q7+nB+Kgc4Pf6G3JyzfT2aDoiOWeyNoyb5 qPkBFlodr0RoRdQS6HrkKzv6G7S9Ek5J0pKSAXiHMt84qeiBarVDGXtS857/etf/24O7 BpKw== X-Received: by 10.50.159.194 with SMTP id xe2mr41449781igb.13.1389312092418; Thu, 09 Jan 2014 16:01:32 -0800 (PST) Received: from [10.105.1.106] (pat-wlanguest-a.epic.com. [199.204.56.140]) by mx.google.com with ESMTPSA id ft2sm10493793igb.5.2014.01.09.16.01.31 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 09 Jan 2014 16:01:31 -0800 (PST) Message-ID: <52CF385A.9050109@gmail.com> Date: Thu, 09 Jan 2014 18:01:30 -0600 From: Clinton Sprain User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: linux-input@vger.kernel.org CC: Dmitry Torokhov , Henrik Rydberg Subject: [PATCH 1/2] input: appletouch: parametrize and set saner defaults for fuzz and threshold References: <52CF37E1.3030809@gmail.com> In-Reply-To: <52CF37E1.3030809@gmail.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Clinton Sprain Dials back the default fuzz and threshold settings for most devices using this driver, based on values from user feedback from forums and bug reports. This increases smoothness and movement granularity. No changes were made for the older devices that use the driver, as I did not find any user feedback for them regarding these settings; however, the two settings can also now both be specified as module parameters in case there is a desire to change the values for devices that do not have new defaults. There are also a couple of style cleanups per checkpatch.pl. Signed-off-by: Clinton Sprain --- drivers/input/mouse/appletouch.c | 66 ++++++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 24 deletions(-) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/input/mouse/appletouch.c b/drivers/input/mouse/appletouch.c index e42f1fa..ba6bbd7 100644 --- a/drivers/input/mouse/appletouch.c +++ b/drivers/input/mouse/appletouch.c @@ -43,12 +43,14 @@ */ struct atp_info { int xsensors; /* number of X sensors */ - int xsensors_17; /* 17" models have more sensors */ + int xsensors_17; /* 17" model has more sensors */ int ysensors; /* number of Y sensors */ int xfact; /* X multiplication factor */ int yfact; /* Y multiplication factor */ int datalen; /* size of USB transfers */ void (*callback)(struct urb *); /* callback function */ + int fuzz; /* fuzz touchpad generates */ + int threshold; /* sensitivity threshold */ }; static void atp_complete_geyser_1_2(struct urb *urb); @@ -62,6 +64,8 @@ static const struct atp_info fountain_info = { .yfact = 43, .datalen = 81, .callback = atp_complete_geyser_1_2, + .fuzz = 16, + .threshold = 5, }; static const struct atp_info geyser1_info = { @@ -72,6 +76,8 @@ static const struct atp_info geyser1_info = { .yfact = 43, .datalen = 81, .callback = atp_complete_geyser_1_2, + .fuzz = 16, + .threshold = 5, }; static const struct atp_info geyser2_info = { @@ -82,6 +88,8 @@ static const struct atp_info geyser2_info = { .yfact = 43, .datalen = 64, .callback = atp_complete_geyser_1_2, + .fuzz = 0, + .threshold = 3, }; static const struct atp_info geyser3_info = { @@ -91,6 +99,8 @@ static const struct atp_info geyser3_info = { .yfact = 64, .datalen = 64, .callback = atp_complete_geyser_3_4, + .fuzz = 0, + .threshold = 3, }; static const struct atp_info geyser4_info = { @@ -100,6 +110,8 @@ static const struct atp_info geyser4_info = { .yfact = 64, .datalen = 64, .callback = atp_complete_geyser_3_4, + .fuzz = 0, + .threshold = 2, }; #define ATP_DEVICE(prod, info) \ @@ -156,18 +168,9 @@ MODULE_DEVICE_TABLE(usb, atp_table); #define ATP_XSENSORS 26 #define ATP_YSENSORS 16 -/* amount of fuzz this touchpad generates */ -#define ATP_FUZZ 16 - /* maximum pressure this driver will report */ #define ATP_PRESSURE 300 -/* - * Threshold for the touchpad sensors. Any change less than ATP_THRESHOLD is - * ignored. - */ -#define ATP_THRESHOLD 5 - /* Geyser initialization constants */ #define ATP_GEYSER_MODE_READ_REQUEST_ID 1 #define ATP_GEYSER_MODE_WRITE_REQUEST_ID 9 @@ -213,14 +216,16 @@ struct atp { struct work_struct work; }; -#define dbg_dump(msg, tab) \ +#define dbg_dump(msg, tab) \ +{ \ if (debug > 1) { \ int __i; \ printk(KERN_DEBUG "appletouch: %s", msg); \ for (__i = 0; __i < ATP_XSENSORS + ATP_YSENSORS; __i++) \ printk(" %02x", tab[__i]); \ printk("\n"); \ - } + } \ +} #define dprintk(format, a...) \ do { \ @@ -236,14 +241,20 @@ MODULE_AUTHOR("Sven Anders"); MODULE_DESCRIPTION("Apple PowerBook and MacBook USB touchpad driver"); MODULE_LICENSE("GPL"); -/* - * Make the threshold a module parameter - */ -static int threshold = ATP_THRESHOLD; +static int threshold = -1; module_param(threshold, int, 0644); MODULE_PARM_DESC(threshold, "Discard any change in data from a sensor" " (the trackpad has many of these sensors)" - " less than this value."); + " less than this value. Devices have defaults;" + " this parameter overrides them."); +static int fuzz = -1; + +module_param(fuzz, int, 0644); +MODULE_PARM_DESC(fuzz, "Fuzz the trackpad generates. The higher" + " this is, the less sensitive the trackpad" + " will feel, but values too low may generate" + " random movement. Devices have defaults;" + " this parameter overrides them."); static int debug; module_param(debug, int, 0644); @@ -363,7 +374,8 @@ static int atp_calculate_abs(int *xy_sensors, int nb_sensors, int fact, (!is_increasing && xy_sensors[i - 1] < xy_sensors[i])) { (*fingers)++; is_increasing = 1; - } else if (i > 0 && (xy_sensors[i - 1] - xy_sensors[i] > threshold)) { + } else if (i > 0 && (xy_sensors[i - 1] - + xy_sensors[i] > threshold)) { is_increasing = 0; } @@ -456,7 +468,7 @@ static void atp_detect_size(struct atp *dev) input_set_abs_params(dev->input, ABS_X, 0, (dev->info->xsensors_17 - 1) * dev->info->xfact - 1, - ATP_FUZZ, 0); + fuzz, 0); break; } } @@ -513,7 +525,8 @@ static void atp_complete_geyser_1_2(struct urb *urb) /* Y values */ dev->xy_cur[ATP_XSENSORS + i] = dev->data[5 * i + 1]; - dev->xy_cur[ATP_XSENSORS + i + 8] = dev->data[5 * i + 3]; + dev->xy_cur[ATP_XSENSORS + i + 8] = + dev->data[5 * i + 3]; } } @@ -809,12 +822,17 @@ static int atp_probe(struct usb_interface *iface, dev->info = info; dev->overflow_warned = false; + if (fuzz < 0) + fuzz = dev->info->fuzz; + if (threshold < 0) + threshold = dev->info->threshold; + dev->urb = usb_alloc_urb(0, GFP_KERNEL); if (!dev->urb) goto err_free_devs; - dev->data = usb_alloc_coherent(dev->udev, dev->info->datalen, GFP_KERNEL, - &dev->urb->transfer_dma); + dev->data = usb_alloc_coherent(dev->udev, dev->info->datalen, + GFP_KERNEL, &dev->urb->transfer_dma); if (!dev->data) goto err_free_urb; @@ -844,10 +862,10 @@ static int atp_probe(struct usb_interface *iface, input_set_abs_params(input_dev, ABS_X, 0, (dev->info->xsensors - 1) * dev->info->xfact - 1, - ATP_FUZZ, 0); + fuzz, 0); input_set_abs_params(input_dev, ABS_Y, 0, (dev->info->ysensors - 1) * dev->info->yfact - 1, - ATP_FUZZ, 0); + fuzz, 0); input_set_abs_params(input_dev, ABS_PRESSURE, 0, ATP_PRESSURE, 0, 0); set_bit(EV_KEY, input_dev->evbit);