From patchwork Fri Sep 10 17:14:10 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henrik Rydberg X-Patchwork-Id: 64440 X-Patchwork-Delegate: leann.ogasawara@canonical.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id 5953FB70FF for ; Sat, 11 Sep 2010 03:17:05 +1000 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.69) (envelope-from ) id 1Ou7Dg-0004Nm-7d; Fri, 10 Sep 2010 18:17:00 +0100 Received: from ch-smtp01.sth.basefarm.net ([80.76.149.212]) by chlorine.canonical.com with esmtp (Exim 4.69) (envelope-from ) id 1Ou7De-0004Nh-P9 for kernel-team@lists.ubuntu.com; Fri, 10 Sep 2010 18:16:58 +0100 Received: from c83-248-196-134.bredband.comhem.se ([83.248.196.134]:53525 helo=alnilam) by ch-smtp01.sth.basefarm.net with smtp (Exim 4.71) (envelope-from ) id 1Ou7BP-0001zH-4Y for kernel-team@lists.ubuntu.com; Fri, 10 Sep 2010 19:14:43 +0200 Received: by alnilam (sSMTP sendmail emulation); Fri, 10 Sep 2010 19:14:39 +0200 From: "Henrik Rydberg" To: kernel-team@lists.ubuntu.com Subject: [PATCH 04/13] Input: wacom - collect device quirks into single function Date: Fri, 10 Sep 2010 19:14:10 +0200 Message-Id: <1284138859-32673-5-git-send-email-rydberg@euromail.se> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1284138859-32673-1-git-send-email-rydberg@euromail.se> References: <1284138859-32673-1-git-send-email-rydberg@euromail.se> X-Originating-IP: 83.248.196.134 X-Scan-Result: No virus found in message 1Ou7BP-0001zH-4Y. X-Scan-Signature: ch-smtp01.sth.basefarm.net 1Ou7BP-0001zH-4Y 9045285ca288b3616f6e40bfe44d2d82 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: kernel-team-bounces@lists.ubuntu.com Errors-To: kernel-team-bounces@lists.ubuntu.com Collect device-specific code into a single function, and use quirks to flag specific behavior instead. Signed-off-by: Henrik Rydberg Acked-by: Ping Cheng Signed-off-by: Dmitry Torokhov --- drivers/input/tablet/wacom.h | 1 + drivers/input/tablet/wacom_sys.c | 11 +++-------- drivers/input/tablet/wacom_wac.c | 16 ++++++++++++++++ drivers/input/tablet/wacom_wac.h | 4 ++++ 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/drivers/input/tablet/wacom.h b/drivers/input/tablet/wacom.h index 284dfaa..de5adb1 100644 --- a/drivers/input/tablet/wacom.h +++ b/drivers/input/tablet/wacom.h @@ -118,6 +118,7 @@ struct wacom { extern const struct usb_device_id wacom_ids[]; void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len); +void wacom_setup_device_quirks(struct wacom_features *features); void wacom_setup_input_capabilities(struct input_dev *input_dev, struct wacom_wac *wacom_wac); #endif diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c index 98cba08..fc6fd53 100644 --- a/drivers/input/tablet/wacom_sys.c +++ b/drivers/input/tablet/wacom_sys.c @@ -381,12 +381,6 @@ static int wacom_retrieve_hid_descriptor(struct usb_interface *intf, if (error) goto out; - /* touch device found but size is not defined. use default */ - if (features->device_type == BTN_TOOL_DOUBLETAP && !features->x_max) { - features->x_max = 1023; - features->y_max = 1023; - } - out: return error; } @@ -522,10 +516,11 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i if (error) goto fail2; + wacom_setup_device_quirks(features); + strlcpy(wacom_wac->name, features->name, sizeof(wacom_wac->name)); - if (features->type == TABLETPC || features->type == TABLETPC2FG || - features->type == BAMBOO_PT) { + if (features->quirks & WACOM_QUIRK_MULTI_INPUT) { /* Append the device type to the name */ strlcat(wacom_wac->name, features->device_type == BTN_TOOL_PEN ? diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c index 38516bb..eb73fa6 100644 --- a/drivers/input/tablet/wacom_wac.c +++ b/drivers/input/tablet/wacom_wac.c @@ -904,6 +904,22 @@ static void wacom_setup_intuos(struct wacom_wac *wacom_wac) input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0); } + +void wacom_setup_device_quirks(struct wacom_features *features) +{ + + /* touch device found but size is not defined. use default */ + if (features->device_type == BTN_TOOL_DOUBLETAP && !features->x_max) { + features->x_max = 1023; + features->y_max = 1023; + } + + /* these device have multiple inputs */ + if (features->type == TABLETPC || features->type == TABLETPC2FG || + features->type == BAMBOO_PT) + features->quirks |= WACOM_QUIRK_MULTI_INPUT; +} + void wacom_setup_input_capabilities(struct input_dev *input_dev, struct wacom_wac *wacom_wac) { diff --git a/drivers/input/tablet/wacom_wac.h b/drivers/input/tablet/wacom_wac.h index 88ac589..986223a 100644 --- a/drivers/input/tablet/wacom_wac.h +++ b/drivers/input/tablet/wacom_wac.h @@ -38,6 +38,9 @@ #define WACOM_REPORT_TPC1FG 6 #define WACOM_REPORT_TPC2FG 13 +/* device quirks */ +#define WACOM_QUIRK_MULTI_INPUT 0x0001 + enum { PENPARTNER = 0, GRAPHIRE, @@ -78,6 +81,7 @@ struct wacom_features { int y_fuzz; int pressure_fuzz; int distance_fuzz; + unsigned quirks; }; struct wacom_shared {