Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[linux-dvb] patch to budget-ci.c for nova-t rc



Hello,

I have Debian Sid 2.6.7 and Nova-t with ir port.

I managed to get key events on /dev/input/event? but not the correct ones for my
rc (some keys were wrong, some were not found). So I searched the archives and
found:
http://www.linuxtv.org/mailinglists/linux-dvb/2003/11-2003/msg00473.html
and
http://www.linuxtv.org/mailinglists/linux-dvb/2004/05-2004/msg00540.html

So I looked at video/ir-kbd-gpio.c and common/ir-common.[c|h]. Also on evdev.c.

I decided to use ioctl directly in budget-ci.c as this is the simplest for me.
The patch attached fills the input_dev members keycodemax, keycodesize and
keycode to the static key_map. So nothing else must be changed (except the
meaning of input_dev.repeat_key) and the default key mapping can stay.

I also filled in the member phys and id like in ir-kbd-gpio.c (this was
mentioned in some reply of the threads above).

When coding I swapped the lines
input_register_device(&budget_ci->input_dev);
and
for (i=0; i<sizeof(key_map)/sizeof(*key_map); i++)
	if (key_map[i])
		set_bit(key_map[i], budget_ci->input_dev.keybit);
The result is that "kbd" does not install an eventhandler on this input device.
I find this useful to me, but may be someoneelse not - I didn't find anything
to prevent "kbd" capture the rc events.

With this patch one can change the key map table with the ioctl functions. I use
Gerd Knorrs input-kbd from
http://dl.bytesex.org/cvs-snapshots/input-20040421-115547.tar.gz

A sample file for my rc (the same as the one mentioned in the later thread
above) is appended. I added the line
install budget-ci /sbin/modprobe --ignore-install budget-ci;\
/usr/local/bin/input-kbd -f /etc/nova-t.rc 4
to my /etc/modprobe.d/dvb so the right mapping is added after loading the dvb
moduls.

I decided to not use ir-common as the support in budget-ci was quite simple and
otherwise the code to debounce has to be added to ir-common. I think the same
can be applied very simple to av7110_ir.c.

To the point that this method does not work for 32 bit rc codes:
The ioctl functions would support 32 bit rc codes. The problem is the data
structure in input_dev and its handling in evdev.c. The member keycode is an
array of key events (KEY_*) indexed by scan codes. This way it is used by
ir-kbd-gpio and the keyboard drivers and handled by evdev.c. To support 32bit
rc codes (without 4GB tables) I propose a new imput_dev member keyscancode.
When this is null everything works as before. If it is not null, it is an int
array with the same length like keycode and contains the [scan|rc]code to the
corresponding event code in keycode. This is simple and none of the old drivers
must be changed.

There is one "bug" in input-kbd: it does not delete old entries when loading a
new mapping.

The diff is to the kernel 2.6.7 source code.

Thomas
--- budget-ci.old.c	2004-07-16 09:16:41.000000000 +0200
+++ budget-ci.c	2004-07-16 12:07:26.000000000 +0200
@@ -73,6 +73,7 @@
 	int slot_status;
 	struct dvb_ca_en50221 ca;
 	char ir_dev_name[50];
+	char ir_dev_phys[50];
 };
 
 static u32 budget_debiread (struct budget_ci* budget_ci, u32 config, int addr, int count)
@@ -193,14 +194,14 @@
 	struct input_dev *dev = (struct input_dev *) data;
 
 	if (dev->rep[0] == 0 || dev->rep[0] == ~0) {
-		input_event(dev, EV_KEY, key_map[dev->repeat_key], !!0);
+		input_event(dev, EV_KEY, dev->repeat_key, !!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 */
+	input_event(dev, EV_KEY, dev->repeat_key, 2);  /* REPEAT */
 }
 
 
@@ -215,28 +216,27 @@
 	        code &= 0x3f;
 
         	if (timer_pending(&dev->timer)) {
-                	if (code == dev->repeat_key) {
+                	if (key_map[code] == dev->repeat_key) {
                         	++dev->rep[0];
 	                        return;
         	        }
                 	del_timer(&dev->timer);
-		        input_event(dev, EV_KEY, key_map[dev->repeat_key], !!0);
+		        input_event(dev, EV_KEY, dev->repeat_key, !!0);
 		}
 
-		if (!key_map[code]) {
+		dev->repeat_key = key_map[code];
+		if (dev->repeat_key == KEY_RESERVED) {
         	        printk ("DVB (%s): no key for %02x!\n",
 				__FUNCTION__, code);
 		        return;
        		}
 
-		/* initialize debounce and repeat */
-		dev->repeat_key = code;
 		/* Zenith remote _always_ sends 2 sequences */
 		dev->rep[0] = ~0;
 		/* 350 milliseconds */
 		dev->timer.expires = jiffies + HZ * 350 / 1000;
 		/* MAKE */
-        	input_event(dev, EV_KEY, key_map[code], !0);
+        	input_event(dev, EV_KEY, dev->repeat_key, !0);
 		add_timer(&dev->timer);
 	}
 }
@@ -249,17 +249,34 @@
 
 	memset(&budget_ci->input_dev, 0, sizeof(struct input_dev));
 
-	sprintf (budget_ci->ir_dev_name, "Budget-CI dvb ir receiver %s", saa->name);
+	snprintf(budget_ci->ir_dev_name, sizeof(budget_ci->ir_dev_name), "Budget-CI dvb ir receiver %s", saa->name);
+	snprintf(budget_ci->ir_dev_phys, sizeof(budget_ci->ir_dev_phys), "pci-%s/ir0", pci_name(saa->pci));
+	
 	budget_ci->input_dev.name = budget_ci->ir_dev_name;
-
+	budget_ci->input_dev.phys = budget_ci->ir_dev_phys;
+	budget_ci->input_dev.id.bustype = BUS_PCI;
+	budget_ci->input_dev.id.version = 1;
+	if (saa->pci->subsystem_vendor) {
+		budget_ci->input_dev.id.vendor  = saa->pci->subsystem_vendor;
+		budget_ci->input_dev.id.product = saa->pci->subsystem_device;
+	} else {
+		budget_ci->input_dev.id.vendor  = saa->pci->vendor;
+		budget_ci->input_dev.id.product = saa->pci->device;
+	}
+	
+	
+	budget_ci->input_dev.keycodemax = sizeof(key_map)/sizeof(key_map[0]) - 1;
+	budget_ci->input_dev.keycodesize = sizeof(key_map[0]);
+	budget_ci->input_dev.keycode = (void*) key_map;
+	
 	set_bit(EV_KEY, budget_ci->input_dev.evbit);
 
+	input_register_device(&budget_ci->input_dev);
+
 	for (i=0; i<sizeof(key_map)/sizeof(*key_map); i++)
 		if (key_map[i])
 			set_bit(key_map[i], budget_ci->input_dev.keybit);
-
-	input_register_device(&budget_ci->input_dev);
-
+	
 	budget_ci->input_dev.timer.function = msp430_ir_debounce;
 
 	saa7146_write(saa, IER, saa7146_read(saa, IER) | MASK_06);
@@ -279,7 +296,7 @@
 	saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT);
 
 	if (del_timer(&dev->timer))
-		input_event(dev, EV_KEY, key_map[dev->repeat_key], !!0);
+		input_event(dev, EV_KEY, dev->repeat_key, !!0);
 
 	input_unregister_device(dev);
 }

Attachment: nova-t.rc
Description: Binary data

Attachment: pgp00001.pgp
Description: Digitale PGP-Unterschrift


Home | Main Index | Thread Index