aboutsummaryrefslogtreecommitdiff
path: root/drivers/video/console/fbcon_rotate.h
diff options
context:
space:
mode:
authorAntonino A. Daplas <adaplas@gmail.com>2005-11-08 21:39:11 -0800
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-09 07:56:34 -0800
commit6cc50e1c5b57180fd37a31282000f43859b0fe73 (patch)
tree109d99a52b1533358445233dd16a5dfadcb618ce /drivers/video/console/fbcon_rotate.h
parent9c44e5f6c211a9b7313ded897f3135ef7d9ad3e2 (diff)
[PATCH] fbcon: Console Rotation - Add support to rotate font bitmap
Add support to rotate the font bitmap. To save on processing time, the entire fontdata will be rotated on a console switch, then stored in a buffer private to fbcon. To further save on processing, the fontdata will only be rotated if the font has changed or if the angle of rotation has changed. Only a single copy of the rotated fontdata will be kept. Signed-off-by: Antonino Daplas <adaplas@pol.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/video/console/fbcon_rotate.h')
-rw-r--r--drivers/video/console/fbcon_rotate.h102
1 files changed, 102 insertions, 0 deletions
diff --git a/drivers/video/console/fbcon_rotate.h b/drivers/video/console/fbcon_rotate.h
new file mode 100644
index 00000000000..6cc27d8e5d4
--- /dev/null
+++ b/drivers/video/console/fbcon_rotate.h
@@ -0,0 +1,102 @@
+/*
+ * linux/drivers/video/console/fbcon_rotate.h -- Software Display Rotation
+ *
+ * Copyright (C) 2005 Antonino Daplas <adaplas@pol.net>
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file COPYING in the main directory of this archive
+ * for more details.
+ */
+
+#ifndef _FBCON_ROTATE_H
+#define _FBCON_ROTATE_H
+
+#define FNTCHARCNT(fd) (((int *)(fd))[-3])
+
+#define GETVYRES(s,i) ({ \
+ (s == SCROLL_REDRAW || s == SCROLL_MOVE) ? \
+ (i)->var.yres : (i)->var.yres_virtual; })
+
+#define GETVXRES(s,i) ({ \
+ (s == SCROLL_REDRAW || s == SCROLL_MOVE || !(i)->fix.xpanstep) ? \
+ (i)->var.xres : (i)->var.xres_virtual; })
+
+/*
+ * The bitmap is always big endian
+ */
+#if defined(__LITTLE_ENDIAN)
+#define FBCON_BIT(b) (7 - (b))
+#else
+#define FBCON_BIT(b) (b)
+#endif
+
+static inline int pattern_test_bit(u32 x, u32 y, u32 pitch, const char *pat)
+{
+ u32 tmp = (y * pitch) + x, index = tmp / 8, bit = tmp % 8;
+
+ pat +=index;
+ return (test_bit(FBCON_BIT(bit), (void *)pat));
+}
+
+static inline void pattern_set_bit(u32 x, u32 y, u32 pitch, char *pat)
+{
+ u32 tmp = (y * pitch) + x, index = tmp / 8, bit = tmp % 8;
+
+ pat += index;
+ set_bit(FBCON_BIT(bit), (void *)pat);
+}
+
+static inline void rotate_ud(const char *in, char *out, u32 width, u32 height)
+{
+ int i, j;
+ int shift = width % 8;
+
+ width = (width + 7) & ~7;
+
+ for (i = 0; i < height; i++) {
+ for (j = 0; j < width; j++) {
+ if (pattern_test_bit(j, i, width, in))
+ pattern_set_bit(width - (1 + j + shift),
+ height - (1 + i),
+ width, out);
+ }
+
+ }
+}
+
+static inline void rotate_cw(const char *in, char *out, u32 width, u32 height)
+{
+ int i, j, h = height, w = width;
+ int shift = (8 - (height % 8)) & 7;
+
+ width = (width + 7) & ~7;
+ height = (height + 7) & ~7;
+
+ for (i = 0; i < h; i++) {
+ for (j = 0; j < w; j++) {
+ if (pattern_test_bit(j, i, width, in))
+ pattern_set_bit(height - 1 - i - shift, j,
+ height, out);
+
+ }
+ }
+}
+
+static inline void rotate_ccw(const char *in, char *out, u32 width, u32 height)
+{
+ int i, j, h = height, w = width;
+ int shift = width % 8;
+
+ width = (width + 7) & ~7;
+ height = (height + 7) & ~7;
+
+ for (i = 0; i < h; i++) {
+ for (j = 0; j < w; j++) {
+ if (pattern_test_bit(j, i, width, in))
+ pattern_set_bit(i, width - 1 - j - shift,
+ height, out);
+ }
+ }
+}
+
+#endif