summaryrefslogtreecommitdiff
path: root/packages/linux/openzaurus-pxa27x-2.4.20-rmk2-embedix20050602/P07-C3000-KBDDEV_041206.patch
blob: b82be1551d585a64759869dc33bd46164642970e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
diff -Nur c3000_pre/linux/drivers/char/Config.in c3000_work/linux/drivers/char/Config.in
--- c3000_pre/linux/drivers/char/Config.in	2004-12-06 17:24:32.000000000 +0900
+++ c3000_work/linux/drivers/char/Config.in	2004-12-06 17:25:51.000000000 +0900
@@ -171,6 +171,7 @@
       bool '   SL-series Bluetooth support' CONFIG_BLUETOOTH_SL
    fi
 fi
+bool 'Use Keyboard device file (EXPERIMENTAL)' CONFIG_KBD_DEV_FILE
 if [ "$CONFIG_ARCH_DBMX1" = "y" ]; then
    tristate 'DragonBall MX1 serial port support' CONFIG_SERIAL_DBMX1
    if [ "$CONFIG_SERIAL_DBMX1" = "y" ]; then
diff -Nur c3000_pre/linux/drivers/char/keyboard.c c3000_work/linux/drivers/char/keyboard.c
--- c3000_pre/linux/drivers/char/keyboard.c	2004-08-21 09:48:25.000000000 +0900
+++ c3000_work/linux/drivers/char/keyboard.c	2004-12-06 17:32:08.000000000 +0900
@@ -35,6 +35,7 @@
 
 #include <asm/keyboard.h>
 #include <asm/bitops.h>
+#include <asm/uaccess.h>
 
 #include <linux/kbd_kern.h>
 #include <linux/kbd_diacr.h>
@@ -921,12 +922,35 @@
 
 pm_callback pm_kbd_request_override = NULL;
 
+#if defined(CONFIG_KBD_DEV_FILE)
+#define	KBD_MAJOR	241
+struct fasync_struct *fasync_kbd;
+
+static int kbd_open(struct inode *, struct file *);
+static int kbd_release(struct inode *, struct file *);
+static int kbd_fasync(int fd, struct file *filp, int on);
+static ssize_t kbd_read(struct file *, char *, size_t, loff_t *);
+static ssize_t kbd_write(struct file *, const char *, size_t, loff_t *);
+
+struct file_operations kbd_fops = {
+	open:		kbd_open,
+	release:	kbd_release,
+	fasync:		kbd_fasync,
+	read:		kbd_read,
+	write:		kbd_write,
+};
+#endif
+
 int __init kbd_init(void)
 {
 	int i;
 	struct kbd_struct kbd0;
 	extern struct tty_driver console_driver;
 
+#if defined(CONFIG_KBD_DEV_FILE)
+	if ( register_chrdev(KBD_MAJOR,"kbd",&kbd_fops) )
+		printk("unable to get major %d for keyboard\n", KBD_MAJOR);
+#endif
 	kbd0.ledflagstate = kbd0.default_ledflagstate = KBD_DEFLEDS;
 	kbd0.ledmode = LED_SHOW_FLAGS;
 	kbd0.lockstate = KBD_DEFLOCK;
@@ -948,3 +972,56 @@
 
 	return 0;
 }
+
+#if defined(CONFIG_KBD_DEV_FILE)
+static int kbd_open(struct inode *inode, struct file *file)
+{
+	kdev_t dev = inode->i_rdev;
+
+	return 0;
+}
+
+
+static int kbd_release(struct inode *inode, struct file *file)
+{
+	kbd_fasync(-1, file, 0);
+	return 0;
+}
+
+static int kbd_fasync(int fd, struct file *filp, int on)
+{
+	int retval;
+
+	retval = fasync_helper(fd, filp, on, &fasync_kbd);
+	if (retval < 0)
+		return retval;
+	return 0;
+}
+
+static ssize_t kbd_read(struct file *file, char *buffer, size_t count, loff_t *ppos)
+{
+//    printk("kbd read\n");
+	return 0;
+}
+
+static ssize_t	kbd_write(struct file *file, const char *buffer, size_t count, loff_t *ppos)
+{
+	char tmp[50];
+	int len;
+	int kbd_scancode,kbd_down;
+
+	len=49;
+
+	if(len>count) len=count;
+	copy_from_user(tmp,buffer,len);
+	tmp[len]='\0';
+
+	if (sscanf(tmp,"%d %d",&kbd_scancode, &kbd_down) == 2) {
+//	    printk("kbd write %02x %02x\n",kbd_scancode,kbd_down);
+		handle_scancode(kbd_scancode,kbd_down);
+	}
+
+//    printk("kbd write\n");
+	return count;
+}
+#endif