diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-09-14 16:33:33 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-09-14 16:33:33 -0400 |
commit | 503f04530fec97f93673ae9048b5312cc4455cfe (patch) | |
tree | 7032c4a766b00e992eaf78f2f95f0f6bc4f4af6b /drivers/video/console | |
parent | 939ae58960bb5ce0c51776aec38877a401c03bcf (diff) | |
parent | 23e9f4ef99dd313fc8d19c326f6518459a402d71 (diff) |
Merge tag 'fbdev-v4.14' of git://github.com/bzolnier/linux
Pull fbdev updates from Bartlomiej Zolnierkiewicz:
- make fbcon a built-time depency for fbdev (fbcon was tristate option
before, now it is a bool) - this is a first step in preparations for
making console_lock usage saner (currently it acts like the BKL for
all things fbdev/fbcon) (Daniel Vetter)
- add fbcon=margin:<color> command line option to select the fbcon
margin color (David Lechner)
- add DMI quirk table for x86 systems which need fbcon rotation
(devices like Asus T100HA, GPD Pocket, the GPD win and the I.T.Works
TW891) (Hans de Goede)
- fix 1bpp logo support for unusual width (needed by LEGO MINDSTORMS
EV3) (David Lechner)
- enable Xilinx FB driver for ARM ZynqMP platform (Michal Simek)
- fix use after free in the error path of udlfb driver (Anton Vasilyev)
- fix error return code handling in pxa3xx_gcu driver (Gustavo A. R.
Silva)
- fix bootparams.screeninfo arguments checking in vgacon (Jan H.
Schönherr)
- do not leak uninitialized padding in clk to userspace in the debug
code of atyfb driver (Vladis Dronov)
- fix compiler warnings in fbcon code and matroxfb driver (Arnd
Bergmann)
- convert fbdev susbsytem to using %pOF instead of full_name (Rob
Herring)
- structures constifications (Arvind Yadav, Bhumika Goyal, Gustavo A.
R. Silva, Julia Lawall)
- misc cleanups (Gustavo A. R. Silva, Hyun Kwon, Julia Lawall, Kuninori
Morimoto, Lynn Lei)
* tag 'fbdev-v4.14' of git://github.com/bzolnier/linux: (75 commits)
video/console: Update BIOS dates list for GPD win console rotation DMI quirk
video/console: Add rotated LCD-panel DMI quirk for the VIOS LTH17
video: fbdev: sis: fix duplicated code for different branches
video: fbdev: make fb_var_screeninfo const
video: fbdev: aty: do not leak uninitialized padding in clk to userspace
vgacon: Prevent faulty bootparams.screeninfo from causing harm
video: fbdev: make fb_videomode const
video/console: Add new BIOS date for GPD pocket to dmi quirk table
fbcon: remove restriction on margin color
video: ARM CLCD: constify amba_id
video: fm2fb: constify zorro_device_id
video: fbdev: annotate fb_fix_screeninfo with const and __initconst
omapfb: constify omap_video_timings structures
video: fbdev: udlfb: Fix use after free on dlfb_usb_probe error path
fbdev: i810: make fb_ops const
fbdev: matrox: make fb_ops const
video: fbdev: pxa3xx_gcu: fix error return code in pxa3xx_gcu_probe()
video: fbdev: Enable Xilinx FB for ZynqMP
video: fbdev: Fix multiple style issues in xilinxfb
video: fbdev: udlfb: constify usb_device_id.
...
Diffstat (limited to 'drivers/video/console')
-rw-r--r-- | drivers/video/console/Kconfig | 2 | ||||
-rw-r--r-- | drivers/video/console/Makefile | 8 | ||||
-rw-r--r-- | drivers/video/console/bitblit.c | 422 | ||||
-rw-r--r-- | drivers/video/console/fbcon.c | 3665 | ||||
-rw-r--r-- | drivers/video/console/fbcon.h | 265 | ||||
-rw-r--r-- | drivers/video/console/fbcon_ccw.c | 424 | ||||
-rw-r--r-- | drivers/video/console/fbcon_cw.c | 407 | ||||
-rw-r--r-- | drivers/video/console/fbcon_rotate.c | 116 | ||||
-rw-r--r-- | drivers/video/console/fbcon_rotate.h | 96 | ||||
-rw-r--r-- | drivers/video/console/fbcon_ud.c | 452 | ||||
-rw-r--r-- | drivers/video/console/softcursor.c | 82 | ||||
-rw-r--r-- | drivers/video/console/tileblit.c | 159 | ||||
-rw-r--r-- | drivers/video/console/vgacon.c | 5 |
13 files changed, 3 insertions, 6100 deletions
diff --git a/drivers/video/console/Kconfig b/drivers/video/console/Kconfig index 2111d06f8c81..7f1f1fbcef9e 100644 --- a/drivers/video/console/Kconfig +++ b/drivers/video/console/Kconfig | |||
@@ -117,7 +117,7 @@ config DUMMY_CONSOLE_ROWS | |||
117 | Select 25 if you use a 640x480 resolution by default. | 117 | Select 25 if you use a 640x480 resolution by default. |
118 | 118 | ||
119 | config FRAMEBUFFER_CONSOLE | 119 | config FRAMEBUFFER_CONSOLE |
120 | tristate "Framebuffer Console support" | 120 | bool "Framebuffer Console support" |
121 | depends on FB && !UML | 121 | depends on FB && !UML |
122 | select VT_HW_CONSOLE_BINDING | 122 | select VT_HW_CONSOLE_BINDING |
123 | select CRC32 | 123 | select CRC32 |
diff --git a/drivers/video/console/Makefile b/drivers/video/console/Makefile index 43bfa485db96..eb2cbec52643 100644 --- a/drivers/video/console/Makefile +++ b/drivers/video/console/Makefile | |||
@@ -7,13 +7,5 @@ obj-$(CONFIG_SGI_NEWPORT_CONSOLE) += newport_con.o | |||
7 | obj-$(CONFIG_STI_CONSOLE) += sticon.o sticore.o | 7 | obj-$(CONFIG_STI_CONSOLE) += sticon.o sticore.o |
8 | obj-$(CONFIG_VGA_CONSOLE) += vgacon.o | 8 | obj-$(CONFIG_VGA_CONSOLE) += vgacon.o |
9 | obj-$(CONFIG_MDA_CONSOLE) += mdacon.o | 9 | obj-$(CONFIG_MDA_CONSOLE) += mdacon.o |
10 | obj-$(CONFIG_FRAMEBUFFER_CONSOLE) += fbcon.o bitblit.o softcursor.o | ||
11 | ifeq ($(CONFIG_FB_TILEBLITTING),y) | ||
12 | obj-$(CONFIG_FRAMEBUFFER_CONSOLE) += tileblit.o | ||
13 | endif | ||
14 | ifeq ($(CONFIG_FRAMEBUFFER_CONSOLE_ROTATION),y) | ||
15 | obj-$(CONFIG_FRAMEBUFFER_CONSOLE) += fbcon_rotate.o fbcon_cw.o fbcon_ud.o \ | ||
16 | fbcon_ccw.o | ||
17 | endif | ||
18 | 10 | ||
19 | obj-$(CONFIG_FB_STI) += sticore.o | 11 | obj-$(CONFIG_FB_STI) += sticore.o |
diff --git a/drivers/video/console/bitblit.c b/drivers/video/console/bitblit.c deleted file mode 100644 index dbfe4eecf12e..000000000000 --- a/drivers/video/console/bitblit.c +++ /dev/null | |||
@@ -1,422 +0,0 @@ | |||
1 | /* | ||
2 | * linux/drivers/video/console/bitblit.c -- BitBlitting Operation | ||
3 | * | ||
4 | * Originally from the 'accel_*' routines in drivers/video/console/fbcon.c | ||
5 | * | ||
6 | * Copyright (C) 2004 Antonino Daplas <adaplas @pol.net> | ||
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 for | ||
10 | * more details. | ||
11 | */ | ||
12 | |||
13 | #include <linux/module.h> | ||
14 | #include <linux/slab.h> | ||
15 | #include <linux/string.h> | ||
16 | #include <linux/fb.h> | ||
17 | #include <linux/vt_kern.h> | ||
18 | #include <linux/console.h> | ||
19 | #include <asm/types.h> | ||
20 | #include "fbcon.h" | ||
21 | |||
22 | /* | ||
23 | * Accelerated handlers. | ||
24 | */ | ||
25 | static void update_attr(u8 *dst, u8 *src, int attribute, | ||
26 | struct vc_data *vc) | ||
27 | { | ||
28 | int i, offset = (vc->vc_font.height < 10) ? 1 : 2; | ||
29 | int width = DIV_ROUND_UP(vc->vc_font.width, 8); | ||
30 | unsigned int cellsize = vc->vc_font.height * width; | ||
31 | u8 c; | ||
32 | |||
33 | offset = cellsize - (offset * width); | ||
34 | for (i = 0; i < cellsize; i++) { | ||
35 | c = src[i]; | ||
36 | if (attribute & FBCON_ATTRIBUTE_UNDERLINE && i >= offset) | ||
37 | c = 0xff; | ||
38 | if (attribute & FBCON_ATTRIBUTE_BOLD) | ||
39 | c |= c >> 1; | ||
40 | if (attribute & FBCON_ATTRIBUTE_REVERSE) | ||
41 | c = ~c; | ||
42 | dst[i] = c; | ||
43 | } | ||
44 | } | ||
45 | |||
46 | static void bit_bmove(struct vc_data *vc, struct fb_info *info, int sy, | ||
47 | int sx, int dy, int dx, int height, int width) | ||
48 | { | ||
49 | struct fb_copyarea area; | ||
50 | |||
51 | area.sx = sx * vc->vc_font.width; | ||
52 | area.sy = sy * vc->vc_font.height; | ||
53 | area.dx = dx * vc->vc_font.width; | ||
54 | area.dy = dy * vc->vc_font.height; | ||
55 | area.height = height * vc->vc_font.height; | ||
56 | area.width = width * vc->vc_font.width; | ||
57 | |||
58 | info->fbops->fb_copyarea(info, &area); | ||
59 | } | ||
60 | |||
61 | static void bit_clear(struct vc_data *vc, struct fb_info *info, int sy, | ||
62 | int sx, int height, int width) | ||
63 | { | ||
64 | int bgshift = (vc->vc_hi_font_mask) ? 13 : 12; | ||
65 | struct fb_fillrect region; | ||
66 | |||
67 | region.color = attr_bgcol_ec(bgshift, vc, info); | ||
68 | region.dx = sx * vc->vc_font.width; | ||
69 | region.dy = sy * vc->vc_font.height; | ||
70 | region.width = width * vc->vc_font.width; | ||
71 | region.height = height * vc->vc_font.height; | ||
72 | region.rop = ROP_COPY; | ||
73 | |||
74 | info->fbops->fb_fillrect(info, ®ion); | ||
75 | } | ||
76 | |||
77 | static inline void bit_putcs_aligned(struct vc_data *vc, struct fb_info *info, | ||
78 | const u16 *s, u32 attr, u32 cnt, | ||
79 | u32 d_pitch, u32 s_pitch, u32 cellsize, | ||
80 | struct fb_image *image, u8 *buf, u8 *dst) | ||
81 | { | ||
82 | u16 charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff; | ||
83 | u32 idx = vc->vc_font.width >> 3; | ||
84 | u8 *src; | ||
85 | |||
86 | while (cnt--) { | ||
87 | src = vc->vc_font.data + (scr_readw(s++)& | ||
88 | charmask)*cellsize; | ||
89 | |||
90 | if (attr) { | ||
91 | update_attr(buf, src, attr, vc); | ||
92 | src = buf; | ||
93 | } | ||
94 | |||
95 | if (likely(idx == 1)) | ||
96 | __fb_pad_aligned_buffer(dst, d_pitch, src, idx, | ||
97 | image->height); | ||
98 | else | ||
99 | fb_pad_aligned_buffer(dst, d_pitch, src, idx, | ||
100 | image->height); | ||
101 | |||
102 | dst += s_pitch; | ||
103 | } | ||
104 | |||
105 | info->fbops->fb_imageblit(info, image); | ||
106 | } | ||
107 | |||
108 | static inline void bit_putcs_unaligned(struct vc_data *vc, | ||
109 | struct fb_info *info, const u16 *s, | ||
110 | u32 attr, u32 cnt, u32 d_pitch, | ||
111 | u32 s_pitch, u32 cellsize, | ||
112 | struct fb_image *image, u8 *buf, | ||
113 | u8 *dst) | ||
114 | { | ||
115 | u16 charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff; | ||
116 | u32 shift_low = 0, mod = vc->vc_font.width % 8; | ||
117 | u32 shift_high = 8; | ||
118 | u32 idx = vc->vc_font.width >> 3; | ||
119 | u8 *src; | ||
120 | |||
121 | while (cnt--) { | ||
122 | src = vc->vc_font.data + (scr_readw(s++)& | ||
123 | charmask)*cellsize; | ||
124 | |||
125 | if (attr) { | ||
126 | update_attr(buf, src, attr, vc); | ||
127 | src = buf; | ||
128 | } | ||
129 | |||
130 | fb_pad_unaligned_buffer(dst, d_pitch, src, idx, | ||
131 | image->height, shift_high, | ||
132 | shift_low, mod); | ||
133 | shift_low += mod; | ||
134 | dst += (shift_low >= 8) ? s_pitch : s_pitch - 1; | ||
135 | shift_low &= 7; | ||
136 | shift_high = 8 - shift_low; | ||
137 | } | ||
138 | |||
139 | info->fbops->fb_imageblit(info, image); | ||
140 | |||
141 | } | ||
142 | |||
143 | static void bit_putcs(struct vc_data *vc, struct fb_info *info, | ||
144 | const unsigned short *s, int count, int yy, int xx, | ||
145 | int fg, int bg) | ||
146 | { | ||
147 | struct fb_image image; | ||
148 | u32 width = DIV_ROUND_UP(vc->vc_font.width, 8); | ||
149 | u32 cellsize = width * vc->vc_font.height; | ||
150 | u32 maxcnt = info->pixmap.size/cellsize; | ||
151 | u32 scan_align = info->pixmap.scan_align - 1; | ||
152 | u32 buf_align = info->pixmap.buf_align - 1; | ||
153 | u32 mod = vc->vc_font.width % 8, cnt, pitch, size; | ||
154 | u32 attribute = get_attribute(info, scr_readw(s)); | ||
155 | u8 *dst, *buf = NULL; | ||
156 | |||
157 | image.fg_color = fg; | ||
158 | image.bg_color = bg; | ||
159 | image.dx = xx * vc->vc_font.width; | ||
160 | image.dy = yy * vc->vc_font.height; | ||
161 | image.height = vc->vc_font.height; | ||
162 | image.depth = 1; | ||
163 | |||
164 | if (attribute) { | ||
165 | buf = kmalloc(cellsize, GFP_ATOMIC); | ||
166 | if (!buf) | ||
167 | return; | ||
168 | } | ||
169 | |||
170 | while (count) { | ||
171 | if (count > maxcnt) | ||
172 | cnt = maxcnt; | ||
173 | else | ||
174 | cnt = count; | ||
175 | |||
176 | image.width = vc->vc_font.width * cnt; | ||
177 | pitch = DIV_ROUND_UP(image.width, 8) + scan_align; | ||
178 | pitch &= ~scan_align; | ||
179 | size = pitch * image.height + buf_align; | ||
180 | size &= ~buf_align; | ||
181 | dst = fb_get_buffer_offset(info, &info->pixmap, size); | ||
182 | image.data = dst; | ||
183 | |||
184 | if (!mod) | ||
185 | bit_putcs_aligned(vc, info, s, attribute, cnt, pitch, | ||
186 | width, cellsize, &image, buf, dst); | ||
187 | else | ||
188 | bit_putcs_unaligned(vc, info, s, attribute, cnt, | ||
189 | pitch, width, cellsize, &image, | ||
190 | buf, dst); | ||
191 | |||
192 | image.dx += cnt * vc->vc_font.width; | ||
193 | count -= cnt; | ||
194 | s += cnt; | ||
195 | } | ||
196 | |||
197 | /* buf is always NULL except when in monochrome mode, so in this case | ||
198 | it's a gain to check buf against NULL even though kfree() handles | ||
199 | NULL pointers just fine */ | ||
200 | if (unlikely(buf)) | ||
201 | kfree(buf); | ||
202 | |||
203 | } | ||
204 | |||
205 | static void bit_clear_margins(struct vc_data *vc, struct fb_info *info, | ||
206 | int bottom_only) | ||
207 | { | ||
208 | unsigned int cw = vc->vc_font.width; | ||
209 | unsigned int ch = vc->vc_font.height; | ||
210 | unsigned int rw = info->var.xres - (vc->vc_cols*cw); | ||
211 | unsigned int bh = info->var.yres - (vc->vc_rows*ch); | ||
212 | unsigned int rs = info->var.xres - rw; | ||
213 | unsigned int bs = info->var.yres - bh; | ||
214 | struct fb_fillrect region; | ||
215 | |||
216 | region.color = 0; | ||
217 | region.rop = ROP_COPY; | ||
218 | |||
219 | if (rw && !bottom_only) { | ||
220 | region.dx = info->var.xoffset + rs; | ||
221 | region.dy = 0; | ||
222 | region.width = rw; | ||
223 | region.height = info->var.yres_virtual; | ||
224 | info->fbops->fb_fillrect(info, ®ion); | ||
225 | } | ||
226 | |||
227 | if (bh) { | ||
228 | region.dx = info->var.xoffset; | ||
229 | region.dy = info->var.yoffset + bs; | ||
230 | region.width = rs; | ||
231 | region.height = bh; | ||
232 | info->fbops->fb_fillrect(info, ®ion); | ||
233 | } | ||
234 | } | ||
235 | |||
236 | static void bit_cursor(struct vc_data *vc, struct fb_info *info, int mode, | ||
237 | int softback_lines, int fg, int bg) | ||
238 | { | ||
239 | struct fb_cursor cursor; | ||
240 | struct fbcon_ops *ops = info->fbcon_par; | ||
241 | unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff; | ||
242 | int w = DIV_ROUND_UP(vc->vc_font.width, 8), c; | ||
243 | int y = real_y(ops->p, vc->vc_y); | ||
244 | int attribute, use_sw = (vc->vc_cursor_type & 0x10); | ||
245 | int err = 1; | ||
246 | char *src; | ||
247 | |||
248 | cursor.set = 0; | ||
249 | |||
250 | if (softback_lines) { | ||
251 | if (y + softback_lines >= vc->vc_rows) { | ||
252 | mode = CM_ERASE; | ||
253 | ops->cursor_flash = 0; | ||
254 | return; | ||
255 | } else | ||
256 | y += softback_lines; | ||
257 | } | ||
258 | |||
259 | c = scr_readw((u16 *) vc->vc_pos); | ||
260 | attribute = get_attribute(info, c); | ||
261 | src = vc->vc_font.data + ((c & charmask) * (w * vc->vc_font.height)); | ||
262 | |||
263 | if (ops->cursor_state.image.data != src || | ||
264 | ops->cursor_reset) { | ||
265 | ops->cursor_state.image.data = src; | ||
266 | cursor.set |= FB_CUR_SETIMAGE; | ||
267 | } | ||
268 | |||
269 | if (attribute) { | ||
270 | u8 *dst; | ||
271 | |||
272 | dst = kmalloc(w * vc->vc_font.height, GFP_ATOMIC); | ||
273 | if (!dst) | ||
274 | return; | ||
275 | kfree(ops->cursor_data); | ||
276 | ops->cursor_data = dst; | ||
277 | update_attr(dst, src, attribute, vc); | ||
278 | src = dst; | ||
279 | } | ||
280 | |||
281 | if (ops->cursor_state.image.fg_color != fg || | ||
282 | ops->cursor_state.image.bg_color != bg || | ||
283 | ops->cursor_reset) { | ||
284 | ops->cursor_state.image.fg_color = fg; | ||
285 | ops->cursor_state.image.bg_color = bg; | ||
286 | cursor.set |= FB_CUR_SETCMAP; | ||
287 | } | ||
288 | |||
289 | if ((ops->cursor_state.image.dx != (vc->vc_font.width * vc->vc_x)) || | ||
290 | (ops->cursor_state.image.dy != (vc->vc_font.height * y)) || | ||
291 | ops->cursor_reset) { | ||
292 | ops->cursor_state.image.dx = vc->vc_font.width * vc->vc_x; | ||
293 | ops->cursor_state.image.dy = vc->vc_font.height * y; | ||
294 | cursor.set |= FB_CUR_SETPOS; | ||
295 | } | ||
296 | |||
297 | if (ops->cursor_state.image.height != vc->vc_font.height || | ||
298 | ops->cursor_state.image.width != vc->vc_font.width || | ||
299 | ops->cursor_reset) { | ||
300 | ops->cursor_state.image.height = vc->vc_font.height; | ||
301 | ops->cursor_state.image.width = vc->vc_font.width; | ||
302 | cursor.set |= FB_CUR_SETSIZE; | ||
303 | } | ||
304 | |||
305 | if (ops->cursor_state.hot.x || ops->cursor_state.hot.y || | ||
306 | ops->cursor_reset) { | ||
307 | ops->cursor_state.hot.x = cursor.hot.y = 0; | ||
308 | cursor.set |= FB_CUR_SETHOT; | ||
309 | } | ||
310 | |||
311 | if (cursor.set & FB_CUR_SETSIZE || | ||
312 | vc->vc_cursor_type != ops->p->cursor_shape || | ||
313 | ops->cursor_state.mask == NULL || | ||
314 | ops->cursor_reset) { | ||
315 | char *mask = kmalloc(w*vc->vc_font.height, GFP_ATOMIC); | ||
316 | int cur_height, size, i = 0; | ||
317 | u8 msk = 0xff; | ||
318 | |||
319 | if (!mask) | ||
320 | return; | ||
321 | |||
322 | kfree(ops->cursor_state.mask); | ||
323 | ops->cursor_state.mask = mask; | ||
324 | |||
325 | ops->p->cursor_shape = vc->vc_cursor_type; | ||
326 | cursor.set |= FB_CUR_SETSHAPE; | ||
327 | |||
328 | switch (ops->p->cursor_shape & CUR_HWMASK) { | ||
329 | case CUR_NONE: | ||
330 | cur_height = 0; | ||
331 | break; | ||
332 | case CUR_UNDERLINE: | ||
333 | cur_height = (vc->vc_font.height < 10) ? 1 : 2; | ||
334 | break; | ||
335 | case CUR_LOWER_THIRD: | ||
336 | cur_height = vc->vc_font.height/3; | ||
337 | break; | ||
338 | case CUR_LOWER_HALF: | ||
339 | cur_height = vc->vc_font.height >> 1; | ||
340 | break; | ||
341 | case CUR_TWO_THIRDS: | ||
342 | cur_height = (vc->vc_font.height << 1)/3; | ||
343 | break; | ||
344 | case CUR_BLOCK: | ||
345 | default: | ||
346 | cur_height = vc->vc_font.height; | ||
347 | break; | ||
348 | } | ||
349 | size = (vc->vc_font.height - cur_height) * w; | ||
350 | while (size--) | ||
351 | mask[i++] = ~msk; | ||
352 | size = cur_height * w; | ||
353 | while (size--) | ||
354 | mask[i++] = msk; | ||
355 | } | ||
356 | |||
357 | switch (mode) { | ||
358 | case CM_ERASE: | ||
359 | ops->cursor_state.enable = 0; | ||
360 | break; | ||
361 | case CM_DRAW: | ||
362 | case CM_MOVE: | ||
363 | default: | ||
364 | ops->cursor_state.enable = (use_sw) ? 0 : 1; | ||
365 | break; | ||
366 | } | ||
367 | |||
368 | cursor.image.data = src; | ||
369 | cursor.image.fg_color = ops->cursor_state.image.fg_color; | ||
370 | cursor.image.bg_color = ops->cursor_state.image.bg_color; | ||
371 | cursor.image.dx = ops->cursor_state.image.dx; | ||
372 | cursor.image.dy = ops->cursor_state.image.dy; | ||
373 | cursor.image.height = ops->cursor_state.image.height; | ||
374 | cursor.image.width = ops->cursor_state.image.width; | ||
375 | cursor.hot.x = ops->cursor_state.hot.x; | ||
376 | cursor.hot.y = ops->cursor_state.hot.y; | ||
377 | cursor.mask = ops->cursor_state.mask; | ||
378 | cursor.enable = ops->cursor_state.enable; | ||
379 | cursor.image.depth = 1; | ||
380 | cursor.rop = ROP_XOR; | ||
381 | |||
382 | if (info->fbops->fb_cursor) | ||
383 | err = info->fbops->fb_cursor(info, &cursor); | ||
384 | |||
385 | if (err) | ||
386 | soft_cursor(info, &cursor); | ||
387 | |||
388 | ops->cursor_reset = 0; | ||
389 | } | ||
390 | |||
391 | static int bit_update_start(struct fb_info *info) | ||
392 | { | ||
393 | struct fbcon_ops *ops = info->fbcon_par; | ||
394 | int err; | ||
395 | |||
396 | err = fb_pan_display(info, &ops->var); | ||
397 | ops->var.xoffset = info->var.xoffset; | ||
398 | ops->var.yoffset = info->var.yoffset; | ||
399 | ops->var.vmode = info->var.vmode; | ||
400 | return err; | ||
401 | } | ||
402 | |||
403 | void fbcon_set_bitops(struct fbcon_ops *ops) | ||
404 | { | ||
405 | ops->bmove = bit_bmove; | ||
406 | ops->clear = bit_clear; | ||
407 | ops->putcs = bit_putcs; | ||
408 | ops->clear_margins = bit_clear_margins; | ||
409 | ops->cursor = bit_cursor; | ||
410 | ops->update_start = bit_update_start; | ||
411 | ops->rotate_font = NULL; | ||
412 | |||
413 | if (ops->rotate) | ||
414 | fbcon_set_rotate(ops); | ||
415 | } | ||
416 | |||
417 | EXPORT_SYMBOL(fbcon_set_bitops); | ||
418 | |||
419 | MODULE_AUTHOR("Antonino Daplas <adaplas@pol.net>"); | ||
420 | MODULE_DESCRIPTION("Bit Blitting Operation"); | ||
421 | MODULE_LICENSE("GPL"); | ||
422 | |||
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c deleted file mode 100644 index 12ded23f1aaf..000000000000 --- a/drivers/video/console/fbcon.c +++ /dev/null | |||
@@ -1,3665 +0,0 @@ | |||
1 | /* | ||
2 | * linux/drivers/video/fbcon.c -- Low level frame buffer based console driver | ||
3 | * | ||
4 | * Copyright (C) 1995 Geert Uytterhoeven | ||
5 | * | ||
6 | * | ||
7 | * This file is based on the original Amiga console driver (amicon.c): | ||
8 | * | ||
9 | * Copyright (C) 1993 Hamish Macdonald | ||
10 | * Greg Harp | ||
11 | * Copyright (C) 1994 David Carter [carter@compsci.bristol.ac.uk] | ||
12 | * | ||
13 | * with work by William Rucklidge (wjr@cs.cornell.edu) | ||
14 | * Geert Uytterhoeven | ||
15 | * Jes Sorensen (jds@kom.auc.dk) | ||
16 | * Martin Apel | ||
17 | * | ||
18 | * and on the original Atari console driver (atacon.c): | ||
19 | * | ||
20 | * Copyright (C) 1993 Bjoern Brauel | ||
21 | * Roman Hodek | ||
22 | * | ||
23 | * with work by Guenther Kelleter | ||
24 | * Martin Schaller | ||
25 | * Andreas Schwab | ||
26 | * | ||
27 | * Hardware cursor support added by Emmanuel Marty (core@ggi-project.org) | ||
28 | * Smart redraw scrolling, arbitrary font width support, 512char font support | ||
29 | * and software scrollback added by | ||
30 | * Jakub Jelinek (jj@ultra.linux.cz) | ||
31 | * | ||
32 | * Random hacking by Martin Mares <mj@ucw.cz> | ||
33 | * | ||
34 | * 2001 - Documented with DocBook | ||
35 | * - Brad Douglas <brad@neruo.com> | ||
36 | * | ||
37 | * The low level operations for the various display memory organizations are | ||
38 | * now in separate source files. | ||
39 | * | ||
40 | * Currently the following organizations are supported: | ||
41 | * | ||
42 | * o afb Amiga bitplanes | ||
43 | * o cfb{2,4,8,16,24,32} Packed pixels | ||
44 | * o ilbm Amiga interleaved bitplanes | ||
45 | * o iplan2p[248] Atari interleaved bitplanes | ||
46 | * o mfb Monochrome | ||
47 | * o vga VGA characters/attributes | ||
48 | * | ||
49 | * To do: | ||
50 | * | ||
51 | * - Implement 16 plane mode (iplan2p16) | ||
52 | * | ||
53 | * | ||
54 | * This file is subject to the terms and conditions of the GNU General Public | ||
55 | * License. See the file COPYING in the main directory of this archive for | ||
56 | * more details. | ||
57 | */ | ||
58 | |||
59 | #undef FBCONDEBUG | ||
60 | |||
61 | #include <linux/module.h> | ||
62 | #include <linux/types.h> | ||
63 | #include <linux/fs.h> | ||
64 | #include <linux/kernel.h> | ||
65 | #include <linux/delay.h> /* MSch: for IRQ probe */ | ||
66 | #include <linux/console.h> | ||
67 | #include <linux/string.h> | ||
68 | #include <linux/kd.h> | ||
69 | #include <linux/slab.h> | ||
70 | #include <linux/fb.h> | ||
71 | #include <linux/vt_kern.h> | ||
72 | #include <linux/selection.h> | ||
73 | #include <linux/font.h> | ||
74 | #include <linux/smp.h> | ||
75 | #include <linux/init.h> | ||
76 | #include <linux/interrupt.h> | ||
77 | #include <linux/crc32.h> /* For counting font checksums */ | ||
78 | #include <asm/fb.h> | ||
79 | #include <asm/irq.h> | ||
80 | |||
81 | #include "fbcon.h" | ||
82 | |||
83 | #ifdef FBCONDEBUG | ||
84 | # define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __func__ , ## args) | ||
85 | #else | ||
86 | # define DPRINTK(fmt, args...) | ||
87 | #endif | ||
88 | |||
89 | enum { | ||
90 | FBCON_LOGO_CANSHOW = -1, /* the logo can be shown */ | ||
91 | FBCON_LOGO_DRAW = -2, /* draw the logo to a console */ | ||
92 | FBCON_LOGO_DONTSHOW = -3 /* do not show the logo */ | ||
93 | }; | ||
94 | |||
95 | static struct display fb_display[MAX_NR_CONSOLES]; | ||
96 | |||
97 | static signed char con2fb_map[MAX_NR_CONSOLES]; | ||
98 | static signed char con2fb_map_boot[MAX_NR_CONSOLES]; | ||
99 | |||
100 | static int logo_lines; | ||
101 | /* logo_shown is an index to vc_cons when >= 0; otherwise follows FBCON_LOGO | ||
102 | enums. */ | ||
103 | static int logo_shown = FBCON_LOGO_CANSHOW; | ||
104 | /* Software scrollback */ | ||
105 | static int fbcon_softback_size = 32768; | ||
106 | static unsigned long softback_buf, softback_curr; | ||
107 | static unsigned long softback_in; | ||
108 | static unsigned long softback_top, softback_end; | ||
109 | static int softback_lines; | ||
110 | /* console mappings */ | ||
111 | static int first_fb_vc; | ||
112 | static int last_fb_vc = MAX_NR_CONSOLES - 1; | ||
113 | static int fbcon_is_default = 1; | ||
114 | static int fbcon_has_exited; | ||
115 | static int primary_device = -1; | ||
116 | static int fbcon_has_console_bind; | ||
117 | |||
118 | #ifdef CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY | ||
119 | static int map_override; | ||
120 | |||
121 | static inline void fbcon_map_override(void) | ||
122 | { | ||
123 | map_override = 1; | ||
124 | } | ||
125 | #else | ||
126 | static inline void fbcon_map_override(void) | ||
127 | { | ||
128 | } | ||
129 | #endif /* CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY */ | ||
130 | |||
131 | /* font data */ | ||
132 | static char fontname[40]; | ||
133 | |||
134 | /* current fb_info */ | ||
135 | static int info_idx = -1; | ||
136 | |||
137 | /* console rotation */ | ||
138 | static int initial_rotation; | ||
139 | static int fbcon_has_sysfs; | ||
140 | |||
141 | static const struct consw fb_con; | ||
142 | |||
143 | #define CM_SOFTBACK (8) | ||
144 | |||
145 | #define advance_row(p, delta) (unsigned short *)((unsigned long)(p) + (delta) * vc->vc_size_row) | ||
146 | |||
147 | static int fbcon_set_origin(struct vc_data *); | ||
148 | |||
149 | static int fbcon_cursor_noblink; | ||
150 | |||
151 | #define divides(a, b) ((!(a) || (b)%(a)) ? 0 : 1) | ||
152 | |||
153 | /* | ||
154 | * Interface used by the world | ||
155 | */ | ||
156 | |||
157 | static const char *fbcon_startup(void); | ||
158 | static void fbcon_init(struct vc_data *vc, int init); | ||
159 | static void fbcon_deinit(struct vc_data *vc); | ||
160 | static void fbcon_clear(struct vc_data *vc, int sy, int sx, int height, | ||
161 | int width); | ||
162 | static void fbcon_putc(struct vc_data *vc, int c, int ypos, int xpos); | ||
163 | static void fbcon_putcs(struct vc_data *vc, const unsigned short *s, | ||
164 | int count, int ypos, int xpos); | ||
165 | static void fbcon_clear_margins(struct vc_data *vc, int bottom_only); | ||
166 | static void fbcon_cursor(struct vc_data *vc, int mode); | ||
167 | static void fbcon_bmove(struct vc_data *vc, int sy, int sx, int dy, int dx, | ||
168 | int height, int width); | ||
169 | static int fbcon_switch(struct vc_data *vc); | ||
170 | static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch); | ||
171 | static void fbcon_set_palette(struct vc_data *vc, const unsigned char *table); | ||
172 | |||
173 | /* | ||
174 | * Internal routines | ||
175 | */ | ||
176 | static __inline__ void ywrap_up(struct vc_data *vc, int count); | ||
177 | static __inline__ void ywrap_down(struct vc_data *vc, int count); | ||
178 | static __inline__ void ypan_up(struct vc_data *vc, int count); | ||
179 | static __inline__ void ypan_down(struct vc_data *vc, int count); | ||
180 | static void fbcon_bmove_rec(struct vc_data *vc, struct display *p, int sy, int sx, | ||
181 | int dy, int dx, int height, int width, u_int y_break); | ||
182 | static void fbcon_set_disp(struct fb_info *info, struct fb_var_screeninfo *var, | ||
183 | int unit); | ||
184 | static void fbcon_redraw_move(struct vc_data *vc, struct display *p, | ||
185 | int line, int count, int dy); | ||
186 | static void fbcon_modechanged(struct fb_info *info); | ||
187 | static void fbcon_set_all_vcs(struct fb_info *info); | ||
188 | static void fbcon_start(void); | ||
189 | static void fbcon_exit(void); | ||
190 | static struct device *fbcon_device; | ||
191 | |||
192 | #ifdef CONFIG_FRAMEBUFFER_CONSOLE_ROTATION | ||
193 | static inline void fbcon_set_rotation(struct fb_info *info) | ||
194 | { | ||
195 | struct fbcon_ops *ops = info->fbcon_par; | ||
196 | |||
197 | if (!(info->flags & FBINFO_MISC_TILEBLITTING) && | ||
198 | ops->p->con_rotate < 4) | ||
199 | ops->rotate = ops->p->con_rotate; | ||
200 | else | ||
201 | ops->rotate = 0; | ||
202 | } | ||
203 | |||
204 | static void fbcon_rotate(struct fb_info *info, u32 rotate) | ||
205 | { | ||
206 | struct fbcon_ops *ops= info->fbcon_par; | ||
207 | struct fb_info *fb_info; | ||
208 | |||
209 | if (!ops || ops->currcon == -1) | ||
210 | return; | ||
211 | |||
212 | fb_info = registered_fb[con2fb_map[ops->currcon]]; | ||
213 | |||
214 | if (info == fb_info) { | ||
215 | struct display *p = &fb_display[ops->currcon]; | ||
216 | |||
217 | if (rotate < 4) | ||
218 | p->con_rotate = rotate; | ||
219 | else | ||
220 | p->con_rotate = 0; | ||
221 | |||
222 | fbcon_modechanged(info); | ||
223 | } | ||
224 | } | ||
225 | |||
226 | static void fbcon_rotate_all(struct fb_info *info, u32 rotate) | ||
227 | { | ||
228 | struct fbcon_ops *ops = info->fbcon_par; | ||
229 | struct vc_data *vc; | ||
230 | struct display *p; | ||
231 | int i; | ||
232 | |||
233 | if (!ops || ops->currcon < 0 || rotate > 3) | ||
234 | return; | ||
235 | |||
236 | for (i = first_fb_vc; i <= last_fb_vc; i++) { | ||
237 | vc = vc_cons[i].d; | ||
238 | if (!vc || vc->vc_mode != KD_TEXT || | ||
239 | registered_fb[con2fb_map[i]] != info) | ||
240 | continue; | ||
241 | |||
242 | p = &fb_display[vc->vc_num]; | ||
243 | p->con_rotate = rotate; | ||
244 | } | ||
245 | |||
246 | fbcon_set_all_vcs(info); | ||
247 | } | ||
248 | #else | ||
249 | static inline void fbcon_set_rotation(struct fb_info *info) | ||
250 | { | ||
251 | struct fbcon_ops *ops = info->fbcon_par; | ||
252 | |||
253 | ops->rotate = FB_ROTATE_UR; | ||
254 | } | ||
255 | |||
256 | static void fbcon_rotate(struct fb_info *info, u32 rotate) | ||
257 | { | ||
258 | return; | ||
259 | } | ||
260 | |||
261 | static void fbcon_rotate_all(struct fb_info *info, u32 rotate) | ||
262 | { | ||
263 | return; | ||
264 | } | ||
265 | #endif /* CONFIG_FRAMEBUFFER_CONSOLE_ROTATION */ | ||
266 | |||
267 | static int fbcon_get_rotate(struct fb_info *info) | ||
268 | { | ||
269 | struct fbcon_ops *ops = info->fbcon_par; | ||
270 | |||
271 | return (ops) ? ops->rotate : 0; | ||
272 | } | ||
273 | |||
274 | static inline int fbcon_is_inactive(struct vc_data *vc, struct fb_info *info) | ||
275 | { | ||
276 | struct fbcon_ops *ops = info->fbcon_par; | ||
277 | |||
278 | return (info->state != FBINFO_STATE_RUNNING || | ||
279 | vc->vc_mode != KD_TEXT || ops->graphics) && | ||
280 | !vt_force_oops_output(vc); | ||
281 | } | ||
282 | |||
283 | static int get_color(struct vc_data *vc, struct fb_info *info, | ||
284 | u16 c, int is_fg) | ||
285 | { | ||
286 | int depth = fb_get_color_depth(&info->var, &info->fix); | ||
287 | int color = 0; | ||
288 | |||
289 | if (console_blanked) { | ||
290 | unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff; | ||
291 | |||
292 | c = vc->vc_video_erase_char & charmask; | ||
293 | } | ||
294 | |||
295 | if (depth != 1) | ||
296 | color = (is_fg) ? attr_fgcol((vc->vc_hi_font_mask) ? 9 : 8, c) | ||
297 | : attr_bgcol((vc->vc_hi_font_mask) ? 13 : 12, c); | ||
298 | |||
299 | switch (depth) { | ||
300 | case 1: | ||
301 | { | ||
302 | int col = mono_col(info); | ||
303 | /* 0 or 1 */ | ||
304 | int fg = (info->fix.visual != FB_VISUAL_MONO01) ? col : 0; | ||
305 | int bg = (info->fix.visual != FB_VISUAL_MONO01) ? 0 : col; | ||
306 | |||
307 | if (console_blanked) | ||
308 | fg = bg; | ||
309 | |||
310 | color = (is_fg) ? fg : bg; | ||
311 | break; | ||
312 | } | ||
313 | case 2: | ||
314 | /* | ||
315 | * Scale down 16-colors to 4 colors. Default 4-color palette | ||
316 | * is grayscale. However, simply dividing the values by 4 | ||
317 | * will not work, as colors 1, 2 and 3 will be scaled-down | ||
318 | * to zero rendering them invisible. So empirically convert | ||
319 | * colors to a sane 4-level grayscale. | ||
320 | */ | ||
321 | switch (color) { | ||
322 | case 0: | ||
323 | color = 0; /* black */ | ||
324 | break; | ||
325 | case 1 ... 6: | ||
326 | color = 2; /* white */ | ||
327 | break; | ||
328 | case 7 ... 8: | ||
329 | color = 1; /* gray */ | ||
330 | break; | ||
331 | default: | ||
332 | color = 3; /* intense white */ | ||
333 | break; | ||
334 | } | ||
335 | break; | ||
336 | case 3: | ||
337 | /* | ||
338 | * Last 8 entries of default 16-color palette is a more intense | ||
339 | * version of the first 8 (i.e., same chrominance, different | ||
340 | * luminance). | ||
341 | */ | ||
342 | color &= 7; | ||
343 | break; | ||
344 | } | ||
345 | |||
346 | |||
347 | return color; | ||
348 | } | ||
349 | |||
350 | static void fbcon_update_softback(struct vc_data *vc) | ||
351 | { | ||
352 | int l = fbcon_softback_size / vc->vc_size_row; | ||
353 | |||
354 | if (l > 5) | ||
355 | softback_end = softback_buf + l * vc->vc_size_row; | ||
356 | else | ||
357 | /* Smaller scrollback makes no sense, and 0 would screw | ||
358 | the operation totally */ | ||
359 | softback_top = 0; | ||
360 | } | ||
361 | |||
362 | static void fb_flashcursor(struct work_struct *work) | ||
363 | { | ||
364 | struct fb_info *info = container_of(work, struct fb_info, queue); | ||
365 | struct fbcon_ops *ops = info->fbcon_par; | ||
366 | struct vc_data *vc = NULL; | ||
367 | int c; | ||
368 | int mode; | ||
369 | int ret; | ||
370 | |||
371 | /* FIXME: we should sort out the unbind locking instead */ | ||
372 | /* instead we just fail to flash the cursor if we can't get | ||
373 | * the lock instead of blocking fbcon deinit */ | ||
374 | ret = console_trylock(); | ||
375 | if (ret == 0) | ||
376 | return; | ||
377 | |||
378 | if (ops && ops->currcon != -1) | ||
379 | vc = vc_cons[ops->currcon].d; | ||
380 | |||
381 | if (!vc || !con_is_visible(vc) || | ||
382 | registered_fb[con2fb_map[vc->vc_num]] != info || | ||
383 | vc->vc_deccm != 1) { | ||
384 | console_unlock(); | ||
385 | return; | ||
386 | } | ||
387 | |||
388 | c = scr_readw((u16 *) vc->vc_pos); | ||
389 | mode = (!ops->cursor_flash || ops->cursor_state.enable) ? | ||
390 | CM_ERASE : CM_DRAW; | ||
391 | ops->cursor(vc, info, mode, softback_lines, get_color(vc, info, c, 1), | ||
392 | get_color(vc, info, c, 0)); | ||
393 | console_unlock(); | ||
394 | } | ||
395 | |||
396 | static void cursor_timer_handler(unsigned long dev_addr) | ||
397 | { | ||
398 | struct fb_info *info = (struct fb_info *) dev_addr; | ||
399 | struct fbcon_ops *ops = info->fbcon_par; | ||
400 | |||
401 | queue_work(system_power_efficient_wq, &info->queue); | ||
402 | mod_timer(&ops->cursor_timer, jiffies + ops->cur_blink_jiffies); | ||
403 | } | ||
404 | |||
405 | static void fbcon_add_cursor_timer(struct fb_info *info) | ||
406 | { | ||
407 | struct fbcon_ops *ops = info->fbcon_par; | ||
408 | |||
409 | if ((!info->queue.func || info->queue.func == fb_flashcursor) && | ||
410 | !(ops->flags & FBCON_FLAGS_CURSOR_TIMER) && | ||
411 | !fbcon_cursor_noblink) { | ||
412 | if (!info->queue.func) | ||
413 | INIT_WORK(&info->queue, fb_flashcursor); | ||
414 | |||
415 | setup_timer(&ops->cursor_timer, cursor_timer_handler, | ||
416 | (unsigned long) info); | ||
417 | mod_timer(&ops->cursor_timer, jiffies + ops->cur_blink_jiffies); | ||
418 | ops->flags |= FBCON_FLAGS_CURSOR_TIMER; | ||
419 | } | ||
420 | } | ||
421 | |||
422 | static void fbcon_del_cursor_timer(struct fb_info *info) | ||
423 | { | ||
424 | struct fbcon_ops *ops = info->fbcon_par; | ||
425 | |||
426 | if (info->queue.func == fb_flashcursor && | ||
427 | ops->flags & FBCON_FLAGS_CURSOR_TIMER) { | ||
428 | del_timer_sync(&ops->cursor_timer); | ||
429 | ops->flags &= ~FBCON_FLAGS_CURSOR_TIMER; | ||
430 | } | ||
431 | } | ||
432 | |||
433 | #ifndef MODULE | ||
434 | static int __init fb_console_setup(char *this_opt) | ||
435 | { | ||
436 | char *options; | ||
437 | int i, j; | ||
438 | |||
439 | if (!this_opt || !*this_opt) | ||
440 | return 1; | ||
441 | |||
442 | while ((options = strsep(&this_opt, ",")) != NULL) { | ||
443 | if (!strncmp(options, "font:", 5)) { | ||
444 | strlcpy(fontname, options + 5, sizeof(fontname)); | ||
445 | continue; | ||
446 | } | ||
447 | |||
448 | if (!strncmp(options, "scrollback:", 11)) { | ||
449 | options += 11; | ||
450 | if (*options) { | ||
451 | fbcon_softback_size = simple_strtoul(options, &options, 0); | ||
452 | if (*options == 'k' || *options == 'K') { | ||
453 | fbcon_softback_size *= 1024; | ||
454 | } | ||
455 | } | ||
456 | continue; | ||
457 | } | ||
458 | |||
459 | if (!strncmp(options, "map:", 4)) { | ||
460 | options += 4; | ||
461 | if (*options) { | ||
462 | for (i = 0, j = 0; i < MAX_NR_CONSOLES; i++) { | ||
463 | if (!options[j]) | ||
464 | j = 0; | ||
465 | con2fb_map_boot[i] = | ||
466 | (options[j++]-'0') % FB_MAX; | ||
467 | } | ||
468 | |||
469 | fbcon_map_override(); | ||
470 | } | ||
471 | continue; | ||
472 | } | ||
473 | |||
474 | if (!strncmp(options, "vc:", 3)) { | ||
475 | options += 3; | ||
476 | if (*options) | ||
477 | first_fb_vc = simple_strtoul(options, &options, 10) - 1; | ||
478 | if (first_fb_vc < 0) | ||
479 | first_fb_vc = 0; | ||
480 | if (*options++ == '-') | ||
481 | last_fb_vc = simple_strtoul(options, &options, 10) - 1; | ||
482 | fbcon_is_default = 0; | ||
483 | continue; | ||
484 | } | ||
485 | |||
486 | if (!strncmp(options, "rotate:", 7)) { | ||
487 | options += 7; | ||
488 | if (*options) | ||
489 | initial_rotation = simple_strtoul(options, &options, 0); | ||
490 | if (initial_rotation > 3) | ||
491 | initial_rotation = 0; | ||
492 | continue; | ||
493 | } | ||
494 | } | ||
495 | return 1; | ||
496 | } | ||
497 | |||
498 | __setup("fbcon=", fb_console_setup); | ||
499 | #endif | ||
500 | |||
501 | static int search_fb_in_map(int idx) | ||
502 | { | ||
503 | int i, retval = 0; | ||
504 | |||
505 | for (i = first_fb_vc; i <= last_fb_vc; i++) { | ||
506 | if (con2fb_map[i] == idx) | ||
507 | retval = 1; | ||
508 | } | ||
509 | return retval; | ||
510 | } | ||
511 | |||
512 | static int search_for_mapped_con(void) | ||
513 | { | ||
514 | int i, retval = 0; | ||
515 | |||
516 | for (i = first_fb_vc; i <= last_fb_vc; i++) { | ||
517 | if (con2fb_map[i] != -1) | ||
518 | retval = 1; | ||
519 | } | ||
520 | return retval; | ||
521 | } | ||
522 | |||
523 | static int do_fbcon_takeover(int show_logo) | ||
524 | { | ||
525 | int err, i; | ||
526 | |||
527 | if (!num_registered_fb) | ||
528 | return -ENODEV; | ||
529 | |||
530 | if (!show_logo) | ||
531 | logo_shown = FBCON_LOGO_DONTSHOW; | ||
532 | |||
533 | for (i = first_fb_vc; i <= last_fb_vc; i++) | ||
534 | con2fb_map[i] = info_idx; | ||
535 | |||
536 | err = do_take_over_console(&fb_con, first_fb_vc, last_fb_vc, | ||
537 | fbcon_is_default); | ||
538 | |||
539 | if (err) { | ||
540 | for (i = first_fb_vc; i <= last_fb_vc; i++) | ||
541 | con2fb_map[i] = -1; | ||
542 | info_idx = -1; | ||
543 | } else { | ||
544 | fbcon_has_console_bind = 1; | ||
545 | } | ||
546 | |||
547 | return err; | ||
548 | } | ||
549 | |||
550 | #ifdef MODULE | ||
551 | static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info, | ||
552 | int cols, int rows, int new_cols, int new_rows) | ||
553 | { | ||
554 | logo_shown = FBCON_LOGO_DONTSHOW; | ||
555 | } | ||
556 | #else | ||
557 | static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info, | ||
558 | int cols, int rows, int new_cols, int new_rows) | ||
559 | { | ||
560 | /* Need to make room for the logo */ | ||
561 | struct fbcon_ops *ops = info->fbcon_par; | ||
562 | int cnt, erase = vc->vc_video_erase_char, step; | ||
563 | unsigned short *save = NULL, *r, *q; | ||
564 | int logo_height; | ||
565 | |||
566 | if (info->flags & FBINFO_MODULE) { | ||
567 | logo_shown = FBCON_LOGO_DONTSHOW; | ||
568 | return; | ||
569 | } | ||
570 | |||
571 | /* | ||
572 | * remove underline attribute from erase character | ||
573 | * if black and white framebuffer. | ||
574 | */ | ||
575 | if (fb_get_color_depth(&info->var, &info->fix) == 1) | ||
576 | erase &= ~0x400; | ||
577 | logo_height = fb_prepare_logo(info, ops->rotate); | ||
578 | logo_lines = DIV_ROUND_UP(logo_height, vc->vc_font.height); | ||
579 | q = (unsigned short *) (vc->vc_origin + | ||
580 | vc->vc_size_row * rows); | ||
581 | step = logo_lines * cols; | ||
582 | for (r = q - logo_lines * cols; r < q; r++) | ||
583 | if (scr_readw(r) != vc->vc_video_erase_char) | ||
584 | break; | ||
585 | if (r != q && new_rows >= rows + logo_lines) { | ||
586 | save = kmalloc(logo_lines * new_cols * 2, GFP_KERNEL); | ||
587 | if (save) { | ||
588 | int i = cols < new_cols ? cols : new_cols; | ||
589 | scr_memsetw(save, erase, logo_lines * new_cols * 2); | ||
590 | r = q - step; | ||
591 | for (cnt = 0; cnt < logo_lines; cnt++, r += i) | ||
592 | scr_memcpyw(save + cnt * new_cols, r, 2 * i); | ||
593 | r = q; | ||
594 | } | ||
595 | } | ||
596 | if (r == q) { | ||
597 | /* We can scroll screen down */ | ||
598 | r = q - step - cols; | ||
599 | for (cnt = rows - logo_lines; cnt > 0; cnt--) { | ||
600 | scr_memcpyw(r + step, r, vc->vc_size_row); | ||
601 | r -= cols; | ||
602 | } | ||
603 | if (!save) { | ||
604 | int lines; | ||
605 | if (vc->vc_y + logo_lines >= rows) | ||
606 | lines = rows - vc->vc_y - 1; | ||
607 | else | ||
608 | lines = logo_lines; | ||
609 | vc->vc_y += lines; | ||
610 | vc->vc_pos += lines * vc->vc_size_row; | ||
611 | } | ||
612 | } | ||
613 | scr_memsetw((unsigned short *) vc->vc_origin, | ||
614 | erase, | ||
615 | vc->vc_size_row * logo_lines); | ||
616 | |||
617 | if (con_is_visible(vc) && vc->vc_mode == KD_TEXT) { | ||
618 | fbcon_clear_margins(vc, 0); | ||
619 | update_screen(vc); | ||
620 | } | ||
621 | |||
622 | if (save) { | ||
623 | q = (unsigned short *) (vc->vc_origin + | ||
624 | vc->vc_size_row * | ||
625 | rows); | ||
626 | scr_memcpyw(q, save, logo_lines * new_cols * 2); | ||
627 | vc->vc_y += logo_lines; | ||
628 | vc->vc_pos += logo_lines * vc->vc_size_row; | ||
629 | kfree(save); | ||
630 | } | ||
631 | |||
632 | if (logo_lines > vc->vc_bottom) { | ||
633 | logo_shown = FBCON_LOGO_CANSHOW; | ||
634 | printk(KERN_INFO | ||
635 | "fbcon_init: disable boot-logo (boot-logo bigger than screen).\n"); | ||
636 | } else if (logo_shown != FBCON_LOGO_DONTSHOW) { | ||
637 | logo_shown = FBCON_LOGO_DRAW; | ||
638 | vc->vc_top = logo_lines; | ||
639 | } | ||
640 | } | ||
641 | #endif /* MODULE */ | ||
642 | |||
643 | #ifdef CONFIG_FB_TILEBLITTING | ||
644 | static void set_blitting_type(struct vc_data *vc, struct fb_info *info) | ||
645 | { | ||
646 | struct fbcon_ops *ops = info->fbcon_par; | ||
647 | |||
648 | ops->p = &fb_display[vc->vc_num]; | ||
649 | |||
650 | if ((info->flags & FBINFO_MISC_TILEBLITTING)) | ||
651 | fbcon_set_tileops(vc, info); | ||
652 | else { | ||
653 | fbcon_set_rotation(info); | ||
654 | fbcon_set_bitops(ops); | ||
655 | } | ||
656 | } | ||
657 | |||
658 | static int fbcon_invalid_charcount(struct fb_info *info, unsigned charcount) | ||
659 | { | ||
660 | int err = 0; | ||
661 | |||
662 | if (info->flags & FBINFO_MISC_TILEBLITTING && | ||
663 | info->tileops->fb_get_tilemax(info) < charcount) | ||
664 | err = 1; | ||
665 | |||
666 | return err; | ||
667 | } | ||
668 | #else | ||
669 | static void set_blitting_type(struct vc_data *vc, struct fb_info *info) | ||
670 | { | ||
671 | struct fbcon_ops *ops = info->fbcon_par; | ||
672 | |||
673 | info->flags &= ~FBINFO_MISC_TILEBLITTING; | ||
674 | ops->p = &fb_display[vc->vc_num]; | ||
675 | fbcon_set_rotation(info); | ||
676 | fbcon_set_bitops(ops); | ||
677 | } | ||
678 | |||
679 | static int fbcon_invalid_charcount(struct fb_info *info, unsigned charcount) | ||
680 | { | ||
681 | return 0; | ||
682 | } | ||
683 | |||
684 | #endif /* CONFIG_MISC_TILEBLITTING */ | ||
685 | |||
686 | |||
687 | static int con2fb_acquire_newinfo(struct vc_data *vc, struct fb_info *info, | ||
688 | int unit, int oldidx) | ||
689 | { | ||
690 | struct fbcon_ops *ops = NULL; | ||
691 | int err = 0; | ||
692 | |||
693 | if (!try_module_get(info->fbops->owner)) | ||
694 | err = -ENODEV; | ||
695 | |||
696 | if (!err && info->fbops->fb_open && | ||
697 | info->fbops->fb_open(info, 0)) | ||
698 | err = -ENODEV; | ||
699 | |||
700 | if (!err) { | ||
701 | ops = kzalloc(sizeof(struct fbcon_ops), GFP_KERNEL); | ||
702 | if (!ops) | ||
703 | err = -ENOMEM; | ||
704 | } | ||
705 | |||
706 | if (!err) { | ||
707 | ops->cur_blink_jiffies = HZ / 5; | ||
708 | info->fbcon_par = ops; | ||
709 | |||
710 | if (vc) | ||
711 | set_blitting_type(vc, info); | ||
712 | } | ||
713 | |||
714 | if (err) { | ||
715 | con2fb_map[unit] = oldidx; | ||
716 | module_put(info->fbops->owner); | ||
717 | } | ||
718 | |||
719 | return err; | ||
720 | } | ||
721 | |||
722 | static int con2fb_release_oldinfo(struct vc_data *vc, struct fb_info *oldinfo, | ||
723 | struct fb_info *newinfo, int unit, | ||
724 | int oldidx, int found) | ||
725 | { | ||
726 | struct fbcon_ops *ops = oldinfo->fbcon_par; | ||
727 | int err = 0, ret; | ||
728 | |||
729 | if (oldinfo->fbops->fb_release && | ||
730 | oldinfo->fbops->fb_release(oldinfo, 0)) { | ||
731 | con2fb_map[unit] = oldidx; | ||
732 | if (!found && newinfo->fbops->fb_release) | ||
733 | newinfo->fbops->fb_release(newinfo, 0); | ||
734 | if (!found) | ||
735 | module_put(newinfo->fbops->owner); | ||
736 | err = -ENODEV; | ||
737 | } | ||
738 | |||
739 | if (!err) { | ||
740 | fbcon_del_cursor_timer(oldinfo); | ||
741 | kfree(ops->cursor_state.mask); | ||
742 | kfree(ops->cursor_data); | ||
743 | kfree(ops->cursor_src); | ||
744 | kfree(ops->fontbuffer); | ||
745 | kfree(oldinfo->fbcon_par); | ||
746 | oldinfo->fbcon_par = NULL; | ||
747 | module_put(oldinfo->fbops->owner); | ||
748 | /* | ||
749 | If oldinfo and newinfo are driving the same hardware, | ||
750 | the fb_release() method of oldinfo may attempt to | ||
751 | restore the hardware state. This will leave the | ||
752 | newinfo in an undefined state. Thus, a call to | ||
753 | fb_set_par() may be needed for the newinfo. | ||
754 | */ | ||
755 | if (newinfo && newinfo->fbops->fb_set_par) { | ||
756 | ret = newinfo->fbops->fb_set_par(newinfo); | ||
757 | |||
758 | if (ret) | ||
759 | printk(KERN_ERR "con2fb_release_oldinfo: " | ||
760 | "detected unhandled fb_set_par error, " | ||
761 | "error code %d\n", ret); | ||
762 | } | ||
763 | } | ||
764 | |||
765 | return err; | ||
766 | } | ||
767 | |||
768 | static void con2fb_init_display(struct vc_data *vc, struct fb_info *info, | ||
769 | int unit, int show_logo) | ||
770 | { | ||
771 | struct fbcon_ops *ops = info->fbcon_par; | ||
772 | int ret; | ||
773 | |||
774 | ops->currcon = fg_console; | ||
775 | |||
776 | if (info->fbops->fb_set_par && !(ops->flags & FBCON_FLAGS_INIT)) { | ||
777 | ret = info->fbops->fb_set_par(info); | ||
778 | |||
779 | if (ret) | ||
780 | printk(KERN_ERR "con2fb_init_display: detected " | ||
781 | "unhandled fb_set_par error, " | ||
782 | "error code %d\n", ret); | ||
783 | } | ||
784 | |||
785 | ops->flags |= FBCON_FLAGS_INIT; | ||
786 | ops->graphics = 0; | ||
787 | fbcon_set_disp(info, &info->var, unit); | ||
788 | |||
789 | if (show_logo) { | ||
790 | struct vc_data *fg_vc = vc_cons[fg_console].d; | ||
791 | struct fb_info *fg_info = | ||
792 | registered_fb[con2fb_map[fg_console]]; | ||
793 | |||
794 | fbcon_prepare_logo(fg_vc, fg_info, fg_vc->vc_cols, | ||
795 | fg_vc->vc_rows, fg_vc->vc_cols, | ||
796 | fg_vc->vc_rows); | ||
797 | } | ||
798 | |||
799 | update_screen(vc_cons[fg_console].d); | ||
800 | } | ||
801 | |||
802 | /** | ||
803 | * set_con2fb_map - map console to frame buffer device | ||
804 | * @unit: virtual console number to map | ||
805 | * @newidx: frame buffer index to map virtual console to | ||
806 | * @user: user request | ||
807 | * | ||
808 | * Maps a virtual console @unit to a frame buffer device | ||
809 | * @newidx. | ||
810 | * | ||
811 | * This should be called with the console lock held. | ||
812 | */ | ||
813 | static int set_con2fb_map(int unit, int newidx, int user) | ||
814 | { | ||
815 | struct vc_data *vc = vc_cons[unit].d; | ||
816 | int oldidx = con2fb_map[unit]; | ||
817 | struct fb_info *info = registered_fb[newidx]; | ||
818 | struct fb_info *oldinfo = NULL; | ||
819 | int found, err = 0; | ||
820 | |||
821 | if (oldidx == newidx) | ||
822 | return 0; | ||
823 | |||
824 | if (!info) | ||
825 | return -EINVAL; | ||
826 | |||
827 | if (!search_for_mapped_con() || !con_is_bound(&fb_con)) { | ||
828 | info_idx = newidx; | ||
829 | return do_fbcon_takeover(0); | ||
830 | } | ||
831 | |||
832 | if (oldidx != -1) | ||
833 | oldinfo = registered_fb[oldidx]; | ||
834 | |||
835 | found = search_fb_in_map(newidx); | ||
836 | |||
837 | con2fb_map[unit] = newidx; | ||
838 | if (!err && !found) | ||
839 | err = con2fb_acquire_newinfo(vc, info, unit, oldidx); | ||
840 | |||
841 | |||
842 | /* | ||
843 | * If old fb is not mapped to any of the consoles, | ||
844 | * fbcon should release it. | ||
845 | */ | ||
846 | if (!err && oldinfo && !search_fb_in_map(oldidx)) | ||
847 | err = con2fb_release_oldinfo(vc, oldinfo, info, unit, oldidx, | ||
848 | found); | ||
849 | |||
850 | if (!err) { | ||
851 | int show_logo = (fg_console == 0 && !user && | ||
852 | logo_shown != FBCON_LOGO_DONTSHOW); | ||
853 | |||
854 | if (!found) | ||
855 | fbcon_add_cursor_timer(info); | ||
856 | con2fb_map_boot[unit] = newidx; | ||
857 | con2fb_init_display(vc, info, unit, show_logo); | ||
858 | } | ||
859 | |||
860 | if (!search_fb_in_map(info_idx)) | ||
861 | info_idx = newidx; | ||
862 | |||
863 | return err; | ||
864 | } | ||
865 | |||
866 | /* | ||
867 | * Low Level Operations | ||
868 | */ | ||
869 | /* NOTE: fbcon cannot be __init: it may be called from do_take_over_console later */ | ||
870 | static int var_to_display(struct display *disp, | ||
871 | struct fb_var_screeninfo *var, | ||
872 | struct fb_info *info) | ||
873 | { | ||
874 | disp->xres_virtual = var->xres_virtual; | ||
875 | disp->yres_virtual = var->yres_virtual; | ||
876 | disp->bits_per_pixel = var->bits_per_pixel; | ||
877 | disp->grayscale = var->grayscale; | ||
878 | disp->nonstd = var->nonstd; | ||
879 | disp->accel_flags = var->accel_flags; | ||
880 | disp->height = var->height; | ||
881 | disp->width = var->width; | ||
882 | disp->red = var->red; | ||
883 | disp->green = var->green; | ||
884 | disp->blue = var->blue; | ||
885 | disp->transp = var->transp; | ||
886 | disp->rotate = var->rotate; | ||
887 | disp->mode = fb_match_mode(var, &info->modelist); | ||
888 | if (disp->mode == NULL) | ||
889 | /* This should not happen */ | ||
890 | return -EINVAL; | ||
891 | return 0; | ||
892 | } | ||
893 | |||
894 | static void display_to_var(struct fb_var_screeninfo *var, | ||
895 | struct display *disp) | ||
896 | { | ||
897 | fb_videomode_to_var(var, disp->mode); | ||
898 | var->xres_virtual = disp->xres_virtual; | ||
899 | var->yres_virtual = disp->yres_virtual; | ||
900 | var->bits_per_pixel = disp->bits_per_pixel; | ||
901 | var->grayscale = disp->grayscale; | ||
902 | var->nonstd = disp->nonstd; | ||
903 | var->accel_flags = disp->accel_flags; | ||
904 | var->height = disp->height; | ||
905 | var->width = disp->width; | ||
906 | var->red = disp->red; | ||
907 | var->green = disp->green; | ||
908 | var->blue = disp->blue; | ||
909 | var->transp = disp->transp; | ||
910 | var->rotate = disp->rotate; | ||
911 | } | ||
912 | |||
913 | static const char *fbcon_startup(void) | ||
914 | { | ||
915 | const char *display_desc = "frame buffer device"; | ||
916 | struct display *p = &fb_display[fg_console]; | ||
917 | struct vc_data *vc = vc_cons[fg_console].d; | ||
918 | const struct font_desc *font = NULL; | ||
919 | struct module *owner; | ||
920 | struct fb_info *info = NULL; | ||
921 | struct fbcon_ops *ops; | ||
922 | int rows, cols; | ||
923 | |||
924 | /* | ||
925 | * If num_registered_fb is zero, this is a call for the dummy part. | ||
926 | * The frame buffer devices weren't initialized yet. | ||
927 | */ | ||
928 | if (!num_registered_fb || info_idx == -1) | ||
929 | return display_desc; | ||
930 | /* | ||
931 | * Instead of blindly using registered_fb[0], we use info_idx, set by | ||
932 | * fb_console_init(); | ||
933 | */ | ||
934 | info = registered_fb[info_idx]; | ||
935 | if (!info) | ||
936 | return NULL; | ||
937 | |||
938 | owner = info->fbops->owner; | ||
939 | if (!try_module_get(owner)) | ||
940 | return NULL; | ||
941 | if (info->fbops->fb_open && info->fbops->fb_open(info, 0)) { | ||
942 | module_put(owner); | ||
943 | return NULL; | ||
944 | } | ||
945 | |||
946 | ops = kzalloc(sizeof(struct fbcon_ops), GFP_KERNEL); | ||
947 | if (!ops) { | ||
948 | module_put(owner); | ||
949 | return NULL; | ||
950 | } | ||
951 | |||
952 | ops->currcon = -1; | ||
953 | ops->graphics = 1; | ||
954 | ops->cur_rotate = -1; | ||
955 | ops->cur_blink_jiffies = HZ / 5; | ||
956 | info->fbcon_par = ops; | ||
957 | p->con_rotate = initial_rotation; | ||
958 | set_blitting_type(vc, info); | ||
959 | |||
960 | if (info->fix.type != FB_TYPE_TEXT) { | ||
961 | if (fbcon_softback_size) { | ||
962 | if (!softback_buf) { | ||
963 | softback_buf = | ||
964 | (unsigned long) | ||
965 | kmalloc(fbcon_softback_size, | ||
966 | GFP_KERNEL); | ||
967 | if (!softback_buf) { | ||
968 | fbcon_softback_size = 0; | ||
969 | softback_top = 0; | ||
970 | } | ||
971 | } | ||
972 | } else { | ||
973 | if (softback_buf) { | ||
974 | kfree((void *) softback_buf); | ||
975 | softback_buf = 0; | ||
976 | softback_top = 0; | ||
977 | } | ||
978 | } | ||
979 | if (softback_buf) | ||
980 | softback_in = softback_top = softback_curr = | ||
981 | softback_buf; | ||
982 | softback_lines = 0; | ||
983 | } | ||
984 | |||
985 | /* Setup default font */ | ||
986 | if (!p->fontdata && !vc->vc_font.data) { | ||
987 | if (!fontname[0] || !(font = find_font(fontname))) | ||
988 | font = get_default_font(info->var.xres, | ||
989 | info->var.yres, | ||
990 | info->pixmap.blit_x, | ||
991 | info->pixmap.blit_y); | ||
992 | vc->vc_font.width = font->width; | ||
993 | vc->vc_font.height = font->height; | ||
994 | vc->vc_font.data = (void *)(p->fontdata = font->data); | ||
995 | vc->vc_font.charcount = 256; /* FIXME Need to support more fonts */ | ||
996 | } else { | ||
997 | p->fontdata = vc->vc_font.data; | ||
998 | } | ||
999 | |||
1000 | cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres); | ||
1001 | rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres); | ||
1002 | cols /= vc->vc_font.width; | ||
1003 | rows /= vc->vc_font.height; | ||
1004 | vc_resize(vc, cols, rows); | ||
1005 | |||
1006 | DPRINTK("mode: %s\n", info->fix.id); | ||
1007 | DPRINTK("visual: %d\n", info->fix.visual); | ||
1008 | DPRINTK("res: %dx%d-%d\n", info->var.xres, | ||
1009 | info->var.yres, | ||
1010 | info->var.bits_per_pixel); | ||
1011 | |||
1012 | fbcon_add_cursor_timer(info); | ||
1013 | fbcon_has_exited = 0; | ||
1014 | return display_desc; | ||
1015 | } | ||
1016 | |||
1017 | static void fbcon_init(struct vc_data *vc, int init) | ||
1018 | { | ||
1019 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; | ||
1020 | struct fbcon_ops *ops; | ||
1021 | struct vc_data **default_mode = vc->vc_display_fg; | ||
1022 | struct vc_data *svc = *default_mode; | ||
1023 | struct display *t, *p = &fb_display[vc->vc_num]; | ||
1024 | int logo = 1, new_rows, new_cols, rows, cols, charcnt = 256; | ||
1025 | int cap, ret; | ||
1026 | |||
1027 | if (info_idx == -1 || info == NULL) | ||
1028 | return; | ||
1029 | |||
1030 | cap = info->flags; | ||
1031 | |||
1032 | if (vc != svc || logo_shown == FBCON_LOGO_DONTSHOW || | ||
1033 | (info->fix.type == FB_TYPE_TEXT)) | ||
1034 | logo = 0; | ||
1035 | |||
1036 | if (var_to_display(p, &info->var, info)) | ||
1037 | return; | ||
1038 | |||
1039 | if (!info->fbcon_par) | ||
1040 | con2fb_acquire_newinfo(vc, info, vc->vc_num, -1); | ||
1041 | |||
1042 | /* If we are not the first console on this | ||
1043 | fb, copy the font from that console */ | ||
1044 | t = &fb_display[fg_console]; | ||
1045 | if (!p->fontdata) { | ||
1046 | if (t->fontdata) { | ||
1047 | struct vc_data *fvc = vc_cons[fg_console].d; | ||
1048 | |||
1049 | vc->vc_font.data = (void *)(p->fontdata = | ||
1050 | fvc->vc_font.data); | ||
1051 | vc->vc_font.width = fvc->vc_font.width; | ||
1052 | vc->vc_font.height = fvc->vc_font.height; | ||
1053 | p->userfont = t->userfont; | ||
1054 | |||
1055 | if (p->userfont) | ||
1056 | REFCOUNT(p->fontdata)++; | ||
1057 | } else { | ||
1058 | const struct font_desc *font = NULL; | ||
1059 | |||
1060 | if (!fontname[0] || !(font = find_font(fontname))) | ||
1061 | font = get_default_font(info->var.xres, | ||
1062 | info->var.yres, | ||
1063 | info->pixmap.blit_x, | ||
1064 | info->pixmap.blit_y); | ||
1065 | vc->vc_font.width = font->width; | ||
1066 | vc->vc_font.height = font->height; | ||
1067 | vc->vc_font.data = (void *)(p->fontdata = font->data); | ||
1068 | vc->vc_font.charcount = 256; /* FIXME Need to | ||
1069 | support more fonts */ | ||
1070 | } | ||
1071 | } | ||
1072 | |||
1073 | if (p->userfont) | ||
1074 | charcnt = FNTCHARCNT(p->fontdata); | ||
1075 | |||
1076 | vc->vc_panic_force_write = !!(info->flags & FBINFO_CAN_FORCE_OUTPUT); | ||
1077 | vc->vc_can_do_color = (fb_get_color_depth(&info->var, &info->fix)!=1); | ||
1078 | vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800; | ||
1079 | if (charcnt == 256) { | ||
1080 | vc->vc_hi_font_mask = 0; | ||
1081 | } else { | ||
1082 | vc->vc_hi_font_mask = 0x100; | ||
1083 | if (vc->vc_can_do_color) | ||
1084 | vc->vc_complement_mask <<= 1; | ||
1085 | } | ||
1086 | |||
1087 | if (!*svc->vc_uni_pagedir_loc) | ||
1088 | con_set_default_unimap(svc); | ||
1089 | if (!*vc->vc_uni_pagedir_loc) | ||
1090 | con_copy_unimap(vc, svc); | ||
1091 | |||
1092 | ops = info->fbcon_par; | ||
1093 | ops->cur_blink_jiffies = msecs_to_jiffies(vc->vc_cur_blink_ms); | ||
1094 | p->con_rotate = initial_rotation; | ||
1095 | set_blitting_type(vc, info); | ||
1096 | |||
1097 | cols = vc->vc_cols; | ||
1098 | rows = vc->vc_rows; | ||
1099 | new_cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres); | ||
1100 | new_rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres); | ||
1101 | new_cols /= vc->vc_font.width; | ||
1102 | new_rows /= vc->vc_font.height; | ||
1103 | |||
1104 | /* | ||
1105 | * We must always set the mode. The mode of the previous console | ||
1106 | * driver could be in the same resolution but we are using different | ||
1107 | * hardware so we have to initialize the hardware. | ||
1108 | * | ||
1109 | * We need to do it in fbcon_init() to prevent screen corruption. | ||
1110 | */ | ||
1111 | if (con_is_visible(vc) && vc->vc_mode == KD_TEXT) { | ||
1112 | if (info->fbops->fb_set_par && | ||
1113 | !(ops->flags & FBCON_FLAGS_INIT)) { | ||
1114 | ret = info->fbops->fb_set_par(info); | ||
1115 | |||
1116 | if (ret) | ||
1117 | printk(KERN_ERR "fbcon_init: detected " | ||
1118 | "unhandled fb_set_par error, " | ||
1119 | "error code %d\n", ret); | ||
1120 | } | ||
1121 | |||
1122 | ops->flags |= FBCON_FLAGS_INIT; | ||
1123 | } | ||
1124 | |||
1125 | ops->graphics = 0; | ||
1126 | |||
1127 | if ((cap & FBINFO_HWACCEL_COPYAREA) && | ||
1128 | !(cap & FBINFO_HWACCEL_DISABLED)) | ||
1129 | p->scrollmode = SCROLL_MOVE; | ||
1130 | else /* default to something safe */ | ||
1131 | p->scrollmode = SCROLL_REDRAW; | ||
1132 | |||
1133 | /* | ||
1134 | * ++guenther: console.c:vc_allocate() relies on initializing | ||
1135 | * vc_{cols,rows}, but we must not set those if we are only | ||
1136 | * resizing the console. | ||
1137 | */ | ||
1138 | if (init) { | ||
1139 | vc->vc_cols = new_cols; | ||
1140 | vc->vc_rows = new_rows; | ||
1141 | } else | ||
1142 | vc_resize(vc, new_cols, new_rows); | ||
1143 | |||
1144 | if (logo) | ||
1145 | fbcon_prepare_logo(vc, info, cols, rows, new_cols, new_rows); | ||
1146 | |||
1147 | if (vc == svc && softback_buf) | ||
1148 | fbcon_update_softback(vc); | ||
1149 | |||
1150 | if (ops->rotate_font && ops->rotate_font(info, vc)) { | ||
1151 | ops->rotate = FB_ROTATE_UR; | ||
1152 | set_blitting_type(vc, info); | ||
1153 | } | ||
1154 | |||
1155 | ops->p = &fb_display[fg_console]; | ||
1156 | } | ||
1157 | |||
1158 | static void fbcon_free_font(struct display *p, bool freefont) | ||
1159 | { | ||
1160 | if (freefont && p->userfont && p->fontdata && (--REFCOUNT(p->fontdata) == 0)) | ||
1161 | kfree(p->fontdata - FONT_EXTRA_WORDS * sizeof(int)); | ||
1162 | p->fontdata = NULL; | ||
1163 | p->userfont = 0; | ||
1164 | } | ||
1165 | |||
1166 | static void set_vc_hi_font(struct vc_data *vc, bool set); | ||
1167 | |||
1168 | static void fbcon_deinit(struct vc_data *vc) | ||
1169 | { | ||
1170 | struct display *p = &fb_display[vc->vc_num]; | ||
1171 | struct fb_info *info; | ||
1172 | struct fbcon_ops *ops; | ||
1173 | int idx; | ||
1174 | bool free_font = true; | ||
1175 | |||
1176 | idx = con2fb_map[vc->vc_num]; | ||
1177 | |||
1178 | if (idx == -1) | ||
1179 | goto finished; | ||
1180 | |||
1181 | info = registered_fb[idx]; | ||
1182 | |||
1183 | if (!info) | ||
1184 | goto finished; | ||
1185 | |||
1186 | if (info->flags & FBINFO_MISC_FIRMWARE) | ||
1187 | free_font = false; | ||
1188 | ops = info->fbcon_par; | ||
1189 | |||
1190 | if (!ops) | ||
1191 | goto finished; | ||
1192 | |||
1193 | if (con_is_visible(vc)) | ||
1194 | fbcon_del_cursor_timer(info); | ||
1195 | |||
1196 | ops->flags &= ~FBCON_FLAGS_INIT; | ||
1197 | finished: | ||
1198 | |||
1199 | fbcon_free_font(p, free_font); | ||
1200 | if (free_font) | ||
1201 | vc->vc_font.data = NULL; | ||
1202 | |||
1203 | if (vc->vc_hi_font_mask) | ||
1204 | set_vc_hi_font(vc, false); | ||
1205 | |||
1206 | if (!con_is_bound(&fb_con)) | ||
1207 | fbcon_exit(); | ||
1208 | |||
1209 | return; | ||
1210 | } | ||
1211 | |||
1212 | /* ====================================================================== */ | ||
1213 | |||
1214 | /* fbcon_XXX routines - interface used by the world | ||
1215 | * | ||
1216 | * This system is now divided into two levels because of complications | ||
1217 | * caused by hardware scrolling. Top level functions: | ||
1218 | * | ||
1219 | * fbcon_bmove(), fbcon_clear(), fbcon_putc(), fbcon_clear_margins() | ||
1220 | * | ||
1221 | * handles y values in range [0, scr_height-1] that correspond to real | ||
1222 | * screen positions. y_wrap shift means that first line of bitmap may be | ||
1223 | * anywhere on this display. These functions convert lineoffsets to | ||
1224 | * bitmap offsets and deal with the wrap-around case by splitting blits. | ||
1225 | * | ||
1226 | * fbcon_bmove_physical_8() -- These functions fast implementations | ||
1227 | * fbcon_clear_physical_8() -- of original fbcon_XXX fns. | ||
1228 | * fbcon_putc_physical_8() -- (font width != 8) may be added later | ||
1229 | * | ||
1230 | * WARNING: | ||
1231 | * | ||
1232 | * At the moment fbcon_putc() cannot blit across vertical wrap boundary | ||
1233 | * Implies should only really hardware scroll in rows. Only reason for | ||
1234 | * restriction is simplicity & efficiency at the moment. | ||
1235 | */ | ||
1236 | |||
1237 | static void fbcon_clear(struct vc_data *vc, int sy, int sx, int height, | ||
1238 | int width) | ||
1239 | { | ||
1240 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; | ||
1241 | struct fbcon_ops *ops = info->fbcon_par; | ||
1242 | |||
1243 | struct display *p = &fb_display[vc->vc_num]; | ||
1244 | u_int y_break; | ||
1245 | |||
1246 | if (fbcon_is_inactive(vc, info)) | ||
1247 | return; | ||
1248 | |||
1249 | if (!height || !width) | ||
1250 | return; | ||
1251 | |||
1252 | if (sy < vc->vc_top && vc->vc_top == logo_lines) { | ||
1253 | vc->vc_top = 0; | ||
1254 | /* | ||
1255 | * If the font dimensions are not an integral of the display | ||
1256 | * dimensions then the ops->clear below won't end up clearing | ||
1257 | * the margins. Call clear_margins here in case the logo | ||
1258 | * bitmap stretched into the margin area. | ||
1259 | */ | ||
1260 | fbcon_clear_margins(vc, 0); | ||
1261 | } | ||
1262 | |||
1263 | /* Split blits that cross physical y_wrap boundary */ | ||
1264 | |||
1265 | y_break = p->vrows - p->yscroll; | ||
1266 | if (sy < y_break && sy + height - 1 >= y_break) { | ||
1267 | u_int b = y_break - sy; | ||
1268 | ops->clear(vc, info, real_y(p, sy), sx, b, width); | ||
1269 | ops->clear(vc, info, real_y(p, sy + b), sx, height - b, | ||
1270 | width); | ||
1271 | } else | ||
1272 | ops->clear(vc, info, real_y(p, sy), sx, height, width); | ||
1273 | } | ||
1274 | |||
1275 | static void fbcon_putcs(struct vc_data *vc, const unsigned short *s, | ||
1276 | int count, int ypos, int xpos) | ||
1277 | { | ||
1278 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; | ||
1279 | struct display *p = &fb_display[vc->vc_num]; | ||
1280 | struct fbcon_ops *ops = info->fbcon_par; | ||
1281 | |||
1282 | if (!fbcon_is_inactive(vc, info)) | ||
1283 | ops->putcs(vc, info, s, count, real_y(p, ypos), xpos, | ||
1284 | get_color(vc, info, scr_readw(s), 1), | ||
1285 | get_color(vc, info, scr_readw(s), 0)); | ||
1286 | } | ||
1287 | |||
1288 | static void fbcon_putc(struct vc_data *vc, int c, int ypos, int xpos) | ||
1289 | { | ||
1290 | unsigned short chr; | ||
1291 | |||
1292 | scr_writew(c, &chr); | ||
1293 | fbcon_putcs(vc, &chr, 1, ypos, xpos); | ||
1294 | } | ||
1295 | |||
1296 | static void fbcon_clear_margins(struct vc_data *vc, int bottom_only) | ||
1297 | { | ||
1298 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; | ||
1299 | struct fbcon_ops *ops = info->fbcon_par; | ||
1300 | |||
1301 | if (!fbcon_is_inactive(vc, info)) | ||
1302 | ops->clear_margins(vc, info, bottom_only); | ||
1303 | } | ||
1304 | |||
1305 | static void fbcon_cursor(struct vc_data *vc, int mode) | ||
1306 | { | ||
1307 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; | ||
1308 | struct fbcon_ops *ops = info->fbcon_par; | ||
1309 | int y; | ||
1310 | int c = scr_readw((u16 *) vc->vc_pos); | ||
1311 | |||
1312 | ops->cur_blink_jiffies = msecs_to_jiffies(vc->vc_cur_blink_ms); | ||
1313 | |||
1314 | if (fbcon_is_inactive(vc, info) || vc->vc_deccm != 1) | ||
1315 | return; | ||
1316 | |||
1317 | if (vc->vc_cursor_type & 0x10) | ||
1318 | fbcon_del_cursor_timer(info); | ||
1319 | else | ||
1320 | fbcon_add_cursor_timer(info); | ||
1321 | |||
1322 | ops->cursor_flash = (mode == CM_ERASE) ? 0 : 1; | ||
1323 | if (mode & CM_SOFTBACK) { | ||
1324 | mode &= ~CM_SOFTBACK; | ||
1325 | y = softback_lines; | ||
1326 | } else { | ||
1327 | if (softback_lines) | ||
1328 | fbcon_set_origin(vc); | ||
1329 | y = 0; | ||
1330 | } | ||
1331 | |||
1332 | ops->cursor(vc, info, mode, y, get_color(vc, info, c, 1), | ||
1333 | get_color(vc, info, c, 0)); | ||
1334 | } | ||
1335 | |||
1336 | static int scrollback_phys_max = 0; | ||
1337 | static int scrollback_max = 0; | ||
1338 | static int scrollback_current = 0; | ||
1339 | |||
1340 | static void fbcon_set_disp(struct fb_info *info, struct fb_var_screeninfo *var, | ||
1341 | int unit) | ||
1342 | { | ||
1343 | struct display *p, *t; | ||
1344 | struct vc_data **default_mode, *vc; | ||
1345 | struct vc_data *svc; | ||
1346 | struct fbcon_ops *ops = info->fbcon_par; | ||
1347 | int rows, cols, charcnt = 256; | ||
1348 | |||
1349 | p = &fb_display[unit]; | ||
1350 | |||
1351 | if (var_to_display(p, var, info)) | ||
1352 | return; | ||
1353 | |||
1354 | vc = vc_cons[unit].d; | ||
1355 | |||
1356 | if (!vc) | ||
1357 | return; | ||
1358 | |||
1359 | default_mode = vc->vc_display_fg; | ||
1360 | svc = *default_mode; | ||
1361 | t = &fb_display[svc->vc_num]; | ||
1362 | |||
1363 | if (!vc->vc_font.data) { | ||
1364 | vc->vc_font.data = (void *)(p->fontdata = t->fontdata); | ||
1365 | vc->vc_font.width = (*default_mode)->vc_font.width; | ||
1366 | vc->vc_font.height = (*default_mode)->vc_font.height; | ||
1367 | p->userfont = t->userfont; | ||
1368 | if (p->userfont) | ||
1369 | REFCOUNT(p->fontdata)++; | ||
1370 | } | ||
1371 | if (p->userfont) | ||
1372 | charcnt = FNTCHARCNT(p->fontdata); | ||
1373 | |||
1374 | var->activate = FB_ACTIVATE_NOW; | ||
1375 | info->var.activate = var->activate; | ||
1376 | var->yoffset = info->var.yoffset; | ||
1377 | var->xoffset = info->var.xoffset; | ||
1378 | fb_set_var(info, var); | ||
1379 | ops->var = info->var; | ||
1380 | vc->vc_can_do_color = (fb_get_color_depth(&info->var, &info->fix)!=1); | ||
1381 | vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800; | ||
1382 | if (charcnt == 256) { | ||
1383 | vc->vc_hi_font_mask = 0; | ||
1384 | } else { | ||
1385 | vc->vc_hi_font_mask = 0x100; | ||
1386 | if (vc->vc_can_do_color) | ||
1387 | vc->vc_complement_mask <<= 1; | ||
1388 | } | ||
1389 | |||
1390 | if (!*svc->vc_uni_pagedir_loc) | ||
1391 | con_set_default_unimap(svc); | ||
1392 | if (!*vc->vc_uni_pagedir_loc) | ||
1393 | con_copy_unimap(vc, svc); | ||
1394 | |||
1395 | cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres); | ||
1396 | rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres); | ||
1397 | cols /= vc->vc_font.width; | ||
1398 | rows /= vc->vc_font.height; | ||
1399 | vc_resize(vc, cols, rows); | ||
1400 | |||
1401 | if (con_is_visible(vc)) { | ||
1402 | update_screen(vc); | ||
1403 | if (softback_buf) | ||
1404 | fbcon_update_softback(vc); | ||
1405 | } | ||
1406 | } | ||
1407 | |||
1408 | static __inline__ void ywrap_up(struct vc_data *vc, int count) | ||
1409 | { | ||
1410 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; | ||
1411 | struct fbcon_ops *ops = info->fbcon_par; | ||
1412 | struct display *p = &fb_display[vc->vc_num]; | ||
1413 | |||
1414 | p->yscroll += count; | ||
1415 | if (p->yscroll >= p->vrows) /* Deal with wrap */ | ||
1416 | p->yscroll -= p->vrows; | ||
1417 | ops->var.xoffset = 0; | ||
1418 | ops->var.yoffset = p->yscroll * vc->vc_font.height; | ||
1419 | ops->var.vmode |= FB_VMODE_YWRAP; | ||
1420 | ops->update_start(info); | ||
1421 | scrollback_max += count; | ||
1422 | if (scrollback_max > scrollback_phys_max) | ||
1423 | scrollback_max = scrollback_phys_max; | ||
1424 | scrollback_current = 0; | ||
1425 | } | ||
1426 | |||
1427 | static __inline__ void ywrap_down(struct vc_data *vc, int count) | ||
1428 | { | ||
1429 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; | ||
1430 | struct fbcon_ops *ops = info->fbcon_par; | ||
1431 | struct display *p = &fb_display[vc->vc_num]; | ||
1432 | |||
1433 | p->yscroll -= count; | ||
1434 | if (p->yscroll < 0) /* Deal with wrap */ | ||
1435 | p->yscroll += p->vrows; | ||
1436 | ops->var.xoffset = 0; | ||
1437 | ops->var.yoffset = p->yscroll * vc->vc_font.height; | ||
1438 | ops->var.vmode |= FB_VMODE_YWRAP; | ||
1439 | ops->update_start(info); | ||
1440 | scrollback_max -= count; | ||
1441 | if (scrollback_max < 0) | ||
1442 | scrollback_max = 0; | ||
1443 | scrollback_current = 0; | ||
1444 | } | ||
1445 | |||
1446 | static __inline__ void ypan_up(struct vc_data *vc, int count) | ||
1447 | { | ||
1448 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; | ||
1449 | struct display *p = &fb_display[vc->vc_num]; | ||
1450 | struct fbcon_ops *ops = info->fbcon_par; | ||
1451 | |||
1452 | p->yscroll += count; | ||
1453 | if (p->yscroll > p->vrows - vc->vc_rows) { | ||
1454 | ops->bmove(vc, info, p->vrows - vc->vc_rows, | ||
1455 | 0, 0, 0, vc->vc_rows, vc->vc_cols); | ||
1456 | p->yscroll -= p->vrows - vc->vc_rows; | ||
1457 | } | ||
1458 | |||
1459 | ops->var.xoffset = 0; | ||
1460 | ops->var.yoffset = p->yscroll * vc->vc_font.height; | ||
1461 | ops->var.vmode &= ~FB_VMODE_YWRAP; | ||
1462 | ops->update_start(info); | ||
1463 | fbcon_clear_margins(vc, 1); | ||
1464 | scrollback_max += count; | ||
1465 | if (scrollback_max > scrollback_phys_max) | ||
1466 | scrollback_max = scrollback_phys_max; | ||
1467 | scrollback_current = 0; | ||
1468 | } | ||
1469 | |||
1470 | static __inline__ void ypan_up_redraw(struct vc_data *vc, int t, int count) | ||
1471 | { | ||
1472 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; | ||
1473 | struct fbcon_ops *ops = info->fbcon_par; | ||
1474 | struct display *p = &fb_display[vc->vc_num]; | ||
1475 | |||
1476 | p->yscroll += count; | ||
1477 | |||
1478 | if (p->yscroll > p->vrows - vc->vc_rows) { | ||
1479 | p->yscroll -= p->vrows - vc->vc_rows; | ||
1480 | fbcon_redraw_move(vc, p, t + count, vc->vc_rows - count, t); | ||
1481 | } | ||
1482 | |||
1483 | ops->var.xoffset = 0; | ||
1484 | ops->var.yoffset = p->yscroll * vc->vc_font.height; | ||
1485 | ops->var.vmode &= ~FB_VMODE_YWRAP; | ||
1486 | ops->update_start(info); | ||
1487 | fbcon_clear_margins(vc, 1); | ||
1488 | scrollback_max += count; | ||
1489 | if (scrollback_max > scrollback_phys_max) | ||
1490 | scrollback_max = scrollback_phys_max; | ||
1491 | scrollback_current = 0; | ||
1492 | } | ||
1493 | |||
1494 | static __inline__ void ypan_down(struct vc_data *vc, int count) | ||
1495 | { | ||
1496 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; | ||
1497 | struct display *p = &fb_display[vc->vc_num]; | ||
1498 | struct fbcon_ops *ops = info->fbcon_par; | ||
1499 | |||
1500 | p->yscroll -= count; | ||
1501 | if (p->yscroll < 0) { | ||
1502 | ops->bmove(vc, info, 0, 0, p->vrows - vc->vc_rows, | ||
1503 | 0, vc->vc_rows, vc->vc_cols); | ||
1504 | p->yscroll += p->vrows - vc->vc_rows; | ||
1505 | } | ||
1506 | |||
1507 | ops->var.xoffset = 0; | ||
1508 | ops->var.yoffset = p->yscroll * vc->vc_font.height; | ||
1509 | ops->var.vmode &= ~FB_VMODE_YWRAP; | ||
1510 | ops->update_start(info); | ||
1511 | fbcon_clear_margins(vc, 1); | ||
1512 | scrollback_max -= count; | ||
1513 | if (scrollback_max < 0) | ||
1514 | scrollback_max = 0; | ||
1515 | scrollback_current = 0; | ||
1516 | } | ||
1517 | |||
1518 | static __inline__ void ypan_down_redraw(struct vc_data *vc, int t, int count) | ||
1519 | { | ||
1520 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; | ||
1521 | struct fbcon_ops *ops = info->fbcon_par; | ||
1522 | struct display *p = &fb_display[vc->vc_num]; | ||
1523 | |||
1524 | p->yscroll -= count; | ||
1525 | |||
1526 | if (p->yscroll < 0) { | ||
1527 | p->yscroll += p->vrows - vc->vc_rows; | ||
1528 | fbcon_redraw_move(vc, p, t, vc->vc_rows - count, t + count); | ||
1529 | } | ||
1530 | |||
1531 | ops->var.xoffset = 0; | ||
1532 | ops->var.yoffset = p->yscroll * vc->vc_font.height; | ||
1533 | ops->var.vmode &= ~FB_VMODE_YWRAP; | ||
1534 | ops->update_start(info); | ||
1535 | fbcon_clear_margins(vc, 1); | ||
1536 | scrollback_max -= count; | ||
1537 | if (scrollback_max < 0) | ||
1538 | scrollback_max = 0; | ||
1539 | scrollback_current = 0; | ||
1540 | } | ||
1541 | |||
1542 | static void fbcon_redraw_softback(struct vc_data *vc, struct display *p, | ||
1543 | long delta) | ||
1544 | { | ||
1545 | int count = vc->vc_rows; | ||
1546 | unsigned short *d, *s; | ||
1547 | unsigned long n; | ||
1548 | int line = 0; | ||
1549 | |||
1550 | d = (u16 *) softback_curr; | ||
1551 | if (d == (u16 *) softback_in) | ||
1552 | d = (u16 *) vc->vc_origin; | ||
1553 | n = softback_curr + delta * vc->vc_size_row; | ||
1554 | softback_lines -= delta; | ||
1555 | if (delta < 0) { | ||
1556 | if (softback_curr < softback_top && n < softback_buf) { | ||
1557 | n += softback_end - softback_buf; | ||
1558 | if (n < softback_top) { | ||
1559 | softback_lines -= | ||
1560 | (softback_top - n) / vc->vc_size_row; | ||
1561 | n = softback_top; | ||
1562 | } | ||
1563 | } else if (softback_curr >= softback_top | ||
1564 | && n < softback_top) { | ||
1565 | softback_lines -= | ||
1566 | (softback_top - n) / vc->vc_size_row; | ||
1567 | n = softback_top; | ||
1568 | } | ||
1569 | } else { | ||
1570 | if (softback_curr > softback_in && n >= softback_end) { | ||
1571 | n += softback_buf - softback_end; | ||
1572 | if (n > softback_in) { | ||
1573 | n = softback_in; | ||
1574 | softback_lines = 0; | ||
1575 | } | ||
1576 | } else if (softback_curr <= softback_in && n > softback_in) { | ||
1577 | n = softback_in; | ||
1578 | softback_lines = 0; | ||
1579 | } | ||
1580 | } | ||
1581 | if (n == softback_curr) | ||
1582 | return; | ||
1583 | softback_curr = n; | ||
1584 | s = (u16 *) softback_curr; | ||
1585 | if (s == (u16 *) softback_in) | ||
1586 | s = (u16 *) vc->vc_origin; | ||
1587 | while (count--) { | ||
1588 | unsigned short *start; | ||
1589 | unsigned short *le; | ||
1590 | unsigned short c; | ||
1591 | int x = 0; | ||
1592 | unsigned short attr = 1; | ||
1593 | |||
1594 | start = s; | ||
1595 | le = advance_row(s, 1); | ||
1596 | do { | ||
1597 | c = scr_readw(s); | ||
1598 | if (attr != (c & 0xff00)) { | ||
1599 | attr = c & 0xff00; | ||
1600 | if (s > start) { | ||
1601 | fbcon_putcs(vc, start, s - start, | ||
1602 | line, x); | ||
1603 | x += s - start; | ||
1604 | start = s; | ||
1605 | } | ||
1606 | } | ||
1607 | if (c == scr_readw(d)) { | ||
1608 | if (s > start) { | ||
1609 | fbcon_putcs(vc, start, s - start, | ||
1610 | line, x); | ||
1611 | x += s - start + 1; | ||
1612 | start = s + 1; | ||
1613 | } else { | ||
1614 | x++; | ||
1615 | start++; | ||
1616 | } | ||
1617 | } | ||
1618 | s++; | ||
1619 | d++; | ||
1620 | } while (s < le); | ||
1621 | if (s > start) | ||
1622 | fbcon_putcs(vc, start, s - start, line, x); | ||
1623 | line++; | ||
1624 | if (d == (u16 *) softback_end) | ||
1625 | d = (u16 *) softback_buf; | ||
1626 | if (d == (u16 *) softback_in) | ||
1627 | d = (u16 *) vc->vc_origin; | ||
1628 | if (s == (u16 *) softback_end) | ||
1629 | s = (u16 *) softback_buf; | ||
1630 | if (s == (u16 *) softback_in) | ||
1631 | s = (u16 *) vc->vc_origin; | ||
1632 | } | ||
1633 | } | ||
1634 | |||
1635 | static void fbcon_redraw_move(struct vc_data *vc, struct display *p, | ||
1636 | int line, int count, int dy) | ||
1637 | { | ||
1638 | unsigned short *s = (unsigned short *) | ||
1639 | (vc->vc_origin + vc->vc_size_row * line); | ||
1640 | |||
1641 | while (count--) { | ||
1642 | unsigned short *start = s; | ||
1643 | unsigned short *le = advance_row(s, 1); | ||
1644 | unsigned short c; | ||
1645 | int x = 0; | ||
1646 | unsigned short attr = 1; | ||
1647 | |||
1648 | do { | ||
1649 | c = scr_readw(s); | ||
1650 | if (attr != (c & 0xff00)) { | ||
1651 | attr = c & 0xff00; | ||
1652 | if (s > start) { | ||
1653 | fbcon_putcs(vc, start, s - start, | ||
1654 | dy, x); | ||
1655 | x += s - start; | ||
1656 | start = s; | ||
1657 | } | ||
1658 | } | ||
1659 | console_conditional_schedule(); | ||
1660 | s++; | ||
1661 | } while (s < le); | ||
1662 | if (s > start) | ||
1663 | fbcon_putcs(vc, start, s - start, dy, x); | ||
1664 | console_conditional_schedule(); | ||
1665 | dy++; | ||
1666 | } | ||
1667 | } | ||
1668 | |||
1669 | static void fbcon_redraw_blit(struct vc_data *vc, struct fb_info *info, | ||
1670 | struct display *p, int line, int count, int ycount) | ||
1671 | { | ||
1672 | int offset = ycount * vc->vc_cols; | ||
1673 | unsigned short *d = (unsigned short *) | ||
1674 | (vc->vc_origin + vc->vc_size_row * line); | ||
1675 | unsigned short *s = d + offset; | ||
1676 | struct fbcon_ops *ops = info->fbcon_par; | ||
1677 | |||
1678 | while (count--) { | ||
1679 | unsigned short *start = s; | ||
1680 | unsigned short *le = advance_row(s, 1); | ||
1681 | unsigned short c; | ||
1682 | int x = 0; | ||
1683 | |||
1684 | do { | ||
1685 | c = scr_readw(s); | ||
1686 | |||
1687 | if (c == scr_readw(d)) { | ||
1688 | if (s > start) { | ||
1689 | ops->bmove(vc, info, line + ycount, x, | ||
1690 | line, x, 1, s-start); | ||
1691 | x += s - start + 1; | ||
1692 | start = s + 1; | ||
1693 | } else { | ||
1694 | x++; | ||
1695 | start++; | ||
1696 | } | ||
1697 | } | ||
1698 | |||
1699 | scr_writew(c, d); | ||
1700 | console_conditional_schedule(); | ||
1701 | s++; | ||
1702 | d++; | ||
1703 | } while (s < le); | ||
1704 | if (s > start) | ||
1705 | ops->bmove(vc, info, line + ycount, x, line, x, 1, | ||
1706 | s-start); | ||
1707 | console_conditional_schedule(); | ||
1708 | if (ycount > 0) | ||
1709 | line++; | ||
1710 | else { | ||
1711 | line--; | ||
1712 | /* NOTE: We subtract two lines from these pointers */ | ||
1713 | s -= vc->vc_size_row; | ||
1714 | d -= vc->vc_size_row; | ||
1715 | } | ||
1716 | } | ||
1717 | } | ||
1718 | |||
1719 | static void fbcon_redraw(struct vc_data *vc, struct display *p, | ||
1720 | int line, int count, int offset) | ||
1721 | { | ||
1722 | unsigned short *d = (unsigned short *) | ||
1723 | (vc->vc_origin + vc->vc_size_row * line); | ||
1724 | unsigned short *s = d + offset; | ||
1725 | |||
1726 | while (count--) { | ||
1727 | unsigned short *start = s; | ||
1728 | unsigned short *le = advance_row(s, 1); | ||
1729 | unsigned short c; | ||
1730 | int x = 0; | ||
1731 | unsigned short attr = 1; | ||
1732 | |||
1733 | do { | ||
1734 | c = scr_readw(s); | ||
1735 | if (attr != (c & 0xff00)) { | ||
1736 | attr = c & 0xff00; | ||
1737 | if (s > start) { | ||
1738 | fbcon_putcs(vc, start, s - start, | ||
1739 | line, x); | ||
1740 | x += s - start; | ||
1741 | start = s; | ||
1742 | } | ||
1743 | } | ||
1744 | if (c == scr_readw(d)) { | ||
1745 | if (s > start) { | ||
1746 | fbcon_putcs(vc, start, s - start, | ||
1747 | line, x); | ||
1748 | x += s - start + 1; | ||
1749 | start = s + 1; | ||
1750 | } else { | ||
1751 | x++; | ||
1752 | start++; | ||
1753 | } | ||
1754 | } | ||
1755 | scr_writew(c, d); | ||
1756 | console_conditional_schedule(); | ||
1757 | s++; | ||
1758 | d++; | ||
1759 | } while (s < le); | ||
1760 | if (s > start) | ||
1761 | fbcon_putcs(vc, start, s - start, line, x); | ||
1762 | console_conditional_schedule(); | ||
1763 | if (offset > 0) | ||
1764 | line++; | ||
1765 | else { | ||
1766 | line--; | ||
1767 | /* NOTE: We subtract two lines from these pointers */ | ||
1768 | s -= vc->vc_size_row; | ||
1769 | d -= vc->vc_size_row; | ||
1770 | } | ||
1771 | } | ||
1772 | } | ||
1773 | |||
1774 | static inline void fbcon_softback_note(struct vc_data *vc, int t, | ||
1775 | int count) | ||
1776 | { | ||
1777 | unsigned short *p; | ||
1778 | |||
1779 | if (vc->vc_num != fg_console) | ||
1780 | return; | ||
1781 | p = (unsigned short *) (vc->vc_origin + t * vc->vc_size_row); | ||
1782 | |||
1783 | while (count) { | ||
1784 | scr_memcpyw((u16 *) softback_in, p, vc->vc_size_row); | ||
1785 | count--; | ||
1786 | p = advance_row(p, 1); | ||
1787 | softback_in += vc->vc_size_row; | ||
1788 | if (softback_in == softback_end) | ||
1789 | softback_in = softback_buf; | ||
1790 | if (softback_in == softback_top) { | ||
1791 | softback_top += vc->vc_size_row; | ||
1792 | if (softback_top == softback_end) | ||
1793 | softback_top = softback_buf; | ||
1794 | } | ||
1795 | } | ||
1796 | softback_curr = softback_in; | ||
1797 | } | ||
1798 | |||
1799 | static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b, | ||
1800 | enum con_scroll dir, unsigned int count) | ||
1801 | { | ||
1802 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; | ||
1803 | struct display *p = &fb_display[vc->vc_num]; | ||
1804 | int scroll_partial = info->flags & FBINFO_PARTIAL_PAN_OK; | ||
1805 | |||
1806 | if (fbcon_is_inactive(vc, info)) | ||
1807 | return true; | ||
1808 | |||
1809 | fbcon_cursor(vc, CM_ERASE); | ||
1810 | |||
1811 | /* | ||
1812 | * ++Geert: Only use ywrap/ypan if the console is in text mode | ||
1813 | * ++Andrew: Only use ypan on hardware text mode when scrolling the | ||
1814 | * whole screen (prevents flicker). | ||
1815 | */ | ||
1816 | |||
1817 | switch (dir) { | ||
1818 | case SM_UP: | ||
1819 | if (count > vc->vc_rows) /* Maximum realistic size */ | ||
1820 | count = vc->vc_rows; | ||
1821 | if (softback_top) | ||
1822 | fbcon_softback_note(vc, t, count); | ||
1823 | if (logo_shown >= 0) | ||
1824 | goto redraw_up; | ||
1825 | switch (p->scrollmode) { | ||
1826 | case SCROLL_MOVE: | ||
1827 | fbcon_redraw_blit(vc, info, p, t, b - t - count, | ||
1828 | count); | ||
1829 | fbcon_clear(vc, b - count, 0, count, vc->vc_cols); | ||
1830 | scr_memsetw((unsigned short *) (vc->vc_origin + | ||
1831 | vc->vc_size_row * | ||
1832 | (b - count)), | ||
1833 | vc->vc_video_erase_char, | ||
1834 | vc->vc_size_row * count); | ||
1835 | return true; | ||
1836 | break; | ||
1837 | |||
1838 | case SCROLL_WRAP_MOVE: | ||
1839 | if (b - t - count > 3 * vc->vc_rows >> 2) { | ||
1840 | if (t > 0) | ||
1841 | fbcon_bmove(vc, 0, 0, count, 0, t, | ||
1842 | vc->vc_cols); | ||
1843 | ywrap_up(vc, count); | ||
1844 | if (vc->vc_rows - b > 0) | ||
1845 | fbcon_bmove(vc, b - count, 0, b, 0, | ||
1846 | vc->vc_rows - b, | ||
1847 | vc->vc_cols); | ||
1848 | } else if (info->flags & FBINFO_READS_FAST) | ||
1849 | fbcon_bmove(vc, t + count, 0, t, 0, | ||
1850 | b - t - count, vc->vc_cols); | ||
1851 | else | ||
1852 | goto redraw_up; | ||
1853 | fbcon_clear(vc, b - count, 0, count, vc->vc_cols); | ||
1854 | break; | ||
1855 | |||
1856 | case SCROLL_PAN_REDRAW: | ||
1857 | if ((p->yscroll + count <= | ||
1858 | 2 * (p->vrows - vc->vc_rows)) | ||
1859 | && ((!scroll_partial && (b - t == vc->vc_rows)) | ||
1860 | || (scroll_partial | ||
1861 | && (b - t - count > | ||
1862 | 3 * vc->vc_rows >> 2)))) { | ||
1863 | if (t > 0) | ||
1864 | fbcon_redraw_move(vc, p, 0, t, count); | ||
1865 | ypan_up_redraw(vc, t, count); | ||
1866 | if (vc->vc_rows - b > 0) | ||
1867 | fbcon_redraw_move(vc, p, b, | ||
1868 | vc->vc_rows - b, b); | ||
1869 | } else | ||
1870 | fbcon_redraw_move(vc, p, t + count, b - t - count, t); | ||
1871 | fbcon_clear(vc, b - count, 0, count, vc->vc_cols); | ||
1872 | break; | ||
1873 | |||
1874 | case SCROLL_PAN_MOVE: | ||
1875 | if ((p->yscroll + count <= | ||
1876 | 2 * (p->vrows - vc->vc_rows)) | ||
1877 | && ((!scroll_partial && (b - t == vc->vc_rows)) | ||
1878 | || (scroll_partial | ||
1879 | && (b - t - count > | ||
1880 | 3 * vc->vc_rows >> 2)))) { | ||
1881 | if (t > 0) | ||
1882 | fbcon_bmove(vc, 0, 0, count, 0, t, | ||
1883 | vc->vc_cols); | ||
1884 | ypan_up(vc, count); | ||
1885 | if (vc->vc_rows - b > 0) | ||
1886 | fbcon_bmove(vc, b - count, 0, b, 0, | ||
1887 | vc->vc_rows - b, | ||
1888 | vc->vc_cols); | ||
1889 | } else if (info->flags & FBINFO_READS_FAST) | ||
1890 | fbcon_bmove(vc, t + count, 0, t, 0, | ||
1891 | b - t - count, vc->vc_cols); | ||
1892 | else | ||
1893 | goto redraw_up; | ||
1894 | fbcon_clear(vc, b - count, 0, count, vc->vc_cols); | ||
1895 | break; | ||
1896 | |||
1897 | case SCROLL_REDRAW: | ||
1898 | redraw_up: | ||
1899 | fbcon_redraw(vc, p, t, b - t - count, | ||
1900 | count * vc->vc_cols); | ||
1901 | fbcon_clear(vc, b - count, 0, count, vc->vc_cols); | ||
1902 | scr_memsetw((unsigned short *) (vc->vc_origin + | ||
1903 | vc->vc_size_row * | ||
1904 | (b - count)), | ||
1905 | vc->vc_video_erase_char, | ||
1906 | vc->vc_size_row * count); | ||
1907 | return true; | ||
1908 | } | ||
1909 | break; | ||
1910 | |||
1911 | case SM_DOWN: | ||
1912 | if (count > vc->vc_rows) /* Maximum realistic size */ | ||
1913 | count = vc->vc_rows; | ||
1914 | if (logo_shown >= 0) | ||
1915 | goto redraw_down; | ||
1916 | switch (p->scrollmode) { | ||
1917 | case SCROLL_MOVE: | ||
1918 | fbcon_redraw_blit(vc, info, p, b - 1, b - t - count, | ||
1919 | -count); | ||
1920 | fbcon_clear(vc, t, 0, count, vc->vc_cols); | ||
1921 | scr_memsetw((unsigned short *) (vc->vc_origin + | ||
1922 | vc->vc_size_row * | ||
1923 | t), | ||
1924 | vc->vc_video_erase_char, | ||
1925 | vc->vc_size_row * count); | ||
1926 | return true; | ||
1927 | break; | ||
1928 | |||
1929 | case SCROLL_WRAP_MOVE: | ||
1930 | if (b - t - count > 3 * vc->vc_rows >> 2) { | ||
1931 | if (vc->vc_rows - b > 0) | ||
1932 | fbcon_bmove(vc, b, 0, b - count, 0, | ||
1933 | vc->vc_rows - b, | ||
1934 | vc->vc_cols); | ||
1935 | ywrap_down(vc, count); | ||
1936 | if (t > 0) | ||
1937 | fbcon_bmove(vc, count, 0, 0, 0, t, | ||
1938 | vc->vc_cols); | ||
1939 | } else if (info->flags & FBINFO_READS_FAST) | ||
1940 | fbcon_bmove(vc, t, 0, t + count, 0, | ||
1941 | b - t - count, vc->vc_cols); | ||
1942 | else | ||
1943 | goto redraw_down; | ||
1944 | fbcon_clear(vc, t, 0, count, vc->vc_cols); | ||
1945 | break; | ||
1946 | |||
1947 | case SCROLL_PAN_MOVE: | ||
1948 | if ((count - p->yscroll <= p->vrows - vc->vc_rows) | ||
1949 | && ((!scroll_partial && (b - t == vc->vc_rows)) | ||
1950 | || (scroll_partial | ||
1951 | && (b - t - count > | ||
1952 | 3 * vc->vc_rows >> 2)))) { | ||
1953 | if (vc->vc_rows - b > 0) | ||
1954 | fbcon_bmove(vc, b, 0, b - count, 0, | ||
1955 | vc->vc_rows - b, | ||
1956 | vc->vc_cols); | ||
1957 | ypan_down(vc, count); | ||
1958 | if (t > 0) | ||
1959 | fbcon_bmove(vc, count, 0, 0, 0, t, | ||
1960 | vc->vc_cols); | ||
1961 | } else if (info->flags & FBINFO_READS_FAST) | ||
1962 | fbcon_bmove(vc, t, 0, t + count, 0, | ||
1963 | b - t - count, vc->vc_cols); | ||
1964 | else | ||
1965 | goto redraw_down; | ||
1966 | fbcon_clear(vc, t, 0, count, vc->vc_cols); | ||
1967 | break; | ||
1968 | |||
1969 | case SCROLL_PAN_REDRAW: | ||
1970 | if ((count - p->yscroll <= p->vrows - vc->vc_rows) | ||
1971 | && ((!scroll_partial && (b - t == vc->vc_rows)) | ||
1972 | || (scroll_partial | ||
1973 | && (b - t - count > | ||
1974 | 3 * vc->vc_rows >> 2)))) { | ||
1975 | if (vc->vc_rows - b > 0) | ||
1976 | fbcon_redraw_move(vc, p, b, vc->vc_rows - b, | ||
1977 | b - count); | ||
1978 | ypan_down_redraw(vc, t, count); | ||
1979 | if (t > 0) | ||
1980 | fbcon_redraw_move(vc, p, count, t, 0); | ||
1981 | } else | ||
1982 | fbcon_redraw_move(vc, p, t, b - t - count, t + count); | ||
1983 | fbcon_clear(vc, t, 0, count, vc->vc_cols); | ||
1984 | break; | ||
1985 | |||
1986 | case SCROLL_REDRAW: | ||
1987 | redraw_down: | ||
1988 | fbcon_redraw(vc, p, b - 1, b - t - count, | ||
1989 | -count * vc->vc_cols); | ||
1990 | fbcon_clear(vc, t, 0, count, vc->vc_cols); | ||
1991 | scr_memsetw((unsigned short *) (vc->vc_origin + | ||
1992 | vc->vc_size_row * | ||
1993 | t), | ||
1994 | vc->vc_video_erase_char, | ||
1995 | vc->vc_size_row * count); | ||
1996 | return true; | ||
1997 | } | ||
1998 | } | ||
1999 | return false; | ||
2000 | } | ||
2001 | |||
2002 | |||
2003 | static void fbcon_bmove(struct vc_data *vc, int sy, int sx, int dy, int dx, | ||
2004 | int height, int width) | ||
2005 | { | ||
2006 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; | ||
2007 | struct display *p = &fb_display[vc->vc_num]; | ||
2008 | |||
2009 | if (fbcon_is_inactive(vc, info)) | ||
2010 | return; | ||
2011 | |||
2012 | if (!width || !height) | ||
2013 | return; | ||
2014 | |||
2015 | /* Split blits that cross physical y_wrap case. | ||
2016 | * Pathological case involves 4 blits, better to use recursive | ||
2017 | * code rather than unrolled case | ||
2018 | * | ||
2019 | * Recursive invocations don't need to erase the cursor over and | ||
2020 | * over again, so we use fbcon_bmove_rec() | ||
2021 | */ | ||
2022 | fbcon_bmove_rec(vc, p, sy, sx, dy, dx, height, width, | ||
2023 | p->vrows - p->yscroll); | ||
2024 | } | ||
2025 | |||
2026 | static void fbcon_bmove_rec(struct vc_data *vc, struct display *p, int sy, int sx, | ||
2027 | int dy, int dx, int height, int width, u_int y_break) | ||
2028 | { | ||
2029 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; | ||
2030 | struct fbcon_ops *ops = info->fbcon_par; | ||
2031 | u_int b; | ||
2032 | |||
2033 | if (sy < y_break && sy + height > y_break) { | ||
2034 | b = y_break - sy; | ||
2035 | if (dy < sy) { /* Avoid trashing self */ | ||
2036 | fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width, | ||
2037 | y_break); | ||
2038 | fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx, | ||
2039 | height - b, width, y_break); | ||
2040 | } else { | ||
2041 | fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx, | ||
2042 | height - b, width, y_break); | ||
2043 | fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width, | ||
2044 | y_break); | ||
2045 | } | ||
2046 | return; | ||
2047 | } | ||
2048 | |||
2049 | if (dy < y_break && dy + height > y_break) { | ||
2050 | b = y_break - dy; | ||
2051 | if (dy < sy) { /* Avoid trashing self */ | ||
2052 | fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width, | ||
2053 | y_break); | ||
2054 | fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx, | ||
2055 | height - b, width, y_break); | ||
2056 | } else { | ||
2057 | fbcon_bmove_rec(vc, p, sy + b, sx, dy + b, dx, | ||
2058 | height - b, width, y_break); | ||
2059 | fbcon_bmove_rec(vc, p, sy, sx, dy, dx, b, width, | ||
2060 | y_break); | ||
2061 | } | ||
2062 | return; | ||
2063 | } | ||
2064 | ops->bmove(vc, info, real_y(p, sy), sx, real_y(p, dy), dx, | ||
2065 | height, width); | ||
2066 | } | ||
2067 | |||
2068 | static void updatescrollmode(struct display *p, | ||
2069 | struct fb_info *info, | ||
2070 | struct vc_data *vc) | ||
2071 | { | ||
2072 | struct fbcon_ops *ops = info->fbcon_par; | ||
2073 | int fh = vc->vc_font.height; | ||
2074 | int cap = info->flags; | ||
2075 | u16 t = 0; | ||
2076 | int ypan = FBCON_SWAP(ops->rotate, info->fix.ypanstep, | ||
2077 | info->fix.xpanstep); | ||
2078 | int ywrap = FBCON_SWAP(ops->rotate, info->fix.ywrapstep, t); | ||
2079 | int yres = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres); | ||
2080 | int vyres = FBCON_SWAP(ops->rotate, info->var.yres_virtual, | ||
2081 | info->var.xres_virtual); | ||
2082 | int good_pan = (cap & FBINFO_HWACCEL_YPAN) && | ||
2083 | divides(ypan, vc->vc_font.height) && vyres > yres; | ||
2084 | int good_wrap = (cap & FBINFO_HWACCEL_YWRAP) && | ||
2085 | divides(ywrap, vc->vc_font.height) && | ||
2086 | divides(vc->vc_font.height, vyres) && | ||
2087 | divides(vc->vc_font.height, yres); | ||
2088 | int reading_fast = cap & FBINFO_READS_FAST; | ||
2089 | int fast_copyarea = (cap & FBINFO_HWACCEL_COPYAREA) && | ||
2090 | !(cap & FBINFO_HWACCEL_DISABLED); | ||
2091 | int fast_imageblit = (cap & FBINFO_HWACCEL_IMAGEBLIT) && | ||
2092 | !(cap & FBINFO_HWACCEL_DISABLED); | ||
2093 | |||
2094 | p->vrows = vyres/fh; | ||
2095 | if (yres > (fh * (vc->vc_rows + 1))) | ||
2096 | p->vrows -= (yres - (fh * vc->vc_rows)) / fh; | ||
2097 | if ((yres % fh) && (vyres % fh < yres % fh)) | ||
2098 | p->vrows--; | ||
2099 | |||
2100 | if (good_wrap || good_pan) { | ||
2101 | if (reading_fast || fast_copyarea) | ||
2102 | p->scrollmode = good_wrap ? | ||
2103 | SCROLL_WRAP_MOVE : SCROLL_PAN_MOVE; | ||
2104 | else | ||
2105 | p->scrollmode = good_wrap ? SCROLL_REDRAW : | ||
2106 | SCROLL_PAN_REDRAW; | ||
2107 | } else { | ||
2108 | if (reading_fast || (fast_copyarea && !fast_imageblit)) | ||
2109 | p->scrollmode = SCROLL_MOVE; | ||
2110 | else | ||
2111 | p->scrollmode = SCROLL_REDRAW; | ||
2112 | } | ||
2113 | } | ||
2114 | |||
2115 | static int fbcon_resize(struct vc_data *vc, unsigned int width, | ||
2116 | unsigned int height, unsigned int user) | ||
2117 | { | ||
2118 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; | ||
2119 | struct fbcon_ops *ops = info->fbcon_par; | ||
2120 | struct display *p = &fb_display[vc->vc_num]; | ||
2121 | struct fb_var_screeninfo var = info->var; | ||
2122 | int x_diff, y_diff, virt_w, virt_h, virt_fw, virt_fh; | ||
2123 | |||
2124 | virt_w = FBCON_SWAP(ops->rotate, width, height); | ||
2125 | virt_h = FBCON_SWAP(ops->rotate, height, width); | ||
2126 | virt_fw = FBCON_SWAP(ops->rotate, vc->vc_font.width, | ||
2127 | vc->vc_font.height); | ||
2128 | virt_fh = FBCON_SWAP(ops->rotate, vc->vc_font.height, | ||
2129 | vc->vc_font.width); | ||
2130 | var.xres = virt_w * virt_fw; | ||
2131 | var.yres = virt_h * virt_fh; | ||
2132 | x_diff = info->var.xres - var.xres; | ||
2133 | y_diff = info->var.yres - var.yres; | ||
2134 | if (x_diff < 0 || x_diff > virt_fw || | ||
2135 | y_diff < 0 || y_diff > virt_fh) { | ||
2136 | const struct fb_videomode *mode; | ||
2137 | |||
2138 | DPRINTK("attempting resize %ix%i\n", var.xres, var.yres); | ||
2139 | mode = fb_find_best_mode(&var, &info->modelist); | ||
2140 | if (mode == NULL) | ||
2141 | return -EINVAL; | ||
2142 | display_to_var(&var, p); | ||
2143 | fb_videomode_to_var(&var, mode); | ||
2144 | |||
2145 | if (virt_w > var.xres/virt_fw || virt_h > var.yres/virt_fh) | ||
2146 | return -EINVAL; | ||
2147 | |||
2148 | DPRINTK("resize now %ix%i\n", var.xres, var.yres); | ||
2149 | if (con_is_visible(vc)) { | ||
2150 | var.activate = FB_ACTIVATE_NOW | | ||
2151 | FB_ACTIVATE_FORCE; | ||
2152 | fb_set_var(info, &var); | ||
2153 | } | ||
2154 | var_to_display(p, &info->var, info); | ||
2155 | ops->var = info->var; | ||
2156 | } | ||
2157 | updatescrollmode(p, info, vc); | ||
2158 | return 0; | ||
2159 | } | ||
2160 | |||
2161 | static int fbcon_switch(struct vc_data *vc) | ||
2162 | { | ||
2163 | struct fb_info *info, *old_info = NULL; | ||
2164 | struct fbcon_ops *ops; | ||
2165 | struct display *p = &fb_display[vc->vc_num]; | ||
2166 | struct fb_var_screeninfo var; | ||
2167 | int i, ret, prev_console, charcnt = 256; | ||
2168 | |||
2169 | info = registered_fb[con2fb_map[vc->vc_num]]; | ||
2170 | ops = info->fbcon_par; | ||
2171 | |||
2172 | if (softback_top) { | ||
2173 | if (softback_lines) | ||
2174 | fbcon_set_origin(vc); | ||
2175 | softback_top = softback_curr = softback_in = softback_buf; | ||
2176 | softback_lines = 0; | ||
2177 | fbcon_update_softback(vc); | ||
2178 | } | ||
2179 | |||
2180 | if (logo_shown >= 0) { | ||
2181 | struct vc_data *conp2 = vc_cons[logo_shown].d; | ||
2182 | |||
2183 | if (conp2->vc_top == logo_lines | ||
2184 | && conp2->vc_bottom == conp2->vc_rows) | ||
2185 | conp2->vc_top = 0; | ||
2186 | logo_shown = FBCON_LOGO_CANSHOW; | ||
2187 | } | ||
2188 | |||
2189 | prev_console = ops->currcon; | ||
2190 | if (prev_console != -1) | ||
2191 | old_info = registered_fb[con2fb_map[prev_console]]; | ||
2192 | /* | ||
2193 | * FIXME: If we have multiple fbdev's loaded, we need to | ||
2194 | * update all info->currcon. Perhaps, we can place this | ||
2195 | * in a centralized structure, but this might break some | ||
2196 | * drivers. | ||
2197 | * | ||
2198 | * info->currcon = vc->vc_num; | ||
2199 | */ | ||
2200 | for (i = 0; i < FB_MAX; i++) { | ||
2201 | if (registered_fb[i] != NULL && registered_fb[i]->fbcon_par) { | ||
2202 | struct fbcon_ops *o = registered_fb[i]->fbcon_par; | ||
2203 | |||
2204 | o->currcon = vc->vc_num; | ||
2205 | } | ||
2206 | } | ||
2207 | memset(&var, 0, sizeof(struct fb_var_screeninfo)); | ||
2208 | display_to_var(&var, p); | ||
2209 | var.activate = FB_ACTIVATE_NOW; | ||
2210 | |||
2211 | /* | ||
2212 | * make sure we don't unnecessarily trip the memcmp() | ||
2213 | * in fb_set_var() | ||
2214 | */ | ||
2215 | info->var.activate = var.activate; | ||
2216 | var.vmode |= info->var.vmode & ~FB_VMODE_MASK; | ||
2217 | fb_set_var(info, &var); | ||
2218 | ops->var = info->var; | ||
2219 | |||
2220 | if (old_info != NULL && (old_info != info || | ||
2221 | info->flags & FBINFO_MISC_ALWAYS_SETPAR)) { | ||
2222 | if (info->fbops->fb_set_par) { | ||
2223 | ret = info->fbops->fb_set_par(info); | ||
2224 | |||
2225 | if (ret) | ||
2226 | printk(KERN_ERR "fbcon_switch: detected " | ||
2227 | "unhandled fb_set_par error, " | ||
2228 | "error code %d\n", ret); | ||
2229 | } | ||
2230 | |||
2231 | if (old_info != info) | ||
2232 | fbcon_del_cursor_timer(old_info); | ||
2233 | } | ||
2234 | |||
2235 | if (fbcon_is_inactive(vc, info) || | ||
2236 | ops->blank_state != FB_BLANK_UNBLANK) | ||
2237 | fbcon_del_cursor_timer(info); | ||
2238 | else | ||
2239 | fbcon_add_cursor_timer(info); | ||
2240 | |||
2241 | set_blitting_type(vc, info); | ||
2242 | ops->cursor_reset = 1; | ||
2243 | |||
2244 | if (ops->rotate_font && ops->rotate_font(info, vc)) { | ||
2245 | ops->rotate = FB_ROTATE_UR; | ||
2246 | set_blitting_type(vc, info); | ||
2247 | } | ||
2248 | |||
2249 | vc->vc_can_do_color = (fb_get_color_depth(&info->var, &info->fix)!=1); | ||
2250 | vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800; | ||
2251 | |||
2252 | if (p->userfont) | ||
2253 | charcnt = FNTCHARCNT(vc->vc_font.data); | ||
2254 | |||
2255 | if (charcnt > 256) | ||
2256 | vc->vc_complement_mask <<= 1; | ||
2257 | |||
2258 | updatescrollmode(p, info, vc); | ||
2259 | |||
2260 | switch (p->scrollmode) { | ||
2261 | case SCROLL_WRAP_MOVE: | ||
2262 | scrollback_phys_max = p->vrows - vc->vc_rows; | ||
2263 | break; | ||
2264 | case SCROLL_PAN_MOVE: | ||
2265 | case SCROLL_PAN_REDRAW: | ||
2266 | scrollback_phys_max = p->vrows - 2 * vc->vc_rows; | ||
2267 | if (scrollback_phys_max < 0) | ||
2268 | scrollback_phys_max = 0; | ||
2269 | break; | ||
2270 | default: | ||
2271 | scrollback_phys_max = 0; | ||
2272 | break; | ||
2273 | } | ||
2274 | |||
2275 | scrollback_max = 0; | ||
2276 | scrollback_current = 0; | ||
2277 | |||
2278 | if (!fbcon_is_inactive(vc, info)) { | ||
2279 | ops->var.xoffset = ops->var.yoffset = p->yscroll = 0; | ||
2280 | ops->update_start(info); | ||
2281 | } | ||
2282 | |||
2283 | fbcon_set_palette(vc, color_table); | ||
2284 | fbcon_clear_margins(vc, 0); | ||
2285 | |||
2286 | if (logo_shown == FBCON_LOGO_DRAW) { | ||
2287 | |||
2288 | logo_shown = fg_console; | ||
2289 | /* This is protected above by initmem_freed */ | ||
2290 | fb_show_logo(info, ops->rotate); | ||
2291 | update_region(vc, | ||
2292 | vc->vc_origin + vc->vc_size_row * vc->vc_top, | ||
2293 | vc->vc_size_row * (vc->vc_bottom - | ||
2294 | vc->vc_top) / 2); | ||
2295 | return 0; | ||
2296 | } | ||
2297 | return 1; | ||
2298 | } | ||
2299 | |||
2300 | static void fbcon_generic_blank(struct vc_data *vc, struct fb_info *info, | ||
2301 | int blank) | ||
2302 | { | ||
2303 | struct fb_event event; | ||
2304 | |||
2305 | if (blank) { | ||
2306 | unsigned short charmask = vc->vc_hi_font_mask ? | ||
2307 | 0x1ff : 0xff; | ||
2308 | unsigned short oldc; | ||
2309 | |||
2310 | oldc = vc->vc_video_erase_char; | ||
2311 | vc->vc_video_erase_char &= charmask; | ||
2312 | fbcon_clear(vc, 0, 0, vc->vc_rows, vc->vc_cols); | ||
2313 | vc->vc_video_erase_char = oldc; | ||
2314 | } | ||
2315 | |||
2316 | |||
2317 | if (!lock_fb_info(info)) | ||
2318 | return; | ||
2319 | event.info = info; | ||
2320 | event.data = ␣ | ||
2321 | fb_notifier_call_chain(FB_EVENT_CONBLANK, &event); | ||
2322 | unlock_fb_info(info); | ||
2323 | } | ||
2324 | |||
2325 | static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch) | ||
2326 | { | ||
2327 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; | ||
2328 | struct fbcon_ops *ops = info->fbcon_par; | ||
2329 | |||
2330 | if (mode_switch) { | ||
2331 | struct fb_var_screeninfo var = info->var; | ||
2332 | |||
2333 | ops->graphics = 1; | ||
2334 | |||
2335 | if (!blank) { | ||
2336 | var.activate = FB_ACTIVATE_NOW | FB_ACTIVATE_FORCE; | ||
2337 | fb_set_var(info, &var); | ||
2338 | ops->graphics = 0; | ||
2339 | ops->var = info->var; | ||
2340 | } | ||
2341 | } | ||
2342 | |||
2343 | if (!fbcon_is_inactive(vc, info)) { | ||
2344 | if (ops->blank_state != blank) { | ||
2345 | ops->blank_state = blank; | ||
2346 | fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW); | ||
2347 | ops->cursor_flash = (!blank); | ||
2348 | |||
2349 | if (!(info->flags & FBINFO_MISC_USEREVENT)) | ||
2350 | if (fb_blank(info, blank)) | ||
2351 | fbcon_generic_blank(vc, info, blank); | ||
2352 | } | ||
2353 | |||
2354 | if (!blank) | ||
2355 | update_screen(vc); | ||
2356 | } | ||
2357 | |||
2358 | if (mode_switch || fbcon_is_inactive(vc, info) || | ||
2359 | ops->blank_state != FB_BLANK_UNBLANK) | ||
2360 | fbcon_del_cursor_timer(info); | ||
2361 | else | ||
2362 | fbcon_add_cursor_timer(info); | ||
2363 | |||
2364 | return 0; | ||
2365 | } | ||
2366 | |||
2367 | static int fbcon_debug_enter(struct vc_data *vc) | ||
2368 | { | ||
2369 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; | ||
2370 | struct fbcon_ops *ops = info->fbcon_par; | ||
2371 | |||
2372 | ops->save_graphics = ops->graphics; | ||
2373 | ops->graphics = 0; | ||
2374 | if (info->fbops->fb_debug_enter) | ||
2375 | info->fbops->fb_debug_enter(info); | ||
2376 | fbcon_set_palette(vc, color_table); | ||
2377 | return 0; | ||
2378 | } | ||
2379 | |||
2380 | static int fbcon_debug_leave(struct vc_data *vc) | ||
2381 | { | ||
2382 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; | ||
2383 | struct fbcon_ops *ops = info->fbcon_par; | ||
2384 | |||
2385 | ops->graphics = ops->save_graphics; | ||
2386 | if (info->fbops->fb_debug_leave) | ||
2387 | info->fbops->fb_debug_leave(info); | ||
2388 | return 0; | ||
2389 | } | ||
2390 | |||
2391 | static int fbcon_get_font(struct vc_data *vc, struct console_font *font) | ||
2392 | { | ||
2393 | u8 *fontdata = vc->vc_font.data; | ||
2394 | u8 *data = font->data; | ||
2395 | int i, j; | ||
2396 | |||
2397 | font->width = vc->vc_font.width; | ||
2398 | font->height = vc->vc_font.height; | ||
2399 | font->charcount = vc->vc_hi_font_mask ? 512 : 256; | ||
2400 | if (!font->data) | ||
2401 | return 0; | ||
2402 | |||
2403 | if (font->width <= 8) { | ||
2404 | j = vc->vc_font.height; | ||
2405 | for (i = 0; i < font->charcount; i++) { | ||
2406 | memcpy(data, fontdata, j); | ||
2407 | memset(data + j, 0, 32 - j); | ||
2408 | data += 32; | ||
2409 | fontdata += j; | ||
2410 | } | ||
2411 | } else if (font->width <= 16) { | ||
2412 | j = vc->vc_font.height * 2; | ||
2413 | for (i = 0; i < font->charcount; i++) { | ||
2414 | memcpy(data, fontdata, j); | ||
2415 | memset(data + j, 0, 64 - j); | ||
2416 | data += 64; | ||
2417 | fontdata += j; | ||
2418 | } | ||
2419 | } else if (font->width <= 24) { | ||
2420 | for (i = 0; i < font->charcount; i++) { | ||
2421 | for (j = 0; j < vc->vc_font.height; j++) { | ||
2422 | *data++ = fontdata[0]; | ||
2423 | *data++ = fontdata[1]; | ||
2424 | *data++ = fontdata[2]; | ||
2425 | fontdata += sizeof(u32); | ||
2426 | } | ||
2427 | memset(data, 0, 3 * (32 - j)); | ||
2428 | data += 3 * (32 - j); | ||
2429 | } | ||
2430 | } else { | ||
2431 | j = vc->vc_font.height * 4; | ||
2432 | for (i = 0; i < font->charcount; i++) { | ||
2433 | memcpy(data, fontdata, j); | ||
2434 | memset(data + j, 0, 128 - j); | ||
2435 | data += 128; | ||
2436 | fontdata += j; | ||
2437 | } | ||
2438 | } | ||
2439 | return 0; | ||
2440 | } | ||
2441 | |||
2442 | /* set/clear vc_hi_font_mask and update vc attrs accordingly */ | ||
2443 | static void set_vc_hi_font(struct vc_data *vc, bool set) | ||
2444 | { | ||
2445 | if (!set) { | ||
2446 | vc->vc_hi_font_mask = 0; | ||
2447 | if (vc->vc_can_do_color) { | ||
2448 | vc->vc_complement_mask >>= 1; | ||
2449 | vc->vc_s_complement_mask >>= 1; | ||
2450 | } | ||
2451 | |||
2452 | /* ++Edmund: reorder the attribute bits */ | ||
2453 | if (vc->vc_can_do_color) { | ||
2454 | unsigned short *cp = | ||
2455 | (unsigned short *) vc->vc_origin; | ||
2456 | int count = vc->vc_screenbuf_size / 2; | ||
2457 | unsigned short c; | ||
2458 | for (; count > 0; count--, cp++) { | ||
2459 | c = scr_readw(cp); | ||
2460 | scr_writew(((c & 0xfe00) >> 1) | | ||
2461 | (c & 0xff), cp); | ||
2462 | } | ||
2463 | c = vc->vc_video_erase_char; | ||
2464 | vc->vc_video_erase_char = | ||
2465 | ((c & 0xfe00) >> 1) | (c & 0xff); | ||
2466 | vc->vc_attr >>= 1; | ||
2467 | } | ||
2468 | } else { | ||
2469 | vc->vc_hi_font_mask = 0x100; | ||
2470 | if (vc->vc_can_do_color) { | ||
2471 | vc->vc_complement_mask <<= 1; | ||
2472 | vc->vc_s_complement_mask <<= 1; | ||
2473 | } | ||
2474 | |||
2475 | /* ++Edmund: reorder the attribute bits */ | ||
2476 | { | ||
2477 | unsigned short *cp = | ||
2478 | (unsigned short *) vc->vc_origin; | ||
2479 | int count = vc->vc_screenbuf_size / 2; | ||
2480 | unsigned short c; | ||
2481 | for (; count > 0; count--, cp++) { | ||
2482 | unsigned short newc; | ||
2483 | c = scr_readw(cp); | ||
2484 | if (vc->vc_can_do_color) | ||
2485 | newc = | ||
2486 | ((c & 0xff00) << 1) | (c & | ||
2487 | 0xff); | ||
2488 | else | ||
2489 | newc = c & ~0x100; | ||
2490 | scr_writew(newc, cp); | ||
2491 | } | ||
2492 | c = vc->vc_video_erase_char; | ||
2493 | if (vc->vc_can_do_color) { | ||
2494 | vc->vc_video_erase_char = | ||
2495 | ((c & 0xff00) << 1) | (c & 0xff); | ||
2496 | vc->vc_attr <<= 1; | ||
2497 | } else | ||
2498 | vc->vc_video_erase_char = c & ~0x100; | ||
2499 | } | ||
2500 | } | ||
2501 | } | ||
2502 | |||
2503 | static int fbcon_do_set_font(struct vc_data *vc, int w, int h, | ||
2504 | const u8 * data, int userfont) | ||
2505 | { | ||
2506 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; | ||
2507 | struct fbcon_ops *ops = info->fbcon_par; | ||
2508 | struct display *p = &fb_display[vc->vc_num]; | ||
2509 | int resize; | ||
2510 | int cnt; | ||
2511 | char *old_data = NULL; | ||
2512 | |||
2513 | if (con_is_visible(vc) && softback_lines) | ||
2514 | fbcon_set_origin(vc); | ||
2515 | |||
2516 | resize = (w != vc->vc_font.width) || (h != vc->vc_font.height); | ||
2517 | if (p->userfont) | ||
2518 | old_data = vc->vc_font.data; | ||
2519 | if (userfont) | ||
2520 | cnt = FNTCHARCNT(data); | ||
2521 | else | ||
2522 | cnt = 256; | ||
2523 | vc->vc_font.data = (void *)(p->fontdata = data); | ||
2524 | if ((p->userfont = userfont)) | ||
2525 | REFCOUNT(data)++; | ||
2526 | vc->vc_font.width = w; | ||
2527 | vc->vc_font.height = h; | ||
2528 | if (vc->vc_hi_font_mask && cnt == 256) | ||
2529 | set_vc_hi_font(vc, false); | ||
2530 | else if (!vc->vc_hi_font_mask && cnt == 512) | ||
2531 | set_vc_hi_font(vc, true); | ||
2532 | |||
2533 | if (resize) { | ||
2534 | int cols, rows; | ||
2535 | |||
2536 | cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres); | ||
2537 | rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres); | ||
2538 | cols /= w; | ||
2539 | rows /= h; | ||
2540 | vc_resize(vc, cols, rows); | ||
2541 | if (con_is_visible(vc) && softback_buf) | ||
2542 | fbcon_update_softback(vc); | ||
2543 | } else if (con_is_visible(vc) | ||
2544 | && vc->vc_mode == KD_TEXT) { | ||
2545 | fbcon_clear_margins(vc, 0); | ||
2546 | update_screen(vc); | ||
2547 | } | ||
2548 | |||
2549 | if (old_data && (--REFCOUNT(old_data) == 0)) | ||
2550 | kfree(old_data - FONT_EXTRA_WORDS * sizeof(int)); | ||
2551 | return 0; | ||
2552 | } | ||
2553 | |||
2554 | static int fbcon_copy_font(struct vc_data *vc, int con) | ||
2555 | { | ||
2556 | struct display *od = &fb_display[con]; | ||
2557 | struct console_font *f = &vc->vc_font; | ||
2558 | |||
2559 | if (od->fontdata == f->data) | ||
2560 | return 0; /* already the same font... */ | ||
2561 | return fbcon_do_set_font(vc, f->width, f->height, od->fontdata, od->userfont); | ||
2562 | } | ||
2563 | |||
2564 | /* | ||
2565 | * User asked to set font; we are guaranteed that | ||
2566 | * a) width and height are in range 1..32 | ||
2567 | * b) charcount does not exceed 512 | ||
2568 | * but lets not assume that, since someone might someday want to use larger | ||
2569 | * fonts. And charcount of 512 is small for unicode support. | ||
2570 | * | ||
2571 | * However, user space gives the font in 32 rows , regardless of | ||
2572 | * actual font height. So a new API is needed if support for larger fonts | ||
2573 | * is ever implemented. | ||
2574 | */ | ||
2575 | |||
2576 | static int fbcon_set_font(struct vc_data *vc, struct console_font *font, unsigned flags) | ||
2577 | { | ||
2578 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; | ||
2579 | unsigned charcount = font->charcount; | ||
2580 | int w = font->width; | ||
2581 | int h = font->height; | ||
2582 | int size; | ||
2583 | int i, csum; | ||
2584 | u8 *new_data, *data = font->data; | ||
2585 | int pitch = (font->width+7) >> 3; | ||
2586 | |||
2587 | /* Is there a reason why fbconsole couldn't handle any charcount >256? | ||
2588 | * If not this check should be changed to charcount < 256 */ | ||
2589 | if (charcount != 256 && charcount != 512) | ||
2590 | return -EINVAL; | ||
2591 | |||
2592 | /* Make sure drawing engine can handle the font */ | ||
2593 | if (!(info->pixmap.blit_x & (1 << (font->width - 1))) || | ||
2594 | !(info->pixmap.blit_y & (1 << (font->height - 1)))) | ||
2595 | return -EINVAL; | ||
2596 | |||
2597 | /* Make sure driver can handle the font length */ | ||
2598 | if (fbcon_invalid_charcount(info, charcount)) | ||
2599 | return -EINVAL; | ||
2600 | |||
2601 | size = h * pitch * charcount; | ||
2602 | |||
2603 | new_data = kmalloc(FONT_EXTRA_WORDS * sizeof(int) + size, GFP_USER); | ||
2604 | |||
2605 | if (!new_data) | ||
2606 | return -ENOMEM; | ||
2607 | |||
2608 | new_data += FONT_EXTRA_WORDS * sizeof(int); | ||
2609 | FNTSIZE(new_data) = size; | ||
2610 | FNTCHARCNT(new_data) = charcount; | ||
2611 | REFCOUNT(new_data) = 0; /* usage counter */ | ||
2612 | for (i=0; i< charcount; i++) { | ||
2613 | memcpy(new_data + i*h*pitch, data + i*32*pitch, h*pitch); | ||
2614 | } | ||
2615 | |||
2616 | /* Since linux has a nice crc32 function use it for counting font | ||
2617 | * checksums. */ | ||
2618 | csum = crc32(0, new_data, size); | ||
2619 | |||
2620 | FNTSUM(new_data) = csum; | ||
2621 | /* Check if the same font is on some other console already */ | ||
2622 | for (i = first_fb_vc; i <= last_fb_vc; i++) { | ||
2623 | struct vc_data *tmp = vc_cons[i].d; | ||
2624 | |||
2625 | if (fb_display[i].userfont && | ||
2626 | fb_display[i].fontdata && | ||
2627 | FNTSUM(fb_display[i].fontdata) == csum && | ||
2628 | FNTSIZE(fb_display[i].fontdata) == size && | ||
2629 | tmp->vc_font.width == w && | ||
2630 | !memcmp(fb_display[i].fontdata, new_data, size)) { | ||
2631 | kfree(new_data - FONT_EXTRA_WORDS * sizeof(int)); | ||
2632 | new_data = (u8 *)fb_display[i].fontdata; | ||
2633 | break; | ||
2634 | } | ||
2635 | } | ||
2636 | return fbcon_do_set_font(vc, font->width, font->height, new_data, 1); | ||
2637 | } | ||
2638 | |||
2639 | static int fbcon_set_def_font(struct vc_data *vc, struct console_font *font, char *name) | ||
2640 | { | ||
2641 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; | ||
2642 | const struct font_desc *f; | ||
2643 | |||
2644 | if (!name) | ||
2645 | f = get_default_font(info->var.xres, info->var.yres, | ||
2646 | info->pixmap.blit_x, info->pixmap.blit_y); | ||
2647 | else if (!(f = find_font(name))) | ||
2648 | return -ENOENT; | ||
2649 | |||
2650 | font->width = f->width; | ||
2651 | font->height = f->height; | ||
2652 | return fbcon_do_set_font(vc, f->width, f->height, f->data, 0); | ||
2653 | } | ||
2654 | |||
2655 | static u16 palette_red[16]; | ||
2656 | static u16 palette_green[16]; | ||
2657 | static u16 palette_blue[16]; | ||
2658 | |||
2659 | static struct fb_cmap palette_cmap = { | ||
2660 | 0, 16, palette_red, palette_green, palette_blue, NULL | ||
2661 | }; | ||
2662 | |||
2663 | static void fbcon_set_palette(struct vc_data *vc, const unsigned char *table) | ||
2664 | { | ||
2665 | struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; | ||
2666 | int i, j, k, depth; | ||
2667 | u8 val; | ||
2668 | |||
2669 | if (fbcon_is_inactive(vc, info)) | ||
2670 | return; | ||
2671 | |||
2672 | if (!con_is_visible(vc)) | ||
2673 | return; | ||
2674 | |||
2675 | depth = fb_get_color_depth(&info->var, &info->fix); | ||
2676 | if (depth > 3) { | ||
2677 | for (i = j = 0; i < 16; i++) { | ||
2678 | k = table[i]; | ||
2679 | val = vc->vc_palette[j++]; | ||
2680 | palette_red[k] = (val << 8) | val; | ||
2681 | val = vc->vc_palette[j++]; | ||
2682 | palette_green[k] = (val << 8) | val; | ||
2683 | val = vc->vc_palette[j++]; | ||
2684 | palette_blue[k] = (val << 8) | val; | ||
2685 | } | ||
2686 | palette_cmap.len = 16; | ||
2687 | palette_cmap.start = 0; | ||
2688 | /* | ||
2689 | * If framebuffer is capable of less than 16 colors, | ||
2690 | * use default palette of fbcon. | ||
2691 | */ | ||
2692 | } else | ||
2693 | fb_copy_cmap(fb_default_cmap(1 << depth), &palette_cmap); | ||
2694 | |||
2695 | fb_set_cmap(&palette_cmap, info); | ||
2696 | } | ||
2697 | |||
2698 | static u16 *fbcon_screen_pos(struct vc_data *vc, int offset) | ||
2699 | { | ||
2700 | unsigned long p; | ||
2701 | int line; | ||
2702 | |||
2703 | if (vc->vc_num != fg_console || !softback_lines) | ||
2704 | return (u16 *) (vc->vc_origin + offset); | ||
2705 | line = offset / vc->vc_size_row; | ||
2706 | if (line >= softback_lines) | ||
2707 | return (u16 *) (vc->vc_origin + offset - | ||
2708 | softback_lines * vc->vc_size_row); | ||
2709 | p = softback_curr + offset; | ||
2710 | if (p >= softback_end) | ||
2711 | p += softback_buf - softback_end; | ||
2712 | return (u16 *) p; | ||
2713 | } | ||
2714 | |||
2715 | static unsigned long fbcon_getxy(struct vc_data *vc, unsigned long pos, | ||
2716 | int *px, int *py) | ||
2717 | { | ||
2718 | unsigned long ret; | ||
2719 | int x, y; | ||
2720 | |||
2721 | if (pos >= vc->vc_origin && pos < vc->vc_scr_end) { | ||
2722 | unsigned long offset = (pos - vc->vc_origin) / 2; | ||
2723 | |||
2724 | x = offset % vc->vc_cols; | ||
2725 | y = offset / vc->vc_cols; | ||
2726 | if (vc->vc_num == fg_console) | ||
2727 | y += softback_lines; | ||
2728 | ret = pos + (vc->vc_cols - x) * 2; | ||
2729 | } else if (vc->vc_num == fg_console && softback_lines) { | ||
2730 | unsigned long offset = pos - softback_curr; | ||
2731 | |||
2732 | if (pos < softback_curr) | ||
2733 | offset += softback_end - softback_buf; | ||
2734 | offset /= 2; | ||
2735 | x = offset % vc->vc_cols; | ||
2736 | y = offset / vc->vc_cols; | ||
2737 | ret = pos + (vc->vc_cols - x) * 2; | ||
2738 | if (ret == softback_end) | ||
2739 | ret = softback_buf; | ||
2740 | if (ret == softback_in) | ||
2741 | ret = vc->vc_origin; | ||
2742 | } else { | ||
2743 | /* Should not happen */ | ||
2744 | x = y = 0; | ||
2745 | ret = vc->vc_origin; | ||
2746 | } | ||
2747 | if (px) | ||
2748 | *px = x; | ||
2749 | if (py) | ||
2750 | *py = y; | ||
2751 | return ret; | ||
2752 | } | ||
2753 | |||
2754 | /* As we might be inside of softback, we may work with non-contiguous buffer, | ||
2755 | that's why we have to use a separate routine. */ | ||
2756 | static void fbcon_invert_region(struct vc_data *vc, u16 * p, int cnt) | ||
2757 | { | ||
2758 | while (cnt--) { | ||
2759 | u16 a = scr_readw(p); | ||
2760 | if (!vc->vc_can_do_color) | ||
2761 | a ^= 0x0800; | ||
2762 | else if (vc->vc_hi_font_mask == 0x100) | ||
2763 | a = ((a) & 0x11ff) | (((a) & 0xe000) >> 4) | | ||
2764 | (((a) & 0x0e00) << 4); | ||
2765 | else | ||
2766 | a = ((a) & 0x88ff) | (((a) & 0x7000) >> 4) | | ||
2767 | (((a) & 0x0700) << 4); | ||
2768 | scr_writew(a, p++); | ||
2769 | if (p == (u16 *) softback_end) | ||
2770 | p = (u16 *) softback_buf; | ||
2771 | if (p == (u16 *) softback_in) | ||
2772 | p = (u16 *) vc->vc_origin; | ||
2773 | } | ||
2774 | } | ||
2775 | |||
2776 | static void fbcon_scrolldelta(struct vc_data *vc, int lines) | ||
2777 | { | ||
2778 | struct fb_info *info = registered_fb[con2fb_map[fg_console]]; | ||
2779 | struct fbcon_ops *ops = info->fbcon_par; | ||
2780 | struct display *disp = &fb_display[fg_console]; | ||
2781 | int offset, limit, scrollback_old; | ||
2782 | |||
2783 | if (softback_top) { | ||
2784 | if (vc->vc_num != fg_console) | ||
2785 | return; | ||
2786 | if (vc->vc_mode != KD_TEXT || !lines) | ||
2787 | return; | ||
2788 | if (logo_shown >= 0) { | ||
2789 | struct vc_data *conp2 = vc_cons[logo_shown].d; | ||
2790 | |||
2791 | if (conp2->vc_top == logo_lines | ||
2792 | && conp2->vc_bottom == conp2->vc_rows) | ||
2793 | conp2->vc_top = 0; | ||
2794 | if (logo_shown == vc->vc_num) { | ||
2795 | unsigned long p, q; | ||
2796 | int i; | ||
2797 | |||
2798 | p = softback_in; | ||
2799 | q = vc->vc_origin + | ||
2800 | logo_lines * vc->vc_size_row; | ||
2801 | for (i = 0; i < logo_lines; i++) { | ||
2802 | if (p == softback_top) | ||
2803 | break; | ||
2804 | if (p == softback_buf) | ||
2805 | p = softback_end; | ||
2806 | p -= vc->vc_size_row; | ||
2807 | q -= vc->vc_size_row; | ||
2808 | scr_memcpyw((u16 *) q, (u16 *) p, | ||
2809 | vc->vc_size_row); | ||
2810 | } | ||
2811 | softback_in = softback_curr = p; | ||
2812 | update_region(vc, vc->vc_origin, | ||
2813 | logo_lines * vc->vc_cols); | ||
2814 | } | ||
2815 | logo_shown = FBCON_LOGO_CANSHOW; | ||
2816 | } | ||
2817 | fbcon_cursor(vc, CM_ERASE | CM_SOFTBACK); | ||
2818 | fbcon_redraw_softback(vc, disp, lines); | ||
2819 | fbcon_cursor(vc, CM_DRAW | CM_SOFTBACK); | ||
2820 | return; | ||
2821 | } | ||
2822 | |||
2823 | if (!scrollback_phys_max) | ||
2824 | return; | ||
2825 | |||
2826 | scrollback_old = scrollback_current; | ||
2827 | scrollback_current -= lines; | ||
2828 | if (scrollback_current < 0) | ||
2829 | scrollback_current = 0; | ||
2830 | else if (scrollback_current > scrollback_max) | ||
2831 | scrollback_current = scrollback_max; | ||
2832 | if (scrollback_current == scrollback_old) | ||
2833 | return; | ||
2834 | |||
2835 | if (fbcon_is_inactive(vc, info)) | ||
2836 | return; | ||
2837 | |||
2838 | fbcon_cursor(vc, CM_ERASE); | ||
2839 | |||
2840 | offset = disp->yscroll - scrollback_current; | ||
2841 | limit = disp->vrows; | ||
2842 | switch (disp->scrollmode) { | ||
2843 | case SCROLL_WRAP_MOVE: | ||
2844 | info->var.vmode |= FB_VMODE_YWRAP; | ||
2845 | break; | ||
2846 | case SCROLL_PAN_MOVE: | ||
2847 | case SCROLL_PAN_REDRAW: | ||
2848 | limit -= vc->vc_rows; | ||
2849 | info->var.vmode &= ~FB_VMODE_YWRAP; | ||
2850 | break; | ||
2851 | } | ||
2852 | if (offset < 0) | ||
2853 | offset += limit; | ||
2854 | else if (offset >= limit) | ||
2855 | offset -= limit; | ||
2856 | |||
2857 | ops->var.xoffset = 0; | ||
2858 | ops->var.yoffset = offset * vc->vc_font.height; | ||
2859 | ops->update_start(info); | ||
2860 | |||
2861 | if (!scrollback_current) | ||
2862 | fbcon_cursor(vc, CM_DRAW); | ||
2863 | } | ||
2864 | |||
2865 | static int fbcon_set_origin(struct vc_data *vc) | ||
2866 | { | ||
2867 | if (softback_lines) | ||
2868 | fbcon_scrolldelta(vc, softback_lines); | ||
2869 | return 0; | ||
2870 | } | ||
2871 | |||
2872 | static void fbcon_suspended(struct fb_info *info) | ||
2873 | { | ||
2874 | struct vc_data *vc = NULL; | ||
2875 | struct fbcon_ops *ops = info->fbcon_par; | ||
2876 | |||
2877 | if (!ops || ops->currcon < 0) | ||
2878 | return; | ||
2879 | vc = vc_cons[ops->currcon].d; | ||
2880 | |||
2881 | /* Clear cursor, restore saved data */ | ||
2882 | fbcon_cursor(vc, CM_ERASE); | ||
2883 | } | ||
2884 | |||
2885 | static void fbcon_resumed(struct fb_info *info) | ||
2886 | { | ||
2887 | struct vc_data *vc; | ||
2888 | struct fbcon_ops *ops = info->fbcon_par; | ||
2889 | |||
2890 | if (!ops || ops->currcon < 0) | ||
2891 | return; | ||
2892 | vc = vc_cons[ops->currcon].d; | ||
2893 | |||
2894 | update_screen(vc); | ||
2895 | } | ||
2896 | |||
2897 | static void fbcon_modechanged(struct fb_info *info) | ||
2898 | { | ||
2899 | struct fbcon_ops *ops = info->fbcon_par; | ||
2900 | struct vc_data *vc; | ||
2901 | struct display *p; | ||
2902 | int rows, cols; | ||
2903 | |||
2904 | if (!ops || ops->currcon < 0) | ||
2905 | return; | ||
2906 | vc = vc_cons[ops->currcon].d; | ||
2907 | if (vc->vc_mode != KD_TEXT || | ||
2908 | registered_fb[con2fb_map[ops->currcon]] != info) | ||
2909 | return; | ||
2910 | |||
2911 | p = &fb_display[vc->vc_num]; | ||
2912 | set_blitting_type(vc, info); | ||
2913 | |||
2914 | if (con_is_visible(vc)) { | ||
2915 | var_to_display(p, &info->var, info); | ||
2916 | cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres); | ||
2917 | rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres); | ||
2918 | cols /= vc->vc_font.width; | ||
2919 | rows /= vc->vc_font.height; | ||
2920 | vc_resize(vc, cols, rows); | ||
2921 | updatescrollmode(p, info, vc); | ||
2922 | scrollback_max = 0; | ||
2923 | scrollback_current = 0; | ||
2924 | |||
2925 | if (!fbcon_is_inactive(vc, info)) { | ||
2926 | ops->var.xoffset = ops->var.yoffset = p->yscroll = 0; | ||
2927 | ops->update_start(info); | ||
2928 | } | ||
2929 | |||
2930 | fbcon_set_palette(vc, color_table); | ||
2931 | update_screen(vc); | ||
2932 | if (softback_buf) | ||
2933 | fbcon_update_softback(vc); | ||
2934 | } | ||
2935 | } | ||
2936 | |||
2937 | static void fbcon_set_all_vcs(struct fb_info *info) | ||
2938 | { | ||
2939 | struct fbcon_ops *ops = info->fbcon_par; | ||
2940 | struct vc_data *vc; | ||
2941 | struct display *p; | ||
2942 | int i, rows, cols, fg = -1; | ||
2943 | |||
2944 | if (!ops || ops->currcon < 0) | ||
2945 | return; | ||
2946 | |||
2947 | for (i = first_fb_vc; i <= last_fb_vc; i++) { | ||
2948 | vc = vc_cons[i].d; | ||
2949 | if (!vc || vc->vc_mode != KD_TEXT || | ||
2950 | registered_fb[con2fb_map[i]] != info) | ||
2951 | continue; | ||
2952 | |||
2953 | if (con_is_visible(vc)) { | ||
2954 | fg = i; | ||
2955 | continue; | ||
2956 | } | ||
2957 | |||
2958 | p = &fb_display[vc->vc_num]; | ||
2959 | set_blitting_type(vc, info); | ||
2960 | var_to_display(p, &info->var, info); | ||
2961 | cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres); | ||
2962 | rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres); | ||
2963 | cols /= vc->vc_font.width; | ||
2964 | rows /= vc->vc_font.height; | ||
2965 | vc_resize(vc, cols, rows); | ||
2966 | } | ||
2967 | |||
2968 | if (fg != -1) | ||
2969 | fbcon_modechanged(info); | ||
2970 | } | ||
2971 | |||
2972 | static int fbcon_mode_deleted(struct fb_info *info, | ||
2973 | struct fb_videomode *mode) | ||
2974 | { | ||
2975 | struct fb_info *fb_info; | ||
2976 | struct display *p; | ||
2977 | int i, j, found = 0; | ||
2978 | |||
2979 | /* before deletion, ensure that mode is not in use */ | ||
2980 | for (i = first_fb_vc; i <= last_fb_vc; i++) { | ||
2981 | j = con2fb_map[i]; | ||
2982 | if (j == -1) | ||
2983 | continue; | ||
2984 | fb_info = registered_fb[j]; | ||
2985 | if (fb_info != info) | ||
2986 | continue; | ||
2987 | p = &fb_display[i]; | ||
2988 | if (!p || !p->mode) | ||
2989 | continue; | ||
2990 | if (fb_mode_is_equal(p->mode, mode)) { | ||
2991 | found = 1; | ||
2992 | break; | ||
2993 | } | ||
2994 | } | ||
2995 | return found; | ||
2996 | } | ||
2997 | |||
2998 | #ifdef CONFIG_VT_HW_CONSOLE_BINDING | ||
2999 | static int fbcon_unbind(void) | ||
3000 | { | ||
3001 | int ret; | ||
3002 | |||
3003 | ret = do_unbind_con_driver(&fb_con, first_fb_vc, last_fb_vc, | ||
3004 | fbcon_is_default); | ||
3005 | |||
3006 | if (!ret) | ||
3007 | fbcon_has_console_bind = 0; | ||
3008 | |||
3009 | return ret; | ||
3010 | } | ||
3011 | #else | ||
3012 | static inline int fbcon_unbind(void) | ||
3013 | { | ||
3014 | return -EINVAL; | ||
3015 | } | ||
3016 | #endif /* CONFIG_VT_HW_CONSOLE_BINDING */ | ||
3017 | |||
3018 | /* called with console_lock held */ | ||
3019 | static int fbcon_fb_unbind(int idx) | ||
3020 | { | ||
3021 | int i, new_idx = -1, ret = 0; | ||
3022 | |||
3023 | if (!fbcon_has_console_bind) | ||
3024 | return 0; | ||
3025 | |||
3026 | for (i = first_fb_vc; i <= last_fb_vc; i++) { | ||
3027 | if (con2fb_map[i] != idx && | ||
3028 | con2fb_map[i] != -1) { | ||
3029 | new_idx = i; | ||
3030 | break; | ||
3031 | } | ||
3032 | } | ||
3033 | |||
3034 | if (new_idx != -1) { | ||
3035 | for (i = first_fb_vc; i <= last_fb_vc; i++) { | ||
3036 | if (con2fb_map[i] == idx) | ||
3037 | set_con2fb_map(i, new_idx, 0); | ||
3038 | } | ||
3039 | } else { | ||
3040 | struct fb_info *info = registered_fb[idx]; | ||
3041 | |||
3042 | /* This is sort of like set_con2fb_map, except it maps | ||
3043 | * the consoles to no device and then releases the | ||
3044 | * oldinfo to free memory and cancel the cursor blink | ||
3045 | * timer. I can imagine this just becoming part of | ||
3046 | * set_con2fb_map where new_idx is -1 | ||
3047 | */ | ||
3048 | for (i = first_fb_vc; i <= last_fb_vc; i++) { | ||
3049 | if (con2fb_map[i] == idx) { | ||
3050 | con2fb_map[i] = -1; | ||
3051 | if (!search_fb_in_map(idx)) { | ||
3052 | ret = con2fb_release_oldinfo(vc_cons[i].d, | ||
3053 | info, NULL, i, | ||
3054 | idx, 0); | ||
3055 | if (ret) { | ||
3056 | con2fb_map[i] = idx; | ||
3057 | return ret; | ||
3058 | } | ||
3059 | } | ||
3060 | } | ||
3061 | } | ||
3062 | ret = fbcon_unbind(); | ||
3063 | } | ||
3064 | |||
3065 | return ret; | ||
3066 | } | ||
3067 | |||
3068 | /* called with console_lock held */ | ||
3069 | static int fbcon_fb_unregistered(struct fb_info *info) | ||
3070 | { | ||
3071 | int i, idx; | ||
3072 | |||
3073 | idx = info->node; | ||
3074 | for (i = first_fb_vc; i <= last_fb_vc; i++) { | ||
3075 | if (con2fb_map[i] == idx) | ||
3076 | con2fb_map[i] = -1; | ||
3077 | } | ||
3078 | |||
3079 | if (idx == info_idx) { | ||
3080 | info_idx = -1; | ||
3081 | |||
3082 | for (i = 0; i < FB_MAX; i++) { | ||
3083 | if (registered_fb[i] != NULL) { | ||
3084 | info_idx = i; | ||
3085 | break; | ||
3086 | } | ||
3087 | } | ||
3088 | } | ||
3089 | |||
3090 | if (info_idx != -1) { | ||
3091 | for (i = first_fb_vc; i <= last_fb_vc; i++) { | ||
3092 | if (con2fb_map[i] == -1) | ||
3093 | con2fb_map[i] = info_idx; | ||
3094 | } | ||
3095 | } | ||
3096 | |||
3097 | if (primary_device == idx) | ||
3098 | primary_device = -1; | ||
3099 | |||
3100 | if (!num_registered_fb) | ||
3101 | do_unregister_con_driver(&fb_con); | ||
3102 | |||
3103 | return 0; | ||
3104 | } | ||
3105 | |||
3106 | /* called with console_lock held */ | ||
3107 | static void fbcon_remap_all(int idx) | ||
3108 | { | ||
3109 | int i; | ||
3110 | for (i = first_fb_vc; i <= last_fb_vc; i++) | ||
3111 | set_con2fb_map(i, idx, 0); | ||
3112 | |||
3113 | if (con_is_bound(&fb_con)) { | ||
3114 | printk(KERN_INFO "fbcon: Remapping primary device, " | ||
3115 | "fb%i, to tty %i-%i\n", idx, | ||
3116 | first_fb_vc + 1, last_fb_vc + 1); | ||
3117 | info_idx = idx; | ||
3118 | } | ||
3119 | } | ||
3120 | |||
3121 | #ifdef CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY | ||
3122 | static void fbcon_select_primary(struct fb_info *info) | ||
3123 | { | ||
3124 | if (!map_override && primary_device == -1 && | ||
3125 | fb_is_primary_device(info)) { | ||
3126 | int i; | ||
3127 | |||
3128 | printk(KERN_INFO "fbcon: %s (fb%i) is primary device\n", | ||
3129 | info->fix.id, info->node); | ||
3130 | primary_device = info->node; | ||
3131 | |||
3132 | for (i = first_fb_vc; i <= last_fb_vc; i++) | ||
3133 | con2fb_map_boot[i] = primary_device; | ||
3134 | |||
3135 | if (con_is_bound(&fb_con)) { | ||
3136 | printk(KERN_INFO "fbcon: Remapping primary device, " | ||
3137 | "fb%i, to tty %i-%i\n", info->node, | ||
3138 | first_fb_vc + 1, last_fb_vc + 1); | ||
3139 | info_idx = primary_device; | ||
3140 | } | ||
3141 | } | ||
3142 | |||
3143 | } | ||
3144 | #else | ||
3145 | static inline void fbcon_select_primary(struct fb_info *info) | ||
3146 | { | ||
3147 | return; | ||
3148 | } | ||
3149 | #endif /* CONFIG_FRAMEBUFFER_DETECT_PRIMARY */ | ||
3150 | |||
3151 | /* called with console_lock held */ | ||
3152 | static int fbcon_fb_registered(struct fb_info *info) | ||
3153 | { | ||
3154 | int ret = 0, i, idx; | ||
3155 | |||
3156 | idx = info->node; | ||
3157 | fbcon_select_primary(info); | ||
3158 | |||
3159 | if (info_idx == -1) { | ||
3160 | for (i = first_fb_vc; i <= last_fb_vc; i++) { | ||
3161 | if (con2fb_map_boot[i] == idx) { | ||
3162 | info_idx = idx; | ||
3163 | break; | ||
3164 | } | ||
3165 | } | ||
3166 | |||
3167 | if (info_idx != -1) | ||
3168 | ret = do_fbcon_takeover(1); | ||
3169 | } else { | ||
3170 | for (i = first_fb_vc; i <= last_fb_vc; i++) { | ||
3171 | if (con2fb_map_boot[i] == idx) | ||
3172 | set_con2fb_map(i, idx, 0); | ||
3173 | } | ||
3174 | } | ||
3175 | |||
3176 | return ret; | ||
3177 | } | ||
3178 | |||
3179 | static void fbcon_fb_blanked(struct fb_info *info, int blank) | ||
3180 | { | ||
3181 | struct fbcon_ops *ops = info->fbcon_par; | ||
3182 | struct vc_data *vc; | ||
3183 | |||
3184 | if (!ops || ops->currcon < 0) | ||
3185 | return; | ||
3186 | |||
3187 | vc = vc_cons[ops->currcon].d; | ||
3188 | if (vc->vc_mode != KD_TEXT || | ||
3189 | registered_fb[con2fb_map[ops->currcon]] != info) | ||
3190 | return; | ||
3191 | |||
3192 | if (con_is_visible(vc)) { | ||
3193 | if (blank) | ||
3194 | do_blank_screen(0); | ||
3195 | else | ||
3196 | do_unblank_screen(0); | ||
3197 | } | ||
3198 | ops->blank_state = blank; | ||
3199 | } | ||
3200 | |||
3201 | static void fbcon_new_modelist(struct fb_info *info) | ||
3202 | { | ||
3203 | int i; | ||
3204 | struct vc_data *vc; | ||
3205 | struct fb_var_screeninfo var; | ||
3206 | const struct fb_videomode *mode; | ||
3207 | |||
3208 | for (i = first_fb_vc; i <= last_fb_vc; i++) { | ||
3209 | if (registered_fb[con2fb_map[i]] != info) | ||
3210 | continue; | ||
3211 | if (!fb_display[i].mode) | ||
3212 | continue; | ||
3213 | vc = vc_cons[i].d; | ||
3214 | display_to_var(&var, &fb_display[i]); | ||
3215 | mode = fb_find_nearest_mode(fb_display[i].mode, | ||
3216 | &info->modelist); | ||
3217 | fb_videomode_to_var(&var, mode); | ||
3218 | fbcon_set_disp(info, &var, vc->vc_num); | ||
3219 | } | ||
3220 | } | ||
3221 | |||
3222 | static void fbcon_get_requirement(struct fb_info *info, | ||
3223 | struct fb_blit_caps *caps) | ||
3224 | { | ||
3225 | struct vc_data *vc; | ||
3226 | struct display *p; | ||
3227 | |||
3228 | if (caps->flags) { | ||
3229 | int i, charcnt; | ||
3230 | |||
3231 | for (i = first_fb_vc; i <= last_fb_vc; i++) { | ||
3232 | vc = vc_cons[i].d; | ||
3233 | if (vc && vc->vc_mode == KD_TEXT && | ||
3234 | info->node == con2fb_map[i]) { | ||
3235 | p = &fb_display[i]; | ||
3236 | caps->x |= 1 << (vc->vc_font.width - 1); | ||
3237 | caps->y |= 1 << (vc->vc_font.height - 1); | ||
3238 | charcnt = (p->userfont) ? | ||
3239 | FNTCHARCNT(p->fontdata) : 256; | ||
3240 | if (caps->len < charcnt) | ||
3241 | caps->len = charcnt; | ||
3242 | } | ||
3243 | } | ||
3244 | } else { | ||
3245 | vc = vc_cons[fg_console].d; | ||
3246 | |||
3247 | if (vc && vc->vc_mode == KD_TEXT && | ||
3248 | info->node == con2fb_map[fg_console]) { | ||
3249 | p = &fb_display[fg_console]; | ||
3250 | caps->x = 1 << (vc->vc_font.width - 1); | ||
3251 | caps->y = 1 << (vc->vc_font.height - 1); | ||
3252 | caps->len = (p->userfont) ? | ||
3253 | FNTCHARCNT(p->fontdata) : 256; | ||
3254 | } | ||
3255 | } | ||
3256 | } | ||
3257 | |||
3258 | static int fbcon_event_notify(struct notifier_block *self, | ||
3259 | unsigned long action, void *data) | ||
3260 | { | ||
3261 | struct fb_event *event = data; | ||
3262 | struct fb_info *info = event->info; | ||
3263 | struct fb_videomode *mode; | ||
3264 | struct fb_con2fbmap *con2fb; | ||
3265 | struct fb_blit_caps *caps; | ||
3266 | int idx, ret = 0; | ||
3267 | |||
3268 | /* | ||
3269 | * ignore all events except driver registration and deregistration | ||
3270 | * if fbcon is not active | ||
3271 | */ | ||
3272 | if (fbcon_has_exited && !(action == FB_EVENT_FB_REGISTERED || | ||
3273 | action == FB_EVENT_FB_UNREGISTERED)) | ||
3274 | goto done; | ||
3275 | |||
3276 | switch(action) { | ||
3277 | case FB_EVENT_SUSPEND: | ||
3278 | fbcon_suspended(info); | ||
3279 | break; | ||
3280 | case FB_EVENT_RESUME: | ||
3281 | fbcon_resumed(info); | ||
3282 | break; | ||
3283 | case FB_EVENT_MODE_CHANGE: | ||
3284 | fbcon_modechanged(info); | ||
3285 | break; | ||
3286 | case FB_EVENT_MODE_CHANGE_ALL: | ||
3287 | fbcon_set_all_vcs(info); | ||
3288 | break; | ||
3289 | case FB_EVENT_MODE_DELETE: | ||
3290 | mode = event->data; | ||
3291 | ret = fbcon_mode_deleted(info, mode); | ||
3292 | break; | ||
3293 | case FB_EVENT_FB_UNBIND: | ||
3294 | idx = info->node; | ||
3295 | ret = fbcon_fb_unbind(idx); | ||
3296 | break; | ||
3297 | case FB_EVENT_FB_REGISTERED: | ||
3298 | ret = fbcon_fb_registered(info); | ||
3299 | break; | ||
3300 | case FB_EVENT_FB_UNREGISTERED: | ||
3301 | ret = fbcon_fb_unregistered(info); | ||
3302 | break; | ||
3303 | case FB_EVENT_SET_CONSOLE_MAP: | ||
3304 | /* called with console lock held */ | ||
3305 | con2fb = event->data; | ||
3306 | ret = set_con2fb_map(con2fb->console - 1, | ||
3307 | con2fb->framebuffer, 1); | ||
3308 | break; | ||
3309 | case FB_EVENT_GET_CONSOLE_MAP: | ||
3310 | con2fb = event->data; | ||
3311 | con2fb->framebuffer = con2fb_map[con2fb->console - 1]; | ||
3312 | break; | ||
3313 | case FB_EVENT_BLANK: | ||
3314 | fbcon_fb_blanked(info, *(int *)event->data); | ||
3315 | break; | ||
3316 | case FB_EVENT_NEW_MODELIST: | ||
3317 | fbcon_new_modelist(info); | ||
3318 | break; | ||
3319 | case FB_EVENT_GET_REQ: | ||
3320 | caps = event->data; | ||
3321 | fbcon_get_requirement(info, caps); | ||
3322 | break; | ||
3323 | case FB_EVENT_REMAP_ALL_CONSOLE: | ||
3324 | idx = info->node; | ||
3325 | fbcon_remap_all(idx); | ||
3326 | break; | ||
3327 | } | ||
3328 | done: | ||
3329 | return ret; | ||
3330 | } | ||
3331 | |||
3332 | /* | ||
3333 | * The console `switch' structure for the frame buffer based console | ||
3334 | */ | ||
3335 | |||
3336 | static const struct consw fb_con = { | ||
3337 | .owner = THIS_MODULE, | ||
3338 | .con_startup = fbcon_startup, | ||
3339 | .con_init = fbcon_init, | ||
3340 | .con_deinit = fbcon_deinit, | ||
3341 | .con_clear = fbcon_clear, | ||
3342 | .con_putc = fbcon_putc, | ||
3343 | .con_putcs = fbcon_putcs, | ||
3344 | .con_cursor = fbcon_cursor, | ||
3345 | .con_scroll = fbcon_scroll, | ||
3346 | .con_switch = fbcon_switch, | ||
3347 | .con_blank = fbcon_blank, | ||
3348 | .con_font_set = fbcon_set_font, | ||
3349 | .con_font_get = fbcon_get_font, | ||
3350 | .con_font_default = fbcon_set_def_font, | ||
3351 | .con_font_copy = fbcon_copy_font, | ||
3352 | .con_set_palette = fbcon_set_palette, | ||
3353 | .con_scrolldelta = fbcon_scrolldelta, | ||
3354 | .con_set_origin = fbcon_set_origin, | ||
3355 | .con_invert_region = fbcon_invert_region, | ||
3356 | .con_screen_pos = fbcon_screen_pos, | ||
3357 | .con_getxy = fbcon_getxy, | ||
3358 | .con_resize = fbcon_resize, | ||
3359 | .con_debug_enter = fbcon_debug_enter, | ||
3360 | .con_debug_leave = fbcon_debug_leave, | ||
3361 | }; | ||
3362 | |||
3363 | static struct notifier_block fbcon_event_notifier = { | ||
3364 | .notifier_call = fbcon_event_notify, | ||
3365 | }; | ||
3366 | |||
3367 | static ssize_t store_rotate(struct device *device, | ||
3368 | struct device_attribute *attr, const char *buf, | ||
3369 | size_t count) | ||
3370 | { | ||
3371 | struct fb_info *info; | ||
3372 | int rotate, idx; | ||
3373 | char **last = NULL; | ||
3374 | |||
3375 | if (fbcon_has_exited) | ||
3376 | return count; | ||
3377 | |||
3378 | console_lock(); | ||
3379 | idx = con2fb_map[fg_console]; | ||
3380 | |||
3381 | if (idx == -1 || registered_fb[idx] == NULL) | ||
3382 | goto err; | ||
3383 | |||
3384 | info = registered_fb[idx]; | ||
3385 | rotate = simple_strtoul(buf, last, 0); | ||
3386 | fbcon_rotate(info, rotate); | ||
3387 | err: | ||
3388 | console_unlock(); | ||
3389 | return count; | ||
3390 | } | ||
3391 | |||
3392 | static ssize_t store_rotate_all(struct device *device, | ||
3393 | struct device_attribute *attr,const char *buf, | ||
3394 | size_t count) | ||
3395 | { | ||
3396 | struct fb_info *info; | ||
3397 | int rotate, idx; | ||
3398 | char **last = NULL; | ||
3399 | |||
3400 | if (fbcon_has_exited) | ||
3401 | return count; | ||
3402 | |||
3403 | console_lock(); | ||
3404 | idx = con2fb_map[fg_console]; | ||
3405 | |||
3406 | if (idx == -1 || registered_fb[idx] == NULL) | ||
3407 | goto err; | ||
3408 | |||
3409 | info = registered_fb[idx]; | ||
3410 | rotate = simple_strtoul(buf, last, 0); | ||
3411 | fbcon_rotate_all(info, rotate); | ||
3412 | err: | ||
3413 | console_unlock(); | ||
3414 | return count; | ||
3415 | } | ||
3416 | |||
3417 | static ssize_t show_rotate(struct device *device, | ||
3418 | struct device_attribute *attr,char *buf) | ||
3419 | { | ||
3420 | struct fb_info *info; | ||
3421 | int rotate = 0, idx; | ||
3422 | |||
3423 | if (fbcon_has_exited) | ||
3424 | return 0; | ||
3425 | |||
3426 | console_lock(); | ||
3427 | idx = con2fb_map[fg_console]; | ||
3428 | |||
3429 | if (idx == -1 || registered_fb[idx] == NULL) | ||
3430 | goto err; | ||
3431 | |||
3432 | info = registered_fb[idx]; | ||
3433 | rotate = fbcon_get_rotate(info); | ||
3434 | err: | ||
3435 | console_unlock(); | ||
3436 | return snprintf(buf, PAGE_SIZE, "%d\n", rotate); | ||
3437 | } | ||
3438 | |||
3439 | static ssize_t show_cursor_blink(struct device *device, | ||
3440 | struct device_attribute *attr, char *buf) | ||
3441 | { | ||
3442 | struct fb_info *info; | ||
3443 | struct fbcon_ops *ops; | ||
3444 | int idx, blink = -1; | ||
3445 | |||
3446 | if (fbcon_has_exited) | ||
3447 | return 0; | ||
3448 | |||
3449 | console_lock(); | ||
3450 | idx = con2fb_map[fg_console]; | ||
3451 | |||
3452 | if (idx == -1 || registered_fb[idx] == NULL) | ||
3453 | goto err; | ||
3454 | |||
3455 | info = registered_fb[idx]; | ||
3456 | ops = info->fbcon_par; | ||
3457 | |||
3458 | if (!ops) | ||
3459 | goto err; | ||
3460 | |||
3461 | blink = (ops->flags & FBCON_FLAGS_CURSOR_TIMER) ? 1 : 0; | ||
3462 | err: | ||
3463 | console_unlock(); | ||
3464 | return snprintf(buf, PAGE_SIZE, "%d\n", blink); | ||
3465 | } | ||
3466 | |||
3467 | static ssize_t store_cursor_blink(struct device *device, | ||
3468 | struct device_attribute *attr, | ||
3469 | const char *buf, size_t count) | ||
3470 | { | ||
3471 | struct fb_info *info; | ||
3472 | int blink, idx; | ||
3473 | char **last = NULL; | ||
3474 | |||
3475 | if (fbcon_has_exited) | ||
3476 | return count; | ||
3477 | |||
3478 | console_lock(); | ||
3479 | idx = con2fb_map[fg_console]; | ||
3480 | |||
3481 | if (idx == -1 || registered_fb[idx] == NULL) | ||
3482 | goto err; | ||
3483 | |||
3484 | info = registered_fb[idx]; | ||
3485 | |||
3486 | if (!info->fbcon_par) | ||
3487 | goto err; | ||
3488 | |||
3489 | blink = simple_strtoul(buf, last, 0); | ||
3490 | |||
3491 | if (blink) { | ||
3492 | fbcon_cursor_noblink = 0; | ||
3493 | fbcon_add_cursor_timer(info); | ||
3494 | } else { | ||
3495 | fbcon_cursor_noblink = 1; | ||
3496 | fbcon_del_cursor_timer(info); | ||
3497 | } | ||
3498 | |||
3499 | err: | ||
3500 | console_unlock(); | ||
3501 | return count; | ||
3502 | } | ||
3503 | |||
3504 | static struct device_attribute device_attrs[] = { | ||
3505 | __ATTR(rotate, S_IRUGO|S_IWUSR, show_rotate, store_rotate), | ||
3506 | __ATTR(rotate_all, S_IWUSR, NULL, store_rotate_all), | ||
3507 | __ATTR(cursor_blink, S_IRUGO|S_IWUSR, show_cursor_blink, | ||
3508 | store_cursor_blink), | ||
3509 | }; | ||
3510 | |||
3511 | static int fbcon_init_device(void) | ||
3512 | { | ||
3513 | int i, error = 0; | ||
3514 | |||
3515 | fbcon_has_sysfs = 1; | ||
3516 | |||
3517 | for (i = 0; i < ARRAY_SIZE(device_attrs); i++) { | ||
3518 | error = device_create_file(fbcon_device, &device_attrs[i]); | ||
3519 | |||
3520 | if (error) | ||
3521 | break; | ||
3522 | } | ||
3523 | |||
3524 | if (error) { | ||
3525 | while (--i >= 0) | ||
3526 | device_remove_file(fbcon_device, &device_attrs[i]); | ||
3527 | |||
3528 | fbcon_has_sysfs = 0; | ||
3529 | } | ||
3530 | |||
3531 | return 0; | ||
3532 | } | ||
3533 | |||
3534 | static void fbcon_start(void) | ||
3535 | { | ||
3536 | if (num_registered_fb) { | ||
3537 | int i; | ||
3538 | |||
3539 | console_lock(); | ||
3540 | |||
3541 | for (i = 0; i < FB_MAX; i++) { | ||
3542 | if (registered_fb[i] != NULL) { | ||
3543 | info_idx = i; | ||
3544 | break; | ||
3545 | } | ||
3546 | } | ||
3547 | |||
3548 | do_fbcon_takeover(0); | ||
3549 | console_unlock(); | ||
3550 | |||
3551 | } | ||
3552 | } | ||
3553 | |||
3554 | static void fbcon_exit(void) | ||
3555 | { | ||
3556 | struct fb_info *info; | ||
3557 | int i, j, mapped; | ||
3558 | |||
3559 | if (fbcon_has_exited) | ||
3560 | return; | ||
3561 | |||
3562 | kfree((void *)softback_buf); | ||
3563 | softback_buf = 0UL; | ||
3564 | |||
3565 | for (i = 0; i < FB_MAX; i++) { | ||
3566 | int pending = 0; | ||
3567 | |||
3568 | mapped = 0; | ||
3569 | info = registered_fb[i]; | ||
3570 | |||
3571 | if (info == NULL) | ||
3572 | continue; | ||
3573 | |||
3574 | if (info->queue.func) | ||
3575 | pending = cancel_work_sync(&info->queue); | ||
3576 | DPRINTK("fbcon: %s pending work\n", (pending ? "canceled" : | ||
3577 | "no")); | ||
3578 | |||
3579 | for (j = first_fb_vc; j <= last_fb_vc; j++) { | ||
3580 | if (con2fb_map[j] == i) { | ||
3581 | mapped = 1; | ||
3582 | break; | ||
3583 | } | ||
3584 | } | ||
3585 | |||
3586 | if (mapped) { | ||
3587 | if (info->fbops->fb_release) | ||
3588 | info->fbops->fb_release(info, 0); | ||
3589 | module_put(info->fbops->owner); | ||
3590 | |||
3591 | if (info->fbcon_par) { | ||
3592 | struct fbcon_ops *ops = info->fbcon_par; | ||
3593 | |||
3594 | fbcon_del_cursor_timer(info); | ||
3595 | kfree(ops->cursor_src); | ||
3596 | kfree(ops->cursor_state.mask); | ||
3597 | kfree(info->fbcon_par); | ||
3598 | info->fbcon_par = NULL; | ||
3599 | } | ||
3600 | |||
3601 | if (info->queue.func == fb_flashcursor) | ||
3602 | info->queue.func = NULL; | ||
3603 | } | ||
3604 | } | ||
3605 | |||
3606 | fbcon_has_exited = 1; | ||
3607 | } | ||
3608 | |||
3609 | static int __init fb_console_init(void) | ||
3610 | { | ||
3611 | int i; | ||
3612 | |||
3613 | console_lock(); | ||
3614 | fb_register_client(&fbcon_event_notifier); | ||
3615 | fbcon_device = device_create(fb_class, NULL, MKDEV(0, 0), NULL, | ||
3616 | "fbcon"); | ||
3617 | |||
3618 | if (IS_ERR(fbcon_device)) { | ||
3619 | printk(KERN_WARNING "Unable to create device " | ||
3620 | "for fbcon; errno = %ld\n", | ||
3621 | PTR_ERR(fbcon_device)); | ||
3622 | fbcon_device = NULL; | ||
3623 | } else | ||
3624 | fbcon_init_device(); | ||
3625 | |||
3626 | for (i = 0; i < MAX_NR_CONSOLES; i++) | ||
3627 | con2fb_map[i] = -1; | ||
3628 | |||
3629 | console_unlock(); | ||
3630 | fbcon_start(); | ||
3631 | return 0; | ||
3632 | } | ||
3633 | |||
3634 | fs_initcall(fb_console_init); | ||
3635 | |||
3636 | #ifdef MODULE | ||
3637 | |||
3638 | static void __exit fbcon_deinit_device(void) | ||
3639 | { | ||
3640 | int i; | ||
3641 | |||
3642 | if (fbcon_has_sysfs) { | ||
3643 | for (i = 0; i < ARRAY_SIZE(device_attrs); i++) | ||
3644 | device_remove_file(fbcon_device, &device_attrs[i]); | ||
3645 | |||
3646 | fbcon_has_sysfs = 0; | ||
3647 | } | ||
3648 | } | ||
3649 | |||
3650 | static void __exit fb_console_exit(void) | ||
3651 | { | ||
3652 | console_lock(); | ||
3653 | fb_unregister_client(&fbcon_event_notifier); | ||
3654 | fbcon_deinit_device(); | ||
3655 | device_destroy(fb_class, MKDEV(0, 0)); | ||
3656 | fbcon_exit(); | ||
3657 | do_unregister_con_driver(&fb_con); | ||
3658 | console_unlock(); | ||
3659 | } | ||
3660 | |||
3661 | module_exit(fb_console_exit); | ||
3662 | |||
3663 | #endif | ||
3664 | |||
3665 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/video/console/fbcon.h b/drivers/video/console/fbcon.h deleted file mode 100644 index 7aaa4eabbba0..000000000000 --- a/drivers/video/console/fbcon.h +++ /dev/null | |||
@@ -1,265 +0,0 @@ | |||
1 | /* | ||
2 | * linux/drivers/video/console/fbcon.h -- Low level frame buffer based console driver | ||
3 | * | ||
4 | * Copyright (C) 1997 Geert Uytterhoeven | ||
5 | * | ||
6 | * This file is subject to the terms and conditions of the GNU General Public | ||
7 | * License. See the file COPYING in the main directory of this archive | ||
8 | * for more details. | ||
9 | */ | ||
10 | |||
11 | #ifndef _VIDEO_FBCON_H | ||
12 | #define _VIDEO_FBCON_H | ||
13 | |||
14 | #include <linux/types.h> | ||
15 | #include <linux/vt_buffer.h> | ||
16 | #include <linux/vt_kern.h> | ||
17 | |||
18 | #include <asm/io.h> | ||
19 | |||
20 | #define FBCON_FLAGS_INIT 1 | ||
21 | #define FBCON_FLAGS_CURSOR_TIMER 2 | ||
22 | |||
23 | /* | ||
24 | * This is the interface between the low-level console driver and the | ||
25 | * low-level frame buffer device | ||
26 | */ | ||
27 | |||
28 | struct display { | ||
29 | /* Filled in by the low-level console driver */ | ||
30 | const u_char *fontdata; | ||
31 | int userfont; /* != 0 if fontdata kmalloc()ed */ | ||
32 | u_short scrollmode; /* Scroll Method */ | ||
33 | u_short inverse; /* != 0 text black on white as default */ | ||
34 | short yscroll; /* Hardware scrolling */ | ||
35 | int vrows; /* number of virtual rows */ | ||
36 | int cursor_shape; | ||
37 | int con_rotate; | ||
38 | u32 xres_virtual; | ||
39 | u32 yres_virtual; | ||
40 | u32 height; | ||
41 | u32 width; | ||
42 | u32 bits_per_pixel; | ||
43 | u32 grayscale; | ||
44 | u32 nonstd; | ||
45 | u32 accel_flags; | ||
46 | u32 rotate; | ||
47 | struct fb_bitfield red; | ||
48 | struct fb_bitfield green; | ||
49 | struct fb_bitfield blue; | ||
50 | struct fb_bitfield transp; | ||
51 | const struct fb_videomode *mode; | ||
52 | }; | ||
53 | |||
54 | struct fbcon_ops { | ||
55 | void (*bmove)(struct vc_data *vc, struct fb_info *info, int sy, | ||
56 | int sx, int dy, int dx, int height, int width); | ||
57 | void (*clear)(struct vc_data *vc, struct fb_info *info, int sy, | ||
58 | int sx, int height, int width); | ||
59 | void (*putcs)(struct vc_data *vc, struct fb_info *info, | ||
60 | const unsigned short *s, int count, int yy, int xx, | ||
61 | int fg, int bg); | ||
62 | void (*clear_margins)(struct vc_data *vc, struct fb_info *info, | ||
63 | int bottom_only); | ||
64 | void (*cursor)(struct vc_data *vc, struct fb_info *info, int mode, | ||
65 | int softback_lines, int fg, int bg); | ||
66 | int (*update_start)(struct fb_info *info); | ||
67 | int (*rotate_font)(struct fb_info *info, struct vc_data *vc); | ||
68 | struct fb_var_screeninfo var; /* copy of the current fb_var_screeninfo */ | ||
69 | struct timer_list cursor_timer; /* Cursor timer */ | ||
70 | struct fb_cursor cursor_state; | ||
71 | struct display *p; | ||
72 | int currcon; /* Current VC. */ | ||
73 | int cur_blink_jiffies; | ||
74 | int cursor_flash; | ||
75 | int cursor_reset; | ||
76 | int blank_state; | ||
77 | int graphics; | ||
78 | int save_graphics; /* for debug enter/leave */ | ||
79 | int flags; | ||
80 | int rotate; | ||
81 | int cur_rotate; | ||
82 | char *cursor_data; | ||
83 | u8 *fontbuffer; | ||
84 | u8 *fontdata; | ||
85 | u8 *cursor_src; | ||
86 | u32 cursor_size; | ||
87 | u32 fd_size; | ||
88 | }; | ||
89 | /* | ||
90 | * Attribute Decoding | ||
91 | */ | ||
92 | |||
93 | /* Color */ | ||
94 | #define attr_fgcol(fgshift,s) \ | ||
95 | (((s) >> (fgshift)) & 0x0f) | ||
96 | #define attr_bgcol(bgshift,s) \ | ||
97 | (((s) >> (bgshift)) & 0x0f) | ||
98 | |||
99 | /* Monochrome */ | ||
100 | #define attr_bold(s) \ | ||
101 | ((s) & 0x200) | ||
102 | #define attr_reverse(s) \ | ||
103 | ((s) & 0x800) | ||
104 | #define attr_underline(s) \ | ||
105 | ((s) & 0x400) | ||
106 | #define attr_blink(s) \ | ||
107 | ((s) & 0x8000) | ||
108 | |||
109 | |||
110 | static inline int mono_col(const struct fb_info *info) | ||
111 | { | ||
112 | __u32 max_len; | ||
113 | max_len = max(info->var.green.length, info->var.red.length); | ||
114 | max_len = max(info->var.blue.length, max_len); | ||
115 | return (~(0xfff << max_len)) & 0xff; | ||
116 | } | ||
117 | |||
118 | static inline int attr_col_ec(int shift, struct vc_data *vc, | ||
119 | struct fb_info *info, int is_fg) | ||
120 | { | ||
121 | int is_mono01; | ||
122 | int col; | ||
123 | int fg; | ||
124 | int bg; | ||
125 | |||
126 | if (!vc) | ||
127 | return 0; | ||
128 | |||
129 | if (vc->vc_can_do_color) | ||
130 | return is_fg ? attr_fgcol(shift,vc->vc_video_erase_char) | ||
131 | : attr_bgcol(shift,vc->vc_video_erase_char); | ||
132 | |||
133 | if (!info) | ||
134 | return 0; | ||
135 | |||
136 | col = mono_col(info); | ||
137 | is_mono01 = info->fix.visual == FB_VISUAL_MONO01; | ||
138 | |||
139 | if (attr_reverse(vc->vc_video_erase_char)) { | ||
140 | fg = is_mono01 ? col : 0; | ||
141 | bg = is_mono01 ? 0 : col; | ||
142 | } | ||
143 | else { | ||
144 | fg = is_mono01 ? 0 : col; | ||
145 | bg = is_mono01 ? col : 0; | ||
146 | } | ||
147 | |||
148 | return is_fg ? fg : bg; | ||
149 | } | ||
150 | |||
151 | #define attr_bgcol_ec(bgshift, vc, info) attr_col_ec(bgshift, vc, info, 0) | ||
152 | #define attr_fgcol_ec(fgshift, vc, info) attr_col_ec(fgshift, vc, info, 1) | ||
153 | |||
154 | /* Font */ | ||
155 | #define REFCOUNT(fd) (((int *)(fd))[-1]) | ||
156 | #define FNTSIZE(fd) (((int *)(fd))[-2]) | ||
157 | #define FNTCHARCNT(fd) (((int *)(fd))[-3]) | ||
158 | #define FNTSUM(fd) (((int *)(fd))[-4]) | ||
159 | #define FONT_EXTRA_WORDS 4 | ||
160 | |||
161 | /* | ||
162 | * Scroll Method | ||
163 | */ | ||
164 | |||
165 | /* There are several methods fbcon can use to move text around the screen: | ||
166 | * | ||
167 | * Operation Pan Wrap | ||
168 | *--------------------------------------------- | ||
169 | * SCROLL_MOVE copyarea No No | ||
170 | * SCROLL_PAN_MOVE copyarea Yes No | ||
171 | * SCROLL_WRAP_MOVE copyarea No Yes | ||
172 | * SCROLL_REDRAW imageblit No No | ||
173 | * SCROLL_PAN_REDRAW imageblit Yes No | ||
174 | * SCROLL_WRAP_REDRAW imageblit No Yes | ||
175 | * | ||
176 | * (SCROLL_WRAP_REDRAW is not implemented yet) | ||
177 | * | ||
178 | * In general, fbcon will choose the best scrolling | ||
179 | * method based on the rule below: | ||
180 | * | ||
181 | * Pan/Wrap > accel imageblit > accel copyarea > | ||
182 | * soft imageblit > (soft copyarea) | ||
183 | * | ||
184 | * Exception to the rule: Pan + accel copyarea is | ||
185 | * preferred over Pan + accel imageblit. | ||
186 | * | ||
187 | * The above is typical for PCI/AGP cards. Unless | ||
188 | * overridden, fbcon will never use soft copyarea. | ||
189 | * | ||
190 | * If you need to override the above rule, set the | ||
191 | * appropriate flags in fb_info->flags. For example, | ||
192 | * to prefer copyarea over imageblit, set | ||
193 | * FBINFO_READS_FAST. | ||
194 | * | ||
195 | * Other notes: | ||
196 | * + use the hardware engine to move the text | ||
197 | * (hw-accelerated copyarea() and fillrect()) | ||
198 | * + use hardware-supported panning on a large virtual screen | ||
199 | * + amifb can not only pan, but also wrap the display by N lines | ||
200 | * (i.e. visible line i = physical line (i+N) % yres). | ||
201 | * + read what's already rendered on the screen and | ||
202 | * write it in a different place (this is cfb_copyarea()) | ||
203 | * + re-render the text to the screen | ||
204 | * | ||
205 | * Whether to use wrapping or panning can only be figured out at | ||
206 | * runtime (when we know whether our font height is a multiple | ||
207 | * of the pan/wrap step) | ||
208 | * | ||
209 | */ | ||
210 | |||
211 | #define SCROLL_MOVE 0x001 | ||
212 | #define SCROLL_PAN_MOVE 0x002 | ||
213 | #define SCROLL_WRAP_MOVE 0x003 | ||
214 | #define SCROLL_REDRAW 0x004 | ||
215 | #define SCROLL_PAN_REDRAW 0x005 | ||
216 | |||
217 | #ifdef CONFIG_FB_TILEBLITTING | ||
218 | extern void fbcon_set_tileops(struct vc_data *vc, struct fb_info *info); | ||
219 | #endif | ||
220 | extern void fbcon_set_bitops(struct fbcon_ops *ops); | ||
221 | extern int soft_cursor(struct fb_info *info, struct fb_cursor *cursor); | ||
222 | |||
223 | #define FBCON_ATTRIBUTE_UNDERLINE 1 | ||
224 | #define FBCON_ATTRIBUTE_REVERSE 2 | ||
225 | #define FBCON_ATTRIBUTE_BOLD 4 | ||
226 | |||
227 | static inline int real_y(struct display *p, int ypos) | ||
228 | { | ||
229 | int rows = p->vrows; | ||
230 | |||
231 | ypos += p->yscroll; | ||
232 | return ypos < rows ? ypos : ypos - rows; | ||
233 | } | ||
234 | |||
235 | |||
236 | static inline int get_attribute(struct fb_info *info, u16 c) | ||
237 | { | ||
238 | int attribute = 0; | ||
239 | |||
240 | if (fb_get_color_depth(&info->var, &info->fix) == 1) { | ||
241 | if (attr_underline(c)) | ||
242 | attribute |= FBCON_ATTRIBUTE_UNDERLINE; | ||
243 | if (attr_reverse(c)) | ||
244 | attribute |= FBCON_ATTRIBUTE_REVERSE; | ||
245 | if (attr_bold(c)) | ||
246 | attribute |= FBCON_ATTRIBUTE_BOLD; | ||
247 | } | ||
248 | |||
249 | return attribute; | ||
250 | } | ||
251 | |||
252 | #define FBCON_SWAP(i,r,v) ({ \ | ||
253 | typeof(r) _r = (r); \ | ||
254 | typeof(v) _v = (v); \ | ||
255 | (void) (&_r == &_v); \ | ||
256 | (i == FB_ROTATE_UR || i == FB_ROTATE_UD) ? _r : _v; }) | ||
257 | |||
258 | #ifdef CONFIG_FRAMEBUFFER_CONSOLE_ROTATION | ||
259 | extern void fbcon_set_rotate(struct fbcon_ops *ops); | ||
260 | #else | ||
261 | #define fbcon_set_rotate(x) do {} while(0) | ||
262 | #endif /* CONFIG_FRAMEBUFFER_CONSOLE_ROTATION */ | ||
263 | |||
264 | #endif /* _VIDEO_FBCON_H */ | ||
265 | |||
diff --git a/drivers/video/console/fbcon_ccw.c b/drivers/video/console/fbcon_ccw.c deleted file mode 100644 index 5a3cbf6dff4d..000000000000 --- a/drivers/video/console/fbcon_ccw.c +++ /dev/null | |||
@@ -1,424 +0,0 @@ | |||
1 | /* | ||
2 | * linux/drivers/video/console/fbcon_ccw.c -- Software Rotation - 270 degrees | ||
3 | * | ||
4 | * Copyright (C) 2005 Antonino Daplas <adaplas @pol.net> | ||
5 | * | ||
6 | * This file is subject to the terms and conditions of the GNU General Public | ||
7 | * License. See the file COPYING in the main directory of this archive for | ||
8 | * more details. | ||
9 | */ | ||
10 | |||
11 | #include <linux/module.h> | ||
12 | #include <linux/slab.h> | ||
13 | #include <linux/string.h> | ||
14 | #include <linux/fb.h> | ||
15 | #include <linux/vt_kern.h> | ||
16 | #include <linux/console.h> | ||
17 | #include <asm/types.h> | ||
18 | #include "fbcon.h" | ||
19 | #include "fbcon_rotate.h" | ||
20 | |||
21 | /* | ||
22 | * Rotation 270 degrees | ||
23 | */ | ||
24 | |||
25 | static void ccw_update_attr(u8 *dst, u8 *src, int attribute, | ||
26 | struct vc_data *vc) | ||
27 | { | ||
28 | int i, j, offset = (vc->vc_font.height < 10) ? 1 : 2; | ||
29 | int width = (vc->vc_font.height + 7) >> 3; | ||
30 | int mod = vc->vc_font.height % 8; | ||
31 | u8 c, msk = ~(0xff << offset), msk1 = 0; | ||
32 | |||
33 | if (mod) | ||
34 | msk <<= (8 - mod); | ||
35 | |||
36 | if (offset > mod) | ||
37 | msk1 |= 0x01; | ||
38 | |||
39 | for (i = 0; i < vc->vc_font.width; i++) { | ||
40 | for (j = 0; j < width; j++) { | ||
41 | c = *src; | ||
42 | |||
43 | if (attribute & FBCON_ATTRIBUTE_UNDERLINE) { | ||
44 | if (j == width - 1) | ||
45 | c |= msk; | ||
46 | |||
47 | if (msk1 && j == width - 2) | ||
48 | c |= msk1; | ||
49 | } | ||
50 | |||
51 | if (attribute & FBCON_ATTRIBUTE_BOLD && i) | ||
52 | *(dst - width) |= c; | ||
53 | |||
54 | if (attribute & FBCON_ATTRIBUTE_REVERSE) | ||
55 | c = ~c; | ||
56 | src++; | ||
57 | *dst++ = c; | ||
58 | } | ||
59 | } | ||
60 | } | ||
61 | |||
62 | |||
63 | static void ccw_bmove(struct vc_data *vc, struct fb_info *info, int sy, | ||
64 | int sx, int dy, int dx, int height, int width) | ||
65 | { | ||
66 | struct fbcon_ops *ops = info->fbcon_par; | ||
67 | struct fb_copyarea area; | ||
68 | u32 vyres = GETVYRES(ops->p->scrollmode, info); | ||
69 | |||
70 | area.sx = sy * vc->vc_font.height; | ||
71 | area.sy = vyres - ((sx + width) * vc->vc_font.width); | ||
72 | area.dx = dy * vc->vc_font.height; | ||
73 | area.dy = vyres - ((dx + width) * vc->vc_font.width); | ||
74 | area.width = height * vc->vc_font.height; | ||
75 | area.height = width * vc->vc_font.width; | ||
76 | |||
77 | info->fbops->fb_copyarea(info, &area); | ||
78 | } | ||
79 | |||
80 | static void ccw_clear(struct vc_data *vc, struct fb_info *info, int sy, | ||
81 | int sx, int height, int width) | ||
82 | { | ||
83 | struct fbcon_ops *ops = info->fbcon_par; | ||
84 | struct fb_fillrect region; | ||
85 | int bgshift = (vc->vc_hi_font_mask) ? 13 : 12; | ||
86 | u32 vyres = GETVYRES(ops->p->scrollmode, info); | ||
87 | |||
88 | region.color = attr_bgcol_ec(bgshift,vc,info); | ||
89 | region.dx = sy * vc->vc_font.height; | ||
90 | region.dy = vyres - ((sx + width) * vc->vc_font.width); | ||
91 | region.height = width * vc->vc_font.width; | ||
92 | region.width = height * vc->vc_font.height; | ||
93 | region.rop = ROP_COPY; | ||
94 | |||
95 | info->fbops->fb_fillrect(info, ®ion); | ||
96 | } | ||
97 | |||
98 | static inline void ccw_putcs_aligned(struct vc_data *vc, struct fb_info *info, | ||
99 | const u16 *s, u32 attr, u32 cnt, | ||
100 | u32 d_pitch, u32 s_pitch, u32 cellsize, | ||
101 | struct fb_image *image, u8 *buf, u8 *dst) | ||
102 | { | ||
103 | struct fbcon_ops *ops = info->fbcon_par; | ||
104 | u16 charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff; | ||
105 | u32 idx = (vc->vc_font.height + 7) >> 3; | ||
106 | u8 *src; | ||
107 | |||
108 | while (cnt--) { | ||
109 | src = ops->fontbuffer + (scr_readw(s--) & charmask)*cellsize; | ||
110 | |||
111 | if (attr) { | ||
112 | ccw_update_attr(buf, src, attr, vc); | ||
113 | src = buf; | ||
114 | } | ||
115 | |||
116 | if (likely(idx == 1)) | ||
117 | __fb_pad_aligned_buffer(dst, d_pitch, src, idx, | ||
118 | vc->vc_font.width); | ||
119 | else | ||
120 | fb_pad_aligned_buffer(dst, d_pitch, src, idx, | ||
121 | vc->vc_font.width); | ||
122 | |||
123 | dst += d_pitch * vc->vc_font.width; | ||
124 | } | ||
125 | |||
126 | info->fbops->fb_imageblit(info, image); | ||
127 | } | ||
128 | |||
129 | static void ccw_putcs(struct vc_data *vc, struct fb_info *info, | ||
130 | const unsigned short *s, int count, int yy, int xx, | ||
131 | int fg, int bg) | ||
132 | { | ||
133 | struct fb_image image; | ||
134 | struct fbcon_ops *ops = info->fbcon_par; | ||
135 | u32 width = (vc->vc_font.height + 7)/8; | ||
136 | u32 cellsize = width * vc->vc_font.width; | ||
137 | u32 maxcnt = info->pixmap.size/cellsize; | ||
138 | u32 scan_align = info->pixmap.scan_align - 1; | ||
139 | u32 buf_align = info->pixmap.buf_align - 1; | ||
140 | u32 cnt, pitch, size; | ||
141 | u32 attribute = get_attribute(info, scr_readw(s)); | ||
142 | u8 *dst, *buf = NULL; | ||
143 | u32 vyres = GETVYRES(ops->p->scrollmode, info); | ||
144 | |||
145 | if (!ops->fontbuffer) | ||
146 | return; | ||
147 | |||
148 | image.fg_color = fg; | ||
149 | image.bg_color = bg; | ||
150 | image.dx = yy * vc->vc_font.height; | ||
151 | image.dy = vyres - ((xx + count) * vc->vc_font.width); | ||
152 | image.width = vc->vc_font.height; | ||
153 | image.depth = 1; | ||
154 | |||
155 | if (attribute) { | ||
156 | buf = kmalloc(cellsize, GFP_KERNEL); | ||
157 | if (!buf) | ||
158 | return; | ||
159 | } | ||
160 | |||
161 | s += count - 1; | ||
162 | |||
163 | while (count) { | ||
164 | if (count > maxcnt) | ||
165 | cnt = maxcnt; | ||
166 | else | ||
167 | cnt = count; | ||
168 | |||
169 | image.height = vc->vc_font.width * cnt; | ||
170 | pitch = ((image.width + 7) >> 3) + scan_align; | ||
171 | pitch &= ~scan_align; | ||
172 | size = pitch * image.height + buf_align; | ||
173 | size &= ~buf_align; | ||
174 | dst = fb_get_buffer_offset(info, &info->pixmap, size); | ||
175 | image.data = dst; | ||
176 | ccw_putcs_aligned(vc, info, s, attribute, cnt, pitch, | ||
177 | width, cellsize, &image, buf, dst); | ||
178 | image.dy += image.height; | ||
179 | count -= cnt; | ||
180 | s -= cnt; | ||
181 | } | ||
182 | |||
183 | /* buf is always NULL except when in monochrome mode, so in this case | ||
184 | it's a gain to check buf against NULL even though kfree() handles | ||
185 | NULL pointers just fine */ | ||
186 | if (unlikely(buf)) | ||
187 | kfree(buf); | ||
188 | |||
189 | } | ||
190 | |||
191 | static void ccw_clear_margins(struct vc_data *vc, struct fb_info *info, | ||
192 | int bottom_only) | ||
193 | { | ||
194 | unsigned int cw = vc->vc_font.width; | ||
195 | unsigned int ch = vc->vc_font.height; | ||
196 | unsigned int rw = info->var.yres - (vc->vc_cols*cw); | ||
197 | unsigned int bh = info->var.xres - (vc->vc_rows*ch); | ||
198 | unsigned int bs = vc->vc_rows*ch; | ||
199 | struct fb_fillrect region; | ||
200 | |||
201 | region.color = 0; | ||
202 | region.rop = ROP_COPY; | ||
203 | |||
204 | if (rw && !bottom_only) { | ||
205 | region.dx = 0; | ||
206 | region.dy = info->var.yoffset; | ||
207 | region.height = rw; | ||
208 | region.width = info->var.xres_virtual; | ||
209 | info->fbops->fb_fillrect(info, ®ion); | ||
210 | } | ||
211 | |||
212 | if (bh) { | ||
213 | region.dx = info->var.xoffset + bs; | ||
214 | region.dy = 0; | ||
215 | region.height = info->var.yres_virtual; | ||
216 | region.width = bh; | ||
217 | info->fbops->fb_fillrect(info, ®ion); | ||
218 | } | ||
219 | } | ||
220 | |||
221 | static void ccw_cursor(struct vc_data *vc, struct fb_info *info, int mode, | ||
222 | int softback_lines, int fg, int bg) | ||
223 | { | ||
224 | struct fb_cursor cursor; | ||
225 | struct fbcon_ops *ops = info->fbcon_par; | ||
226 | unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff; | ||
227 | int w = (vc->vc_font.height + 7) >> 3, c; | ||
228 | int y = real_y(ops->p, vc->vc_y); | ||
229 | int attribute, use_sw = (vc->vc_cursor_type & 0x10); | ||
230 | int err = 1, dx, dy; | ||
231 | char *src; | ||
232 | u32 vyres = GETVYRES(ops->p->scrollmode, info); | ||
233 | |||
234 | if (!ops->fontbuffer) | ||
235 | return; | ||
236 | |||
237 | cursor.set = 0; | ||
238 | |||
239 | if (softback_lines) { | ||
240 | if (y + softback_lines >= vc->vc_rows) { | ||
241 | mode = CM_ERASE; | ||
242 | ops->cursor_flash = 0; | ||
243 | return; | ||
244 | } else | ||
245 | y += softback_lines; | ||
246 | } | ||
247 | |||
248 | c = scr_readw((u16 *) vc->vc_pos); | ||
249 | attribute = get_attribute(info, c); | ||
250 | src = ops->fontbuffer + ((c & charmask) * (w * vc->vc_font.width)); | ||
251 | |||
252 | if (ops->cursor_state.image.data != src || | ||
253 | ops->cursor_reset) { | ||
254 | ops->cursor_state.image.data = src; | ||
255 | cursor.set |= FB_CUR_SETIMAGE; | ||
256 | } | ||
257 | |||
258 | if (attribute) { | ||
259 | u8 *dst; | ||
260 | |||
261 | dst = kmalloc(w * vc->vc_font.width, GFP_ATOMIC); | ||
262 | if (!dst) | ||
263 | return; | ||
264 | kfree(ops->cursor_data); | ||
265 | ops->cursor_data = dst; | ||
266 | ccw_update_attr(dst, src, attribute, vc); | ||
267 | src = dst; | ||
268 | } | ||
269 | |||
270 | if (ops->cursor_state.image.fg_color != fg || | ||
271 | ops->cursor_state.image.bg_color != bg || | ||
272 | ops->cursor_reset) { | ||
273 | ops->cursor_state.image.fg_color = fg; | ||
274 | ops->cursor_state.image.bg_color = bg; | ||
275 | cursor.set |= FB_CUR_SETCMAP; | ||
276 | } | ||
277 | |||
278 | if (ops->cursor_state.image.height != vc->vc_font.width || | ||
279 | ops->cursor_state.image.width != vc->vc_font.height || | ||
280 | ops->cursor_reset) { | ||
281 | ops->cursor_state.image.height = vc->vc_font.width; | ||
282 | ops->cursor_state.image.width = vc->vc_font.height; | ||
283 | cursor.set |= FB_CUR_SETSIZE; | ||
284 | } | ||
285 | |||
286 | dx = y * vc->vc_font.height; | ||
287 | dy = vyres - ((vc->vc_x + 1) * vc->vc_font.width); | ||
288 | |||
289 | if (ops->cursor_state.image.dx != dx || | ||
290 | ops->cursor_state.image.dy != dy || | ||
291 | ops->cursor_reset) { | ||
292 | ops->cursor_state.image.dx = dx; | ||
293 | ops->cursor_state.image.dy = dy; | ||
294 | cursor.set |= FB_CUR_SETPOS; | ||
295 | } | ||
296 | |||
297 | if (ops->cursor_state.hot.x || ops->cursor_state.hot.y || | ||
298 | ops->cursor_reset) { | ||
299 | ops->cursor_state.hot.x = cursor.hot.y = 0; | ||
300 | cursor.set |= FB_CUR_SETHOT; | ||
301 | } | ||
302 | |||
303 | if (cursor.set & FB_CUR_SETSIZE || | ||
304 | vc->vc_cursor_type != ops->p->cursor_shape || | ||
305 | ops->cursor_state.mask == NULL || | ||
306 | ops->cursor_reset) { | ||
307 | char *tmp, *mask = kmalloc(w*vc->vc_font.width, GFP_ATOMIC); | ||
308 | int cur_height, size, i = 0; | ||
309 | int width = (vc->vc_font.width + 7)/8; | ||
310 | |||
311 | if (!mask) | ||
312 | return; | ||
313 | |||
314 | tmp = kmalloc(width * vc->vc_font.height, GFP_ATOMIC); | ||
315 | |||
316 | if (!tmp) { | ||
317 | kfree(mask); | ||
318 | return; | ||
319 | } | ||
320 | |||
321 | kfree(ops->cursor_state.mask); | ||
322 | ops->cursor_state.mask = mask; | ||
323 | |||
324 | ops->p->cursor_shape = vc->vc_cursor_type; | ||
325 | cursor.set |= FB_CUR_SETSHAPE; | ||
326 | |||
327 | switch (ops->p->cursor_shape & CUR_HWMASK) { | ||
328 | case CUR_NONE: | ||
329 | cur_height = 0; | ||
330 | break; | ||
331 | case CUR_UNDERLINE: | ||
332 | cur_height = (vc->vc_font.height < 10) ? 1 : 2; | ||
333 | break; | ||
334 | case CUR_LOWER_THIRD: | ||
335 | cur_height = vc->vc_font.height/3; | ||
336 | break; | ||
337 | case CUR_LOWER_HALF: | ||
338 | cur_height = vc->vc_font.height >> 1; | ||
339 | break; | ||
340 | case CUR_TWO_THIRDS: | ||
341 | cur_height = (vc->vc_font.height << 1)/3; | ||
342 | break; | ||
343 | case CUR_BLOCK: | ||
344 | default: | ||
345 | cur_height = vc->vc_font.height; | ||
346 | break; | ||
347 | } | ||
348 | |||
349 | size = (vc->vc_font.height - cur_height) * width; | ||
350 | while (size--) | ||
351 | tmp[i++] = 0; | ||
352 | size = cur_height * width; | ||
353 | while (size--) | ||
354 | tmp[i++] = 0xff; | ||
355 | memset(mask, 0, w * vc->vc_font.width); | ||
356 | rotate_ccw(tmp, mask, vc->vc_font.width, vc->vc_font.height); | ||
357 | kfree(tmp); | ||
358 | } | ||
359 | |||
360 | switch (mode) { | ||
361 | case CM_ERASE: | ||
362 | ops->cursor_state.enable = 0; | ||
363 | break; | ||
364 | case CM_DRAW: | ||
365 | case CM_MOVE: | ||
366 | default: | ||
367 | ops->cursor_state.enable = (use_sw) ? 0 : 1; | ||
368 | break; | ||
369 | } | ||
370 | |||
371 | cursor.image.data = src; | ||
372 | cursor.image.fg_color = ops->cursor_state.image.fg_color; | ||
373 | cursor.image.bg_color = ops->cursor_state.image.bg_color; | ||
374 | cursor.image.dx = ops->cursor_state.image.dx; | ||
375 | cursor.image.dy = ops->cursor_state.image.dy; | ||
376 | cursor.image.height = ops->cursor_state.image.height; | ||
377 | cursor.image.width = ops->cursor_state.image.width; | ||
378 | cursor.hot.x = ops->cursor_state.hot.x; | ||
379 | cursor.hot.y = ops->cursor_state.hot.y; | ||
380 | cursor.mask = ops->cursor_state.mask; | ||
381 | cursor.enable = ops->cursor_state.enable; | ||
382 | cursor.image.depth = 1; | ||
383 | cursor.rop = ROP_XOR; | ||
384 | |||
385 | if (info->fbops->fb_cursor) | ||
386 | err = info->fbops->fb_cursor(info, &cursor); | ||
387 | |||
388 | if (err) | ||
389 | soft_cursor(info, &cursor); | ||
390 | |||
391 | ops->cursor_reset = 0; | ||
392 | } | ||
393 | |||
394 | static int ccw_update_start(struct fb_info *info) | ||
395 | { | ||
396 | struct fbcon_ops *ops = info->fbcon_par; | ||
397 | u32 yoffset; | ||
398 | u32 vyres = GETVYRES(ops->p->scrollmode, info); | ||
399 | int err; | ||
400 | |||
401 | yoffset = (vyres - info->var.yres) - ops->var.xoffset; | ||
402 | ops->var.xoffset = ops->var.yoffset; | ||
403 | ops->var.yoffset = yoffset; | ||
404 | err = fb_pan_display(info, &ops->var); | ||
405 | ops->var.xoffset = info->var.xoffset; | ||
406 | ops->var.yoffset = info->var.yoffset; | ||
407 | ops->var.vmode = info->var.vmode; | ||
408 | return err; | ||
409 | } | ||
410 | |||
411 | void fbcon_rotate_ccw(struct fbcon_ops *ops) | ||
412 | { | ||
413 | ops->bmove = ccw_bmove; | ||
414 | ops->clear = ccw_clear; | ||
415 | ops->putcs = ccw_putcs; | ||
416 | ops->clear_margins = ccw_clear_margins; | ||
417 | ops->cursor = ccw_cursor; | ||
418 | ops->update_start = ccw_update_start; | ||
419 | } | ||
420 | EXPORT_SYMBOL(fbcon_rotate_ccw); | ||
421 | |||
422 | MODULE_AUTHOR("Antonino Daplas <adaplas@pol.net>"); | ||
423 | MODULE_DESCRIPTION("Console Rotation (270 degrees) Support"); | ||
424 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/video/console/fbcon_cw.c b/drivers/video/console/fbcon_cw.c deleted file mode 100644 index e7ee44db4e98..000000000000 --- a/drivers/video/console/fbcon_cw.c +++ /dev/null | |||
@@ -1,407 +0,0 @@ | |||
1 | /* | ||
2 | * linux/drivers/video/console/fbcon_ud.c -- Software Rotation - 90 degrees | ||
3 | * | ||
4 | * Copyright (C) 2005 Antonino Daplas <adaplas @pol.net> | ||
5 | * | ||
6 | * This file is subject to the terms and conditions of the GNU General Public | ||
7 | * License. See the file COPYING in the main directory of this archive for | ||
8 | * more details. | ||
9 | */ | ||
10 | |||
11 | #include <linux/module.h> | ||
12 | #include <linux/slab.h> | ||
13 | #include <linux/string.h> | ||
14 | #include <linux/fb.h> | ||
15 | #include <linux/vt_kern.h> | ||
16 | #include <linux/console.h> | ||
17 | #include <asm/types.h> | ||
18 | #include "fbcon.h" | ||
19 | #include "fbcon_rotate.h" | ||
20 | |||
21 | /* | ||
22 | * Rotation 90 degrees | ||
23 | */ | ||
24 | |||
25 | static void cw_update_attr(u8 *dst, u8 *src, int attribute, | ||
26 | struct vc_data *vc) | ||
27 | { | ||
28 | int i, j, offset = (vc->vc_font.height < 10) ? 1 : 2; | ||
29 | int width = (vc->vc_font.height + 7) >> 3; | ||
30 | u8 c, msk = ~(0xff >> offset); | ||
31 | |||
32 | for (i = 0; i < vc->vc_font.width; i++) { | ||
33 | for (j = 0; j < width; j++) { | ||
34 | c = *src; | ||
35 | if (attribute & FBCON_ATTRIBUTE_UNDERLINE && !j) | ||
36 | c |= msk; | ||
37 | if (attribute & FBCON_ATTRIBUTE_BOLD && i) | ||
38 | c |= *(src-width); | ||
39 | if (attribute & FBCON_ATTRIBUTE_REVERSE) | ||
40 | c = ~c; | ||
41 | src++; | ||
42 | *dst++ = c; | ||
43 | } | ||
44 | } | ||
45 | } | ||
46 | |||
47 | |||
48 | static void cw_bmove(struct vc_data *vc, struct fb_info *info, int sy, | ||
49 | int sx, int dy, int dx, int height, int width) | ||
50 | { | ||
51 | struct fbcon_ops *ops = info->fbcon_par; | ||
52 | struct fb_copyarea area; | ||
53 | u32 vxres = GETVXRES(ops->p->scrollmode, info); | ||
54 | |||
55 | area.sx = vxres - ((sy + height) * vc->vc_font.height); | ||
56 | area.sy = sx * vc->vc_font.width; | ||
57 | area.dx = vxres - ((dy + height) * vc->vc_font.height); | ||
58 | area.dy = dx * vc->vc_font.width; | ||
59 | area.width = height * vc->vc_font.height; | ||
60 | area.height = width * vc->vc_font.width; | ||
61 | |||
62 | info->fbops->fb_copyarea(info, &area); | ||
63 | } | ||
64 | |||
65 | static void cw_clear(struct vc_data *vc, struct fb_info *info, int sy, | ||
66 | int sx, int height, int width) | ||
67 | { | ||
68 | struct fbcon_ops *ops = info->fbcon_par; | ||
69 | struct fb_fillrect region; | ||
70 | int bgshift = (vc->vc_hi_font_mask) ? 13 : 12; | ||
71 | u32 vxres = GETVXRES(ops->p->scrollmode, info); | ||
72 | |||
73 | region.color = attr_bgcol_ec(bgshift,vc,info); | ||
74 | region.dx = vxres - ((sy + height) * vc->vc_font.height); | ||
75 | region.dy = sx * vc->vc_font.width; | ||
76 | region.height = width * vc->vc_font.width; | ||
77 | region.width = height * vc->vc_font.height; | ||
78 | region.rop = ROP_COPY; | ||
79 | |||
80 | info->fbops->fb_fillrect(info, ®ion); | ||
81 | } | ||
82 | |||
83 | static inline void cw_putcs_aligned(struct vc_data *vc, struct fb_info *info, | ||
84 | const u16 *s, u32 attr, u32 cnt, | ||
85 | u32 d_pitch, u32 s_pitch, u32 cellsize, | ||
86 | struct fb_image *image, u8 *buf, u8 *dst) | ||
87 | { | ||
88 | struct fbcon_ops *ops = info->fbcon_par; | ||
89 | u16 charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff; | ||
90 | u32 idx = (vc->vc_font.height + 7) >> 3; | ||
91 | u8 *src; | ||
92 | |||
93 | while (cnt--) { | ||
94 | src = ops->fontbuffer + (scr_readw(s++) & charmask)*cellsize; | ||
95 | |||
96 | if (attr) { | ||
97 | cw_update_attr(buf, src, attr, vc); | ||
98 | src = buf; | ||
99 | } | ||
100 | |||
101 | if (likely(idx == 1)) | ||
102 | __fb_pad_aligned_buffer(dst, d_pitch, src, idx, | ||
103 | vc->vc_font.width); | ||
104 | else | ||
105 | fb_pad_aligned_buffer(dst, d_pitch, src, idx, | ||
106 | vc->vc_font.width); | ||
107 | |||
108 | dst += d_pitch * vc->vc_font.width; | ||
109 | } | ||
110 | |||
111 | info->fbops->fb_imageblit(info, image); | ||
112 | } | ||
113 | |||
114 | static void cw_putcs(struct vc_data *vc, struct fb_info *info, | ||
115 | const unsigned short *s, int count, int yy, int xx, | ||
116 | int fg, int bg) | ||
117 | { | ||
118 | struct fb_image image; | ||
119 | struct fbcon_ops *ops = info->fbcon_par; | ||
120 | u32 width = (vc->vc_font.height + 7)/8; | ||
121 | u32 cellsize = width * vc->vc_font.width; | ||
122 | u32 maxcnt = info->pixmap.size/cellsize; | ||
123 | u32 scan_align = info->pixmap.scan_align - 1; | ||
124 | u32 buf_align = info->pixmap.buf_align - 1; | ||
125 | u32 cnt, pitch, size; | ||
126 | u32 attribute = get_attribute(info, scr_readw(s)); | ||
127 | u8 *dst, *buf = NULL; | ||
128 | u32 vxres = GETVXRES(ops->p->scrollmode, info); | ||
129 | |||
130 | if (!ops->fontbuffer) | ||
131 | return; | ||
132 | |||
133 | image.fg_color = fg; | ||
134 | image.bg_color = bg; | ||
135 | image.dx = vxres - ((yy + 1) * vc->vc_font.height); | ||
136 | image.dy = xx * vc->vc_font.width; | ||
137 | image.width = vc->vc_font.height; | ||
138 | image.depth = 1; | ||
139 | |||
140 | if (attribute) { | ||
141 | buf = kmalloc(cellsize, GFP_KERNEL); | ||
142 | if (!buf) | ||
143 | return; | ||
144 | } | ||
145 | |||
146 | while (count) { | ||
147 | if (count > maxcnt) | ||
148 | cnt = maxcnt; | ||
149 | else | ||
150 | cnt = count; | ||
151 | |||
152 | image.height = vc->vc_font.width * cnt; | ||
153 | pitch = ((image.width + 7) >> 3) + scan_align; | ||
154 | pitch &= ~scan_align; | ||
155 | size = pitch * image.height + buf_align; | ||
156 | size &= ~buf_align; | ||
157 | dst = fb_get_buffer_offset(info, &info->pixmap, size); | ||
158 | image.data = dst; | ||
159 | cw_putcs_aligned(vc, info, s, attribute, cnt, pitch, | ||
160 | width, cellsize, &image, buf, dst); | ||
161 | image.dy += image.height; | ||
162 | count -= cnt; | ||
163 | s += cnt; | ||
164 | } | ||
165 | |||
166 | /* buf is always NULL except when in monochrome mode, so in this case | ||
167 | it's a gain to check buf against NULL even though kfree() handles | ||
168 | NULL pointers just fine */ | ||
169 | if (unlikely(buf)) | ||
170 | kfree(buf); | ||
171 | |||
172 | } | ||
173 | |||
174 | static void cw_clear_margins(struct vc_data *vc, struct fb_info *info, | ||
175 | int bottom_only) | ||
176 | { | ||
177 | unsigned int cw = vc->vc_font.width; | ||
178 | unsigned int ch = vc->vc_font.height; | ||
179 | unsigned int rw = info->var.yres - (vc->vc_cols*cw); | ||
180 | unsigned int bh = info->var.xres - (vc->vc_rows*ch); | ||
181 | unsigned int rs = info->var.yres - rw; | ||
182 | struct fb_fillrect region; | ||
183 | |||
184 | region.color = 0; | ||
185 | region.rop = ROP_COPY; | ||
186 | |||
187 | if (rw && !bottom_only) { | ||
188 | region.dx = 0; | ||
189 | region.dy = info->var.yoffset + rs; | ||
190 | region.height = rw; | ||
191 | region.width = info->var.xres_virtual; | ||
192 | info->fbops->fb_fillrect(info, ®ion); | ||
193 | } | ||
194 | |||
195 | if (bh) { | ||
196 | region.dx = info->var.xoffset; | ||
197 | region.dy = info->var.yoffset; | ||
198 | region.height = info->var.yres; | ||
199 | region.width = bh; | ||
200 | info->fbops->fb_fillrect(info, ®ion); | ||
201 | } | ||
202 | } | ||
203 | |||
204 | static void cw_cursor(struct vc_data *vc, struct fb_info *info, int mode, | ||
205 | int softback_lines, int fg, int bg) | ||
206 | { | ||
207 | struct fb_cursor cursor; | ||
208 | struct fbcon_ops *ops = info->fbcon_par; | ||
209 | unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff; | ||
210 | int w = (vc->vc_font.height + 7) >> 3, c; | ||
211 | int y = real_y(ops->p, vc->vc_y); | ||
212 | int attribute, use_sw = (vc->vc_cursor_type & 0x10); | ||
213 | int err = 1, dx, dy; | ||
214 | char *src; | ||
215 | u32 vxres = GETVXRES(ops->p->scrollmode, info); | ||
216 | |||
217 | if (!ops->fontbuffer) | ||
218 | return; | ||
219 | |||
220 | cursor.set = 0; | ||
221 | |||
222 | if (softback_lines) { | ||
223 | if (y + softback_lines >= vc->vc_rows) { | ||
224 | mode = CM_ERASE; | ||
225 | ops->cursor_flash = 0; | ||
226 | return; | ||
227 | } else | ||
228 | y += softback_lines; | ||
229 | } | ||
230 | |||
231 | c = scr_readw((u16 *) vc->vc_pos); | ||
232 | attribute = get_attribute(info, c); | ||
233 | src = ops->fontbuffer + ((c & charmask) * (w * vc->vc_font.width)); | ||
234 | |||
235 | if (ops->cursor_state.image.data != src || | ||
236 | ops->cursor_reset) { | ||
237 | ops->cursor_state.image.data = src; | ||
238 | cursor.set |= FB_CUR_SETIMAGE; | ||
239 | } | ||
240 | |||
241 | if (attribute) { | ||
242 | u8 *dst; | ||
243 | |||
244 | dst = kmalloc(w * vc->vc_font.width, GFP_ATOMIC); | ||
245 | if (!dst) | ||
246 | return; | ||
247 | kfree(ops->cursor_data); | ||
248 | ops->cursor_data = dst; | ||
249 | cw_update_attr(dst, src, attribute, vc); | ||
250 | src = dst; | ||
251 | } | ||
252 | |||
253 | if (ops->cursor_state.image.fg_color != fg || | ||
254 | ops->cursor_state.image.bg_color != bg || | ||
255 | ops->cursor_reset) { | ||
256 | ops->cursor_state.image.fg_color = fg; | ||
257 | ops->cursor_state.image.bg_color = bg; | ||
258 | cursor.set |= FB_CUR_SETCMAP; | ||
259 | } | ||
260 | |||
261 | if (ops->cursor_state.image.height != vc->vc_font.width || | ||
262 | ops->cursor_state.image.width != vc->vc_font.height || | ||
263 | ops->cursor_reset) { | ||
264 | ops->cursor_state.image.height = vc->vc_font.width; | ||
265 | ops->cursor_state.image.width = vc->vc_font.height; | ||
266 | cursor.set |= FB_CUR_SETSIZE; | ||
267 | } | ||
268 | |||
269 | dx = vxres - ((y * vc->vc_font.height) + vc->vc_font.height); | ||
270 | dy = vc->vc_x * vc->vc_font.width; | ||
271 | |||
272 | if (ops->cursor_state.image.dx != dx || | ||
273 | ops->cursor_state.image.dy != dy || | ||
274 | ops->cursor_reset) { | ||
275 | ops->cursor_state.image.dx = dx; | ||
276 | ops->cursor_state.image.dy = dy; | ||
277 | cursor.set |= FB_CUR_SETPOS; | ||
278 | } | ||
279 | |||
280 | if (ops->cursor_state.hot.x || ops->cursor_state.hot.y || | ||
281 | ops->cursor_reset) { | ||
282 | ops->cursor_state.hot.x = cursor.hot.y = 0; | ||
283 | cursor.set |= FB_CUR_SETHOT; | ||
284 | } | ||
285 | |||
286 | if (cursor.set & FB_CUR_SETSIZE || | ||
287 | vc->vc_cursor_type != ops->p->cursor_shape || | ||
288 | ops->cursor_state.mask == NULL || | ||
289 | ops->cursor_reset) { | ||
290 | char *tmp, *mask = kmalloc(w*vc->vc_font.width, GFP_ATOMIC); | ||
291 | int cur_height, size, i = 0; | ||
292 | int width = (vc->vc_font.width + 7)/8; | ||
293 | |||
294 | if (!mask) | ||
295 | return; | ||
296 | |||
297 | tmp = kmalloc(width * vc->vc_font.height, GFP_ATOMIC); | ||
298 | |||
299 | if (!tmp) { | ||
300 | kfree(mask); | ||
301 | return; | ||
302 | } | ||
303 | |||
304 | kfree(ops->cursor_state.mask); | ||
305 | ops->cursor_state.mask = mask; | ||
306 | |||
307 | ops->p->cursor_shape = vc->vc_cursor_type; | ||
308 | cursor.set |= FB_CUR_SETSHAPE; | ||
309 | |||
310 | switch (ops->p->cursor_shape & CUR_HWMASK) { | ||
311 | case CUR_NONE: | ||
312 | cur_height = 0; | ||
313 | break; | ||
314 | case CUR_UNDERLINE: | ||
315 | cur_height = (vc->vc_font.height < 10) ? 1 : 2; | ||
316 | break; | ||
317 | case CUR_LOWER_THIRD: | ||
318 | cur_height = vc->vc_font.height/3; | ||
319 | break; | ||
320 | case CUR_LOWER_HALF: | ||
321 | cur_height = vc->vc_font.height >> 1; | ||
322 | break; | ||
323 | case CUR_TWO_THIRDS: | ||
324 | cur_height = (vc->vc_font.height << 1)/3; | ||
325 | break; | ||
326 | case CUR_BLOCK: | ||
327 | default: | ||
328 | cur_height = vc->vc_font.height; | ||
329 | break; | ||
330 | } | ||
331 | |||
332 | size = (vc->vc_font.height - cur_height) * width; | ||
333 | while (size--) | ||
334 | tmp[i++] = 0; | ||
335 | size = cur_height * width; | ||
336 | while (size--) | ||
337 | tmp[i++] = 0xff; | ||
338 | memset(mask, 0, w * vc->vc_font.width); | ||
339 | rotate_cw(tmp, mask, vc->vc_font.width, vc->vc_font.height); | ||
340 | kfree(tmp); | ||
341 | } | ||
342 | |||
343 | switch (mode) { | ||
344 | case CM_ERASE: | ||
345 | ops->cursor_state.enable = 0; | ||
346 | break; | ||
347 | case CM_DRAW: | ||
348 | case CM_MOVE: | ||
349 | default: | ||
350 | ops->cursor_state.enable = (use_sw) ? 0 : 1; | ||
351 | break; | ||
352 | } | ||
353 | |||
354 | cursor.image.data = src; | ||
355 | cursor.image.fg_color = ops->cursor_state.image.fg_color; | ||
356 | cursor.image.bg_color = ops->cursor_state.image.bg_color; | ||
357 | cursor.image.dx = ops->cursor_state.image.dx; | ||
358 | cursor.image.dy = ops->cursor_state.image.dy; | ||
359 | cursor.image.height = ops->cursor_state.image.height; | ||
360 | cursor.image.width = ops->cursor_state.image.width; | ||
361 | cursor.hot.x = ops->cursor_state.hot.x; | ||
362 | cursor.hot.y = ops->cursor_state.hot.y; | ||
363 | cursor.mask = ops->cursor_state.mask; | ||
364 | cursor.enable = ops->cursor_state.enable; | ||
365 | cursor.image.depth = 1; | ||
366 | cursor.rop = ROP_XOR; | ||
367 | |||
368 | if (info->fbops->fb_cursor) | ||
369 | err = info->fbops->fb_cursor(info, &cursor); | ||
370 | |||
371 | if (err) | ||
372 | soft_cursor(info, &cursor); | ||
373 | |||
374 | ops->cursor_reset = 0; | ||
375 | } | ||
376 | |||
377 | static int cw_update_start(struct fb_info *info) | ||
378 | { | ||
379 | struct fbcon_ops *ops = info->fbcon_par; | ||
380 | u32 vxres = GETVXRES(ops->p->scrollmode, info); | ||
381 | u32 xoffset; | ||
382 | int err; | ||
383 | |||
384 | xoffset = vxres - (info->var.xres + ops->var.yoffset); | ||
385 | ops->var.yoffset = ops->var.xoffset; | ||
386 | ops->var.xoffset = xoffset; | ||
387 | err = fb_pan_display(info, &ops->var); | ||
388 | ops->var.xoffset = info->var.xoffset; | ||
389 | ops->var.yoffset = info->var.yoffset; | ||
390 | ops->var.vmode = info->var.vmode; | ||
391 | return err; | ||
392 | } | ||
393 | |||
394 | void fbcon_rotate_cw(struct fbcon_ops *ops) | ||
395 | { | ||
396 | ops->bmove = cw_bmove; | ||
397 | ops->clear = cw_clear; | ||
398 | ops->putcs = cw_putcs; | ||
399 | ops->clear_margins = cw_clear_margins; | ||
400 | ops->cursor = cw_cursor; | ||
401 | ops->update_start = cw_update_start; | ||
402 | } | ||
403 | EXPORT_SYMBOL(fbcon_rotate_cw); | ||
404 | |||
405 | MODULE_AUTHOR("Antonino Daplas <adaplas@pol.net>"); | ||
406 | MODULE_DESCRIPTION("Console Rotation (90 degrees) Support"); | ||
407 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/video/console/fbcon_rotate.c b/drivers/video/console/fbcon_rotate.c deleted file mode 100644 index db6528f2d3f2..000000000000 --- a/drivers/video/console/fbcon_rotate.c +++ /dev/null | |||
@@ -1,116 +0,0 @@ | |||
1 | /* | ||
2 | * linux/drivers/video/console/fbcon_rotate.c -- Software Rotation | ||
3 | * | ||
4 | * Copyright (C) 2005 Antonino Daplas <adaplas @pol.net> | ||
5 | * | ||
6 | * This file is subject to the terms and conditions of the GNU General Public | ||
7 | * License. See the file COPYING in the main directory of this archive for | ||
8 | * more details. | ||
9 | */ | ||
10 | |||
11 | #include <linux/module.h> | ||
12 | #include <linux/slab.h> | ||
13 | #include <linux/string.h> | ||
14 | #include <linux/fb.h> | ||
15 | #include <linux/vt_kern.h> | ||
16 | #include <linux/console.h> | ||
17 | #include <asm/types.h> | ||
18 | #include "fbcon.h" | ||
19 | #include "fbcon_rotate.h" | ||
20 | |||
21 | static int fbcon_rotate_font(struct fb_info *info, struct vc_data *vc) | ||
22 | { | ||
23 | struct fbcon_ops *ops = info->fbcon_par; | ||
24 | int len, err = 0; | ||
25 | int s_cellsize, d_cellsize, i; | ||
26 | const u8 *src; | ||
27 | u8 *dst; | ||
28 | |||
29 | if (vc->vc_font.data == ops->fontdata && | ||
30 | ops->p->con_rotate == ops->cur_rotate) | ||
31 | goto finished; | ||
32 | |||
33 | src = ops->fontdata = vc->vc_font.data; | ||
34 | ops->cur_rotate = ops->p->con_rotate; | ||
35 | len = (!ops->p->userfont) ? 256 : FNTCHARCNT(src); | ||
36 | s_cellsize = ((vc->vc_font.width + 7)/8) * | ||
37 | vc->vc_font.height; | ||
38 | d_cellsize = s_cellsize; | ||
39 | |||
40 | if (ops->rotate == FB_ROTATE_CW || | ||
41 | ops->rotate == FB_ROTATE_CCW) | ||
42 | d_cellsize = ((vc->vc_font.height + 7)/8) * | ||
43 | vc->vc_font.width; | ||
44 | |||
45 | if (info->fbops->fb_sync) | ||
46 | info->fbops->fb_sync(info); | ||
47 | |||
48 | if (ops->fd_size < d_cellsize * len) { | ||
49 | dst = kmalloc(d_cellsize * len, GFP_KERNEL); | ||
50 | |||
51 | if (dst == NULL) { | ||
52 | err = -ENOMEM; | ||
53 | goto finished; | ||
54 | } | ||
55 | |||
56 | ops->fd_size = d_cellsize * len; | ||
57 | kfree(ops->fontbuffer); | ||
58 | ops->fontbuffer = dst; | ||
59 | } | ||
60 | |||
61 | dst = ops->fontbuffer; | ||
62 | memset(dst, 0, ops->fd_size); | ||
63 | |||
64 | switch (ops->rotate) { | ||
65 | case FB_ROTATE_UD: | ||
66 | for (i = len; i--; ) { | ||
67 | rotate_ud(src, dst, vc->vc_font.width, | ||
68 | vc->vc_font.height); | ||
69 | |||
70 | src += s_cellsize; | ||
71 | dst += d_cellsize; | ||
72 | } | ||
73 | break; | ||
74 | case FB_ROTATE_CW: | ||
75 | for (i = len; i--; ) { | ||
76 | rotate_cw(src, dst, vc->vc_font.width, | ||
77 | vc->vc_font.height); | ||
78 | src += s_cellsize; | ||
79 | dst += d_cellsize; | ||
80 | } | ||
81 | break; | ||
82 | case FB_ROTATE_CCW: | ||
83 | for (i = len; i--; ) { | ||
84 | rotate_ccw(src, dst, vc->vc_font.width, | ||
85 | vc->vc_font.height); | ||
86 | src += s_cellsize; | ||
87 | dst += d_cellsize; | ||
88 | } | ||
89 | break; | ||
90 | } | ||
91 | |||
92 | finished: | ||
93 | return err; | ||
94 | } | ||
95 | |||
96 | void fbcon_set_rotate(struct fbcon_ops *ops) | ||
97 | { | ||
98 | ops->rotate_font = fbcon_rotate_font; | ||
99 | |||
100 | switch(ops->rotate) { | ||
101 | case FB_ROTATE_CW: | ||
102 | fbcon_rotate_cw(ops); | ||
103 | break; | ||
104 | case FB_ROTATE_UD: | ||
105 | fbcon_rotate_ud(ops); | ||
106 | break; | ||
107 | case FB_ROTATE_CCW: | ||
108 | fbcon_rotate_ccw(ops); | ||
109 | break; | ||
110 | } | ||
111 | } | ||
112 | EXPORT_SYMBOL(fbcon_set_rotate); | ||
113 | |||
114 | MODULE_AUTHOR("Antonino Daplas <adaplas@pol.net>"); | ||
115 | MODULE_DESCRIPTION("Console Rotation Support"); | ||
116 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/video/console/fbcon_rotate.h b/drivers/video/console/fbcon_rotate.h deleted file mode 100644 index e233444cda66..000000000000 --- a/drivers/video/console/fbcon_rotate.h +++ /dev/null | |||
@@ -1,96 +0,0 @@ | |||
1 | /* | ||
2 | * linux/drivers/video/console/fbcon_rotate.h -- Software Display Rotation | ||
3 | * | ||
4 | * Copyright (C) 2005 Antonino Daplas <adaplas@pol.net> | ||
5 | * | ||
6 | * This file is subject to the terms and conditions of the GNU General Public | ||
7 | * License. See the file COPYING in the main directory of this archive | ||
8 | * for more details. | ||
9 | */ | ||
10 | |||
11 | #ifndef _FBCON_ROTATE_H | ||
12 | #define _FBCON_ROTATE_H | ||
13 | |||
14 | #define GETVYRES(s,i) ({ \ | ||
15 | (s == SCROLL_REDRAW || s == SCROLL_MOVE) ? \ | ||
16 | (i)->var.yres : (i)->var.yres_virtual; }) | ||
17 | |||
18 | #define GETVXRES(s,i) ({ \ | ||
19 | (s == SCROLL_REDRAW || s == SCROLL_MOVE || !(i)->fix.xpanstep) ? \ | ||
20 | (i)->var.xres : (i)->var.xres_virtual; }) | ||
21 | |||
22 | |||
23 | static inline int pattern_test_bit(u32 x, u32 y, u32 pitch, const char *pat) | ||
24 | { | ||
25 | u32 tmp = (y * pitch) + x, index = tmp / 8, bit = tmp % 8; | ||
26 | |||
27 | pat +=index; | ||
28 | return (*pat) & (0x80 >> bit); | ||
29 | } | ||
30 | |||
31 | static inline void pattern_set_bit(u32 x, u32 y, u32 pitch, char *pat) | ||
32 | { | ||
33 | u32 tmp = (y * pitch) + x, index = tmp / 8, bit = tmp % 8; | ||
34 | |||
35 | pat += index; | ||
36 | |||
37 | (*pat) |= 0x80 >> bit; | ||
38 | } | ||
39 | |||
40 | static inline void rotate_ud(const char *in, char *out, u32 width, u32 height) | ||
41 | { | ||
42 | int i, j; | ||
43 | int shift = (8 - (width % 8)) & 7; | ||
44 | |||
45 | width = (width + 7) & ~7; | ||
46 | |||
47 | for (i = 0; i < height; i++) { | ||
48 | for (j = 0; j < width - shift; j++) { | ||
49 | if (pattern_test_bit(j, i, width, in)) | ||
50 | pattern_set_bit(width - (1 + j + shift), | ||
51 | height - (1 + i), | ||
52 | width, out); | ||
53 | } | ||
54 | |||
55 | } | ||
56 | } | ||
57 | |||
58 | static inline void rotate_cw(const char *in, char *out, u32 width, u32 height) | ||
59 | { | ||
60 | int i, j, h = height, w = width; | ||
61 | int shift = (8 - (height % 8)) & 7; | ||
62 | |||
63 | width = (width + 7) & ~7; | ||
64 | height = (height + 7) & ~7; | ||
65 | |||
66 | for (i = 0; i < h; i++) { | ||
67 | for (j = 0; j < w; j++) { | ||
68 | if (pattern_test_bit(j, i, width, in)) | ||
69 | pattern_set_bit(height - 1 - i - shift, j, | ||
70 | height, out); | ||
71 | |||
72 | } | ||
73 | } | ||
74 | } | ||
75 | |||
76 | static inline void rotate_ccw(const char *in, char *out, u32 width, u32 height) | ||
77 | { | ||
78 | int i, j, h = height, w = width; | ||
79 | int shift = (8 - (width % 8)) & 7; | ||
80 | |||
81 | width = (width + 7) & ~7; | ||
82 | height = (height + 7) & ~7; | ||
83 | |||
84 | for (i = 0; i < h; i++) { | ||
85 | for (j = 0; j < w; j++) { | ||
86 | if (pattern_test_bit(j, i, width, in)) | ||
87 | pattern_set_bit(i, width - 1 - j - shift, | ||
88 | height, out); | ||
89 | } | ||
90 | } | ||
91 | } | ||
92 | |||
93 | extern void fbcon_rotate_cw(struct fbcon_ops *ops); | ||
94 | extern void fbcon_rotate_ud(struct fbcon_ops *ops); | ||
95 | extern void fbcon_rotate_ccw(struct fbcon_ops *ops); | ||
96 | #endif | ||
diff --git a/drivers/video/console/fbcon_ud.c b/drivers/video/console/fbcon_ud.c deleted file mode 100644 index 19e3714abfe8..000000000000 --- a/drivers/video/console/fbcon_ud.c +++ /dev/null | |||
@@ -1,452 +0,0 @@ | |||
1 | /* | ||
2 | * linux/drivers/video/console/fbcon_ud.c -- Software Rotation - 180 degrees | ||
3 | * | ||
4 | * Copyright (C) 2005 Antonino Daplas <adaplas @pol.net> | ||
5 | * | ||
6 | * This file is subject to the terms and conditions of the GNU General Public | ||
7 | * License. See the file COPYING in the main directory of this archive for | ||
8 | * more details. | ||
9 | */ | ||
10 | |||
11 | #include <linux/module.h> | ||
12 | #include <linux/slab.h> | ||
13 | #include <linux/string.h> | ||
14 | #include <linux/fb.h> | ||
15 | #include <linux/vt_kern.h> | ||
16 | #include <linux/console.h> | ||
17 | #include <asm/types.h> | ||
18 | #include "fbcon.h" | ||
19 | #include "fbcon_rotate.h" | ||
20 | |||
21 | /* | ||
22 | * Rotation 180 degrees | ||
23 | */ | ||
24 | |||
25 | static void ud_update_attr(u8 *dst, u8 *src, int attribute, | ||
26 | struct vc_data *vc) | ||
27 | { | ||
28 | int i, offset = (vc->vc_font.height < 10) ? 1 : 2; | ||
29 | int width = (vc->vc_font.width + 7) >> 3; | ||
30 | unsigned int cellsize = vc->vc_font.height * width; | ||
31 | u8 c; | ||
32 | |||
33 | offset = offset * width; | ||
34 | |||
35 | for (i = 0; i < cellsize; i++) { | ||
36 | c = src[i]; | ||
37 | if (attribute & FBCON_ATTRIBUTE_UNDERLINE && i < offset) | ||
38 | c = 0xff; | ||
39 | if (attribute & FBCON_ATTRIBUTE_BOLD) | ||
40 | c |= c << 1; | ||
41 | if (attribute & FBCON_ATTRIBUTE_REVERSE) | ||
42 | c = ~c; | ||
43 | dst[i] = c; | ||
44 | } | ||
45 | } | ||
46 | |||
47 | |||
48 | static void ud_bmove(struct vc_data *vc, struct fb_info *info, int sy, | ||
49 | int sx, int dy, int dx, int height, int width) | ||
50 | { | ||
51 | struct fbcon_ops *ops = info->fbcon_par; | ||
52 | struct fb_copyarea area; | ||
53 | u32 vyres = GETVYRES(ops->p->scrollmode, info); | ||
54 | u32 vxres = GETVXRES(ops->p->scrollmode, info); | ||
55 | |||
56 | area.sy = vyres - ((sy + height) * vc->vc_font.height); | ||
57 | area.sx = vxres - ((sx + width) * vc->vc_font.width); | ||
58 | area.dy = vyres - ((dy + height) * vc->vc_font.height); | ||
59 | area.dx = vxres - ((dx + width) * vc->vc_font.width); | ||
60 | area.height = height * vc->vc_font.height; | ||
61 | area.width = width * vc->vc_font.width; | ||
62 | |||
63 | info->fbops->fb_copyarea(info, &area); | ||
64 | } | ||
65 | |||
66 | static void ud_clear(struct vc_data *vc, struct fb_info *info, int sy, | ||
67 | int sx, int height, int width) | ||
68 | { | ||
69 | struct fbcon_ops *ops = info->fbcon_par; | ||
70 | struct fb_fillrect region; | ||
71 | int bgshift = (vc->vc_hi_font_mask) ? 13 : 12; | ||
72 | u32 vyres = GETVYRES(ops->p->scrollmode, info); | ||
73 | u32 vxres = GETVXRES(ops->p->scrollmode, info); | ||
74 | |||
75 | region.color = attr_bgcol_ec(bgshift,vc,info); | ||
76 | region.dy = vyres - ((sy + height) * vc->vc_font.height); | ||
77 | region.dx = vxres - ((sx + width) * vc->vc_font.width); | ||
78 | region.width = width * vc->vc_font.width; | ||
79 | region.height = height * vc->vc_font.height; | ||
80 | region.rop = ROP_COPY; | ||
81 | |||
82 | info->fbops->fb_fillrect(info, ®ion); | ||
83 | } | ||
84 | |||
85 | static inline void ud_putcs_aligned(struct vc_data *vc, struct fb_info *info, | ||
86 | const u16 *s, u32 attr, u32 cnt, | ||
87 | u32 d_pitch, u32 s_pitch, u32 cellsize, | ||
88 | struct fb_image *image, u8 *buf, u8 *dst) | ||
89 | { | ||
90 | struct fbcon_ops *ops = info->fbcon_par; | ||
91 | u16 charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff; | ||
92 | u32 idx = vc->vc_font.width >> 3; | ||
93 | u8 *src; | ||
94 | |||
95 | while (cnt--) { | ||
96 | src = ops->fontbuffer + (scr_readw(s--) & charmask)*cellsize; | ||
97 | |||
98 | if (attr) { | ||
99 | ud_update_attr(buf, src, attr, vc); | ||
100 | src = buf; | ||
101 | } | ||
102 | |||
103 | if (likely(idx == 1)) | ||
104 | __fb_pad_aligned_buffer(dst, d_pitch, src, idx, | ||
105 | image->height); | ||
106 | else | ||
107 | fb_pad_aligned_buffer(dst, d_pitch, src, idx, | ||
108 | image->height); | ||
109 | |||
110 | dst += s_pitch; | ||
111 | } | ||
112 | |||
113 | info->fbops->fb_imageblit(info, image); | ||
114 | } | ||
115 | |||
116 | static inline void ud_putcs_unaligned(struct vc_data *vc, | ||
117 | struct fb_info *info, const u16 *s, | ||
118 | u32 attr, u32 cnt, u32 d_pitch, | ||
119 | u32 s_pitch, u32 cellsize, | ||
120 | struct fb_image *image, u8 *buf, | ||
121 | u8 *dst) | ||
122 | { | ||
123 | struct fbcon_ops *ops = info->fbcon_par; | ||
124 | u16 charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff; | ||
125 | u32 shift_low = 0, mod = vc->vc_font.width % 8; | ||
126 | u32 shift_high = 8; | ||
127 | u32 idx = vc->vc_font.width >> 3; | ||
128 | u8 *src; | ||
129 | |||
130 | while (cnt--) { | ||
131 | src = ops->fontbuffer + (scr_readw(s--) & charmask)*cellsize; | ||
132 | |||
133 | if (attr) { | ||
134 | ud_update_attr(buf, src, attr, vc); | ||
135 | src = buf; | ||
136 | } | ||
137 | |||
138 | fb_pad_unaligned_buffer(dst, d_pitch, src, idx, | ||
139 | image->height, shift_high, | ||
140 | shift_low, mod); | ||
141 | shift_low += mod; | ||
142 | dst += (shift_low >= 8) ? s_pitch : s_pitch - 1; | ||
143 | shift_low &= 7; | ||
144 | shift_high = 8 - shift_low; | ||
145 | } | ||
146 | |||
147 | info->fbops->fb_imageblit(info, image); | ||
148 | |||
149 | } | ||
150 | |||
151 | static void ud_putcs(struct vc_data *vc, struct fb_info *info, | ||
152 | const unsigned short *s, int count, int yy, int xx, | ||
153 | int fg, int bg) | ||
154 | { | ||
155 | struct fb_image image; | ||
156 | struct fbcon_ops *ops = info->fbcon_par; | ||
157 | u32 width = (vc->vc_font.width + 7)/8; | ||
158 | u32 cellsize = width * vc->vc_font.height; | ||
159 | u32 maxcnt = info->pixmap.size/cellsize; | ||
160 | u32 scan_align = info->pixmap.scan_align - 1; | ||
161 | u32 buf_align = info->pixmap.buf_align - 1; | ||
162 | u32 mod = vc->vc_font.width % 8, cnt, pitch, size; | ||
163 | u32 attribute = get_attribute(info, scr_readw(s)); | ||
164 | u8 *dst, *buf = NULL; | ||
165 | u32 vyres = GETVYRES(ops->p->scrollmode, info); | ||
166 | u32 vxres = GETVXRES(ops->p->scrollmode, info); | ||
167 | |||
168 | if (!ops->fontbuffer) | ||
169 | return; | ||
170 | |||
171 | image.fg_color = fg; | ||
172 | image.bg_color = bg; | ||
173 | image.dy = vyres - ((yy * vc->vc_font.height) + vc->vc_font.height); | ||
174 | image.dx = vxres - ((xx + count) * vc->vc_font.width); | ||
175 | image.height = vc->vc_font.height; | ||
176 | image.depth = 1; | ||
177 | |||
178 | if (attribute) { | ||
179 | buf = kmalloc(cellsize, GFP_KERNEL); | ||
180 | if (!buf) | ||
181 | return; | ||
182 | } | ||
183 | |||
184 | s += count - 1; | ||
185 | |||
186 | while (count) { | ||
187 | if (count > maxcnt) | ||
188 | cnt = maxcnt; | ||
189 | else | ||
190 | cnt = count; | ||
191 | |||
192 | image.width = vc->vc_font.width * cnt; | ||
193 | pitch = ((image.width + 7) >> 3) + scan_align; | ||
194 | pitch &= ~scan_align; | ||
195 | size = pitch * image.height + buf_align; | ||
196 | size &= ~buf_align; | ||
197 | dst = fb_get_buffer_offset(info, &info->pixmap, size); | ||
198 | image.data = dst; | ||
199 | |||
200 | if (!mod) | ||
201 | ud_putcs_aligned(vc, info, s, attribute, cnt, pitch, | ||
202 | width, cellsize, &image, buf, dst); | ||
203 | else | ||
204 | ud_putcs_unaligned(vc, info, s, attribute, cnt, pitch, | ||
205 | width, cellsize, &image, | ||
206 | buf, dst); | ||
207 | |||
208 | image.dx += image.width; | ||
209 | count -= cnt; | ||
210 | s -= cnt; | ||
211 | xx += cnt; | ||
212 | } | ||
213 | |||
214 | /* buf is always NULL except when in monochrome mode, so in this case | ||
215 | it's a gain to check buf against NULL even though kfree() handles | ||
216 | NULL pointers just fine */ | ||
217 | if (unlikely(buf)) | ||
218 | kfree(buf); | ||
219 | |||
220 | } | ||
221 | |||
222 | static void ud_clear_margins(struct vc_data *vc, struct fb_info *info, | ||
223 | int bottom_only) | ||
224 | { | ||
225 | unsigned int cw = vc->vc_font.width; | ||
226 | unsigned int ch = vc->vc_font.height; | ||
227 | unsigned int rw = info->var.xres - (vc->vc_cols*cw); | ||
228 | unsigned int bh = info->var.yres - (vc->vc_rows*ch); | ||
229 | struct fb_fillrect region; | ||
230 | |||
231 | region.color = 0; | ||
232 | region.rop = ROP_COPY; | ||
233 | |||
234 | if (rw && !bottom_only) { | ||
235 | region.dy = 0; | ||
236 | region.dx = info->var.xoffset; | ||
237 | region.width = rw; | ||
238 | region.height = info->var.yres_virtual; | ||
239 | info->fbops->fb_fillrect(info, ®ion); | ||
240 | } | ||
241 | |||
242 | if (bh) { | ||
243 | region.dy = info->var.yoffset; | ||
244 | region.dx = info->var.xoffset; | ||
245 | region.height = bh; | ||
246 | region.width = info->var.xres; | ||
247 | info->fbops->fb_fillrect(info, ®ion); | ||
248 | } | ||
249 | } | ||
250 | |||
251 | static void ud_cursor(struct vc_data *vc, struct fb_info *info, int mode, | ||
252 | int softback_lines, int fg, int bg) | ||
253 | { | ||
254 | struct fb_cursor cursor; | ||
255 | struct fbcon_ops *ops = info->fbcon_par; | ||
256 | unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff; | ||
257 | int w = (vc->vc_font.width + 7) >> 3, c; | ||
258 | int y = real_y(ops->p, vc->vc_y); | ||
259 | int attribute, use_sw = (vc->vc_cursor_type & 0x10); | ||
260 | int err = 1, dx, dy; | ||
261 | char *src; | ||
262 | u32 vyres = GETVYRES(ops->p->scrollmode, info); | ||
263 | u32 vxres = GETVXRES(ops->p->scrollmode, info); | ||
264 | |||
265 | if (!ops->fontbuffer) | ||
266 | return; | ||
267 | |||
268 | cursor.set = 0; | ||
269 | |||
270 | if (softback_lines) { | ||
271 | if (y + softback_lines >= vc->vc_rows) { | ||
272 | mode = CM_ERASE; | ||
273 | ops->cursor_flash = 0; | ||
274 | return; | ||
275 | } else | ||
276 | y += softback_lines; | ||
277 | } | ||
278 | |||
279 | c = scr_readw((u16 *) vc->vc_pos); | ||
280 | attribute = get_attribute(info, c); | ||
281 | src = ops->fontbuffer + ((c & charmask) * (w * vc->vc_font.height)); | ||
282 | |||
283 | if (ops->cursor_state.image.data != src || | ||
284 | ops->cursor_reset) { | ||
285 | ops->cursor_state.image.data = src; | ||
286 | cursor.set |= FB_CUR_SETIMAGE; | ||
287 | } | ||
288 | |||
289 | if (attribute) { | ||
290 | u8 *dst; | ||
291 | |||
292 | dst = kmalloc(w * vc->vc_font.height, GFP_ATOMIC); | ||
293 | if (!dst) | ||
294 | return; | ||
295 | kfree(ops->cursor_data); | ||
296 | ops->cursor_data = dst; | ||
297 | ud_update_attr(dst, src, attribute, vc); | ||
298 | src = dst; | ||
299 | } | ||
300 | |||
301 | if (ops->cursor_state.image.fg_color != fg || | ||
302 | ops->cursor_state.image.bg_color != bg || | ||
303 | ops->cursor_reset) { | ||
304 | ops->cursor_state.image.fg_color = fg; | ||
305 | ops->cursor_state.image.bg_color = bg; | ||
306 | cursor.set |= FB_CUR_SETCMAP; | ||
307 | } | ||
308 | |||
309 | if (ops->cursor_state.image.height != vc->vc_font.height || | ||
310 | ops->cursor_state.image.width != vc->vc_font.width || | ||
311 | ops->cursor_reset) { | ||
312 | ops->cursor_state.image.height = vc->vc_font.height; | ||
313 | ops->cursor_state.image.width = vc->vc_font.width; | ||
314 | cursor.set |= FB_CUR_SETSIZE; | ||
315 | } | ||
316 | |||
317 | dy = vyres - ((y * vc->vc_font.height) + vc->vc_font.height); | ||
318 | dx = vxres - ((vc->vc_x * vc->vc_font.width) + vc->vc_font.width); | ||
319 | |||
320 | if (ops->cursor_state.image.dx != dx || | ||
321 | ops->cursor_state.image.dy != dy || | ||
322 | ops->cursor_reset) { | ||
323 | ops->cursor_state.image.dx = dx; | ||
324 | ops->cursor_state.image.dy = dy; | ||
325 | cursor.set |= FB_CUR_SETPOS; | ||
326 | } | ||
327 | |||
328 | if (ops->cursor_state.hot.x || ops->cursor_state.hot.y || | ||
329 | ops->cursor_reset) { | ||
330 | ops->cursor_state.hot.x = cursor.hot.y = 0; | ||
331 | cursor.set |= FB_CUR_SETHOT; | ||
332 | } | ||
333 | |||
334 | if (cursor.set & FB_CUR_SETSIZE || | ||
335 | vc->vc_cursor_type != ops->p->cursor_shape || | ||
336 | ops->cursor_state.mask == NULL || | ||
337 | ops->cursor_reset) { | ||
338 | char *mask = kmalloc(w*vc->vc_font.height, GFP_ATOMIC); | ||
339 | int cur_height, size, i = 0; | ||
340 | u8 msk = 0xff; | ||
341 | |||
342 | if (!mask) | ||
343 | return; | ||
344 | |||
345 | kfree(ops->cursor_state.mask); | ||
346 | ops->cursor_state.mask = mask; | ||
347 | |||
348 | ops->p->cursor_shape = vc->vc_cursor_type; | ||
349 | cursor.set |= FB_CUR_SETSHAPE; | ||
350 | |||
351 | switch (ops->p->cursor_shape & CUR_HWMASK) { | ||
352 | case CUR_NONE: | ||
353 | cur_height = 0; | ||
354 | break; | ||
355 | case CUR_UNDERLINE: | ||
356 | cur_height = (vc->vc_font.height < 10) ? 1 : 2; | ||
357 | break; | ||
358 | case CUR_LOWER_THIRD: | ||
359 | cur_height = vc->vc_font.height/3; | ||
360 | break; | ||
361 | case CUR_LOWER_HALF: | ||
362 | cur_height = vc->vc_font.height >> 1; | ||
363 | break; | ||
364 | case CUR_TWO_THIRDS: | ||
365 | cur_height = (vc->vc_font.height << 1)/3; | ||
366 | break; | ||
367 | case CUR_BLOCK: | ||
368 | default: | ||
369 | cur_height = vc->vc_font.height; | ||
370 | break; | ||
371 | } | ||
372 | |||
373 | size = cur_height * w; | ||
374 | |||
375 | while (size--) | ||
376 | mask[i++] = msk; | ||
377 | |||
378 | size = (vc->vc_font.height - cur_height) * w; | ||
379 | |||
380 | while (size--) | ||
381 | mask[i++] = ~msk; | ||
382 | } | ||
383 | |||
384 | switch (mode) { | ||
385 | case CM_ERASE: | ||
386 | ops->cursor_state.enable = 0; | ||
387 | break; | ||
388 | case CM_DRAW: | ||
389 | case CM_MOVE: | ||
390 | default: | ||
391 | ops->cursor_state.enable = (use_sw) ? 0 : 1; | ||
392 | break; | ||
393 | } | ||
394 | |||
395 | cursor.image.data = src; | ||
396 | cursor.image.fg_color = ops->cursor_state.image.fg_color; | ||
397 | cursor.image.bg_color = ops->cursor_state.image.bg_color; | ||
398 | cursor.image.dx = ops->cursor_state.image.dx; | ||
399 | cursor.image.dy = ops->cursor_state.image.dy; | ||
400 | cursor.image.height = ops->cursor_state.image.height; | ||
401 | cursor.image.width = ops->cursor_state.image.width; | ||
402 | cursor.hot.x = ops->cursor_state.hot.x; | ||
403 | cursor.hot.y = ops->cursor_state.hot.y; | ||
404 | cursor.mask = ops->cursor_state.mask; | ||
405 | cursor.enable = ops->cursor_state.enable; | ||
406 | cursor.image.depth = 1; | ||
407 | cursor.rop = ROP_XOR; | ||
408 | |||
409 | if (info->fbops->fb_cursor) | ||
410 | err = info->fbops->fb_cursor(info, &cursor); | ||
411 | |||
412 | if (err) | ||
413 | soft_cursor(info, &cursor); | ||
414 | |||
415 | ops->cursor_reset = 0; | ||
416 | } | ||
417 | |||
418 | static int ud_update_start(struct fb_info *info) | ||
419 | { | ||
420 | struct fbcon_ops *ops = info->fbcon_par; | ||
421 | int xoffset, yoffset; | ||
422 | u32 vyres = GETVYRES(ops->p->scrollmode, info); | ||
423 | u32 vxres = GETVXRES(ops->p->scrollmode, info); | ||
424 | int err; | ||
425 | |||
426 | xoffset = vxres - info->var.xres - ops->var.xoffset; | ||
427 | yoffset = vyres - info->var.yres - ops->var.yoffset; | ||
428 | if (yoffset < 0) | ||
429 | yoffset += vyres; | ||
430 | ops->var.xoffset = xoffset; | ||
431 | ops->var.yoffset = yoffset; | ||
432 | err = fb_pan_display(info, &ops->var); | ||
433 | ops->var.xoffset = info->var.xoffset; | ||
434 | ops->var.yoffset = info->var.yoffset; | ||
435 | ops->var.vmode = info->var.vmode; | ||
436 | return err; | ||
437 | } | ||
438 | |||
439 | void fbcon_rotate_ud(struct fbcon_ops *ops) | ||
440 | { | ||
441 | ops->bmove = ud_bmove; | ||
442 | ops->clear = ud_clear; | ||
443 | ops->putcs = ud_putcs; | ||
444 | ops->clear_margins = ud_clear_margins; | ||
445 | ops->cursor = ud_cursor; | ||
446 | ops->update_start = ud_update_start; | ||
447 | } | ||
448 | EXPORT_SYMBOL(fbcon_rotate_ud); | ||
449 | |||
450 | MODULE_AUTHOR("Antonino Daplas <adaplas@pol.net>"); | ||
451 | MODULE_DESCRIPTION("Console Rotation (180 degrees) Support"); | ||
452 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/video/console/softcursor.c b/drivers/video/console/softcursor.c deleted file mode 100644 index 46dd8f5d2e9e..000000000000 --- a/drivers/video/console/softcursor.c +++ /dev/null | |||
@@ -1,82 +0,0 @@ | |||
1 | /* | ||
2 | * linux/drivers/video/console/softcursor.c | ||
3 | * | ||
4 | * Generic software cursor for frame buffer devices | ||
5 | * | ||
6 | * Created 14 Nov 2002 by James Simmons | ||
7 | * | ||
8 | * This file is subject to the terms and conditions of the GNU General | ||
9 | * Public License. See the file COPYING in the main directory of this | ||
10 | * archive for more details. | ||
11 | */ | ||
12 | |||
13 | #include <linux/module.h> | ||
14 | #include <linux/string.h> | ||
15 | #include <linux/fb.h> | ||
16 | #include <linux/slab.h> | ||
17 | |||
18 | #include <asm/io.h> | ||
19 | |||
20 | #include "fbcon.h" | ||
21 | |||
22 | int soft_cursor(struct fb_info *info, struct fb_cursor *cursor) | ||
23 | { | ||
24 | struct fbcon_ops *ops = info->fbcon_par; | ||
25 | unsigned int scan_align = info->pixmap.scan_align - 1; | ||
26 | unsigned int buf_align = info->pixmap.buf_align - 1; | ||
27 | unsigned int i, size, dsize, s_pitch, d_pitch; | ||
28 | struct fb_image *image; | ||
29 | u8 *src, *dst; | ||
30 | |||
31 | if (info->state != FBINFO_STATE_RUNNING) | ||
32 | return 0; | ||
33 | |||
34 | s_pitch = (cursor->image.width + 7) >> 3; | ||
35 | dsize = s_pitch * cursor->image.height; | ||
36 | |||
37 | if (dsize + sizeof(struct fb_image) != ops->cursor_size) { | ||
38 | kfree(ops->cursor_src); | ||
39 | ops->cursor_size = dsize + sizeof(struct fb_image); | ||
40 | |||
41 | ops->cursor_src = kmalloc(ops->cursor_size, GFP_ATOMIC); | ||
42 | if (!ops->cursor_src) { | ||
43 | ops->cursor_size = 0; | ||
44 | return -ENOMEM; | ||
45 | } | ||
46 | } | ||
47 | |||
48 | src = ops->cursor_src + sizeof(struct fb_image); | ||
49 | image = (struct fb_image *)ops->cursor_src; | ||
50 | *image = cursor->image; | ||
51 | d_pitch = (s_pitch + scan_align) & ~scan_align; | ||
52 | |||
53 | size = d_pitch * image->height + buf_align; | ||
54 | size &= ~buf_align; | ||
55 | dst = fb_get_buffer_offset(info, &info->pixmap, size); | ||
56 | |||
57 | if (cursor->enable) { | ||
58 | switch (cursor->rop) { | ||
59 | case ROP_XOR: | ||
60 | for (i = 0; i < dsize; i++) | ||
61 | src[i] = image->data[i] ^ cursor->mask[i]; | ||
62 | break; | ||
63 | case ROP_COPY: | ||
64 | default: | ||
65 | for (i = 0; i < dsize; i++) | ||
66 | src[i] = image->data[i] & cursor->mask[i]; | ||
67 | break; | ||
68 | } | ||
69 | } else | ||
70 | memcpy(src, image->data, dsize); | ||
71 | |||
72 | fb_pad_aligned_buffer(dst, d_pitch, src, s_pitch, image->height); | ||
73 | image->data = dst; | ||
74 | info->fbops->fb_imageblit(info, image); | ||
75 | return 0; | ||
76 | } | ||
77 | |||
78 | EXPORT_SYMBOL(soft_cursor); | ||
79 | |||
80 | MODULE_AUTHOR("James Simmons <jsimmons@users.sf.net>"); | ||
81 | MODULE_DESCRIPTION("Generic software cursor"); | ||
82 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/video/console/tileblit.c b/drivers/video/console/tileblit.c deleted file mode 100644 index 15e8e1a89c45..000000000000 --- a/drivers/video/console/tileblit.c +++ /dev/null | |||
@@ -1,159 +0,0 @@ | |||
1 | /* | ||
2 | * linux/drivers/video/console/tileblit.c -- Tile Blitting Operation | ||
3 | * | ||
4 | * Copyright (C) 2004 Antonino Daplas <adaplas @pol.net> | ||
5 | * | ||
6 | * This file is subject to the terms and conditions of the GNU General Public | ||
7 | * License. See the file COPYING in the main directory of this archive for | ||
8 | * more details. | ||
9 | */ | ||
10 | |||
11 | #include <linux/module.h> | ||
12 | #include <linux/string.h> | ||
13 | #include <linux/fb.h> | ||
14 | #include <linux/vt_kern.h> | ||
15 | #include <linux/console.h> | ||
16 | #include <asm/types.h> | ||
17 | #include "fbcon.h" | ||
18 | |||
19 | static void tile_bmove(struct vc_data *vc, struct fb_info *info, int sy, | ||
20 | int sx, int dy, int dx, int height, int width) | ||
21 | { | ||
22 | struct fb_tilearea area; | ||
23 | |||
24 | area.sx = sx; | ||
25 | area.sy = sy; | ||
26 | area.dx = dx; | ||
27 | area.dy = dy; | ||
28 | area.height = height; | ||
29 | area.width = width; | ||
30 | |||
31 | info->tileops->fb_tilecopy(info, &area); | ||
32 | } | ||
33 | |||
34 | static void tile_clear(struct vc_data *vc, struct fb_info *info, int sy, | ||
35 | int sx, int height, int width) | ||
36 | { | ||
37 | struct fb_tilerect rect; | ||
38 | int bgshift = (vc->vc_hi_font_mask) ? 13 : 12; | ||
39 | int fgshift = (vc->vc_hi_font_mask) ? 9 : 8; | ||
40 | |||
41 | rect.index = vc->vc_video_erase_char & | ||
42 | ((vc->vc_hi_font_mask) ? 0x1ff : 0xff); | ||
43 | rect.fg = attr_fgcol_ec(fgshift, vc, info); | ||
44 | rect.bg = attr_bgcol_ec(bgshift, vc, info); | ||
45 | rect.sx = sx; | ||
46 | rect.sy = sy; | ||
47 | rect.width = width; | ||
48 | rect.height = height; | ||
49 | rect.rop = ROP_COPY; | ||
50 | |||
51 | info->tileops->fb_tilefill(info, &rect); | ||
52 | } | ||
53 | |||
54 | static void tile_putcs(struct vc_data *vc, struct fb_info *info, | ||
55 | const unsigned short *s, int count, int yy, int xx, | ||
56 | int fg, int bg) | ||
57 | { | ||
58 | struct fb_tileblit blit; | ||
59 | unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff; | ||
60 | int size = sizeof(u32) * count, i; | ||
61 | |||
62 | blit.sx = xx; | ||
63 | blit.sy = yy; | ||
64 | blit.width = count; | ||
65 | blit.height = 1; | ||
66 | blit.fg = fg; | ||
67 | blit.bg = bg; | ||
68 | blit.length = count; | ||
69 | blit.indices = (u32 *) fb_get_buffer_offset(info, &info->pixmap, size); | ||
70 | for (i = 0; i < count; i++) | ||
71 | blit.indices[i] = (u32)(scr_readw(s++) & charmask); | ||
72 | |||
73 | info->tileops->fb_tileblit(info, &blit); | ||
74 | } | ||
75 | |||
76 | static void tile_clear_margins(struct vc_data *vc, struct fb_info *info, | ||
77 | int bottom_only) | ||
78 | { | ||
79 | return; | ||
80 | } | ||
81 | |||
82 | static void tile_cursor(struct vc_data *vc, struct fb_info *info, int mode, | ||
83 | int softback_lines, int fg, int bg) | ||
84 | { | ||
85 | struct fb_tilecursor cursor; | ||
86 | int use_sw = (vc->vc_cursor_type & 0x10); | ||
87 | |||
88 | cursor.sx = vc->vc_x; | ||
89 | cursor.sy = vc->vc_y; | ||
90 | cursor.mode = (mode == CM_ERASE || use_sw) ? 0 : 1; | ||
91 | cursor.fg = fg; | ||
92 | cursor.bg = bg; | ||
93 | |||
94 | switch (vc->vc_cursor_type & 0x0f) { | ||
95 | case CUR_NONE: | ||
96 | cursor.shape = FB_TILE_CURSOR_NONE; | ||
97 | break; | ||
98 | case CUR_UNDERLINE: | ||
99 | cursor.shape = FB_TILE_CURSOR_UNDERLINE; | ||
100 | break; | ||
101 | case CUR_LOWER_THIRD: | ||
102 | cursor.shape = FB_TILE_CURSOR_LOWER_THIRD; | ||
103 | break; | ||
104 | case CUR_LOWER_HALF: | ||
105 | cursor.shape = FB_TILE_CURSOR_LOWER_HALF; | ||
106 | break; | ||
107 | case CUR_TWO_THIRDS: | ||
108 | cursor.shape = FB_TILE_CURSOR_TWO_THIRDS; | ||
109 | break; | ||
110 | case CUR_BLOCK: | ||
111 | default: | ||
112 | cursor.shape = FB_TILE_CURSOR_BLOCK; | ||
113 | break; | ||
114 | } | ||
115 | |||
116 | info->tileops->fb_tilecursor(info, &cursor); | ||
117 | } | ||
118 | |||
119 | static int tile_update_start(struct fb_info *info) | ||
120 | { | ||
121 | struct fbcon_ops *ops = info->fbcon_par; | ||
122 | int err; | ||
123 | |||
124 | err = fb_pan_display(info, &ops->var); | ||
125 | ops->var.xoffset = info->var.xoffset; | ||
126 | ops->var.yoffset = info->var.yoffset; | ||
127 | ops->var.vmode = info->var.vmode; | ||
128 | return err; | ||
129 | } | ||
130 | |||
131 | void fbcon_set_tileops(struct vc_data *vc, struct fb_info *info) | ||
132 | { | ||
133 | struct fb_tilemap map; | ||
134 | struct fbcon_ops *ops = info->fbcon_par; | ||
135 | |||
136 | ops->bmove = tile_bmove; | ||
137 | ops->clear = tile_clear; | ||
138 | ops->putcs = tile_putcs; | ||
139 | ops->clear_margins = tile_clear_margins; | ||
140 | ops->cursor = tile_cursor; | ||
141 | ops->update_start = tile_update_start; | ||
142 | |||
143 | if (ops->p) { | ||
144 | map.width = vc->vc_font.width; | ||
145 | map.height = vc->vc_font.height; | ||
146 | map.depth = 1; | ||
147 | map.length = (ops->p->userfont) ? | ||
148 | FNTCHARCNT(ops->p->fontdata) : 256; | ||
149 | map.data = ops->p->fontdata; | ||
150 | info->tileops->fb_settile(info, &map); | ||
151 | } | ||
152 | } | ||
153 | |||
154 | EXPORT_SYMBOL(fbcon_set_tileops); | ||
155 | |||
156 | MODULE_AUTHOR("Antonino Daplas <adaplas@pol.net>"); | ||
157 | MODULE_DESCRIPTION("Tile Blitting Operation"); | ||
158 | MODULE_LICENSE("GPL"); | ||
159 | |||
diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index dc06cb6a15dc..445b1dc5d441 100644 --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c | |||
@@ -398,9 +398,8 @@ static const char *vgacon_startup(void) | |||
398 | #endif | 398 | #endif |
399 | } | 399 | } |
400 | 400 | ||
401 | /* boot_params.screen_info initialized? */ | 401 | /* boot_params.screen_info reasonably initialized? */ |
402 | if ((screen_info.orig_video_mode == 0) && | 402 | if ((screen_info.orig_video_lines == 0) || |
403 | (screen_info.orig_video_lines == 0) && | ||
404 | (screen_info.orig_video_cols == 0)) | 403 | (screen_info.orig_video_cols == 0)) |
405 | goto no_vga; | 404 | goto no_vga; |
406 | 405 | ||