matrix_keypad.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #ifndef _MATRIX_KEYPAD_H
  2. #define _MATRIX_KEYPAD_H
  3. #include <linux/types.h>
  4. #include <linux/input.h>
  5. #define MATRIX_MAX_ROWS 16
  6. #define MATRIX_MAX_COLS 16
  7. #define KEY(row, col, val) ((((row) & (MATRIX_MAX_ROWS - 1)) << 24) |\
  8. (((col) & (MATRIX_MAX_COLS - 1)) << 16) |\
  9. (val & 0xffff))
  10. #define KEY_ROW(k) (((k) >> 24) & 0xff)
  11. #define KEY_COL(k) (((k) >> 16) & 0xff)
  12. #define KEY_VAL(k) ((k) & 0xffff)
  13. /**
  14. * struct matrix_keymap_data - keymap for matrix keyboards
  15. * @keymap: pointer to array of uint32 values encoded with KEY() macro
  16. * representing keymap
  17. * @keymap_size: number of entries (initialized) in this keymap
  18. * @max_keymap_size: maximum size of keymap supported by the device
  19. *
  20. * This structure is supposed to be used by platform code to supply
  21. * keymaps to drivers that implement matrix-like keypads/keyboards.
  22. */
  23. struct matrix_keymap_data {
  24. const uint32_t *keymap;
  25. unsigned int keymap_size;
  26. unsigned int max_keymap_size;
  27. };
  28. /**
  29. * struct matrix_keypad_platform_data - platform-dependent keypad data
  30. * @keymap_data: pointer to &matrix_keymap_data
  31. * @row_gpios: array of gpio numbers reporesenting rows
  32. * @col_gpios: array of gpio numbers reporesenting colums
  33. * @num_row_gpios: actual number of row gpios used by device
  34. * @num_col_gpios: actual number of col gpios used by device
  35. * @col_scan_delay_us: delay, measured in microseconds, that is
  36. * needed before we can keypad after activating column gpio
  37. * @debounce_ms: debounce interval in milliseconds
  38. *
  39. * This structure represents platform-specific data that use used by
  40. * matrix_keypad driver to perform proper initialization.
  41. */
  42. struct matrix_keypad_platform_data {
  43. const struct matrix_keymap_data *keymap_data;
  44. unsigned int row_gpios[MATRIX_MAX_ROWS];
  45. unsigned int col_gpios[MATRIX_MAX_COLS];
  46. unsigned int num_row_gpios;
  47. unsigned int num_col_gpios;
  48. unsigned int col_scan_delay_us;
  49. /* key debounce interval in milli-second */
  50. unsigned int debounce_ms;
  51. bool active_low;
  52. bool wakeup;
  53. };
  54. #endif /* _MATRIX_KEYPAD_H */