The attached patch makes budget-ci use ir-common for input handling. It also selects the "Hauppauge grey" keymap for devices which match my Nova-T. This patch depends on my -fixups patch. The remapping support which is apparently supposed to be there isn't actually working here: I'm getting "invalid argument" when input-kbd tries to set the mappings. Reading the current mappings is working fine, though. (Kernel 2.6.13.4 with recent v4l-dvb CVS, in case it makes any difference; specifically, ir-common.c rev. 1.18.) -- | Darren Salt | d youmustbejoking,demon,co,uk | nr. Ashington, | Debian, | s zap,tartarus,org | Northumberland | RISC OS | @ | Toon Army | <URL:http://www.youmustbejoking.demon.co.uk/> (PGP 2.6, GPG keys) Prosperity makes friends, adversity tries them. -------------- next part -------------- Make budget-ci use ir-common (for key remapping). Select "Hauppauge grey" keymap for Nova-T (subsystem 13C2:1011); my remote control has a subset of the keys defined in that mapping. Signed-Off-By: Darren Salt <linux@xxxxxxxxxxxxxxxxxxxxxxxxxxx> --- linux/drivers/media/dvb/ttpci/budget-ci.c.orig 2005-12-20 19:09:37.000000000 +0000 +++ linux/drivers/media/dvb/ttpci/budget-ci.c 2005-12-20 19:27:42.000000000 +0000 @@ -4,6 +4,7 @@ * Compiled from various sources by Michael Hunold <michael@xxxxxxx> * * msp430 IR support contributed by Jack Thomasson <jkt@xxxxxxxxxx> + * modified to use ir-common by Darren Salt <linux@xxxxxxxxxxxxxxxxxxxxxxxxxxx> * partially based on the Siemens DVB driver by Ralph+Marcus Metzler * * CI interface support (c) 2004 Andrew de Quincey <adq_dvb@xxxxxxxxxxxxx> @@ -37,6 +38,7 @@ #include <linux/interrupt.h> #include <linux/input.h> #include <linux/spinlock.h> +#include <media/ir-common.h> #include "dvb_ca_en50221.h" #include "stv0299.h" @@ -66,6 +68,7 @@ struct budget_ci_ir { struct input_dev *dev; + struct ir_input_state state; char name[72]; /* 40 + 32 for (struct saa7146_dev).name */ char phys[32]; }; @@ -85,7 +88,7 @@ Hauppauge (from NOVA-CI-s box product) i've taken a "middle of the road" approach and note the differences */ -static u16 key_map[64] = { +static IR_KEYTAB_TYPE key_map[IR_KEYTAB_SIZE] = { /* 0x0X */ KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, @@ -136,17 +139,18 @@ static void msp430_ir_debounce(unsigned long data) { - struct input_dev *dev = (struct input_dev *) data; + struct budget_ci_ir *ir = (struct budget_ci_ir *) data; - if (dev->rep[0] == 0 || dev->rep[0] == ~0) { - input_event(dev, EV_KEY, key_map[dev->repeat_key], !!0); + if (ir->dev->rep[0] == 0 || ir->dev->rep[0] == ~0) return; - } - dev->rep[0] = 0; - dev->timer.expires = jiffies + HZ * 350 / 1000; - add_timer(&dev->timer); - input_event(dev, EV_KEY, key_map[dev->repeat_key], 2); /* REPEAT */ + /* we only ever get key-down, so we have to handle repeat ourselves */ + ir_input_keydown(ir->dev, &ir->state, ir->state.ir_key, ir->state.ir_raw); + ir_input_nokey(ir->dev, &ir->state); + + ir->dev->rep[0] = 0; + ir->dev->timer.expires = jiffies + HZ * IR_REPEAT_DELAY / 1000; + add_timer(&ir->dev->timer); } static void msp430_ir_interrupt(unsigned long data) @@ -160,26 +164,20 @@ code &= 0x3f; if (timer_pending(&dev->timer)) { - if (code == dev->repeat_key) { + if (code == budget_ci->ir.state.ir_raw) { ++dev->rep[0]; return; } del_timer(&dev->timer); - input_event(dev, EV_KEY, key_map[dev->repeat_key], !!0); } - if (!key_map[code]) { - printk("DVB (%s): no key for %02x!\n", __FUNCTION__, code); - return; - } + ir_input_keydown(dev, &budget_ci->ir.state, code, code); + ir_input_nokey(dev, &budget_ci->ir.state); - /* initialize debounce and repeat */ - dev->repeat_key = code; /* Zenith remote _always_ sends 2 sequences */ dev->rep[0] = ~0; dev->timer.expires = jiffies + HZ * IR_REPEAT_DELAY / 1000; /* MAKE */ - input_event(dev, EV_KEY, key_map[code], !0); add_timer(&dev->timer); } } @@ -188,7 +186,7 @@ { struct saa7146_dev *saa = budget_ci->budget.dev; struct input_dev *input_dev; - int i; + IR_KEYTAB_TYPE *keys; budget_ci->ir.dev = input_dev = input_allocate_device(); if (!input_dev) @@ -200,13 +198,19 @@ snprintf(budget_ci->ir.name, sizeof(budget_ci->ir.name), "Budget-CI dvb ir receiver %s", saa->name); snprintf(budget_ci->ir.phys, sizeof(budget_ci->ir.phys), "pci-%s/ir0", pci_name(saa->pci)); - input_dev->name = budget_ci->ir.name; + /* Select keymap */ + switch (budget_ci->budget.dev->pci->subsystem_device) { + case 0x1011: // Hauppauge/TT Nova-T budget (tda10045/Philips tdm1316l(tda6651tt) + TDA9889) + keys = ir_codes_hauppauge_new; /* more keys defined than are physically present */ + break; - set_bit(EV_KEY, input_dev->evbit); - for (i = 0; i < ARRAY_SIZE(key_map); i++) - if (key_map[i]) - set_bit(key_map[i], input_dev->keybit); + default: // unknown or insufficient information - FIXME + keys = key_map; + break; + } + ir_input_init(input_dev, &budget_ci->ir.state, IR_TYPE_RC5, keys); + input_dev->name = budget_ci->ir.name; #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) input_dev->phys = budget_ci->ir.phys; input_dev->id.bustype = BUS_PCI; @@ -224,9 +228,13 @@ input_dev->dev = &saa->pci->dev; #endif #endif - input_register_device(input_dev); + input_dev->rep[0] = 0; + input_dev->rep[1] = IR_REPEAT_DELAY; input_dev->timer.function = msp430_ir_debounce; + input_dev->timer.data = (unsigned long) &budget_ci->ir; + + input_register_device(input_dev); saa7146_write(saa, IER, saa7146_read(saa, IER) | MASK_06); saa7146_setgpio(saa, 3, SAA7146_GPIO_IRQHI); @@ -245,7 +253,7 @@ if (dev) { if (del_timer(&dev->timer)) - input_event(dev, EV_KEY, key_map[dev->repeat_key], !!0); + ir_input_nokey(budget_ci->ir.dev, &budget_ci->ir.state); input_unregister_device(dev); } }