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#include <linux/module.h>
44#include <linux/init.h>
45#include <linux/input.h>
46#include <linux/delay.h>
47#include <linux/interrupt.h>
48
49#include <asm/atariints.h>
50#include <asm/atarihw.h>
51#include <asm/atarikb.h>
52#include <asm/irq.h>
53
54MODULE_AUTHOR("Michael Schmitz <schmitz@biophys.uni-duesseldorf.de>");
55MODULE_DESCRIPTION("Atari keyboard driver");
56MODULE_LICENSE("GPL");
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
82static unsigned char atakbd_keycode[0x72] = {
83 [0] = KEY_GRAVE,
84 [1] = KEY_ESC,
85 [2] = KEY_1,
86 [3] = KEY_2,
87 [4] = KEY_3,
88 [5] = KEY_4,
89 [6] = KEY_5,
90 [7] = KEY_6,
91 [8] = KEY_7,
92 [9] = KEY_8,
93 [10] = KEY_9,
94 [11] = KEY_0,
95 [12] = KEY_MINUS,
96 [13] = KEY_EQUAL,
97 [14] = KEY_BACKSPACE,
98 [15] = KEY_TAB,
99 [16] = KEY_Q,
100 [17] = KEY_W,
101 [18] = KEY_E,
102 [19] = KEY_R,
103 [20] = KEY_T,
104 [21] = KEY_Y,
105 [22] = KEY_U,
106 [23] = KEY_I,
107 [24] = KEY_O,
108 [25] = KEY_P,
109 [26] = KEY_LEFTBRACE,
110 [27] = KEY_RIGHTBRACE,
111 [28] = KEY_ENTER,
112 [29] = KEY_LEFTCTRL,
113 [30] = KEY_A,
114 [31] = KEY_S,
115 [32] = KEY_D,
116 [33] = KEY_F,
117 [34] = KEY_G,
118 [35] = KEY_H,
119 [36] = KEY_J,
120 [37] = KEY_K,
121 [38] = KEY_L,
122 [39] = KEY_SEMICOLON,
123 [40] = KEY_APOSTROPHE,
124 [41] = KEY_BACKSLASH,
125 [42] = KEY_LEFTSHIFT,
126 [43] = KEY_GRAVE,
127 [44] = KEY_Z,
128 [45] = KEY_X,
129 [46] = KEY_C,
130 [47] = KEY_V,
131 [48] = KEY_B,
132 [49] = KEY_N,
133 [50] = KEY_M,
134 [51] = KEY_COMMA,
135 [52] = KEY_DOT,
136 [53] = KEY_SLASH,
137 [54] = KEY_RIGHTSHIFT,
138 [55] = KEY_KPASTERISK,
139 [56] = KEY_LEFTALT,
140 [57] = KEY_SPACE,
141 [58] = KEY_CAPSLOCK,
142 [59] = KEY_F1,
143 [60] = KEY_F2,
144 [61] = KEY_F3,
145 [62] = KEY_F4,
146 [63] = KEY_F5,
147 [64] = KEY_F6,
148 [65] = KEY_F7,
149 [66] = KEY_F8,
150 [67] = KEY_F9,
151 [68] = KEY_F10,
152 [69] = KEY_ESC,
153 [70] = KEY_DELETE,
154 [71] = KEY_KP7,
155 [72] = KEY_KP8,
156 [73] = KEY_KP9,
157 [74] = KEY_KPMINUS,
158 [75] = KEY_KP4,
159 [76] = KEY_KP5,
160 [77] = KEY_KP6,
161 [78] = KEY_KPPLUS,
162 [79] = KEY_KP1,
163 [80] = KEY_KP2,
164 [81] = KEY_KP3,
165 [82] = KEY_KP0,
166 [83] = KEY_KPDOT,
167 [90] = KEY_KPLEFTPAREN,
168 [91] = KEY_KPRIGHTPAREN,
169 [92] = KEY_KPASTERISK,
170 [93] = KEY_KPASTERISK,
171 [94] = KEY_KPPLUS,
172 [95] = KEY_HELP,
173 [96] = KEY_102ND,
174 [97] = KEY_KPASTERISK,
175 [98] = KEY_KPSLASH,
176 [99] = KEY_KPLEFTPAREN,
177 [100] = KEY_KPRIGHTPAREN,
178 [101] = KEY_KPSLASH,
179 [102] = KEY_KPASTERISK,
180 [103] = KEY_UP,
181 [104] = KEY_KPASTERISK,
182 [105] = KEY_LEFT,
183 [106] = KEY_RIGHT,
184 [107] = KEY_KPASTERISK,
185 [108] = KEY_DOWN,
186 [109] = KEY_KPASTERISK,
187 [110] = KEY_KPASTERISK,
188 [111] = KEY_KPASTERISK,
189 [112] = KEY_KPASTERISK,
190 [113] = KEY_KPASTERISK
191};
192
193static struct input_dev *atakbd_dev;
194
195static void atakbd_interrupt(unsigned char scancode, char down)
196{
197
198 if (scancode < 0x72) {
199
200
201
202 scancode = atakbd_keycode[scancode];
203
204 if (scancode == KEY_CAPSLOCK) {
205 input_report_key(atakbd_dev, scancode, 1);
206 input_report_key(atakbd_dev, scancode, 0);
207 input_sync(atakbd_dev);
208 } else {
209 input_report_key(atakbd_dev, scancode, down);
210 input_sync(atakbd_dev);
211 }
212 } else
213 printk(KERN_INFO "atakbd: unhandled scancode %x\n", scancode);
214
215 return;
216}
217
218static int __init atakbd_init(void)
219{
220 int i, error;
221
222 if (!MACH_IS_ATARI || !ATARIHW_PRESENT(ST_MFP))
223 return -ENODEV;
224
225
226 error = atari_keyb_init();
227 if (error)
228 return error;
229
230 atakbd_dev = input_allocate_device();
231 if (!atakbd_dev)
232 return -ENOMEM;
233
234 atakbd_dev->name = "Atari Keyboard";
235 atakbd_dev->phys = "atakbd/input0";
236 atakbd_dev->id.bustype = BUS_HOST;
237 atakbd_dev->id.vendor = 0x0001;
238 atakbd_dev->id.product = 0x0001;
239 atakbd_dev->id.version = 0x0100;
240
241 atakbd_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP);
242 atakbd_dev->keycode = atakbd_keycode;
243 atakbd_dev->keycodesize = sizeof(unsigned char);
244 atakbd_dev->keycodemax = ARRAY_SIZE(atakbd_keycode);
245
246 for (i = 1; i < 0x72; i++) {
247 set_bit(atakbd_keycode[i], atakbd_dev->keybit);
248 }
249
250
251 error = input_register_device(atakbd_dev);
252 if (error) {
253 input_free_device(atakbd_dev);
254 return error;
255 }
256
257 atari_input_keyboard_interrupt_hook = atakbd_interrupt;
258
259 return 0;
260}
261
262static void __exit atakbd_exit(void)
263{
264 atari_input_keyboard_interrupt_hook = NULL;
265 input_unregister_device(atakbd_dev);
266}
267
268module_init(atakbd_init);
269module_exit(atakbd_exit);
270