Hi Ezequiel,
On 28.09.2013 20:26, Ezequiel Garcia wrote:
> Some rotary-encoder devices (such as those with detents) are capable
> of producing a stable event on each step. This commit adds support
> for this case, by implementing a new interruption handler.
>
> The handler needs only detect the direction of the turn and generate
> an event according to this detection.
>
> +static irqreturn_t rotary_encoder_stepped_irq(int irq, void *dev_id)
> +{
> + struct rotary_encoder *encoder = dev_id;
> + int state, sum;
> +
> + state = rotary_encoder_get_state(encoder->pdata);
> +
> + /*
> + * We encode the previous and the current state,
> + * in the 'sum' variable and then use a table
> + * to decide the direction of the turn.
> + */
> + sum = (encoder->last_stable << 2) + state;
> + switch (sum) {
> + case 0b1101:
> + case 0b0100:
> + case 0b0010:
> + case 0b1011:
Binary constants are frowned upon, please avoid them in the kernel.
checkpatch.pl should have warned you about them as well.
> diff --git a/include/linux/rotary_encoder.h b/include/linux/rotary_encoder.h
> index 3f594dc..499f6f7 100644
> --- a/include/linux/rotary_encoder.h
> +++ b/include/linux/rotary_encoder.h
> @@ -11,6 +11,7 @@ struct rotary_encoder_platform_data {
> bool relative_axis;
> bool rollover;
> bool half_period;
> + bool on_each_step;
Care to add a DT binding for this property as well?
Other than that, this looks good to me, but I can't test it due to the
lack of hardware.
Thanks,
Daniel
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html