linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "R, Vignesh" <vigneshr@ti.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Rob Herring <robh+dt@kernel.org>,
	Tony Lindgren <tony@atomide.com>,
	Jonathan Corbet <corbet@lwn.net>, Johan Hovold <johan@kernel.org>,
	Sylvain Rochet <sylvain.rochet@finsecur.com>,
	Masanari Iida <standby24x7@gmail.com>,
	Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>,
	S Twiss <stwiss.opensource@diasemi.com>,
	Krzysztof Kozlowski <k.kozlowski@samsung.com>,
	Moritz Fischer <moritz.fischer@ettus.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Timo Teras <timo.teras@iki.fi>,
	Clifton Barnes <clifton.a.barnes@gmail.com>,
	"linux-input@vger.kernel.org" <linux-input@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
	"linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [RFC PATCH 1/2] Input: rotary-encoder- Add support for absolute encoder
Date: Mon, 23 May 2016 16:48:40 +0530	[thread overview]
Message-ID: <5742E710.9@ti.com> (raw)
In-Reply-To: <20160522102606.GB23704@pengutronix.de>



On 5/22/2016 3:56 PM, Uwe Kleine-König wrote:
> Hello,
> 
> On Thu, May 19, 2016 at 02:34:00PM +0530, Vignesh R wrote:
>> There are rotary-encoders where GPIO lines reflect the actual position
>> of the rotary encoder dial. For example, if dial points to 9, then four
>> GPIO lines connected to the rotary encoder will read HLLH(1001b = 9).
>> Add support for such rotary-encoder.
>> The driver relies on rotary-encoder,absolute-encoder DT property to
>> detect such encoders.
>> Since, GPIO IRQs are not necessary to work with
>> such encoders, optional polling mode support is added using
> 
> I don't understand this. It's necessary in the same way as with the
> already supported devices. I.e. you want to trigger an irq when the
> encoder is moved and then check for it's position in the handler.
> 

Unlike already supported device, there is no need to count steps or
determine the direction of rotation. Hence, IRQ is not a requirement,
periodically polling the gpio lines is more than sufficient. With
absolute encoder, you are able to determine the current position at any
time just by looking at the gpio inputs.
Suppose we poll device at t=0ms and see gpio values are LLLH(1), if we
again poll device at t=500ms(which is what input_poll_dev helps to do)
and see that gpio values is LLHH(3), then we know that rotary encoder
has changed to 3. This can be done w/o IRQ for absolute encoders.

>> diff --git a/Documentation/devicetree/bindings/input/rotary-encoder.txt b/Documentation/devicetree/bindings/input/rotary-encoder.txt
>> index 6c9f0c8a846c..9c928dbd1500 100644
>> --- a/Documentation/devicetree/bindings/input/rotary-encoder.txt
>> +++ b/Documentation/devicetree/bindings/input/rotary-encoder.txt
>> @@ -12,6 +12,10 @@ Optional properties:
>>  - rotary-encoder,relative-axis: register a relative axis rather than an
>>    absolute one. Relative axis will only generate +1/-1 events on the input
>>    device, hence no steps need to be passed.
>> +- rotary-encoder,absolute-encoder: support encoders where GPIO lines
>> +  reflect the actual position of the rotary encoder dial. For example,
>> +  if dial points to 9, then four GPIO lines read HLLH(1001b = 9).
>> +  In this case, rotary-encoder,steps-per-period needed not be defined.
> 
> IMHO this is wrong, I'd formalize this device as:
> 
> 	{
> 		compatible = "rotary-encoder";
> 		gpios = <&gpio 19 1>, <&gpio 20 0>, <...>, <...>;
> 		rotary-encoder,encoding = "binary";
> 		rotary-encoder,steps = <16>;
> 		rotary-encoder,steps-per-period = <16>;

The above bindings essential means quarter_period device. I would not
like to bother with all the logic in rotary_encoder_quarter_period_irq()
when we can know encoder->pos by directly reading state of gpio lines.

> 		rotary-encoder,rollover;
> 	}
> 
> and support this with a v4 of
> 
> 	http://thread.gmane.org/gmane.linux.kernel.input/48892
> 
>

IMHO, there needs to be separate IRQ handler for absolute encoders so
that the driver logic is greatly simplified.

  reply	other threads:[~2016-05-23 11:19 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-19  9:03 [RFC PATCH 0/2] AM335x-ICE: Add support for rotary-encoder Vignesh R
2016-05-19  9:04 ` [RFC PATCH 1/2] Input: rotary-encoder- Add support for absolute encoder Vignesh R
2016-05-19 11:25   ` Krzysztof Kozlowski
2016-05-19 11:44     ` Vignesh R
2016-05-20 16:34   ` Dmitry Torokhov
2016-05-23  9:18     ` R, Vignesh
2016-05-25  8:44       ` Vignesh R
2016-06-16 10:47         ` Vignesh R
2016-07-19 13:04           ` R, Vignesh
2016-05-20 21:49   ` Rob Herring
2016-05-22 10:26   ` Uwe Kleine-König
2016-05-23 11:18     ` R, Vignesh [this message]
2016-05-23 13:18       ` Uwe Kleine-König
2016-05-24  5:09         ` Vignesh R
2016-05-24  8:20           ` Uwe Kleine-König
2016-05-25  8:44             ` Vignesh R
2016-05-19  9:04 ` [RFC PATCH 2/2] ARM: dts: am335x-icev2: Add rotary-encoder node Vignesh R

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5742E710.9@ti.com \
    --to=vigneshr@ti.com \
    --cc=arnd@arndb.de \
    --cc=clifton.a.barnes@gmail.com \
    --cc=corbet@lwn.net \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=ezequiel@vanguardiasur.com.ar \
    --cc=geert@linux-m68k.org \
    --cc=johan@kernel.org \
    --cc=k.kozlowski@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=moritz.fischer@ettus.com \
    --cc=robh+dt@kernel.org \
    --cc=standby24x7@gmail.com \
    --cc=stwiss.opensource@diasemi.com \
    --cc=sylvain.rochet@finsecur.com \
    --cc=timo.teras@iki.fi \
    --cc=tony@atomide.com \
    --cc=u.kleine-koenig@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).