From patchwork Sat Oct 9 11:37:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 12547517 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F329AC433EF for ; Sat, 9 Oct 2021 11:37:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CA83460F39 for ; Sat, 9 Oct 2021 11:37:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232865AbhJILjP (ORCPT ); Sat, 9 Oct 2021 07:39:15 -0400 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:60655 "EHLO wout2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232413AbhJILjO (ORCPT ); Sat, 9 Oct 2021 07:39:14 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id B7FF13200D78; Sat, 9 Oct 2021 07:37:17 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Sat, 09 Oct 2021 07:37:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alistair23.me; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm2; bh=sAuAlg1YEQ5sq8r/I8rO3wTnzL EwPBPmuYw2IxS2njI=; b=AFHT5YmC0qtgGh+vs2uFH0DOBHo2gOE/6wmv+vmGCL cnUDTgoR9F41Zn6tB0niSL3Hp7zIUjOojLC0UIdSbWBm9gvLU4I8U4aXV0S2Kwwh M+SAI0HigW71gkmRnibIbFwzAT8rhJWCF82znzD/r/esp7qU7NP9+aN9G0UiJfo4 yqjPxT7idIAeQQowJTAB5lBomufZ5Z/qH98LCvY5EyX9FCwp3+5St2U3lDFHAj5m tc2wCAN6n2N7Y9przgL/3F2pMGU+u2RyTkYcLHzMH6YDiwirQ6tNF9q8PC9ne5o1 +RvPLFzQgYcP7PfsnGToQerJgwJ02KWDMJGauMVr+Xkg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=sAuAlg1YEQ5sq8r/I 8rO3wTnzLEwPBPmuYw2IxS2njI=; b=FbT/qW9OKhDpqGvQ/IvGvoLEuStMK3kXb c7lAKA4LDi+u9v512rJPk53LvrRlSTCdWr2yWyoN7xTaVW9/fTi3eyR0u5s5Xa4y GyzNSTUaIyv81TtuVy0R5pIz5BlThHXCe9/l3wh1b3SILriQlZFDC27iqJWOdD53 4/Naod5Roe/8F7q/38K8zrzH6GSJmQTe7aEQJIWFFPAzJCHA1GQi/f1217P5bW8+ xlzvFVB82TxBQ7qAEKRik+jHdB+nxIEGXg0829k/a9U+59FzCiGmOVx5F82uGKiY AmS7sfc+CzoeiJmeD4dllQt62LP/APojtD+g1u2AzFgLPUsxPBoxg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddtvddggeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgggfestdekredtre dttdenucfhrhhomheptehlihhsthgrihhrucfhrhgrnhgtihhsuceorghlihhsthgrihhr segrlhhishhtrghirhdvfedrmhgvqeenucggtffrrghtthgvrhhnpeejleeihfdvtefgtd ethfdtgefftdeiffefjeeiffefveeuleejheejvefhffeukeenucevlhhushhtvghrufhi iigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhishhtrghirhesrghlihhsth grihhrvdefrdhmvg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 9 Oct 2021 07:37:14 -0400 (EDT) From: Alistair Francis To: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Cc: alistair@alistair23.me, alistair23@gmail.com Subject: [PATCH 1/2] Input: wacom_i2c - Clean up the query device fields Date: Sat, 9 Oct 2021 21:37:06 +1000 Message-Id: <20211009113707.17568-1-alistair@alistair23.me> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Improve the query device fields to be more verbose. Signed-off-by: Alistair Francis --- drivers/input/touchscreen/wacom_i2c.c | 49 ++++++++++++++++----------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/drivers/input/touchscreen/wacom_i2c.c b/drivers/input/touchscreen/wacom_i2c.c index 22826c387da5..8d7267ccc661 100644 --- a/drivers/input/touchscreen/wacom_i2c.c +++ b/drivers/input/touchscreen/wacom_i2c.c @@ -14,13 +14,21 @@ #include #include -#define WACOM_CMD_QUERY0 0x04 -#define WACOM_CMD_QUERY1 0x00 -#define WACOM_CMD_QUERY2 0x33 -#define WACOM_CMD_QUERY3 0x02 -#define WACOM_CMD_THROW0 0x05 -#define WACOM_CMD_THROW1 0x00 -#define WACOM_QUERY_SIZE 19 +// Registers +#define WACOM_COMMAND_LSB 0x04 +#define WACOM_COMMAND_MSB 0x00 + +#define WACOM_DATA_LSB 0x05 +#define WACOM_DATA_MSB 0x00 + +// Report types +#define REPORT_FEATURE 0x30 + +// Requests / operations +#define OPCODE_GET_REPORT 0x02 + +#define WACOM_QUERY_REPORT 3 +#define WACOM_QUERY_SIZE 22 struct wacom_features { int x_max; @@ -41,27 +49,30 @@ static int wacom_query_device(struct i2c_client *client, struct wacom_features *features) { int ret; - u8 cmd1[] = { WACOM_CMD_QUERY0, WACOM_CMD_QUERY1, - WACOM_CMD_QUERY2, WACOM_CMD_QUERY3 }; - u8 cmd2[] = { WACOM_CMD_THROW0, WACOM_CMD_THROW1 }; u8 data[WACOM_QUERY_SIZE]; + + u8 get_query_data_cmd[] = { + WACOM_COMMAND_LSB, + WACOM_COMMAND_MSB, + REPORT_FEATURE | WACOM_QUERY_REPORT, + OPCODE_GET_REPORT, + WACOM_DATA_LSB, + WACOM_DATA_MSB, + }; + struct i2c_msg msgs[] = { + // Request reading of feature ReportID: 3 (Pen Query Data) { .addr = client->addr, .flags = 0, - .len = sizeof(cmd1), - .buf = cmd1, - }, - { - .addr = client->addr, - .flags = 0, - .len = sizeof(cmd2), - .buf = cmd2, + .len = sizeof(get_query_data_cmd), + .buf = get_query_data_cmd, }, + // Read 21 bytes { .addr = client->addr, .flags = I2C_M_RD, - .len = sizeof(data), + .len = WACOM_QUERY_SIZE - 1, .buf = data, }, }; From patchwork Sat Oct 9 11:37:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 12547519 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABB39C433F5 for ; Sat, 9 Oct 2021 11:37:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8CEB760F39 for ; Sat, 9 Oct 2021 11:37:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232519AbhJILjT (ORCPT ); Sat, 9 Oct 2021 07:39:19 -0400 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:38699 "EHLO wout2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232960AbhJILjS (ORCPT ); Sat, 9 Oct 2021 07:39:18 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 50DE63200DA8; Sat, 9 Oct 2021 07:37:21 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Sat, 09 Oct 2021 07:37:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alistair23.me; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=3mNRLjHegM/+z sOwmvU7YPcMf59k7n3IQSmcunFOm/k=; b=2oUdJxfvt4ge/cMZKSPjZ42LwtUsl ijUvpLsPwFaih0hmZSt+N0oih+aUMjuYtsG6oCjup+D9+beLyg4tCrrH8GSf+2x4 h7g8POaDsmr0NBuHtUT2H12wW2Mdb2hjv99bgHhqG8WinR5+IPk3FTjY0OJue3y3 dw2zsKYK0zxsUDpzqHkj9TTwAGJLPyck6sAk1pTHII+CeNWeus+I2WOnOHgXOoVf 4NYnd4DdKQBgmUWtQpdmSbXhad7fLy8g5aWEWsAzNTFLOA1Ml2aeJm3piIHEFBHH XiEax6djYHgAzWEGNDK4b/kPC1MIDogaHqjtPFRcRtoY0JuKWStfRd7HQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=3mNRLjHegM/+zsOwmvU7YPcMf59k7n3IQSmcunFOm/k=; b=lAvxDR+0 3qGUQv+W5D9bnygahUXFVLlbRVaBUuu508MhZ20EUU4KOQuDlmXLCP+GxS20s+4N bxr1OFXmoMPxP76cHmOOjJO3AXPzGAPSE7pHenudP8qi/IgIz9+8XmIL++SqHzD2 o+qso7GSeSc/IHa6JVzzJZtmYpqlC6/qgHoICJSSL3KqZxrsVAxrsTjykU2irNFZ IdE9eNBR6+J2eiDZgrl77Zo1lAscUFFiEpAYwJAJyMVav64kdocSvpAEijrce+BL 1VrHFS6ykQX1dQbD8Uy7I+Rda4kxukL2xxk4Roi076iRIs159jiTXYUGq8TNmKpO Cf4M+MsxvLdNxA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddtvddggeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomheptehlihhsthgrihhrucfhrhgrnhgtihhsuceorghlihhsthgr ihhrsegrlhhishhtrghirhdvfedrmhgvqeenucggtffrrghtthgvrhhnpeeggedtteejke eggeeugfehueevudegvdetjeeviedugedvtdekffekhedtteduhfenucevlhhushhtvghr ufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhishhtrghirhesrghlih hsthgrihhrvdefrdhmvg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 9 Oct 2021 07:37:18 -0400 (EDT) From: Alistair Francis To: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Cc: alistair@alistair23.me, alistair23@gmail.com Subject: [PATCH 2/2] Input: wacom_i2c - Use macros for the bit masks Date: Sat, 9 Oct 2021 21:37:07 +1000 Message-Id: <20211009113707.17568-2-alistair@alistair23.me> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211009113707.17568-1-alistair@alistair23.me> References: <20211009113707.17568-1-alistair@alistair23.me> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org To make the code easier to read use macros for the bit masks. Signed-off-by: Alistair Francis --- drivers/input/touchscreen/wacom_i2c.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/input/touchscreen/wacom_i2c.c b/drivers/input/touchscreen/wacom_i2c.c index 8d7267ccc661..6865342db659 100644 --- a/drivers/input/touchscreen/wacom_i2c.c +++ b/drivers/input/touchscreen/wacom_i2c.c @@ -14,6 +14,12 @@ #include #include +// Bitmasks (for data[3]) +#define WACOM_TIP_SWITCH_bm (1 << 0) +#define WACOM_BARREL_SWITCH_bm (1 << 1) +#define WACOM_ERASER_bm (1 << 2) +#define WACOM_BARREL_SWITCH_2_bm (1 << 4) + // Registers #define WACOM_COMMAND_LSB 0x04 #define WACOM_COMMAND_MSB 0x00 @@ -110,10 +116,10 @@ static irqreturn_t wacom_i2c_irq(int irq, void *dev_id) if (error < 0) goto out; - tsw = data[3] & 0x01; - ers = data[3] & 0x04; - f1 = data[3] & 0x02; - f2 = data[3] & 0x10; + tsw = data[3] & WACOM_TIP_SWITCH_bm; + ers = data[3] & WACOM_ERASER_bm; + f1 = data[3] & WACOM_BARREL_SWITCH_bm; + f2 = data[3] & WACOM_BARREL_SWITCH_2_bm; x = le16_to_cpup((__le16 *)&data[4]); y = le16_to_cpup((__le16 *)&data[6]); pressure = le16_to_cpup((__le16 *)&data[8]);