From mboxrd@z Thu Jan 1 00:00:00 1970 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 4AFCACCA48A for ; Thu, 21 Jul 2022 14:51:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231815AbiGUOvz (ORCPT ); Thu, 21 Jul 2022 10:51:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232478AbiGUOvk (ORCPT ); Thu, 21 Jul 2022 10:51:40 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24A2B2656A for ; Thu, 21 Jul 2022 07:51:32 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id d8so2632002wrp.6 for ; Thu, 21 Jul 2022 07:51:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=IPaODleuydbpyW0oBL1XNwJwvfUIp3A8aiBZ01eGt1Q=; b=Bp2CpXtTwoG2Mnt4Fsd7PNBiqhFzvabUoEaCdKBe3coRfhSaMn+IIzpniKnrnFrdUL YhHsz3Ra5N7e+r023RiThEm579WWFjxT2W0IebSd/oCBBUrkN2xOrQcsyBg6JyfJ/B06 uW2TLiUxl2xnqjMml93W/ohzP0oDXt+rL55KYML2aeVYi9E9IwK0fr75+lVU9M4E6WHn w+wMYeCQ/PNSDSqlUkF0fvC4GDYMUpr7/gqG3lio6pvxXZ229AUfF0LOIV9uFJw/fDXj xPhrjpbrWMoF9dB7pyMhKmgN+M7JS8WWrZtMk0sg7uhJaH7SOHY7byVkp4DdroOI7rGq 6F3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=IPaODleuydbpyW0oBL1XNwJwvfUIp3A8aiBZ01eGt1Q=; b=qPG59TK6vRPfSxH9KMIBY0rOfirzTPXewwjTCJ5ks6PRE8AE3RPMMwg+dLXiz50mMz +Bp91ePHOcuFexmaaHFMqtiEHFAOr4vLl0aHkPKoCZubRDOiOM1/3jJjYdVowbyySY0f 7WyKuEtzKnvJjLOBs+cUkxw8n2jB+QPSbGK1m1u9hncsZEKkTJFfimzmmtUxuxbASY1L /no44BI0ouMdUVrid+EJaFWTIJeUxbJIs0iL+LdjyxwNk+1kmq/AEtC/JB18/JBS8cnJ U/QoFGb4WZyF+6KCOfY/54r509KPW5W/r48ja/froZec2HYaS9Umm10mhJLClLB7naGu m+Ow== X-Gm-Message-State: AJIora/DSg6h0Eqp4nKUFs+4K1A1plWbNmoBb1+wkYXXr8x1GlkBWmgp m23CSD2vV3TMWhxvOFm51RYRsg== X-Google-Smtp-Source: AGRyM1sfP4ZknR79BKzwBYDjRzsvFl6fMqYkGmVH+vZxkOOLeoF5imavLdHStfa8XEkO8/4kwJBLWg== X-Received: by 2002:adf:f0c6:0:b0:21e:4480:2fa5 with SMTP id x6-20020adff0c6000000b0021e44802fa5mr9138352wro.377.1658415090631; Thu, 21 Jul 2022 07:51:30 -0700 (PDT) Received: from localhost ([82.66.159.240]) by smtp.gmail.com with ESMTPSA id q5-20020a1ce905000000b003a0323463absm2087311wmc.45.2022.07.21.07.51.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Jul 2022 07:51:30 -0700 (PDT) From: Mattijs Korpershoek To: AngeloGioacchino Del Regno , Rob Herring , Krzysztof Kozlowski , Dmitry Torokhov , Matthias Brugger Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, Fabien Parent , devicetree@vger.kernel.org, linux-mediatek@lists.infradead.org, Fabien Parent , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v1 4/6] Input: mt6779-keypad - support double keys matrix In-Reply-To: References: <20220720-mt8183-keypad-v1-0-ef9fc29dbff4@baylibre.com> <20220720-mt8183-keypad-v1-4-ef9fc29dbff4@baylibre.com> Date: Thu, 21 Jul 2022 16:51:29 +0200 Message-ID: <87ilnqh632.fsf@baylibre.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org On Thu, Jul 21, 2022 at 10:34, AngeloGioacchino Del Regno wrote: > Il 20/07/22 16:48, Mattijs Korpershoek ha scritto: >> MediaTek keypad has 2 modes of detecting key events: >> - single key: each (row, column) can detect one key >> - double key: each (row, column) is a group of 2 keys >> >> Double key support exists to minimize cost, since it reduces the number >> of pins required for physical keys. >> >> Double key is configured by setting BIT(0) of the KP_SEL register. >> >> Enable double key matrix support based on the mediatek,double-keys >> device tree property. >> >> Signed-off-by: Mattijs Korpershoek >> Reviewed-by: Matthias Brugger >> >> diff --git a/drivers/input/keyboard/mt6779-keypad.c b/drivers/input/keyboard/mt6779-keypad.c >> index bf447bf598fb..9a5dbd415dac 100644 >> --- a/drivers/input/keyboard/mt6779-keypad.c >> +++ b/drivers/input/keyboard/mt6779-keypad.c >> @@ -18,6 +18,7 @@ >> #define MTK_KPD_DEBOUNCE_MASK GENMASK(13, 0) >> #define MTK_KPD_DEBOUNCE_MAX_MS 256 >> #define MTK_KPD_SEL 0x0020 >> +#define MTK_KPD_SEL_DOUBLE_KP_MODE BIT(0) >> #define MTK_KPD_SEL_COL GENMASK(15, 10) >> #define MTK_KPD_SEL_ROW GENMASK(9, 4) >> #define MTK_KPD_SEL_COLMASK(c) GENMASK((c) + 9, 10) >> @@ -31,6 +32,7 @@ struct mt6779_keypad { >> struct clk *clk; >> u32 n_rows; >> u32 n_cols; >> + bool double_keys; >> DECLARE_BITMAP(keymap_state, MTK_KPD_NUM_BITS); >> }; >> >> @@ -67,8 +69,13 @@ static irqreturn_t mt6779_keypad_irq_handler(int irq, void *dev_id) >> continue; >> >> key = bit_nr / 32 * 16 + bit_nr % 32; >> - row = key / 9; >> - col = key % 9; >> + if (keypad->double_keys) { >> + row = key / 13; >> + col = (key % 13) / 2; >> + } else { >> + row = key / 9; >> + col = key % 9; >> + } > > I don't fully like this if branch permanently evaluating true or false, as no > runtime can actually change this result... > > In practice, it's fine, but I was wondering if anyone would disagree with the > following proposal... > > struct mt6779_keypad { > ....... > void (*calc_row_col)(unsigned int *row, unsigned int *col); > }; > > In mt6779_keypad_irq_handler: > > key = bit_nr / 32 * 16 + bit_nr % 32; > keypad->calc_row_col(&row, &col); > > and below... > >> >> scancode = MATRIX_SCAN_CODE(row, col, row_shift); >> /* 1: not pressed, 0: pressed */ >> @@ -150,6 +157,8 @@ static int mt6779_keypad_pdrv_probe(struct platform_device *pdev) >> >> wakeup = device_property_read_bool(&pdev->dev, "wakeup-source"); >> >> + keypad->double_keys = device_property_read_bool(&pdev->dev, "mediatek,double-keys"); >> + >> dev_dbg(&pdev->dev, "n_row=%d n_col=%d debounce=%d\n", >> keypad->n_rows, keypad->n_cols, debounce); >> >> @@ -166,6 +175,10 @@ static int mt6779_keypad_pdrv_probe(struct platform_device *pdev) >> regmap_write(keypad->regmap, MTK_KPD_DEBOUNCE, >> (debounce * (1 << 5)) & MTK_KPD_DEBOUNCE_MASK); >> >> + if (keypad->double_keys) > > keypad->calc_row_col = mt6779_keypad_calc_row_col_double_kp; > >> + regmap_update_bits(keypad->regmap, MTK_KPD_SEL, >> + MTK_KPD_SEL_DOUBLE_KP_MODE, MTK_KPD_SEL_DOUBLE_KP_MODE); >> + > > } else { > keypad->calc_row_col = mt6779_keypad_calc_row_col_single_kp; > } > >> regmap_update_bits(keypad->regmap, MTK_KPD_SEL, MTK_KPD_SEL_ROW, >> MTK_KPD_SEL_ROWMASK(keypad->n_rows)); >> regmap_update_bits(keypad->regmap, MTK_KPD_SEL, MTK_KPD_SEL_COL, > > what do you think? Hi Angelo, Thank you for your detailed suggestion. I like it and since I have to resend a v2 anyways, I will consider implementing it. On the other hand, I'm a little reluctant because it means that I'll have to remove Matthias's reviewed-by :( > > Cheers, > Angelo From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 56616C433EF for ; Thu, 21 Jul 2022 14:55:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:References :In-Reply-To:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OkUd4roOKbZ4fMuwiS6cmEUQQTdNTCKCC2TCSMAZFtg=; b=hMIwMIH0rzG66r Hi6sFT0ODoQpSMGbx0Bf05VYsEQcvci/7/MvBv0GdmJJwmMMyu+Mqzsaf+WM3l7MdzWT3dQK5eE6x qSEnc/GgVS6gC+hjwizV3zDNzmK+xA7OmY3rsL7B95VxjfCNB/kPJ5o8LEbyStu2gj+cBPZchup3Z 5EcYwQLEHRD4J2QfhJ7kBVf15rnN4iqkwUOOPGez+H6IihyGmi0ARKiqVMHeOyEkT36J5yY7XVSef LkXyIn7gTXeq1Cu0YdR6vOZnbgj4W9hcKKtU7o6u8lBMQBZp+dr9wvYEDpPbaOrPoSNhofjOzdcfF p20z+zcxTAqozbXY+U9w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oEXZG-008PkQ-FT; Thu, 21 Jul 2022 14:54:22 +0000 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oEXWX-008MUF-6P for linux-arm-kernel@lists.infradead.org; Thu, 21 Jul 2022 14:51:35 +0000 Received: by mail-wr1-x42f.google.com with SMTP id bu1so2616155wrb.9 for ; Thu, 21 Jul 2022 07:51:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=IPaODleuydbpyW0oBL1XNwJwvfUIp3A8aiBZ01eGt1Q=; b=Bp2CpXtTwoG2Mnt4Fsd7PNBiqhFzvabUoEaCdKBe3coRfhSaMn+IIzpniKnrnFrdUL YhHsz3Ra5N7e+r023RiThEm579WWFjxT2W0IebSd/oCBBUrkN2xOrQcsyBg6JyfJ/B06 uW2TLiUxl2xnqjMml93W/ohzP0oDXt+rL55KYML2aeVYi9E9IwK0fr75+lVU9M4E6WHn w+wMYeCQ/PNSDSqlUkF0fvC4GDYMUpr7/gqG3lio6pvxXZ229AUfF0LOIV9uFJw/fDXj xPhrjpbrWMoF9dB7pyMhKmgN+M7JS8WWrZtMk0sg7uhJaH7SOHY7byVkp4DdroOI7rGq 6F3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=IPaODleuydbpyW0oBL1XNwJwvfUIp3A8aiBZ01eGt1Q=; b=Zq3zODUgypXdsOYLfJec3fHCq7OCuf/l06wCi5JP8FC4E+Zh0fUjtWdYzGTHmr27dt zNAmK6KYgme2SmVDhRmqIJ9JlqdamipbnCf7xz7fFYmsQJoBW/vrZyW/J6TCA8p3M5X6 aUL8yBRde2yQoV++GNhifqYNh+GG1l+hmRqE0GWNZRSYlzxkaVGBikgvcPGPnSKJvlYt zb8YQY3uU2sPh7y4lIpRizKqYk9D1iGbN9nNt2YtGmldDG+OBeMXYfrwbJ+tJ4U1IjrQ PiY6nSD5eDSqNOYv7i5FkNOmzPPbgemu0gCwtEeoAWHWGYDv5PtTfbEz/GtHQbPWMgF3 7JGA== X-Gm-Message-State: AJIora8fs30eFRFwNFRS08LGypnfZ3wNOSYRxOSIqgqC6QQjzZHivL7m i3kAQoZ1x3auC+6rk9pX/qj+Cw== X-Google-Smtp-Source: AGRyM1sfP4ZknR79BKzwBYDjRzsvFl6fMqYkGmVH+vZxkOOLeoF5imavLdHStfa8XEkO8/4kwJBLWg== X-Received: by 2002:adf:f0c6:0:b0:21e:4480:2fa5 with SMTP id x6-20020adff0c6000000b0021e44802fa5mr9138352wro.377.1658415090631; Thu, 21 Jul 2022 07:51:30 -0700 (PDT) Received: from localhost ([82.66.159.240]) by smtp.gmail.com with ESMTPSA id q5-20020a1ce905000000b003a0323463absm2087311wmc.45.2022.07.21.07.51.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Jul 2022 07:51:30 -0700 (PDT) From: Mattijs Korpershoek To: AngeloGioacchino Del Regno , Rob Herring , Krzysztof Kozlowski , Dmitry Torokhov , Matthias Brugger Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, Fabien Parent , devicetree@vger.kernel.org, linux-mediatek@lists.infradead.org, Fabien Parent , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v1 4/6] Input: mt6779-keypad - support double keys matrix In-Reply-To: References: <20220720-mt8183-keypad-v1-0-ef9fc29dbff4@baylibre.com> <20220720-mt8183-keypad-v1-4-ef9fc29dbff4@baylibre.com> Date: Thu, 21 Jul 2022 16:51:29 +0200 Message-ID: <87ilnqh632.fsf@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220721_075133_296206_E7AA39FA X-CRM114-Status: GOOD ( 22.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Jul 21, 2022 at 10:34, AngeloGioacchino Del Regno wrote: > Il 20/07/22 16:48, Mattijs Korpershoek ha scritto: >> MediaTek keypad has 2 modes of detecting key events: >> - single key: each (row, column) can detect one key >> - double key: each (row, column) is a group of 2 keys >> >> Double key support exists to minimize cost, since it reduces the number >> of pins required for physical keys. >> >> Double key is configured by setting BIT(0) of the KP_SEL register. >> >> Enable double key matrix support based on the mediatek,double-keys >> device tree property. >> >> Signed-off-by: Mattijs Korpershoek >> Reviewed-by: Matthias Brugger >> >> diff --git a/drivers/input/keyboard/mt6779-keypad.c b/drivers/input/keyboard/mt6779-keypad.c >> index bf447bf598fb..9a5dbd415dac 100644 >> --- a/drivers/input/keyboard/mt6779-keypad.c >> +++ b/drivers/input/keyboard/mt6779-keypad.c >> @@ -18,6 +18,7 @@ >> #define MTK_KPD_DEBOUNCE_MASK GENMASK(13, 0) >> #define MTK_KPD_DEBOUNCE_MAX_MS 256 >> #define MTK_KPD_SEL 0x0020 >> +#define MTK_KPD_SEL_DOUBLE_KP_MODE BIT(0) >> #define MTK_KPD_SEL_COL GENMASK(15, 10) >> #define MTK_KPD_SEL_ROW GENMASK(9, 4) >> #define MTK_KPD_SEL_COLMASK(c) GENMASK((c) + 9, 10) >> @@ -31,6 +32,7 @@ struct mt6779_keypad { >> struct clk *clk; >> u32 n_rows; >> u32 n_cols; >> + bool double_keys; >> DECLARE_BITMAP(keymap_state, MTK_KPD_NUM_BITS); >> }; >> >> @@ -67,8 +69,13 @@ static irqreturn_t mt6779_keypad_irq_handler(int irq, void *dev_id) >> continue; >> >> key = bit_nr / 32 * 16 + bit_nr % 32; >> - row = key / 9; >> - col = key % 9; >> + if (keypad->double_keys) { >> + row = key / 13; >> + col = (key % 13) / 2; >> + } else { >> + row = key / 9; >> + col = key % 9; >> + } > > I don't fully like this if branch permanently evaluating true or false, as no > runtime can actually change this result... > > In practice, it's fine, but I was wondering if anyone would disagree with the > following proposal... > > struct mt6779_keypad { > ....... > void (*calc_row_col)(unsigned int *row, unsigned int *col); > }; > > In mt6779_keypad_irq_handler: > > key = bit_nr / 32 * 16 + bit_nr % 32; > keypad->calc_row_col(&row, &col); > > and below... > >> >> scancode = MATRIX_SCAN_CODE(row, col, row_shift); >> /* 1: not pressed, 0: pressed */ >> @@ -150,6 +157,8 @@ static int mt6779_keypad_pdrv_probe(struct platform_device *pdev) >> >> wakeup = device_property_read_bool(&pdev->dev, "wakeup-source"); >> >> + keypad->double_keys = device_property_read_bool(&pdev->dev, "mediatek,double-keys"); >> + >> dev_dbg(&pdev->dev, "n_row=%d n_col=%d debounce=%d\n", >> keypad->n_rows, keypad->n_cols, debounce); >> >> @@ -166,6 +175,10 @@ static int mt6779_keypad_pdrv_probe(struct platform_device *pdev) >> regmap_write(keypad->regmap, MTK_KPD_DEBOUNCE, >> (debounce * (1 << 5)) & MTK_KPD_DEBOUNCE_MASK); >> >> + if (keypad->double_keys) > > keypad->calc_row_col = mt6779_keypad_calc_row_col_double_kp; > >> + regmap_update_bits(keypad->regmap, MTK_KPD_SEL, >> + MTK_KPD_SEL_DOUBLE_KP_MODE, MTK_KPD_SEL_DOUBLE_KP_MODE); >> + > > } else { > keypad->calc_row_col = mt6779_keypad_calc_row_col_single_kp; > } > >> regmap_update_bits(keypad->regmap, MTK_KPD_SEL, MTK_KPD_SEL_ROW, >> MTK_KPD_SEL_ROWMASK(keypad->n_rows)); >> regmap_update_bits(keypad->regmap, MTK_KPD_SEL, MTK_KPD_SEL_COL, > > what do you think? Hi Angelo, Thank you for your detailed suggestion. I like it and since I have to resend a v2 anyways, I will consider implementing it. On the other hand, I'm a little reluctant because it means that I'll have to remove Matthias's reviewed-by :( > > Cheers, > Angelo _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel