From patchwork Wed Dec 5 02:24:05 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Mostafa X-Patchwork-Id: 1840061 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 264C83FC64 for ; Wed, 5 Dec 2012 02:24:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753462Ab2LECYG (ORCPT ); Tue, 4 Dec 2012 21:24:06 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:58889 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752810Ab2LECYF (ORCPT ); Tue, 4 Dec 2012 21:24:05 -0500 Received: from c-67-160-231-42.hsd1.ca.comcast.net ([67.160.231.42] helo=fourier) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1Tg4eZ-0004nv-8M; Wed, 05 Dec 2012 02:24:03 +0000 Received: from kamal by fourier with local (Exim 4.80) (envelope-from ) id 1Tg4ec-0006iT-9c; Tue, 04 Dec 2012 18:24:06 -0800 From: Kamal Mostafa To: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Dmitry Torokhov , Henrik Rydberg Cc: Dudley Du , David Solda , Troy Abercrombia , Kamal Mostafa , Kyle Fazzari , Mario Limonciello , Tim Gardner , Herton Krzesinski Subject: [PATCH v4 4/4] input: Cypress PS/2 Trackpad simulated multitouch (disabled) Date: Tue, 4 Dec 2012 18:24:05 -0800 Message-Id: <1354674245-25768-5-git-send-email-kamal@canonical.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1354674245-25768-1-git-send-email-kamal@canonical.com> References: <1354674245-25768-1-git-send-email-kamal@canonical.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org This feature is disabled by default; enable with CYPRESS_SIMULATED_MT. Instead of SEMI_MT, present a full mt interface with simulated contact positions for >=3 fingers. Enables e.g. multi-finger tap and drag for old userspace applications which only count the contact positions. Signed-off-by: Kamal Mostafa --- drivers/input/mouse/cypress_ps2.c | 18 ++++++++++++++++++ drivers/input/mouse/cypress_ps2.h | 16 ++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/drivers/input/mouse/cypress_ps2.c b/drivers/input/mouse/cypress_ps2.c index fab4d18..088cdb8 100644 --- a/drivers/input/mouse/cypress_ps2.c +++ b/drivers/input/mouse/cypress_ps2.c @@ -408,7 +408,9 @@ static int cypress_set_input_params(struct input_dev *input, if (ret < 0) return ret; +#if ( CYPRESS_SIMULATED_MT != 1 ) __set_bit(INPUT_PROP_SEMI_MT, input->propbit); +#endif if (cytp->tp_res_x && cytp->tp_res_y) { input_abs_set_res(input, ABS_X, cytp->tp_res_x); @@ -531,6 +533,22 @@ static int cypress_parse_packet(struct psmouse *psmouse, ((packet[5] & 0x0f) << 8) | packet[7]; if (cytp->mode & CYTP_BIT_ABS_PRESSURE) report_data->contacts[1].z = report_data->contacts[0].z; +#if ( CYPRESS_SIMULATED_MT == 1 ) + /* simulate contact positions for >2 fingers */ + if ( report_data->contact_cnt >= 3 ) { + int i; + for ( i=1; icontact_cnt; i++ ) { + report_data->contacts[i].x = + report_data->contacts[0].x + + 100*(i)*((i%2)?-1:1); + report_data->contacts[i].y = + report_data->contacts[0].y; + if (cytp->mode & CYTP_BIT_ABS_PRESSURE) + report_data->contacts[i].z = + report_data->contacts[0].z; + } + } +#endif } report_data->left = (header_byte & BTN_LEFT_BIT) ? 1 : 0; diff --git a/drivers/input/mouse/cypress_ps2.h b/drivers/input/mouse/cypress_ps2.h index a74f985..c38cb6f 100644 --- a/drivers/input/mouse/cypress_ps2.h +++ b/drivers/input/mouse/cypress_ps2.h @@ -133,8 +133,20 @@ #define RESP_REMOTE_BIT 0x40 #define RESP_SMBUS_BIT 0x80 -#define CYTP_MAX_CONTACTS 2 -#define CYTP_MAX_MT_SLOTS 2 +/* + * CYPRESS_SIMULATED_MT + * set to 1 for simulated multitouch (up to CTYP_MAX_CONTACTS fingers) + * set to 0 for SEMI_MT (2 fingers only) + */ +#define CYPRESS_SIMULATED_MT 0 + +#if ( CYPRESS_SIMULATED_MT == 1 ) +# define CYTP_MAX_CONTACTS 5 +# define CYTP_MAX_MT_SLOTS 16 +#else +# define CYTP_MAX_CONTACTS 2 +# define CYTP_MAX_MT_SLOTS 2 +#endif enum cytp_type { CYTP_STG,