Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2087133ybz; Sun, 26 Apr 2020 10:51:31 -0700 (PDT) X-Google-Smtp-Source: APiQypKLaZ7kD0PPFn9qrmaHQ/1ljRs5eUU1W5A8/s9kMP4w7dbKRq5M89/IX4mSfE2uP8xg3goO X-Received: by 2002:a05:6402:1a49:: with SMTP id bf9mr6074236edb.189.1587923490926; Sun, 26 Apr 2020 10:51:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587923490; cv=none; d=google.com; s=arc-20160816; b=t/h4RR8DQEjY9K+7InV4ZxQiEpI/9DpoEhPkmQ4gQwoJklzRCpxmAZJPGZljKDIa0y BdIAa090GTNrspXL7iusNdpGxw/nkMsAuhdXKUnm3/UNukwvsb7eGKOVa7mfdCiiamT7 bwzJHdjkVF/1GjwlkXR/CK2qrUKYTmsmZMx0byiV1lBGr44MOI5W+B4RzbmFWODH7u1k C0Mmmeiox2kQx7/wVUAJJdKRgcJFIoZcqqlJVv24WfvRS5kzWicY9I6bfI1iVKzM7uPp i54lwAB3IwFEjFHol6mtm/tC5Wq4vbQlFKxAi/VG+BQPEG+PahSeuJMKoYABEBKF8FVT uMig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:content-transfer-encoding :mime-version:subject:from:references:in-reply-to:message-id:date :dkim-signature; bh=FCr5zf13Y+bc58Cc8Ia6vRgky+xxaP/zcqLRsWGHqJQ=; b=uR9PZ5JCgS7fqySjDEsZGvZLMN4A3dUDuSebNC+RyP+9MS86GcX226un/EBiCgkgvP Fkkwdv3vFp1BQeBeJ/HER0UgWwKaNPIy46qoq3PPyqDZwoDa/+wI426NodCC1EPbPnxu tqFXezJ2KAWNC+GvT9/DEyxd5VLTkr0ag06bf18o+gK0UlUVyEul4cNnIC4yTzrzISA0 LbLS7qOWyR+a/zuGTqL2qjoQc8VRUJ48O57EcRKscHq2IDJtjESDR+7bZ7B2xfJnyXVl woXLCfmwbHCRv4+ttADwvXy6C2RoWL3j8mXqjhRaIVh6xbM0+53/mBOwB2e7c9ZBqezR jkHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b="Y/vJnF/c"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e9si6433350eds.63.2020.04.26.10.51.08; Sun, 26 Apr 2020 10:51:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b="Y/vJnF/c"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726306AbgDZRsZ (ORCPT + 99 others); Sun, 26 Apr 2020 13:48:25 -0400 Received: from rere.qmqm.pl ([91.227.64.183]:36981 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726156AbgDZRrw (ORCPT ); Sun, 26 Apr 2020 13:47:52 -0400 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 499Fjy22TwzsC; Sun, 26 Apr 2020 19:47:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1587923270; bh=IthshsP+Hrk4TIyx4kPla8Gk2+PcSLRsErz0s+IVwRw=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=Y/vJnF/cUUDU3asO4Wal1m3ownNLmcBjBzOjr0Y2woAL++piRzg0hSbGDeMqtKGTN AZ2SsnXm36o5PDsZl6muNEj6ABCGh2YO4AW8TSxXt0RBEC1NTHXIv8bOnrEyWEg15R yzf6XkQhGW0/YjkadPUrtMKcXBCUWnl0ampGoPc3DCBRvU+A+ZoVq6OH8PP+3a+oSW o/SvVAacLgkvqCgYzXHj1D2l8pib10AfKLRwZF45QOx7zLEAhiRp1S+xL4BN83trxC wTYMv30hMhy2IvTHVLjXA9lWZiqsL70VO3FyGrEnLkX7lCVr1dnAJqbXr4kpVYad8s rA5Ih2tzED/NA== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.2 at mail Date: Sun, 26 Apr 2020 19:47:49 +0200 Message-Id: <0c2d8ebf44062bf84bc6e65a0445948fb6d1da63.1587923061.git.mirq-linux@rere.qmqm.pl> In-Reply-To: References: From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= Subject: [PATCH v5 02/10] input: elants: support old touch report format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To: David Heidelberg , Dmitry Osipenko , Dmitry Torokhov , Henrik Rydberg , James Chen , Johnny Chuang , Rob Herring , Scott Liu Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Support ELAN touchpad sensor with older firmware as found on eg. Asus Transformer Pads. Signed-off-by: Michał Mirosław Reviewed-by: Dmitry Osipenko Tested-by: Dmitry Osipenko --- drivers/input/touchscreen/elants_i2c.c | 36 ++++++++++++++++++-------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c index d2175fb6209a..6c2b336d92bf 100644 --- a/drivers/input/touchscreen/elants_i2c.c +++ b/drivers/input/touchscreen/elants_i2c.c @@ -68,6 +68,7 @@ #define CMD_HEADER_REK 0x66 /* FW position data */ +#define PACKET_SIZE_OLD 40 #define PACKET_SIZE 55 #define MAX_CONTACT_NUM 10 #define FW_POS_HEADER 0 @@ -855,7 +856,8 @@ static int elants_i2c_fw_update(struct elants_data *ts) * Event reporting. */ -static void elants_i2c_mt_event(struct elants_data *ts, u8 *buf) +static void elants_i2c_mt_event(struct elants_data *ts, u8 *buf, + size_t report_len) { struct input_dev *input = ts->input; unsigned int n_fingers; @@ -868,7 +870,8 @@ static void elants_i2c_mt_event(struct elants_data *ts, u8 *buf) buf[FW_POS_STATE]; dev_dbg(&ts->client->dev, - "n_fingers: %u, state: %04x\n", n_fingers, finger_state); + "n_fingers: %u, state: %04x, report_len: %zu\n", + n_fingers, finger_state, report_len); /* Note: all fingers have the same tool type */ tool_type = buf[FW_POS_TOOL_TYPE] & BIT(0) ? @@ -882,8 +885,16 @@ static void elants_i2c_mt_event(struct elants_data *ts, u8 *buf) pos = &buf[FW_POS_XY + i * 3]; x = (((u16)pos[0] & 0xf0) << 4) | pos[1]; y = (((u16)pos[0] & 0x0f) << 8) | pos[2]; - p = buf[FW_POS_PRESSURE + i]; - w = buf[FW_POS_WIDTH + i]; + if (report_len == PACKET_SIZE_OLD) { + w = buf[FW_POS_WIDTH + i / 2]; + w >>= 4 * (~i & 1); // little-endian-nibbles + w |= w << 4; + w |= !w; + p = w; + } else { + p = buf[FW_POS_PRESSURE + i]; + w = buf[FW_POS_WIDTH + i]; + } dev_dbg(&ts->client->dev, "i=%d x=%d y=%d p=%d w=%d\n", i, x, y, p, w); @@ -916,7 +927,8 @@ static u8 elants_i2c_calculate_checksum(u8 *buf) return checksum; } -static void elants_i2c_event(struct elants_data *ts, u8 *buf) +static void elants_i2c_event(struct elants_data *ts, u8 *buf, + size_t report_len) { u8 checksum = elants_i2c_calculate_checksum(buf); @@ -930,7 +942,7 @@ static void elants_i2c_event(struct elants_data *ts, u8 *buf) "%s: unknown packet type: %02x\n", __func__, buf[FW_POS_HEADER]); else - elants_i2c_mt_event(ts, buf); + elants_i2c_mt_event(ts, buf, report_len); } static irqreturn_t elants_i2c_irq(int irq, void *_dev) @@ -988,7 +1000,8 @@ static irqreturn_t elants_i2c_irq(int irq, void *_dev) break; case QUEUE_HEADER_SINGLE: - elants_i2c_event(ts, &ts->buf[HEADER_SIZE]); + elants_i2c_event(ts, &ts->buf[HEADER_SIZE], + ts->buf[FW_HDR_LENGTH]); break; case QUEUE_HEADER_NORMAL: @@ -1001,17 +1014,18 @@ static irqreturn_t elants_i2c_irq(int irq, void *_dev) } report_len = ts->buf[FW_HDR_LENGTH] / report_count; - if (report_len != PACKET_SIZE) { + if (report_len != PACKET_SIZE && + report_len != PACKET_SIZE_OLD) { dev_err(&client->dev, - "mismatching report length: %*ph\n", + "unsupported report length: %*ph\n", HEADER_SIZE, ts->buf); break; } for (i = 0; i < report_count; i++) { u8 *buf = ts->buf + HEADER_SIZE + - i * PACKET_SIZE; - elants_i2c_event(ts, buf); + i * report_len; + elants_i2c_event(ts, buf, report_len); } break; -- 2.20.1