Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 192930
b: refs/heads/master
c: 67780d6
h: refs/heads/master
v: v3
  • Loading branch information
Mauro Carvalho Chehab committed May 19, 2010
1 parent b3d9743 commit 9315d29
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 33 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2f16f6315f583964732bc23c873d4024281d763c
refs/heads/master: 67780d6a2347d03b640f22295f8df7f00fbc829f
40 changes: 8 additions & 32 deletions trunk/drivers/media/IR/ir-nec-decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,14 @@

#include <media/ir-core.h>

#define NEC_NBITS 32
#define NEC_UNIT 559979 /* ns */
#define NEC_HEADER_MARK (16 * NEC_UNIT)
#define NEC_HEADER_SPACE (8 * NEC_UNIT)
#define NEC_REPEAT_SPACE (4 * NEC_UNIT)
#define NEC_MARK (NEC_UNIT)
#define NEC_0_SYMBOL (NEC_UNIT)
#define NEC_1_SYMBOL (3 * NEC_UNIT)

/* Start time: 4.5 ms + 560 us of the next pulse */
#define MIN_START_TIME (3900000 + 560000)
#define MAX_START_TIME (5100000 + 560000)

/* Bit 1 time: 2.25ms us */
#define MIN_BIT1_TIME 2050000
#define MAX_BIT1_TIME 2450000

/* Bit 0 time: 1.12ms us */
#define MIN_BIT0_TIME 920000
#define MAX_BIT0_TIME 1320000

/* Total IR code is 110 ms, including the 9 ms for the start pulse */
#define MAX_NEC_TIME 4000000

/* Total IR code is 110 ms, including the 9 ms for the start pulse */
#define MIN_REPEAT_TIME 99000000
#define MAX_REPEAT_TIME 112000000

/* Repeat time: 2.25ms us */
#define MIN_REPEAT_START_TIME 2050000
#define MAX_REPEAT_START_TIME 3000000

#define REPEAT_TIME 240 /* ms */
#define NEC_0_SPACE (NEC_UNIT)
#define NEC_1_SPACE (3 * NEC_UNIT)

/* Used to register nec_decoder clients */
static LIST_HEAD(decoder_list);
Expand Down Expand Up @@ -223,11 +199,11 @@ static int handle_event(struct input_dev *input_dev,
if (last_bit)
goto err;

if ((ev->delta.tv_nsec >= NEC_0_SYMBOL - NEC_UNIT / 2) &&
(ev->delta.tv_nsec < NEC_0_SYMBOL + NEC_UNIT / 2))
if ((ev->delta.tv_nsec >= NEC_0_SPACE - NEC_UNIT / 2) &&
(ev->delta.tv_nsec < NEC_0_SPACE + NEC_UNIT / 2))
bit = 0;
else if ((ev->delta.tv_nsec >= NEC_1_SYMBOL - NEC_UNIT / 2) &&
(ev->delta.tv_nsec < NEC_1_SYMBOL + NEC_UNIT / 2))
else if ((ev->delta.tv_nsec >= NEC_1_SPACE - NEC_UNIT / 2) &&
(ev->delta.tv_nsec < NEC_1_SPACE + NEC_UNIT / 2))
bit = 1;
else {
IR_dprintk(1, "Decode failed at %d-th bit (%s) @%luus\n",
Expand Down Expand Up @@ -256,7 +232,7 @@ static int handle_event(struct input_dev *input_dev,
data->nec_code.not_command |= 1 << (shift - 24);
}
}
if (++data->count == 32) {
if (++data->count == NEC_NBITS) {
u32 scancode;
/*
* Fixme: may need to accept Extended NEC protocol?
Expand Down

0 comments on commit 9315d29

Please sign in to comment.