Patchwork [RFC,v1,1/6] matrix_keypad: Increase the max limit of rows and columns

login
register
mail settings
Submitter Trilok Soni
Date Nov. 10, 2010, 12:47 p.m.
Message ID <1289393281-4459-2-git-send-email-tsoni@codeaurora.org>
Download mbox | patch
Permalink /patch/70628/
State New
Headers show

Comments

Trilok Soni - Nov. 10, 2010, 12:47 p.m.
Some keyboard controller have support for more than
16 columns and rows.

Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Eric Miao <eric.y.miao@gmail.com>
Signed-off-by: Trilok Soni <tsoni@codeaurora.org>
---
 include/linux/input/matrix_keypad.h |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
Eric Miao - Nov. 10, 2010, 6:33 p.m.
On Wed, Nov 10, 2010 at 8:47 PM, Trilok Soni <tsoni@codeaurora.org> wrote:
> Some keyboard controller have support for more than
> 16 columns and rows.
>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: Eric Miao <eric.y.miao@gmail.com>
> Signed-off-by: Trilok Soni <tsoni@codeaurora.org>
> ---
>  include/linux/input/matrix_keypad.h |    8 ++++----
>  1 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/include/linux/input/matrix_keypad.h b/include/linux/input/matrix_keypad.h
> index 80352ad..d80845e 100644
> --- a/include/linux/input/matrix_keypad.h
> +++ b/include/linux/input/matrix_keypad.h
> @@ -4,11 +4,11 @@
>  #include <linux/types.h>
>  #include <linux/input.h>
>
> -#define MATRIX_MAX_ROWS                16
> -#define MATRIX_MAX_COLS                16
> +#define MATRIX_MAX_ROWS                18
> +#define MATRIX_MAX_COLS                18
>
> -#define KEY(row, col, val)     ((((row) & (MATRIX_MAX_ROWS - 1)) << 24) |\
> -                                (((col) & (MATRIX_MAX_COLS - 1)) << 16) |\
> +#define KEY(row, col, val)     ((((row) % (MATRIX_MAX_ROWS)) << 24) |\
> +                                (((col) % (MATRIX_MAX_COLS)) << 16) |\
>                                 (val & 0xffff))
>

Or maybe we can solve this completely by introducing something like:

struct matrix_keycode {
        int row;
        int col;
        int value;
}

And make changes to KEY() macro and other places. You may also want to
eliminate the hardcoded MATRIX_MAX_* in matrix_keypad.c.
>  #define KEY_ROW(k)             (((k) >> 24) & 0xff)
> --
> 1.7.0.2
>
>
Dmitry Torokhov - Nov. 10, 2010, 11:30 p.m.
On Thu, Nov 11, 2010 at 02:33:45AM +0800, Eric Miao wrote:
> On Wed, Nov 10, 2010 at 8:47 PM, Trilok Soni <tsoni@codeaurora.org> wrote:
> > Some keyboard controller have support for more than
> > 16 columns and rows.
> >
> > Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > Cc: Eric Miao <eric.y.miao@gmail.com>
> > Signed-off-by: Trilok Soni <tsoni@codeaurora.org>
> > ---
> >  include/linux/input/matrix_keypad.h |    8 ++++----
> >  1 files changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/include/linux/input/matrix_keypad.h b/include/linux/input/matrix_keypad.h
> > index 80352ad..d80845e 100644
> > --- a/include/linux/input/matrix_keypad.h
> > +++ b/include/linux/input/matrix_keypad.h
> > @@ -4,11 +4,11 @@
> >  #include <linux/types.h>
> >  #include <linux/input.h>
> >
> > -#define MATRIX_MAX_ROWS                16
> > -#define MATRIX_MAX_COLS                16
> > +#define MATRIX_MAX_ROWS                18
> > +#define MATRIX_MAX_COLS                18
> >
> > -#define KEY(row, col, val)     ((((row) & (MATRIX_MAX_ROWS - 1)) << 24) |\
> > -                                (((col) & (MATRIX_MAX_COLS - 1)) << 16) |\
> > +#define KEY(row, col, val)     ((((row) % (MATRIX_MAX_ROWS)) << 24) |\
> > +                                (((col) % (MATRIX_MAX_COLS)) << 16) |\
> >                                 (val & 0xffff))
> >
> 
> Or maybe we can solve this completely by introducing something like:
> 
> struct matrix_keycode {
>         int row;
>         int col;
>         int value;

Though that triples the space needed to store initial keymaps.
Dmitry Torokhov - Nov. 17, 2010, 5:54 p.m.
On Wed, Nov 10, 2010 at 03:30:36PM -0800, Dmitry Torokhov wrote:
> On Thu, Nov 11, 2010 at 02:33:45AM +0800, Eric Miao wrote:
> > On Wed, Nov 10, 2010 at 8:47 PM, Trilok Soni <tsoni@codeaurora.org> wrote:
> > > Some keyboard controller have support for more than
> > > 16 columns and rows.
> > >
> > > Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > > Cc: Eric Miao <eric.y.miao@gmail.com>
> > > Signed-off-by: Trilok Soni <tsoni@codeaurora.org>
> > > ---
> > >  include/linux/input/matrix_keypad.h |    8 ++++----
> > >  1 files changed, 4 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/include/linux/input/matrix_keypad.h b/include/linux/input/matrix_keypad.h
> > > index 80352ad..d80845e 100644
> > > --- a/include/linux/input/matrix_keypad.h
> > > +++ b/include/linux/input/matrix_keypad.h
> > > @@ -4,11 +4,11 @@
> > >  #include <linux/types.h>
> > >  #include <linux/input.h>
> > >
> > > -#define MATRIX_MAX_ROWS                16
> > > -#define MATRIX_MAX_COLS                16
> > > +#define MATRIX_MAX_ROWS                18
> > > +#define MATRIX_MAX_COLS                18
> > >
> > > -#define KEY(row, col, val)     ((((row) & (MATRIX_MAX_ROWS - 1)) << 24) |\
> > > -                                (((col) & (MATRIX_MAX_COLS - 1)) << 16) |\
> > > +#define KEY(row, col, val)     ((((row) % (MATRIX_MAX_ROWS)) << 24) |\
> > > +                                (((col) % (MATRIX_MAX_COLS)) << 16) |\
> > >                                 (val & 0xffff))
> > >
> > 
> > Or maybe we can solve this completely by introducing something like:
> > 
> > struct matrix_keycode {
> >         int row;
> >         int col;
> >         int value;
> 
> Though that triples the space needed to store initial keymaps.
> 

Looking at it I think we should simply bump up max cols/rows to 32 and
be done with it. It will grow the matrix keypad structure by a few bytes
but nothing drastic.

Patch

diff --git a/include/linux/input/matrix_keypad.h b/include/linux/input/matrix_keypad.h
index 80352ad..d80845e 100644
--- a/include/linux/input/matrix_keypad.h
+++ b/include/linux/input/matrix_keypad.h
@@ -4,11 +4,11 @@ 
 #include <linux/types.h>
 #include <linux/input.h>
 
-#define MATRIX_MAX_ROWS		16
-#define MATRIX_MAX_COLS		16
+#define MATRIX_MAX_ROWS		18
+#define MATRIX_MAX_COLS		18
 
-#define KEY(row, col, val)	((((row) & (MATRIX_MAX_ROWS - 1)) << 24) |\
-				 (((col) & (MATRIX_MAX_COLS - 1)) << 16) |\
+#define KEY(row, col, val)	((((row) % (MATRIX_MAX_ROWS)) << 24) |\
+				 (((col) % (MATRIX_MAX_COLS)) << 16) |\
 				 (val & 0xffff))
 
 #define KEY_ROW(k)		(((k) >> 24) & 0xff)