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/config.h>
12 #include <linux/module.h>
13 #include <linux/string.h>
15 #include <linux/vt_kern.h>
16 #include <linux/console.h>
17 #include <asm/types.h>
19 #include "fbcon_rotate.h"
21 static int fbcon_rotate_font(struct fb_info *info, struct vc_data *vc,
24 struct fbcon_ops *ops = info->fbcon_par;
26 int s_cellsize, d_cellsize, i;
30 if (vc->vc_font.data == ops->fontdata &&
31 p->con_rotate == ops->cur_rotate)
34 src = ops->fontdata = vc->vc_font.data;
35 ops->cur_rotate = p->con_rotate;
36 len = (!p->userfont) ? 256 : FNTCHARCNT(src);
37 s_cellsize = ((vc->vc_font.width + 7)/8) *
39 d_cellsize = s_cellsize;
41 if (ops->rotate == FB_ROTATE_CW ||
42 ops->rotate == FB_ROTATE_CCW)
43 d_cellsize = ((vc->vc_font.height + 7)/8) *
46 if (info->fbops->fb_sync)
47 info->fbops->fb_sync(info);
49 if (ops->fd_size < d_cellsize * len) {
50 dst = kmalloc(d_cellsize * len, GFP_KERNEL);
57 ops->fd_size = d_cellsize * len;
58 kfree(ops->fontbuffer);
59 ops->fontbuffer = dst;
62 dst = ops->fontbuffer;
63 memset(dst, 0, ops->fd_size);
65 switch (ops->rotate) {
67 for (i = len; i--; ) {
68 rotate_ud(src, dst, vc->vc_font.width,
76 for (i = len; i--; ) {
77 rotate_cw(src, dst, vc->vc_font.width,
84 for (i = len; i--; ) {
85 rotate_ccw(src, dst, vc->vc_font.width,
97 void fbcon_set_rotate(struct fbcon_ops *ops)
99 ops->rotate_font = fbcon_rotate_font;
101 switch(ops->rotate) {
103 fbcon_rotate_cw(ops);
106 fbcon_rotate_ud(ops);
109 fbcon_rotate_ccw(ops);
113 EXPORT_SYMBOL(fbcon_set_rotate);
115 MODULE_AUTHOR("Antonino Daplas <adaplas@pol.net>");
116 MODULE_DESCRIPTION("Console Rotation Support");
117 MODULE_LICENSE("GPL");