1 /*
2 * linux/drivers/video/sticon.c - console driver using HP's STI firmware
3 *
4 * Copyright (C) 2000 Philipp Rumpf <prumpf@tux.org>
5 *
6 * Based on linux/drivers/video/vgacon.c and linux/drivers/video/fbcon.c,
7 * which were
8 *
9 * Created 28 Sep 1997 by Geert Uytterhoeven
10 * Rewritten by Martin Mares <mj@ucw.cz>, July 1998
11 * Copyright (C) 1991, 1992 Linus Torvalds
12 * 1995 Jay Estabrook
13 * Copyright (C) 1995 Geert Uytterhoeven
14 * Copyright (C) 1993 Bjoern Brauel
15 * Roman Hodek
16 * Copyright (C) 1993 Hamish Macdonald
17 * Greg Harp
18 * Copyright (C) 1994 David Carter [carter@compsci.bristol.ac.uk]
19 *
20 * with work by William Rucklidge (wjr@cs.cornell.edu)
21 * Geert Uytterhoeven
22 * Jes Sorensen (jds@kom.auc.dk)
23 * Martin Apel
24 * with work by Guenther Kelleter
25 * Martin Schaller
26 * Andreas Schwab
27 * Emmanuel Marty (core@ggi-project.org)
28 * Jakub Jelinek (jj@ultra.linux.cz)
29 * Martin Mares <mj@ucw.cz>
30 *
31 * This file is subject to the terms and conditions of the GNU General Public
32 * License. See the file COPYING in the main directory of this archive for
33 * more details.
34 */
35 /*
36 * TODO:
37 * - call STI in virtual mode rather than in real mode
38 * - support for PCI-only STI ROMs (which don't have a traditional region
39 * list)
40 * - safe detection (i.e. verify there is a graphics device at a given
41 * address first, not just read a random device's io space)
42 * - support for multiple STI devices in one machine
43 * - support for byte-mode STI ROMs
44 * - support for just using STI to switch to a colour fb (stifb ?)
45 * - try to make it work on m68k hp workstations ;)
46 */
47
48 #include <linux/init.h>
49 #include <linux/kernel.h>
50 #include <linux/tty.h>
51 #include <linux/console.h>
52 #include <linux/console_struct.h>
53 #include <linux/errno.h>
54 #include <linux/vt_kern.h>
55 #include <linux/selection.h>
56
57 #include <asm/io.h>
58
59 #include "sti.h"
60
61 /* STICON */
62
63 static const char * __init
64 sticon_startup(void)
65 {
66 return "STI console";
67 }
68
69 static int
70 sticon_set_palette(struct vc_data *c, unsigned char *table)
71 {
72 return -EINVAL;
73 }
74 static int
75 sticon_font_op(struct vc_data *c, struct console_font_op *op)
76 {
77 return -ENOSYS;
78 }
79
80 static void sticon_putc(struct vc_data *conp, int c, int ypos, int xpos)
81 {
82 sti_putc(&default_sti, c, ypos, xpos);
83 }
84
85 static void sticon_putcs(struct vc_data *conp, const unsigned short *s,
86 int count, int ypos, int xpos)
87 {
88 while(count--) {
89 sti_putc(&default_sti, *s++, ypos, xpos++);
90 }
91 }
92
93 static void sticon_cursor(struct vc_data *conp, int mode)
94 {
95 }
96
97 static int sticon_scroll(struct vc_data *conp, int t, int b, int dir,
98 int count)
99 {
100 struct sti_struct *sti = &default_sti;
101
102 if(console_blanked)
103 return 0;
104
105 sticon_cursor(conp, CM_ERASE);
106
107 switch(dir) {
108 case SM_UP:
109 sti_bmove(sti, t+count, 0, t, 0, b-t-count, conp->vc_cols);
110 sti_clear(sti, b-count, 0, count, conp->vc_cols);
111
112 break;
113
114 case SM_DOWN:
115 sti_bmove(sti, t, 0, t+count, 0, b-t-count, conp->vc_cols);
116 sti_clear(sti, t, 0, count, conp->vc_cols);
117
118 break;
119 }
120
121 return 0;
122 }
123
124 static void sticon_bmove(struct vc_data *conp, int sy, int sx, int dy, int dx,
125 int height, int width)
126 {
127 sti_bmove(&default_sti, sy, sx, dy, dx, height, width);
128 }
129
130 static void sticon_init(struct vc_data *c, int init)
131 {
132 struct sti_struct *sti = &default_sti;
133 int vc_cols, vc_rows;
134
135 sti_set(sti, 0, 0, sti_onscreen_y(sti), sti_onscreen_x(sti), 0);
136 c->vc_can_do_color = 1;
137 vc_cols = PTR_STI(sti->glob_cfg)->onscreen_x / sti_font_x(sti);
138 vc_rows = PTR_STI(sti->glob_cfg)->onscreen_y / sti_font_y(sti);
139
140 vc_resize_con(vc_rows, vc_cols, c->vc_num);
141 }
142
143 static void sticon_deinit(struct vc_data *c)
144 {
145 }
146
147 static void sticon_clear(struct vc_data *conp, int sy, int sx, int height,
148 int width)
149 {
150 sti_clear(&default_sti, sy, sx, height, width);
151 }
152
153 static int sticon_switch(struct vc_data *conp)
154 {
155 return 0;
156 }
157
158 static int sticon_blank(struct vc_data *conp, int blank)
159 {
160 return 0;
161 }
162
163 static int sticon_scrolldelta(struct vc_data *conp, int lines)
164 {
165 return 0;
166 }
167
168 static int sticon_set_origin(struct vc_data *conp)
169 {
170 return 0;
171 }
172
173 static u16 *sticon_screen_pos(struct vc_data *conp, int offset)
174 {
175 return NULL;
176 }
177
178 static unsigned long sticon_getxy(struct vc_data *conp, unsigned long pos, int *px, int *py)
179 {
180 return 0;
181 }
182
183 static u8 sticon_build_attr(struct vc_data *conp, u8 color, u8 intens, u8 blink, u8 underline, u8 reverse)
184 {
185 u8 attr = ((color & 0x70) >> 1) | ((color & 7));
186
187 if(reverse) {
188 color = ((color>>3)&0x7) | ((color &0x7)<<3);
189 }
190
191
192 return attr;
193 }
194
195 struct consw sti_con = {
196 con_startup: sticon_startup,
197 con_init: sticon_init,
198 con_deinit: sticon_deinit,
199 con_clear: sticon_clear,
200 con_putc: sticon_putc,
201 con_putcs: sticon_putcs,
202 con_cursor: sticon_cursor,
203 con_scroll: sticon_scroll,
204 con_bmove: sticon_bmove,
205 con_switch: sticon_switch,
206 con_blank: sticon_blank,
207 con_font_op: sticon_font_op,
208 con_set_palette: sticon_set_palette,
209 con_scrolldelta: sticon_scrolldelta,
210 con_set_origin: sticon_set_origin,
211 con_save_screen: NULL,
212 con_build_attr: sticon_build_attr,
213 con_invert_region: NULL,
214 con_screen_pos: sticon_screen_pos,
215 con_getxy: sticon_getxy,
216 };
217
218 static int __init sti_init(void)
219 {
220 printk("searching for word mode STI ROMs\n");
221 if (sti_init_roms()) {
222 pdc_console_die();
223 take_over_console(&sti_con, 0, MAX_NR_CONSOLES-1, 1);
224 return 0;
225 } else
226 return -ENODEV;
227 }
228
229 module_init(sti_init)
230
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.