From patchwork Fri Nov 12 08:11:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henrik Rydberg X-Patchwork-Id: 70937 X-Patchwork-Delegate: apw@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 A9675B70FB for ; Fri, 12 Nov 2010 19:13:12 +1100 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.69) (envelope-from ) id 1PGokt-0004tA-JD; Fri, 12 Nov 2010 08:13:07 +0000 Received: from ch-smtp02.sth.basefarm.net ([80.76.149.213]) by chlorine.canonical.com with esmtp (Exim 4.69) (envelope-from ) id 1PGokr-0004sg-L1 for kernel-team@lists.ubuntu.com; Fri, 12 Nov 2010 08:13:05 +0000 Received: from c83-248-196-134.bredband.comhem.se ([83.248.196.134]:42066 helo=polaris) by ch-smtp02.sth.basefarm.net with smtp (Exim 4.68) (envelope-from ) id 1PGojw-0004up-6Z for kernel-team@lists.ubuntu.com; Fri, 12 Nov 2010 09:12:11 +0100 Received: by polaris (sSMTP sendmail emulation); Fri, 12 Nov 2010 09:12:07 +0100 From: "Henrik Rydberg" To: kernel-team@lists.ubuntu.com Subject: [PATCH 2/5] UBUNTU: SAUCE: hid: ntrig: Setup input filtering manually Date: Fri, 12 Nov 2010 09:11:51 +0100 Message-Id: <1289549514-5421-3-git-send-email-rydberg@euromail.se> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1289549514-5421-1-git-send-email-rydberg@euromail.se> References: <1289549514-5421-1-git-send-email-rydberg@euromail.se> X-Originating-IP: 83.248.196.134 X-Scan-Result: No virus found in message 1PGojw-0004up-6Z. X-Scan-Signature: ch-smtp02.sth.basefarm.net 1PGojw-0004up-6Z a80b35ca750086094836fb1699c83e52 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. Has been tested succesfully on Dell Studio 17, Dell XT2, HP TX2 and Lenovo T410s. Not likely to go upstream in its present form. However, it does help constitue a tuning-free driver which works well together with Unity, and as such are vital to the MT push. Signed-off-by: Henrik Rydberg Acked-by: Chase Douglas Signed-off-by: Leann Ogasawara --- drivers/hid/hid-ntrig.c | 75 +++++++++++++++++++++++++--------------------- 1 files changed, 41 insertions(+), 34 deletions(-) diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c index b5302c0..07784eb 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; @@ -129,9 +135,13 @@ err_free: static int ntrig_input_mapping(struct hid_device *hdev, struct hid_input *hi, struct hid_field *field, struct hid_usage *usage, - unsigned long **bit, int *max) + 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) @@ -141,12 +151,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 - @@ -163,12 +172,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 - @@ -194,22 +202,34 @@ 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); + 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, + EV_ABS, ABS_MT_TOUCH_MINOR); + 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; - case 0xff000000: /* we do not want to map these: no input-oriented meaning */ return -1; @@ -226,11 +246,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; } /* @@ -565,18 +584,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) ?