Skip to content

Commit 42f2309

Browse files
mchehabdtor
authored andcommitted
Input: rotary-encoder - convert documentation into to ReST format
This file require minimum adjustments to be a valid ReST file. Do it, in order to be able to parse it with Sphinx. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent 7b11fdc commit 42f2309

1 file changed

Lines changed: 43 additions & 41 deletions

File tree

‎Documentation/input/rotary-encoder.txt‎

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
============================================================
12
rotary-encoder - a generic driver for GPIO connected devices
2-
Daniel Mack <daniel@caiaq.de>, Feb 2009
3+
============================================================
34

4-
0. Function
5-
-----------
5+
:Author: Daniel Mack <daniel@caiaq.de>, Feb 2009
6+
7+
Function
8+
--------
69

710
Rotary encoders are devices which are connected to the CPU or other
811
peripherals with two wires. The outputs are phase-shifted by 90 degrees
@@ -13,7 +16,7 @@ Some encoders have both outputs low in stable states, others also have
1316
a stable state with both outputs high (half-period mode) and some have
1417
a stable state in all steps (quarter-period mode).
1518

16-
The phase diagram of these two outputs look like this:
19+
The phase diagram of these two outputs look like this::
1720

1821
_____ _____ _____
1922
| | | | | |
@@ -40,8 +43,8 @@ For more information, please see
4043
https://en.wikipedia.org/wiki/Rotary_encoder
4144

4245

43-
1. Events / state machine
44-
-------------------------
46+
Events / state machine
47+
----------------------
4548

4649
In half-period mode, state a) and c) above are used to determine the
4750
rotational direction based on the last stable state. Events are reported in
@@ -65,16 +68,16 @@ d) Falling edge on channel B, channel A in low state
6568
should have happened, unless it flipped back on half the way. The
6669
'armed' state tells us about that.
6770

68-
2. Platform requirements
69-
------------------------
71+
Platform requirements
72+
---------------------
7073

7174
As there is no hardware dependent call in this driver, the platform it is
7275
used with must support gpiolib. Another requirement is that IRQs must be
7376
able to fire on both edges.
7477

7578

76-
3. Board integration
77-
--------------------
79+
Board integration
80+
-----------------
7881

7982
To use this driver in your system, register a platform_device with the
8083
name 'rotary-encoder' and associate the IRQs and some specific platform
@@ -93,34 +96,33 @@ the configuration.
9396
Because GPIO to IRQ mapping is platform specific, this information must
9497
be given in separately to the driver. See the example below.
9598

96-
---------<snip>---------
97-
98-
/* board support file example */
99-
100-
#include <linux/input.h>
101-
#include <linux/rotary_encoder.h>
102-
103-
#define GPIO_ROTARY_A 1
104-
#define GPIO_ROTARY_B 2
105-
106-
static struct rotary_encoder_platform_data my_rotary_encoder_info = {
107-
.steps = 24,
108-
.axis = ABS_X,
109-
.relative_axis = false,
110-
.rollover = false,
111-
.gpio_a = GPIO_ROTARY_A,
112-
.gpio_b = GPIO_ROTARY_B,
113-
.inverted_a = 0,
114-
.inverted_b = 0,
115-
.half_period = false,
116-
.wakeup_source = false,
117-
};
118-
119-
static struct platform_device rotary_encoder_device = {
120-
.name = "rotary-encoder",
121-
.id = 0,
122-
.dev = {
123-
.platform_data = &my_rotary_encoder_info,
124-
}
125-
};
126-
99+
::
100+
101+
/* board support file example */
102+
103+
#include <linux/input.h>
104+
#include <linux/rotary_encoder.h>
105+
106+
#define GPIO_ROTARY_A 1
107+
#define GPIO_ROTARY_B 2
108+
109+
static struct rotary_encoder_platform_data my_rotary_encoder_info = {
110+
.steps = 24,
111+
.axis = ABS_X,
112+
.relative_axis = false,
113+
.rollover = false,
114+
.gpio_a = GPIO_ROTARY_A,
115+
.gpio_b = GPIO_ROTARY_B,
116+
.inverted_a = 0,
117+
.inverted_b = 0,
118+
.half_period = false,
119+
.wakeup_source = false,
120+
};
121+
122+
static struct platform_device rotary_encoder_device = {
123+
.name = "rotary-encoder",
124+
.id = 0,
125+
.dev = {
126+
.platform_data = &my_rotary_encoder_info,
127+
}
128+
};

0 commit comments

Comments
 (0)