From patchwork Fri Jun 10 19:55:03 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derek Foreman X-Patchwork-Id: 870572 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p5AK2e5o005667 for ; Fri, 10 Jun 2011 20:02:41 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757863Ab1FJUCl (ORCPT ); Fri, 10 Jun 2011 16:02:41 -0400 Received: from bhuna.collabora.co.uk ([93.93.128.226]:37426 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757900Ab1FJUCj (ORCPT ); Fri, 10 Jun 2011 16:02:39 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: derek) with ESMTPSA id 91EF411A817D From: Derek Foreman To: linux-input@vger.kernel.org Subject: [PATCH 3/4] Input: Synaptics: Some touchpads can sense the complete locations of two fingers rather than just the bounding box, so for these pads, report the co-ordinates directly. Date: Fri, 10 Jun 2011 15:55:03 -0400 Message-Id: <1307735704-30673-4-git-send-email-derek.foreman@collabora.co.uk> X-Mailer: git-send-email 1.7.5.3 In-Reply-To: <1307735704-30673-1-git-send-email-derek.foreman@collabora.co.uk> References: <1307735704-30673-1-git-send-email-derek.foreman@collabora.co.uk> 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.6 (demeter2.kernel.org [140.211.167.43]); Fri, 10 Jun 2011 20:02:41 +0000 (UTC) From: Daniel Stone Signed-off-by: Derek Foreman --- drivers/input/mouse/synaptics.c | 35 ++++++++++++++++++++++++++--------- drivers/input/mouse/synaptics.h | 2 ++ 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c index 40748e3..3c68663 100644 --- a/drivers/input/mouse/synaptics.c +++ b/drivers/input/mouse/synaptics.c @@ -162,6 +162,11 @@ static int synaptics_capability(struct psmouse *psmouse) } else { priv->ext_cap = (cap[0] << 16) | (cap[1] << 8) | cap[2]; + if (priv->model_id == 0x1e2b1) + priv->use_bounding_box = 0; + else + priv->use_bounding_box = 1; + /* * if nExtBtn is greater than 8 it should be considered * invalid and treated as 0 @@ -485,7 +490,8 @@ static int synaptics_parse_hw_state(const unsigned char buf[], return 0; } -static void set_slot(struct input_dev *dev, int slot, bool active, int x, int y) +static void set_slot(struct input_dev *dev, int slot, bool active, int x, int y, + int z) { input_mt_slot(dev, slot); input_mt_report_slot_state(dev, MT_TOOL_FINGER, active); @@ -493,23 +499,30 @@ static void set_slot(struct input_dev *dev, int slot, bool active, int x, int y) input_report_abs(dev, ABS_MT_POSITION_X, x); input_report_abs(dev, ABS_MT_POSITION_Y, YMAX_NOMINAL + YMIN_NOMINAL - y); + input_report_abs(dev, ABS_MT_PRESSURE, z); } } static void synaptics_report_semi_mt_data(struct input_dev *dev, + struct synaptics_data *priv, const struct synaptics_hw_state *a, const struct synaptics_hw_state *b, int num_fingers) { - if (num_fingers >= 2) { - set_slot(dev, 0, true, min(a->x, b->x), min(a->y, b->y)); - set_slot(dev, 1, true, max(a->x, b->x), max(a->y, b->y)); + if (num_fingers >= 2 && priv->use_bounding_box) { + set_slot(dev, 0, true, min(a->x, b->x), min(a->y, b->y), + min(a->z, b->z)); + set_slot(dev, 1, true, max(a->x, b->x), max(a->y, b->y), + max(a->z, b->z)); + } else if (num_fingers >= 2) { + set_slot(dev, 0, true, a->x, a->y, a->z); + set_slot(dev, 1, true, b->x, b->y, b->z); } else if (num_fingers == 1) { - set_slot(dev, 0, true, a->x, a->y); - set_slot(dev, 1, false, 0, 0); + set_slot(dev, 0, true, a->x, a->y, a->z); + set_slot(dev, 1, false, 0, 0, 0); } else { - set_slot(dev, 0, false, 0, 0); - set_slot(dev, 1, false, 0, 0); + set_slot(dev, 0, false, 0, 0, 0); + set_slot(dev, 1, false, 0, 0, 0); } } @@ -573,7 +586,8 @@ static void synaptics_process_packet(struct psmouse *psmouse) } if (SYN_CAP_ADV_GESTURE(priv->ext_cap_0c)) - synaptics_report_semi_mt_data(dev, &hw, &priv->mt, num_fingers); + synaptics_report_semi_mt_data(dev, priv, &hw, &priv->mt, + num_fingers); /* Post events * BTN_TOUCH has to be first as mousedev relies on it when doing @@ -702,6 +716,7 @@ static void set_input_params(struct input_dev *dev, struct synaptics_data *priv) priv->x_max ?: XMAX_NOMINAL, 0, 0); input_set_abs_params(dev, ABS_MT_POSITION_Y, YMIN_NOMINAL, priv->y_max ?: YMAX_NOMINAL, 0, 0); + input_set_abs_params(dev, ABS_MT_PRESSURE, 0, 255, 0, 0); } if (SYN_CAP_PALMDETECT(priv->capabilities)) @@ -736,6 +751,8 @@ static void set_input_params(struct input_dev *dev, struct synaptics_data *priv) input_abs_set_res(dev, ABS_X, priv->x_res); input_abs_set_res(dev, ABS_Y, priv->y_res); + input_abs_set_res(dev, ABS_MT_POSITION_X, priv->x_res); + input_abs_set_res(dev, ABS_MT_POSITION_Y, priv->y_res); if (SYN_CAP_CLICKPAD(priv->ext_cap_0c)) { __set_bit(INPUT_PROP_BUTTONPAD, dev->propbit); diff --git a/drivers/input/mouse/synaptics.h b/drivers/input/mouse/synaptics.h index 7453938..9a2b0a7 100644 --- a/drivers/input/mouse/synaptics.h +++ b/drivers/input/mouse/synaptics.h @@ -136,6 +136,8 @@ struct synaptics_data { unsigned char mode; /* current mode byte */ int scroll; + unsigned int use_bounding_box:1; /* report bounding box for MT */ + struct serio *pt_port; /* Pass-through serio port */ struct synaptics_hw_state mt; /* current gesture packet */