RE: [PATCH 1/5] input: New MATRIX_KEY macro

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Introduce new macro to input.h for packing matrix keypad keycodes.

As suggested by David Brownell, add two driver-internal defines:
     * MATRIX_ROWCOL_MASK to strip R/C from MATRIX_KEY()
     * MATRIX_KEYCODE_MASK to stip the keycode from a MATRIX_KEY()

Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx>
Cc: David Brownell <david-b@xxxxxxxxxxx>

---

diff --git a/include/linux/input.h b/include/linux/input.h
index 1249a0c..6d88780 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -598,6 +598,17 @@ struct input_absinfo {
 #define KEY_CNT			(KEY_MAX+1)
 
 /*
+ * Macro to pack the row/col of a key on a matrix keypad and it's
associated
+ * KEY_* code into into an array.  4 bits are used for both the row and
column
+ * allowing for up to a 16x16 keypad.  The row (_r) and column (_c) are
+ * interchangable depending on a keypad drivers usage.
+ */
+#define MATRIX_KEY(_r, _c, _v)	(((_r) << 28) | ((_c) << 24) | (_v))
+
+#define MATRIX_ROWCOL_MASK	0xff000000
+#define MATRIX_KEYCODE_MASK	0x00ffffff
+
+/*
  * Relative axes
  */
  
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux