From patchwork Wed May 12 13:12:34 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jelle Martijn Kok X-Patchwork-Id: 99006 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4CDCavc005593 for ; Wed, 12 May 2010 13:12:36 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751979Ab0ELNMg (ORCPT ); Wed, 12 May 2010 09:12:36 -0400 Received: from lime.solrad.nl ([213.193.238.107]:49560 "EHLO lime.solrad.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751565Ab0ELNMf (ORCPT ); Wed, 12 May 2010 09:12:35 -0400 Received: from green.youcom.nl (green.youcom.nl [::ffff:195.64.93.233]) (TLS: TLSv1/SSLv3,256bits,AES256-SHA) by lime.solrad.nl with esmtp; Wed, 12 May 2010 15:12:34 +0200 id 000EB307.4BEAA942.00002F64 Received: from [192.168.5.122] ([::ffff:192.168.5.122]) (AUTH: LOGIN jmkok) by green.youcom.nl with esmtp; Wed, 12 May 2010 15:12:34 +0200 id 0000000001F28543.000000004BEAA942.00000237 Message-ID: <4BEAA942.1010108@youcom.nl> Date: Wed, 12 May 2010 15:12:34 +0200 From: Jelle Martijn Kok Organization: You/Com Audiocommunicatie BV User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100423 Thunderbird/3.0.4 MIME-Version: 1.0 To: linux-input@vger.kernel.org Subject: [PATCH 3/3] rotary_encoder: added key events to increase and decrease Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 12 May 2010 13:12:36 +0000 (UTC) diff --git a/drivers/input/misc/rotary_encoder.c b/drivers/input/misc/rotary_encoder.c index 1c9728f..9ada6fd 100644 --- a/drivers/input/misc/rotary_encoder.c +++ b/drivers/input/misc/rotary_encoder.c @@ -56,9 +56,17 @@ static irqreturn_t rotary_encoder_irq(int irq, void *dev_id) int dir = 0; if (state_exor == 0x01) { dir = +1; + if (pdata->event_up) { + input_report_key(encoder->input, pdata->event_up, 1); + input_report_key(encoder->input, pdata->event_up, 0); + } } else { dir = -1; + if (pdata->event_down) { + input_report_key(encoder->input, pdata->event_down, 1); + input_report_key(encoder->input, pdata->event_down, 0); + } } if (dir) { @@ -130,11 +138,18 @@ static int __devinit rotary_encoder_probe(struct platform_device *pdev) input->id.bustype = BUS_HOST; input->dev.parent = &pdev->dev; + if (pdata->event_up || pdata->event_down) { + input->evbit[0] |= BIT(EV_KEY); + __set_bit(pdata->event_up, input->keybit); + __set_bit(pdata->event_down, input->keybit); + input_set_capability(input, EV_MSC, MSC_SCAN); + } + if (pdata->relative_axis) { - input->evbit[0] = BIT_MASK(EV_REL); + input->evbit[0] |= BIT_MASK(EV_REL); input->relbit[0] = BIT_MASK(pdata->axis); } else { - input->evbit[0] = BIT_MASK(EV_ABS); + input->evbit[0] |= BIT_MASK(EV_ABS); input_set_abs_params(encoder->input, pdata->axis, pdata->min_value, pdata->max_value, 0, 1); } diff --git a/include/linux/rotary_encoder.h b/include/linux/rotary_encoder.h index a0d15d9..2350a48 100644 --- a/include/linux/rotary_encoder.h +++ b/include/linux/rotary_encoder.h @@ -7,6 +7,8 @@ struct rotary_encoder_platform_data { unsigned int min_value; unsigned int max_value; unsigned int axis; + unsigned int event_up; + unsigned int event_down; unsigned int gpio_a; unsigned int gpio_b; unsigned int inverted_a;