]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - include/linux/input/matrix_keypad.h
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux...
[mirror_ubuntu-artful-kernel.git] / include / linux / input / matrix_keypad.h
CommitLineData
bab7614d
EM
1#ifndef _MATRIX_KEYPAD_H
2#define _MATRIX_KEYPAD_H
3
4#include <linux/types.h>
5#include <linux/input.h>
2cd36877 6#include <linux/of.h>
bab7614d 7
cfaea567
TS
8#define MATRIX_MAX_ROWS 32
9#define MATRIX_MAX_COLS 32
bab7614d
EM
10
11#define KEY(row, col, val) ((((row) & (MATRIX_MAX_ROWS - 1)) << 24) |\
12 (((col) & (MATRIX_MAX_COLS - 1)) << 16) |\
da1f026b 13 ((val) & 0xffff))
bab7614d
EM
14
15#define KEY_ROW(k) (((k) >> 24) & 0xff)
16#define KEY_COL(k) (((k) >> 16) & 0xff)
17#define KEY_VAL(k) ((k) & 0xffff)
18
d82f1c35
EM
19#define MATRIX_SCAN_CODE(row, col, row_shift) (((row) << (row_shift)) + (col))
20
bab7614d
EM
21/**
22 * struct matrix_keymap_data - keymap for matrix keyboards
23 * @keymap: pointer to array of uint32 values encoded with KEY() macro
24 * representing keymap
25 * @keymap_size: number of entries (initialized) in this keymap
bab7614d
EM
26 *
27 * This structure is supposed to be used by platform code to supply
28 * keymaps to drivers that implement matrix-like keypads/keyboards.
29 */
30struct matrix_keymap_data {
31 const uint32_t *keymap;
32 unsigned int keymap_size;
bab7614d
EM
33};
34
35/**
36 * struct matrix_keypad_platform_data - platform-dependent keypad data
37 * @keymap_data: pointer to &matrix_keymap_data
d82f1c35
EM
38 * @row_gpios: pointer to array of gpio numbers representing rows
39 * @col_gpios: pointer to array of gpio numbers reporesenting colums
bab7614d
EM
40 * @num_row_gpios: actual number of row gpios used by device
41 * @num_col_gpios: actual number of col gpios used by device
42 * @col_scan_delay_us: delay, measured in microseconds, that is
43 * needed before we can keypad after activating column gpio
44 * @debounce_ms: debounce interval in milliseconds
fb76dd10
LF
45 * @clustered_irq: may be specified if interrupts of all row/column GPIOs
46 * are bundled to one single irq
47 * @clustered_irq_flags: flags that are needed for the clustered irq
d69249f4
DT
48 * @active_low: gpio polarity
49 * @wakeup: controls whether the device should be set up as wakeup
50 * source
9d32c305 51 * @no_autorepeat: disable key autorepeat
bab7614d
EM
52 *
53 * This structure represents platform-specific data that use used by
54 * matrix_keypad driver to perform proper initialization.
55 */
56struct matrix_keypad_platform_data {
57 const struct matrix_keymap_data *keymap_data;
58
d82f1c35
EM
59 const unsigned int *row_gpios;
60 const unsigned int *col_gpios;
61
bab7614d
EM
62 unsigned int num_row_gpios;
63 unsigned int num_col_gpios;
64
65 unsigned int col_scan_delay_us;
66
67 /* key debounce interval in milli-second */
68 unsigned int debounce_ms;
69
fb76dd10
LF
70 unsigned int clustered_irq;
71 unsigned int clustered_irq_flags;
72
bab7614d
EM
73 bool active_low;
74 bool wakeup;
9d32c305 75 bool no_autorepeat;
bab7614d
EM
76};
77
1932811f
DT
78int matrix_keypad_build_keymap(const struct matrix_keymap_data *keymap_data,
79 const char *keymap_name,
80 unsigned int rows, unsigned int cols,
81 unsigned short *keymap,
82 struct input_dev *input_dev);
77a53fd2 83
bab7614d 84#endif /* _MATRIX_KEYPAD_H */