2 * $Id: scan_keyb.c,v 1.1 2000/06/10 21:45:30 yaegashi Exp $
3 * Copyright (C) 2000 YAEGASHI Takeshi
4 * Generic scan keyboard driver
7 #include <linux/spinlock.h>
8 #include <linux/sched.h>
9 #include <linux/interrupt.h>
10 #include <linux/tty.h>
12 #include <linux/signal.h>
13 #include <linux/init.h>
14 #include <linux/kbd_ll.h>
15 #include <linux/delay.h>
16 #include <linux/random.h>
17 #include <linux/poll.h>
18 #include <linux/miscdevice.h>
19 #include <linux/malloc.h>
20 #include <linux/kbd_kern.h>
22 struct scan_keyboard
{
23 struct scan_keyboard
*next
;
24 void (*scan
)(unsigned char *buffer
);
25 const unsigned char *table
;
26 unsigned char *s0
, *s1
;
30 static struct scan_keyboard
*keyboards
=NULL
;
31 static struct tq_struct task_scan_kbd
;
33 static void check_kbd(const unsigned char *table
,
34 unsigned char *new, unsigned char *old
, int length
)
36 int need_tasklet_schedule
=0;
37 unsigned char xor, bit
;
40 if((xor=*new^*old
)==0) {
44 for(bit
=0x80; bit
!=0; bit
>>=1) {
46 handle_scancode(*table
, !(*new&bit
));
47 need_tasklet_schedule
=1;
55 if(need_tasklet_schedule
)
56 tasklet_schedule(&keyboard_tasklet
);
60 static void scan_kbd(void *dummy
)
62 struct scan_keyboard
*kbd
;
64 for(kbd
=keyboards
; kbd
!=NULL
; kbd
=kbd
->next
) {
67 check_kbd(kbd
->table
, kbd
->s0
, kbd
->s1
, kbd
->length
);
71 check_kbd(kbd
->table
, kbd
->s1
, kbd
->s0
, kbd
->length
);
75 queue_task(&task_scan_kbd
, &tq_timer
);
79 int register_scan_keyboard(void (*scan
)(unsigned char *buffer
),
80 const unsigned char *table
,
83 struct scan_keyboard
*kbd
;
85 if((kbd
=kmalloc(sizeof(struct scan_keyboard
), GFP_KERNEL
))==NULL
)
93 if((kbd
->s0
=kmalloc(length
, GFP_KERNEL
))==NULL
)
95 if((kbd
->s1
=kmalloc(length
, GFP_KERNEL
))==NULL
)
118 void __init
scan_kbd_init(void)
121 task_scan_kbd
.next
=NULL
;
122 task_scan_kbd
.sync
=0;
123 task_scan_kbd
.routine
=scan_kbd
;
124 task_scan_kbd
.data
=NULL
;
125 queue_task(&task_scan_kbd
, &tq_timer
);
126 printk(KERN_INFO
"Generic scan keyboard driver initialized\n");