Skip to content

Commit

Permalink
Input: rotary-encoder - convert documentation into to ReST format
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Mauro Carvalho Chehab authored and Dmitry Torokhov committed Apr 5, 2017
1 parent 7b11fdc commit 42f2309
Showing 1 changed file with 43 additions and 41 deletions.
84 changes: 43 additions & 41 deletions Documentation/input/rotary-encoder.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
============================================================
rotary-encoder - a generic driver for GPIO connected devices
Daniel Mack <daniel@caiaq.de>, Feb 2009
============================================================

0. Function
-----------
:Author: Daniel Mack <daniel@caiaq.de>, Feb 2009

Function
--------

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

The phase diagram of these two outputs look like this:
The phase diagram of these two outputs look like this::

_____ _____ _____
| | | | | |
Expand All @@ -40,8 +43,8 @@ For more information, please see
https://en.wikipedia.org/wiki/Rotary_encoder


1. Events / state machine
-------------------------
Events / state machine
----------------------

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

2. Platform requirements
------------------------
Platform requirements
---------------------

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


3. Board integration
--------------------
Board integration
-----------------

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

---------<snip>---------

/* board support file example */

#include <linux/input.h>
#include <linux/rotary_encoder.h>

#define GPIO_ROTARY_A 1
#define GPIO_ROTARY_B 2

static struct rotary_encoder_platform_data my_rotary_encoder_info = {
.steps = 24,
.axis = ABS_X,
.relative_axis = false,
.rollover = false,
.gpio_a = GPIO_ROTARY_A,
.gpio_b = GPIO_ROTARY_B,
.inverted_a = 0,
.inverted_b = 0,
.half_period = false,
.wakeup_source = false,
};

static struct platform_device rotary_encoder_device = {
.name = "rotary-encoder",
.id = 0,
.dev = {
.platform_data = &my_rotary_encoder_info,
}
};

::

/* board support file example */

#include <linux/input.h>
#include <linux/rotary_encoder.h>

#define GPIO_ROTARY_A 1
#define GPIO_ROTARY_B 2

static struct rotary_encoder_platform_data my_rotary_encoder_info = {
.steps = 24,
.axis = ABS_X,
.relative_axis = false,
.rollover = false,
.gpio_a = GPIO_ROTARY_A,
.gpio_b = GPIO_ROTARY_B,
.inverted_a = 0,
.inverted_b = 0,
.half_period = false,
.wakeup_source = false,
};

static struct platform_device rotary_encoder_device = {
.name = "rotary-encoder",
.id = 0,
.dev = {
.platform_data = &my_rotary_encoder_info,
}
};

0 comments on commit 42f2309

Please sign in to comment.