aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2014-04-03 19:31:30 -0400
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-07-23 20:50:48 -0400
commit120703f9eb32033f0e39bdc552c0273c8ab45f33 (patch)
tree427e55aad9dcfcb91e99b98d508e6fb407e8f600
parentaf3a4a9bbeb00df3e42e77240b4cdac5479812f9 (diff)
[media] rc-core: document the protocol type
Right now the protocol information is not preserved, rc-core gets handed a scancode but has no idea which protocol it corresponds to. This patch (which required reading through the source/keymap for all drivers, not fun) makes the protocol information explicit which is important documentation and makes it easier to e.g. support multiple protocols with one decoder (think rc5 and rc-streamzap). The information isn't used yet so there should be no functional changes. [m.chehab@samsung.com: rebased, added cxusb and removed bad whitespacing] Signed-off-by: David Härdeman <david@hardeman.nu> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
-rw-r--r--drivers/media/i2c/ir-kbd-i2c.c5
-rw-r--r--drivers/media/pci/bt8xx/bttv-input.c12
-rw-r--r--drivers/media/pci/cx88/cx88-input.c26
-rw-r--r--drivers/media/pci/dm1105/dm1105.c3
-rw-r--r--drivers/media/pci/saa7134/saa7134-input.c6
-rw-r--r--drivers/media/pci/ttpci/budget-ci.c8
-rw-r--r--drivers/media/rc/ati_remote.c4
-rw-r--r--drivers/media/rc/img-ir/img-ir-hw.c10
-rw-r--r--drivers/media/rc/img-ir/img-ir-hw.h3
-rw-r--r--drivers/media/rc/img-ir/img-ir-jvc.c4
-rw-r--r--drivers/media/rc/img-ir/img-ir-nec.c4
-rw-r--r--drivers/media/rc/img-ir/img-ir-sanyo.c4
-rw-r--r--drivers/media/rc/img-ir/img-ir-sharp.c4
-rw-r--r--drivers/media/rc/img-ir/img-ir-sony.c12
-rw-r--r--drivers/media/rc/imon.c5
-rw-r--r--drivers/media/rc/ir-jvc-decoder.c2
-rw-r--r--drivers/media/rc/ir-nec-decoder.c2
-rw-r--r--drivers/media/rc/ir-rc5-decoder.c5
-rw-r--r--drivers/media/rc/ir-rc5-sz-decoder.c2
-rw-r--r--drivers/media/rc/ir-rc6-decoder.c37
-rw-r--r--drivers/media/rc/ir-sanyo-decoder.c2
-rw-r--r--drivers/media/rc/ir-sharp-decoder.c2
-rw-r--r--drivers/media/rc/ir-sony-decoder.c6
-rw-r--r--drivers/media/rc/rc-main.c30
-rw-r--r--drivers/media/usb/dvb-usb-v2/af9015.c18
-rw-r--r--drivers/media/usb/dvb-usb-v2/af9035.c9
-rw-r--r--drivers/media/usb/dvb-usb-v2/anysee.c3
-rw-r--r--drivers/media/usb/dvb-usb-v2/az6007.c25
-rw-r--r--drivers/media/usb/dvb-usb-v2/lmedm04.c9
-rw-r--r--drivers/media/usb/dvb-usb-v2/rtl28xxu.c12
-rw-r--r--drivers/media/usb/dvb-usb/cxusb.c2
-rw-r--r--drivers/media/usb/dvb-usb/dib0700_core.c9
-rw-r--r--drivers/media/usb/dvb-usb/dib0700_devices.c24
-rw-r--r--drivers/media/usb/dvb-usb/dw2102.c7
-rw-r--r--drivers/media/usb/dvb-usb/m920x.c2
-rw-r--r--drivers/media/usb/dvb-usb/pctv452e.c8
-rw-r--r--drivers/media/usb/dvb-usb/ttusb2.c6
-rw-r--r--drivers/media/usb/em28xx/em28xx-input.c98
-rw-r--r--drivers/media/usb/tm6000/tm6000-input.c51
-rw-r--r--include/media/rc-core.h8
40 files changed, 305 insertions, 184 deletions
diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c
index 143cb2b26c46..f9c4233ba96e 100644
--- a/drivers/media/i2c/ir-kbd-i2c.c
+++ b/drivers/media/i2c/ir-kbd-i2c.c
@@ -261,8 +261,9 @@ static int ir_key_poll(struct IR_i2c *ir)
261 } 261 }
262 262
263 if (rc) { 263 if (rc) {
264 dprintk(1, "%s: scancode = 0x%08x\n", __func__, scancode); 264 dprintk(1, "%s: proto = 0x%04x, scancode = 0x%08x\n",
265 rc_keydown(ir->rc, scancode, toggle); 265 __func__, protocol, scancode);
266 rc_keydown(ir->rc, protocol, scancode, toggle);
266 } 267 }
267 return 0; 268 return 0;
268} 269}
diff --git a/drivers/media/pci/bt8xx/bttv-input.c b/drivers/media/pci/bt8xx/bttv-input.c
index e745f5a04a40..67c8d6b2c335 100644
--- a/drivers/media/pci/bt8xx/bttv-input.c
+++ b/drivers/media/pci/bt8xx/bttv-input.c
@@ -73,12 +73,12 @@ static void ir_handle_key(struct bttv *btv)
73 73
74 if ((ir->mask_keydown && (gpio & ir->mask_keydown)) || 74 if ((ir->mask_keydown && (gpio & ir->mask_keydown)) ||
75 (ir->mask_keyup && !(gpio & ir->mask_keyup))) { 75 (ir->mask_keyup && !(gpio & ir->mask_keyup))) {
76 rc_keydown_notimeout(ir->dev, data, 0); 76 rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0);
77 } else { 77 } else {
78 /* HACK: Probably, ir->mask_keydown is missing 78 /* HACK: Probably, ir->mask_keydown is missing
79 for this board */ 79 for this board */
80 if (btv->c.type == BTTV_BOARD_WINFAST2000) 80 if (btv->c.type == BTTV_BOARD_WINFAST2000)
81 rc_keydown_notimeout(ir->dev, data, 0); 81 rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0);
82 82
83 rc_keyup(ir->dev); 83 rc_keyup(ir->dev);
84 } 84 }
@@ -103,7 +103,7 @@ static void ir_enltv_handle_key(struct bttv *btv)
103 gpio, data, 103 gpio, data,
104 (gpio & ir->mask_keyup) ? " up" : "up/down"); 104 (gpio & ir->mask_keyup) ? " up" : "up/down");
105 105
106 rc_keydown_notimeout(ir->dev, data, 0); 106 rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0);
107 if (keyup) 107 if (keyup)
108 rc_keyup(ir->dev); 108 rc_keyup(ir->dev);
109 } else { 109 } else {
@@ -117,7 +117,7 @@ static void ir_enltv_handle_key(struct bttv *btv)
117 if (keyup) 117 if (keyup)
118 rc_keyup(ir->dev); 118 rc_keyup(ir->dev);
119 else 119 else
120 rc_keydown_notimeout(ir->dev, data, 0); 120 rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0);
121 } 121 }
122 122
123 ir->last_gpio = data | keyup; 123 ir->last_gpio = data | keyup;
@@ -241,8 +241,8 @@ static void bttv_rc5_timer_end(unsigned long data)
241 return; 241 return;
242 } 242 }
243 243
244 scancode = system << 8 | command; 244 scancode = RC_SCANCODE_RC5(system, command);
245 rc_keydown(ir->dev, scancode, toggle); 245 rc_keydown(ir->dev, RC_TYPE_RC5, scancode, toggle);
246 dprintk("scancode %x, toggle %x\n", scancode, toggle); 246 dprintk("scancode %x, toggle %x\n", scancode, toggle);
247} 247}
248 248
diff --git a/drivers/media/pci/cx88/cx88-input.c b/drivers/media/pci/cx88/cx88-input.c
index 779fc630327a..9bf48ca619c7 100644
--- a/drivers/media/pci/cx88/cx88-input.c
+++ b/drivers/media/pci/cx88/cx88-input.c
@@ -130,25 +130,41 @@ static void cx88_ir_handle_key(struct cx88_IR *ir)
130 130
131 data = (data << 4) | ((gpio_key & 0xf0) >> 4); 131 data = (data << 4) | ((gpio_key & 0xf0) >> 4);
132 132
133 rc_keydown(ir->dev, data, 0); 133 rc_keydown(ir->dev, RC_TYPE_UNKNOWN, data, 0);
134
135 } else if (ir->core->boardnr == CX88_BOARD_PROLINK_PLAYTVPVR ||
136 ir->core->boardnr == CX88_BOARD_PIXELVIEW_PLAYTV_ULTRA_PRO) {
137 /* bit cleared on keydown, NEC scancode, 0xAAAACC, A = 0x866b */
138 u16 addr;
139 u8 cmd;
140 u32 scancode;
141
142 addr = (data >> 8) & 0xffff;
143 cmd = (data >> 0) & 0x00ff;
144 scancode = RC_SCANCODE_NECX(addr, cmd);
145
146 if (0 == (gpio & ir->mask_keyup))
147 rc_keydown_notimeout(ir->dev, RC_TYPE_NEC, scancode, 0);
148 else
149 rc_keyup(ir->dev);
134 150
135 } else if (ir->mask_keydown) { 151 } else if (ir->mask_keydown) {
136 /* bit set on keydown */ 152 /* bit set on keydown */
137 if (gpio & ir->mask_keydown) 153 if (gpio & ir->mask_keydown)
138 rc_keydown_notimeout(ir->dev, data, 0); 154 rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0);
139 else 155 else
140 rc_keyup(ir->dev); 156 rc_keyup(ir->dev);
141 157
142 } else if (ir->mask_keyup) { 158 } else if (ir->mask_keyup) {
143 /* bit cleared on keydown */ 159 /* bit cleared on keydown */
144 if (0 == (gpio & ir->mask_keyup)) 160 if (0 == (gpio & ir->mask_keyup))
145 rc_keydown_notimeout(ir->dev, data, 0); 161 rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0);
146 else 162 else
147 rc_keyup(ir->dev); 163 rc_keyup(ir->dev);
148 164
149 } else { 165 } else {
150 /* can't distinguish keydown/up :-/ */ 166 /* can't distinguish keydown/up :-/ */
151 rc_keydown_notimeout(ir->dev, data, 0); 167 rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0);
152 rc_keyup(ir->dev); 168 rc_keyup(ir->dev);
153 } 169 }
154} 170}
@@ -329,6 +345,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
329 * 002-T mini RC, provided with newer PV hardware 345 * 002-T mini RC, provided with newer PV hardware
330 */ 346 */
331 ir_codes = RC_MAP_PIXELVIEW_MK12; 347 ir_codes = RC_MAP_PIXELVIEW_MK12;
348 rc_type = RC_BIT_NEC;
332 ir->gpio_addr = MO_GP1_IO; 349 ir->gpio_addr = MO_GP1_IO;
333 ir->mask_keyup = 0x80; 350 ir->mask_keyup = 0x80;
334 ir->polling = 10; /* ms */ 351 ir->polling = 10; /* ms */
@@ -416,7 +433,6 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
416 break; 433 break;
417 case CX88_BOARD_TWINHAN_VP1027_DVBS: 434 case CX88_BOARD_TWINHAN_VP1027_DVBS:
418 ir_codes = RC_MAP_TWINHAN_VP1027_DVBS; 435 ir_codes = RC_MAP_TWINHAN_VP1027_DVBS;
419 rc_type = RC_BIT_NEC;
420 ir->sampling = 0xff00; /* address */ 436 ir->sampling = 0xff00; /* address */
421 break; 437 break;
422 } 438 }
diff --git a/drivers/media/pci/dm1105/dm1105.c b/drivers/media/pci/dm1105/dm1105.c
index e60ac35fc10c..e8826c535ccd 100644
--- a/drivers/media/pci/dm1105/dm1105.c
+++ b/drivers/media/pci/dm1105/dm1105.c
@@ -678,7 +678,8 @@ static void dm1105_emit_key(struct work_struct *work)
678 678
679 data = (ircom >> 8) & 0x7f; 679 data = (ircom >> 8) & 0x7f;
680 680
681 rc_keydown(ir->dev, data, 0); 681 /* FIXME: UNKNOWN because we don't generate a full NEC scancode (yet?) */
682 rc_keydown(ir->dev, RC_TYPE_UNKNOWN, data, 0);
682} 683}
683 684
684/* work handler */ 685/* work handler */
diff --git a/drivers/media/pci/saa7134/saa7134-input.c b/drivers/media/pci/saa7134/saa7134-input.c
index 73670ed7156b..43dd8bda02e1 100644
--- a/drivers/media/pci/saa7134/saa7134-input.c
+++ b/drivers/media/pci/saa7134/saa7134-input.c
@@ -83,14 +83,14 @@ static int build_key(struct saa7134_dev *dev)
83 if (data == ir->mask_keycode) 83 if (data == ir->mask_keycode)
84 rc_keyup(ir->dev); 84 rc_keyup(ir->dev);
85 else 85 else
86 rc_keydown_notimeout(ir->dev, data, 0); 86 rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0);
87 return 0; 87 return 0;
88 } 88 }
89 89
90 if (ir->polling) { 90 if (ir->polling) {
91 if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) || 91 if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) ||
92 (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) { 92 (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) {
93 rc_keydown_notimeout(ir->dev, data, 0); 93 rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0);
94 } else { 94 } else {
95 rc_keyup(ir->dev); 95 rc_keyup(ir->dev);
96 } 96 }
@@ -98,7 +98,7 @@ static int build_key(struct saa7134_dev *dev)
98 else { /* IRQ driven mode - handle key press and release in one go */ 98 else { /* IRQ driven mode - handle key press and release in one go */
99 if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) || 99 if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) ||
100 (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) { 100 (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) {
101 rc_keydown_notimeout(ir->dev, data, 0); 101 rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0);
102 rc_keyup(ir->dev); 102 rc_keyup(ir->dev);
103 } 103 }
104 } 104 }
diff --git a/drivers/media/pci/ttpci/budget-ci.c b/drivers/media/pci/ttpci/budget-ci.c
index 0acf9202103d..41ce7dec60e6 100644
--- a/drivers/media/pci/ttpci/budget-ci.c
+++ b/drivers/media/pci/ttpci/budget-ci.c
@@ -161,14 +161,14 @@ static void msp430_ir_interrupt(unsigned long data)
161 return; 161 return;
162 162
163 if (budget_ci->ir.full_rc5) { 163 if (budget_ci->ir.full_rc5) {
164 rc_keydown(dev, 164 rc_keydown(dev, RC_TYPE_RC5,
165 budget_ci->ir.rc5_device <<8 | budget_ci->ir.ir_key, 165 RC_SCANCODE_RC5(budget_ci->ir.rc5_device, budget_ci->ir.ir_key),
166 (command & 0x20) ? 1 : 0); 166 !!(command & 0x20));
167 return; 167 return;
168 } 168 }
169 169
170 /* FIXME: We should generate complete scancodes for all devices */ 170 /* FIXME: We should generate complete scancodes for all devices */
171 rc_keydown(dev, budget_ci->ir.ir_key, (command & 0x20) ? 1 : 0); 171 rc_keydown(dev, RC_TYPE_UNKNOWN, budget_ci->ir.ir_key, !!(command & 0x20));
172} 172}
173 173
174static int msp430_ir_init(struct budget_ci *budget_ci) 174static int msp430_ir_init(struct budget_ci *budget_ci)
diff --git a/drivers/media/rc/ati_remote.c b/drivers/media/rc/ati_remote.c
index 2df7c5516013..8730b32a067c 100644
--- a/drivers/media/rc/ati_remote.c
+++ b/drivers/media/rc/ati_remote.c
@@ -622,8 +622,8 @@ static void ati_remote_input_report(struct urb *urb)
622 * it would cause ghost repeats which would be a 622 * it would cause ghost repeats which would be a
623 * regression for this driver. 623 * regression for this driver.
624 */ 624 */
625 rc_keydown_notimeout(ati_remote->rdev, scancode, 625 rc_keydown_notimeout(ati_remote->rdev, RC_TYPE_OTHER,
626 data[2]); 626 scancode, data[2]);
627 rc_keyup(ati_remote->rdev); 627 rc_keyup(ati_remote->rdev);
628 } 628 }
629 return; 629 return;
diff --git a/drivers/media/rc/img-ir/img-ir-hw.c b/drivers/media/rc/img-ir/img-ir-hw.c
index 153c0840bf4c..b0ec55f52228 100644
--- a/drivers/media/rc/img-ir/img-ir-hw.c
+++ b/drivers/media/rc/img-ir/img-ir-hw.c
@@ -512,7 +512,7 @@ unlock:
512static int img_ir_set_normal_filter(struct rc_dev *dev, 512static int img_ir_set_normal_filter(struct rc_dev *dev,
513 struct rc_scancode_filter *sc_filter) 513 struct rc_scancode_filter *sc_filter)
514{ 514{
515 return img_ir_set_filter(dev, RC_FILTER_NORMAL, sc_filter); 515 return img_ir_set_filter(dev, RC_FILTER_NORMAL, sc_filter);
516} 516}
517 517
518static int img_ir_set_wakeup_filter(struct rc_dev *dev, 518static int img_ir_set_wakeup_filter(struct rc_dev *dev,
@@ -795,9 +795,11 @@ static void img_ir_handle_data(struct img_ir_priv *priv, u32 len, u64 raw)
795 struct img_ir_priv_hw *hw = &priv->hw; 795 struct img_ir_priv_hw *hw = &priv->hw;
796 const struct img_ir_decoder *dec = hw->decoder; 796 const struct img_ir_decoder *dec = hw->decoder;
797 int ret = IMG_IR_SCANCODE; 797 int ret = IMG_IR_SCANCODE;
798 int scancode; 798 u32 scancode;
799 enum rc_type protocol = RC_TYPE_UNKNOWN;
800
799 if (dec->scancode) 801 if (dec->scancode)
800 ret = dec->scancode(len, raw, &scancode, hw->enabled_protocols); 802 ret = dec->scancode(len, raw, &protocol, &scancode, hw->enabled_protocols);
801 else if (len >= 32) 803 else if (len >= 32)
802 scancode = (u32)raw; 804 scancode = (u32)raw;
803 else if (len < 32) 805 else if (len < 32)
@@ -806,7 +808,7 @@ static void img_ir_handle_data(struct img_ir_priv *priv, u32 len, u64 raw)
806 len, (unsigned long long)raw); 808 len, (unsigned long long)raw);
807 if (ret == IMG_IR_SCANCODE) { 809 if (ret == IMG_IR_SCANCODE) {
808 dev_dbg(priv->dev, "decoded scan code %#x\n", scancode); 810 dev_dbg(priv->dev, "decoded scan code %#x\n", scancode);
809 rc_keydown(hw->rdev, scancode, 0); 811 rc_keydown(hw->rdev, protocol, scancode, 0);
810 img_ir_end_repeat(priv); 812 img_ir_end_repeat(priv);
811 } else if (ret == IMG_IR_REPEATCODE) { 813 } else if (ret == IMG_IR_REPEATCODE) {
812 if (hw->mode == IMG_IR_M_REPEATING) { 814 if (hw->mode == IMG_IR_M_REPEATING) {
diff --git a/drivers/media/rc/img-ir/img-ir-hw.h b/drivers/media/rc/img-ir/img-ir-hw.h
index 450f17dfb66a..3e40ce87b898 100644
--- a/drivers/media/rc/img-ir/img-ir-hw.h
+++ b/drivers/media/rc/img-ir/img-ir-hw.h
@@ -162,7 +162,8 @@ struct img_ir_decoder {
162 struct img_ir_control control; 162 struct img_ir_control control;
163 163
164 /* scancode logic */ 164 /* scancode logic */
165 int (*scancode)(int len, u64 raw, int *scancode, u64 protocols); 165 int (*scancode)(int len, u64 raw, enum rc_type *protocol,
166 u32 *scancode, u64 enabled_protocols);
166 int (*filter)(const struct rc_scancode_filter *in, 167 int (*filter)(const struct rc_scancode_filter *in,
167 struct img_ir_filter *out, u64 protocols); 168 struct img_ir_filter *out, u64 protocols);
168}; 169};
diff --git a/drivers/media/rc/img-ir/img-ir-jvc.c b/drivers/media/rc/img-ir/img-ir-jvc.c
index 85ee90f53242..a60dda8bf706 100644
--- a/drivers/media/rc/img-ir/img-ir-jvc.c
+++ b/drivers/media/rc/img-ir/img-ir-jvc.c
@@ -12,7 +12,8 @@
12#include "img-ir-hw.h" 12#include "img-ir-hw.h"
13 13
14/* Convert JVC data to a scancode */ 14/* Convert JVC data to a scancode */
15static int img_ir_jvc_scancode(int len, u64 raw, int *scancode, u64 protocols) 15static int img_ir_jvc_scancode(int len, u64 raw, enum rc_type *protocol,
16 u32 *scancode, u64 enabled_protocols)
16{ 17{
17 unsigned int cust, data; 18 unsigned int cust, data;
18 19
@@ -22,6 +23,7 @@ static int img_ir_jvc_scancode(int len, u64 raw, int *scancode, u64 protocols)
22 cust = (raw >> 0) & 0xff; 23 cust = (raw >> 0) & 0xff;
23 data = (raw >> 8) & 0xff; 24 data = (raw >> 8) & 0xff;
24 25
26 *protocol = RC_TYPE_JVC;
25 *scancode = cust << 8 | data; 27 *scancode = cust << 8 | data;
26 return IMG_IR_SCANCODE; 28 return IMG_IR_SCANCODE;
27} 29}
diff --git a/drivers/media/rc/img-ir/img-ir-nec.c b/drivers/media/rc/img-ir/img-ir-nec.c
index f7520e25fbdb..739897549b5b 100644
--- a/drivers/media/rc/img-ir/img-ir-nec.c
+++ b/drivers/media/rc/img-ir/img-ir-nec.c
@@ -13,7 +13,8 @@
13#include <linux/bitrev.h> 13#include <linux/bitrev.h>
14 14
15/* Convert NEC data to a scancode */ 15/* Convert NEC data to a scancode */
16static int img_ir_nec_scancode(int len, u64 raw, int *scancode, u64 protocols) 16static int img_ir_nec_scancode(int len, u64 raw, enum rc_type *protocol,
17 u32 *scancode, u64 enabled_protocols)
17{ 18{
18 unsigned int addr, addr_inv, data, data_inv; 19 unsigned int addr, addr_inv, data, data_inv;
19 /* a repeat code has no data */ 20 /* a repeat code has no data */
@@ -45,6 +46,7 @@ static int img_ir_nec_scancode(int len, u64 raw, int *scancode, u64 protocols)
45 *scancode = addr << 8 | 46 *scancode = addr << 8 |
46 data; 47 data;
47 } 48 }
49 *protocol = RC_TYPE_NEC;
48 return IMG_IR_SCANCODE; 50 return IMG_IR_SCANCODE;
49} 51}
50 52
diff --git a/drivers/media/rc/img-ir/img-ir-sanyo.c b/drivers/media/rc/img-ir/img-ir-sanyo.c
index 6755c945bce8..6b0653ecdf5a 100644
--- a/drivers/media/rc/img-ir/img-ir-sanyo.c
+++ b/drivers/media/rc/img-ir/img-ir-sanyo.c
@@ -23,7 +23,8 @@
23#include "img-ir-hw.h" 23#include "img-ir-hw.h"
24 24
25/* Convert Sanyo data to a scancode */ 25/* Convert Sanyo data to a scancode */
26static int img_ir_sanyo_scancode(int len, u64 raw, int *scancode, u64 protocols) 26static int img_ir_sanyo_scancode(int len, u64 raw, enum rc_type *protocol,
27 u32 *scancode, u64 enabled_protocols)
27{ 28{
28 unsigned int addr, addr_inv, data, data_inv; 29 unsigned int addr, addr_inv, data, data_inv;
29 /* a repeat code has no data */ 30 /* a repeat code has no data */
@@ -43,6 +44,7 @@ static int img_ir_sanyo_scancode(int len, u64 raw, int *scancode, u64 protocols)
43 return -EINVAL; 44 return -EINVAL;
44 45
45 /* Normal Sanyo */ 46 /* Normal Sanyo */
47 *protocol = RC_TYPE_SANYO;
46 *scancode = addr << 8 | data; 48 *scancode = addr << 8 | data;
47 return IMG_IR_SCANCODE; 49 return IMG_IR_SCANCODE;
48} 50}
diff --git a/drivers/media/rc/img-ir/img-ir-sharp.c b/drivers/media/rc/img-ir/img-ir-sharp.c
index 5867be088cce..3300a38802ac 100644
--- a/drivers/media/rc/img-ir/img-ir-sharp.c
+++ b/drivers/media/rc/img-ir/img-ir-sharp.c
@@ -12,7 +12,8 @@
12#include "img-ir-hw.h" 12#include "img-ir-hw.h"
13 13
14/* Convert Sharp data to a scancode */ 14/* Convert Sharp data to a scancode */
15static int img_ir_sharp_scancode(int len, u64 raw, int *scancode, u64 protocols) 15static int img_ir_sharp_scancode(int len, u64 raw, enum rc_type *protocol,
16 u32 *scancode, u64 enabled_protocols)
16{ 17{
17 unsigned int addr, cmd, exp, chk; 18 unsigned int addr, cmd, exp, chk;
18 19
@@ -31,6 +32,7 @@ static int img_ir_sharp_scancode(int len, u64 raw, int *scancode, u64 protocols)
31 /* probably the second half of the message */ 32 /* probably the second half of the message */
32 return -EINVAL; 33 return -EINVAL;
33 34
35 *protocol = RC_TYPE_SHARP;
34 *scancode = addr << 8 | cmd; 36 *scancode = addr << 8 | cmd;
35 return IMG_IR_SCANCODE; 37 return IMG_IR_SCANCODE;
36} 38}
diff --git a/drivers/media/rc/img-ir/img-ir-sony.c b/drivers/media/rc/img-ir/img-ir-sony.c
index b9029aecceac..3a0f17b0752c 100644
--- a/drivers/media/rc/img-ir/img-ir-sony.c
+++ b/drivers/media/rc/img-ir/img-ir-sony.c
@@ -12,35 +12,39 @@
12#include "img-ir-hw.h" 12#include "img-ir-hw.h"
13 13
14/* Convert Sony data to a scancode */ 14/* Convert Sony data to a scancode */
15static int img_ir_sony_scancode(int len, u64 raw, int *scancode, u64 protocols) 15static int img_ir_sony_scancode(int len, u64 raw, enum rc_type *protocol,
16 u32 *scancode, u64 enabled_protocols)
16{ 17{
17 unsigned int dev, subdev, func; 18 unsigned int dev, subdev, func;
18 19
19 switch (len) { 20 switch (len) {
20 case 12: 21 case 12:
21 if (!(protocols & RC_BIT_SONY12)) 22 if (!(enabled_protocols & RC_BIT_SONY12))
22 return -EINVAL; 23 return -EINVAL;
23 func = raw & 0x7f; /* first 7 bits */ 24 func = raw & 0x7f; /* first 7 bits */
24 raw >>= 7; 25 raw >>= 7;
25 dev = raw & 0x1f; /* next 5 bits */ 26 dev = raw & 0x1f; /* next 5 bits */
26 subdev = 0; 27 subdev = 0;
28 *protocol = RC_TYPE_SONY12;
27 break; 29 break;
28 case 15: 30 case 15:
29 if (!(protocols & RC_BIT_SONY15)) 31 if (!(enabled_protocols & RC_BIT_SONY15))
30 return -EINVAL; 32 return -EINVAL;
31 func = raw & 0x7f; /* first 7 bits */ 33 func = raw & 0x7f; /* first 7 bits */
32 raw >>= 7; 34 raw >>= 7;
33 dev = raw & 0xff; /* next 8 bits */ 35 dev = raw & 0xff; /* next 8 bits */
34 subdev = 0; 36 subdev = 0;
37 *protocol = RC_TYPE_SONY15;
35 break; 38 break;
36 case 20: 39 case 20:
37 if (!(protocols & RC_BIT_SONY20)) 40 if (!(enabled_protocols & RC_BIT_SONY20))
38 return -EINVAL; 41 return -EINVAL;
39 func = raw & 0x7f; /* first 7 bits */ 42 func = raw & 0x7f; /* first 7 bits */
40 raw >>= 7; 43 raw >>= 7;
41 dev = raw & 0x1f; /* next 5 bits */ 44 dev = raw & 0x1f; /* next 5 bits */
42 raw >>= 5; 45 raw >>= 5;
43 subdev = raw & 0xff; /* next 8 bits */ 46 subdev = raw & 0xff; /* next 8 bits */
47 *protocol = RC_TYPE_SONY20;
44 break; 48 break;
45 default: 49 default:
46 return -EINVAL; 50 return -EINVAL;
diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c
index 6f24e77b1488..eb37f2622364 100644
--- a/drivers/media/rc/imon.c
+++ b/drivers/media/rc/imon.c
@@ -1579,7 +1579,10 @@ static void imon_incoming_packet(struct imon_context *ictx,
1579 if (press_type == 0) 1579 if (press_type == 0)
1580 rc_keyup(ictx->rdev); 1580 rc_keyup(ictx->rdev);
1581 else { 1581 else {
1582 rc_keydown(ictx->rdev, ictx->rc_scancode, ictx->rc_toggle); 1582 if (ictx->rc_type == RC_BIT_RC6_MCE)
1583 rc_keydown(ictx->rdev,
1584 ictx->rc_type == RC_BIT_RC6_MCE ? RC_TYPE_RC6_MCE : RC_TYPE_OTHER,
1585 ictx->rc_scancode, ictx->rc_toggle);
1583 spin_lock_irqsave(&ictx->kc_lock, flags); 1586 spin_lock_irqsave(&ictx->kc_lock, flags);
1584 ictx->last_keycode = ictx->kc; 1587 ictx->last_keycode = ictx->kc;
1585 spin_unlock_irqrestore(&ictx->kc_lock, flags); 1588 spin_unlock_irqrestore(&ictx->kc_lock, flags);
diff --git a/drivers/media/rc/ir-jvc-decoder.c b/drivers/media/rc/ir-jvc-decoder.c
index 4ea62a1dcfda..7b79eca83449 100644
--- a/drivers/media/rc/ir-jvc-decoder.c
+++ b/drivers/media/rc/ir-jvc-decoder.c
@@ -140,7 +140,7 @@ again:
140 scancode = (bitrev8((data->bits >> 8) & 0xff) << 8) | 140 scancode = (bitrev8((data->bits >> 8) & 0xff) << 8) |
141 (bitrev8((data->bits >> 0) & 0xff) << 0); 141 (bitrev8((data->bits >> 0) & 0xff) << 0);
142 IR_dprintk(1, "JVC scancode 0x%04x\n", scancode); 142 IR_dprintk(1, "JVC scancode 0x%04x\n", scancode);
143 rc_keydown(dev, scancode, data->toggle); 143 rc_keydown(dev, RC_TYPE_JVC, scancode, data->toggle);
144 data->first = false; 144 data->first = false;
145 data->old_bits = data->bits; 145 data->old_bits = data->bits;
146 } else if (data->bits == data->old_bits) { 146 } else if (data->bits == data->old_bits) {
diff --git a/drivers/media/rc/ir-nec-decoder.c b/drivers/media/rc/ir-nec-decoder.c
index 35c42e5e270b..c4333d5c0046 100644
--- a/drivers/media/rc/ir-nec-decoder.c
+++ b/drivers/media/rc/ir-nec-decoder.c
@@ -189,7 +189,7 @@ static int ir_nec_decode(struct rc_dev *dev, struct ir_raw_event ev)
189 if (data->is_nec_x) 189 if (data->is_nec_x)
190 data->necx_repeat = true; 190 data->necx_repeat = true;
191 191
192 rc_keydown(dev, scancode, 0); 192 rc_keydown(dev, RC_TYPE_NEC, scancode, 0);
193 data->state = STATE_INACTIVE; 193 data->state = STATE_INACTIVE;
194 return 0; 194 return 0;
195 } 195 }
diff --git a/drivers/media/rc/ir-rc5-decoder.c b/drivers/media/rc/ir-rc5-decoder.c
index 4295d9b250c8..3d38cbce5667 100644
--- a/drivers/media/rc/ir-rc5-decoder.c
+++ b/drivers/media/rc/ir-rc5-decoder.c
@@ -51,6 +51,7 @@ static int ir_rc5_decode(struct rc_dev *dev, struct ir_raw_event ev)
51 struct rc5_dec *data = &dev->raw->rc5; 51 struct rc5_dec *data = &dev->raw->rc5;
52 u8 toggle; 52 u8 toggle;
53 u32 scancode; 53 u32 scancode;
54 enum rc_type protocol;
54 55
55 if (!rc_protocols_enabled(dev, RC_BIT_RC5 | RC_BIT_RC5X)) 56 if (!rc_protocols_enabled(dev, RC_BIT_RC5 | RC_BIT_RC5X))
56 return 0; 57 return 0;
@@ -138,6 +139,7 @@ again:
138 toggle = (data->bits & 0x20000) ? 1 : 0; 139 toggle = (data->bits & 0x20000) ? 1 : 0;
139 command += (data->bits & 0x01000) ? 0 : 0x40; 140 command += (data->bits & 0x01000) ? 0 : 0x40;
140 scancode = system << 16 | command << 8 | xdata; 141 scancode = system << 16 | command << 8 | xdata;
142 protocol = RC_TYPE_RC5X;
141 143
142 IR_dprintk(1, "RC5X scancode 0x%06x (toggle: %u)\n", 144 IR_dprintk(1, "RC5X scancode 0x%06x (toggle: %u)\n",
143 scancode, toggle); 145 scancode, toggle);
@@ -154,12 +156,13 @@ again:
154 toggle = (data->bits & 0x00800) ? 1 : 0; 156 toggle = (data->bits & 0x00800) ? 1 : 0;
155 command += (data->bits & 0x01000) ? 0 : 0x40; 157 command += (data->bits & 0x01000) ? 0 : 0x40;
156 scancode = system << 8 | command; 158 scancode = system << 8 | command;
159 protocol = RC_TYPE_RC5;
157 160
158 IR_dprintk(1, "RC5 scancode 0x%04x (toggle: %u)\n", 161 IR_dprintk(1, "RC5 scancode 0x%04x (toggle: %u)\n",
159 scancode, toggle); 162 scancode, toggle);
160 } 163 }
161 164
162 rc_keydown(dev, scancode, toggle); 165 rc_keydown(dev, protocol, scancode, toggle);
163 data->state = STATE_INACTIVE; 166 data->state = STATE_INACTIVE;
164 return 0; 167 return 0;
165 } 168 }
diff --git a/drivers/media/rc/ir-rc5-sz-decoder.c b/drivers/media/rc/ir-rc5-sz-decoder.c
index dc18b7434db8..85c771112cf5 100644
--- a/drivers/media/rc/ir-rc5-sz-decoder.c
+++ b/drivers/media/rc/ir-rc5-sz-decoder.c
@@ -115,7 +115,7 @@ again:
115 IR_dprintk(1, "RC5-sz scancode 0x%04x (toggle: %u)\n", 115 IR_dprintk(1, "RC5-sz scancode 0x%04x (toggle: %u)\n",
116 scancode, toggle); 116 scancode, toggle);
117 117
118 rc_keydown(dev, scancode, toggle); 118 rc_keydown(dev, RC_TYPE_RC5_SZ, scancode, toggle);
119 data->state = STATE_INACTIVE; 119 data->state = STATE_INACTIVE;
120 return 0; 120 return 0;
121 } 121 }
diff --git a/drivers/media/rc/ir-rc6-decoder.c b/drivers/media/rc/ir-rc6-decoder.c
index cfbd64e3999c..1dc97a7b92a5 100644
--- a/drivers/media/rc/ir-rc6-decoder.c
+++ b/drivers/media/rc/ir-rc6-decoder.c
@@ -88,6 +88,7 @@ static int ir_rc6_decode(struct rc_dev *dev, struct ir_raw_event ev)
88 struct rc6_dec *data = &dev->raw->rc6; 88 struct rc6_dec *data = &dev->raw->rc6;
89 u32 scancode; 89 u32 scancode;
90 u8 toggle; 90 u8 toggle;
91 enum rc_type protocol;
91 92
92 if (!rc_protocols_enabled(dev, RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 | 93 if (!rc_protocols_enabled(dev, RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 |
93 RC_BIT_RC6_6A_24 | RC_BIT_RC6_6A_32 | 94 RC_BIT_RC6_6A_24 | RC_BIT_RC6_6A_32 |
@@ -233,9 +234,11 @@ again:
233 case RC6_MODE_0: 234 case RC6_MODE_0:
234 scancode = data->body; 235 scancode = data->body;
235 toggle = data->toggle; 236 toggle = data->toggle;
237 protocol = RC_TYPE_RC6_0;
236 IR_dprintk(1, "RC6(0) scancode 0x%04x (toggle: %u)\n", 238 IR_dprintk(1, "RC6(0) scancode 0x%04x (toggle: %u)\n",
237 scancode, toggle); 239 scancode, toggle);
238 break; 240 break;
241
239 case RC6_MODE_6A: 242 case RC6_MODE_6A:
240 if (data->count > CHAR_BIT * sizeof data->body) { 243 if (data->count > CHAR_BIT * sizeof data->body) {
241 IR_dprintk(1, "RC6 too many (%u) data bits\n", 244 IR_dprintk(1, "RC6 too many (%u) data bits\n",
@@ -244,23 +247,39 @@ again:
244 } 247 }
245 248
246 scancode = data->body; 249 scancode = data->body;
247 if (data->count == RC6_6A_32_NBITS && 250 switch (data->count) {
248 (scancode & RC6_6A_LCC_MASK) == RC6_6A_MCE_CC) { 251 case 20:
249 /* MCE RC */ 252 protocol = RC_TYPE_RC6_6A_20;
250 toggle = (scancode & RC6_6A_MCE_TOGGLE_MASK) ? 1 : 0; 253 toggle = 0;
251 scancode &= ~RC6_6A_MCE_TOGGLE_MASK; 254 break;
252 } else { 255 case 24:
256 protocol = RC_BIT_RC6_6A_24;
253 toggle = 0; 257 toggle = 0;
258 break;
259 case 32:
260 if ((scancode & RC6_6A_LCC_MASK) == RC6_6A_MCE_CC) {
261 protocol = RC_TYPE_RC6_MCE;
262 scancode &= ~RC6_6A_MCE_TOGGLE_MASK;
263 toggle = !!(scancode & RC6_6A_MCE_TOGGLE_MASK);
264 } else {
265 protocol = RC_BIT_RC6_6A_32;
266 toggle = 0;
267 }
268 break;
269 default:
270 IR_dprintk(1, "RC6(6A) unsupported length\n");
271 goto out;
254 } 272 }
255 IR_dprintk(1, "RC6(6A) scancode 0x%08x (toggle: %u)\n", 273
256 scancode, toggle); 274 IR_dprintk(1, "RC6(6A) proto 0x%04x, scancode 0x%08x (toggle: %u)\n",
275 protocol, scancode, toggle);
257 break; 276 break;
258 default: 277 default:
259 IR_dprintk(1, "RC6 unknown mode\n"); 278 IR_dprintk(1, "RC6 unknown mode\n");
260 goto out; 279 goto out;
261 } 280 }
262 281
263 rc_keydown(dev, scancode, toggle); 282 rc_keydown(dev, protocol, scancode, toggle);
264 data->state = STATE_INACTIVE; 283 data->state = STATE_INACTIVE;
265 return 0; 284 return 0;
266 } 285 }
diff --git a/drivers/media/rc/ir-sanyo-decoder.c b/drivers/media/rc/ir-sanyo-decoder.c
index eb715f04dc27..5f7702261d23 100644
--- a/drivers/media/rc/ir-sanyo-decoder.c
+++ b/drivers/media/rc/ir-sanyo-decoder.c
@@ -167,7 +167,7 @@ static int ir_sanyo_decode(struct rc_dev *dev, struct ir_raw_event ev)
167 167
168 scancode = address << 8 | command; 168 scancode = address << 8 | command;
169 IR_dprintk(1, "SANYO scancode: 0x%06x\n", scancode); 169 IR_dprintk(1, "SANYO scancode: 0x%06x\n", scancode);
170 rc_keydown(dev, scancode, 0); 170 rc_keydown(dev, RC_TYPE_SANYO, scancode, 0);
171 data->state = STATE_INACTIVE; 171 data->state = STATE_INACTIVE;
172 return 0; 172 return 0;
173 } 173 }
diff --git a/drivers/media/rc/ir-sharp-decoder.c b/drivers/media/rc/ir-sharp-decoder.c
index 66d20394ceaa..c8f251939143 100644
--- a/drivers/media/rc/ir-sharp-decoder.c
+++ b/drivers/media/rc/ir-sharp-decoder.c
@@ -162,7 +162,7 @@ static int ir_sharp_decode(struct rc_dev *dev, struct ir_raw_event ev)
162 scancode = address << 8 | command; 162 scancode = address << 8 | command;
163 IR_dprintk(1, "Sharp scancode 0x%04x\n", scancode); 163 IR_dprintk(1, "Sharp scancode 0x%04x\n", scancode);
164 164
165 rc_keydown(dev, scancode, 0); 165 rc_keydown(dev, RC_TYPE_SHARP, scancode, 0);
166 data->state = STATE_INACTIVE; 166 data->state = STATE_INACTIVE;
167 return 0; 167 return 0;
168 } 168 }
diff --git a/drivers/media/rc/ir-sony-decoder.c b/drivers/media/rc/ir-sony-decoder.c
index 599c19a73360..f485f9fe1e90 100644
--- a/drivers/media/rc/ir-sony-decoder.c
+++ b/drivers/media/rc/ir-sony-decoder.c
@@ -42,6 +42,7 @@ enum sony_state {
42static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev) 42static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev)
43{ 43{
44 struct sony_dec *data = &dev->raw->sony; 44 struct sony_dec *data = &dev->raw->sony;
45 enum rc_type protocol;
45 u32 scancode; 46 u32 scancode;
46 u8 device, subdevice, function; 47 u8 device, subdevice, function;
47 48
@@ -131,6 +132,7 @@ static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev)
131 device = bitrev8((data->bits << 3) & 0xF8); 132 device = bitrev8((data->bits << 3) & 0xF8);
132 subdevice = 0; 133 subdevice = 0;
133 function = bitrev8((data->bits >> 4) & 0xFE); 134 function = bitrev8((data->bits >> 4) & 0xFE);
135 protocol = RC_TYPE_SONY12;
134 break; 136 break;
135 case 15: 137 case 15:
136 if (!rc_protocols_enabled(dev, RC_BIT_SONY15)) { 138 if (!rc_protocols_enabled(dev, RC_BIT_SONY15)) {
@@ -140,6 +142,7 @@ static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev)
140 device = bitrev8((data->bits >> 0) & 0xFF); 142 device = bitrev8((data->bits >> 0) & 0xFF);
141 subdevice = 0; 143 subdevice = 0;
142 function = bitrev8((data->bits >> 7) & 0xFE); 144 function = bitrev8((data->bits >> 7) & 0xFE);
145 protocol = RC_TYPE_SONY15;
143 break; 146 break;
144 case 20: 147 case 20:
145 if (!rc_protocols_enabled(dev, RC_BIT_SONY20)) { 148 if (!rc_protocols_enabled(dev, RC_BIT_SONY20)) {
@@ -149,6 +152,7 @@ static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev)
149 device = bitrev8((data->bits >> 5) & 0xF8); 152 device = bitrev8((data->bits >> 5) & 0xF8);
150 subdevice = bitrev8((data->bits >> 0) & 0xFF); 153 subdevice = bitrev8((data->bits >> 0) & 0xFF);
151 function = bitrev8((data->bits >> 12) & 0xFE); 154 function = bitrev8((data->bits >> 12) & 0xFE);
155 protocol = RC_TYPE_SONY20;
152 break; 156 break;
153 default: 157 default:
154 IR_dprintk(1, "Sony invalid bitcount %u\n", data->count); 158 IR_dprintk(1, "Sony invalid bitcount %u\n", data->count);
@@ -157,7 +161,7 @@ static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev)
157 161
158 scancode = device << 16 | subdevice << 8 | function; 162 scancode = device << 16 | subdevice << 8 | function;
159 IR_dprintk(1, "Sony(%u) scancode 0x%05x\n", data->count, scancode); 163 IR_dprintk(1, "Sony(%u) scancode 0x%05x\n", data->count, scancode);
160 rc_keydown(dev, scancode, 0); 164 rc_keydown(dev, protocol, scancode, 0);
161 data->state = STATE_INACTIVE; 165 data->state = STATE_INACTIVE;
162 return 0; 166 return 0;
163 } 167 }
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index 970b93d6f399..9abcf77246fa 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -623,6 +623,7 @@ EXPORT_SYMBOL_GPL(rc_repeat);
623/** 623/**
624 * ir_do_keydown() - internal function to process a keypress 624 * ir_do_keydown() - internal function to process a keypress
625 * @dev: the struct rc_dev descriptor of the device 625 * @dev: the struct rc_dev descriptor of the device
626 * @protocol: the protocol of the keypress
626 * @scancode: the scancode of the keypress 627 * @scancode: the scancode of the keypress
627 * @keycode: the keycode of the keypress 628 * @keycode: the keycode of the keypress
628 * @toggle: the toggle value of the keypress 629 * @toggle: the toggle value of the keypress
@@ -630,12 +631,13 @@ EXPORT_SYMBOL_GPL(rc_repeat);
630 * This function is used internally to register a keypress, it must be 631 * This function is used internally to register a keypress, it must be
631 * called with keylock held. 632 * called with keylock held.
632 */ 633 */
633static void ir_do_keydown(struct rc_dev *dev, int scancode, 634static void ir_do_keydown(struct rc_dev *dev, enum rc_type protocol,
634 u32 keycode, u8 toggle) 635 u32 scancode, u32 keycode, u8 toggle)
635{ 636{
636 bool new_event = (!dev->keypressed || 637 bool new_event = (!dev->keypressed ||
638 dev->last_protocol != protocol ||
637 dev->last_scancode != scancode || 639 dev->last_scancode != scancode ||
638 dev->last_toggle != toggle); 640 dev->last_toggle != toggle);
639 641
640 if (new_event && dev->keypressed) 642 if (new_event && dev->keypressed)
641 ir_do_keyup(dev, false); 643 ir_do_keyup(dev, false);
@@ -645,13 +647,14 @@ static void ir_do_keydown(struct rc_dev *dev, int scancode,
645 if (new_event && keycode != KEY_RESERVED) { 647 if (new_event && keycode != KEY_RESERVED) {
646 /* Register a keypress */ 648 /* Register a keypress */
647 dev->keypressed = true; 649 dev->keypressed = true;
650 dev->last_protocol = protocol;
648 dev->last_scancode = scancode; 651 dev->last_scancode = scancode;
649 dev->last_toggle = toggle; 652 dev->last_toggle = toggle;
650 dev->last_keycode = keycode; 653 dev->last_keycode = keycode;
651 654
652 IR_dprintk(1, "%s: key down event, " 655 IR_dprintk(1, "%s: key down event, "
653 "key 0x%04x, scancode 0x%04x\n", 656 "key 0x%04x, protocol 0x%04x, scancode 0x%08x\n",
654 dev->input_name, keycode, scancode); 657 dev->input_name, keycode, protocol, scancode);
655 input_report_key(dev->input_dev, keycode, 1); 658 input_report_key(dev->input_dev, keycode, 1);
656 659
657 led_trigger_event(led_feedback, LED_FULL); 660 led_trigger_event(led_feedback, LED_FULL);
@@ -663,20 +666,21 @@ static void ir_do_keydown(struct rc_dev *dev, int scancode,
663/** 666/**
664 * rc_keydown() - generates input event for a key press 667 * rc_keydown() - generates input event for a key press
665 * @dev: the struct rc_dev descriptor of the device 668 * @dev: the struct rc_dev descriptor of the device
666 * @scancode: the scancode that we're seeking 669 * @protocol: the protocol for the keypress
670 * @scancode: the scancode for the keypress
667 * @toggle: the toggle value (protocol dependent, if the protocol doesn't 671 * @toggle: the toggle value (protocol dependent, if the protocol doesn't
668 * support toggle values, this should be set to zero) 672 * support toggle values, this should be set to zero)
669 * 673 *
670 * This routine is used to signal that a key has been pressed on the 674 * This routine is used to signal that a key has been pressed on the
671 * remote control. 675 * remote control.
672 */ 676 */
673void rc_keydown(struct rc_dev *dev, int scancode, u8 toggle) 677void rc_keydown(struct rc_dev *dev, enum rc_type protocol, u32 scancode, u8 toggle)
674{ 678{
675 unsigned long flags; 679 unsigned long flags;
676 u32 keycode = rc_g_keycode_from_table(dev, scancode); 680 u32 keycode = rc_g_keycode_from_table(dev, scancode);
677 681
678 spin_lock_irqsave(&dev->keylock, flags); 682 spin_lock_irqsave(&dev->keylock, flags);
679 ir_do_keydown(dev, scancode, keycode, toggle); 683 ir_do_keydown(dev, protocol, scancode, keycode, toggle);
680 684
681 if (dev->keypressed) { 685 if (dev->keypressed) {
682 dev->keyup_jiffies = jiffies + msecs_to_jiffies(IR_KEYPRESS_TIMEOUT); 686 dev->keyup_jiffies = jiffies + msecs_to_jiffies(IR_KEYPRESS_TIMEOUT);
@@ -690,20 +694,22 @@ EXPORT_SYMBOL_GPL(rc_keydown);
690 * rc_keydown_notimeout() - generates input event for a key press without 694 * rc_keydown_notimeout() - generates input event for a key press without
691 * an automatic keyup event at a later time 695 * an automatic keyup event at a later time
692 * @dev: the struct rc_dev descriptor of the device 696 * @dev: the struct rc_dev descriptor of the device
693 * @scancode: the scancode that we're seeking 697 * @protocol: the protocol for the keypress
698 * @scancode: the scancode for the keypress
694 * @toggle: the toggle value (protocol dependent, if the protocol doesn't 699 * @toggle: the toggle value (protocol dependent, if the protocol doesn't
695 * support toggle values, this should be set to zero) 700 * support toggle values, this should be set to zero)
696 * 701 *
697 * This routine is used to signal that a key has been pressed on the 702 * This routine is used to signal that a key has been pressed on the
698 * remote control. The driver must manually call rc_keyup() at a later stage. 703 * remote control. The driver must manually call rc_keyup() at a later stage.
699 */ 704 */
700void rc_keydown_notimeout(struct rc_dev *dev, int scancode, u8 toggle) 705void rc_keydown_notimeout(struct rc_dev *dev, enum rc_type protocol,
706 u32 scancode, u8 toggle)
701{ 707{
702 unsigned long flags; 708 unsigned long flags;
703 u32 keycode = rc_g_keycode_from_table(dev, scancode); 709 u32 keycode = rc_g_keycode_from_table(dev, scancode);
704 710
705 spin_lock_irqsave(&dev->keylock, flags); 711 spin_lock_irqsave(&dev->keylock, flags);
706 ir_do_keydown(dev, scancode, keycode, toggle); 712 ir_do_keydown(dev, protocol, scancode, keycode, toggle);
707 spin_unlock_irqrestore(&dev->keylock, flags); 713 spin_unlock_irqrestore(&dev->keylock, flags);
708} 714}
709EXPORT_SYMBOL_GPL(rc_keydown_notimeout); 715EXPORT_SYMBOL_GPL(rc_keydown_notimeout);
@@ -1315,7 +1321,7 @@ int rc_register_device(struct rc_dev *dev)
1315 dev->dev.groups = dev->sysfs_groups; 1321 dev->dev.groups = dev->sysfs_groups;
1316 dev->sysfs_groups[attr++] = &rc_dev_protocol_attr_grp; 1322 dev->sysfs_groups[attr++] = &rc_dev_protocol_attr_grp;
1317 if (dev->s_filter) 1323 if (dev->s_filter)
1318 dev->sysfs_groups[attr++] = &rc_dev_filter_attr_grp; 1324 dev->sysfs_groups[attr++] = &rc_dev_filter_attr_grp;
1319 if (dev->s_wakeup_filter) 1325 if (dev->s_wakeup_filter)
1320 dev->sysfs_groups[attr++] = &rc_dev_wakeup_filter_attr_grp; 1326 dev->sysfs_groups[attr++] = &rc_dev_wakeup_filter_attr_grp;
1321 if (dev->change_wakeup_protocol) 1327 if (dev->change_wakeup_protocol)
diff --git a/drivers/media/usb/dvb-usb-v2/af9015.c b/drivers/media/usb/dvb-usb-v2/af9015.c
index da47d2392f2a..5ca738ab44e0 100644
--- a/drivers/media/usb/dvb-usb-v2/af9015.c
+++ b/drivers/media/usb/dvb-usb-v2/af9015.c
@@ -1213,7 +1213,7 @@ static int af9015_rc_query(struct dvb_usb_device *d)
1213 if ((state->rc_repeat != buf[6] || buf[0]) && 1213 if ((state->rc_repeat != buf[6] || buf[0]) &&
1214 !memcmp(&buf[12], state->rc_last, 4)) { 1214 !memcmp(&buf[12], state->rc_last, 4)) {
1215 dev_dbg(&d->udev->dev, "%s: key repeated\n", __func__); 1215 dev_dbg(&d->udev->dev, "%s: key repeated\n", __func__);
1216 rc_keydown(d->rc_dev, state->rc_keycode, 0); 1216 rc_repeat(d->rc_dev);
1217 state->rc_repeat = buf[6]; 1217 state->rc_repeat = buf[6];
1218 return ret; 1218 return ret;
1219 } 1219 }
@@ -1233,18 +1233,22 @@ static int af9015_rc_query(struct dvb_usb_device *d)
1233 if (buf[14] == (u8) ~buf[15]) { 1233 if (buf[14] == (u8) ~buf[15]) {
1234 if (buf[12] == (u8) ~buf[13]) { 1234 if (buf[12] == (u8) ~buf[13]) {
1235 /* NEC */ 1235 /* NEC */
1236 state->rc_keycode = buf[12] << 8 | buf[14]; 1236 state->rc_keycode = RC_SCANCODE_NEC(buf[12],
1237 buf[14]);
1237 } else { 1238 } else {
1238 /* NEC extended*/ 1239 /* NEC extended*/
1239 state->rc_keycode = buf[12] << 16 | 1240 state->rc_keycode = RC_SCANCODE_NECX(buf[12] << 8 |
1240 buf[13] << 8 | buf[14]; 1241 buf[13],
1242 buf[14]);
1241 } 1243 }
1242 } else { 1244 } else {
1243 /* 32 bit NEC */ 1245 /* 32 bit NEC */
1244 state->rc_keycode = buf[12] << 24 | buf[13] << 16 | 1246 state->rc_keycode = RC_SCANCODE_NEC32(buf[12] << 24 |
1245 buf[14] << 8 | buf[15]; 1247 buf[13] << 16 |
1248 buf[14] << 8 |
1249 buf[15]);
1246 } 1250 }
1247 rc_keydown(d->rc_dev, state->rc_keycode, 0); 1251 rc_keydown(d->rc_dev, RC_TYPE_NEC, state->rc_keycode, 0);
1248 } else { 1252 } else {
1249 dev_dbg(&d->udev->dev, "%s: no key press\n", __func__); 1253 dev_dbg(&d->udev->dev, "%s: no key press\n", __func__);
1250 /* Invalidate last keypress */ 1254 /* Invalidate last keypress */
diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c
index 7b9b75f60774..221af2b6e6cf 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -1313,19 +1313,20 @@ static int af9035_rc_query(struct dvb_usb_device *d)
1313 if ((buf[2] + buf[3]) == 0xff) { 1313 if ((buf[2] + buf[3]) == 0xff) {
1314 if ((buf[0] + buf[1]) == 0xff) { 1314 if ((buf[0] + buf[1]) == 0xff) {
1315 /* NEC standard 16bit */ 1315 /* NEC standard 16bit */
1316 key = buf[0] << 8 | buf[2]; 1316 key = RC_SCANCODE_NEC(buf[0], buf[2]);
1317 } else { 1317 } else {
1318 /* NEC extended 24bit */ 1318 /* NEC extended 24bit */
1319 key = buf[0] << 16 | buf[1] << 8 | buf[2]; 1319 key = RC_SCANCODE_NECX(buf[0] << 8 | buf[1], buf[2]);
1320 } 1320 }
1321 } else { 1321 } else {
1322 /* NEC full code 32bit */ 1322 /* NEC full code 32bit */
1323 key = buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3]; 1323 key = RC_SCANCODE_NEC32(buf[0] << 24 | buf[1] << 16 |
1324 buf[2] << 8 | buf[3]);
1324 } 1325 }
1325 1326
1326 dev_dbg(&d->udev->dev, "%s: %*ph\n", __func__, 4, buf); 1327 dev_dbg(&d->udev->dev, "%s: %*ph\n", __func__, 4, buf);
1327 1328
1328 rc_keydown(d->rc_dev, key, 0); 1329 rc_keydown(d->rc_dev, RC_TYPE_NEC, key, 0);
1329 1330
1330 return 0; 1331 return 0;
1331 1332
diff --git a/drivers/media/usb/dvb-usb-v2/anysee.c b/drivers/media/usb/dvb-usb-v2/anysee.c
index eeab79bdd2aa..e4a2382196f0 100644
--- a/drivers/media/usb/dvb-usb-v2/anysee.c
+++ b/drivers/media/usb/dvb-usb-v2/anysee.c
@@ -1038,7 +1038,8 @@ static int anysee_rc_query(struct dvb_usb_device *d)
1038 if (ircode[0]) { 1038 if (ircode[0]) {
1039 dev_dbg(&d->udev->dev, "%s: key pressed %02x\n", __func__, 1039 dev_dbg(&d->udev->dev, "%s: key pressed %02x\n", __func__,
1040 ircode[1]); 1040 ircode[1]);
1041 rc_keydown(d->rc_dev, 0x08 << 8 | ircode[1], 0); 1041 rc_keydown(d->rc_dev, RC_TYPE_NEC,
1042 RC_SCANCODE_NEC(0x08, ircode[1]), 0);
1042 } 1043 }
1043 1044
1044 return 0; 1045 return 0;
diff --git a/drivers/media/usb/dvb-usb-v2/az6007.c b/drivers/media/usb/dvb-usb-v2/az6007.c
index c3c4b98733bf..935dbaa80ef0 100644
--- a/drivers/media/usb/dvb-usb-v2/az6007.c
+++ b/drivers/media/usb/dvb-usb-v2/az6007.c
@@ -207,24 +207,27 @@ static int az6007_streaming_ctrl(struct dvb_frontend *fe, int onoff)
207static int az6007_rc_query(struct dvb_usb_device *d) 207static int az6007_rc_query(struct dvb_usb_device *d)
208{ 208{
209 struct az6007_device_state *st = d_to_priv(d); 209 struct az6007_device_state *st = d_to_priv(d);
210 unsigned code = 0; 210 unsigned code;
211 211
212 az6007_read(d, AZ6007_READ_IR, 0, 0, st->data, 10); 212 az6007_read(d, AZ6007_READ_IR, 0, 0, st->data, 10);
213 213
214 if (st->data[1] == 0x44) 214 if (st->data[1] == 0x44)
215 return 0; 215 return 0;
216 216
217 if ((st->data[1] ^ st->data[2]) == 0xff) 217 if ((st->data[3] ^ st->data[4]) == 0xff) {
218 code = st->data[1]; 218 if ((st->data[1] ^ st->data[2]) == 0xff)
219 else 219 code = RC_SCANCODE_NEC(st->data[1], st->data[3]);
220 code = st->data[1] << 8 | st->data[2]; 220 else
221 221 code = RC_SCANCODE_NECX(st->data[1] << 8 | st->data[2],
222 if ((st->data[3] ^ st->data[4]) == 0xff) 222 st->data[3]);
223 code = code << 8 | st->data[3]; 223 } else {
224 else 224 code = RC_SCANCODE_NEC32(st->data[1] << 24 |
225 code = code << 16 | st->data[3] << 8 | st->data[4]; 225 st->data[2] << 16 |
226 st->data[3] << 8 |
227 st->data[4]);
228 }
226 229
227 rc_keydown(d->rc_dev, code, st->data[5]); 230 rc_keydown(d->rc_dev, RC_TYPE_NEC, code, st->data[5]);
228 231
229 return 0; 232 return 0;
230} 233}
diff --git a/drivers/media/usb/dvb-usb-v2/lmedm04.c b/drivers/media/usb/dvb-usb-v2/lmedm04.c
index 7d685bc8c2c0..e332af731187 100644
--- a/drivers/media/usb/dvb-usb-v2/lmedm04.c
+++ b/drivers/media/usb/dvb-usb-v2/lmedm04.c
@@ -286,14 +286,13 @@ static void lme2510_int_response(struct urb *lme_urb)
286 case 0xaa: 286 case 0xaa:
287 debug_data_snipet(1, "INT Remote data snipet", ibuf); 287 debug_data_snipet(1, "INT Remote data snipet", ibuf);
288 if ((ibuf[4] + ibuf[5]) == 0xff) { 288 if ((ibuf[4] + ibuf[5]) == 0xff) {
289 key = ibuf[5]; 289 key = RC_SCANCODE_NECX((ibuf[2] ^ 0xff) << 8 |
290 key += (ibuf[3] > 0) 290 (ibuf[3] > 0) ? (ibuf[3] ^ 0xff) : 0,
291 ? (ibuf[3] ^ 0xff) << 8 : 0; 291 ibuf[5]);
292 key += (ibuf[2] ^ 0xff) << 16;
293 deb_info(1, "INT Key =%08x", key); 292 deb_info(1, "INT Key =%08x", key);
294 if (adap_to_d(adap)->rc_dev != NULL) 293 if (adap_to_d(adap)->rc_dev != NULL)
295 rc_keydown(adap_to_d(adap)->rc_dev, 294 rc_keydown(adap_to_d(adap)->rc_dev,
296 key, 0); 295 RC_TYPE_NEC, key, 0);
297 } 296 }
298 break; 297 break;
299 case 0xbb: 298 case 0xbb:
diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index a676e4452847..57ac62d6fa1f 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -1287,19 +1287,19 @@ static int rtl2831u_rc_query(struct dvb_usb_device *d)
1287 if (buf[2] == (u8) ~buf[3]) { 1287 if (buf[2] == (u8) ~buf[3]) {
1288 if (buf[0] == (u8) ~buf[1]) { 1288 if (buf[0] == (u8) ~buf[1]) {
1289 /* NEC standard (16 bit) */ 1289 /* NEC standard (16 bit) */
1290 rc_code = buf[0] << 8 | buf[2]; 1290 rc_code = RC_SCANCODE_NEC(buf[0], buf[2]);
1291 } else { 1291 } else {
1292 /* NEC extended (24 bit) */ 1292 /* NEC extended (24 bit) */
1293 rc_code = buf[0] << 16 | 1293 rc_code = RC_SCANCODE_NECX(buf[0] << 8 | buf[1],
1294 buf[1] << 8 | buf[2]; 1294 buf[2]);
1295 } 1295 }
1296 } else { 1296 } else {
1297 /* NEC full (32 bit) */ 1297 /* NEC full (32 bit) */
1298 rc_code = buf[0] << 24 | buf[1] << 16 | 1298 rc_code = RC_SCANCODE_NEC32(buf[0] << 24 | buf[1] << 16 |
1299 buf[2] << 8 | buf[3]; 1299 buf[2] << 8 | buf[3]);
1300 } 1300 }
1301 1301
1302 rc_keydown(d->rc_dev, rc_code, 0); 1302 rc_keydown(d->rc_dev, RC_TYPE_NEC, rc_code, 0);
1303 1303
1304 ret = rtl28xx_wr_reg(d, SYS_IRRC_SR, 1); 1304 ret = rtl28xx_wr_reg(d, SYS_IRRC_SR, 1);
1305 if (ret) 1305 if (ret)
diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
index f379f7e1fcb0..16bc579d1404 100644
--- a/drivers/media/usb/dvb-usb/cxusb.c
+++ b/drivers/media/usb/dvb-usb/cxusb.c
@@ -541,7 +541,7 @@ static int cxusb_tt_ct2_4400_rc_query(struct dvb_usb_device *d)
541 rc5_addr = (cmd & 0x07C0) >> 6; /* bits 7-11 for address */ 541 rc5_addr = (cmd & 0x07C0) >> 6; /* bits 7-11 for address */
542 rc5_toggle = (cmd & 0x0800) >> 11; /* bit 12 for toggle */ 542 rc5_toggle = (cmd & 0x0800) >> 11; /* bit 12 for toggle */
543 keycode = (rc5_addr << 8) | rc5_cmd; 543 keycode = (rc5_addr << 8) | rc5_cmd;
544 rc_keydown(d->rc_dev, keycode, rc5_toggle); 544 rc_keydown(d->rc_dev, RC_BIT_RC5, keycode, rc5_toggle);
545 } 545 }
546 546
547 return 0; 547 return 0;
diff --git a/drivers/media/usb/dvb-usb/dib0700_core.c b/drivers/media/usb/dvb-usb/dib0700_core.c
index 38b151f7ceac..50856dbf5496 100644
--- a/drivers/media/usb/dvb-usb/dib0700_core.c
+++ b/drivers/media/usb/dvb-usb/dib0700_core.c
@@ -669,6 +669,7 @@ static void dib0700_rc_urb_completion(struct urb *purb)
669{ 669{
670 struct dvb_usb_device *d = purb->context; 670 struct dvb_usb_device *d = purb->context;
671 struct dib0700_rc_response *poll_reply; 671 struct dib0700_rc_response *poll_reply;
672 enum rc_type protocol;
672 u32 uninitialized_var(keycode); 673 u32 uninitialized_var(keycode);
673 u8 toggle; 674 u8 toggle;
674 675
@@ -702,6 +703,7 @@ static void dib0700_rc_urb_completion(struct urb *purb)
702 703
703 switch (d->props.rc.core.protocol) { 704 switch (d->props.rc.core.protocol) {
704 case RC_BIT_NEC: 705 case RC_BIT_NEC:
706 protocol = RC_TYPE_NEC;
705 toggle = 0; 707 toggle = 0;
706 708
707 /* NEC protocol sends repeat code as 0 0 0 FF */ 709 /* NEC protocol sends repeat code as 0 0 0 FF */
@@ -724,6 +726,7 @@ static void dib0700_rc_urb_completion(struct urb *purb)
724 keycode = RC_SCANCODE_NECX(poll_reply->system << 8 | 726 keycode = RC_SCANCODE_NECX(poll_reply->system << 8 |
725 poll_reply->not_system, 727 poll_reply->not_system,
726 poll_reply->data); 728 poll_reply->data);
729
727 } else { 730 } else {
728 deb_data("NEC normal protocol\n"); 731 deb_data("NEC normal protocol\n");
729 keycode = RC_SCANCODE_NEC(poll_reply->system, 732 keycode = RC_SCANCODE_NEC(poll_reply->system,
@@ -733,9 +736,9 @@ static void dib0700_rc_urb_completion(struct urb *purb)
733 break; 736 break;
734 default: 737 default:
735 deb_data("RC5 protocol\n"); 738 deb_data("RC5 protocol\n");
736 /* RC5 Protocol */ 739 protocol = RC_TYPE_RC5;
737 toggle = poll_reply->report_id; 740 toggle = poll_reply->report_id;
738 keycode = poll_reply->system << 8 | poll_reply->data; 741 keycode = RC_SCANCODE_RC5(poll_reply->system, poll_reply->data);
739 742
740 break; 743 break;
741 } 744 }
@@ -748,7 +751,7 @@ static void dib0700_rc_urb_completion(struct urb *purb)
748 goto resubmit; 751 goto resubmit;
749 } 752 }
750 753
751 rc_keydown(d->rc_dev, keycode, toggle); 754 rc_keydown(d->rc_dev, protocol, keycode, toggle);
752 755
753resubmit: 756resubmit:
754 /* Clean the buffer before we requeue */ 757 /* Clean the buffer before we requeue */
diff --git a/drivers/media/usb/dvb-usb/dib0700_devices.c b/drivers/media/usb/dvb-usb/dib0700_devices.c
index 501947eaacfe..91e5ebb0f2c7 100644
--- a/drivers/media/usb/dvb-usb/dib0700_devices.c
+++ b/drivers/media/usb/dvb-usb/dib0700_devices.c
@@ -512,7 +512,8 @@ static u8 rc_request[] = { REQUEST_POLL_RC, 0 };
512static int dib0700_rc_query_old_firmware(struct dvb_usb_device *d) 512static int dib0700_rc_query_old_firmware(struct dvb_usb_device *d)
513{ 513{
514 u8 key[4]; 514 u8 key[4];
515 u32 keycode; 515 enum rc_type protocol;
516 u32 scancode;
516 u8 toggle; 517 u8 toggle;
517 int i; 518 int i;
518 struct dib0700_state *st = d->priv; 519 struct dib0700_state *st = d->priv;
@@ -539,28 +540,29 @@ static int dib0700_rc_query_old_firmware(struct dvb_usb_device *d)
539 540
540 dib0700_rc_setup(d, NULL); /* reset ir sensor data to prevent false events */ 541 dib0700_rc_setup(d, NULL); /* reset ir sensor data to prevent false events */
541 542
542 d->last_event = 0;
543 switch (d->props.rc.core.protocol) { 543 switch (d->props.rc.core.protocol) {
544 case RC_BIT_NEC: 544 case RC_BIT_NEC:
545 /* NEC protocol sends repeat code as 0 0 0 FF */ 545 /* NEC protocol sends repeat code as 0 0 0 FF */
546 if ((key[3-2] == 0x00) && (key[3-3] == 0x00) && 546 if ((key[3-2] == 0x00) && (key[3-3] == 0x00) &&
547 (key[3] == 0xff)) 547 (key[3] == 0xff)) {
548 keycode = d->last_event; 548 rc_repeat(d->rc_dev);
549 else { 549 return 0;
550 keycode = key[3-2] << 8 | key[3-3];
551 d->last_event = keycode;
552 } 550 }
553 551
554 rc_keydown(d->rc_dev, keycode, 0); 552 protocol = RC_TYPE_NEC;
553 scancode = RC_SCANCODE_NEC(key[3-2], key[3-3]);
554 toggle = 0;
555 break; 555 break;
556
556 default: 557 default:
557 /* RC-5 protocol changes toggle bit on new keypress */ 558 /* RC-5 protocol changes toggle bit on new keypress */
558 keycode = key[3-2] << 8 | key[3-3]; 559 protocol = RC_TYPE_RC5;
560 scancode = RC_SCANCODE_RC5(key[3-2], key[3-3]);
559 toggle = key[3-1]; 561 toggle = key[3-1];
560 rc_keydown(d->rc_dev, keycode, toggle);
561
562 break; 562 break;
563 } 563 }
564
565 rc_keydown(d->rc_dev, protocol, scancode, toggle);
564 return 0; 566 return 0;
565} 567}
566 568
diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
index 7135a3e87b86..2add8c507ec9 100644
--- a/drivers/media/usb/dvb-usb/dw2102.c
+++ b/drivers/media/usb/dvb-usb/dw2102.c
@@ -1490,7 +1490,7 @@ static int dw2102_rc_query(struct dvb_usb_device *d)
1490 if (msg.buf[0] != 0xff) { 1490 if (msg.buf[0] != 0xff) {
1491 deb_rc("%s: rc code: %x, %x\n", 1491 deb_rc("%s: rc code: %x, %x\n",
1492 __func__, key[0], key[1]); 1492 __func__, key[0], key[1]);
1493 rc_keydown(d->rc_dev, key[0], 1); 1493 rc_keydown(d->rc_dev, RC_TYPE_UNKNOWN, key[0], 0);
1494 } 1494 }
1495 } 1495 }
1496 1496
@@ -1511,7 +1511,7 @@ static int prof_rc_query(struct dvb_usb_device *d)
1511 if (msg.buf[0] != 0xff) { 1511 if (msg.buf[0] != 0xff) {
1512 deb_rc("%s: rc code: %x, %x\n", 1512 deb_rc("%s: rc code: %x, %x\n",
1513 __func__, key[0], key[1]); 1513 __func__, key[0], key[1]);
1514 rc_keydown(d->rc_dev, key[0]^0xff, 1); 1514 rc_keydown(d->rc_dev, RC_TYPE_UNKNOWN, key[0]^0xff, 0);
1515 } 1515 }
1516 } 1516 }
1517 1517
@@ -1532,7 +1532,8 @@ static int su3000_rc_query(struct dvb_usb_device *d)
1532 if (msg.buf[0] != 0xff) { 1532 if (msg.buf[0] != 0xff) {
1533 deb_rc("%s: rc code: %x, %x\n", 1533 deb_rc("%s: rc code: %x, %x\n",
1534 __func__, key[0], key[1]); 1534 __func__, key[0], key[1]);
1535 rc_keydown(d->rc_dev, key[1] << 8 | key[0], 1); 1535 rc_keydown(d->rc_dev, RC_TYPE_RC5,
1536 RC_SCANCODE_RC5(key[1], key[0]), 0);
1536 } 1537 }
1537 } 1538 }
1538 1539
diff --git a/drivers/media/usb/dvb-usb/m920x.c b/drivers/media/usb/dvb-usb/m920x.c
index 0306cb778df4..abf8ab2e02e5 100644
--- a/drivers/media/usb/dvb-usb/m920x.c
+++ b/drivers/media/usb/dvb-usb/m920x.c
@@ -245,7 +245,7 @@ static int m920x_rc_core_query(struct dvb_usb_device *d)
245 else if (state == REMOTE_KEY_REPEAT) 245 else if (state == REMOTE_KEY_REPEAT)
246 rc_repeat(d->rc_dev); 246 rc_repeat(d->rc_dev);
247 else 247 else
248 rc_keydown(d->rc_dev, rc_state[1], 0); 248 rc_keydown(d->rc_dev, RC_TYPE_UNKNOWN, rc_state[1], 0);
249 249
250out: 250out:
251 kfree(rc_state); 251 kfree(rc_state);
diff --git a/drivers/media/usb/dvb-usb/pctv452e.c b/drivers/media/usb/dvb-usb/pctv452e.c
index 449a99605a87..bdfe8963591c 100644
--- a/drivers/media/usb/dvb-usb/pctv452e.c
+++ b/drivers/media/usb/dvb-usb/pctv452e.c
@@ -565,12 +565,12 @@ static int pctv452e_rc_query(struct dvb_usb_device *d)
565 565
566 if ((rx[3] == 9) && (rx[12] & 0x01)) { 566 if ((rx[3] == 9) && (rx[12] & 0x01)) {
567 /* got a "press" event */ 567 /* got a "press" event */
568 state->last_rc_key = (rx[7] << 8) | rx[6]; 568 state->last_rc_key = RC_SCANCODE_RC5(rx[7], rx[6]);
569 if (debug > 2) 569 if (debug > 2)
570 info("%s: cmd=0x%02x sys=0x%02x\n", 570 info("%s: cmd=0x%02x sys=0x%02x\n",
571 __func__, rx[6], rx[7]); 571 __func__, rx[6], rx[7]);
572 572
573 rc_keydown(d->rc_dev, state->last_rc_key, 0); 573 rc_keydown(d->rc_dev, RC_TYPE_RC5, state->last_rc_key, 0);
574 } else if (state->last_rc_key) { 574 } else if (state->last_rc_key) {
575 rc_keyup(d->rc_dev); 575 rc_keyup(d->rc_dev);
576 state->last_rc_key = 0; 576 state->last_rc_key = 0;
@@ -927,7 +927,7 @@ static struct dvb_usb_device_properties pctv452e_properties = {
927 927
928 .rc.core = { 928 .rc.core = {
929 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 929 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
930 .allowed_protos = RC_BIT_UNKNOWN, 930 .allowed_protos = RC_BIT_RC5,
931 .rc_query = pctv452e_rc_query, 931 .rc_query = pctv452e_rc_query,
932 .rc_interval = 100, 932 .rc_interval = 100,
933 }, 933 },
@@ -980,7 +980,7 @@ static struct dvb_usb_device_properties tt_connect_s2_3600_properties = {
980 980
981 .rc.core = { 981 .rc.core = {
982 .rc_codes = RC_MAP_TT_1500, 982 .rc_codes = RC_MAP_TT_1500,
983 .allowed_protos = RC_BIT_UNKNOWN, 983 .allowed_protos = RC_BIT_RC5,
984 .rc_query = pctv452e_rc_query, 984 .rc_query = pctv452e_rc_query,
985 .rc_interval = 100, 985 .rc_interval = 100,
986 }, 986 },
diff --git a/drivers/media/usb/dvb-usb/ttusb2.c b/drivers/media/usb/dvb-usb/ttusb2.c
index 2ce3d19c58ef..f10717311e05 100644
--- a/drivers/media/usb/dvb-usb/ttusb2.c
+++ b/drivers/media/usb/dvb-usb/ttusb2.c
@@ -438,9 +438,9 @@ static int tt3650_rc_query(struct dvb_usb_device *d)
438 438
439 if (rx[8] & 0x01) { 439 if (rx[8] & 0x01) {
440 /* got a "press" event */ 440 /* got a "press" event */
441 st->last_rc_key = (rx[3] << 8) | rx[2]; 441 st->last_rc_key = RC_SCANCODE_RC5(rx[3], rx[2]);
442 deb_info("%s: cmd=0x%02x sys=0x%02x\n", __func__, rx[2], rx[3]); 442 deb_info("%s: cmd=0x%02x sys=0x%02x\n", __func__, rx[2], rx[3]);
443 rc_keydown(d->rc_dev, st->last_rc_key, rx[1]); 443 rc_keydown(d->rc_dev, RC_TYPE_RC5, st->last_rc_key, rx[1]);
444 } else if (st->last_rc_key) { 444 } else if (st->last_rc_key) {
445 rc_keyup(d->rc_dev); 445 rc_keyup(d->rc_dev);
446 st->last_rc_key = 0; 446 st->last_rc_key = 0;
@@ -747,7 +747,7 @@ static struct dvb_usb_device_properties ttusb2_properties_ct3650 = {
747 .rc_interval = 150, /* Less than IR_KEYPRESS_TIMEOUT */ 747 .rc_interval = 150, /* Less than IR_KEYPRESS_TIMEOUT */
748 .rc_codes = RC_MAP_TT_1500, 748 .rc_codes = RC_MAP_TT_1500,
749 .rc_query = tt3650_rc_query, 749 .rc_query = tt3650_rc_query,
750 .allowed_protos = RC_BIT_UNKNOWN, 750 .allowed_protos = RC_BIT_RC5,
751 }, 751 },
752 752
753 .num_adapters = 1, 753 .num_adapters = 1,
diff --git a/drivers/media/usb/em28xx/em28xx-input.c b/drivers/media/usb/em28xx/em28xx-input.c
index 56ef49df4f8d..7f06ae59eca6 100644
--- a/drivers/media/usb/em28xx/em28xx-input.c
+++ b/drivers/media/usb/em28xx/em28xx-input.c
@@ -27,6 +27,7 @@
27#include <linux/interrupt.h> 27#include <linux/interrupt.h>
28#include <linux/usb.h> 28#include <linux/usb.h>
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/bitrev.h>
30 31
31#include "em28xx.h" 32#include "em28xx.h"
32 33
@@ -53,6 +54,7 @@ struct em28xx_ir_poll_result {
53 unsigned int toggle_bit:1; 54 unsigned int toggle_bit:1;
54 unsigned int read_count:7; 55 unsigned int read_count:7;
55 56
57 enum rc_type protocol;
56 u32 scancode; 58 u32 scancode;
57}; 59};
58 60
@@ -72,7 +74,7 @@ struct em28xx_IR {
72 /* i2c slave address of external device (if used) */ 74 /* i2c slave address of external device (if used) */
73 u16 i2c_dev_addr; 75 u16 i2c_dev_addr;
74 76
75 int (*get_key_i2c)(struct i2c_client *, u32 *); 77 int (*get_key_i2c)(struct i2c_client *ir, enum rc_type *protocol, u32 *scancode);
76 int (*get_key)(struct em28xx_IR *, struct em28xx_ir_poll_result *); 78 int (*get_key)(struct em28xx_IR *, struct em28xx_ir_poll_result *);
77}; 79};
78 80
@@ -80,7 +82,8 @@ struct em28xx_IR {
80 I2C IR based get keycodes - should be used with ir-kbd-i2c 82 I2C IR based get keycodes - should be used with ir-kbd-i2c
81 **********************************************************/ 83 **********************************************************/
82 84
83static int em28xx_get_key_terratec(struct i2c_client *i2c_dev, u32 *ir_key) 85static int em28xx_get_key_terratec(struct i2c_client *i2c_dev,
86 enum rc_type *protocol, u32 *scancode)
84{ 87{
85 unsigned char b; 88 unsigned char b;
86 89
@@ -98,14 +101,15 @@ static int em28xx_get_key_terratec(struct i2c_client *i2c_dev, u32 *ir_key)
98 /* keep old data */ 101 /* keep old data */
99 return 1; 102 return 1;
100 103
101 *ir_key = b; 104 *protocol = RC_TYPE_UNKNOWN;
105 *scancode = b;
102 return 1; 106 return 1;
103} 107}
104 108
105static int em28xx_get_key_em_haup(struct i2c_client *i2c_dev, u32 *ir_key) 109static int em28xx_get_key_em_haup(struct i2c_client *i2c_dev,
110 enum rc_type *protocol, u32 *scancode)
106{ 111{
107 unsigned char buf[2]; 112 unsigned char buf[2];
108 u16 code;
109 int size; 113 int size;
110 114
111 /* poll IR chip */ 115 /* poll IR chip */
@@ -127,26 +131,13 @@ static int em28xx_get_key_em_haup(struct i2c_client *i2c_dev, u32 *ir_key)
127 * So, the code translation is not complete. Yet, it is enough to 131 * So, the code translation is not complete. Yet, it is enough to
128 * work with the provided RC5 IR. 132 * work with the provided RC5 IR.
129 */ 133 */
130 code = 134 *protocol = RC_TYPE_RC5;
131 ((buf[0] & 0x01) ? 0x0020 : 0) | /* 0010 0000 */ 135 *scancode = (bitrev8(buf[1]) & 0x1f) << 8 | bitrev8(buf[0]) >> 2;
132 ((buf[0] & 0x02) ? 0x0010 : 0) | /* 0001 0000 */
133 ((buf[0] & 0x04) ? 0x0008 : 0) | /* 0000 1000 */
134 ((buf[0] & 0x08) ? 0x0004 : 0) | /* 0000 0100 */
135 ((buf[0] & 0x10) ? 0x0002 : 0) | /* 0000 0010 */
136 ((buf[0] & 0x20) ? 0x0001 : 0) | /* 0000 0001 */
137 ((buf[1] & 0x08) ? 0x1000 : 0) | /* 0001 0000 */
138 ((buf[1] & 0x10) ? 0x0800 : 0) | /* 0000 1000 */
139 ((buf[1] & 0x20) ? 0x0400 : 0) | /* 0000 0100 */
140 ((buf[1] & 0x40) ? 0x0200 : 0) | /* 0000 0010 */
141 ((buf[1] & 0x80) ? 0x0100 : 0); /* 0000 0001 */
142
143 /* return key */
144 *ir_key = code;
145 return 1; 136 return 1;
146} 137}
147 138
148static int em28xx_get_key_pinnacle_usb_grey(struct i2c_client *i2c_dev, 139static int em28xx_get_key_pinnacle_usb_grey(struct i2c_client *i2c_dev,
149 u32 *ir_key) 140 enum rc_type *protocol, u32 *scancode)
150{ 141{
151 unsigned char buf[3]; 142 unsigned char buf[3];
152 143
@@ -158,13 +149,13 @@ static int em28xx_get_key_pinnacle_usb_grey(struct i2c_client *i2c_dev,
158 if (buf[0] != 0x00) 149 if (buf[0] != 0x00)
159 return 0; 150 return 0;
160 151
161 *ir_key = buf[2]&0x3f; 152 *protocol = RC_TYPE_UNKNOWN;
162 153 *scancode = buf[2] & 0x3f;
163 return 1; 154 return 1;
164} 155}
165 156
166static int em28xx_get_key_winfast_usbii_deluxe(struct i2c_client *i2c_dev, 157static int em28xx_get_key_winfast_usbii_deluxe(struct i2c_client *i2c_dev,
167 u32 *ir_key) 158 enum rc_type *protocol, u32 *scancode)
168{ 159{
169 unsigned char subaddr, keydetect, key; 160 unsigned char subaddr, keydetect, key;
170 161
@@ -184,7 +175,8 @@ static int em28xx_get_key_winfast_usbii_deluxe(struct i2c_client *i2c_dev,
184 if (key == 0x00) 175 if (key == 0x00)
185 return 0; 176 return 0;
186 177
187 *ir_key = key; 178 *protocol = RC_TYPE_UNKNOWN;
179 *scancode = key;
188 return 1; 180 return 1;
189} 181}
190 182
@@ -215,7 +207,22 @@ static int default_polling_getkey(struct em28xx_IR *ir,
215 poll_result->read_count = (msg[0] & 0x7f); 207 poll_result->read_count = (msg[0] & 0x7f);
216 208
217 /* Remote Control Address/Data (Regs 0x46/0x47) */ 209 /* Remote Control Address/Data (Regs 0x46/0x47) */
218 poll_result->scancode = msg[1] << 8 | msg[2]; 210 switch (ir->rc_type) {
211 case RC_BIT_RC5:
212 poll_result->protocol = RC_TYPE_RC5;
213 poll_result->scancode = RC_SCANCODE_RC5(msg[1], msg[2]);
214 break;
215
216 case RC_BIT_NEC:
217 poll_result->protocol = RC_TYPE_NEC;
218 poll_result->scancode = RC_SCANCODE_NEC(msg[1], msg[2]);
219 break;
220
221 default:
222 poll_result->protocol = RC_TYPE_UNKNOWN;
223 poll_result->scancode = msg[1] << 8 | msg[2];
224 break;
225 }
219 226
220 return 0; 227 return 0;
221} 228}
@@ -247,25 +254,32 @@ static int em2874_polling_getkey(struct em28xx_IR *ir,
247 */ 254 */
248 switch (ir->rc_type) { 255 switch (ir->rc_type) {
249 case RC_BIT_RC5: 256 case RC_BIT_RC5:
250 poll_result->scancode = msg[1] << 8 | msg[2]; 257 poll_result->protocol = RC_TYPE_RC5;
258 poll_result->scancode = RC_SCANCODE_RC5(msg[1], msg[2]);
251 break; 259 break;
260
252 case RC_BIT_NEC: 261 case RC_BIT_NEC:
262 poll_result->protocol = RC_TYPE_RC5;
263 poll_result->scancode = msg[1] << 8 | msg[2];
253 if ((msg[3] ^ msg[4]) != 0xff) /* 32 bits NEC */ 264 if ((msg[3] ^ msg[4]) != 0xff) /* 32 bits NEC */
254 poll_result->scancode = (msg[1] << 24) | 265 poll_result->scancode = RC_SCANCODE_NEC32((msg[1] << 24) |
255 (msg[2] << 16) | 266 (msg[2] << 16) |
256 (msg[3] << 8) | 267 (msg[3] << 8) |
257 msg[4]; 268 (msg[4]));
258 else if ((msg[1] ^ msg[2]) != 0xff) /* 24 bits NEC */ 269 else if ((msg[1] ^ msg[2]) != 0xff) /* 24 bits NEC */
259 poll_result->scancode = (msg[1] << 16) | 270 poll_result->scancode = RC_SCANCODE_NECX(msg[1] << 8 |
260 (msg[2] << 8) | 271 msg[2], msg[3]);
261 msg[3];
262 else /* Normal NEC */ 272 else /* Normal NEC */
263 poll_result->scancode = msg[1] << 8 | msg[3]; 273 poll_result->scancode = RC_SCANCODE_NEC(msg[1], msg[3]);
264 break; 274 break;
275
265 case RC_BIT_RC6_0: 276 case RC_BIT_RC6_0:
266 poll_result->scancode = msg[1] << 8 | msg[2]; 277 poll_result->protocol = RC_TYPE_RC6_0;
278 poll_result->scancode = RC_SCANCODE_RC6_0(msg[1], msg[2]);
267 break; 279 break;
280
268 default: 281 default:
282 poll_result->protocol = RC_TYPE_UNKNOWN;
269 poll_result->scancode = (msg[1] << 24) | (msg[2] << 16) | 283 poll_result->scancode = (msg[1] << 24) | (msg[2] << 16) |
270 (msg[3] << 8) | msg[4]; 284 (msg[3] << 8) | msg[4];
271 break; 285 break;
@@ -281,22 +295,24 @@ static int em2874_polling_getkey(struct em28xx_IR *ir,
281static int em28xx_i2c_ir_handle_key(struct em28xx_IR *ir) 295static int em28xx_i2c_ir_handle_key(struct em28xx_IR *ir)
282{ 296{
283 struct em28xx *dev = ir->dev; 297 struct em28xx *dev = ir->dev;
284 static u32 ir_key; 298 static u32 scancode;
299 enum rc_type protocol;
285 int rc; 300 int rc;
286 struct i2c_client client; 301 struct i2c_client client;
287 302
288 client.adapter = &ir->dev->i2c_adap[dev->def_i2c_bus]; 303 client.adapter = &ir->dev->i2c_adap[dev->def_i2c_bus];
289 client.addr = ir->i2c_dev_addr; 304 client.addr = ir->i2c_dev_addr;
290 305
291 rc = ir->get_key_i2c(&client, &ir_key); 306 rc = ir->get_key_i2c(&client, &protocol, &scancode);
292 if (rc < 0) { 307 if (rc < 0) {
293 dprintk("ir->get_key_i2c() failed: %d\n", rc); 308 dprintk("ir->get_key_i2c() failed: %d\n", rc);
294 return rc; 309 return rc;
295 } 310 }
296 311
297 if (rc) { 312 if (rc) {
298 dprintk("%s: keycode = 0x%04x\n", __func__, ir_key); 313 dprintk("%s: proto = 0x%04x, scancode = 0x%04x\n",
299 rc_keydown(ir->rc, ir_key, 0); 314 __func__, protocol, scancode);
315 rc_keydown(ir->rc, protocol, scancode, 0);
300 } 316 }
301 return 0; 317 return 0;
302} 318}
@@ -319,10 +335,12 @@ static void em28xx_ir_handle_key(struct em28xx_IR *ir)
319 poll_result.scancode); 335 poll_result.scancode);
320 if (ir->full_code) 336 if (ir->full_code)
321 rc_keydown(ir->rc, 337 rc_keydown(ir->rc,
338 poll_result.protocol,
322 poll_result.scancode, 339 poll_result.scancode,
323 poll_result.toggle_bit); 340 poll_result.toggle_bit);
324 else 341 else
325 rc_keydown(ir->rc, 342 rc_keydown(ir->rc,
343 RC_TYPE_UNKNOWN,
326 poll_result.scancode & 0xff, 344 poll_result.scancode & 0xff,
327 poll_result.toggle_bit); 345 poll_result.toggle_bit);
328 346
diff --git a/drivers/media/usb/tm6000/tm6000-input.c b/drivers/media/usb/tm6000/tm6000-input.c
index d1af5438c168..676c0232060e 100644
--- a/drivers/media/usb/tm6000/tm6000-input.c
+++ b/drivers/media/usb/tm6000/tm6000-input.c
@@ -162,11 +162,42 @@ static int tm6000_ir_config(struct tm6000_IR *ir)
162 return 0; 162 return 0;
163} 163}
164 164
165static void tm6000_ir_keydown(struct tm6000_IR *ir,
166 const char *buf, unsigned int len)
167{
168 u8 device, command;
169 u32 scancode;
170 enum rc_type protocol;
171
172 if (len < 1)
173 return;
174
175 command = buf[0];
176 device = (len > 1 ? buf[1] : 0x0);
177 switch (ir->rc_type) {
178 case RC_BIT_RC5:
179 protocol = RC_TYPE_RC5;
180 scancode = RC_SCANCODE_RC5(device, command);
181 break;
182 case RC_BIT_NEC:
183 protocol = RC_TYPE_NEC;
184 scancode = RC_SCANCODE_NEC(device, command);
185 break;
186 default:
187 protocol = RC_TYPE_OTHER;
188 scancode = RC_SCANCODE_OTHER(device << 8 | command);
189 break;
190 }
191
192 dprintk(1, "%s, protocol: 0x%04x, scancode: 0x%08x\n",
193 __func__, protocol, scancode);
194 rc_keydown(ir->rc, protocol, scancode, 0);
195}
196
165static void tm6000_ir_urb_received(struct urb *urb) 197static void tm6000_ir_urb_received(struct urb *urb)
166{ 198{
167 struct tm6000_core *dev = urb->context; 199 struct tm6000_core *dev = urb->context;
168 struct tm6000_IR *ir = dev->ir; 200 struct tm6000_IR *ir = dev->ir;
169 struct tm6000_ir_poll_result poll_result;
170 char *buf; 201 char *buf;
171 202
172 dprintk(2, "%s\n",__func__); 203 dprintk(2, "%s\n",__func__);
@@ -184,12 +215,7 @@ static void tm6000_ir_urb_received(struct urb *urb)
184 DUMP_PREFIX_OFFSET,16, 1, 215 DUMP_PREFIX_OFFSET,16, 1,
185 buf, urb->actual_length, false); 216 buf, urb->actual_length, false);
186 217
187 poll_result.rc_data = buf[0]; 218 tm6000_ir_keydown(ir, urb->transfer_buffer, urb->actual_length);
188 if (urb->actual_length > 1)
189 poll_result.rc_data |= buf[1] << 8;
190
191 dprintk(1, "%s, scancode: 0x%04x\n",__func__, poll_result.rc_data);
192 rc_keydown(ir->rc, poll_result.rc_data, 0);
193 219
194 usb_submit_urb(urb, GFP_ATOMIC); 220 usb_submit_urb(urb, GFP_ATOMIC);
195 /* 221 /*
@@ -204,7 +230,6 @@ static void tm6000_ir_handle_key(struct work_struct *work)
204{ 230{
205 struct tm6000_IR *ir = container_of(work, struct tm6000_IR, work.work); 231 struct tm6000_IR *ir = container_of(work, struct tm6000_IR, work.work);
206 struct tm6000_core *dev = ir->dev; 232 struct tm6000_core *dev = ir->dev;
207 struct tm6000_ir_poll_result poll_result;
208 int rc; 233 int rc;
209 u8 buf[2]; 234 u8 buf[2];
210 235
@@ -219,13 +244,8 @@ static void tm6000_ir_handle_key(struct work_struct *work)
219 if (rc < 0) 244 if (rc < 0)
220 return; 245 return;
221 246
222 if (rc > 1)
223 poll_result.rc_data = buf[0] | buf[1] << 8;
224 else
225 poll_result.rc_data = buf[0];
226
227 /* Check if something was read */ 247 /* Check if something was read */
228 if ((poll_result.rc_data & 0xff) == 0xff) { 248 if ((buf[0] & 0xff) == 0xff) {
229 if (!ir->pwled) { 249 if (!ir->pwled) {
230 tm6000_flash_led(dev, 1); 250 tm6000_flash_led(dev, 1);
231 ir->pwled = 1; 251 ir->pwled = 1;
@@ -233,8 +253,7 @@ static void tm6000_ir_handle_key(struct work_struct *work)
233 return; 253 return;
234 } 254 }
235 255
236 dprintk(1, "%s, scancode: 0x%04x\n",__func__, poll_result.rc_data); 256 tm6000_ir_keydown(ir, buf, rc);
237 rc_keydown(ir->rc, poll_result.rc_data, 0);
238 tm6000_flash_led(dev, 0); 257 tm6000_flash_led(dev, 0);
239 ir->pwled = 0; 258 ir->pwled = 0;
240 259
diff --git a/include/media/rc-core.h b/include/media/rc-core.h
index fde142e5f25a..00811c9e22b0 100644
--- a/include/media/rc-core.h
+++ b/include/media/rc-core.h
@@ -89,6 +89,7 @@ enum rc_filter_type {
89 * @keyup_jiffies: time (in jiffies) when the current keypress should be released 89 * @keyup_jiffies: time (in jiffies) when the current keypress should be released
90 * @timer_keyup: timer for releasing a keypress 90 * @timer_keyup: timer for releasing a keypress
91 * @last_keycode: keycode of last keypress 91 * @last_keycode: keycode of last keypress
92 * @last_protocol: protocol of last keypress
92 * @last_scancode: scancode of last keypress 93 * @last_scancode: scancode of last keypress
93 * @last_toggle: toggle value of last command 94 * @last_toggle: toggle value of last command
94 * @timeout: optional time after which device stops sending data 95 * @timeout: optional time after which device stops sending data
@@ -113,7 +114,7 @@ enum rc_filter_type {
113 * device doesn't interrupt host until it sees IR pulses 114 * device doesn't interrupt host until it sees IR pulses
114 * @s_learning_mode: enable wide band receiver used for learning 115 * @s_learning_mode: enable wide band receiver used for learning
115 * @s_carrier_report: enable carrier reports 116 * @s_carrier_report: enable carrier reports
116 * @s_filter: set the scancode filter 117 * @s_filter: set the scancode filter
117 * @s_wakeup_filter: set the wakeup scancode filter 118 * @s_wakeup_filter: set the wakeup scancode filter
118 */ 119 */
119struct rc_dev { 120struct rc_dev {
@@ -141,6 +142,7 @@ struct rc_dev {
141 unsigned long keyup_jiffies; 142 unsigned long keyup_jiffies;
142 struct timer_list timer_keyup; 143 struct timer_list timer_keyup;
143 u32 last_keycode; 144 u32 last_keycode;
145 enum rc_type last_protocol;
144 u32 last_scancode; 146 u32 last_scancode;
145 u8 last_toggle; 147 u8 last_toggle;
146 u32 timeout; 148 u32 timeout;
@@ -221,8 +223,8 @@ int rc_open(struct rc_dev *rdev);
221void rc_close(struct rc_dev *rdev); 223void rc_close(struct rc_dev *rdev);
222 224
223void rc_repeat(struct rc_dev *dev); 225void rc_repeat(struct rc_dev *dev);
224void rc_keydown(struct rc_dev *dev, int scancode, u8 toggle); 226void rc_keydown(struct rc_dev *dev, enum rc_type protocol, u32 scancode, u8 toggle);
225void rc_keydown_notimeout(struct rc_dev *dev, int scancode, u8 toggle); 227void rc_keydown_notimeout(struct rc_dev *dev, enum rc_type protocol, u32 scancode, u8 toggle);
226void rc_keyup(struct rc_dev *dev); 228void rc_keyup(struct rc_dev *dev);
227u32 rc_g_keycode_from_table(struct rc_dev *dev, u32 scancode); 229u32 rc_g_keycode_from_table(struct rc_dev *dev, u32 scancode);
228 230