Full support for Ginger Console
[linux-ginger.git] / drivers / video / console / fbcon_rotate.c
blob00884e013f0f2713591bad338b978ac37713b5cf
1 /*
2 * linux/drivers/video/console/fbcon_rotate.c -- Software Rotation
4 * Copyright (C) 2005 Antonino Daplas <adaplas @pol.net>
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 */
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 #include "fbcon_rotate.h"
20 static int fbcon_rotate_font(struct fb_info *info, struct vc_data *vc)
22 struct fbcon_ops *ops = info->fbcon_par;
23 int len, err = 0;
24 int s_cellsize, d_cellsize, i;
25 const u8 *src;
26 u8 *dst;
28 if (vc->vc_font.data == ops->fontdata &&
29 ops->p->con_rotate == ops->cur_rotate)
30 goto finished;
32 src = ops->fontdata = vc->vc_font.data;
33 ops->cur_rotate = ops->p->con_rotate;
34 len = (!ops->p->userfont) ? 256 : FNTCHARCNT(src);
35 s_cellsize = ((vc->vc_font.width + 7)/8) *
36 vc->vc_font.height;
37 d_cellsize = s_cellsize;
39 if (ops->rotate == FB_ROTATE_CW ||
40 ops->rotate == FB_ROTATE_CCW)
41 d_cellsize = ((vc->vc_font.height + 7)/8) *
42 vc->vc_font.width;
44 if (info->fbops->fb_sync)
45 info->fbops->fb_sync(info);
47 if (ops->fd_size < d_cellsize * len) {
48 dst = kmalloc(d_cellsize * len, GFP_KERNEL);
50 if (dst == NULL) {
51 err = -ENOMEM;
52 goto finished;
55 ops->fd_size = d_cellsize * len;
56 kfree(ops->fontbuffer);
57 ops->fontbuffer = dst;
60 dst = ops->fontbuffer;
61 memset(dst, 0, ops->fd_size);
63 switch (ops->rotate) {
64 case FB_ROTATE_UD:
65 for (i = len; i--; ) {
66 rotate_ud(src, dst, vc->vc_font.width,
67 vc->vc_font.height);
69 src += s_cellsize;
70 dst += d_cellsize;
72 break;
73 case FB_ROTATE_CW:
74 for (i = len; i--; ) {
75 rotate_cw(src, dst, vc->vc_font.width,
76 vc->vc_font.height);
77 src += s_cellsize;
78 dst += d_cellsize;
80 break;
81 case FB_ROTATE_CCW:
82 for (i = len; i--; ) {
83 rotate_ccw(src, dst, vc->vc_font.width,
84 vc->vc_font.height);
85 src += s_cellsize;
86 dst += d_cellsize;
88 break;
91 finished:
92 return err;
95 void fbcon_set_rotate(struct fbcon_ops *ops)
97 ops->rotate_font = fbcon_rotate_font;
99 switch(ops->rotate) {
100 case FB_ROTATE_CW:
101 fbcon_rotate_cw(ops);
102 break;
103 case FB_ROTATE_UD:
104 fbcon_rotate_ud(ops);
105 break;
106 case FB_ROTATE_CCW:
107 fbcon_rotate_ccw(ops);
108 break;
111 EXPORT_SYMBOL(fbcon_set_rotate);
113 MODULE_AUTHOR("Antonino Daplas <adaplas@pol.net>");
114 MODULE_DESCRIPTION("Console Rotation Support");
115 MODULE_LICENSE("GPL");