25 #include <linux/types.h>
27 #include <linux/module.h>
29 #include <linux/kernel.h>
30 #include <linux/bitops.h>
42 #define IR_ALL 0xffffffff
44 #define UP_TIMEOUT (HZ*7/25)
53 static int ir_inversion[
AV_CNT];
55 MODULE_PARM_DESC(ir_inversion,
"Inversion of infrared signal: 0 not inverted (default), 1 inverted");
59 MODULE_PARM_DESC(ir_device_mask,
"Bitmask of infrared devices: bit 0..31 = device 0..31 (default: all)");
65 static u16 default_key_map [256] = {
68 KEY_VOLUMEUP,
KEY_VOLUMEDOWN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
70 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
71 0, 0, 0, 0,
KEY_TEXT, 0, 0,
KEY_TV, 0, 0, 0, 0, 0,
KEY_SETUP, 0, 0,
75 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
KEY_RED,
KEY_GREEN,
KEY_YELLOW,
76 KEY_BLUE, 0, 0, 0, 0, 0, 0, 0,
KEY_MENU,
KEY_LIST, 0, 0, 0, 0, 0, 0,
77 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
78 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
79 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
80 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
83 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
84 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
85 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
KEY_VCR
90 static void av7110_emit_keyup(
unsigned long parm)
103 static void av7110_emit_key(
unsigned long parm)
116 addr = (ircom >> 6) & 0x1f;
117 toggle = ircom & 0x0800;
122 addr = (ircom >> 8) & 0x1f;
123 toggle = ircom & 0x8000;
128 addr = (ircom >> 6) & 0x1f;
130 if (!(ircom & 0x1000))
132 toggle = ircom & 0x0800;
145 dprintk(16,
"%s: code %08x -> addr %i data 0x%02x -> keycode %i\n",
146 __func__, ircom, addr, data, keycode);
153 printk (
"%s: code %08x -> addr %i data 0x%02x -> unknown key!\n",
154 __func__, ircom, addr, data);
185 static void input_register_keys(
struct infrared *ir)
212 static void input_repeat_key(
unsigned long parm)
224 int modified =
force;
227 for (i = 0; i < av_cnt; i++)
228 if (av7110 == av_list[i])
231 if (i < av_cnt && av7110) {
232 if ((av7110->
ir.protocol & 1) != ir_protocol[i] ||
233 av7110->
ir.inversion != ir_inversion[i])
238 if (ir_protocol[i]) {
241 av7110->
ir.ir_config = 0x0001;
244 av7110->
ir.ir_config = 0x0002;
247 av7110->
ir.ir_config = 0x0000;
250 if (ir_inversion[i]) {
252 av7110->
ir.ir_config |= 0x8000;
254 av7110->
ir.inversion = ir_inversion[
i];
257 av7110->
ir.ir_config);
262 if (av7110->
ir.device_mask != ir_device_mask[i])
263 av7110->
ir.device_mask = ir_device_mask[
i];
276 int size =
sizeof ir_config +
sizeof av_list[0]->
ir.key_map;
291 memcpy(&ir_config, page,
sizeof ir_config);
293 for (i = 0; i < av_cnt; i++) {
296 sizeof(av_list[i]->
ir.key_map));
298 ir_protocol[
i] = ir_config & 0x0001;
299 ir_inversion[
i] = ir_config & 0x8000 ? 1 : 0;
300 if (ir_config & 0x4000)
301 ir_device_mask[
i] = 1 << ((ir_config >> 16) & 0x1f);
306 input_register_keys(&av_list[i]->ir);
314 .write = av7110_ir_proc_write,
321 dprintk(4,
"ir command = %08x\n", ircom);
322 av7110->
ir.ir_command = ircom;
323 tasklet_schedule(&av7110->
ir.ir_tasklet);
329 struct input_dev *input_dev;
336 av_list[av_cnt++] = av7110;
340 av7110->
ir.keyup_timer.function = av7110_emit_keyup;
341 av7110->
ir.keyup_timer.data = (
unsigned long) &av7110->
ir;
343 input_dev = input_allocate_device();
347 av7110->
ir.input_dev = input_dev;
348 snprintf(av7110->
ir.input_phys,
sizeof(av7110->
ir.input_phys),
349 "pci-%s/ir0", pci_name(av7110->
dev->pci));
351 input_dev->name =
"DVB on-card IR receiver";
353 input_dev->phys = av7110->
ir.input_phys;
354 input_dev->id.bustype =
BUS_PCI;
355 input_dev->id.version = 2;
356 if (av7110->
dev->pci->subsystem_vendor) {
357 input_dev->id.vendor = av7110->
dev->pci->subsystem_vendor;
358 input_dev->id.product = av7110->
dev->pci->subsystem_device;
360 input_dev->id.vendor = av7110->
dev->pci->vendor;
361 input_dev->id.product = av7110->
dev->pci->device;
363 input_dev->dev.parent = &av7110->
dev->pci->dev;
365 memcpy(av7110->
ir.key_map, default_key_map,
sizeof av7110->
ir.key_map);
366 input_register_keys(&av7110->
ir);
367 err = input_register_device(input_dev);
369 input_free_device(input_dev);
372 input_dev->timer.function = input_repeat_key;
373 input_dev->timer.data = (
unsigned long) &av7110->
ir;
376 e = proc_create(
"av7110_ir",
S_IWUSR,
NULL, &av7110_ir_proc_fops);
378 e->
size = 4 + 256 *
sizeof(
u16);
381 tasklet_init(&av7110->
ir.ir_tasklet, av7110_emit_key, (
unsigned long) &av7110->
ir);
382 av7110->
ir.ir_handler = ir_handler;
396 av7110->
ir.ir_handler =
NULL;
399 for (i = 0; i < av_cnt; i++)
400 if (av_list[i] == av7110) {
401 av_list[
i] = av_list[av_cnt-1];
402 av_list[av_cnt-1] =
NULL;
409 input_unregister_device(av7110->
ir.input_dev);