OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [drivers/] [char/] [dummy_keyb.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
 * linux/drivers/char/dummy_keyb.c
3
 *
4
 * Allows CONFIG_VT on hardware without keyboards.
5
 *
6
 * Copyright (C) 1999, 2001 Bradley D. LaRonde
7
 *
8
 * This file is subject to the terms and conditions of the GNU General Public
9
 * License.  See the file "COPYING" in the main directory of this archive
10
 * for more details.
11
 *
12
 * What is this for?
13
 *
14
 * Not all systems have keyboards.  Some don't even have a keyboard
15
 * port.  However, some of those systems have video support and can
16
 * use the virtual terminal support for display.  However, the virtual
17
 * terminal code expects a keyboard of some kind.  This driver keeps
18
 * the virtual terminal code happy by providing it a "keyboard", albeit
19
 * a very quiet one.
20
 *
21
 * If you want to use the virtual terminal support but your system
22
 * does not support a keyboard, define CONFIG_DUMMY_KEYB along with
23
 * CONFIG_VT.
24
 *
25
 */
26
 
27
#include <linux/config.h>
28
#include <linux/sched.h>
29
#include <linux/errno.h>
30
#include <linux/init.h>
31
#include <linux/input.h>
32
 
33
void kbd_leds(unsigned char leds)
34
{
35
}
36
 
37
int kbd_setkeycode(unsigned int scancode, unsigned int keycode)
38
{
39
        return (scancode == keycode) ? 0 : -EINVAL;
40
}
41
 
42
int kbd_getkeycode(unsigned int scancode)
43
{
44
        return scancode;
45
}
46
 
47
#ifdef CONFIG_INPUT
48
static unsigned char e0_keys[128] = {
49
        0, 0, 0, KEY_KPCOMMA, 0, KEY_INTL3, 0, 0,             /* 0x00-0x07 */
50
        0, 0, 0, 0, KEY_LANG1, KEY_LANG2, 0, 0,                       /* 0x08-0x0f */
51
        0, 0, 0, 0, 0, 0, 0, 0,                                 /* 0x10-0x17 */
52
        0, 0, 0, 0, KEY_KPENTER, KEY_RIGHTCTRL, KEY_VOLUMEUP, 0,/* 0x18-0x1f */
53
        0, 0, 0, 0, 0, KEY_VOLUMEDOWN, KEY_MUTE, 0,           /* 0x20-0x27 */
54
        0, 0, 0, 0, 0, 0, 0, 0,                                 /* 0x28-0x2f */
55
        0, 0, 0, 0, 0, KEY_KPSLASH, 0, KEY_SYSRQ,             /* 0x30-0x37 */
56
        KEY_RIGHTALT, KEY_BRIGHTNESSUP, KEY_BRIGHTNESSDOWN,
57
                KEY_EJECTCD, 0, 0, 0, 0,                    /* 0x38-0x3f */
58
        0, 0, 0, 0, 0, 0, 0, KEY_HOME,                         /* 0x40-0x47 */
59
        KEY_UP, KEY_PAGEUP, 0, KEY_LEFT, 0, KEY_RIGHT, 0, KEY_END, /* 0x48-0x4f */
60
        KEY_DOWN, KEY_PAGEDOWN, KEY_INSERT, KEY_DELETE, 0, 0, 0, 0, /* 0x50-0x57 */
61
        0, 0, 0, KEY_LEFTMETA, KEY_RIGHTMETA, KEY_COMPOSE, KEY_POWER, 0, /* 0x58-0x5f */
62
        0, 0, 0, 0, 0, 0, 0, 0,                                 /* 0x60-0x67 */
63
        0, 0, 0, 0, 0, 0, 0, KEY_MACRO,                                /* 0x68-0x6f */
64
        0, 0, 0, 0, 0, 0, 0, 0,                                 /* 0x70-0x77 */
65
        0, 0, 0, 0, 0, 0, 0, 0                                  /* 0x78-0x7f */
66
};
67
 
68
int kbd_translate(unsigned char scancode, unsigned char *keycode,
69
        char raw_mode)
70
{
71
        /* This code was copied from char/pc_keyb.c and will be
72
         * superflous when the input layer is fully integrated.
73
         * We don't need the high_keys handling, so this part
74
         * has been removed.
75
         */
76
        static int prev_scancode = 0;
77
 
78
        /* special prefix scancodes.. */
79
        if (scancode == 0xe0 || scancode == 0xe1) {
80
                prev_scancode = scancode;
81
                return 0;
82
        }
83
 
84
        scancode &= 0x7f;
85
 
86
        if (prev_scancode) {
87
                if (prev_scancode != 0xe0) {
88
                        if (prev_scancode == 0xe1 && scancode == 0x1d) {
89
                                prev_scancode = 0x100;
90
                                return 0;
91
                        } else if (prev_scancode == 0x100 && scancode == 0x45) {
92
                                *keycode = KEY_PAUSE;
93
                                prev_scancode = 0;
94
                        } else {
95
                                if (!raw_mode)
96
                                        printk(KERN_INFO "keyboard: unknown e1 escape sequence\n");
97
                                prev_scancode = 0;
98
                                return 0;
99
                        }
100
                } else {
101
                        prev_scancode = 0;
102
                        if (scancode == 0x2a || scancode == 0x36)
103
                                return 0;
104
                }
105
                if (e0_keys[scancode])
106
                        *keycode = e0_keys[scancode];
107
                else {
108
                        if (!raw_mode)
109
                                printk(KERN_INFO "keyboard: unknown scancode e0 %02x\n",
110
                                       scancode);
111
                        return 0;
112
                }
113
        } else {
114
                switch (scancode) {
115
                case  91: scancode = KEY_LINEFEED; break;
116
                case  92: scancode = KEY_KPEQUAL; break;
117
                case 125: scancode = KEY_INTL1; break;
118
                }
119
                *keycode = scancode;
120
        }
121
        return 1;
122
}
123
 
124
#else
125
int kbd_translate(unsigned char scancode, unsigned char *keycode,
126
        char raw_mode)
127
{
128
        *keycode = scancode;
129
 
130
        return 1;
131
}
132
#endif
133
 
134
char kbd_unexpected_up(unsigned char keycode)
135
{
136
        return 0x80;
137
}
138
 
139
void __init kbd_init_hw(void)
140
{
141
        printk("Dummy keyboard driver installed.\n");
142
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.