All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] input: rotary-encoder: add support for half-period encoders
@ 2011-04-05 18:15 Johan Hovold
  2011-04-05 18:15 ` [PATCH 1/2] input: rotary-encoder: refactor and clean up Johan Hovold
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Johan Hovold @ 2011-04-05 18:15 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Daniel Mack, linux-input, Johan Hovold

Hi, 

These patches add support for rotary-encoders which have two stable states per
input signal period.

The first patch refactors state retrieval and event reporting and the second
adds support for such half-period encoders.

Thanks,
Johan


Johan Hovold (2):
  input: rotary-encoder: refactor and clean up
  input: rotary-encoder: add support for half-period encoders

 Documentation/input/rotary-encoder.txt |   13 ++++
 drivers/input/misc/rotary_encoder.c    |  124 ++++++++++++++++++++++----------
 include/linux/rotary_encoder.h         |    1 +
 3 files changed, 101 insertions(+), 37 deletions(-)

-- 
1.7.4.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/2] input: rotary-encoder: refactor and clean up
  2011-04-05 18:15 [PATCH 0/2] input: rotary-encoder: add support for half-period encoders Johan Hovold
@ 2011-04-05 18:15 ` Johan Hovold
  2011-04-06 23:30   ` H Hartley Sweeten
  2011-04-05 18:15 ` [PATCH 2/2] input: rotary-encoder: add support for half-period encoders Johan Hovold
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 12+ messages in thread
From: Johan Hovold @ 2011-04-05 18:15 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Daniel Mack, linux-input, Johan Hovold

Refactor state retrieval and event reporting in interrupt handler.
Remove a few empty lines.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
---
 drivers/input/misc/rotary_encoder.c |   83 ++++++++++++++++++++--------------
 1 files changed, 49 insertions(+), 34 deletions(-)

diff --git a/drivers/input/misc/rotary_encoder.c b/drivers/input/misc/rotary_encoder.c
index 7e64d01..253e502 100644
--- a/drivers/input/misc/rotary_encoder.c
+++ b/drivers/input/misc/rotary_encoder.c
@@ -40,58 +40,74 @@ struct rotary_encoder {
 	unsigned char dir;	/* 0 - clockwise, 1 - CCW */
 };
 
-static irqreturn_t rotary_encoder_irq(int irq, void *dev_id)
+static int rotary_encoder_get_state(struct rotary_encoder_platform_data *pdata)
 {
-	struct rotary_encoder *encoder = dev_id;
-	struct rotary_encoder_platform_data *pdata = encoder->pdata;
 	int a = !!gpio_get_value(pdata->gpio_a);
 	int b = !!gpio_get_value(pdata->gpio_b);
-	int state;
 
 	a ^= pdata->inverted_a;
 	b ^= pdata->inverted_b;
-	state = (a << 1) | b;
 
-	switch (state) {
+	return ((a << 1) | b);
+}
 
-	case 0x0:
-		if (!encoder->armed)
-			break;
+static void rotary_encoder_report_event(struct rotary_encoder *encoder)
+{
+	struct rotary_encoder_platform_data *pdata = encoder->pdata;
+	unsigned pos;
+	int value;
 
-		if (pdata->relative_axis) {
-			input_report_rel(encoder->input, pdata->axis,
-					 encoder->dir ? -1 : 1);
-		} else {
-			unsigned int pos = encoder->pos;
-
-			if (encoder->dir) {
-				/* turning counter-clockwise */
-				if (pdata->rollover)
-					pos += pdata->steps;
-				if (pos)
-					pos--;
-			} else {
-				/* turning clockwise */
-				if (pdata->rollover || pos < pdata->steps)
-					pos++;
-			}
+	if (pdata->relative_axis) {
+		if (encoder->dir)
+			value = -1;
+		else
+			value = 1;
+
+		input_report_rel(encoder->input, pdata->axis, value);
+	} else {
+		pos = encoder->pos;
+
+		if (encoder->dir) {
+			/* turning counter-clockwise */
 			if (pdata->rollover)
-				pos %= pdata->steps;
-			encoder->pos = pos;
-			input_report_abs(encoder->input, pdata->axis,
-					 encoder->pos);
+				pos += pdata->steps;
+			if (pos)
+				pos--;
+		} else {
+			/* turning clockwise */
+			if (pdata->rollover || pos < pdata->steps)
+				pos++;
 		}
-		input_sync(encoder->input);
 
+		if (pdata->rollover)
+			pos %= pdata->steps;
+
+		encoder->pos = pos;
+		input_report_abs(encoder->input, pdata->axis, encoder->pos);
+	}
+
+	input_sync(encoder->input);
+}
+
+static irqreturn_t rotary_encoder_irq(int irq, void *dev_id)
+{
+	struct rotary_encoder *encoder = dev_id;
+	int state;
+
+	state = rotary_encoder_get_state(encoder->pdata);
+
+	switch (state) {
+	case 0x0:
+		if (!encoder->armed)
+			break;
+		rotary_encoder_report_event(encoder);
 		encoder->armed = false;
 		break;
-
 	case 0x1:
 	case 0x2:
 		if (encoder->armed)
 			encoder->dir = state - 1;
 		break;
-
 	case 0x3:
 		encoder->armed = true;
 		break;
@@ -254,4 +270,3 @@ MODULE_ALIAS("platform:" DRV_NAME);
 MODULE_DESCRIPTION("GPIO rotary encoder driver");
 MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>");
 MODULE_LICENSE("GPL v2");
-
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/2] input: rotary-encoder: add support for half-period encoders
  2011-04-05 18:15 [PATCH 0/2] input: rotary-encoder: add support for half-period encoders Johan Hovold
  2011-04-05 18:15 ` [PATCH 1/2] input: rotary-encoder: refactor and clean up Johan Hovold
@ 2011-04-05 18:15 ` Johan Hovold
  2011-04-05 19:39   ` [PATCH 2/2 v2] " Johan Hovold
  2011-04-08  7:39 ` [PATCH 0/2] " Daniel Mack
  2011-05-10 19:05 ` Johan Hovold
  3 siblings, 1 reply; 12+ messages in thread
From: Johan Hovold @ 2011-04-05 18:15 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Daniel Mack, linux-input, Johan Hovold

Add support for encoders that have two detents per input signal period.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
---
 Documentation/input/rotary-encoder.txt |   13 ++++++++++
 drivers/input/misc/rotary_encoder.c    |   41 +++++++++++++++++++++++++++++--
 include/linux/rotary_encoder.h         |    1 +
 3 files changed, 52 insertions(+), 3 deletions(-)

diff --git a/Documentation/input/rotary-encoder.txt b/Documentation/input/rotary-encoder.txt
index 8b4129d..76b707b 100644
--- a/Documentation/input/rotary-encoder.txt
+++ b/Documentation/input/rotary-encoder.txt
@@ -9,6 +9,9 @@ peripherals with two wires. The outputs are phase-shifted by 90 degrees
 and by triggering on falling and rising edges, the turn direction can
 be determined.
 
+Some encoders have both inputs low in stable states, whereas others also have
+a stable state with both inputs high (half-period mode).
+
 The phase diagram of these two outputs look like this:
 
                   _____       _____       _____
@@ -26,6 +29,8 @@ The phase diagram of these two outputs look like this:
                 |<-------->|
 	          one step
 
+                |<-->|
+	          one step (half-period mode)
 
 For more information, please see
 	http://en.wikipedia.org/wiki/Rotary_encoder
@@ -34,6 +39,13 @@ For more information, please see
 1. 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
+states b) and d) given that the new stable state is different from the last
+(i.e. the rotation was not reversed half-way).
+
+Otherwise, the following apply:
+
 a) Rising edge on channel A, channel B in low state
 	This state is used to recognize a clockwise turn
 
@@ -96,6 +108,7 @@ static struct rotary_encoder_platform_data my_rotary_encoder_info = {
 	.gpio_b		= GPIO_ROTARY_B,
 	.inverted_a	= 0,
 	.inverted_b	= 0,
+	.half_period	= false,
 };
 
 static struct platform_device rotary_encoder_device = {
diff --git a/drivers/input/misc/rotary_encoder.c b/drivers/input/misc/rotary_encoder.c
index 253e502..ce329a6 100644
--- a/drivers/input/misc/rotary_encoder.c
+++ b/drivers/input/misc/rotary_encoder.c
@@ -2,6 +2,7 @@
  * rotary_encoder.c
  *
  * (c) 2009 Daniel Mack <daniel@caiaq.de>
+ * Copyright (C) 2011 Johan Hovold <jhovold@gmail.com>
  *
  * state machine code inspired by code from Tim Ruetz
  *
@@ -38,6 +39,8 @@ struct rotary_encoder {
 
 	bool armed;
 	unsigned char dir;	/* 0 - clockwise, 1 - CCW */
+
+	char last_stable;
 };
 
 static int rotary_encoder_get_state(struct rotary_encoder_platform_data *pdata)
@@ -116,11 +119,36 @@ static irqreturn_t rotary_encoder_irq(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
+static irqreturn_t rotary_encoder_half_period_irq(int irq, void *dev_id)
+{
+	struct rotary_encoder *encoder = dev_id;
+	int state;
+
+	state = rotary_encoder_get_state(encoder->pdata);
+
+	switch (state) {
+	case 0x00:
+	case 0x03:
+		if (state == encoder->last_stable)
+			break;
+		rotary_encoder_report_event(encoder);
+		encoder->last_stable = state;
+		break;
+	case 0x01:
+	case 0x02:
+		encoder->dir = (encoder->last_stable + state) & 0x01;
+		break;
+	}
+
+	return IRQ_HANDLED;
+}
+
 static int __devinit rotary_encoder_probe(struct platform_device *pdev)
 {
 	struct rotary_encoder_platform_data *pdata = pdev->dev.platform_data;
 	struct rotary_encoder *encoder;
 	struct input_dev *input;
+	irq_handler_t handler;
 	int err;
 
 	if (!pdata) {
@@ -191,7 +219,14 @@ static int __devinit rotary_encoder_probe(struct platform_device *pdev)
 	}
 
 	/* request the IRQs */
-	err = request_irq(encoder->irq_a, &rotary_encoder_irq,
+	if (pdata->half_period) {
+		handler = &rotary_encoder_half_period_irq;
+		encoder->last_stable = rotary_encoder_get_state(pdata);
+	} else {
+		handler = &rotary_encoder_irq;
+	}
+
+	err = request_irq(encoder->irq_a, handler,
 			  IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
 			  DRV_NAME, encoder);
 	if (err) {
@@ -200,7 +235,7 @@ static int __devinit rotary_encoder_probe(struct platform_device *pdev)
 		goto exit_free_gpio_b;
 	}
 
-	err = request_irq(encoder->irq_b, &rotary_encoder_irq,
+	err = request_irq(encoder->irq_b, handler,
 			  IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
 			  DRV_NAME, encoder);
 	if (err) {
@@ -268,5 +303,5 @@ module_exit(rotary_encoder_exit);
 
 MODULE_ALIAS("platform:" DRV_NAME);
 MODULE_DESCRIPTION("GPIO rotary encoder driver");
-MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>");
+MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>, Johan Hovold");
 MODULE_LICENSE("GPL v2");
diff --git a/include/linux/rotary_encoder.h b/include/linux/rotary_encoder.h
index 215278b..3f594dc 100644
--- a/include/linux/rotary_encoder.h
+++ b/include/linux/rotary_encoder.h
@@ -10,6 +10,7 @@ struct rotary_encoder_platform_data {
 	unsigned int inverted_b;
 	bool relative_axis;
 	bool rollover;
+	bool half_period;
 };
 
 #endif /* __ROTARY_ENCODER_H__ */
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/2 v2] input: rotary-encoder: add support for half-period encoders
  2011-04-05 18:15 ` [PATCH 2/2] input: rotary-encoder: add support for half-period encoders Johan Hovold
@ 2011-04-05 19:39   ` Johan Hovold
  2011-04-05 19:46     ` [PATCH 2/2 v3] " Johan Hovold
  0 siblings, 1 reply; 12+ messages in thread
From: Johan Hovold @ 2011-04-05 19:39 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Daniel Mack, linux-input, Johan Hovold

Add support for encoders that have two detents per input signal period.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
---

v2: fix typo in documentation (s/inputs/outputs/)

 Documentation/input/rotary-encoder.txt |   13 ++++++++++
 drivers/input/misc/rotary_encoder.c    |   41 +++++++++++++++++++++++++++++--
 include/linux/rotary_encoder.h         |    1 +
 3 files changed, 52 insertions(+), 3 deletions(-)

diff --git a/Documentation/input/rotary-encoder.txt b/Documentation/input/rotary-encoder.txt
index 8b4129d..64fbed0 100644
--- a/Documentation/input/rotary-encoder.txt
+++ b/Documentation/input/rotary-encoder.txt
@@ -9,6 +9,9 @@ peripherals with two wires. The outputs are phase-shifted by 90 degrees
 and by triggering on falling and rising edges, the turn direction can
 be determined.
 
+Some encoders have both outputs low in stable states, whereas others also have
+a stable state with both ouputs high (half-period mode).
+
 The phase diagram of these two outputs look like this:
 
                   _____       _____       _____
@@ -26,6 +29,8 @@ The phase diagram of these two outputs look like this:
                 |<-------->|
 	          one step
 
+                |<-->|
+	          one step (half-period mode)
 
 For more information, please see
 	http://en.wikipedia.org/wiki/Rotary_encoder
@@ -34,6 +39,13 @@ For more information, please see
 1. 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
+states b) and d) given that the new stable state is different from the last
+(i.e. the rotation was not reversed half-way).
+
+Otherwise, the following apply:
+
 a) Rising edge on channel A, channel B in low state
 	This state is used to recognize a clockwise turn
 
@@ -96,6 +108,7 @@ static struct rotary_encoder_platform_data my_rotary_encoder_info = {
 	.gpio_b		= GPIO_ROTARY_B,
 	.inverted_a	= 0,
 	.inverted_b	= 0,
+	.half_period	= false,
 };
 
 static struct platform_device rotary_encoder_device = {
diff --git a/drivers/input/misc/rotary_encoder.c b/drivers/input/misc/rotary_encoder.c
index 253e502..ce329a6 100644
--- a/drivers/input/misc/rotary_encoder.c
+++ b/drivers/input/misc/rotary_encoder.c
@@ -2,6 +2,7 @@
  * rotary_encoder.c
  *
  * (c) 2009 Daniel Mack <daniel@caiaq.de>
+ * Copyright (C) 2011 Johan Hovold <jhovold@gmail.com>
  *
  * state machine code inspired by code from Tim Ruetz
  *
@@ -38,6 +39,8 @@ struct rotary_encoder {
 
 	bool armed;
 	unsigned char dir;	/* 0 - clockwise, 1 - CCW */
+
+	char last_stable;
 };
 
 static int rotary_encoder_get_state(struct rotary_encoder_platform_data *pdata)
@@ -116,11 +119,36 @@ static irqreturn_t rotary_encoder_irq(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
+static irqreturn_t rotary_encoder_half_period_irq(int irq, void *dev_id)
+{
+	struct rotary_encoder *encoder = dev_id;
+	int state;
+
+	state = rotary_encoder_get_state(encoder->pdata);
+
+	switch (state) {
+	case 0x00:
+	case 0x03:
+		if (state == encoder->last_stable)
+			break;
+		rotary_encoder_report_event(encoder);
+		encoder->last_stable = state;
+		break;
+	case 0x01:
+	case 0x02:
+		encoder->dir = (encoder->last_stable + state) & 0x01;
+		break;
+	}
+
+	return IRQ_HANDLED;
+}
+
 static int __devinit rotary_encoder_probe(struct platform_device *pdev)
 {
 	struct rotary_encoder_platform_data *pdata = pdev->dev.platform_data;
 	struct rotary_encoder *encoder;
 	struct input_dev *input;
+	irq_handler_t handler;
 	int err;
 
 	if (!pdata) {
@@ -191,7 +219,14 @@ static int __devinit rotary_encoder_probe(struct platform_device *pdev)
 	}
 
 	/* request the IRQs */
-	err = request_irq(encoder->irq_a, &rotary_encoder_irq,
+	if (pdata->half_period) {
+		handler = &rotary_encoder_half_period_irq;
+		encoder->last_stable = rotary_encoder_get_state(pdata);
+	} else {
+		handler = &rotary_encoder_irq;
+	}
+
+	err = request_irq(encoder->irq_a, handler,
 			  IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
 			  DRV_NAME, encoder);
 	if (err) {
@@ -200,7 +235,7 @@ static int __devinit rotary_encoder_probe(struct platform_device *pdev)
 		goto exit_free_gpio_b;
 	}
 
-	err = request_irq(encoder->irq_b, &rotary_encoder_irq,
+	err = request_irq(encoder->irq_b, handler,
 			  IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
 			  DRV_NAME, encoder);
 	if (err) {
@@ -268,5 +303,5 @@ module_exit(rotary_encoder_exit);
 
 MODULE_ALIAS("platform:" DRV_NAME);
 MODULE_DESCRIPTION("GPIO rotary encoder driver");
-MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>");
+MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>, Johan Hovold");
 MODULE_LICENSE("GPL v2");
diff --git a/include/linux/rotary_encoder.h b/include/linux/rotary_encoder.h
index 215278b..3f594dc 100644
--- a/include/linux/rotary_encoder.h
+++ b/include/linux/rotary_encoder.h
@@ -10,6 +10,7 @@ struct rotary_encoder_platform_data {
 	unsigned int inverted_b;
 	bool relative_axis;
 	bool rollover;
+	bool half_period;
 };
 
 #endif /* __ROTARY_ENCODER_H__ */
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/2 v3] input: rotary-encoder: add support for half-period encoders
  2011-04-05 19:39   ` [PATCH 2/2 v2] " Johan Hovold
@ 2011-04-05 19:46     ` Johan Hovold
  0 siblings, 0 replies; 12+ messages in thread
From: Johan Hovold @ 2011-04-05 19:46 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Daniel Mack, linux-input, Johan Hovold

Add support for encoders that have two detents per input signal period.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
---

v2: fix typo in documentation (s/inputs/outputs/)
v3: fix typo in documentation (s/ouputs/outputs/)

 Documentation/input/rotary-encoder.txt |   13 ++++++++++
 drivers/input/misc/rotary_encoder.c    |   41 +++++++++++++++++++++++++++++--
 include/linux/rotary_encoder.h         |    1 +
 3 files changed, 52 insertions(+), 3 deletions(-)

diff --git a/Documentation/input/rotary-encoder.txt b/Documentation/input/rotary-encoder.txt
index 8b4129d..2ac5c60 100644
--- a/Documentation/input/rotary-encoder.txt
+++ b/Documentation/input/rotary-encoder.txt
@@ -9,6 +9,9 @@ peripherals with two wires. The outputs are phase-shifted by 90 degrees
 and by triggering on falling and rising edges, the turn direction can
 be determined.
 
+Some encoders have both outputs low in stable states, whereas others also have
+a stable state with both outputs high (half-period mode).
+
 The phase diagram of these two outputs look like this:
 
                   _____       _____       _____
@@ -26,6 +29,8 @@ The phase diagram of these two outputs look like this:
                 |<-------->|
 	          one step
 
+                |<-->|
+	          one step (half-period mode)
 
 For more information, please see
 	http://en.wikipedia.org/wiki/Rotary_encoder
@@ -34,6 +39,13 @@ For more information, please see
 1. 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
+states b) and d) given that the new stable state is different from the last
+(i.e. the rotation was not reversed half-way).
+
+Otherwise, the following apply:
+
 a) Rising edge on channel A, channel B in low state
 	This state is used to recognize a clockwise turn
 
@@ -96,6 +108,7 @@ static struct rotary_encoder_platform_data my_rotary_encoder_info = {
 	.gpio_b		= GPIO_ROTARY_B,
 	.inverted_a	= 0,
 	.inverted_b	= 0,
+	.half_period	= false,
 };
 
 static struct platform_device rotary_encoder_device = {
diff --git a/drivers/input/misc/rotary_encoder.c b/drivers/input/misc/rotary_encoder.c
index 253e502..ce329a6 100644
--- a/drivers/input/misc/rotary_encoder.c
+++ b/drivers/input/misc/rotary_encoder.c
@@ -2,6 +2,7 @@
  * rotary_encoder.c
  *
  * (c) 2009 Daniel Mack <daniel@caiaq.de>
+ * Copyright (C) 2011 Johan Hovold <jhovold@gmail.com>
  *
  * state machine code inspired by code from Tim Ruetz
  *
@@ -38,6 +39,8 @@ struct rotary_encoder {
 
 	bool armed;
 	unsigned char dir;	/* 0 - clockwise, 1 - CCW */
+
+	char last_stable;
 };
 
 static int rotary_encoder_get_state(struct rotary_encoder_platform_data *pdata)
@@ -116,11 +119,36 @@ static irqreturn_t rotary_encoder_irq(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
+static irqreturn_t rotary_encoder_half_period_irq(int irq, void *dev_id)
+{
+	struct rotary_encoder *encoder = dev_id;
+	int state;
+
+	state = rotary_encoder_get_state(encoder->pdata);
+
+	switch (state) {
+	case 0x00:
+	case 0x03:
+		if (state == encoder->last_stable)
+			break;
+		rotary_encoder_report_event(encoder);
+		encoder->last_stable = state;
+		break;
+	case 0x01:
+	case 0x02:
+		encoder->dir = (encoder->last_stable + state) & 0x01;
+		break;
+	}
+
+	return IRQ_HANDLED;
+}
+
 static int __devinit rotary_encoder_probe(struct platform_device *pdev)
 {
 	struct rotary_encoder_platform_data *pdata = pdev->dev.platform_data;
 	struct rotary_encoder *encoder;
 	struct input_dev *input;
+	irq_handler_t handler;
 	int err;
 
 	if (!pdata) {
@@ -191,7 +219,14 @@ static int __devinit rotary_encoder_probe(struct platform_device *pdev)
 	}
 
 	/* request the IRQs */
-	err = request_irq(encoder->irq_a, &rotary_encoder_irq,
+	if (pdata->half_period) {
+		handler = &rotary_encoder_half_period_irq;
+		encoder->last_stable = rotary_encoder_get_state(pdata);
+	} else {
+		handler = &rotary_encoder_irq;
+	}
+
+	err = request_irq(encoder->irq_a, handler,
 			  IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
 			  DRV_NAME, encoder);
 	if (err) {
@@ -200,7 +235,7 @@ static int __devinit rotary_encoder_probe(struct platform_device *pdev)
 		goto exit_free_gpio_b;
 	}
 
-	err = request_irq(encoder->irq_b, &rotary_encoder_irq,
+	err = request_irq(encoder->irq_b, handler,
 			  IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
 			  DRV_NAME, encoder);
 	if (err) {
@@ -268,5 +303,5 @@ module_exit(rotary_encoder_exit);
 
 MODULE_ALIAS("platform:" DRV_NAME);
 MODULE_DESCRIPTION("GPIO rotary encoder driver");
-MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>");
+MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>, Johan Hovold");
 MODULE_LICENSE("GPL v2");
diff --git a/include/linux/rotary_encoder.h b/include/linux/rotary_encoder.h
index 215278b..3f594dc 100644
--- a/include/linux/rotary_encoder.h
+++ b/include/linux/rotary_encoder.h
@@ -10,6 +10,7 @@ struct rotary_encoder_platform_data {
 	unsigned int inverted_b;
 	bool relative_axis;
 	bool rollover;
+	bool half_period;
 };
 
 #endif /* __ROTARY_ENCODER_H__ */
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* RE: [PATCH 1/2] input: rotary-encoder: refactor and clean up
  2011-04-05 18:15 ` [PATCH 1/2] input: rotary-encoder: refactor and clean up Johan Hovold
@ 2011-04-06 23:30   ` H Hartley Sweeten
  0 siblings, 0 replies; 12+ messages in thread
From: H Hartley Sweeten @ 2011-04-06 23:30 UTC (permalink / raw)
  To: Johan Hovold, Dmitry Torokhov; +Cc: Daniel Mack, linux-input

On Tuesday, April 05, 2011 11:15 AM, Johan Hovold wrote:
>
> Refactor state retrieval and event reporting in interrupt handler.
> Remove a few empty lines.
>
> Signed-off-by: Johan Hovold <jhovold@gmail.com>
> ---
>  drivers/input/misc/rotary_encoder.c |   83 ++++++++++++++++++++--------------
>  1 files changed, 49 insertions(+), 34 deletions(-)

Looks sane to me.

Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/2] input: rotary-encoder: add support for half-period encoders
  2011-04-05 18:15 [PATCH 0/2] input: rotary-encoder: add support for half-period encoders Johan Hovold
  2011-04-05 18:15 ` [PATCH 1/2] input: rotary-encoder: refactor and clean up Johan Hovold
  2011-04-05 18:15 ` [PATCH 2/2] input: rotary-encoder: add support for half-period encoders Johan Hovold
@ 2011-04-08  7:39 ` Daniel Mack
  2011-04-11 10:44   ` Johan Hovold
  2011-05-10 19:05 ` Johan Hovold
  3 siblings, 1 reply; 12+ messages in thread
From: Daniel Mack @ 2011-04-08  7:39 UTC (permalink / raw)
  To: Johan Hovold; +Cc: Dmitry Torokhov, linux-input

On Tue, Apr 5, 2011 at 8:15 PM, Johan Hovold <jhovold@gmail.com> wrote:
> Hi,
>
> These patches add support for rotary-encoders which have two stable states per
> input signal period.
>
> The first patch refactors state retrieval and event reporting and the second
> adds support for such half-period encoders.

I have no objections to let the code in, and the patch looks sane to me.

However, I don't currently have access to the hardware I wrote the
driver for, so I can't test right now, but will do at some later
point.

Feel free to add my Acked-by:, and I will get back to you in case I
encounter any trouble.

Thanks,
Daniel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/2] input: rotary-encoder: add support for half-period encoders
  2011-04-08  7:39 ` [PATCH 0/2] " Daniel Mack
@ 2011-04-11 10:44   ` Johan Hovold
  0 siblings, 0 replies; 12+ messages in thread
From: Johan Hovold @ 2011-04-11 10:44 UTC (permalink / raw)
  To: Daniel Mack; +Cc: Dmitry Torokhov, linux-input

On Fri, Apr 08, 2011 at 09:39:21AM +0200, Daniel Mack wrote:
> On Tue, Apr 5, 2011 at 8:15 PM, Johan Hovold <jhovold@gmail.com> wrote:
> > Hi,
> >
> > These patches add support for rotary-encoders which have two stable states per
> > input signal period.
> >
> > The first patch refactors state retrieval and event reporting and the second
> > adds support for such half-period encoders.
> 
> I have no objections to let the code in, and the patch looks sane to me.
> 
> However, I don't currently have access to the hardware I wrote the
> driver for, so I can't test right now, but will do at some later
> point.

It is possible to test non-half-period mode with a half-period encoder
(and vice verse) and I've verified that my patches do not change the
original state machine. In particular, every other event is still
missing as no event is delivered in the armed-state in non-half-period
mode.

> Feel free to add my Acked-by:, and I will get back to you in case I
> encounter any trouble.

Thanks,
Johan

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/2] input: rotary-encoder: add support for half-period encoders
  2011-04-05 18:15 [PATCH 0/2] input: rotary-encoder: add support for half-period encoders Johan Hovold
                   ` (2 preceding siblings ...)
  2011-04-08  7:39 ` [PATCH 0/2] " Daniel Mack
@ 2011-05-10 19:05 ` Johan Hovold
  2011-05-22 21:29   ` Daniel Mack
  3 siblings, 1 reply; 12+ messages in thread
From: Johan Hovold @ 2011-05-10 19:05 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Daniel Mack, linux-input

Hi Dmitry,

On Tue, Apr 05, 2011 at 08:15:11PM +0200, Johan Hovold wrote:
> These patches add support for rotary-encoders which have two stable
> states per input signal period.

Is there any chance to get these into 2.6.40? I haven't received any
feedback from you so I thought I'd send a reminder.

Thanks,
Johan

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/2] input: rotary-encoder: add support for half-period encoders
  2011-05-10 19:05 ` Johan Hovold
@ 2011-05-22 21:29   ` Daniel Mack
  2011-05-22 22:42     ` Daniel Mack
  2011-05-23 12:07     ` Johan Hovold
  0 siblings, 2 replies; 12+ messages in thread
From: Daniel Mack @ 2011-05-22 21:29 UTC (permalink / raw)
  To: Johan Hovold; +Cc: Dmitry Torokhov, linux-input

Hi Johan,

On Tue, May 10, 2011 at 9:05 PM, Johan Hovold <jhovold@gmail.com> wrote:
> Hi Dmitry,
>
> On Tue, Apr 05, 2011 at 08:15:11PM +0200, Johan Hovold wrote:
>> These patches add support for rotary-encoders which have two stable
>> states per input signal period.
>
> Is there any chance to get these into 2.6.40? I haven't received any
> feedback from you so I thought I'd send a reminder.

Very sorry for the long delay.

I was finally able to test your patches with real hardware, and they
seem to work alright. So I have no problem with them being accepted
any time soon, but I don't know if they will still make it to 2.6.40.

Sorry again for not getting back to you earlier, and thanks for your
contribution.

Daniel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/2] input: rotary-encoder: add support for half-period encoders
  2011-05-22 21:29   ` Daniel Mack
@ 2011-05-22 22:42     ` Daniel Mack
  2011-05-23 12:07     ` Johan Hovold
  1 sibling, 0 replies; 12+ messages in thread
From: Daniel Mack @ 2011-05-22 22:42 UTC (permalink / raw)
  To: Johan Hovold; +Cc: Dmitry Torokhov, linux-input

On Sun, May 22, 2011 at 11:29 PM, Daniel Mack <zonque@gmail.com> wrote:
> Hi Johan,
>
> On Tue, May 10, 2011 at 9:05 PM, Johan Hovold <jhovold@gmail.com> wrote:
>> Hi Dmitry,
>>
>> On Tue, Apr 05, 2011 at 08:15:11PM +0200, Johan Hovold wrote:
>>> These patches add support for rotary-encoders which have two stable
>>> states per input signal period.
>>
>> Is there any chance to get these into 2.6.40? I haven't received any
>> feedback from you so I thought I'd send a reminder.
>
> Very sorry for the long delay.
>
> I was finally able to test your patches with real hardware, and they
> seem to work alright. So I have no problem with them being accepted
> any time soon, but I don't know if they will still make it to 2.6.40.

Btw, that also means you can have my

Acked-by: Daniel Mack <zonque@gmail.com>

for both patches.

Daniel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/2] input: rotary-encoder: add support for half-period encoders
  2011-05-22 21:29   ` Daniel Mack
  2011-05-22 22:42     ` Daniel Mack
@ 2011-05-23 12:07     ` Johan Hovold
  1 sibling, 0 replies; 12+ messages in thread
From: Johan Hovold @ 2011-05-23 12:07 UTC (permalink / raw)
  To: Daniel Mack; +Cc: Dmitry Torokhov, linux-input

On Sun, May 22, 2011 at 11:29:44PM +0200, Daniel Mack wrote:
> I was finally able to test your patches with real hardware, and they
> seem to work alright. So I have no problem with them being accepted
> any time soon, but I don't know if they will still make it to 2.6.40.

Thanks for testing. It seems they where added to Dmitry's tree about a
week ago.

Thanks,
Johan

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2011-05-23 12:07 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-05 18:15 [PATCH 0/2] input: rotary-encoder: add support for half-period encoders Johan Hovold
2011-04-05 18:15 ` [PATCH 1/2] input: rotary-encoder: refactor and clean up Johan Hovold
2011-04-06 23:30   ` H Hartley Sweeten
2011-04-05 18:15 ` [PATCH 2/2] input: rotary-encoder: add support for half-period encoders Johan Hovold
2011-04-05 19:39   ` [PATCH 2/2 v2] " Johan Hovold
2011-04-05 19:46     ` [PATCH 2/2 v3] " Johan Hovold
2011-04-08  7:39 ` [PATCH 0/2] " Daniel Mack
2011-04-11 10:44   ` Johan Hovold
2011-05-10 19:05 ` Johan Hovold
2011-05-22 21:29   ` Daniel Mack
2011-05-22 22:42     ` Daniel Mack
2011-05-23 12:07     ` Johan Hovold

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.