From nobody Mon Apr 6 10:44:59 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 538003D1CC9; Fri, 20 Mar 2026 16:44:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774025085; cv=none; b=OsgQGjD/MY/2G5ytrA3m0RBoieeIBOl1xu8n9/XTL7RZfj0TB0s1MYG48QRbJNxmwW2vfIYHyLrWFmxKRhW2NT+T1bq4otpVZz28ZK2dJMr+5L+5J7uJItfA1/xLpClucEQCoU9F3j0udrviviWQAKI8LYf0H3U0r1dFAiBvFmY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774025085; c=relaxed/simple; bh=3JqlcwNzqVml1mGtEsepM1GlRvW7I4xqcXmLf3QfRQ0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lARJw+5QgW0t/zSZ+1Ls7QlyviYFnJOwvzHqK2qM+koZkx1ej9CH1/PTK8pPtgz/81EshKtw8Vi/LppAxInhbHVtYaISXBefLAKo9FMYuuW+26Fvysqvihe4L7b/atNga9owpWsQpnjUEn5gtIUKS4IcVgcEzos2+UqL1dS2Y3E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=svRE+y0z; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="svRE+y0z" Received: by smtp.kernel.org (Postfix) with ESMTPS id 27325C2BCB8; Fri, 20 Mar 2026 16:44:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774025085; bh=3JqlcwNzqVml1mGtEsepM1GlRvW7I4xqcXmLf3QfRQ0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=svRE+y0zcTmYVS0Kvmam0dyXyke8zgbA7qsFFjxANjUT5Gk6LrZJ/+R4cnInj3JIx /2ch+qCdxr/3Bv+ZLakY+XqHFjqE38e70/oe7GIK6wd3iNhsq39ZVn8/mfkC7hGd5c WRMZW5WsQT/bESvN0LVvgfDvIS7v85kN4RBsSH0FLuY4oXQmw5qXnsbMO/Ifv/nRh1 V1Govt8otQi2/+Pa9BisFK+zwef6oeg06xd/FJHePLGaJ/rXRyURHN7i5zagCfpLcJ OK6te09y2qZqHozIjzPam0ELW6VUtda8BJhnGV/Tb0Yd4dXtQPJhAHv89Yyq2mwakB h+asLOFmKMshg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E76A10987B5; Fri, 20 Mar 2026 16:44:45 +0000 (UTC) From: David Heidelberg via B4 Relay Date: Fri, 20 Mar 2026 17:44:48 +0100 Subject: [PATCH v7 7/7] Input: synaptics-rmi4 - support fallback values for PDT descriptor bytes Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260320-synaptics-rmi4-v7-7-379360de18d0@ixit.cz> References: <20260320-synaptics-rmi4-v7-0-379360de18d0@ixit.cz> In-Reply-To: <20260320-synaptics-rmi4-v7-0-379360de18d0@ixit.cz> To: Kaustabh Chakraborty , Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , "Jason A. Donenfeld" , Matthias Schiffer , Vincent Huang Cc: David Heidelberg , linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Casey Connolly , phone-devel@vger.kernel.org X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=5650; i=david@ixit.cz; h=from:subject:message-id; bh=QMO1uzX1oG+qWT4REjO5yGwZjOwaRzQblxJ3S0B14zU=; b=owEBbQKS/ZANAwAIAWACP8TTSSByAcsmYgBpvXl7Q9U4PfdLwey2srzJGevl8h0ui7MAH+72Q qcqBZmvDheJAjMEAAEIAB0WIQTXegnP7twrvVOnBHRgAj/E00kgcgUCab15ewAKCRBgAj/E00kg clvrD/9diJd5zIoKHMycuW8cwdpYvPIbOPmI1d9P9zCktRm+AoYEdCRGN3rQ8iWb4uS3mh6mLPH nd7V1IN2f4shG/5O9nF8qRfn/QAGQn2DQzkWdKnnrbMhB7QNYI1m1VNr+U/FS5jRNrs6fmUSL/M YBd2E4od79C9D40X2Jrrr6pSbocRf3aiCov3F0vZo8QGdtPBpeRWPEnc8O2RYDPoOHxEksmi8aw tyuxrvlT1EVryWOP1uL06L52h4laLAqoXXX+c0hGK4ZFIlJPHtqFl0kgjWSl5pW5Y88H/RGkMM2 WEwjmpJdkL4L+QuXX7CkxFjDAbaT4g6j1EltdwYEzAD/OwPr43IXoDVqM+PApKlbzd5Z6R8eabr Y32kY3h25vKjEwBUSYiiG7zaXfE4TqE8aBzSl0BlWLNENIGFfBEBnLduP6sWTBugN9e+Br+RdNo VtyfxA6SgpbO2qWtXFffbtcRhhS9asc6huLQOrZQ9zdeZmBlvyBUWFqupm503lCAMKoIsJQluxA gBclZ0Qukqmy6lM10CCVcswWlX7sv8iVFI8lF7OuVxC8iLUUM48Jl5e4VVPpjNM5r04D5VJ2hpD b0c0p8h8NcaLUtKBNi5PHdu7SlnXD/8WNuQyREmGHqtn+nSpaLP7Xenr4UFmNligUY/FjiARsgP jOtxnlDdGPMh9lw== X-Developer-Key: i=david@ixit.cz; a=openpgp; fpr=D77A09CFEEDC2BBD53A7047460023FC4D3492072 X-Endpoint-Received: by B4 Relay for david@ixit.cz/default with auth_id=355 X-Original-From: David Heidelberg Reply-To: david@ixit.cz From: Kaustabh Chakraborty Some replacement displays include third-party touch ICs which do not expose the function number and the interrupt status in its PDT entries. OnePlus 6 (original touch IC) rmi4_i2c 12-0020: read 6 bytes at 0x00e3: 0 (2b 22 0d 06 01 01) OnePlus 6 (aftermarket touch IC) rmi4_i2c 12-0020: read 6 bytes at 0x00e3: 0 (2c 23 0d 06 00 00) Signed-off-by: Kaustabh Chakraborty [codeflow adjustments, checkpatch fixes, wording] Signed-off-by: Casey Connolly Co-developed-by: David Heidelberg Signed-off-by: David Heidelberg --- drivers/input/rmi4/rmi_driver.c | 62 +++++++++++++++++++++++++++++++++++--= ---- drivers/input/rmi4/rmi_driver.h | 2 ++ include/linux/rmi.h | 3 ++ 3 files changed, 59 insertions(+), 8 deletions(-) diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_drive= r.c index 93a190e333c66..bb1db5bbb3abb 100644 --- a/drivers/input/rmi4/rmi_driver.c +++ b/drivers/input/rmi4/rmi_driver.c @@ -462,9 +462,10 @@ static int rmi_driver_reset_handler(struct rmi_device = *rmi_dev) return 0; } =20 -static int rmi_read_pdt_entry(struct rmi_device *rmi_dev, - struct pdt_entry *entry, u16 pdt_address) +static int rmi_read_pdt_entry(struct rmi_device *rmi_dev, struct pdt_entry= *entry, + struct pdt_scan_state *state, u16 pdt_address) { + const struct rmi_device_platform_data *pdata =3D rmi_get_platform_data(rm= i_dev); u8 buf[RMI_PDT_ENTRY_SIZE]; int error; =20 @@ -475,6 +476,21 @@ static int rmi_read_pdt_entry(struct rmi_device *rmi_d= ev, return error; } =20 + if (pdata->pdt_fallback_size > state->pdt_count * RMI_OF_PDT_DESC_CELLS += 1) { + /* Use the description bytes from the driver */ + buf[5] =3D pdata->pdt_fallback_desc[state->pdt_count * RMI_OF_PDT_DESC_C= ELLS]; + buf[4] =3D pdata->pdt_fallback_desc[state->pdt_count * RMI_OF_PDT_DESC_C= ELLS + 1]; + + error =3D rmi_read_block(rmi_dev, pdt_address, buf, + RMI_PDT_ENTRY_SIZE - 2); + if (error) { + dev_err(&rmi_dev->dev, + "Read PDT entry at %#06x failed, code: %d.\n", + pdt_address, error); + return error; + } + } + entry->page_start =3D pdt_address & RMI4_PAGE_MASK; entry->query_base_addr =3D buf[0]; entry->command_base_addr =3D buf[1]; @@ -547,7 +563,7 @@ static int rmi_scan_pdt_page(struct rmi_device *rmi_dev, int retval; =20 for (addr =3D pdt_start; addr >=3D pdt_end; addr -=3D RMI_PDT_ENTRY_SIZE)= { - error =3D rmi_read_pdt_entry(rmi_dev, &pdt_entry, addr); + error =3D rmi_read_pdt_entry(rmi_dev, &pdt_entry, state, addr); if (error) return error; =20 @@ -1024,9 +1040,13 @@ static int rmi_driver_remove(struct device *dev) } =20 #ifdef CONFIG_OF -static int rmi_driver_of_probe(struct device *dev, - struct rmi_device_platform_data *pdata) +static const u8 rmi_s3706_fallback_pdt[] =3D {34, 41, 01, 01, 12, 01}; + +static int rmi_driver_of_probe(struct rmi_device *rmi_dev, + struct rmi_device_platform_data *pdata) { + struct device *dev =3D rmi_dev->xport->dev; + u8 buf[RMI_PDT_ENTRY_SIZE]; int retval; =20 retval =3D rmi_of_property_read_u32(dev, &pdata->reset_delay_ms, @@ -1034,11 +1054,37 @@ static int rmi_driver_of_probe(struct device *dev, if (retval) return retval; =20 + /* + * In some aftermerket touch ICs, the first PDT entry is empty and + * the function number register is 0. If so, the driver + * may have provide backup PDT entries. + */ + + retval =3D rmi_read_block(rmi_dev, PDT_START_SCAN_LOCATION, + buf, RMI_PDT_ENTRY_SIZE); + if (retval) { + dev_err(dev, "Read PDT entry at %#06x failed, code: %d.\n", + PDT_START_SCAN_LOCATION, retval); + return retval; + } + + if (!RMI4_END_OF_PDT(buf[5])) + return 0; + + /* List of known PDT entries per compatible. */ + if (of_device_is_compatible(dev->of_node, "syna,rmi4-s3706b")) { + pdata->pdt_fallback_desc =3D rmi_s3706_fallback_pdt; + pdata->pdt_fallback_size =3D ARRAY_SIZE(rmi_s3706_fallback_pdt); + } else { + dev_err(dev, "First PDT entry is empty and no backup values provided.\n"= ); + return -EINVAL; + } + return 0; } #else -static inline int rmi_driver_of_probe(struct device *dev, - struct rmi_device_platform_data *pdata) +static inline int rmi_driver_of_probe(struct rmi_device *rmi_dev, + struct rmi_device_platform_data *pdata) { return -ENODEV; } @@ -1159,7 +1205,7 @@ static int rmi_driver_probe(struct device *dev) pdata =3D rmi_get_platform_data(rmi_dev); =20 if (rmi_dev->xport->dev->of_node) { - retval =3D rmi_driver_of_probe(rmi_dev->xport->dev, pdata); + retval =3D rmi_driver_of_probe(rmi_dev, pdata); if (retval) return retval; } diff --git a/drivers/input/rmi4/rmi_driver.h b/drivers/input/rmi4/rmi_drive= r.h index a4ae2af93ce3a..b931f428713bf 100644 --- a/drivers/input/rmi4/rmi_driver.h +++ b/drivers/input/rmi4/rmi_driver.h @@ -31,6 +31,8 @@ #define RMI_PDT_FUNCTION_VERSION_MASK 0x60 #define RMI_PDT_INT_SOURCE_COUNT_MASK 0x07 =20 +#define RMI_OF_PDT_DESC_CELLS 2 + #define PDT_START_SCAN_LOCATION 0x00e9 #define PDT_END_SCAN_LOCATION 0x0005 #define RMI4_END_OF_PDT(id) ((id) =3D=3D 0x00 || (id) =3D=3D 0xff) diff --git a/include/linux/rmi.h b/include/linux/rmi.h index ab7eea01ab427..4ba2cefac8558 100644 --- a/include/linux/rmi.h +++ b/include/linux/rmi.h @@ -214,6 +214,9 @@ struct rmi_device_platform_data { int reset_delay_ms; int irq; =20 + unsigned int pdt_fallback_size; + const u8 *pdt_fallback_desc; + struct rmi_device_platform_data_spi spi_data; =20 /* function handler pdata */ --=20 2.53.0