aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/input
diff options
context:
space:
mode:
authorHeiko Stübner <heiko@sntech.de>2011-11-29 14:04:09 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2011-12-01 02:41:16 -0500
commit3bfd5c5baf66e975b0f365a0cda8d75bf2953ebe (patch)
tree49517da40dd6071ed9d3acde9fa1ef97d39ede13 /Documentation/input
parenta6c61789c8499381a5fe612f11dc95d0b55e590a (diff)
Input: add generic GPIO-tilt driver
There exist tilt switches that simply report their tilt-state via some gpios. The number and orientation of their axes can vary depending on the switch used and the build of the device. Also two or more one-axis switches could be combined to provide multi-dimensional orientation. One example of a device using such a switch is the family of Qisda ebook readers, where the switch provides information about the landscape / portrait orientation of the device. The example in Documentation/input/gpio-tilt.txt documents exactly this one-axis device. Signed-off-by: Heiko Stuebner <heiko@sntech.de> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'Documentation/input')
-rw-r--r--Documentation/input/gpio-tilt.txt103
1 files changed, 103 insertions, 0 deletions
diff --git a/Documentation/input/gpio-tilt.txt b/Documentation/input/gpio-tilt.txt
new file mode 100644
index 000000000000..06d60c3ff5e7
--- /dev/null
+++ b/Documentation/input/gpio-tilt.txt
@@ -0,0 +1,103 @@
1Driver for tilt-switches connected via GPIOs
2============================================
3
4Generic driver to read data from tilt switches connected via gpios.
5Orientation can be provided by one or more than one tilt switches,
6i.e. each tilt switch providing one axis, and the number of axes
7is also not limited.
8
9
10Data structures:
11----------------
12
13The array of struct gpio in the gpios field is used to list the gpios
14that represent the current tilt state.
15
16The array of struct gpio_tilt_axis describes the axes that are reported
17to the input system. The values set therein are used for the
18input_set_abs_params calls needed to init the axes.
19
20The array of struct gpio_tilt_state maps gpio states to the corresponding
21values to report. The gpio state is represented as a bitfield where the
22bit-index corresponds to the index of the gpio in the struct gpio array.
23In the same manner the values stored in the axes array correspond to
24the elements of the gpio_tilt_axis-array.
25
26
27Example:
28--------
29
30Example configuration for a single TS1003 tilt switch that rotates around
31one axis in 4 steps and emitts the current tilt via two GPIOs.
32
33static int sg060_tilt_enable(struct device *dev) {
34 /* code to enable the sensors */
35};
36
37static void sg060_tilt_disable(struct device *dev) {
38 /* code to disable the sensors */
39};
40
41static struct gpio sg060_tilt_gpios[] = {
42 { SG060_TILT_GPIO_SENSOR1, GPIOF_IN, "tilt_sensor1" },
43 { SG060_TILT_GPIO_SENSOR2, GPIOF_IN, "tilt_sensor2" },
44};
45
46static struct gpio_tilt_state sg060_tilt_states[] = {
47 {
48 .gpios = (0 << 1) | (0 << 0),
49 .axes = (int[]) {
50 0,
51 },
52 }, {
53 .gpios = (0 << 1) | (1 << 0),
54 .axes = (int[]) {
55 1, /* 90 degrees */
56 },
57 }, {
58 .gpios = (1 << 1) | (1 << 0),
59 .axes = (int[]) {
60 2, /* 180 degrees */
61 },
62 }, {
63 .gpios = (1 << 1) | (0 << 0),
64 .axes = (int[]) {
65 3, /* 270 degrees */
66 },
67 },
68};
69
70static struct gpio_tilt_axis sg060_tilt_axes[] = {
71 {
72 .axis = ABS_RY,
73 .min = 0,
74 .max = 3,
75 .fuzz = 0,
76 .flat = 0,
77 },
78};
79
80static struct gpio_tilt_platform_data sg060_tilt_pdata= {
81 .gpios = sg060_tilt_gpios,
82 .nr_gpios = ARRAY_SIZE(sg060_tilt_gpios),
83
84 .axes = sg060_tilt_axes,
85 .nr_axes = ARRAY_SIZE(sg060_tilt_axes),
86
87 .states = sg060_tilt_states,
88 .nr_states = ARRAY_SIZE(sg060_tilt_states),
89
90 .debounce_interval = 100,
91
92 .poll_interval = 1000,
93 .enable = sg060_tilt_enable,
94 .disable = sg060_tilt_disable,
95};
96
97static struct platform_device sg060_device_tilt = {
98 .name = "gpio-tilt-polled",
99 .id = -1,
100 .dev = {
101 .platform_data = &sg060_tilt_pdata,
102 },
103};