All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@redhat.com>
To: Linux Media Mailing List <linux-media@vger.kernel.org>
Subject: [PATCH RFC]  ir-rc5-decoder: don't wait for the end space to produce a code
Date: Wed, 20 Oct 2010 15:18:47 -0200	[thread overview]
Message-ID: <4CBF2477.9020008@redhat.com> (raw)

The RC5 decoding is complete at a BIT_END state. there's no reason
to wait for the next space to produce a code.
    
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

diff --git a/drivers/media/IR/ir-rc5-decoder.c b/drivers/media/IR/ir-rc5-decoder.c
index df4770d..4139678 100644
--- a/drivers/media/IR/ir-rc5-decoder.c
+++ b/drivers/media/IR/ir-rc5-decoder.c
@@ -98,9 +98,36 @@ again:
 		if (!is_transition(&ev, &ir_dev->raw->prev_ev))
 			break;
 
-		if (data->count == data->wanted_bits)
+		if (data->count == data->wanted_bits) {
 			data->state = STATE_FINISHED;
-		else if (data->count == CHECK_RC5X_NBITS)
+
+			if (data->wanted_bits == RC5X_NBITS) {
+				/* RC5X */
+				u8 xdata, command, system;
+				xdata    = (data->bits & 0x0003F) >> 0;
+				command  = (data->bits & 0x00FC0) >> 6;
+				system   = (data->bits & 0x1F000) >> 12;
+				toggle   = (data->bits & 0x20000) ? 1 : 0;
+				command += (data->bits & 0x01000) ? 0 : 0x40;
+				scancode = system << 16 | command << 8 | xdata;
+
+				IR_dprintk(1, "RC5X scancode 0x%06x (toggle: %u)\n",
+					   scancode, toggle);
+			} else {
+				/* RC5 */
+				u8 command, system;
+				command  = (data->bits & 0x0003F) >> 0;
+				system   = (data->bits & 0x007C0) >> 6;
+				toggle   = (data->bits & 0x00800) ? 1 : 0;
+				command += (data->bits & 0x01000) ? 0 : 0x40;
+				scancode = system << 8 | command;
+
+				IR_dprintk(1, "RC5 scancode 0x%04x (toggle: %u)\n",
+					   scancode, toggle);
+			}
+
+			ir_keydown(input_dev, scancode, toggle);
+		} else if (data->count == CHECK_RC5X_NBITS)
 			data->state = STATE_CHECK_RC5X;
 		else
 			data->state = STATE_BIT_START;
@@ -124,33 +151,6 @@ again:
 		if (ev.pulse)
 			break;
 
-		if (data->wanted_bits == RC5X_NBITS) {
-			/* RC5X */
-			u8 xdata, command, system;
-			xdata    = (data->bits & 0x0003F) >> 0;
-			command  = (data->bits & 0x00FC0) >> 6;
-			system   = (data->bits & 0x1F000) >> 12;
-			toggle   = (data->bits & 0x20000) ? 1 : 0;
-			command += (data->bits & 0x01000) ? 0 : 0x40;
-			scancode = system << 16 | command << 8 | xdata;
-
-			IR_dprintk(1, "RC5X scancode 0x%06x (toggle: %u)\n",
-				   scancode, toggle);
-
-		} else {
-			/* RC5 */
-			u8 command, system;
-			command  = (data->bits & 0x0003F) >> 0;
-			system   = (data->bits & 0x007C0) >> 6;
-			toggle   = (data->bits & 0x00800) ? 1 : 0;
-			command += (data->bits & 0x01000) ? 0 : 0x40;
-			scancode = system << 8 | command;
-
-			IR_dprintk(1, "RC5 scancode 0x%04x (toggle: %u)\n",
-				   scancode, toggle);
-		}
-
-		ir_keydown(input_dev, scancode, toggle);
 		data->state = STATE_INACTIVE;
 		return 0;
 	}
diff --git a/drivers/media/IR/mceusb.c b/drivers/media/IR/mceusb.c
index 61ccb8f..d779f20 100644
--- a/drivers/media/IR/mceusb.c
+++ b/drivers/media/IR/mceusb.c
@@ -674,6 +674,7 @@ static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len)
 {
 	struct ir_raw_event rawir = { .pulse = false, .duration = 0 };
 	int i, start_index = 0;
+	bool has_events;
 	u8 hdr = MCE_CONTROL_HEADER;
 
 	/* skip meaningless 0xb1 0x60 header bytes on orig receiver */
@@ -698,9 +699,12 @@ static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len)
 			return;
 		}
 
+		has_events = false;
 		for (; (ir->rem > 0) && (i < buf_len); i++) {
 			ir->rem--;
 
+			has_events = true;
+
 			rawir.pulse = ((ir->buf_in[i] & MCE_PULSE_BIT) != 0);
 			rawir.duration = (ir->buf_in[i] & MCE_PULSE_MASK)
 					 * MCE_TIME_UNIT * 1000;
@@ -728,8 +732,10 @@ static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len)
 		if (ir->buf_in[i] == 0x80 || ir->buf_in[i] == 0x9f)
 			ir->rem = 0;
 
-		dev_dbg(ir->dev, "calling ir_raw_event_handle\n");
-		ir_raw_event_handle(ir->idev);
+		if (has_events) {
+			dev_dbg(ir->dev, "calling ir_raw_event_handle\n");
+			ir_raw_event_handle(ir->idev);
+		}
 	}
 }
 
@@ -772,6 +778,7 @@ static void mceusb_dev_recv(struct urb *urb, struct pt_regs *regs)
 
 	case -EPIPE:
 	default:
+		dev_dbg(ir->dev, "Error: urb status = %d\n");
 		break;
 	}
 

             reply	other threads:[~2010-10-20 17:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-20 17:18 Mauro Carvalho Chehab [this message]
2010-10-21 13:46 ` [PATCH RFC] ir-rc5-decoder: don't wait for the end space to produce a code Jarod Wilson
2010-10-21 13:56   ` Mauro Carvalho Chehab
2010-10-23  1:25     ` Maxim Levitsky
2010-10-23  1:39       ` Mauro Carvalho Chehab
2010-10-23  2:02         ` Maxim Levitsky

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=4CBF2477.9020008@redhat.com \
    --to=mchehab@redhat.com \
    --cc=linux-media@vger.kernel.org \
    /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.