All of lore.kernel.org
 help / color / mirror / Atom feed
From: Niels Laukens <niels@dest-unreach.be>
To: Mauro Carvalho Chehab <m.chehab@samsung.com>,
	linux-media@vger.kernel.org
Cc: "James Hogan" <james.hogan@imgtec.com>,
	"David Härdeman" <david@hardeman.nu>,
	"Antti Seppälä" <a.seppala@gmail.com>
Subject: [PATCH 1/2] drivers/media/rc/ir-nec-decode : add toggle feature
Date: Thu, 19 Jun 2014 10:25:29 +0200	[thread overview]
Message-ID: <53A29E79.2000304@dest-unreach.be> (raw)
In-Reply-To: <53A29E5A.9030304@dest-unreach.be>

>From 83aa9f9fa0eaf9eb8005af49f5ce93d24a0b9f2e Mon Sep 17 00:00:00 2001
From: Niels Laukens <niels.laukens@vrt.be>
Date: Thu, 19 Jun 2014 10:05:11 +0200
Subject: [PATCH 1/2] drivers/media/rc/ir-nec-decode : add toggle feature (1/2)

Made the distinction between repeated key presses, and a single long
press. The NEC-protocol does not have a toggle-bit (cfr RC5/RC6), but
has specific repeat-codes.

This patch identifies a repeat code, and skips the scancode calculations
and the rc_keydown() in that case. In the case of a full code, it makes
sure that the rc_keydown() is regarded as a new event by using the
toggle feature.

Signed-off-by: Niels Laukens <niels@dest-unreach.be>
---
 drivers/media/rc/ir-nec-decoder.c | 7 ++++++-
 drivers/media/rc/rc-core-priv.h   | 1 +
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/media/rc/ir-nec-decoder.c b/drivers/media/rc/ir-nec-decoder.c
index 35c42e5..1f2482a 100644
--- a/drivers/media/rc/ir-nec-decoder.c
+++ b/drivers/media/rc/ir-nec-decoder.c
@@ -79,6 +79,7 @@ static int ir_nec_decode(struct rc_dev *dev, struct ir_raw_event ev)
 			break;
 
 		data->count = 0;
+		data->nec_repeat = false;
 		data->state = STATE_HEADER_SPACE;
 		return 0;
 
@@ -93,6 +94,7 @@ static int ir_nec_decode(struct rc_dev *dev, struct ir_raw_event ev)
 			if (!dev->keypressed) {
 				IR_dprintk(1, "Discarding last key repeat: event after key up\n");
 			} else {
+				data->nec_repeat = true;
 				rc_repeat(dev);
 				IR_dprintk(1, "Repeat last key\n");
 				data->state = STATE_TRAILER_PULSE;
@@ -158,6 +160,7 @@ static int ir_nec_decode(struct rc_dev *dev, struct ir_raw_event ev)
 		if (!geq_margin(ev.duration, NEC_TRAILER_SPACE, NEC_UNIT / 2))
 			break;
 
+		if (!data->nec_repeat) {
 		address     = bitrev8((data->bits >> 24) & 0xff);
 		not_address = bitrev8((data->bits >> 16) & 0xff);
 		command	    = bitrev8((data->bits >>  8) & 0xff);
@@ -189,7 +192,9 @@ static int ir_nec_decode(struct rc_dev *dev, struct ir_raw_event ev)
 		if (data->is_nec_x)
 			data->necx_repeat = true;
 
-		rc_keydown(dev, scancode, 0);
+		rc_keydown(dev, scancode, !dev->last_toggle);
+		}
+
 		data->state = STATE_INACTIVE;
 		return 0;
 	}
diff --git a/drivers/media/rc/rc-core-priv.h b/drivers/media/rc/rc-core-priv.h
index da536c9..37f3b74 100644
--- a/drivers/media/rc/rc-core-priv.h
+++ b/drivers/media/rc/rc-core-priv.h
@@ -49,6 +49,7 @@ struct ir_raw_event_ctrl {
 		u32 bits;
 		bool is_nec_x;
 		bool necx_repeat;
+		bool nec_repeat;
 	} nec;
 	struct rc5_dec {
 		int state;
-- 
1.8.5.2 (Apple Git-48)



  reply	other threads:[~2014-06-19  8:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-19  8:24 [PATCH 0/2] drivers/media/rc/ir-nec-decode : add toggle feature Niels Laukens
2014-06-19  8:25 ` Niels Laukens [this message]
2014-06-19  9:05   ` [PATCH 1/2] " David Härdeman
2014-06-19 11:59     ` Niels Laukens
2014-07-26 15:47       ` Mauro Carvalho Chehab
2014-07-26 16:58         ` Niels Laukens
2014-06-19  8:25 ` [PATCH 2/2] drivers/media/rc/ir-nec-decode : add toggle feature (2/2) Niels Laukens

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=53A29E79.2000304@dest-unreach.be \
    --to=niels@dest-unreach.be \
    --cc=a.seppala@gmail.com \
    --cc=david@hardeman.nu \
    --cc=james.hogan@imgtec.com \
    --cc=linux-media@vger.kernel.org \
    --cc=m.chehab@samsung.com \
    /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 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.