From patchwork Sat May 3 09:08:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaustabh Chakraborty X-Patchwork-Id: 887052 Received: from layka.disroot.org (layka.disroot.org [178.21.23.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0BCA41B3956; Sat, 3 May 2025 09:08:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.21.23.139 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746263334; cv=none; b=I/fvHit5nWmMlTg6K7/HhydiBSNo5NDOTObsrEs4QvPsSl3QjXpz7RP9rmEh7KvzSjpZnHstblGL23NaUogOzMneCdYCzJujtgfR2KED/6Hku2lB11etAXbEfSL0ecuRLFrZfFNJDI+UYg+9UvoxDkjOZIbB/Cx8Cv6dhVJ80o4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746263334; c=relaxed/simple; bh=JDWmFaDxoZVY3gQxu6nB8V2vVs15BbtJjuJfl1PZll8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DwbNb3QJkm2dTLWjBcTPcPHlSX/SRnvSDLgLMqcsE2o9wRIUymmKjkIoIBH/k4us80bkD3ZFC2qz5sVU2ckbiQvLhg/ZAZK/M7Z4yPDssY8SBqpmsf9fVKUkeb+a2XuVonoMCYNai/YGdaiou9ks8j8egJTfqst2Fk4Ko7czvuU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org; spf=pass smtp.mailfrom=disroot.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b=Nz9Q+Dit; arc=none smtp.client-ip=178.21.23.139 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=disroot.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b="Nz9Q+Dit" Received: from mail01.disroot.lan (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 1786925ED4; Sat, 3 May 2025 11:08:50 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id qdsQ83TAFIVs; Sat, 3 May 2025 11:08:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1746263329; bh=JDWmFaDxoZVY3gQxu6nB8V2vVs15BbtJjuJfl1PZll8=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=Nz9Q+Dit/VyelFL41ecgnR90UZhdFzNfLWY775bu2LKk/svJh5IkP/id4PJ9wngZI ZXeYLSbaLldv8ZHKp9Pe20Z9nbjWqm/DNrqFhbWDzO9r2YR+M1Mi2imuTTrf9fe5xK CHNmZA5NQ8PhE5PIS4dFoySAKwOuSzC9ii+0w6orajs4n/Rpk1vr3pjciKNCNI++ef sPoUxHqpDfM0CPNrp9Khu+9wUz5Jtt9ge7DdYcHoye6DIab7sxKHjGaFlYMMVdj9ZH 4rSMI2pyKKzrae4zCNn6SqXaHCyl9EADkbIwbs8s7GGspQ39SLBzsLQjmytYCCBzdS W4XoP3AxGCOIA== From: Kaustabh Chakraborty Date: Sat, 03 May 2025 14:38:27 +0530 Subject: [PATCH RFC 1/4] dt-bindings: input: melfas-mip4: document linux,keycodes property Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250503-mip4-touchkey-v1-1-b483cda29a5b@disroot.org> References: <20250503-mip4-touchkey-v1-0-b483cda29a5b@disroot.org> In-Reply-To: <20250503-mip4-touchkey-v1-0-b483cda29a5b@disroot.org> To: Sangwon Jee , Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Henrik Rydberg Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Kaustabh Chakraborty X-Developer-Signature: v=1; a=ed25519-sha256; t=1746263323; l=1179; i=kauschluss@disroot.org; s=20250202; h=from:subject:message-id; bh=JDWmFaDxoZVY3gQxu6nB8V2vVs15BbtJjuJfl1PZll8=; b=zHf3GWA9mgYVqAJKyKz0DaMzGfak5Y06FmzYPjE0g+4kmNt4/kC7UZED47jPidQGFvLrquOV+ 4dcJ3oE6pwJAyXbBJ6qT2Itv40jINxBlS4OLe8Mg6PlzAJeFXYh/2G7 X-Developer-Key: i=kauschluss@disroot.org; a=ed25519; pk=h2xeR+V2I1+GrfDPAhZa3M+NWA0Cnbdkkq1bH3ct1hE= Document the linux,keycodes property. The property values are key codes which are used in input key events generated by the touchkey device. Signed-off-by: Kaustabh Chakraborty --- Documentation/devicetree/bindings/input/touchscreen/melfas_mip4.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/input/touchscreen/melfas_mip4.txt b/Documentation/devicetree/bindings/input/touchscreen/melfas_mip4.txt index b2ab5498e51900e887fab4d9b5239cccccec2ea9..16d1031ee017604ac56109dfbebfce6a05491c60 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/melfas_mip4.txt +++ b/Documentation/devicetree/bindings/input/touchscreen/melfas_mip4.txt @@ -7,6 +7,7 @@ Required properties: Optional properties: - ce-gpios: GPIO connected to the CE (chip enable) pin of the chip +- linux,keycodes: array of keycodes to be reported by touchkeys Example: i2c@00000000 { @@ -16,5 +17,6 @@ Example: interrupt-parent = <&gpio>; interrupts = <0 IRQ_TYPE_EDGE_FALLING>; ce-gpios = <&gpio 0 GPIO_ACTIVE_HIGH>; + linux,keycodes = , ; }; }; From patchwork Sat May 3 09:08:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaustabh Chakraborty X-Patchwork-Id: 887292 Received: from layka.disroot.org (layka.disroot.org [178.21.23.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 985351DDA00; Sat, 3 May 2025 09:08:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.21.23.139 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746263338; cv=none; b=q/HSlfcuo8w2UzHRofUDvQJbSbRW02Q4G99nODwSyreYKE70+KpdPvUDzTau2LAdcTny9mHq0SfVgB8nV9+rMefpAkX+PUPM1nGzI1NWedzQXtPiSlTRKzDzi3EhgW8X4sX6ErneHRtNTwGgXbSIH0aC1ZfVqeuIJh5bABFx6VM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746263338; c=relaxed/simple; bh=fg5AoTsDiUevWYSsxPAW01tdMPFTPzlekM5HpegsD7U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Bv7/AeCzH61HMjFjBq0UGIdeMSyu5wD+CiORlsuo5sNmb7iijBy/RiKpe/Azh9XBWZUfAxjryavX5TLzBS1zRVr383CgOc316C3w46jjS1VsLRR8rmdsJVfbn/VxLkrPmYtZEkUKbRsz2rOscag01QfNQ+h9TKO81aizQghQBoM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org; spf=pass smtp.mailfrom=disroot.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b=LJezFwE4; arc=none smtp.client-ip=178.21.23.139 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=disroot.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b="LJezFwE4" Received: from mail01.disroot.lan (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 1EFD925D3B; Sat, 3 May 2025 11:08:53 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id nysnAGpSfo57; Sat, 3 May 2025 11:08:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1746263332; bh=fg5AoTsDiUevWYSsxPAW01tdMPFTPzlekM5HpegsD7U=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=LJezFwE4O6zoPwaOTawzSIaz/HsxGpWWkF+Wgr+xblqQWHFDGhlJWOdHRjlPR+pjo yJRi1GBZv+AJFLw221/sdB2mtB6NCI3dZs626WARXVKPDVZuEDVnMtOwdp+J4uPLQT 3RO/yUVKXRAp4hhr+0KMFmHt5g+IGlCR8EAePoIMSQU+bi6xOHwCePGCFSuOJE1QKz 4/qjrk5yG39lKLzre62vR8TXbidzcg50mURH6Ou8K3vMWN/dlNYDJJQzApO5QjtUZT L8dABXxiloh8sSAxgnBWURxwyTANIqukWU94iKpmj2PnLTqkugg1Q9T6hd07vxkZcC Tg2s8Vx7lkD3Q== From: Kaustabh Chakraborty Date: Sat, 03 May 2025 14:38:28 +0530 Subject: [PATCH RFC 2/4] Input: melfas-mip4 - add support for touchkey input events Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250503-mip4-touchkey-v1-2-b483cda29a5b@disroot.org> References: <20250503-mip4-touchkey-v1-0-b483cda29a5b@disroot.org> In-Reply-To: <20250503-mip4-touchkey-v1-0-b483cda29a5b@disroot.org> To: Sangwon Jee , Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Henrik Rydberg Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Kaustabh Chakraborty X-Developer-Signature: v=1; a=ed25519-sha256; t=1746263323; l=3116; i=kauschluss@disroot.org; s=20250202; h=from:subject:message-id; bh=fg5AoTsDiUevWYSsxPAW01tdMPFTPzlekM5HpegsD7U=; b=YCttFFSeRL9zsyyPp/Jogg8qRrgeKuXK9PFKq84ASqzmwPF8C2ofLlxMHoVzTnNz14MEGXz/p Z6Lb0B0Ur/EDhybQwI+JJQ8+cl3T0XuS1CgQQJcWW17Gs4wyBEoOJAG X-Developer-Key: i=kauschluss@disroot.org; a=ed25519; pk=h2xeR+V2I1+GrfDPAhZa3M+NWA0Cnbdkkq1bH3ct1hE= The MIP4 protocol are supposed to support touchscreens, touchkeys, and combo-devices. The driver handles touchscreen events, but touchkey events are unimplemented. Implement them. If compiled with devicetree support, the driver attempts to retrieve keycodes from a property named "linux,keycodes". Signed-off-by: Kaustabh Chakraborty --- drivers/input/touchscreen/melfas_mip4.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/drivers/input/touchscreen/melfas_mip4.c b/drivers/input/touchscreen/melfas_mip4.c index a6946e3d8376d7e9b4c26f4194409e0ba78bb075..061ac353bc7a2e28f17581411af81f35c89733a1 100644 --- a/drivers/input/touchscreen/melfas_mip4.c +++ b/drivers/input/touchscreen/melfas_mip4.c @@ -169,7 +169,7 @@ struct mip4_ts { unsigned int event_format; unsigned int key_num; - unsigned short key_code[MIP4_MAX_KEYS]; + unsigned int key_code[MIP4_MAX_KEYS]; bool wake_irq_enabled; @@ -337,8 +337,13 @@ static int mip4_query_device(struct mip4_ts *ts) ts->ppm_x, ts->ppm_y); /* Key ts */ - if (ts->node_key > 0) + if (ts->node_key > MIP4_MAX_KEYS) { + dev_warn(&ts->client->dev, + "Too many keys (%u) found\n", ts->node_key); + ts->key_num = MIP4_MAX_KEYS; + } else { ts->key_num = ts->node_key; + } } /* Protocol */ @@ -1080,6 +1085,7 @@ static int mip4_flash_fw(struct mip4_ts *ts, const u8 *fw_data, u32 fw_size, u32 fw_offset) { struct i2c_client *client = ts->client; + unsigned int i; int offset; u16 buf_addr; int error, error2; @@ -1149,6 +1155,11 @@ static int mip4_flash_fw(struct mip4_ts *ts, input_abs_set_res(ts->input, ABS_X, ts->ppm_x); input_abs_set_res(ts->input, ABS_Y, ts->ppm_y); + for (i = 0; i < ts->key_num; i++) { + if (ts->key_code[i]) + input_set_capability(ts->input, EV_KEY, ts->key_code[i]); + } + return error ? error : 0; } @@ -1425,6 +1436,7 @@ static int mip4_probe(struct i2c_client *client) { struct mip4_ts *ts; struct input_dev *input; + unsigned int i; int error; if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { @@ -1471,6 +1483,17 @@ static int mip4_probe(struct i2c_client *client) input_set_drvdata(input, ts); +#ifdef CONFIG_OF + error = of_property_read_u32_array(client->dev.of_node, "linux,keycodes", + ts->key_code, ts->key_num); + if (error && ts->key_num) { + dev_warn(&client->dev, + "Failed to get codes for %u supported keys", ts->key_num); + /* Disable touchkey support */ + ts->key_num = 0; + } +#endif + input->keycode = ts->key_code; input->keycodesize = sizeof(*ts->key_code); input->keycodemax = ts->key_num; @@ -1491,6 +1514,11 @@ static int mip4_probe(struct i2c_client *client) if (error) return error; + for (i = 0; i < ts->key_num; i++) { + if (ts->key_code[i]) + input_set_capability(input, EV_KEY, ts->key_code[i]); + } + i2c_set_clientdata(client, ts); error = devm_request_threaded_irq(&client->dev, client->irq, From patchwork Sat May 3 09:08:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaustabh Chakraborty X-Patchwork-Id: 887051 Received: from layka.disroot.org (layka.disroot.org [178.21.23.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7A5F1DE2CC; Sat, 3 May 2025 09:08:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.21.23.139 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746263339; cv=none; b=fnzdD35NB+o5csNEvGenZYfW7L67ThF6RAJx4znUDjIenGIFd6J4HOoHD4pMMCb7fmnGkB1bFrWsg6hx3bACi1SzCSyFi1z0FLvikCqL04Ap7xfs7oGdVJHktY9s5++IAFXepqfvMXuVydpryjuVSgnxkJSiB3O3OcZ1RbbCzZw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746263339; c=relaxed/simple; bh=db09hgbzvuUJ1yzYHRq+CAMm77k09qcfo3UfxtjsWeY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=p4Y4YYXZLuRJufhTadXXnVz35xNDHpreu+hSlH2po9SzmsFsObINcwYCxDXlxarMsKiAQOUZcj3WDl9pUNLR74KiAT5F3+jmc/798I4wRWHq2KtLV3LkpuulQTHPnhZ8z0qHoC9c1BMEitZY5MwLvJLNmtQ3bJt7YH0bXkVJnPc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org; spf=pass smtp.mailfrom=disroot.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b=PDK9adsk; arc=none smtp.client-ip=178.21.23.139 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=disroot.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b="PDK9adsk" Received: from mail01.disroot.lan (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 10D7225CE4; Sat, 3 May 2025 11:08:56 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id AE5XxdhkPRVy; Sat, 3 May 2025 11:08:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1746263335; bh=db09hgbzvuUJ1yzYHRq+CAMm77k09qcfo3UfxtjsWeY=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=PDK9adskaoiTMMT9sGngElY1esVrk6c6kFyNwIy5bP9jrvctnQUHtMvAr5+pTp+XG PWwRb7QCajx3FtIOP5zIpM8goDvvnqzTxp/sRT5Y9AmdmCu+hPANJ/SkqIZtznr046 hUBAGJPByCv2HEYy8WbyTZAnBHKWquS3Ch7P30jdgM8Kjfdna0bVQd7RT9N5EXAJzI xZOkxeuyqfPrUiyNUt9djTWngdWekzCSOBnOu5RUl8QXb8FIi7lQwGI4BjWKpsk79P tlBz/EyhcCsPgp1ZPhAEuLkoK2KewNyQ+W4ye4Jj5s0vEXf7mluntCwmJ49TIaJaNi q2VDM7MlXDZ2A== From: Kaustabh Chakraborty Date: Sat, 03 May 2025 14:38:29 +0530 Subject: [PATCH RFC 3/4] Input: melfas-mip4 - initialize touch events only if the device is a touchscreen Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250503-mip4-touchkey-v1-3-b483cda29a5b@disroot.org> References: <20250503-mip4-touchkey-v1-0-b483cda29a5b@disroot.org> In-Reply-To: <20250503-mip4-touchkey-v1-0-b483cda29a5b@disroot.org> To: Sangwon Jee , Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Henrik Rydberg Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Kaustabh Chakraborty X-Developer-Signature: v=1; a=ed25519-sha256; t=1746263323; l=3948; i=kauschluss@disroot.org; s=20250202; h=from:subject:message-id; bh=db09hgbzvuUJ1yzYHRq+CAMm77k09qcfo3UfxtjsWeY=; b=wlrUg1ONopq6BlhLWr2/7scfe+Kbt+zSC+HxlGSWE2gWSQVyTiboC3DS4GmI0iSlOh2It7E8G wvEdy7hcaD5D7ZUPuuRdHfGkcbLAvBokq0/P+M5WRFcPvCNnmEUtobq X-Developer-Key: i=kauschluss@disroot.org; a=ed25519; pk=h2xeR+V2I1+GrfDPAhZa3M+NWA0Cnbdkkq1bH3ct1hE= Certain MIP4 devices report zero values when enquired for its touchscreen dimensions (MIP4_R1_INFO_RESOLUTION_X and MIP4_R1_INFO_RESOLUTION_Y), which is indicative of the fact that those devices are not touchscreens. While registering for touch events for the device, always check - and proceed - only if the device reports a non-zero resolution. Signed-off-by: Kaustabh Chakraborty --- drivers/input/touchscreen/melfas_mip4.c | 50 ++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/drivers/input/touchscreen/melfas_mip4.c b/drivers/input/touchscreen/melfas_mip4.c index 061ac353bc7a2e28f17581411af81f35c89733a1..57b657694a420220be135c2f78d3ddad3ef6f520 100644 --- a/drivers/input/touchscreen/melfas_mip4.c +++ b/drivers/input/touchscreen/melfas_mip4.c @@ -1146,14 +1146,16 @@ static int mip4_flash_fw(struct mip4_ts *ts, mip4_query_device(ts); /* Refresh device parameters */ - input_set_abs_params(ts->input, ABS_MT_POSITION_X, 0, ts->max_x, 0, 0); - input_set_abs_params(ts->input, ABS_MT_POSITION_Y, 0, ts->max_y, 0, 0); - input_set_abs_params(ts->input, ABS_X, 0, ts->max_x, 0, 0); - input_set_abs_params(ts->input, ABS_Y, 0, ts->max_y, 0, 0); - input_abs_set_res(ts->input, ABS_MT_POSITION_X, ts->ppm_x); - input_abs_set_res(ts->input, ABS_MT_POSITION_Y, ts->ppm_y); - input_abs_set_res(ts->input, ABS_X, ts->ppm_x); - input_abs_set_res(ts->input, ABS_Y, ts->ppm_y); + if (ts->max_x && ts->max_y) { + input_set_abs_params(ts->input, ABS_MT_POSITION_X, 0, ts->max_x, 0, 0); + input_set_abs_params(ts->input, ABS_MT_POSITION_Y, 0, ts->max_y, 0, 0); + input_set_abs_params(ts->input, ABS_X, 0, ts->max_x, 0, 0); + input_set_abs_params(ts->input, ABS_Y, 0, ts->max_y, 0, 0); + input_abs_set_res(ts->input, ABS_MT_POSITION_X, ts->ppm_x); + input_abs_set_res(ts->input, ABS_MT_POSITION_Y, ts->ppm_y); + input_abs_set_res(ts->input, ABS_X, ts->ppm_x); + input_abs_set_res(ts->input, ABS_Y, ts->ppm_y); + } for (i = 0; i < ts->key_num; i++) { if (ts->key_code[i]) @@ -1498,21 +1500,23 @@ static int mip4_probe(struct i2c_client *client) input->keycodesize = sizeof(*ts->key_code); input->keycodemax = ts->key_num; - input_set_abs_params(input, ABS_MT_TOOL_TYPE, 0, MT_TOOL_PALM, 0, 0); - input_set_abs_params(input, ABS_MT_POSITION_X, 0, ts->max_x, 0, 0); - input_set_abs_params(input, ABS_MT_POSITION_Y, 0, ts->max_y, 0, 0); - input_set_abs_params(input, ABS_MT_PRESSURE, - MIP4_PRESSURE_MIN, MIP4_PRESSURE_MAX, 0, 0); - input_set_abs_params(input, ABS_MT_TOUCH_MAJOR, - MIP4_TOUCH_MAJOR_MIN, MIP4_TOUCH_MAJOR_MAX, 0, 0); - input_set_abs_params(input, ABS_MT_TOUCH_MINOR, - MIP4_TOUCH_MINOR_MIN, MIP4_TOUCH_MINOR_MAX, 0, 0); - input_abs_set_res(ts->input, ABS_MT_POSITION_X, ts->ppm_x); - input_abs_set_res(ts->input, ABS_MT_POSITION_Y, ts->ppm_y); - - error = input_mt_init_slots(input, MIP4_MAX_FINGERS, INPUT_MT_DIRECT); - if (error) - return error; + if (ts->max_x && ts->max_y) { + input_set_abs_params(input, ABS_MT_TOOL_TYPE, 0, MT_TOOL_PALM, 0, 0); + input_set_abs_params(input, ABS_MT_POSITION_X, 0, ts->max_x, 0, 0); + input_set_abs_params(input, ABS_MT_POSITION_Y, 0, ts->max_y, 0, 0); + input_set_abs_params(input, ABS_MT_PRESSURE, + MIP4_PRESSURE_MIN, MIP4_PRESSURE_MAX, 0, 0); + input_set_abs_params(input, ABS_MT_TOUCH_MAJOR, + MIP4_TOUCH_MAJOR_MIN, MIP4_TOUCH_MAJOR_MAX, 0, 0); + input_set_abs_params(input, ABS_MT_TOUCH_MINOR, + MIP4_TOUCH_MINOR_MIN, MIP4_TOUCH_MINOR_MAX, 0, 0); + input_abs_set_res(ts->input, ABS_MT_POSITION_X, ts->ppm_x); + input_abs_set_res(ts->input, ABS_MT_POSITION_Y, ts->ppm_y); + + error = input_mt_init_slots(input, MIP4_MAX_FINGERS, INPUT_MT_DIRECT); + if (error) + return error; + } for (i = 0; i < ts->key_num; i++) { if (ts->key_code[i]) From patchwork Sat May 3 09:08:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaustabh Chakraborty X-Patchwork-Id: 887291 Received: from layka.disroot.org (layka.disroot.org [178.21.23.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5442D1E1041; Sat, 3 May 2025 09:09:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.21.23.139 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746263341; cv=none; b=FSETU3+Vtb3XQ2qY0LWQ5XRSlItvnjDlABFh1jQPB1R9rfixY8UqYhA+RoEr7j9ws+xpFrF/IqHH2S+oVGCgwRrlr87jHfn/nH8NIwkEOI2ar6iQVMrzSkuQJF5WzuIOFVbcG93h6U1sbwl+x0j965HlgomUmADxmnJNSzdGc/U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746263341; c=relaxed/simple; bh=5Ehg8aQGjsmQjFGFetFWzPdWaPT+YpJgL6j24A8jE6I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KZgdbIgL+8/1/s3MdNE8Bx5MVa5qAbsTikrd+mw3wgkW3nd+flXL50ARr4KdTZUTV4PrP2RanHGrq8NSfvOgF62lVNGvxRjS2V+a4QenRkXeSBgsJ3z6F587tDAyUQDhbWR7HMjoPJdtjUX1xVzs4iBfR/7LOrPaKbKXKdk3U6g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org; spf=pass smtp.mailfrom=disroot.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b=f61YVFsd; arc=none smtp.client-ip=178.21.23.139 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=disroot.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b="f61YVFsd" Received: from mail01.disroot.lan (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 1C45425DA3; Sat, 3 May 2025 11:08:59 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 7-CJBNnZefvM; Sat, 3 May 2025 11:08:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1746263338; bh=5Ehg8aQGjsmQjFGFetFWzPdWaPT+YpJgL6j24A8jE6I=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=f61YVFsdF+CKMaZb2y/knpFU/fkUZvkKAhHxfBo5p6IdU9ndhC7ppsyMWAnO4q+Bw bbsPsMPNgko41UNU2sq5XTJ/PT/L/cISYONIYzeXFgo40Tx7TvIneDOFGFocK67y4l 0n61gGcZRkfx+Zsy2GoA/UXx4RONt4VRnAysjq04YnEO/tCEzhzdVLN2SvlJZOXBV4 8rX+dYmUS4kGJE6D8sEk4IaV+ZACGr03fNMUHeA0PZ/K36yteuLb5NzXLF6aXh5Lxp qTYVgdwOPc7t3jb0Yp12Of44QzAIYOZWsHrhvuQc3OFACx+yPuUTXFi6yCfdUYGpD7 C6qK2Jjg61/JQ== From: Kaustabh Chakraborty Date: Sat, 03 May 2025 14:38:30 +0530 Subject: [PATCH RFC 4/4] Input: melfas-mip4 - add support for event formats 4 and 9 Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250503-mip4-touchkey-v1-4-b483cda29a5b@disroot.org> References: <20250503-mip4-touchkey-v1-0-b483cda29a5b@disroot.org> In-Reply-To: <20250503-mip4-touchkey-v1-0-b483cda29a5b@disroot.org> To: Sangwon Jee , Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Henrik Rydberg Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Kaustabh Chakraborty X-Developer-Signature: v=1; a=ed25519-sha256; t=1746263323; l=1820; i=kauschluss@disroot.org; s=20250202; h=from:subject:message-id; bh=5Ehg8aQGjsmQjFGFetFWzPdWaPT+YpJgL6j24A8jE6I=; b=Sew6ti7sPKMTm/ndloE+nJ0EfetoZLWaI8nmFXFOcUVHBRHbuQ4Qlb87y9FaGhF+EEL7FYpzr zbaqhzjMAgsCUwYreLNmJLWGMiSd/etJe58aigFrtkZMKfmFw4rySOL X-Developer-Key: i=kauschluss@disroot.org; a=ed25519; pk=h2xeR+V2I1+GrfDPAhZa3M+NWA0Cnbdkkq1bH3ct1hE= Valid event formats in this driver is limited to 0, 1, and 3. These are event formats for MIP4 touchscreen devices. Add support for event formats 4 and 9, which belong to touchkey devices. While at it, simplify the logic in function mip4_query_device where valid event formats are checked. Use a human-readable switch-case block instead of an if statement with obscure conditions. Signed-off-by: Kaustabh Chakraborty --- drivers/input/touchscreen/melfas_mip4.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/melfas_mip4.c b/drivers/input/touchscreen/melfas_mip4.c index 57b657694a420220be135c2f78d3ddad3ef6f520..95a78c86873355d0a8e0207b1eb4a8408f55cee4 100644 --- a/drivers/input/touchscreen/melfas_mip4.c +++ b/drivers/input/touchscreen/melfas_mip4.c @@ -360,9 +360,19 @@ static int mip4_query_device(struct mip4_ts *ts) dev_dbg(&ts->client->dev, "event_format: %d, event_size: %d\n", ts->event_format, ts->event_size); - if (ts->event_format == 2 || ts->event_format > 3) + switch (ts->event_format) { + /* Touchscreens */ + case 0: + case 1: + case 3: + /* Touchkeys */ + case 4: + case 9: + break; + default: dev_warn(&ts->client->dev, "Unknown event format %d\n", ts->event_format); + } } return 0; @@ -440,6 +450,8 @@ static void mip4_report_keys(struct mip4_ts *ts, u8 *packet) switch (ts->event_format) { case 0: case 1: + case 4: + case 9: key = packet[0] & 0x0F; down = packet[0] & 0x80; break; @@ -552,6 +564,8 @@ static int mip4_handle_packet(struct mip4_ts *ts, u8 *packet) switch (ts->event_format) { case 0: case 1: + case 4: + case 9: type = (packet[0] & 0x40) >> 6; break;