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
11 #include <linux/module.h>
12 #include <linux/string.h>
14 #include <linux/vt_kern.h>
15 #include <linux/console.h>
16 #include <asm/types.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;
24 int s_cellsize, d_cellsize, i;
28 if (vc->vc_font.data == ops->fontdata &&
29 ops->p->con_rotate == ops->cur_rotate)
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) *
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) *
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);
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) {
65 for (i = len; i--; ) {
66 rotate_ud(src, dst, vc->vc_font.width,
74 for (i = len; i--; ) {
75 rotate_cw(src, dst, vc->vc_font.width,
82 for (i = len; i--; ) {
83 rotate_ccw(src, dst, vc->vc_font.width,
95 void fbcon_set_rotate(struct fbcon_ops *ops)
97 ops->rotate_font = fbcon_rotate_font;
101 fbcon_rotate_cw(ops);
104 fbcon_rotate_ud(ops);
107 fbcon_rotate_ccw(ops);
111 EXPORT_SYMBOL(fbcon_set_rotate);
113 MODULE_AUTHOR("Antonino Daplas <adaplas@pol.net>");
114 MODULE_DESCRIPTION("Console Rotation Support");
115 MODULE_LICENSE("GPL");