From patchwork Mon Nov 29 07:43:27 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henrik Rydberg X-Patchwork-Id: 363092 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oAT7jK9J009946 for ; Mon, 29 Nov 2010 07:45:21 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755227Ab0K2Ho6 (ORCPT ); Mon, 29 Nov 2010 02:44:58 -0500 Received: from ch-smtp01.sth.basefarm.net ([80.76.149.212]:34941 "EHLO ch-smtp01.sth.basefarm.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755206Ab0K2Ho6 (ORCPT ); Mon, 29 Nov 2010 02:44:58 -0500 Received: from c83-248-196-64.bredband.comhem.se ([83.248.196.64]:50457 helo=polaris) by ch-smtp01.sth.basefarm.net with smtp (Exim 4.71) (envelope-from ) id 1PMyOt-0008Tl-3Z; Mon, 29 Nov 2010 08:43:54 +0100 Received: by polaris (sSMTP sendmail emulation); Mon, 29 Nov 2010 08:43:50 +0100 From: "Henrik Rydberg" To: Jiri Kosina Cc: Dmitry Torokhov , Philipp Merkel , Stephane Chatty , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Henrik Rydberg Subject: [PATCH 2/7] hid: egalax: Setup input device manually (rev2) Date: Mon, 29 Nov 2010 08:43:27 +0100 Message-Id: <1291016612-25102-3-git-send-email-rydberg@euromail.se> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1291016612-25102-1-git-send-email-rydberg@euromail.se> References: <1291016612-25102-1-git-send-email-rydberg@euromail.se> X-Originating-IP: 83.248.196.64 X-Scan-Result: No virus found in message 1PMyOt-0008Tl-3Z. X-Scan-Signature: ch-smtp01.sth.basefarm.net 1PMyOt-0008Tl-3Z eb4efb540960a968147cf39c7a487851 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Mon, 29 Nov 2010 07:45:21 +0000 (UTC) diff --git a/drivers/hid/hid-egalax.c b/drivers/hid/hid-egalax.c index 5a1b52e..6fbb4e0 100644 --- a/drivers/hid/hid-egalax.c +++ b/drivers/hid/hid-egalax.c @@ -34,10 +34,21 @@ struct egalax_data { __u16 lastx, lasty, lastz; /* latest valid (x, y, z) in the frame */ }; +static void set_abs(struct input_dev *input, unsigned int code, + struct hid_field *field, int snratio) +{ + int fmin = field->logical_minimum; + int fmax = field->logical_maximum; + int fuzz = snratio ? (fmax - fmin) / snratio : 0; + input_set_abs_params(input, code, fmin, fmax, fuzz, 0); +} + static int egalax_input_mapping(struct hid_device *hdev, struct hid_input *hi, struct hid_field *field, struct hid_usage *usage, unsigned long **bit, int *max) { + struct input_dev *input = hi->input; + switch (usage->hid & HID_USAGE_PAGE) { case HID_UP_GENDESK: @@ -45,18 +56,16 @@ static int egalax_input_mapping(struct hid_device *hdev, struct hid_input *hi, case HID_GD_X: hid_map_usage(hi, usage, bit, max, EV_ABS, ABS_MT_POSITION_X); + set_abs(input, ABS_MT_POSITION_X, field, 0); /* touchscreen emulation */ - input_set_abs_params(hi->input, ABS_X, - field->logical_minimum, - field->logical_maximum, 0, 0); + set_abs(input, ABS_X, field, 0); return 1; case HID_GD_Y: hid_map_usage(hi, usage, bit, max, EV_ABS, ABS_MT_POSITION_Y); + set_abs(input, ABS_MT_POSITION_Y, field, 0); /* touchscreen emulation */ - input_set_abs_params(hi->input, ABS_Y, - field->logical_minimum, - field->logical_maximum, 0, 0); + set_abs(input, ABS_Y, field, 0); return 1; } return 0; @@ -66,6 +75,7 @@ static int egalax_input_mapping(struct hid_device *hdev, struct hid_input *hi, case HID_DG_TIPSWITCH: /* touchscreen emulation */ hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH); + input_set_capability(input, EV_KEY, BTN_TOUCH); return 1; case HID_DG_INRANGE: case HID_DG_CONFIDENCE: @@ -75,14 +85,14 @@ static int egalax_input_mapping(struct hid_device *hdev, struct hid_input *hi, case HID_DG_CONTACTID: hid_map_usage(hi, usage, bit, max, EV_ABS, ABS_MT_TRACKING_ID); + set_abs(input, ABS_MT_TRACKING_ID, field, 0); return 1; case HID_DG_TIPPRESSURE: hid_map_usage(hi, usage, bit, max, EV_ABS, ABS_MT_PRESSURE); + set_abs(input, ABS_MT_PRESSURE, field, 0); /* touchscreen emulation */ - input_set_abs_params(hi->input, ABS_PRESSURE, - field->logical_minimum, - field->logical_maximum, 0, 0); + set_abs(input, ABS_PRESSURE, field, 0); return 1; } return 0; @@ -96,10 +106,10 @@ static int egalax_input_mapped(struct hid_device *hdev, struct hid_input *hi, struct hid_field *field, struct hid_usage *usage, unsigned long **bit, int *max) { + /* tell hid-input to skip setup of these event types */ if (usage->type == EV_KEY || usage->type == EV_ABS) - clear_bit(usage->code, *bit); - - return 0; + set_bit(usage->type, hi->input->evbit); + return -1; } /*