Skip to content

Commit

Permalink
V4L/DVB: ir-core: Make use of the new IR keymap modules
Browse files Browse the repository at this point in the history
Instead of using the ugly keymap sequences, use the new rc-*.ko keymap
files. For now, it is still needed to have one keymap loaded, for the
RC code to work. Later patches will remove this depenency.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Mauro Carvalho Chehab committed May 19, 2010
1 parent b2245ba commit 02858ee
Show file tree
Hide file tree
Showing 18 changed files with 247 additions and 135 deletions.
2 changes: 2 additions & 0 deletions drivers/media/IR/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
ir-common-objs := ir-functions.o ir-keymaps.o
ir-core-objs := ir-keytable.o ir-sysfs.o ir-raw-event.o rc-map.o

obj-y += keymaps/

obj-$(CONFIG_IR_CORE) += ir-core.o
obj-$(CONFIG_VIDEO_IR) += ir-common.o
obj-$(CONFIG_IR_NEC_DECODER) += ir-nec-decoder.o
4 changes: 3 additions & 1 deletion drivers/media/IR/ir-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,10 @@ static int __init ir_core_init(void)
return rc;
}

/* Initialize/load the decoders that will be used */
/* Initialize/load the decoders/keymap code that will be used */
ir_raw_init();
rc_map_init();


return 0;
}
Expand Down
27 changes: 21 additions & 6 deletions drivers/media/IR/rc-map.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ static struct rc_keymap *seek_rc_map(const char *name)

spin_lock(&rc_map_lock);
list_for_each_entry(map, &rc_map_list, list) {
if (!strcmp(name, map->map.name))
break;
if (!strcmp(name, map->map.name)) {
spin_unlock(&rc_map_lock);
return map;
}
}
spin_unlock(&rc_map_lock);

return map;
return NULL;
}

struct ir_scancode_table *get_rc_map(const char *name)
Expand All @@ -43,15 +45,22 @@ struct ir_scancode_table *get_rc_map(const char *name)
map = seek_rc_map(name);
#ifdef MODULE
if (!map) {
rc = request_module("name");
if (rc < 0)
rc = request_module(name);
if (rc < 0) {
printk(KERN_ERR "Couldn't load IR keymap %s\n", name);
return NULL;
}
msleep(20); /* Give some time for IR to register */

map = seek_rc_map(name);
}
#endif
if (!map)
if (!map) {
printk(KERN_ERR "IR keymap %s not found\n", name);
return NULL;
}

printk(KERN_INFO "Registered IR keymap %s\n", map->map.name);

return &map->map;
}
Expand All @@ -73,3 +82,9 @@ void ir_unregister_map(struct rc_keymap *map)
spin_unlock(&rc_map_lock);
}
EXPORT_SYMBOL_GPL(ir_unregister_map);

void rc_map_init(void)
{
spin_lock_init(&rc_map_lock);

}
4 changes: 2 additions & 2 deletions drivers/media/dvb/dm1105/dm1105.c
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ static irqreturn_t dm1105_irq(int irq, void *dev_id)
int __devinit dm1105_ir_init(struct dm1105_dev *dm1105)
{
struct input_dev *input_dev;
struct ir_scancode_table *ir_codes = &IR_KEYTABLE(dm1105_nec);
char *ir_codes = NULL;
u64 ir_type = IR_TYPE_OTHER;
int err = -ENOMEM;

Expand Down Expand Up @@ -630,7 +630,7 @@ int __devinit dm1105_ir_init(struct dm1105_dev *dm1105)

INIT_WORK(&dm1105->ir.work, dm1105_emit_key);

err = __ir_input_register(input_dev, ir_codes, NULL, MODULE_NAME);
err = ir_input_register(input_dev, ir_codes, NULL, MODULE_NAME);

return err;
}
Expand Down
10 changes: 5 additions & 5 deletions drivers/media/dvb/ttpci/budget-ci.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ static int msp430_ir_init(struct budget_ci *budget_ci)
struct saa7146_dev *saa = budget_ci->budget.dev;
struct input_dev *input_dev = budget_ci->ir.dev;
int error;
struct ir_scancode_table *ir_codes;
char *ir_codes = NULL;


budget_ci->ir.dev = input_dev = input_allocate_device();
Expand Down Expand Up @@ -232,7 +232,7 @@ static int msp430_ir_init(struct budget_ci *budget_ci)
case 0x1011:
case 0x1012:
/* The hauppauge keymap is a superset of these remotes */
ir_codes = &IR_KEYTABLE(hauppauge_new);
ir_codes = RC_MAP_HAUPPAUGE_NEW;

if (rc5_device < 0)
budget_ci->ir.rc5_device = 0x1f;
Expand All @@ -241,11 +241,11 @@ static int msp430_ir_init(struct budget_ci *budget_ci)
case 0x1017:
case 0x101a:
/* for the Technotrend 1500 bundled remote */
ir_codes = &IR_KEYTABLE(tt_1500);
ir_codes = RC_MAP_TT_1500;
break;
default:
/* unknown remote */
ir_codes = &IR_KEYTABLE(budget_ci_old);
ir_codes = RC_MAP_BUDGET_CI_OLD;
break;
}

Expand All @@ -256,7 +256,7 @@ static int msp430_ir_init(struct budget_ci *budget_ci)
budget_ci->ir.timer_keyup.function = msp430_ir_keyup;
budget_ci->ir.timer_keyup.data = (unsigned long) &budget_ci->ir;
budget_ci->ir.last_raw = 0xffff; /* An impossible value */
error = __ir_input_register(input_dev, ir_codes, NULL, MODULE_NAME);
error = ir_input_register(input_dev, ir_codes, NULL, MODULE_NAME);
if (error) {
printk(KERN_ERR "budget_ci: could not init driver for IR device (code %d)\n", error);
return error;
Expand Down
28 changes: 14 additions & 14 deletions drivers/media/video/bt8xx/bttv-input.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ static void bttv_ir_stop(struct bttv *btv)
int bttv_input_init(struct bttv *btv)
{
struct card_ir *ir;
struct ir_scancode_table *ir_codes = NULL;
char *ir_codes = NULL;
struct input_dev *input_dev;
u64 ir_type = IR_TYPE_OTHER;
int err = -ENOMEM;
Expand All @@ -266,78 +266,78 @@ int bttv_input_init(struct bttv *btv)
case BTTV_BOARD_AVERMEDIA:
case BTTV_BOARD_AVPHONE98:
case BTTV_BOARD_AVERMEDIA98:
ir_codes = &IR_KEYTABLE(avermedia);
ir_codes = RC_MAP_AVERMEDIA;
ir->mask_keycode = 0xf88000;
ir->mask_keydown = 0x010000;
ir->polling = 50; // ms
break;

case BTTV_BOARD_AVDVBT_761:
case BTTV_BOARD_AVDVBT_771:
ir_codes = &IR_KEYTABLE(avermedia_dvbt);
ir_codes = RC_MAP_AVERMEDIA_DVBT;
ir->mask_keycode = 0x0f00c0;
ir->mask_keydown = 0x000020;
ir->polling = 50; // ms
break;

case BTTV_BOARD_PXELVWPLTVPAK:
ir_codes = &IR_KEYTABLE(pixelview);
ir_codes = RC_MAP_PIXELVIEW;
ir->mask_keycode = 0x003e00;
ir->mask_keyup = 0x010000;
ir->polling = 50; // ms
break;
case BTTV_BOARD_PV_M4900:
case BTTV_BOARD_PV_BT878P_9B:
case BTTV_BOARD_PV_BT878P_PLUS:
ir_codes = &IR_KEYTABLE(pixelview);
ir_codes = RC_MAP_PIXELVIEW;
ir->mask_keycode = 0x001f00;
ir->mask_keyup = 0x008000;
ir->polling = 50; // ms
break;

case BTTV_BOARD_WINFAST2000:
ir_codes = &IR_KEYTABLE(winfast);
ir_codes = RC_MAP_WINFAST;
ir->mask_keycode = 0x1f8;
break;
case BTTV_BOARD_MAGICTVIEW061:
case BTTV_BOARD_MAGICTVIEW063:
ir_codes = &IR_KEYTABLE(winfast);
ir_codes = RC_MAP_WINFAST;
ir->mask_keycode = 0x0008e000;
ir->mask_keydown = 0x00200000;
break;
case BTTV_BOARD_APAC_VIEWCOMP:
ir_codes = &IR_KEYTABLE(apac_viewcomp);
ir_codes = RC_MAP_APAC_VIEWCOMP;
ir->mask_keycode = 0x001f00;
ir->mask_keyup = 0x008000;
ir->polling = 50; // ms
break;
case BTTV_BOARD_ASKEY_CPH03X:
case BTTV_BOARD_CONCEPTRONIC_CTVFMI2:
case BTTV_BOARD_CONTVFMI:
ir_codes = &IR_KEYTABLE(pixelview);
ir_codes = RC_MAP_PIXELVIEW;
ir->mask_keycode = 0x001F00;
ir->mask_keyup = 0x006000;
ir->polling = 50; // ms
break;
case BTTV_BOARD_NEBULA_DIGITV:
ir_codes = &IR_KEYTABLE(nebula);
ir_codes = RC_MAP_NEBULA;
btv->custom_irq = bttv_rc5_irq;
ir->rc5_gpio = 1;
break;
case BTTV_BOARD_MACHTV_MAGICTV:
ir_codes = &IR_KEYTABLE(apac_viewcomp);
ir_codes = RC_MAP_APAC_VIEWCOMP;
ir->mask_keycode = 0x001F00;
ir->mask_keyup = 0x004000;
ir->polling = 50; /* ms */
break;
case BTTV_BOARD_KOZUMI_KTV_01C:
ir_codes = &IR_KEYTABLE(pctv_sedna);
ir_codes = RC_MAP_PCTV_SEDNA;
ir->mask_keycode = 0x001f00;
ir->mask_keyup = 0x006000;
ir->polling = 50; /* ms */
break;
case BTTV_BOARD_ENLTV_FM_2:
ir_codes = &IR_KEYTABLE(encore_enltv2);
ir_codes = RC_MAP_ENCORE_ENLTV2;
ir->mask_keycode = 0x00fd00;
ir->mask_keyup = 0x000080;
ir->polling = 1; /* ms */
Expand Down Expand Up @@ -392,7 +392,7 @@ int bttv_input_init(struct bttv *btv)
bttv_ir_start(btv, ir);

/* all done */
err = __ir_input_register(btv->remote->dev, ir_codes, NULL, MODULE_NAME);
err = ir_input_register(btv->remote->dev, ir_codes, NULL, MODULE_NAME);
if (err)
goto err_out_stop;

Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/cx18/cx18-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ static int cx18_i2c_new_ir(struct cx18 *cx, struct i2c_adapter *adap, u32 hw,
/* Our default information for ir-kbd-i2c.c to use */
switch (hw) {
case CX18_HW_Z8F0811_IR_RX_HAUP:
init_data->ir_codes = &IR_KEYTABLE(hauppauge_new);
init_data->ir_codes = RC_MAP_HAUPPAUGE_NEW;
init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR;
init_data->type = IR_TYPE_RC5;
init_data->name = cx->card_name;
Expand Down
6 changes: 3 additions & 3 deletions drivers/media/video/cx23885/cx23885-input.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ int cx23885_input_init(struct cx23885_dev *dev)
{
struct card_ir *ir;
struct input_dev *input_dev;
struct ir_scancode_table *ir_codes = NULL;
char *ir_codes = NULL;
int ir_type, ir_addr, ir_start;
int ret;

Expand All @@ -355,7 +355,7 @@ int cx23885_input_init(struct cx23885_dev *dev)
case CX23885_BOARD_HAUPPAUGE_HVR1850:
case CX23885_BOARD_HAUPPAUGE_HVR1290:
/* Parameters for the grey Hauppauge remote for the HVR-1850 */
ir_codes = &IR_KEYTABLE(hauppauge_new);
ir_codes = RC_MAP_HAUPPAUGE_NEW;
ir_type = IR_TYPE_RC5;
ir_addr = 0x1e; /* RC-5 system bits emitted by the remote */
ir_start = RC5_START_BITS_NORMAL; /* A basic RC-5 remote */
Expand Down Expand Up @@ -400,7 +400,7 @@ int cx23885_input_init(struct cx23885_dev *dev)
dev->ir_input = ir;
cx23885_input_ir_start(dev);

ret = __ir_input_register(ir->dev, ir_codes, NULL, MODULE_NAME);
ret = ir_input_register(ir->dev, ir_codes, NULL, MODULE_NAME);
if (ret)
goto err_out_stop;

Expand Down
Loading

0 comments on commit 02858ee

Please sign in to comment.