From patchwork Sat Mar 13 19:12:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff LaBundy X-Patchwork-Id: 400236 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28AADC4332E for ; Sat, 13 Mar 2021 19:14:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1503A64E54 for ; Sat, 13 Mar 2021 19:14:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234299AbhCMTNX (ORCPT ); Sat, 13 Mar 2021 14:13:23 -0500 Received: from mail-mw2nam10hn2207.outbound.protection.outlook.com ([52.100.157.207]:25712 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234010AbhCMTNS (ORCPT ); Sat, 13 Mar 2021 14:13:18 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y4cF8sR0B27I30hucdzirjbgzk4se98j//aeHAYO28pEHwE2ca3rENXNVWO8A3fAEky6vCwgiS7/3r8pad1J/Sa4BC/eGATw0DRwE23kI9PW5BdSyC/G0EOJx6ew0WfD4Fp+SQltZ/hVkMq5+WVWmPii43RYh2czhU9wbsZ60OEBdeSykt8COHnlNFU0du9a8jMo6urtcOkxwhdHYKruk+K8Q7CXS9A2LxW30uu+BAY53L0QgsttqYN93vDd6L6TkLBSMxu74+pVPNClN2VrS2yrOCLU8igB4UZBpe+Uy3jm2lHn7KTqAm+dJK/l5LYRYLwjDbFcbvJhrNDtccwA9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QgTVGHCwrxUA2MwXrEDHIa4uo9zxIR6YuOKLFYAvSWw=; b=cQ6kQem4Wd58kR6TG+NkCyrzoxGiYrvb09v7GrRPO8upiIj2YPdM8bNaMJK2VYfsHpKiOM8b6HE4XBj6jnfA0umyNcGSQDGth31Fe4M+yApA6VaKkwXpHJtKkU6vYe85SrPaR/MY4PmO3vKVkY0f1ShFj9XzbyR8UP5h9oZ9nzvYfQ9RNMAl27DtfTYA3x6l2IXbMPwcFtOMiwlMR8540FRoLkgpS5lbbIreOq77wl5Gr7mnktxvx4Z+TYT9s1kLU8gnN4gkh+7eNvKXiJUhzK1MKKn5PXtNDvejqw8p+fuzIzD5YWRUR3eSdoY9dIvW1nK2/17hTfLI/O9Xw2UrqQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=labundy.com; dmarc=pass action=none header.from=labundy.com; dkim=pass header.d=labundy.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NETORG5796793.onmicrosoft.com; s=selector1-NETORG5796793-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QgTVGHCwrxUA2MwXrEDHIa4uo9zxIR6YuOKLFYAvSWw=; b=G5MGuvGSPtE+KOC6Qqg0xdM5fBTHZPiryBfdpGEDWAzeo1tVw4lA7dE/GAC5shYlFVGvf0xabRQLFAgjopaABTlNEy0Yh103bnknfUtJMP1qGs602b+VUKwh9RFnfl30tRHII87J+PJ75B0EugIzVZlxwiKBY5LehaQyl8TfGEE= Authentication-Results: gmail.com; dkim=none (message not signed) header.d=none; gmail.com; dmarc=none action=none header.from=labundy.com; Received: from SN6PR08MB5517.namprd08.prod.outlook.com (2603:10b6:805:fb::32) by SN6PR08MB5694.namprd08.prod.outlook.com (2603:10b6:805:104::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3933.31; Sat, 13 Mar 2021 19:13:17 +0000 Received: from SN6PR08MB5517.namprd08.prod.outlook.com ([fe80::79a3:8aa5:feb8:7f04]) by SN6PR08MB5517.namprd08.prod.outlook.com ([fe80::79a3:8aa5:feb8:7f04%7]) with mapi id 15.20.3912.030; Sat, 13 Mar 2021 19:13:17 +0000 From: Jeff LaBundy To: dmitry.torokhov@gmail.com, robh+dt@kernel.org Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, Jeff LaBundy Subject: [PATCH v2 2/9] Input: iqs5xx - optimize axis definition and validation Date: Sat, 13 Mar 2021 13:12:29 -0600 Message-Id: <20210313191236.4366-3-jeff@labundy.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210313191236.4366-1-jeff@labundy.com> References: <20210313191236.4366-1-jeff@labundy.com> X-Originating-IP: [136.49.90.243] X-ClientProxiedBy: SN7PR04CA0231.namprd04.prod.outlook.com (2603:10b6:806:127::26) To SN6PR08MB5517.namprd08.prod.outlook.com (2603:10b6:805:fb::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (136.49.90.243) by SN7PR04CA0231.namprd04.prod.outlook.com (2603:10b6:806:127::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3933.32 via Frontend Transport; Sat, 13 Mar 2021 19:13:16 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7ee152a5-5308-4844-d70f-08d8e6540e88 X-MS-TrafficTypeDiagnostic: SN6PR08MB5694: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4303; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bxuOyq2ney2yX+STJcqRcIN9fFpBxYvliC6tNe47yvw/ZK3vNgyjxqpcMlAeiVZ/EXlllCjZCxY8+a2pjRbliACNhUd7yxqbln86R3dqNRnT0h9QODa6DILTyF+a9L+tGfB/CIa17/HlB0BrI6bSWh/EvJDOGPqMz07/3K8OKAfMtifm9V3OiLHp+gUlZHKStHEXidrJ/+msfEjKDj/wm20AdBA1/Bi3M8OSmEcPk7nB8Sn08lPU5ShUeHfLQVzsywHGLoh8MVYFpkKRu2tWSr+xfUTn0/BFo3vuXIEc0b5BaHoXZQITkIPDsblUEVv/78SsGjsf8DMSxSKOCdnzNBMwlfu5BUOkLgvwWgjAssirlYnBzWF4CCQBmPrDstqvXqxzIH1bgzj0snOJActBbLpH1Fty8crR6TCM1GXnspKUkqHWi6hNAYlSHPgf7OncaOyZaRq0ewsSfHmdk8rk0KvcM20ijlc+9Fkroh4X8l76kZDKDFrelHGFWV8bM1asceuWyLonzjehZVZRDhRB3YejYl/gn8/QwOr8DzahRakQWwFe0NYX8iuM4Hjqn2Jwlp+E2ISZhgSAEhGWA9cU10IjTNUDVHF+hk/V3efafNEeLc1OXOibhpstt/QIq1IKwoK8f0cB+LDVwACIch97+d9Lu9y5o7GfuGmrfztWwpdV8EhjjR2u7UA4jwmv05cfsCOvKvmHwDvXchE1TjekyXWhVq41nGB4UZrDWTObNyik8tzL7OoWVa7i4csIVcUddluDi3hVP6x0u1MEy9871qSU2CE4zodud24/SEyTaGLvQdlGgxftIrACUWa0VMA9ziFQhwDdgXAt+mK9yUIZAP9Q37+SrnrMxr7ZBnpWzmmWE/rF0Rpf9cQGNf/mX3dDi/9o1dGuULtGOD38HX/qiJR8V1aBz8xK86RR5VL356MZMqs0LBtSoMhVVpgqYVdC6rD9sh7QL3obIClkx5rcEQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:5; SRV:; IPV:NLI; SFV:SPM; H:SN6PR08MB5517.namprd08.prod.outlook.com; PTR:; CAT:OSPM; SFS:(39830400003)(396003)(136003)(376002)(346002)(366004)(6486002)(52116002)(2906002)(66946007)(6512007)(2616005)(36756003)(186003)(69590400012)(6666004)(16526019)(26005)(1076003)(66476007)(478600001)(83380400001)(316002)(66556008)(956004)(4326008)(8936002)(6506007)(86362001)(5660300002)(107886003)(8676002)(42413003)(32563001); DIR:OUT; SFP:1501; X-MS-Exchange-AntiSpam-MessageData: IkjcwXT864ziz/+CIhYe5ROfkj4b74C2qeCCqt35ucbHbnjxXWMkRHIOsg/qaA50rHKz2B7Nrgw5fhudalWOdRIYyiAe0Or3ubBioFr8xrOV4oJNH11eo4OQtn5MvgHXIWnIKRWZNcn/CrbCmYO5TA+ChYT5Fuvec/qiG29VnirTD7Xfua4gqmdnA3WOYmW5gnobsFwyk2Axe8+YwLV5lXUq+T7+1qPNyLPXV9Jq6e7XYhXgnB4AUOQk74YVGKR4dYzkR+L9ELGEspk0fpfVKaOwJUZ+xX4r9CnxfbOKZ9Z7rQnn8AIUzfxtYnU8n1u7t34JE0Izu02SfKQ55ICWw6du9S/wWPFWFTL11KhVZwyYj3TVYe2TTKijj5V6lt2p3AJ4iSLwjwcRpP7wygDrS5zSP0UXJFRfRI72XCh2xOn9dhJKJa3+zgq5lY9rjiBFIPcKrkbcOZhxIPpoXVcxpleinqPgISLV5v5VyFk3ZCDQOfvnSwE6m55Vk3XIxJ2MSvRNsB97sV0NOC6SojyzJ8WOfXLN2hJ9Y82hm9901AZHaqpKkAWvmGwhxwr2IiN1al68d4w0ezaQY+R4RYYXzCUe1NSLra/XnFawz/+Nw6OAubtk9Vhn4TxlYDzoxK4jvOr1Cy6TfsQp1MSQPepJX1aF5dcb4dQwdtXjwlmw8kcpw7pOzWT7ZtcoJdGAv7a/+7pZf5elRn2cQiF2XxJm2Dy+1Q5RdCDpMyO8tQ7m5z5vZ4EQvWqzg3lp8xEFo4HpdV84++S6lB4UUZ8/JjrZTL4sUQdd/aw9wmdf1jn4kd8bggz9EXkeBkq1yAIv4ZZIwbfxhUUf6xn8VqKvbgQd5AZ6yht6mYbu+S+HrVKzT6lR0hXrSQfoZ8/7ayILKp0RS8WKsv+eXlF4AAsDgKa8LR/PpW1NsLIzMR5cDPVwyhlZHMxchIkoFDkJ40CeF56qc6jTqvCQaMASUzvvc9gCYgWJgYWrIPzZ9dNmcJiGksxISafBrRPesxhpyUm6VwRcs33vTU6PHqu36wXIE3Ll5DXejkPLAmyQDNK50EUyQIDXCq15D3Aysm9/T37taaDmfbuC9OfgFZzNqQVpqZA+hLaARRZhjU0VwJt4j/SNStrBiyekrLkVLsSMLIU+pvf6Or0pfH/CVo4V9mfXRJD8kZeZnkAEakSrGDt37eB389IcdoTL6hesOBufYeH4B1MiLuT80LMyF4EhkXvqn5y5YYHYgqgk344d00qzpPcZl7LTYkQbGC0Ht9WTk2sJw/R8k+NGWbBuv5xEhqcInGHpAP/vzNmBr5OyBAfnV1ztzbNKGjM1x8gdsXDWbnuY7dw6 X-OriginatorOrg: labundy.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7ee152a5-5308-4844-d70f-08d8e6540e88 X-MS-Exchange-CrossTenant-AuthSource: SN6PR08MB5517.namprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Mar 2021 19:13:16.9714 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 00b69d09-acab-4585-aca7-8fb7c6323e6f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: m9bk/vVe+omaxtJootNQEl152htbDvn6dLDv16VJterTOe1CNCNZz7dU8NPmohZdfnLFyiq+oY1IQAiIv/+HiQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR08MB5694 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Set the maximum ABS_MT_PRESSURE value and use the existing U16_MAX definition instead of a magic number to validate ABS_MT_POSITION_X and ABS_MT_POSITION_Y. Also use input_set_abs_params() rather than input_abs_set_max() to avoid having to call input_set_capability() separately. Signed-off-by: Jeff LaBundy --- Changes in v2: - None drivers/input/touchscreen/iqs5xx.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) -- 2.17.1 diff --git a/drivers/input/touchscreen/iqs5xx.c b/drivers/input/touchscreen/iqs5xx.c index 403e251a5e7d..2a4e048f1400 100644 --- a/drivers/input/touchscreen/iqs5xx.c +++ b/drivers/input/touchscreen/iqs5xx.c @@ -32,7 +32,6 @@ #define IQS5XX_NUM_RETRIES 10 #define IQS5XX_NUM_CONTACTS 5 #define IQS5XX_WR_BYTES_MAX 2 -#define IQS5XX_XY_RES_MAX 0xFFFE #define IQS5XX_PROD_NUM_IQS550 40 #define IQS5XX_PROD_NUM_IQS572 58 @@ -504,10 +503,6 @@ static int iqs5xx_axis_init(struct i2c_client *client) input->open = iqs5xx_open; input->close = iqs5xx_close; - input_set_capability(input, EV_ABS, ABS_MT_POSITION_X); - input_set_capability(input, EV_ABS, ABS_MT_POSITION_Y); - input_set_capability(input, EV_ABS, ABS_MT_PRESSURE); - input_set_drvdata(input, iqs5xx); iqs5xx->input = input; } @@ -520,26 +515,29 @@ static int iqs5xx_axis_init(struct i2c_client *client) if (error) return error; - input_abs_set_max(iqs5xx->input, ABS_MT_POSITION_X, max_x); - input_abs_set_max(iqs5xx->input, ABS_MT_POSITION_Y, max_y); + input_set_abs_params(iqs5xx->input, ABS_MT_POSITION_X, 0, max_x, 0, 0); + input_set_abs_params(iqs5xx->input, ABS_MT_POSITION_Y, 0, max_y, 0, 0); + input_set_abs_params(iqs5xx->input, ABS_MT_PRESSURE, 0, U16_MAX, 0, 0); touchscreen_parse_properties(iqs5xx->input, true, prop); - if (prop->max_x > IQS5XX_XY_RES_MAX) { - dev_err(&client->dev, "Invalid maximum x-coordinate: %u > %u\n", - prop->max_x, IQS5XX_XY_RES_MAX); + /* + * The device reserves 0xFFFF for coordinates that correspond to slots + * which are not in a state of touch. + */ + if (prop->max_x >= U16_MAX || prop->max_y >= U16_MAX) { + dev_err(&client->dev, "Invalid touchscreen size: %u*%u\n", + prop->max_x, prop->max_y); return -EINVAL; - } else if (prop->max_x != max_x) { + } + + if (prop->max_x != max_x) { error = iqs5xx_write_word(client, IQS5XX_X_RES, prop->max_x); if (error) return error; } - if (prop->max_y > IQS5XX_XY_RES_MAX) { - dev_err(&client->dev, "Invalid maximum y-coordinate: %u > %u\n", - prop->max_y, IQS5XX_XY_RES_MAX); - return -EINVAL; - } else if (prop->max_y != max_y) { + if (prop->max_y != max_y) { error = iqs5xx_write_word(client, IQS5XX_Y_RES, prop->max_y); if (error) return error;