Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8573b74a authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab
Browse files

V4L/DVB (13533): ir: use dynamic tables, instead of static ones

parent ef53a115
Loading
Loading
Loading
Loading
+6 −26
Original line number Diff line number Diff line
@@ -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));

	/*
	 * 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;
	ir_set_keycode_table(dev, ir_codes);

	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 */
+0 −2
Original line number Diff line number Diff line
@@ -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);
+1 −1
Original line number Diff line number Diff line
@@ -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);
}

+1 −1
Original line number Diff line number Diff line
@@ -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;
	}

+4 −4
Original line number Diff line number Diff line
@@ -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;
Loading