Commit 120703f9 authored by David Härdeman's avatar David Härdeman Committed by Mauro Carvalho Chehab

[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: default avatarDavid Härdeman <david@hardeman.nu>
Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent af3a4a9b
...@@ -261,8 +261,9 @@ static int ir_key_poll(struct IR_i2c *ir) ...@@ -261,8 +261,9 @@ static int ir_key_poll(struct IR_i2c *ir)
} }
if (rc) { if (rc) {
dprintk(1, "%s: scancode = 0x%08x\n", __func__, scancode); dprintk(1, "%s: proto = 0x%04x, scancode = 0x%08x\n",
rc_keydown(ir->rc, scancode, toggle); __func__, protocol, scancode);
rc_keydown(ir->rc, protocol, scancode, toggle);
} }
return 0; return 0;
} }
......
...@@ -73,12 +73,12 @@ static void ir_handle_key(struct bttv *btv) ...@@ -73,12 +73,12 @@ static void ir_handle_key(struct bttv *btv)
if ((ir->mask_keydown && (gpio & ir->mask_keydown)) || if ((ir->mask_keydown && (gpio & ir->mask_keydown)) ||
(ir->mask_keyup && !(gpio & ir->mask_keyup))) { (ir->mask_keyup && !(gpio & ir->mask_keyup))) {
rc_keydown_notimeout(ir->dev, data, 0); rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0);
} else { } else {
/* HACK: Probably, ir->mask_keydown is missing /* HACK: Probably, ir->mask_keydown is missing
for this board */ for this board */
if (btv->c.type == BTTV_BOARD_WINFAST2000) if (btv->c.type == BTTV_BOARD_WINFAST2000)
rc_keydown_notimeout(ir->dev, data, 0); rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0);
rc_keyup(ir->dev); rc_keyup(ir->dev);
} }
...@@ -103,7 +103,7 @@ static void ir_enltv_handle_key(struct bttv *btv) ...@@ -103,7 +103,7 @@ static void ir_enltv_handle_key(struct bttv *btv)
gpio, data, gpio, data,
(gpio & ir->mask_keyup) ? " up" : "up/down"); (gpio & ir->mask_keyup) ? " up" : "up/down");
rc_keydown_notimeout(ir->dev, data, 0); rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0);
if (keyup) if (keyup)
rc_keyup(ir->dev); rc_keyup(ir->dev);
} else { } else {
...@@ -117,7 +117,7 @@ static void ir_enltv_handle_key(struct bttv *btv) ...@@ -117,7 +117,7 @@ static void ir_enltv_handle_key(struct bttv *btv)
if (keyup) if (keyup)
rc_keyup(ir->dev); rc_keyup(ir->dev);
else else
rc_keydown_notimeout(ir->dev, data, 0); rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0);
} }
ir->last_gpio = data | keyup; ir->last_gpio = data | keyup;
...@@ -241,8 +241,8 @@ static void bttv_rc5_timer_end(unsigned long data) ...@@ -241,8 +241,8 @@ static void bttv_rc5_timer_end(unsigned long data)
return; return;
} }
scancode = system << 8 | command; scancode = RC_SCANCODE_RC5(system, command);
rc_keydown(ir->dev, scancode, toggle); rc_keydown(ir->dev, RC_TYPE_RC5, scancode, toggle);
dprintk("scancode %x, toggle %x\n", scancode, toggle); dprintk("scancode %x, toggle %x\n", scancode, toggle);
} }
......
...@@ -130,25 +130,41 @@ static void cx88_ir_handle_key(struct cx88_IR *ir) ...@@ -130,25 +130,41 @@ static void cx88_ir_handle_key(struct cx88_IR *ir)
data = (data << 4) | ((gpio_key & 0xf0) >> 4); data = (data << 4) | ((gpio_key & 0xf0) >> 4);
rc_keydown(ir->dev, data, 0); rc_keydown(ir->dev, RC_TYPE_UNKNOWN, data, 0);
} else if (ir->core->boardnr == CX88_BOARD_PROLINK_PLAYTVPVR ||
ir->core->boardnr == CX88_BOARD_PIXELVIEW_PLAYTV_ULTRA_PRO) {
/* bit cleared on keydown, NEC scancode, 0xAAAACC, A = 0x866b */
u16 addr;
u8 cmd;
u32 scancode;
addr = (data >> 8) & 0xffff;
cmd = (data >> 0) & 0x00ff;
scancode = RC_SCANCODE_NECX(addr, cmd);
if (0 == (gpio & ir->mask_keyup))
rc_keydown_notimeout(ir->dev, RC_TYPE_NEC, scancode, 0);
else
rc_keyup(ir->dev);
} else if (ir->mask_keydown) { } else if (ir->mask_keydown) {
/* bit set on keydown */ /* bit set on keydown */
if (gpio & ir->mask_keydown) if (gpio & ir->mask_keydown)
rc_keydown_notimeout(ir->dev, data, 0); rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0);
else else
rc_keyup(ir->dev); rc_keyup(ir->dev);
} else if (ir->mask_keyup) { } else if (ir->mask_keyup) {
/* bit cleared on keydown */ /* bit cleared on keydown */
if (0 == (gpio & ir->mask_keyup)) if (0 == (gpio & ir->mask_keyup))
rc_keydown_notimeout(ir->dev, data, 0); rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0);
else else
rc_keyup(ir->dev); rc_keyup(ir->dev);
} else { } else {
/* can't distinguish keydown/up :-/ */ /* can't distinguish keydown/up :-/ */
rc_keydown_notimeout(ir->dev, data, 0); rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0);
rc_keyup(ir->dev); rc_keyup(ir->dev);
} }
} }
...@@ -329,6 +345,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci) ...@@ -329,6 +345,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
* 002-T mini RC, provided with newer PV hardware * 002-T mini RC, provided with newer PV hardware
*/ */
ir_codes = RC_MAP_PIXELVIEW_MK12; ir_codes = RC_MAP_PIXELVIEW_MK12;
rc_type = RC_BIT_NEC;
ir->gpio_addr = MO_GP1_IO; ir->gpio_addr = MO_GP1_IO;
ir->mask_keyup = 0x80; ir->mask_keyup = 0x80;
ir->polling = 10; /* ms */ ir->polling = 10; /* ms */
...@@ -416,7 +433,6 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci) ...@@ -416,7 +433,6 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
break; break;
case CX88_BOARD_TWINHAN_VP1027_DVBS: case CX88_BOARD_TWINHAN_VP1027_DVBS:
ir_codes = RC_MAP_TWINHAN_VP1027_DVBS; ir_codes = RC_MAP_TWINHAN_VP1027_DVBS;
rc_type = RC_BIT_NEC;
ir->sampling = 0xff00; /* address */ ir->sampling = 0xff00; /* address */
break; break;
} }
......
...@@ -678,7 +678,8 @@ static void dm1105_emit_key(struct work_struct *work) ...@@ -678,7 +678,8 @@ static void dm1105_emit_key(struct work_struct *work)
data = (ircom >> 8) & 0x7f; data = (ircom >> 8) & 0x7f;
rc_keydown(ir->dev, data, 0); /* FIXME: UNKNOWN because we don't generate a full NEC scancode (yet?) */
rc_keydown(ir->dev, RC_TYPE_UNKNOWN, data, 0);
} }
/* work handler */ /* work handler */
......
...@@ -83,14 +83,14 @@ static int build_key(struct saa7134_dev *dev) ...@@ -83,14 +83,14 @@ static int build_key(struct saa7134_dev *dev)
if (data == ir->mask_keycode) if (data == ir->mask_keycode)
rc_keyup(ir->dev); rc_keyup(ir->dev);
else else
rc_keydown_notimeout(ir->dev, data, 0); rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0);
return 0; return 0;
} }
if (ir->polling) { if (ir->polling) {
if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) || if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) ||
(ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) { (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) {
rc_keydown_notimeout(ir->dev, data, 0); rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0);
} else { } else {
rc_keyup(ir->dev); rc_keyup(ir->dev);
} }
...@@ -98,7 +98,7 @@ static int build_key(struct saa7134_dev *dev) ...@@ -98,7 +98,7 @@ static int build_key(struct saa7134_dev *dev)
else { /* IRQ driven mode - handle key press and release in one go */ else { /* IRQ driven mode - handle key press and release in one go */
if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) || if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) ||
(ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) { (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) {
rc_keydown_notimeout(ir->dev, data, 0); rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0);
rc_keyup(ir->dev); rc_keyup(ir->dev);
} }
} }
......
...@@ -161,14 +161,14 @@ static void msp430_ir_interrupt(unsigned long data) ...@@ -161,14 +161,14 @@ static void msp430_ir_interrupt(unsigned long data)
return; return;
if (budget_ci->ir.full_rc5) { if (budget_ci->ir.full_rc5) {
rc_keydown(dev, rc_keydown(dev, RC_TYPE_RC5,
budget_ci->ir.rc5_device <<8 | budget_ci->ir.ir_key, RC_SCANCODE_RC5(budget_ci->ir.rc5_device, budget_ci->ir.ir_key),
(command & 0x20) ? 1 : 0); !!(command & 0x20));
return; return;
} }
/* FIXME: We should generate complete scancodes for all devices */ /* FIXME: We should generate complete scancodes for all devices */
rc_keydown(dev, budget_ci->ir.ir_key, (command & 0x20) ? 1 : 0); rc_keydown(dev, RC_TYPE_UNKNOWN, budget_ci->ir.ir_key, !!(command & 0x20));
} }
static int msp430_ir_init(struct budget_ci *budget_ci) static int msp430_ir_init(struct budget_ci *budget_ci)
......
...@@ -622,8 +622,8 @@ static void ati_remote_input_report(struct urb *urb) ...@@ -622,8 +622,8 @@ static void ati_remote_input_report(struct urb *urb)
* it would cause ghost repeats which would be a * it would cause ghost repeats which would be a
* regression for this driver. * regression for this driver.
*/ */
rc_keydown_notimeout(ati_remote->rdev, scancode, rc_keydown_notimeout(ati_remote->rdev, RC_TYPE_OTHER,
data[2]); scancode, data[2]);
rc_keyup(ati_remote->rdev); rc_keyup(ati_remote->rdev);
} }
return; return;
......
...@@ -795,9 +795,11 @@ static void img_ir_handle_data(struct img_ir_priv *priv, u32 len, u64 raw) ...@@ -795,9 +795,11 @@ static void img_ir_handle_data(struct img_ir_priv *priv, u32 len, u64 raw)
struct img_ir_priv_hw *hw = &priv->hw; struct img_ir_priv_hw *hw = &priv->hw;
const struct img_ir_decoder *dec = hw->decoder; const struct img_ir_decoder *dec = hw->decoder;
int ret = IMG_IR_SCANCODE; int ret = IMG_IR_SCANCODE;
int scancode; u32 scancode;
enum rc_type protocol = RC_TYPE_UNKNOWN;
if (dec->scancode) if (dec->scancode)
ret = dec->scancode(len, raw, &scancode, hw->enabled_protocols); ret = dec->scancode(len, raw, &protocol, &scancode, hw->enabled_protocols);
else if (len >= 32) else if (len >= 32)
scancode = (u32)raw; scancode = (u32)raw;
else if (len < 32) else if (len < 32)
...@@ -806,7 +808,7 @@ static void img_ir_handle_data(struct img_ir_priv *priv, u32 len, u64 raw) ...@@ -806,7 +808,7 @@ static void img_ir_handle_data(struct img_ir_priv *priv, u32 len, u64 raw)
len, (unsigned long long)raw); len, (unsigned long long)raw);
if (ret == IMG_IR_SCANCODE) { if (ret == IMG_IR_SCANCODE) {
dev_dbg(priv->dev, "decoded scan code %#x\n", scancode); dev_dbg(priv->dev, "decoded scan code %#x\n", scancode);
rc_keydown(hw->rdev, scancode, 0); rc_keydown(hw->rdev, protocol, scancode, 0);
img_ir_end_repeat(priv); img_ir_end_repeat(priv);
} else if (ret == IMG_IR_REPEATCODE) { } else if (ret == IMG_IR_REPEATCODE) {
if (hw->mode == IMG_IR_M_REPEATING) { if (hw->mode == IMG_IR_M_REPEATING) {
......
...@@ -162,7 +162,8 @@ struct img_ir_decoder { ...@@ -162,7 +162,8 @@ struct img_ir_decoder {
struct img_ir_control control; struct img_ir_control control;
/* scancode logic */ /* scancode logic */
int (*scancode)(int len, u64 raw, int *scancode, u64 protocols); int (*scancode)(int len, u64 raw, enum rc_type *protocol,
u32 *scancode, u64 enabled_protocols);
int (*filter)(const struct rc_scancode_filter *in, int (*filter)(const struct rc_scancode_filter *in,
struct img_ir_filter *out, u64 protocols); struct img_ir_filter *out, u64 protocols);
}; };
......
...@@ -12,7 +12,8 @@ ...@@ -12,7 +12,8 @@
#include "img-ir-hw.h" #include "img-ir-hw.h"
/* Convert JVC data to a scancode */ /* Convert JVC data to a scancode */
static int img_ir_jvc_scancode(int len, u64 raw, int *scancode, u64 protocols) static int img_ir_jvc_scancode(int len, u64 raw, enum rc_type *protocol,
u32 *scancode, u64 enabled_protocols)
{ {
unsigned int cust, data; unsigned int cust, data;
...@@ -22,6 +23,7 @@ static int img_ir_jvc_scancode(int len, u64 raw, int *scancode, u64 protocols) ...@@ -22,6 +23,7 @@ static int img_ir_jvc_scancode(int len, u64 raw, int *scancode, u64 protocols)
cust = (raw >> 0) & 0xff; cust = (raw >> 0) & 0xff;
data = (raw >> 8) & 0xff; data = (raw >> 8) & 0xff;
*protocol = RC_TYPE_JVC;
*scancode = cust << 8 | data; *scancode = cust << 8 | data;
return IMG_IR_SCANCODE; return IMG_IR_SCANCODE;
} }
......
...@@ -13,7 +13,8 @@ ...@@ -13,7 +13,8 @@
#include <linux/bitrev.h> #include <linux/bitrev.h>
/* Convert NEC data to a scancode */ /* Convert NEC data to a scancode */
static int img_ir_nec_scancode(int len, u64 raw, int *scancode, u64 protocols) static int img_ir_nec_scancode(int len, u64 raw, enum rc_type *protocol,
u32 *scancode, u64 enabled_protocols)
{ {
unsigned int addr, addr_inv, data, data_inv; unsigned int addr, addr_inv, data, data_inv;
/* a repeat code has no data */ /* 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,6 +46,7 @@ static int img_ir_nec_scancode(int len, u64 raw, int *scancode, u64 protocols)
*scancode = addr << 8 | *scancode = addr << 8 |
data; data;
} }
*protocol = RC_TYPE_NEC;
return IMG_IR_SCANCODE; return IMG_IR_SCANCODE;
} }
......
...@@ -23,7 +23,8 @@ ...@@ -23,7 +23,8 @@
#include "img-ir-hw.h" #include "img-ir-hw.h"
/* Convert Sanyo data to a scancode */ /* Convert Sanyo data to a scancode */
static int img_ir_sanyo_scancode(int len, u64 raw, int *scancode, u64 protocols) static int img_ir_sanyo_scancode(int len, u64 raw, enum rc_type *protocol,
u32 *scancode, u64 enabled_protocols)
{ {
unsigned int addr, addr_inv, data, data_inv; unsigned int addr, addr_inv, data, data_inv;
/* a repeat code has no data */ /* 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,6 +44,7 @@ static int img_ir_sanyo_scancode(int len, u64 raw, int *scancode, u64 protocols)
return -EINVAL; return -EINVAL;
/* Normal Sanyo */ /* Normal Sanyo */
*protocol = RC_TYPE_SANYO;
*scancode = addr << 8 | data; *scancode = addr << 8 | data;
return IMG_IR_SCANCODE; return IMG_IR_SCANCODE;
} }
......
...@@ -12,7 +12,8 @@ ...@@ -12,7 +12,8 @@
#include "img-ir-hw.h" #include "img-ir-hw.h"
/* Convert Sharp data to a scancode */ /* Convert Sharp data to a scancode */
static int img_ir_sharp_scancode(int len, u64 raw, int *scancode, u64 protocols) static int img_ir_sharp_scancode(int len, u64 raw, enum rc_type *protocol,
u32 *scancode, u64 enabled_protocols)
{ {
unsigned int addr, cmd, exp, chk; unsigned int addr, cmd, exp, chk;
...@@ -31,6 +32,7 @@ static int img_ir_sharp_scancode(int len, u64 raw, int *scancode, u64 protocols) ...@@ -31,6 +32,7 @@ static int img_ir_sharp_scancode(int len, u64 raw, int *scancode, u64 protocols)
/* probably the second half of the message */ /* probably the second half of the message */
return -EINVAL; return -EINVAL;
*protocol = RC_TYPE_SHARP;
*scancode = addr << 8 | cmd; *scancode = addr << 8 | cmd;
return IMG_IR_SCANCODE; return IMG_IR_SCANCODE;
} }
......
...@@ -12,35 +12,39 @@ ...@@ -12,35 +12,39 @@
#include "img-ir-hw.h" #include "img-ir-hw.h"
/* Convert Sony data to a scancode */ /* Convert Sony data to a scancode */
static int img_ir_sony_scancode(int len, u64 raw, int *scancode, u64 protocols) static int img_ir_sony_scancode(int len, u64 raw, enum rc_type *protocol,
u32 *scancode, u64 enabled_protocols)
{ {
unsigned int dev, subdev, func; unsigned int dev, subdev, func;
switch (len) { switch (len) {
case 12: case 12:
if (!(protocols & RC_BIT_SONY12)) if (!(enabled_protocols & RC_BIT_SONY12))
return -EINVAL; return -EINVAL;
func = raw & 0x7f; /* first 7 bits */ func = raw & 0x7f; /* first 7 bits */
raw >>= 7; raw >>= 7;
dev = raw & 0x1f; /* next 5 bits */ dev = raw & 0x1f; /* next 5 bits */
subdev = 0; subdev = 0;
*protocol = RC_TYPE_SONY12;
break; break;
case 15: case 15:
if (!(protocols & RC_BIT_SONY15)) if (!(enabled_protocols & RC_BIT_SONY15))
return -EINVAL; return -EINVAL;
func = raw & 0x7f; /* first 7 bits */ func = raw & 0x7f; /* first 7 bits */
raw >>= 7; raw >>= 7;
dev = raw & 0xff; /* next 8 bits */ dev = raw & 0xff; /* next 8 bits */
subdev = 0; subdev = 0;
*protocol = RC_TYPE_SONY15;
break; break;
case 20: case 20:
if (!(protocols & RC_BIT_SONY20)) if (!(enabled_protocols & RC_BIT_SONY20))
return -EINVAL; return -EINVAL;
func = raw & 0x7f; /* first 7 bits */ func = raw & 0x7f; /* first 7 bits */
raw >>= 7; raw >>= 7;
dev = raw & 0x1f; /* next 5 bits */ dev = raw & 0x1f; /* next 5 bits */
raw >>= 5; raw >>= 5;
subdev = raw & 0xff; /* next 8 bits */ subdev = raw & 0xff; /* next 8 bits */
*protocol = RC_TYPE_SONY20;
break; break;
default: default:
return -EINVAL; return -EINVAL;
......
...@@ -1579,7 +1579,10 @@ static void imon_incoming_packet(struct imon_context *ictx, ...@@ -1579,7 +1579,10 @@ static void imon_incoming_packet(struct imon_context *ictx,
if (press_type == 0) if (press_type == 0)
rc_keyup(ictx->rdev); rc_keyup(ictx->rdev);
else { else {
rc_keydown(ictx->rdev, ictx->rc_scancode, ictx->rc_toggle); if (ictx->rc_type == RC_BIT_RC6_MCE)
rc_keydown(ictx->rdev,
ictx->rc_type == RC_BIT_RC6_MCE ? RC_TYPE_RC6_MCE : RC_TYPE_OTHER,
ictx->rc_scancode, ictx->rc_toggle);
spin_lock_irqsave(&ictx->kc_lock, flags); spin_lock_irqsave(&ictx->kc_lock, flags);
ictx->last_keycode = ictx->kc; ictx->last_keycode = ictx->kc;
spin_unlock_irqrestore(&ictx->kc_lock, flags); spin_unlock_irqrestore(&ictx->kc_lock, flags);
......
...@@ -140,7 +140,7 @@ static int ir_jvc_decode(struct rc_dev *dev, struct ir_raw_event ev) ...@@ -140,7 +140,7 @@ static int ir_jvc_decode(struct rc_dev *dev, struct ir_raw_event ev)
scancode = (bitrev8((data->bits >> 8) & 0xff) << 8) | scancode = (bitrev8((data->bits >> 8) & 0xff) << 8) |
(bitrev8((data->bits >> 0) & 0xff) << 0); (bitrev8((data->bits >> 0) & 0xff) << 0);
IR_dprintk(1, "JVC scancode 0x%04x\n", scancode); IR_dprintk(1, "JVC scancode 0x%04x\n", scancode);
rc_keydown(dev, scancode, data->toggle); rc_keydown(dev, RC_TYPE_JVC, scancode, data->toggle);
data->first = false; data->first = false;
data->old_bits = data->bits; data->old_bits = data->bits;
} else if (data->bits == data->old_bits) { } else if (data->bits == data->old_bits) {
......
...@@ -189,7 +189,7 @@ static int ir_nec_decode(struct rc_dev *dev, struct ir_raw_event ev) ...@@ -189,7 +189,7 @@ static int ir_nec_decode(struct rc_dev *dev, struct ir_raw_event ev)
if (data->is_nec_x) if (data->is_nec_x)
data->necx_repeat = true; data->necx_repeat = true;
rc_keydown(dev, scancode, 0); rc_keydown(dev, RC_TYPE_NEC, scancode, 0);
data->state = STATE_INACTIVE; data->state = STATE_INACTIVE;
return 0; return 0;
} }
......
...@@ -51,6 +51,7 @@ static int ir_rc5_decode(struct rc_dev *dev, struct ir_raw_event ev) ...@@ -51,6 +51,7 @@ static int ir_rc5_decode(struct rc_dev *dev, struct ir_raw_event ev)
struct rc5_dec *data = &dev->raw->rc5; struct rc5_dec *data = &dev->raw->rc5;
u8 toggle; u8 toggle;
u32 scancode; u32 scancode;
enum rc_type protocol;
if (!rc_protocols_enabled(dev, RC_BIT_RC5 | RC_BIT_RC5X)) if (!rc_protocols_enabled(dev, RC_BIT_RC5 | RC_BIT_RC5X))
return 0; return 0;
...@@ -138,6 +139,7 @@ static int ir_rc5_decode(struct rc_dev *dev, struct ir_raw_event ev) ...@@ -138,6 +139,7 @@ static int ir_rc5_decode(struct rc_dev *dev, struct ir_raw_event ev)
toggle = (data->bits & 0x20000) ? 1 : 0; toggle = (data->bits & 0x20000) ? 1 : 0;
command += (data->bits & 0x01000) ? 0 : 0x40; command += (data->bits & 0x01000) ? 0 : 0x40;
scancode = system << 16 | command << 8 | xdata; scancode = system << 16 | command << 8 | xdata;
protocol = RC_TYPE_RC5X;
IR_dprintk(1, "RC5X scancode 0x%06x (toggle: %u)\n", IR_dprintk(1, "RC5X scancode 0x%06x (toggle: %u)\n",
scancode, toggle); scancode, toggle);
...@@ -154,12 +156,13 @@ static int ir_rc5_decode(struct rc_dev *dev, struct ir_raw_event ev) ...@@ -154,12 +156,13 @@ static int ir_rc5_decode(struct rc_dev *dev, struct ir_raw_event ev)
toggle = (data->bits & 0x00800) ? 1 : 0; toggle = (data->bits & 0x00800) ? 1 : 0;
command += (data->bits & 0x01000) ? 0 : 0x40; command += (data->bits & 0x01000) ? 0 : 0x40;
scancode = system << 8 | command; scancode = system << 8 | command;
protocol = RC_TYPE_RC5;
IR_dprintk(1, "RC5 scancode 0x%04x (toggle: %u)\n", IR_dprintk(1, "RC5 scancode 0x%04x (toggle: %u)\n",
scancode, toggle); scancode, toggle);
} }
rc_keydown(dev, scancode, toggle); rc_keydown(dev, protocol, scancode, toggle);
data->state = STATE_INACTIVE; data->state = STATE_INACTIVE;
return 0; return 0;
} }
......
...@@ -115,7 +115,7 @@ static int ir_rc5_sz_decode(struct rc_dev *dev, struct ir_raw_event ev) ...@@ -115,7 +115,7 @@ static int ir_rc5_sz_decode(struct rc_dev *dev, struct ir_raw_event ev)
IR_dprintk(1, "RC5-sz scancode 0x%04x (toggle: %u)\n", IR_dprintk(1, "RC5-sz scancode 0x%04x (toggle: %u)\n",
scancode, toggle); scancode, toggle);
rc_keydown(dev, scancode, toggle); rc_keydown(dev, RC_TYPE_RC5_SZ, scancode, toggle);
data->state = STATE_INACTIVE; data->state = STATE_INACTIVE;
return 0; return 0;
} }
......
...@@ -88,6 +88,7 @@ static int ir_rc6_decode(struct rc_dev *dev, struct ir_raw_event ev) ...@@ -88,6 +88,7 @@ static int ir_rc6_decode(struct rc_dev *dev, struct ir_raw_event ev)
struct rc6_dec *data = &dev->raw->rc6; struct rc6_dec *data = &dev->raw->rc6;
u32 scancode; u32 scancode;
u8 toggle; u8 toggle;
enum rc_type protocol;
if (!rc_protocols_enabled(dev, RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 | if (!rc_protocols_enabled(dev, RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 |
RC_BIT_RC6_6A_24 | RC_BIT_RC6_6A_32 | RC_BIT_RC6_6A_24 | RC_BIT_RC6_6A_32 |
...@@ -233,9 +234,11 @@ static int ir_rc6_decode(struct rc_dev *dev, struct ir_raw_event ev) ...@@ -233,9 +234,11 @@ static int ir_rc6_decode(struct rc_dev *dev, struct ir_raw_event ev)
case RC6_MODE_0: case RC6_MODE_0:
scancode = data->body; scancode = data->body;
toggle = data->toggle; toggle = data->toggle;
protocol = RC_TYPE_RC6_0;
IR_dprintk(1, "RC6(0) scancode 0x%04x (toggle: %u)\n", IR_dprintk(1, "RC6(0) scancode 0x%04x (toggle: %u)\n",
scancode, toggle); scancode, toggle);
break; break;
case RC6_MODE_6A: case RC6_MODE_6A:
if (data->count > CHAR_BIT * sizeof data->body) { if (data->count > CHAR_BIT * sizeof data->body) {
IR_dprintk(1, "RC6 too many (%u) data bits\n", IR_dprintk(1, "RC6 too many (%u) data bits\n",
...@@ -244,23 +247,39 @@ static int ir_rc6_decode(struct rc_dev *dev, struct ir_raw_event ev) ...@@ -244,23 +247,39 @@ static int ir_rc6_decode(struct rc_dev *dev, struct ir_raw_event ev)
} }
scancode = data->body; scancode = data->body;
if (data->count == RC6_6A_32_NBITS && switch (data->count) {
(scancode & RC6_6A_LCC_MASK) == RC6_6A_MCE_CC) { case 20:
/* MCE RC */ protocol = RC_TYPE_RC6_6A_20;
toggle = (scancode & RC6_6A_MCE_TOGGLE_MASK) ? 1 : 0; toggle = 0;
break;
case 24:
protocol = RC_BIT_RC6_6A_24;
toggle = 0;
break;
case 32:
if ((scancode & RC6_6A_LCC_MASK) == RC6_6A_MCE_CC) {
protocol = RC_TYPE_RC6_MCE;
scancode &= ~RC6_6A_MCE_TOGGLE_MASK; scancode &= ~RC6_6A_MCE_TOGGLE_MASK;
toggle = !!(scancode & RC6_6A_MCE_TOGGLE_MASK);
} else { } else {
protocol = RC_BIT_RC6_6A_32;
toggle = 0; toggle = 0;
} }
IR_dprintk(1, "RC6(6A) scancode 0x%08x (toggle: %u)\n", break;
scancode, toggle); default:
IR_dprintk(1, "RC6(6A) unsupported length\n");
goto out;
}
IR_dprintk(1, "RC6(6A) proto 0x%04x, scancode 0x%08x (toggle: %u)\n",
protocol, scancode, toggle);
break; break;
default: default:
IR_dprintk(1, "RC6 unknown mode\n"); IR_dprintk(1, "RC6 unknown mode\n");
goto out; goto out;
} }
rc_keydown(dev, scancode, toggle); rc_keydown(dev, protocol, scancode, toggle);
data->state = STATE_INACTIVE; data->state = STATE_INACTIVE;
return 0; return 0;
} }
......
...@@ -167,7 +167,7 @@ static int ir_sanyo_decode(struct rc_dev *dev, struct ir_raw_event ev) ...@@ -167,7 +167,7 @@ static int ir_sanyo_decode(struct rc_dev *dev, struct ir_raw_event ev)
scancode = address << 8 | command; scancode = address << 8 | command;
IR_dprintk(1, "SANYO scancode: 0x%06x\n", scancode); IR_dprintk(1, "SANYO scancode: 0x%06x\n", scancode);
rc_keydown(dev, scancode, 0); rc_keydown(dev, RC_TYPE_SANYO, scancode, 0);
data->state = STATE_INACTIVE; data->state = STATE_INACTIVE;
return 0; return 0;
} }
......
...@@ -162,7 +162,7 @@ static int ir_sharp_decode(struct rc_dev *dev, struct ir_raw_event ev) ...@@ -162,7 +162,7 @@ static int ir_sharp_decode(struct rc_dev *dev, struct ir_raw_event ev)
scancode = address << 8 | command; scancode = address << 8 | command;
IR_dprintk(1, "Sharp scancode 0x%04x\n", scancode); IR_dprintk(1, "Sharp scancode 0x%04x\n", scancode);
rc_keydown(dev, scancode, 0); rc_keydown(dev, RC_TYPE_SHARP, scancode, 0);
data->state = STATE_INACTIVE; data->state = STATE_INACTIVE;
return 0; return 0;
} }
......
...@@ -42,6 +42,7 @@ enum sony_state { ...@@ -42,6 +42,7 @@ enum sony_state {
static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev) static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev)
{ {
struct sony_dec *data = &dev->raw->sony; struct sony_dec *data = &dev->raw->sony;
enum rc_type protocol;
u32 scancode; u32 scancode;
u8 device, subdevice, function; u8 device, subdevice, function;
...@@ -131,6 +132,7 @@ static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev) ...@@ -131,6 +132,7 @@ static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev)
device = bitrev8((data->bits << 3) & 0xF8); device = bitrev8((data->bits << 3) & 0xF8);
subdevice = 0; subdevice = 0;
function = bitrev8((data->bits >> 4) & 0xFE); function = bitrev8((data->bits >> 4) & 0xFE);
protocol = RC_TYPE_SONY12;
break; break;
case 15: case 15:
if (!rc_protocols_enabled(dev, RC_BIT_SONY15)) { 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,6 +142,7 @@ static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev)
device = bitrev8((data->bits >> 0) & 0xFF); device = bitrev8((data->bits >> 0) & 0xFF);
subdevice = 0; subdevice = 0;
function = bitrev8((data->bits >> 7) & 0xFE); function = bitrev8((data->bits >> 7) & 0xFE);
protocol = RC_TYPE_SONY15;
break; break;
case 20: case 20:
if (!rc_protocols_enabled(dev, RC_BIT_SONY20)) { 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,6 +152,7 @@ static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev)
device = bitrev8((data->bits >> 5) & 0xF8); device = bitrev8((data->bits >> 5) & 0xF8);
subdevice = bitrev8((data->bits >> 0) & 0xFF); subdevice = bitrev8((data->bits >> 0) & 0xFF);
function = bitrev8((data->bits >> 12) & 0xFE); function = bitrev8((data->bits >> 12) & 0xFE);
protocol = RC_TYPE_SONY20;
break; break;
default: default:
IR_dprintk(1, "Sony invalid bitcount %u\n", data->count); 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,7 +161,7 @@ static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev)
scancode = device << 16 | subdevice << 8 | function; scancode = device << 16 | subdevice << 8 | function;
IR_dprintk(1, "Sony(%u) scancode 0x%05x\n", data->count, scancode); IR_dprintk(1, "Sony(%u) scancode 0x%05x\n", data->count, scancode);
rc_keydown(dev, scancode, 0); rc_keydown(dev, protocol, scancode, 0);
data->state = STATE_INACTIVE; data->state = STATE_INACTIVE;
return 0; return 0;
} }
......
...@@ -623,6 +623,7 @@ EXPORT_SYMBOL_GPL(rc_repeat); ...@@ -623,6 +623,7 @@ EXPORT_SYMBOL_GPL(rc_repeat);
/** /**
* ir_do_keydown() - internal function to process a keypress * ir_do_keydown() - internal function to process a keypress
* @dev: the struct rc_dev descriptor of the device * @dev: the struct rc_dev descriptor of the device
* @protocol: the protocol of the keypress
* @scancode: the scancode of the keypress * @scancode: the scancode of the keypress
* @keycode: the keycode of the keypress * @keycode: the keycode of the keypress
* @toggle: the toggle value of the keypress * @toggle: the toggle value of the keypress
...@@ -630,10 +631,11 @@ EXPORT_SYMBOL_GPL(rc_repeat); ...@@ -630,10 +631,11 @@ EXPORT_SYMBOL_GPL(rc_repeat);
* This function is used internally to register a keypress, it must be * This function is used internally to register a keypress, it must be
* called with keylock held. * called with keylock held.
*/ */
static void ir_do_keydown(struct rc_dev *dev, int scancode, static void ir_do_keydown(struct rc_dev *dev, enum rc_type protocol,
u32 keycode, u8 toggle) u32 scancode, u32 keycode, u8 toggle)
{ {
bool new_event = (!dev->keypressed || bool new_event = (!dev->keypressed ||
dev->last_protocol != protocol ||
dev->last_scancode != scancode || dev->last_scancode != scancode ||
dev->last_toggle != toggle); dev->last_toggle != toggle);
...@@ -645,13 +647,14 @@ static void ir_do_keydown(struct rc_dev *dev, int scancode, ...@@ -645,13 +647,14 @@ static void ir_do_keydown(struct rc_dev *dev, int scancode,
if (new_event && keycode != KEY_RESERVED) { if (new_event && keycode != KEY_RESERVED) {
/* Register a keypress */ /* Register a keypress */
dev->keypressed = true; dev->keypressed = true;
dev->last_protocol = protocol;
dev->last_scancode = scancode; dev->last_scancode = scancode;
dev->last_toggle = toggle; dev->last_toggle = toggle;
dev->last_keycode = keycode; dev->last_keycode = keycode;
IR_dprintk(1, "%s: key down event, " IR_dprintk(1, "%s: key down event, "
"key 0x%04x, scancode 0x%04x\n", "key 0x%04x, protocol 0x%04x, scancode 0x%08x\n",
dev->input_name, keycode, scancode); dev->input_name, keycode, protocol, scancode);
input_report_key(dev->input_dev, keycode, 1); input_report_key(dev->input_dev, keycode, 1);
led_trigger_event(led_feedback, LED_FULL); led_trigger_event(led_feedback, LED_FULL);
...@@ -663,20 +666,21 @@ static void ir_do_keydown(struct rc_dev *dev, int scancode, ...@@ -663,20 +666,21 @@ static void ir_do_keydown(struct rc_dev *dev, int scancode,
/** /**
* rc_keydown() - generates input event for a key press * rc_keydown() - generates input event for a key press
* @dev: the struct rc_dev descriptor of the device * @dev: the struct rc_dev descriptor of the device
* @scancode: the scancode that we're seeking * @protocol: the protocol for the keypress
* @scancode: the scancode for the keypress
* @toggle: the toggle value (protocol dependent, if the protocol doesn't * @toggle: the toggle value (protocol dependent, if the protocol doesn't
* support toggle values, this should be set to zero) * support toggle values, this should be set to zero)
* *
* This routine is used to signal that a key has been pressed on the * This routine is used to signal that a key has been pressed on the
* remote control. * remote control.
*/ */
void rc_keydown(struct rc_dev *dev, int scancode, u8 toggle) void rc_keydown(struct rc_dev *dev, enum rc_type protocol, u32 scancode, u8 toggle)
{ {
unsigned long flags; unsigned long flags;
u32 keycode = rc_g_keycode_from_table(dev, scancode); u32 keycode = rc_g_keycode_from_table(dev, scancode);
spin_lock_irqsave(&dev->keylock, flags); spin_lock_irqsave(&dev->keylock, flags);
ir_do_keydown(dev, scancode, keycode, toggle); ir_do_keydown(dev, protocol, scancode, keycode, toggle);
if (dev->keypressed) { if (dev->keypressed) {
dev->keyup_jiffies = jiffies + msecs_to_jiffies(IR_KEYPRESS_TIMEOUT); dev->keyup_jiffies = jiffies + msecs_to_jiffies(IR_KEYPRESS_TIMEOUT);
...@@ -690,20 +694,22 @@ EXPORT_SYMBOL_GPL(rc_keydown); ...@@ -690,20 +694,22 @@ EXPORT_SYMBOL_GPL(rc_keydown);
* rc_keydown_notimeout() - generates input event for a key press without * rc_keydown_notimeout() - generates input event for a key press without
* an automatic keyup event at a later time * an automatic keyup event at a later time
* @dev: the struct rc_dev descriptor of the device * @dev: the struct rc_dev descriptor of the device
* @scancode: the scancode that we're seeking * @protocol: the protocol for the keypress
* @scancode: the scancode for the keypress
* @toggle: the toggle value (protocol dependent, if the protocol doesn't * @toggle: the toggle value (protocol dependent, if the protocol doesn't
* support toggle values, this should be set to zero) * support toggle values, this should be set to zero)
* *
* This routine is used to signal that a key has been pressed on the * This routine is used to signal that a key has been pressed on the
* remote control. The driver must manually call rc_keyup() at a later stage. * remote control. The driver must manually call rc_keyup() at a later stage.
*/ */
void rc_keydown_notimeout(struct rc_dev *dev, int scancode, u8 toggle) void rc_keydown_notimeout(struct rc_dev *dev, enum rc_type protocol,
u32 scancode, u8 toggle)
{ {
unsigned long flags; unsigned long flags;
u32 keycode = rc_g_keycode_from_table(dev, scancode); u32 keycode = rc_g_keycode_from_table(dev, scancode);
spin_lock_irqsave(&dev->keylock, flags); spin_lock_irqsave(&dev->keylock, flags);
ir_do_keydown(dev, scancode, keycode, toggle); ir_do_keydown(dev, protocol, scancode, keycode, toggle);
spin_unlock_irqrestore(&dev->keylock, flags); spin_unlock_irqrestore(&dev->keylock, flags);
} }
EXPORT_SYMBOL_GPL(rc_keydown_notimeout); EXPORT_SYMBOL_GPL(rc_keydown_notimeout);
......
...@@ -1213,7 +1213,7 @@ static int af9015_rc_query(struct dvb_usb_device *d) ...@@ -1213,7 +1213,7 @@ static int af9015_rc_query(struct dvb_usb_device *d)
if ((state->rc_repeat != buf[6] || buf[0]) && if ((state->rc_repeat != buf[6] || buf[0]) &&
!memcmp(&buf[12], state->rc_last, 4)) { !memcmp(&buf[12], state->rc_last, 4)) {
dev_dbg(&d->udev->dev, "%s: key repeated\n", __func__); dev_dbg(&d->udev->dev, "%s: key repeated\n", __func__);
rc_keydown(d->rc_dev, state->rc_keycode, 0); rc_repeat(d->rc_dev);
state->rc_repeat = buf[6]; state->rc_repeat = buf[6];
return ret; return ret;
} }
...@@ -1233,18 +1233,22 @@ static int af9015_rc_query(struct dvb_usb_device *d) ...@@ -1233,18 +1233,22 @@ static int af9015_rc_query(struct dvb_usb_device *d)
if (buf[14] == (u8) ~buf[15]) { if (buf[14] == (u8) ~buf[15]) {
if (buf[12] == (u8) ~buf[13]) { if (buf[12] == (u8) ~buf[13]) {
/* NEC */ /* NEC */
state->rc_keycode = buf[12] << 8 | buf[14]; state->rc_keycode = RC_SCANCODE_NEC(buf[12],
buf[14]);
} else { } else {
/* NEC extended*/ /* NEC extended*/
state->rc_keycode = buf[12] << 16 | state->rc_keycode = RC_SCANCODE_NECX(buf[12] << 8 |
buf[13] << 8 | buf[14]; buf[13],
buf[14]);
} }
} else { } else {
/* 32 bit NEC */ /* 32 bit NEC */
state->rc_keycode = buf[12] << 24 | buf[13] << 16 | state->rc_keycode = RC_SCANCODE_NEC32(buf[12] << 24 |
buf[14] << 8 | buf[15]; buf[13] << 16 |
buf[14] << 8 |
buf[15]);
} }
rc_keydown(d->rc_dev, state->rc_keycode, 0); rc_keydown(d->rc_dev, RC_TYPE_NEC, state->rc_keycode, 0);
} else { } else {
dev_dbg(&d->udev->dev, "%s: no key press\n", __func__); dev_dbg(&d->udev->dev, "%s: no key press\n", __func__);
/* Invalidate last keypress */ /* Invalidate last keypress */
......
...@@ -1313,19 +1313,20 @@ static int af9035_rc_query(struct dvb_usb_device *d) ...@@ -1313,19 +1313,20 @@ static int af9035_rc_query(struct dvb_usb_device *d)
if ((buf[2] + buf[3]) == 0xff) { if ((buf[2] + buf[3]) == 0xff) {
if ((buf[0] + buf[1]) == 0xff) { if ((buf[0] + buf[1]) == 0xff) {
/* NEC standard 16bit */ /* NEC standard 16bit */
key = buf[0] << 8 | buf[2]; key = RC_SCANCODE_NEC(buf[0], buf[2]);
} else { } else {
/* NEC extended 24bit */ /* NEC extended 24bit */
key = buf[0] << 16 | buf[1] << 8 | buf[2]; key = RC_SCANCODE_NECX(buf[0] << 8 | buf[1], buf[2]);
} }
} else { } else {
/* NEC full code 32bit */ /* NEC full code 32bit */
key = buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3]; key = RC_SCANCODE_NEC32(buf[0] << 24 | buf[1] << 16 |
buf[2] << 8 | buf[3]);
} }
dev_dbg(&d->udev->dev, "%s: %*ph\n", __func__, 4, buf); dev_dbg(&d->udev->dev, "%s: %*ph\n", __func__, 4, buf);
rc_keydown(d->rc_dev, key, 0); rc_keydown(d->rc_dev, RC_TYPE_NEC, key, 0);
return 0; return 0;
......
...@@ -1038,7 +1038,8 @@ static int anysee_rc_query(struct dvb_usb_device *d) ...@@ -1038,7 +1038,8 @@ static int anysee_rc_query(struct dvb_usb_device *d)
if (ircode[0]) { if (ircode[0]) {
dev_dbg(&d->udev->dev, "%s: key pressed %02x\n", __func__, dev_dbg(&d->udev->dev, "%s: key pressed %02x\n", __func__,
ircode[1]); ircode[1]);
rc_keydown(d->rc_dev, 0x08 << 8 | ircode[1], 0); rc_keydown(d->rc_dev, RC_TYPE_NEC,
RC_SCANCODE_NEC(0x08, ircode[1]), 0);
} }
return 0; return 0;
......
...@@ -207,24 +207,27 @@ static int az6007_streaming_ctrl(struct dvb_frontend *fe, int onoff) ...@@ -207,24 +207,27 @@ static int az6007_streaming_ctrl(struct dvb_frontend *fe, int onoff)
static int az6007_rc_query(struct dvb_usb_device *d) static int az6007_rc_query(struct dvb_usb_device *d)
{ {
struct az6007_device_state *st = d_to_priv(d); struct az6007_device_state *st = d_to_priv(d);
unsigned code = 0; unsigned code;
az6007_read(d, AZ6007_READ_IR, 0, 0, st->data, 10); az6007_read(d, AZ6007_READ_IR, 0, 0, st->data, 10);
if (st->data[1] == 0x44) if (st->data[1] == 0x44)
return 0; return 0;
if ((st->data[3] ^ st->data[4]) == 0xff) {
if ((st->data[1] ^ st->data[2]) == 0xff) if ((st->data[1] ^ st->data[2]) == 0xff)
code = st->data[1]; code = RC_SCANCODE_NEC(st->data[1], st->data[3]);
else else
code = st->data[1] << 8 | st->data[2]; code = RC_SCANCODE_NECX(st->data[1] << 8 | st->data[2],
st->data[3]);
if ((st->data[3] ^ st->data[4]) == 0xff) } else {
code = code << 8 | st->data[3]; code = RC_SCANCODE_NEC32(st->data[1] << 24 |
else st->data[2] << 16 |
code = code << 16 | st->data[3] << 8 | st->data[4]; st->data[3] << 8 |
st->data[4]);
}
rc_keydown(d->rc_dev, code, st->data[5]); rc_keydown(d->rc_dev, RC_TYPE_NEC, code, st->data[5]);
return 0; return 0;
} }
......
...@@ -286,14 +286,13 @@ static void lme2510_int_response(struct urb *lme_urb) ...@@ -286,14 +286,13 @@ static void lme2510_int_response(struct urb *lme_urb)
case 0xaa: case 0xaa:
debug_data_snipet(1, "INT Remote data snipet", ibuf); debug_data_snipet(1, "INT Remote data snipet", ibuf);
if ((ibuf[4] + ibuf[5]) == 0xff) { if ((ibuf[4] + ibuf[5]) == 0xff) {
key = ibuf[5]; key = RC_SCANCODE_NECX((ibuf[2] ^ 0xff) << 8 |
key += (ibuf[3] > 0) (ibuf[3] > 0) ? (ibuf[3] ^ 0xff) : 0,
? (ibuf[3] ^ 0xff) << 8 : 0; ibuf[5]);
key += (ibuf[2] ^ 0xff) << 16;
deb_info(1, "INT Key =%08x", key); deb_info(1, "INT Key =%08x", key);
if (adap_to_d(adap)->rc_dev != NULL) if (adap_to_d(adap)->rc_dev != NULL)
rc_keydown(adap_to_d(adap)->rc_dev, rc_keydown(adap_to_d(adap)->rc_dev,
key, 0); RC_TYPE_NEC, key, 0);
} }
break; break;
case 0xbb: case 0xbb:
......
...@@ -1287,19 +1287,19 @@ static int rtl2831u_rc_query(struct dvb_usb_device *d) ...@@ -1287,19 +1287,19 @@ static int rtl2831u_rc_query(struct dvb_usb_device *d)
if (buf[2] == (u8) ~buf[3]) { if (buf[2] == (u8) ~buf[3]) {
if (buf[0] == (u8) ~buf[1]) { if (buf[0] == (u8) ~buf[1]) {
/* NEC standard (16 bit) */ /* NEC standard (16 bit) */
rc_code = buf[0] << 8 | buf[2]; rc_code = RC_SCANCODE_NEC(buf[0], buf[2]);
} else { } else {
/* NEC extended (24 bit) */ /* NEC extended (24 bit) */
rc_code = buf[0] << 16 | rc_code = RC_SCANCODE_NECX(buf[0] << 8 | buf[1],
buf[1] << 8 | buf[2]; buf[2]);
} }
} else { } else {
/* NEC full (32 bit) */ /* NEC full (32 bit) */
rc_code = buf[0] << 24 | buf[1] << 16 | rc_code = RC_SCANCODE_NEC32(buf[0] << 24 | buf[1] << 16 |
buf[2] << 8 | buf[3]; buf[2] << 8 | buf[3]);
} }
rc_keydown(d->rc_dev, rc_code, 0); rc_keydown(d->rc_dev, RC_TYPE_NEC, rc_code, 0);
ret = rtl28xx_wr_reg(d, SYS_IRRC_SR, 1); ret = rtl28xx_wr_reg(d, SYS_IRRC_SR, 1);
if (ret) if (ret)
......
...@@ -541,7 +541,7 @@ static int cxusb_tt_ct2_4400_rc_query(struct dvb_usb_device *d) ...@@ -541,7 +541,7 @@ static int cxusb_tt_ct2_4400_rc_query(struct dvb_usb_device *d)
rc5_addr = (cmd & 0x07C0) >> 6; /* bits 7-11 for address */ rc5_addr = (cmd & 0x07C0) >> 6; /* bits 7-11 for address */
rc5_toggle = (cmd & 0x0800) >> 11; /* bit 12 for toggle */ rc5_toggle = (cmd & 0x0800) >> 11; /* bit 12 for toggle */
keycode = (rc5_addr << 8) | rc5_cmd; keycode = (rc5_addr << 8) | rc5_cmd;
rc_keydown(d->rc_dev, keycode, rc5_toggle); rc_keydown(d->rc_dev, RC_BIT_RC5, keycode, rc5_toggle);
} }
return 0; return 0;
......
...@@ -669,6 +669,7 @@ static void dib0700_rc_urb_completion(struct urb *purb) ...@@ -669,6 +669,7 @@ static void dib0700_rc_urb_completion(struct urb *purb)
{ {
struct dvb_usb_device *d = purb->context; struct dvb_usb_device *d = purb->context;
struct dib0700_rc_response *poll_reply; struct dib0700_rc_response *poll_reply;
enum rc_type protocol;
u32 uninitialized_var(keycode); u32 uninitialized_var(keycode);
u8 toggle; u8 toggle;
...@@ -702,6 +703,7 @@ static void dib0700_rc_urb_completion(struct urb *purb) ...@@ -702,6 +703,7 @@ static void dib0700_rc_urb_completion(struct urb *purb)
switch (d->props.rc.core.protocol) { switch (d->props.rc.core.protocol) {
case RC_BIT_NEC: case RC_BIT_NEC:
protocol = RC_TYPE_NEC;
toggle = 0; toggle = 0;
/* NEC protocol sends repeat code as 0 0 0 FF */ /* NEC protocol sends repeat code as 0 0 0 FF */
...@@ -724,6 +726,7 @@ static void dib0700_rc_urb_completion(struct urb *purb) ...@@ -724,6 +726,7 @@ static void dib0700_rc_urb_completion(struct urb *purb)
keycode = RC_SCANCODE_NECX(poll_reply->system << 8 | keycode = RC_SCANCODE_NECX(poll_reply->system << 8 |
poll_reply->not_system, poll_reply->not_system,
poll_reply->data); poll_reply->data);
} else { } else {
deb_data("NEC normal protocol\n"); deb_data("NEC normal protocol\n");
keycode = RC_SCANCODE_NEC(poll_reply->system, keycode = RC_SCANCODE_NEC(poll_reply->system,
...@@ -733,9 +736,9 @@ static void dib0700_rc_urb_completion(struct urb *purb) ...@@ -733,9 +736,9 @@ static void dib0700_rc_urb_completion(struct urb *purb)
break; break;
default: default:
deb_data("RC5 protocol\n"); deb_data("RC5 protocol\n");
/* RC5 Protocol */ protocol = RC_TYPE_RC5;
toggle = poll_reply->report_id; toggle = poll_reply->report_id;
keycode = poll_reply->system << 8 | poll_reply->data; keycode = RC_SCANCODE_RC5(poll_reply->system, poll_reply->data);
break; break;
} }
...@@ -748,7 +751,7 @@ static void dib0700_rc_urb_completion(struct urb *purb) ...@@ -748,7 +751,7 @@ static void dib0700_rc_urb_completion(struct urb *purb)
goto resubmit; goto resubmit;
} }
rc_keydown(d->rc_dev, keycode, toggle); rc_keydown(d->rc_dev, protocol, keycode, toggle);
resubmit: resubmit:
/* Clean the buffer before we requeue */ /* Clean the buffer before we requeue */
......
...@@ -512,7 +512,8 @@ static u8 rc_request[] = { REQUEST_POLL_RC, 0 }; ...@@ -512,7 +512,8 @@ static u8 rc_request[] = { REQUEST_POLL_RC, 0 };
static int dib0700_rc_query_old_firmware(struct dvb_usb_device *d) static int dib0700_rc_query_old_firmware(struct dvb_usb_device *d)
{ {
u8 key[4]; u8 key[4];
u32 keycode; enum rc_type protocol;
u32 scancode;
u8 toggle; u8 toggle;
int i; int i;
struct dib0700_state *st = d->priv; struct dib0700_state *st = d->priv;
...@@ -539,28 +540,29 @@ static int dib0700_rc_query_old_firmware(struct dvb_usb_device *d) ...@@ -539,28 +540,29 @@ static int dib0700_rc_query_old_firmware(struct dvb_usb_device *d)
dib0700_rc_setup(d, NULL); /* reset ir sensor data to prevent false events */ dib0700_rc_setup(d, NULL); /* reset ir sensor data to prevent false events */
d->last_event = 0;
switch (d->props.rc.core.protocol) { switch (d->props.rc.core.protocol) {
case RC_BIT_NEC: case RC_BIT_NEC:
/* NEC protocol sends repeat code as 0 0 0 FF */ /* NEC protocol sends repeat code as 0 0 0 FF */
if ((key[3-2] == 0x00) && (key[3-3] == 0x00) && if ((key[3-2] == 0x00) && (key[3-3] == 0x00) &&
(key[3] == 0xff)) (key[3] == 0xff)) {
keycode = d->last_event; rc_repeat(d->rc_dev);
else { return 0;
keycode = key[3-2] << 8 | key[3-3];
d->last_event = keycode;
} }
rc_keydown(d->rc_dev, keycode, 0); protocol = RC_TYPE_NEC;
scancode = RC_SCANCODE_NEC(key[3-2], key[3-3]);
toggle = 0;
break; break;
default: default:
/* RC-5 protocol changes toggle bit on new keypress */ /* RC-5 protocol changes toggle bit on new keypress */
keycode = key[3-2] << 8 | key[3-3]; protocol = RC_TYPE_RC5;
scancode = RC_SCANCODE_RC5(key[3-2], key[3-3]);
toggle = key[3-1]; toggle = key[3-1];
rc_keydown(d->rc_dev, keycode, toggle);
break; break;
} }
rc_keydown(d->rc_dev, protocol, scancode, toggle);
return 0; return 0;
} }
......
...@@ -1490,7 +1490,7 @@ static int dw2102_rc_query(struct dvb_usb_device *d) ...@@ -1490,7 +1490,7 @@ static int dw2102_rc_query(struct dvb_usb_device *d)
if (msg.buf[0] != 0xff) { if (msg.buf[0] != 0xff) {
deb_rc("%s: rc code: %x, %x\n", deb_rc("%s: rc code: %x, %x\n",
__func__, key[0], key[1]); __func__, key[0], key[1]);
rc_keydown(d->rc_dev, key[0], 1); rc_keydown(d->rc_dev, RC_TYPE_UNKNOWN, key[0], 0);
} }
} }
...@@ -1511,7 +1511,7 @@ static int prof_rc_query(struct dvb_usb_device *d) ...@@ -1511,7 +1511,7 @@ static int prof_rc_query(struct dvb_usb_device *d)
if (msg.buf[0] != 0xff) { if (msg.buf[0] != 0xff) {
deb_rc("%s: rc code: %x, %x\n", deb_rc("%s: rc code: %x, %x\n",
__func__, key[0], key[1]); __func__, key[0], key[1]);
rc_keydown(d->rc_dev, key[0]^0xff, 1); rc_keydown(d->rc_dev, RC_TYPE_UNKNOWN, key[0]^0xff, 0);
} }
} }
...@@ -1532,7 +1532,8 @@ static int su3000_rc_query(struct dvb_usb_device *d) ...@@ -1532,7 +1532,8 @@ static int su3000_rc_query(struct dvb_usb_device *d)
if (msg.buf[0] != 0xff) { if (msg.buf[0] != 0xff) {
deb_rc("%s: rc code: %x, %x\n", deb_rc("%s: rc code: %x, %x\n",
__func__, key[0], key[1]); __func__, key[0], key[1]);
rc_keydown(d->rc_dev, key[1] << 8 | key[0], 1); rc_keydown(d->rc_dev, RC_TYPE_RC5,
RC_SCANCODE_RC5(key[1], key[0]), 0);
} }
} }
......
...@@ -245,7 +245,7 @@ static int m920x_rc_core_query(struct dvb_usb_device *d) ...@@ -245,7 +245,7 @@ static int m920x_rc_core_query(struct dvb_usb_device *d)
else if (state == REMOTE_KEY_REPEAT) else if (state == REMOTE_KEY_REPEAT)
rc_repeat(d->rc_dev); rc_repeat(d->rc_dev);
else else
rc_keydown(d->rc_dev, rc_state[1], 0); rc_keydown(d->rc_dev, RC_TYPE_UNKNOWN, rc_state[1], 0);
out: out:
kfree(rc_state); kfree(rc_state);
......
...@@ -565,12 +565,12 @@ static int pctv452e_rc_query(struct dvb_usb_device *d) ...@@ -565,12 +565,12 @@ static int pctv452e_rc_query(struct dvb_usb_device *d)
if ((rx[3] == 9) && (rx[12] & 0x01)) { if ((rx[3] == 9) && (rx[12] & 0x01)) {
/* got a "press" event */ /* got a "press" event */
state->last_rc_key = (rx[7] << 8) | rx[6]; state->last_rc_key = RC_SCANCODE_RC5(rx[7], rx[6]);
if (debug > 2) if (debug > 2)
info("%s: cmd=0x%02x sys=0x%02x\n", info("%s: cmd=0x%02x sys=0x%02x\n",
__func__, rx[6], rx[7]); __func__, rx[6], rx[7]);
rc_keydown(d->rc_dev, state->last_rc_key, 0); rc_keydown(d->rc_dev, RC_TYPE_RC5, state->last_rc_key, 0);
} else if (state->last_rc_key) { } else if (state->last_rc_key) {
rc_keyup(d->rc_dev); rc_keyup(d->rc_dev);
state->last_rc_key = 0; state->last_rc_key = 0;
...@@ -927,7 +927,7 @@ static struct dvb_usb_device_properties pctv452e_properties = { ...@@ -927,7 +927,7 @@ static struct dvb_usb_device_properties pctv452e_properties = {
.rc.core = { .rc.core = {
.rc_codes = RC_MAP_DIB0700_RC5_TABLE, .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
.allowed_protos = RC_BIT_UNKNOWN, .allowed_protos = RC_BIT_RC5,
.rc_query = pctv452e_rc_query, .rc_query = pctv452e_rc_query,
.rc_interval = 100, .rc_interval = 100,
}, },
...@@ -980,7 +980,7 @@ static struct dvb_usb_device_properties tt_connect_s2_3600_properties = { ...@@ -980,7 +980,7 @@ static struct dvb_usb_device_properties tt_connect_s2_3600_properties = {
.rc.core = { .rc.core = {
.rc_codes = RC_MAP_TT_1500, .rc_codes = RC_MAP_TT_1500,
.allowed_protos = RC_BIT_UNKNOWN, .allowed_protos = RC_BIT_RC5,
.rc_query = pctv452e_rc_query, .rc_query = pctv452e_rc_query,
.rc_interval = 100, .rc_interval = 100,
}, },
......
...@@ -438,9 +438,9 @@ static int tt3650_rc_query(struct dvb_usb_device *d) ...@@ -438,9 +438,9 @@ static int tt3650_rc_query(struct dvb_usb_device *d)
if (rx[8] & 0x01) { if (rx[8] & 0x01) {
/* got a "press" event */ /* got a "press" event */
st->last_rc_key = (rx[3] << 8) | rx[2]; st->last_rc_key = RC_SCANCODE_RC5(rx[3], rx[2]);
deb_info("%s: cmd=0x%02x sys=0x%02x\n", __func__, rx[2], rx[3]); deb_info("%s: cmd=0x%02x sys=0x%02x\n", __func__, rx[2], rx[3]);
rc_keydown(d->rc_dev, st->last_rc_key, rx[1]); rc_keydown(d->rc_dev, RC_TYPE_RC5, st->last_rc_key, rx[1]);
} else if (st->last_rc_key) { } else if (st->last_rc_key) {
rc_keyup(d->rc_dev); rc_keyup(d->rc_dev);
st->last_rc_key = 0; st->last_rc_key = 0;
...@@ -747,7 +747,7 @@ static struct dvb_usb_device_properties ttusb2_properties_ct3650 = { ...@@ -747,7 +747,7 @@ static struct dvb_usb_device_properties ttusb2_properties_ct3650 = {
.rc_interval = 150, /* Less than IR_KEYPRESS_TIMEOUT */ .rc_interval = 150, /* Less than IR_KEYPRESS_TIMEOUT */
.rc_codes = RC_MAP_TT_1500, .rc_codes = RC_MAP_TT_1500,
.rc_query = tt3650_rc_query, .rc_query = tt3650_rc_query,
.allowed_protos = RC_BIT_UNKNOWN, .allowed_protos = RC_BIT_RC5,
}, },
.num_adapters = 1, .num_adapters = 1,
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/usb.h> #include <linux/usb.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/bitrev.h>
#include "em28xx.h" #include "em28xx.h"
...@@ -53,6 +54,7 @@ struct em28xx_ir_poll_result { ...@@ -53,6 +54,7 @@ struct em28xx_ir_poll_result {
unsigned int toggle_bit:1; unsigned int toggle_bit:1;
unsigned int read_count:7; unsigned int read_count:7;
enum rc_type protocol;
u32 scancode; u32 scancode;
}; };
...@@ -72,7 +74,7 @@ struct em28xx_IR { ...@@ -72,7 +74,7 @@ struct em28xx_IR {
/* i2c slave address of external device (if used) */ /* i2c slave address of external device (if used) */
u16 i2c_dev_addr; u16 i2c_dev_addr;
int (*get_key_i2c)(struct i2c_client *, u32 *); int (*get_key_i2c)(struct i2c_client *ir, enum rc_type *protocol, u32 *scancode);
int (*get_key)(struct em28xx_IR *, struct em28xx_ir_poll_result *); int (*get_key)(struct em28xx_IR *, struct em28xx_ir_poll_result *);
}; };
...@@ -80,7 +82,8 @@ struct em28xx_IR { ...@@ -80,7 +82,8 @@ struct em28xx_IR {
I2C IR based get keycodes - should be used with ir-kbd-i2c I2C IR based get keycodes - should be used with ir-kbd-i2c
**********************************************************/ **********************************************************/
static int em28xx_get_key_terratec(struct i2c_client *i2c_dev, u32 *ir_key) static int em28xx_get_key_terratec(struct i2c_client *i2c_dev,
enum rc_type *protocol, u32 *scancode)
{ {
unsigned char b; unsigned char b;
...@@ -98,14 +101,15 @@ static int em28xx_get_key_terratec(struct i2c_client *i2c_dev, u32 *ir_key) ...@@ -98,14 +101,15 @@ static int em28xx_get_key_terratec(struct i2c_client *i2c_dev, u32 *ir_key)
/* keep old data */ /* keep old data */
return 1; return 1;
*ir_key = b; *protocol = RC_TYPE_UNKNOWN;
*scancode = b;
return 1; return 1;
} }
static int em28xx_get_key_em_haup(struct i2c_client *i2c_dev, u32 *ir_key) static int em28xx_get_key_em_haup(struct i2c_client *i2c_dev,
enum rc_type *protocol, u32 *scancode)
{ {
unsigned char buf[2]; unsigned char buf[2];
u16 code;
int size; int size;
/* poll IR chip */ /* poll IR chip */
...@@ -127,26 +131,13 @@ static int em28xx_get_key_em_haup(struct i2c_client *i2c_dev, u32 *ir_key) ...@@ -127,26 +131,13 @@ static int em28xx_get_key_em_haup(struct i2c_client *i2c_dev, u32 *ir_key)
* So, the code translation is not complete. Yet, it is enough to * So, the code translation is not complete. Yet, it is enough to
* work with the provided RC5 IR. * work with the provided RC5 IR.
*/ */
code = *protocol = RC_TYPE_RC5;
((buf[0] & 0x01) ? 0x0020 : 0) | /* 0010 0000 */ *scancode = (bitrev8(buf[1]) & 0x1f) << 8 | bitrev8(buf[0]) >> 2;
((buf[0] & 0x02) ? 0x0010 : 0) | /* 0001 0000 */
((buf[0] & 0x04) ? 0x0008 : 0) | /* 0000 1000 */
((buf[0] & 0x08) ? 0x0004 : 0) | /* 0000 0100 */
((buf[0] & 0x10) ? 0x0002 : 0) | /* 0000 0010 */
((buf[0] & 0x20) ? 0x0001 : 0) | /* 0000 0001 */
((buf[1] & 0x08) ? 0x1000 : 0) | /* 0001 0000 */
((buf[1] & 0x10) ? 0x0800 : 0) | /* 0000 1000 */
((buf[1] & 0x20) ? 0x0400 : 0) | /* 0000 0100 */
((buf[1] & 0x40) ? 0x0200 : 0) | /* 0000 0010 */
((buf[1] & 0x80) ? 0x0100 : 0); /* 0000 0001 */
/* return key */
*ir_key = code;
return 1; return 1;
} }
static int em28xx_get_key_pinnacle_usb_grey(struct i2c_client *i2c_dev, static int em28xx_get_key_pinnacle_usb_grey(struct i2c_client *i2c_dev,
u32 *ir_key) enum rc_type *protocol, u32 *scancode)
{ {
unsigned char buf[3]; unsigned char buf[3];
...@@ -158,13 +149,13 @@ static int em28xx_get_key_pinnacle_usb_grey(struct i2c_client *i2c_dev, ...@@ -158,13 +149,13 @@ static int em28xx_get_key_pinnacle_usb_grey(struct i2c_client *i2c_dev,
if (buf[0] != 0x00) if (buf[0] != 0x00)
return 0; return 0;
*ir_key = buf[2]&0x3f; *protocol = RC_TYPE_UNKNOWN;
*scancode = buf[2] & 0x3f;
return 1; return 1;
} }
static int em28xx_get_key_winfast_usbii_deluxe(struct i2c_client *i2c_dev, static int em28xx_get_key_winfast_usbii_deluxe(struct i2c_client *i2c_dev,
u32 *ir_key) enum rc_type *protocol, u32 *scancode)
{ {
unsigned char subaddr, keydetect, key; unsigned char subaddr, keydetect, key;
...@@ -184,7 +175,8 @@ static int em28xx_get_key_winfast_usbii_deluxe(struct i2c_client *i2c_dev, ...@@ -184,7 +175,8 @@ static int em28xx_get_key_winfast_usbii_deluxe(struct i2c_client *i2c_dev,
if (key == 0x00) if (key == 0x00)
return 0; return 0;
*ir_key = key; *protocol = RC_TYPE_UNKNOWN;
*scancode = key;
return 1; return 1;
} }
...@@ -215,7 +207,22 @@ static int default_polling_getkey(struct em28xx_IR *ir, ...@@ -215,7 +207,22 @@ static int default_polling_getkey(struct em28xx_IR *ir,
poll_result->read_count = (msg[0] & 0x7f); poll_result->read_count = (msg[0] & 0x7f);
/* Remote Control Address/Data (Regs 0x46/0x47) */ /* Remote Control Address/Data (Regs 0x46/0x47) */
switch (ir->rc_type) {
case RC_BIT_RC5:
poll_result->protocol = RC_TYPE_RC5;
poll_result->scancode = RC_SCANCODE_RC5(msg[1], msg[2]);
break;
case RC_BIT_NEC:
poll_result->protocol = RC_TYPE_NEC;
poll_result->scancode = RC_SCANCODE_NEC(msg[1], msg[2]);
break;
default:
poll_result->protocol = RC_TYPE_UNKNOWN;
poll_result->scancode = msg[1] << 8 | msg[2]; poll_result->scancode = msg[1] << 8 | msg[2];
break;
}
return 0; return 0;
} }
...@@ -247,25 +254,32 @@ static int em2874_polling_getkey(struct em28xx_IR *ir, ...@@ -247,25 +254,32 @@ static int em2874_polling_getkey(struct em28xx_IR *ir,
*/ */
switch (ir->rc_type) { switch (ir->rc_type) {
case RC_BIT_RC5: case RC_BIT_RC5:
poll_result->scancode = msg[1] << 8 | msg[2]; poll_result->protocol = RC_TYPE_RC5;
poll_result->scancode = RC_SCANCODE_RC5(msg[1], msg[2]);
break; break;
case RC_BIT_NEC: case RC_BIT_NEC:
poll_result->protocol = RC_TYPE_RC5;
poll_result->scancode = msg[1] << 8 | msg[2];
if ((msg[3] ^ msg[4]) != 0xff) /* 32 bits NEC */ if ((msg[3] ^ msg[4]) != 0xff) /* 32 bits NEC */
poll_result->scancode = (msg[1] << 24) | poll_result->scancode = RC_SCANCODE_NEC32((msg[1] << 24) |
(msg[2] << 16) | (msg[2] << 16) |
(msg[3] << 8) | (msg[3] << 8) |
msg[4]; (msg[4]));
else if ((msg[1] ^ msg[2]) != 0xff) /* 24 bits NEC */ else if ((msg[1] ^ msg[2]) != 0xff) /* 24 bits NEC */
poll_result->scancode = (msg[1] << 16) | poll_result->scancode = RC_SCANCODE_NECX(msg[1] << 8 |
(msg[2] << 8) | msg[2], msg[3]);
msg[3];
else /* Normal NEC */ else /* Normal NEC */
poll_result->scancode = msg[1] << 8 | msg[3]; poll_result->scancode = RC_SCANCODE_NEC(msg[1], msg[3]);
break; break;
case RC_BIT_RC6_0: case RC_BIT_RC6_0:
poll_result->scancode = msg[1] << 8 | msg[2]; poll_result->protocol = RC_TYPE_RC6_0;
poll_result->scancode = RC_SCANCODE_RC6_0(msg[1], msg[2]);
break; break;
default: default:
poll_result->protocol = RC_TYPE_UNKNOWN;
poll_result->scancode = (msg[1] << 24) | (msg[2] << 16) | poll_result->scancode = (msg[1] << 24) | (msg[2] << 16) |
(msg[3] << 8) | msg[4]; (msg[3] << 8) | msg[4];
break; break;
...@@ -281,22 +295,24 @@ static int em2874_polling_getkey(struct em28xx_IR *ir, ...@@ -281,22 +295,24 @@ static int em2874_polling_getkey(struct em28xx_IR *ir,
static int em28xx_i2c_ir_handle_key(struct em28xx_IR *ir) static int em28xx_i2c_ir_handle_key(struct em28xx_IR *ir)
{ {
struct em28xx *dev = ir->dev; struct em28xx *dev = ir->dev;
static u32 ir_key; static u32 scancode;
enum rc_type protocol;
int rc; int rc;
struct i2c_client client; struct i2c_client client;
client.adapter = &ir->dev->i2c_adap[dev->def_i2c_bus]; client.adapter = &ir->dev->i2c_adap[dev->def_i2c_bus];
client.addr = ir->i2c_dev_addr; client.addr = ir->i2c_dev_addr;
rc = ir->get_key_i2c(&client, &ir_key); rc = ir->get_key_i2c(&client, &protocol, &scancode);
if (rc < 0) { if (rc < 0) {
dprintk("ir->get_key_i2c() failed: %d\n", rc); dprintk("ir->get_key_i2c() failed: %d\n", rc);
return rc; return rc;
} }
if (rc) { if (rc) {
dprintk("%s: keycode = 0x%04x\n", __func__, ir_key); dprintk("%s: proto = 0x%04x, scancode = 0x%04x\n",
rc_keydown(ir->rc, ir_key, 0); __func__, protocol, scancode);
rc_keydown(ir->rc, protocol, scancode, 0);
} }
return 0; return 0;
} }
...@@ -319,10 +335,12 @@ static void em28xx_ir_handle_key(struct em28xx_IR *ir) ...@@ -319,10 +335,12 @@ static void em28xx_ir_handle_key(struct em28xx_IR *ir)
poll_result.scancode); poll_result.scancode);
if (ir->full_code) if (ir->full_code)
rc_keydown(ir->rc, rc_keydown(ir->rc,
poll_result.protocol,
poll_result.scancode, poll_result.scancode,
poll_result.toggle_bit); poll_result.toggle_bit);
else else
rc_keydown(ir->rc, rc_keydown(ir->rc,
RC_TYPE_UNKNOWN,
poll_result.scancode & 0xff, poll_result.scancode & 0xff,
poll_result.toggle_bit); poll_result.toggle_bit);
......
...@@ -162,11 +162,42 @@ static int tm6000_ir_config(struct tm6000_IR *ir) ...@@ -162,11 +162,42 @@ static int tm6000_ir_config(struct tm6000_IR *ir)
return 0; return 0;
} }
static void tm6000_ir_keydown(struct tm6000_IR *ir,
const char *buf, unsigned int len)
{
u8 device, command;
u32 scancode;
enum rc_type protocol;
if (len < 1)
return;
command = buf[0];
device = (len > 1 ? buf[1] : 0x0);
switch (ir->rc_type) {
case RC_BIT_RC5:
protocol = RC_TYPE_RC5;
scancode = RC_SCANCODE_RC5(device, command);
break;
case RC_BIT_NEC:
protocol = RC_TYPE_NEC;
scancode = RC_SCANCODE_NEC(device, command);
break;
default:
protocol = RC_TYPE_OTHER;
scancode = RC_SCANCODE_OTHER(device << 8 | command);
break;
}
dprintk(1, "%s, protocol: 0x%04x, scancode: 0x%08x\n",
__func__, protocol, scancode);
rc_keydown(ir->rc, protocol, scancode, 0);
}
static void tm6000_ir_urb_received(struct urb *urb) static void tm6000_ir_urb_received(struct urb *urb)
{ {
struct tm6000_core *dev = urb->context; struct tm6000_core *dev = urb->context;
struct tm6000_IR *ir = dev->ir; struct tm6000_IR *ir = dev->ir;
struct tm6000_ir_poll_result poll_result;
char *buf; char *buf;
dprintk(2, "%s\n",__func__); dprintk(2, "%s\n",__func__);
...@@ -184,12 +215,7 @@ static void tm6000_ir_urb_received(struct urb *urb) ...@@ -184,12 +215,7 @@ static void tm6000_ir_urb_received(struct urb *urb)
DUMP_PREFIX_OFFSET,16, 1, DUMP_PREFIX_OFFSET,16, 1,
buf, urb->actual_length, false); buf, urb->actual_length, false);
poll_result.rc_data = buf[0]; tm6000_ir_keydown(ir, urb->transfer_buffer, urb->actual_length);
if (urb->actual_length > 1)
poll_result.rc_data |= buf[1] << 8;
dprintk(1, "%s, scancode: 0x%04x\n",__func__, poll_result.rc_data);
rc_keydown(ir->rc, poll_result.rc_data, 0);
usb_submit_urb(urb, GFP_ATOMIC); usb_submit_urb(urb, GFP_ATOMIC);
/* /*
...@@ -204,7 +230,6 @@ static void tm6000_ir_handle_key(struct work_struct *work) ...@@ -204,7 +230,6 @@ static void tm6000_ir_handle_key(struct work_struct *work)
{ {
struct tm6000_IR *ir = container_of(work, struct tm6000_IR, work.work); struct tm6000_IR *ir = container_of(work, struct tm6000_IR, work.work);
struct tm6000_core *dev = ir->dev; struct tm6000_core *dev = ir->dev;
struct tm6000_ir_poll_result poll_result;
int rc; int rc;
u8 buf[2]; u8 buf[2];
...@@ -219,13 +244,8 @@ static void tm6000_ir_handle_key(struct work_struct *work) ...@@ -219,13 +244,8 @@ static void tm6000_ir_handle_key(struct work_struct *work)
if (rc < 0) if (rc < 0)
return; return;
if (rc > 1)
poll_result.rc_data = buf[0] | buf[1] << 8;
else
poll_result.rc_data = buf[0];
/* Check if something was read */ /* Check if something was read */
if ((poll_result.rc_data & 0xff) == 0xff) { if ((buf[0] & 0xff) == 0xff) {
if (!ir->pwled) { if (!ir->pwled) {
tm6000_flash_led(dev, 1); tm6000_flash_led(dev, 1);
ir->pwled = 1; ir->pwled = 1;
...@@ -233,8 +253,7 @@ static void tm6000_ir_handle_key(struct work_struct *work) ...@@ -233,8 +253,7 @@ static void tm6000_ir_handle_key(struct work_struct *work)
return; return;
} }
dprintk(1, "%s, scancode: 0x%04x\n",__func__, poll_result.rc_data); tm6000_ir_keydown(ir, buf, rc);
rc_keydown(ir->rc, poll_result.rc_data, 0);
tm6000_flash_led(dev, 0); tm6000_flash_led(dev, 0);
ir->pwled = 0; ir->pwled = 0;
......
...@@ -89,6 +89,7 @@ enum rc_filter_type { ...@@ -89,6 +89,7 @@ enum rc_filter_type {
* @keyup_jiffies: time (in jiffies) when the current keypress should be released * @keyup_jiffies: time (in jiffies) when the current keypress should be released
* @timer_keyup: timer for releasing a keypress * @timer_keyup: timer for releasing a keypress
* @last_keycode: keycode of last keypress * @last_keycode: keycode of last keypress
* @last_protocol: protocol of last keypress
* @last_scancode: scancode of last keypress * @last_scancode: scancode of last keypress
* @last_toggle: toggle value of last command * @last_toggle: toggle value of last command
* @timeout: optional time after which device stops sending data * @timeout: optional time after which device stops sending data
...@@ -141,6 +142,7 @@ struct rc_dev { ...@@ -141,6 +142,7 @@ struct rc_dev {
unsigned long keyup_jiffies; unsigned long keyup_jiffies;
struct timer_list timer_keyup; struct timer_list timer_keyup;
u32 last_keycode; u32 last_keycode;
enum rc_type last_protocol;
u32 last_scancode; u32 last_scancode;
u8 last_toggle; u8 last_toggle;
u32 timeout; u32 timeout;
...@@ -221,8 +223,8 @@ int rc_open(struct rc_dev *rdev); ...@@ -221,8 +223,8 @@ int rc_open(struct rc_dev *rdev);
void rc_close(struct rc_dev *rdev); void rc_close(struct rc_dev *rdev);
void rc_repeat(struct rc_dev *dev); void rc_repeat(struct rc_dev *dev);
void rc_keydown(struct rc_dev *dev, int scancode, u8 toggle); void rc_keydown(struct rc_dev *dev, enum rc_type protocol, u32 scancode, u8 toggle);
void rc_keydown_notimeout(struct rc_dev *dev, int scancode, u8 toggle); void rc_keydown_notimeout(struct rc_dev *dev, enum rc_type protocol, u32 scancode, u8 toggle);
void rc_keyup(struct rc_dev *dev); void rc_keyup(struct rc_dev *dev);
u32 rc_g_keycode_from_table(struct rc_dev *dev, u32 scancode); u32 rc_g_keycode_from_table(struct rc_dev *dev, u32 scancode);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment