mirror of
https://github.com/torvalds/linux.git
synced 2024-10-30 08:42:47 +00:00
V4L/DVB (13533): ir: use dynamic tables, instead of static ones
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
parent
ef53a1159d
commit
8573b74af2
@ -42,8 +42,8 @@ module_param_named(debug, media_ir_debug, int, 0644);
|
||||
static void ir_input_key_event(struct input_dev *dev, struct ir_input_state *ir)
|
||||
{
|
||||
if (KEY_RESERVED == ir->keycode) {
|
||||
printk(KERN_INFO "%s: unknown key: key=0x%02x raw=0x%02x down=%d\n",
|
||||
dev->name,ir->ir_key,ir->ir_raw,ir->keypressed);
|
||||
printk(KERN_INFO "%s: unknown key: key=0x%02x down=%d\n",
|
||||
dev->name, ir->ir_key, ir->keypressed);
|
||||
return;
|
||||
}
|
||||
IR_dprintk(1,"%s: key event code=%d down=%d\n",
|
||||
@ -57,28 +57,10 @@ static void ir_input_key_event(struct input_dev *dev, struct ir_input_state *ir)
|
||||
void ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
|
||||
int ir_type, struct ir_scancode_table *ir_codes)
|
||||
{
|
||||
int i;
|
||||
|
||||
ir->ir_type = ir_type;
|
||||
|
||||
memset(ir->ir_codes, 0, sizeof(ir->ir_codes));
|
||||
ir_set_keycode_table(dev, ir_codes);
|
||||
|
||||
/*
|
||||
* FIXME: This is a temporary workaround to use the new IR tables
|
||||
* with the old approach. Later patches will replace this to a
|
||||
* proper method
|
||||
*/
|
||||
|
||||
if (ir_codes)
|
||||
for (i = 0; i < ir_codes->size; i++)
|
||||
if (ir_codes->scan[i].scancode < IR_KEYTAB_SIZE)
|
||||
ir->ir_codes[ir_codes->scan[i].scancode] = ir_codes->scan[i].keycode;
|
||||
|
||||
dev->keycode = ir->ir_codes;
|
||||
dev->keycodesize = sizeof(IR_KEYTAB_TYPE);
|
||||
dev->keycodemax = IR_KEYTAB_SIZE;
|
||||
for (i = 0; i < IR_KEYTAB_SIZE; i++)
|
||||
set_bit(ir->ir_codes[i], dev->keybit);
|
||||
clear_bit(0, dev->keybit);
|
||||
|
||||
set_bit(EV_KEY, dev->evbit);
|
||||
@ -97,9 +79,9 @@ void ir_input_nokey(struct input_dev *dev, struct ir_input_state *ir)
|
||||
EXPORT_SYMBOL_GPL(ir_input_nokey);
|
||||
|
||||
void ir_input_keydown(struct input_dev *dev, struct ir_input_state *ir,
|
||||
u32 ir_key, u32 ir_raw)
|
||||
u32 ir_key)
|
||||
{
|
||||
u32 keycode = IR_KEYCODE(ir->ir_codes, ir_key);
|
||||
u32 keycode = ir_g_keycode_from_table(dev, ir_key);
|
||||
|
||||
if (ir->keypressed && ir->keycode != keycode) {
|
||||
ir->keypressed = 0;
|
||||
@ -107,7 +89,6 @@ void ir_input_keydown(struct input_dev *dev, struct ir_input_state *ir,
|
||||
}
|
||||
if (!ir->keypressed) {
|
||||
ir->ir_key = ir_key;
|
||||
ir->ir_raw = ir_raw;
|
||||
ir->keycode = keycode;
|
||||
ir->keypressed = 1;
|
||||
ir_input_key_event(dev,ir);
|
||||
@ -354,8 +335,7 @@ void ir_rc5_timer_end(unsigned long data)
|
||||
IR_dprintk(1, "ir-common: instruction %x, toggle %x\n", instr,
|
||||
toggle);
|
||||
ir_input_nokey(ir->dev, &ir->ir);
|
||||
ir_input_keydown(ir->dev, &ir->ir, instr,
|
||||
instr);
|
||||
ir_input_keydown(ir->dev, &ir->ir, instr);
|
||||
}
|
||||
|
||||
/* Set/reset key-up timer */
|
||||
|
@ -118,7 +118,6 @@ u32 ir_g_keycode_from_table(struct input_dev *dev, u32 scancode)
|
||||
|
||||
return KEY_UNKNOWN;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(ir_g_keycode_from_table);
|
||||
|
||||
/**
|
||||
* ir_set_keycode_table() - sets the IR keycode table and add the handlers
|
||||
@ -153,4 +152,3 @@ int ir_set_keycode_table(struct input_dev *input_dev,
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(ir_set_keycode_table);
|
||||
|
@ -510,7 +510,7 @@ static void dm1105_emit_key(struct work_struct *work)
|
||||
|
||||
data = (ircom >> 8) & 0x7f;
|
||||
|
||||
ir_input_keydown(ir->input_dev, &ir->ir, data, data);
|
||||
ir_input_keydown(ir->input_dev, &ir->ir, data);
|
||||
ir_input_nokey(ir->input_dev, &ir->ir);
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,7 @@ static void msp430_ir_interrupt(unsigned long data)
|
||||
if (budget_ci->ir.last_raw != raw || !timer_pending(&budget_ci->ir.timer_keyup)) {
|
||||
ir_input_nokey(dev, &budget_ci->ir.state);
|
||||
ir_input_keydown(dev, &budget_ci->ir.state,
|
||||
budget_ci->ir.ir_key, raw);
|
||||
budget_ci->ir.ir_key);
|
||||
budget_ci->ir.last_raw = raw;
|
||||
}
|
||||
|
||||
|
@ -73,12 +73,12 @@ static void ir_handle_key(struct bttv *btv)
|
||||
|
||||
if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) ||
|
||||
(ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) {
|
||||
ir_input_keydown(ir->dev,&ir->ir,data,data);
|
||||
ir_input_keydown(ir->dev, &ir->ir, data);
|
||||
} else {
|
||||
/* HACK: Probably, ir->mask_keydown is missing
|
||||
for this board */
|
||||
if (btv->c.type == BTTV_BOARD_WINFAST2000)
|
||||
ir_input_keydown(ir->dev, &ir->ir, data, data);
|
||||
ir_input_keydown(ir->dev, &ir->ir, data);
|
||||
|
||||
ir_input_nokey(ir->dev,&ir->ir);
|
||||
}
|
||||
@ -104,7 +104,7 @@ static void ir_enltv_handle_key(struct bttv *btv)
|
||||
gpio, data,
|
||||
(gpio & ir->mask_keyup) ? " up" : "up/down");
|
||||
|
||||
ir_input_keydown(ir->dev, &ir->ir, data, data);
|
||||
ir_input_keydown(ir->dev, &ir->ir, data);
|
||||
if (keyup)
|
||||
ir_input_nokey(ir->dev, &ir->ir);
|
||||
} else {
|
||||
@ -118,7 +118,7 @@ static void ir_enltv_handle_key(struct bttv *btv)
|
||||
if (keyup)
|
||||
ir_input_nokey(ir->dev, &ir->ir);
|
||||
else
|
||||
ir_input_keydown(ir->dev, &ir->ir, data, data);
|
||||
ir_input_keydown(ir->dev, &ir->ir, data);
|
||||
}
|
||||
|
||||
ir->last_gpio = data | keyup;
|
||||
|
@ -126,8 +126,7 @@ static void cx231xx_ir_handle_key(struct cx231xx_IR *ir)
|
||||
|
||||
if (do_sendkey) {
|
||||
dprintk("sending keypress\n");
|
||||
ir_input_keydown(ir->input, &ir->ir, poll_result.rc_data[0],
|
||||
poll_result.rc_data[0]);
|
||||
ir_input_keydown(ir->input, &ir->ir, poll_result.rc_data[0]);
|
||||
ir_input_nokey(ir->input, &ir->ir);
|
||||
}
|
||||
|
||||
|
@ -94,8 +94,7 @@ static void cx23885_input_process_raw_rc5(struct cx23885_dev *dev)
|
||||
RC5_START(ir_input->last_rc5) == 0) {
|
||||
/* This keypress is differnet: not an auto repeat */
|
||||
ir_input_nokey(ir_input->dev, &ir_input->ir);
|
||||
ir_input_keydown(ir_input->dev, &ir_input->ir,
|
||||
command, ir_input->code);
|
||||
ir_input_keydown(ir_input->dev, &ir_input->ir, command);
|
||||
}
|
||||
ir_input->last_rc5 = rc5;
|
||||
|
||||
|
@ -118,13 +118,13 @@ static void cx88_ir_handle_key(struct cx88_IR *ir)
|
||||
|
||||
data = (data << 4) | ((gpio_key & 0xf0) >> 4);
|
||||
|
||||
ir_input_keydown(ir->input, &ir->ir, data, data);
|
||||
ir_input_keydown(ir->input, &ir->ir, data);
|
||||
ir_input_nokey(ir->input, &ir->ir);
|
||||
|
||||
} else if (ir->mask_keydown) {
|
||||
/* bit set on keydown */
|
||||
if (gpio & ir->mask_keydown) {
|
||||
ir_input_keydown(ir->input, &ir->ir, data, data);
|
||||
ir_input_keydown(ir->input, &ir->ir, data);
|
||||
} else {
|
||||
ir_input_nokey(ir->input, &ir->ir);
|
||||
}
|
||||
@ -132,14 +132,14 @@ static void cx88_ir_handle_key(struct cx88_IR *ir)
|
||||
} else if (ir->mask_keyup) {
|
||||
/* bit cleared on keydown */
|
||||
if (0 == (gpio & ir->mask_keyup)) {
|
||||
ir_input_keydown(ir->input, &ir->ir, data, data);
|
||||
ir_input_keydown(ir->input, &ir->ir, data);
|
||||
} else {
|
||||
ir_input_nokey(ir->input, &ir->ir);
|
||||
}
|
||||
|
||||
} else {
|
||||
/* can't distinguish keydown/up :-/ */
|
||||
ir_input_keydown(ir->input, &ir->ir, data, data);
|
||||
ir_input_keydown(ir->input, &ir->ir, data);
|
||||
ir_input_nokey(ir->input, &ir->ir);
|
||||
}
|
||||
}
|
||||
@ -487,7 +487,7 @@ void cx88_ir_irq(struct cx88_core *core)
|
||||
|
||||
ir_dprintk("Key Code: %x\n", (ircode >> 16) & 0x7f);
|
||||
|
||||
ir_input_keydown(ir->input, &ir->ir, (ircode >> 16) & 0x7f, (ircode >> 16) & 0xff);
|
||||
ir_input_keydown(ir->input, &ir->ir, (ircode >> 16) & 0x7f);
|
||||
ir->release = jiffies + msecs_to_jiffies(120);
|
||||
break;
|
||||
case CX88_BOARD_HAUPPAUGE:
|
||||
@ -524,7 +524,7 @@ void cx88_ir_irq(struct cx88_core *core)
|
||||
if ( dev != 0x1e && dev != 0x1f )
|
||||
/* not a hauppauge remote */
|
||||
break;
|
||||
ir_input_keydown(ir->input, &ir->ir, code, ircode);
|
||||
ir_input_keydown(ir->input, &ir->ir, code);
|
||||
ir->release = jiffies + msecs_to_jiffies(120);
|
||||
break;
|
||||
case CX88_BOARD_PINNACLE_PCTV_HD_800i:
|
||||
@ -532,7 +532,7 @@ void cx88_ir_irq(struct cx88_core *core)
|
||||
ir_dprintk("biphase decoded: %x\n", ircode);
|
||||
if ((ircode & 0xfffff000) != 0x3000)
|
||||
break;
|
||||
ir_input_keydown(ir->input, &ir->ir, ircode & 0x3f, ircode);
|
||||
ir_input_keydown(ir->input, &ir->ir, ircode & 0x3f);
|
||||
ir->release = jiffies + msecs_to_jiffies(120);
|
||||
break;
|
||||
}
|
||||
|
@ -282,8 +282,7 @@ static void em28xx_ir_handle_key(struct em28xx_IR *ir)
|
||||
|
||||
if (do_sendkey) {
|
||||
dprintk("sending keypress\n");
|
||||
ir_input_keydown(ir->input, &ir->ir, poll_result.rc_data[0],
|
||||
poll_result.rc_data[0]);
|
||||
ir_input_keydown(ir->input, &ir->ir, poll_result.rc_data[0]);
|
||||
ir_input_nokey(ir->input, &ir->ir);
|
||||
}
|
||||
|
||||
|
@ -275,7 +275,7 @@ static void ir_key_poll(struct IR_i2c *ir)
|
||||
if (0 == rc) {
|
||||
ir_input_nokey(ir->input, &ir->ir);
|
||||
} else {
|
||||
ir_input_keydown(ir->input, &ir->ir, ir_key, ir_raw);
|
||||
ir_input_keydown(ir->input, &ir->ir, ir_key);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,14 +102,14 @@ static int build_key(struct saa7134_dev *dev)
|
||||
if (data == ir->mask_keycode)
|
||||
ir_input_nokey(ir->dev, &ir->ir);
|
||||
else
|
||||
ir_input_keydown(ir->dev, &ir->ir, data, data);
|
||||
ir_input_keydown(ir->dev, &ir->ir, data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ir->polling) {
|
||||
if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) ||
|
||||
(ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) {
|
||||
ir_input_keydown(ir->dev, &ir->ir, data, data);
|
||||
ir_input_keydown(ir->dev, &ir->ir, data);
|
||||
} else {
|
||||
ir_input_nokey(ir->dev, &ir->ir);
|
||||
}
|
||||
@ -117,7 +117,7 @@ static int build_key(struct saa7134_dev *dev)
|
||||
else { /* IRQ driven mode - handle key press and release in one go */
|
||||
if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) ||
|
||||
(ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) {
|
||||
ir_input_keydown(ir->dev, &ir->ir, data, data);
|
||||
ir_input_keydown(ir->dev, &ir->ir, data);
|
||||
ir_input_nokey(ir->dev, &ir->ir);
|
||||
}
|
||||
}
|
||||
@ -938,7 +938,7 @@ static void nec_task(unsigned long data)
|
||||
dprintk("scancode = 0x%02x (code = 0x%02x, notcode= 0x%02x)\n",
|
||||
ir->code, ircode, not_code);
|
||||
|
||||
ir_input_keydown(ir->dev, &ir->ir, ir->code, ir->code);
|
||||
ir_input_keydown(ir->dev, &ir->ir, ir->code);
|
||||
} else
|
||||
dprintk("Repeat last key\n");
|
||||
|
||||
|
@ -62,8 +62,7 @@ struct ir_input_state {
|
||||
IR_KEYTAB_TYPE ir_codes[IR_KEYTAB_SIZE];
|
||||
|
||||
/* key info */
|
||||
u32 ir_raw; /* raw data */
|
||||
u32 ir_key; /* ir key code */
|
||||
u32 ir_key; /* ir scancode */
|
||||
u32 keycode; /* linux key code */
|
||||
int keypressed; /* current state */
|
||||
};
|
||||
@ -112,7 +111,7 @@ void ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
|
||||
int ir_type, struct ir_scancode_table *ir_codes);
|
||||
void ir_input_nokey(struct input_dev *dev, struct ir_input_state *ir);
|
||||
void ir_input_keydown(struct input_dev *dev, struct ir_input_state *ir,
|
||||
u32 ir_key, u32 ir_raw);
|
||||
u32 ir_key);
|
||||
u32 ir_extract_bits(u32 data, u32 mask);
|
||||
int ir_dump_samples(u32 *samples, int count);
|
||||
int ir_decode_biphase(u32 *samples, int count, int low, int high);
|
||||
|
Loading…
Reference in New Issue
Block a user