From nobody Thu Dec 18 12:46:29 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E76B5C32772 for ; Tue, 23 Aug 2022 08:27:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243396AbiHWI1c (ORCPT ); Tue, 23 Aug 2022 04:27:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242890AbiHWIV6 (ORCPT ); Tue, 23 Aug 2022 04:21:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7443E6B66F; Tue, 23 Aug 2022 01:13:05 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id AAF22612DA; Tue, 23 Aug 2022 08:12:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8D98C43142; Tue, 23 Aug 2022 08:12:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661242358; bh=70zht3iXI+nD4lhGJ7awU9z0EeMuRPW/A6oszaYsjeo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GTc+raHFE4y2rc97//cnIvmAw1TMnw7Ek3RRWMF1FfIDmdZT5P2HuFxYn1dfZcA9R 93JZE1+TMLRx1O2KF9ch0841FaexxTgOqIC0qJS1bilwZsRHStveoH239NW4E9TB4A UAVH5UUnWQ8Go/TaNpl/ADW79OKl33qG6h8MocKI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Fabien Parent , Mattijs Korpershoek , Dmitry Torokhov Subject: [PATCH 5.19 103/365] Input: mt6779-keypad - match hardware matrix organization Date: Tue, 23 Aug 2022 10:00:04 +0200 Message-Id: <20220823080122.513731633@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080118.128342613@linuxfoundation.org> References: <20220823080118.128342613@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Mattijs Korpershoek commit d6ed52583034f9d2e39dead7c18e03380fd4edf2 upstream. The MediaTek keypad has a set of bits representing keys, from KEY0 to KEY77, arranged in 5 chunks of 15 bits split into 5 32-bit registers. In our implementation, we simply decided to use register number as row and offset in the register as column when encoding our "matrix". Because of this, we can have a 5x32 matrix which does not match the hardware at all, which is confusing. Change the row/column calculation to match the hardware. Fixes: f28af984e771 ("Input: mt6779-keypad - add MediaTek keypad driver") Co-developed-by: Fabien Parent Signed-off-by: Fabien Parent Signed-off-by: Mattijs Korpershoek Link: https://lore.kernel.org/r/20220707075236.126631-2-mkorpershoek@baylib= re.com Signed-off-by: Dmitry Torokhov Signed-off-by: Greg Kroah-Hartman --- drivers/input/keyboard/mt6779-keypad.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/input/keyboard/mt6779-keypad.c b/drivers/input/keyboar= d/mt6779-keypad.c index 2e7c9187c10f..bd86cb95bde3 100644 --- a/drivers/input/keyboard/mt6779-keypad.c +++ b/drivers/input/keyboard/mt6779-keypad.c @@ -42,7 +42,7 @@ static irqreturn_t mt6779_keypad_irq_handler(int irq, voi= d *dev_id) const unsigned short *keycode =3D keypad->input_dev->keycode; DECLARE_BITMAP(new_state, MTK_KPD_NUM_BITS); DECLARE_BITMAP(change, MTK_KPD_NUM_BITS); - unsigned int bit_nr; + unsigned int bit_nr, key; unsigned int row, col; unsigned int scancode; unsigned int row_shift =3D get_count_order(keypad->n_cols); @@ -61,8 +61,10 @@ static irqreturn_t mt6779_keypad_irq_handler(int irq, vo= id *dev_id) if (bit_nr % 32 >=3D 16) continue; =20 - row =3D bit_nr / 32; - col =3D bit_nr % 32; + key =3D bit_nr / 32 * 16 + bit_nr % 32; + row =3D key / 9; + col =3D key % 9; + scancode =3D MATRIX_SCAN_CODE(row, col, row_shift); /* 1: not pressed, 0: pressed */ pressed =3D !test_bit(bit_nr, new_state); --=20 2.37.2