linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Samuel Holland <samuel@sholland.org>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>,
	linux-input <linux-input@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Ondrej Jirman <x@xff.cz>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Chen-Yu Tsai <wens@csie.org>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	linux-arm Mailing List <linux-arm-kernel@lists.infradead.org>,
	linux-sunxi@lists.linux.dev
Subject: Re: [PATCH v4 2/4] Input: pinephone-keyboard - Add PinePhone keyboard driver
Date: Fri, 30 Sep 2022 23:28:08 -0700	[thread overview]
Message-ID: <Yzfd+GC7mH3P2Y0Y@google.com> (raw)
In-Reply-To: <2e6499b8-d8f4-b63a-689b-1e93aca7c210@sholland.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 <samuel@sholland.org> 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 <linux/crc8.h>
> >> +#include <linux/i2c.h>
> >> +#include <linux/input/matrix_keypad.h>
> >> +#include <linux/interrupt.h>
> >> +#include <linux/module.h>
> >> +#include <linux/regulator/consumer.h>
> > 
> > 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

  reply	other threads:[~2022-10-01  6:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-18 16:57 [PATCH v4 0/4] Pine64 PinePhone keyboard support Samuel Holland
2022-06-18 16:57 ` [PATCH v4 1/4] dt-bindings: input: Add the PinePhone keyboard binding Samuel Holland
2022-06-18 16:57 ` [PATCH v4 2/4] Input: pinephone-keyboard - Add PinePhone keyboard driver Samuel Holland
2022-06-19 11:43   ` Andy Shevchenko
2022-06-21  4:12     ` Samuel Holland
2022-10-01  6:28       ` Dmitry Torokhov [this message]
2022-06-18 16:57 ` [PATCH v4 3/4] Input: pinephone-keyboard - Support the proxied I2C bus Samuel Holland
2022-06-19 11:34   ` Andy Shevchenko
2022-06-18 16:57 ` [PATCH v4 4/4] [DO NOT MERGE] arm64: dts: allwinner: pinephone: Add keyboard Samuel Holland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yzfd+GC7mH3P2Y0Y@google.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=jernej.skrabec@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=samuel@sholland.org \
    --cc=wens@csie.org \
    --cc=x@xff.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).