Ensure FMODE_NONOTIFY is not set by userspace
[pandora-kernel.git] / drivers / staging / dream / include / linux / gpio_event.h
1 /* drivers/staging/dream/include/linux/gpio_event.h
2  *
3  * Copyright (C) 2007 Google, Inc.
4  *
5  * This software is licensed under the terms of the GNU General Public
6  * License version 2, as published by the Free Software Foundation, and
7  * may be copied, distributed, and modified under those terms.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  */
15
16 #ifndef _LINUX_GPIO_EVENT_H
17 #define _LINUX_GPIO_EVENT_H
18
19 #include <linux/input.h>
20
21 enum {
22         GPIO_EVENT_FUNC_UNINIT  = 0x0,
23         GPIO_EVENT_FUNC_INIT    = 0x1,
24         GPIO_EVENT_FUNC_SUSPEND = 0x2,
25         GPIO_EVENT_FUNC_RESUME  = 0x3,
26 };
27 struct gpio_event_info {
28         int (*func)(struct input_dev *input_dev,
29                     struct gpio_event_info *info,
30                     void **data, int func);
31         int (*event)(struct input_dev *input_dev,
32                      struct gpio_event_info *info,
33                      void **data, unsigned int type,
34                      unsigned int code, int value); /* out events */
35 };
36
37 struct gpio_event_platform_data {
38         const char *name;
39         struct gpio_event_info **info;
40         size_t info_count;
41         int (*power)(const struct gpio_event_platform_data *pdata, bool on);
42 };
43
44 #define GPIO_EVENT_DEV_NAME "gpio-event"
45
46 /* Key matrix */
47
48 enum gpio_event_matrix_flags {
49         /* unset: drive active output low, set: drive active output high */
50         GPIOKPF_ACTIVE_HIGH              = 1U << 0,
51         GPIOKPF_DEBOUNCE                 = 1U << 1,
52         GPIOKPF_REMOVE_SOME_PHANTOM_KEYS = 1U << 2,
53         GPIOKPF_REMOVE_PHANTOM_KEYS      = GPIOKPF_REMOVE_SOME_PHANTOM_KEYS |
54                                            GPIOKPF_DEBOUNCE,
55         GPIOKPF_DRIVE_INACTIVE           = 1U << 3,
56         GPIOKPF_LEVEL_TRIGGERED_IRQ      = 1U << 4,
57         GPIOKPF_PRINT_UNMAPPED_KEYS      = 1U << 16,
58         GPIOKPF_PRINT_MAPPED_KEYS        = 1U << 17,
59         GPIOKPF_PRINT_PHANTOM_KEYS       = 1U << 18,
60 };
61
62 extern int gpio_event_matrix_func(struct input_dev *input_dev,
63                         struct gpio_event_info *info, void **data, int func);
64 struct gpio_event_matrix_info {
65         /* initialize to gpio_event_matrix_func */
66         struct gpio_event_info info;
67         /* size must be ninputs * noutputs */
68         const unsigned short *keymap;
69         unsigned int *input_gpios;
70         unsigned int *output_gpios;
71         unsigned int ninputs;
72         unsigned int noutputs;
73         /* time to wait before reading inputs after driving each output */
74         ktime_t settle_time;
75         /* time to wait before scanning the keypad a second time */
76         ktime_t debounce_delay;
77         ktime_t poll_time;
78         unsigned flags;
79 };
80
81 /* Directly connected inputs and outputs */
82
83 enum gpio_event_direct_flags {
84         GPIOEDF_ACTIVE_HIGH         = 1U << 0,
85 /*      GPIOEDF_USE_DOWN_IRQ        = 1U << 1, */
86 /*      GPIOEDF_USE_IRQ             = (1U << 2) | GPIOIDF_USE_DOWN_IRQ, */
87         GPIOEDF_PRINT_KEYS          = 1U << 8,
88         GPIOEDF_PRINT_KEY_DEBOUNCE  = 1U << 9,
89 };
90
91 struct gpio_event_direct_entry {
92         uint32_t gpio:23;
93         uint32_t code:9;
94 };
95
96 /* inputs */
97 extern int gpio_event_input_func(struct input_dev *input_dev,
98                         struct gpio_event_info *info, void **data, int func);
99 struct gpio_event_input_info {
100         /* initialize to gpio_event_input_func */
101         struct gpio_event_info info;
102         ktime_t debounce_time;
103         ktime_t poll_time;
104         uint16_t flags;
105         uint16_t type;
106         const struct gpio_event_direct_entry *keymap;
107         size_t keymap_size;
108 };
109
110 /* outputs */
111 extern int gpio_event_output_func(struct input_dev *input_dev,
112                         struct gpio_event_info *info, void **data, int func);
113 extern int gpio_event_output_event(struct input_dev *input_dev,
114                         struct gpio_event_info *info, void **data,
115                         unsigned int type, unsigned int code, int value);
116 struct gpio_event_output_info {
117         /* initialize to gpio_event_output_func and gpio_event_output_event */
118         struct gpio_event_info info;
119         uint16_t flags;
120         uint16_t type;
121         const struct gpio_event_direct_entry *keymap;
122         size_t keymap_size;
123 };
124
125
126 /* axes */
127
128 enum gpio_event_axis_flags {
129         GPIOEAF_PRINT_UNKNOWN_DIRECTION  = 1U << 16,
130         GPIOEAF_PRINT_RAW                = 1U << 17,
131         GPIOEAF_PRINT_EVENT              = 1U << 18,
132 };
133
134 extern int gpio_event_axis_func(struct input_dev *input_dev,
135                         struct gpio_event_info *info, void **data, int func);
136 struct gpio_event_axis_info {
137         /* initialize to gpio_event_axis_func */
138         struct gpio_event_info info;
139         uint8_t  count;
140         uint8_t  type; /* EV_REL or EV_ABS */
141         uint16_t code;
142         uint16_t decoded_size;
143         uint16_t (*map)(struct gpio_event_axis_info *info, uint16_t in);
144         uint32_t *gpio;
145         uint32_t flags;
146 };
147 #define gpio_axis_2bit_gray_map gpio_axis_4bit_gray_map
148 #define gpio_axis_3bit_gray_map gpio_axis_4bit_gray_map
149 uint16_t gpio_axis_4bit_gray_map(
150                         struct gpio_event_axis_info *info, uint16_t in);
151 uint16_t gpio_axis_5bit_singletrack_map(
152                         struct gpio_event_axis_info *info, uint16_t in);
153
154 #endif