From patchwork Fri Sep 10 17:14:17 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henrik Rydberg X-Patchwork-Id: 64433 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 97DB5B7102 for ; Sat, 11 Sep 2010 03:15:23 +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 1Ou7C2-0003mc-Lq; Fri, 10 Sep 2010 18:15:18 +0100 Received: from ch-smtp02.sth.basefarm.net ([80.76.149.213]) by chlorine.canonical.com with esmtp (Exim 4.69) (envelope-from ) id 1Ou7C0-0003ls-FF for kernel-team@lists.ubuntu.com; Fri, 10 Sep 2010 18:15:16 +0100 Received: from c83-248-196-134.bredband.comhem.se ([83.248.196.134]:54298 helo=alnilam) by ch-smtp02.sth.basefarm.net with smtp (Exim 4.68) (envelope-from ) id 1Ou7Bs-0007Og-7L for kernel-team@lists.ubuntu.com; Fri, 10 Sep 2010 19:15:12 +0200 Received: by alnilam (sSMTP sendmail emulation); Fri, 10 Sep 2010 19:15:08 +0200 From: "Henrik Rydberg" To: kernel-team@lists.ubuntu.com Subject: [PATCH 11/13] hid: ntrig: Setup input filtering manually Date: Fri, 10 Sep 2010 19:14:17 +0200 Message-Id: <1284138859-32673-12-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 1Ou7Bs-0007Og-7L. X-Scan-Signature: ch-smtp02.sth.basefarm.net 1Ou7Bs-0007Og-7L bbb0b589874f065e72c9e51443e30ffc 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 The hid core does not set fuzz parameters properly, so take over setup of all input parameters for the multitouch device. Signed-off-by: Henrik Rydberg --- drivers/hid/hid-ntrig.c | 70 ++++++++++++++++++++++++++--------------------- 1 files changed, 39 insertions(+), 31 deletions(-) diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c index fbb68d2..41ba359 100644 --- a/drivers/hid/hid-ntrig.c +++ b/drivers/hid/hid-ntrig.c @@ -24,6 +24,12 @@ #define NTRIG_DUPLICATE_USAGES 0x001 +#define MAX_EVENTS 120 + +#define SN_MOVE_X 128 +#define SN_MOVE_Y 92 +#define SN_MAJOR 48 + static unsigned int min_width; static unsigned int min_height; @@ -83,6 +89,10 @@ static int ntrig_input_mapping(struct hid_device *hdev, struct hid_input *hi, unsigned long **bit, int *max) { struct ntrig_data *nd = hid_get_drvdata(hdev); + struct input_dev *input = hi->input; + int f1 = field->logical_minimum; + int f2 = field->logical_maximum; + int df = f2 - f1; /* No special mappings needed for the pen and single touch */ if (field->physical) @@ -92,12 +102,11 @@ static int ntrig_input_mapping(struct hid_device *hdev, struct hid_input *hi, case HID_UP_GENDESK: switch (usage->hid) { case HID_GD_X: - hid_map_usage(hi, usage, bit, max, - EV_ABS, ABS_MT_POSITION_X); - input_set_abs_params(hi->input, ABS_X, - field->logical_minimum, - field->logical_maximum, 0, 0); - + hid_map_usage(hi, usage, bit, max, EV_ABS, ABS_X); + input_set_abs_params(input, ABS_X, + f1, f2, df / SN_MOVE_X, 0); + input_set_abs_params(input, ABS_MT_POSITION_X, + f1, f2, df / SN_MOVE_X, 0); if (!nd->sensor_logical_width) { nd->sensor_logical_width = field->logical_maximum - @@ -114,12 +123,11 @@ static int ntrig_input_mapping(struct hid_device *hdev, struct hid_input *hi, } return 1; case HID_GD_Y: - hid_map_usage(hi, usage, bit, max, - EV_ABS, ABS_MT_POSITION_Y); - input_set_abs_params(hi->input, ABS_Y, - field->logical_minimum, - field->logical_maximum, 0, 0); - + hid_map_usage(hi, usage, bit, max, EV_ABS, ABS_Y); + input_set_abs_params(input, ABS_Y, + f1, f2, df / SN_MOVE_Y, 0); + input_set_abs_params(input, ABS_MT_POSITION_Y, + f1, f2, df / SN_MOVE_Y, 0); if (!nd->sensor_logical_height) { nd->sensor_logical_height = field->logical_maximum - @@ -145,18 +153,31 @@ static int ntrig_input_mapping(struct hid_device *hdev, struct hid_input *hi, case HID_DG_INPUTMODE: case HID_DG_DEVICEINDEX: case HID_DG_CONTACTMAX: + case HID_DG_CONTACTCOUNT: + case HID_DG_INRANGE: + case HID_DG_CONFIDENCE: return -1; + case HID_DG_TIPSWITCH: + hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH); + input_set_capability(input, EV_KEY, BTN_TOUCH); + return 1; + /* width/height mapped on TouchMajor/TouchMinor/Orientation */ case HID_DG_WIDTH: hid_map_usage(hi, usage, bit, max, EV_ABS, ABS_MT_TOUCH_MAJOR); + input_set_abs_params(input, ABS_MT_TOUCH_MAJOR, + f1, f2, df / SN_MAJOR, 0); return 1; case HID_DG_HEIGHT: hid_map_usage(hi, usage, bit, max, EV_ABS, ABS_MT_TOUCH_MINOR); - input_set_abs_params(hi->input, ABS_MT_ORIENTATION, - 0, 1, 0, 0); + input_set_abs_params(input, ABS_MT_TOUCH_MINOR, + f1, f2, df / SN_MAJOR, 0); + input_set_abs_params(input, ABS_MT_ORIENTATION, + 0, 1, 0, 0); + input_set_events_per_packet(input, MAX_EVENTS); return 1; } return 0; @@ -177,11 +198,10 @@ static int ntrig_input_mapped(struct hid_device *hdev, struct hid_input *hi, if (field->physical) return 0; - if (usage->type == EV_KEY || usage->type == EV_REL - || usage->type == EV_ABS) - clear_bit(usage->code, *bit); - - return 0; + /* tell hid-input to skip setup of these event types */ + if (usage->type == EV_KEY || usage->type == EV_ABS) + set_bit(usage->type, hi->input->evbit); + return -1; } /* @@ -516,18 +536,6 @@ static int ntrig_probe(struct hid_device *hdev, const struct hid_device_id *id) input->name = "N-Trig Pen"; break; case HID_DG_TOUCHSCREEN: - /* These keys are redundant for fingers, clear them - * to prevent incorrect identification */ - __clear_bit(BTN_TOOL_PEN, input->keybit); - __clear_bit(BTN_TOOL_FINGER, input->keybit); - __clear_bit(BTN_0, input->keybit); - __set_bit(BTN_TOOL_DOUBLETAP, input->keybit); - /* - * The physical touchscreen (single touch) - * input has a value for physical, whereas - * the multitouch only has logical input - * fields. - */ input->name = (hidinput->report->field[0] ->physical) ?