diff options
| author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
|---|---|---|
| committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
| commit | fcc9d2e5a6c89d22b8b773a64fb4ad21ac318446 (patch) | |
| tree | a57612d1888735a2ec7972891b68c1ac5ec8faea /include/linux/gpio_event.h | |
| parent | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (diff) | |
Diffstat (limited to 'include/linux/gpio_event.h')
| -rw-r--r-- | include/linux/gpio_event.h | 170 |
1 files changed, 170 insertions, 0 deletions
diff --git a/include/linux/gpio_event.h b/include/linux/gpio_event.h new file mode 100644 index 00000000000..2613fc5e4a9 --- /dev/null +++ b/include/linux/gpio_event.h | |||
| @@ -0,0 +1,170 @@ | |||
| 1 | /* 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 | struct gpio_event_input_devs { | ||
| 22 | int count; | ||
| 23 | struct input_dev *dev[]; | ||
| 24 | }; | ||
| 25 | enum { | ||
| 26 | GPIO_EVENT_FUNC_UNINIT = 0x0, | ||
| 27 | GPIO_EVENT_FUNC_INIT = 0x1, | ||
| 28 | GPIO_EVENT_FUNC_SUSPEND = 0x2, | ||
| 29 | GPIO_EVENT_FUNC_RESUME = 0x3, | ||
| 30 | }; | ||
| 31 | struct gpio_event_info { | ||
| 32 | int (*func)(struct gpio_event_input_devs *input_devs, | ||
| 33 | struct gpio_event_info *info, | ||
| 34 | void **data, int func); | ||
| 35 | int (*event)(struct gpio_event_input_devs *input_devs, | ||
| 36 | struct gpio_event_info *info, | ||
| 37 | void **data, unsigned int dev, unsigned int type, | ||
| 38 | unsigned int code, int value); /* out events */ | ||
| 39 | bool no_suspend; | ||
| 40 | }; | ||
| 41 | |||
| 42 | struct gpio_event_platform_data { | ||
| 43 | const char *name; | ||
| 44 | struct gpio_event_info **info; | ||
| 45 | size_t info_count; | ||
| 46 | int (*power)(const struct gpio_event_platform_data *pdata, bool on); | ||
| 47 | const char *names[]; /* If name is NULL, names contain a NULL */ | ||
| 48 | /* terminated list of input devices to create */ | ||
| 49 | }; | ||
| 50 | |||
| 51 | #define GPIO_EVENT_DEV_NAME "gpio-event" | ||
| 52 | |||
| 53 | /* Key matrix */ | ||
| 54 | |||
| 55 | enum gpio_event_matrix_flags { | ||
| 56 | /* unset: drive active output low, set: drive active output high */ | ||
| 57 | GPIOKPF_ACTIVE_HIGH = 1U << 0, | ||
| 58 | GPIOKPF_DEBOUNCE = 1U << 1, | ||
| 59 | GPIOKPF_REMOVE_SOME_PHANTOM_KEYS = 1U << 2, | ||
| 60 | GPIOKPF_REMOVE_PHANTOM_KEYS = GPIOKPF_REMOVE_SOME_PHANTOM_KEYS | | ||
| 61 | GPIOKPF_DEBOUNCE, | ||
| 62 | GPIOKPF_DRIVE_INACTIVE = 1U << 3, | ||
| 63 | GPIOKPF_LEVEL_TRIGGERED_IRQ = 1U << 4, | ||
| 64 | GPIOKPF_PRINT_UNMAPPED_KEYS = 1U << 16, | ||
| 65 | GPIOKPF_PRINT_MAPPED_KEYS = 1U << 17, | ||
| 66 | GPIOKPF_PRINT_PHANTOM_KEYS = 1U << 18, | ||
| 67 | }; | ||
| 68 | |||
| 69 | #define MATRIX_CODE_BITS (10) | ||
| 70 | #define MATRIX_KEY_MASK ((1U << MATRIX_CODE_BITS) - 1) | ||
| 71 | #define MATRIX_KEY(dev, code) \ | ||
| 72 | (((dev) << MATRIX_CODE_BITS) | (code & MATRIX_KEY_MASK)) | ||
| 73 | |||
| 74 | extern int gpio_event_matrix_func(struct gpio_event_input_devs *input_devs, | ||
| 75 | struct gpio_event_info *info, void **data, int func); | ||
| 76 | struct gpio_event_matrix_info { | ||
| 77 | /* initialize to gpio_event_matrix_func */ | ||
| 78 | struct gpio_event_info info; | ||
| 79 | /* size must be ninputs * noutputs */ | ||
| 80 | const unsigned short *keymap; | ||
| 81 | unsigned int *input_gpios; | ||
| 82 | unsigned int *output_gpios; | ||
| 83 | unsigned int ninputs; | ||
| 84 | unsigned int noutputs; | ||
| 85 | /* time to wait before reading inputs after driving each output */ | ||
| 86 | ktime_t settle_time; | ||
| 87 | /* time to wait before scanning the keypad a second time */ | ||
| 88 | ktime_t debounce_delay; | ||
| 89 | ktime_t poll_time; | ||
| 90 | unsigned flags; | ||
| 91 | }; | ||
| 92 | |||
| 93 | /* Directly connected inputs and outputs */ | ||
| 94 | |||
| 95 | enum gpio_event_direct_flags { | ||
| 96 | GPIOEDF_ACTIVE_HIGH = 1U << 0, | ||
| 97 | /* GPIOEDF_USE_DOWN_IRQ = 1U << 1, */ | ||
| 98 | /* GPIOEDF_USE_IRQ = (1U << 2) | GPIOIDF_USE_DOWN_IRQ, */ | ||
| 99 | GPIOEDF_PRINT_KEYS = 1U << 8, | ||
| 100 | GPIOEDF_PRINT_KEY_DEBOUNCE = 1U << 9, | ||
| 101 | GPIOEDF_PRINT_KEY_UNSTABLE = 1U << 10, | ||
| 102 | }; | ||
| 103 | |||
| 104 | struct gpio_event_direct_entry { | ||
| 105 | uint32_t gpio:16; | ||
| 106 | uint32_t code:10; | ||
| 107 | uint32_t dev:6; | ||
| 108 | }; | ||
| 109 | |||
| 110 | /* inputs */ | ||
| 111 | extern int gpio_event_input_func(struct gpio_event_input_devs *input_devs, | ||
| 112 | struct gpio_event_info *info, void **data, int func); | ||
| 113 | struct gpio_event_input_info { | ||
| 114 | /* initialize to gpio_event_input_func */ | ||
| 115 | struct gpio_event_info info; | ||
| 116 | ktime_t debounce_time; | ||
| 117 | ktime_t poll_time; | ||
| 118 | uint16_t flags; | ||
| 119 | uint16_t type; | ||
| 120 | const struct gpio_event_direct_entry *keymap; | ||
| 121 | size_t keymap_size; | ||
| 122 | }; | ||
| 123 | |||
| 124 | /* outputs */ | ||
| 125 | extern int gpio_event_output_func(struct gpio_event_input_devs *input_devs, | ||
| 126 | struct gpio_event_info *info, void **data, int func); | ||
| 127 | extern int gpio_event_output_event(struct gpio_event_input_devs *input_devs, | ||
| 128 | struct gpio_event_info *info, void **data, | ||
| 129 | unsigned int dev, unsigned int type, | ||
| 130 | unsigned int code, int value); | ||
| 131 | struct gpio_event_output_info { | ||
| 132 | /* initialize to gpio_event_output_func and gpio_event_output_event */ | ||
| 133 | struct gpio_event_info info; | ||
| 134 | uint16_t flags; | ||
| 135 | uint16_t type; | ||
| 136 | const struct gpio_event_direct_entry *keymap; | ||
| 137 | size_t keymap_size; | ||
| 138 | }; | ||
| 139 | |||
| 140 | |||
| 141 | /* axes */ | ||
| 142 | |||
| 143 | enum gpio_event_axis_flags { | ||
| 144 | GPIOEAF_PRINT_UNKNOWN_DIRECTION = 1U << 16, | ||
| 145 | GPIOEAF_PRINT_RAW = 1U << 17, | ||
| 146 | GPIOEAF_PRINT_EVENT = 1U << 18, | ||
| 147 | }; | ||
| 148 | |||
| 149 | extern int gpio_event_axis_func(struct gpio_event_input_devs *input_devs, | ||
| 150 | struct gpio_event_info *info, void **data, int func); | ||
| 151 | struct gpio_event_axis_info { | ||
| 152 | /* initialize to gpio_event_axis_func */ | ||
| 153 | struct gpio_event_info info; | ||
| 154 | uint8_t count; /* number of gpios for this axis */ | ||
| 155 | uint8_t dev; /* device index when using multiple input devices */ | ||
| 156 | uint8_t type; /* EV_REL or EV_ABS */ | ||
| 157 | uint16_t code; | ||
| 158 | uint16_t decoded_size; | ||
| 159 | uint16_t (*map)(struct gpio_event_axis_info *info, uint16_t in); | ||
| 160 | uint32_t *gpio; | ||
| 161 | uint32_t flags; | ||
| 162 | }; | ||
| 163 | #define gpio_axis_2bit_gray_map gpio_axis_4bit_gray_map | ||
| 164 | #define gpio_axis_3bit_gray_map gpio_axis_4bit_gray_map | ||
| 165 | uint16_t gpio_axis_4bit_gray_map( | ||
| 166 | struct gpio_event_axis_info *info, uint16_t in); | ||
| 167 | uint16_t gpio_axis_5bit_singletrack_map( | ||
| 168 | struct gpio_event_axis_info *info, uint16_t in); | ||
| 169 | |||
| 170 | #endif | ||
