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/slab.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
)
23 struct fbcon_ops
*ops
= info
->fbcon_par
;
25 int s_cellsize
, d_cellsize
, i
;
29 if (vc
->vc_font
.data
== ops
->fontdata
&&
30 ops
->p
->con_rotate
== ops
->cur_rotate
)
33 src
= ops
->fontdata
= vc
->vc_font
.data
;
34 ops
->cur_rotate
= ops
->p
->con_rotate
;
35 len
= vc
->vc_font
.charcount
;
36 s_cellsize
= ((vc
->vc_font
.width
+ 7)/8) *
38 d_cellsize
= s_cellsize
;
40 if (ops
->rotate
== FB_ROTATE_CW
||
41 ops
->rotate
== FB_ROTATE_CCW
)
42 d_cellsize
= ((vc
->vc_font
.height
+ 7)/8) *
45 if (info
->fbops
->fb_sync
)
46 info
->fbops
->fb_sync(info
);
48 if (ops
->fd_size
< d_cellsize
* len
) {
49 dst
= kmalloc_array(len
, d_cellsize
, GFP_KERNEL
);
56 ops
->fd_size
= d_cellsize
* len
;
57 kfree(ops
->fontbuffer
);
58 ops
->fontbuffer
= dst
;
61 dst
= ops
->fontbuffer
;
62 memset(dst
, 0, ops
->fd_size
);
64 switch (ops
->rotate
) {
66 for (i
= len
; i
--; ) {
67 rotate_ud(src
, dst
, vc
->vc_font
.width
,
75 for (i
= len
; i
--; ) {
76 rotate_cw(src
, dst
, vc
->vc_font
.width
,
83 for (i
= len
; i
--; ) {
84 rotate_ccw(src
, dst
, vc
->vc_font
.width
,
96 void fbcon_set_rotate(struct fbcon_ops
*ops
)
98 ops
->rotate_font
= fbcon_rotate_font
;
100 switch(ops
->rotate
) {
102 fbcon_rotate_cw(ops
);
105 fbcon_rotate_ud(ops
);
108 fbcon_rotate_ccw(ops
);