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 79B2AC433F5 for ; Sat, 1 Oct 2022 06:29:29 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Krt7rvDu3TC7fGSp2cY2aUYwAx3e8xXCut8IA8I19fU=; b=b94JNNKIqxDPac fnJszW4+Ew727rBlm93ABkrWInfqYtUHWEq9TP9+OK/5oxRsxHIYogITKCsQHat5EJUM/F5oz7/xW qptyhhXVAIaqX6J+omwlYG/LBcD8HI2NCR6lLrsgYDXinfTQNEmjdPQ1B0hqglHUXd488jGiObgx6 TgrXNT3lqBRgioeegmUFXxcHObXkRDpQkKn4VtOiJ+yq5VpwZXYRR1ZcTyvK0ui9nfjebTr+SvZa5 cJGjebZRvLJSpruUsEsao95MpNBC6vpIsDXXmUYPeyUThVlB7X6Pzx885Q2UgLF/vvhgUu1A5nRuw JxjFHiJx/AztEkxjyHXA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oeVyz-00DN2V-ET; Sat, 01 Oct 2022 06:28:17 +0000 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oeVyw-00DN1m-Ds for linux-arm-kernel@lists.infradead.org; Sat, 01 Oct 2022 06:28:15 +0000 Received: by mail-pl1-x633.google.com with SMTP id w20so5629376ply.12 for ; Fri, 30 Sep 2022 23:28:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=k2HY/9fTWjD6yOUfkXa90L9vnBK9YBSc4ZyQwrFqunU=; b=N6aMnXgZPio+JDqAgd7OoztzGDn5YRVaEHhpQVxjh2Qa4mTgDGjA8NC/4mvctST5xW smeisubUybmDrk14fWCj1EDsnVZfbZOkKA/1Pxys/GqDmnohuonql4qYjXYLw4pS2S05 xTWqIVq4bRe9GvSmSM4cZnAb+lSznS3slJhvL2IUtvQjS9O9vn5pjv/z1pwHjDTKp7/U KM30Kl9ak5T5/v7C3sxP8aRZubIRCw7t8bd1yyV3/GwX8TM7lne/ME3ezDpqVcDCnoQH 6i9cLiUsaOm1yntVBuiJgLinn6hZtIb3wOcryJwC76FvFEEcsi0Pd/31Z5GddirzhEaP yhrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=k2HY/9fTWjD6yOUfkXa90L9vnBK9YBSc4ZyQwrFqunU=; b=yxGa2FKXdJw2NQ77aSzyBdXnItjdglKOXwu+42tCmokqXQNZZxUi7fW9aNxFtEh9Mq 3VtWQr0Uo2HQUbmSmiaesiAv+h2aJbYEamSTsPG+PIglhuHZa/xA//fGs8lGzezkF0wb iypg9mC9B+Zy+Xk+bGaDBppmEni1GpCTwWBUtkH+wr9ZBvumHyLAN8Z8aMM4wtFWMt3n SxD/sTXULx43oNbRvNFzWEEiFcyKw3D4Mu9X/+1ZqN0/dxN0eCvEpE/IBl/7F/Xcfp9w x1u4SRIWPSz2hILHTuolRxM9SiCensTPFnL8yuZO/8AqiVZ4RdMr4EkXn4L1KCHcXMGk UQsA== X-Gm-Message-State: ACrzQf3RVUsXthr9a9AecMJ4QcpbsfRiJUrRogNpYNadHiw52V204V6C TxlSPiUBRTHXUwepE/XAJmVPcKbwtMk= X-Google-Smtp-Source: AMsMyM5hUfLusi1pDlwlsfEM1qZvQ6LzZmDCgYBkMt8EErnV2H9a+OTQit3hERCFi0h8OWG9Oks4Vw== X-Received: by 2002:a17:902:8217:b0:176:e41d:b804 with SMTP id x23-20020a170902821700b00176e41db804mr12308819pln.111.1664605692437; Fri, 30 Sep 2022 23:28:12 -0700 (PDT) Received: from google.com ([2620:15c:9d:2:63e7:415:943b:4707]) by smtp.gmail.com with ESMTPSA id y8-20020a62ce08000000b0055817a49b28sm2946161pfg.67.2022.09.30.23.28.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Sep 2022 23:28:11 -0700 (PDT) Date: Fri, 30 Sep 2022 23:28:08 -0700 From: Dmitry Torokhov To: Samuel Holland Cc: Andy Shevchenko , linux-input , Linux Kernel Mailing List , Ondrej Jirman , Andy Shevchenko , Chen-Yu Tsai , Jernej Skrabec , linux-arm Mailing List , linux-sunxi@lists.linux.dev Subject: Re: [PATCH v4 2/4] Input: pinephone-keyboard - Add PinePhone keyboard driver Message-ID: References: <20220618165747.55709-1-samuel@sholland.org> <20220618165747.55709-3-samuel@sholland.org> <2e6499b8-d8f4-b63a-689b-1e93aca7c210@sholland.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <2e6499b8-d8f4-b63a-689b-1e93aca7c210@sholland.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220930_232814_508728_A63A239D X-CRM114-Status: GOOD ( 23.86 ) 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 Mon, Jun 20, 2022 at 11:12:46PM -0500, Samuel Holland wrote: > On 6/19/22 6:43 AM, Andy Shevchenko wrote: > > On Sat, Jun 18, 2022 at 7:10 PM Samuel Holland wrote: > >> > >> The official Pine64 PinePhone keyboard case contains a matrix keypad and > >> a MCU which runs a libre firmware. Add support for its I2C interface. > > > > ... > > > >> +#include > >> +#include > >> +#include > >> +#include > >> +#include > >> +#include > > > > Missed > > types.h > > > > ... > > > >> +#define PPKB_ROWS 6 > >> +#define PPKB_COLS 12 > > > > ... > > > >> + for (col = 0; col < PPKB_COLS; ++col) { > >> + u8 old = old_buf[1 + col]; > >> + u8 new = new_buf[1 + col]; > >> + u8 changed = old ^ new; > >> + > >> + if (!changed) > >> + continue; > >> + > >> + for (row = 0; row < PPKB_ROWS; ++row) { > >> + u8 mask = BIT(row); > >> + u8 value = new & mask; > >> + unsigned short code; > >> + bool fn_state; > >> + > >> + if (!(changed & mask)) > >> + continue; > >> + > >> + /* > >> + * Save off the FN key state when the key was pressed, > >> + * and use that to determine the code during a release. > >> + */ > >> + fn_state = value ? ppkb->fn_pressed : ppkb->fn_state[col] & mask; > >> + if (fn_state) > >> + ppkb->fn_state[col] ^= mask; > > > > Can't it be converted to use bitmap APIs? > > This is a 2D matrix, with one byte per column, and one bit per row. There are > only 6 rows, so two bits per byte are unused. Converting this to the bitmap API > would unnecessarily complicate things. We could have a constant bitmap masking the unused bits so they are always skipped. Anyway, I made a few edits and applied, we can continue improving the driver in an iterative manner. Thanks. -- Dmitry _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel