Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  *  linux/drivers/video/console/fbcon_rotate.h -- Software Display Rotation
0003  *
0004  *  Copyright (C) 2005 Antonino Daplas <adaplas@pol.net>
0005  *
0006  *  This file is subject to the terms and conditions of the GNU General Public
0007  *  License.  See the file COPYING in the main directory of this archive
0008  *  for more details.
0009  */
0010 
0011 #ifndef _FBCON_ROTATE_H
0012 #define _FBCON_ROTATE_H
0013 
0014 #define GETVYRES(s,i) ({                           \
0015         (fb_scrollmode(s) == SCROLL_REDRAW || fb_scrollmode(s) == SCROLL_MOVE) ? \
0016         (i)->var.yres : (i)->var.yres_virtual; })
0017 
0018 #define GETVXRES(s,i) ({                           \
0019         (fb_scrollmode(s) == SCROLL_REDRAW || fb_scrollmode(s) == SCROLL_MOVE || !(i)->fix.xpanstep) ? \
0020         (i)->var.xres : (i)->var.xres_virtual; })
0021 
0022 
0023 static inline int pattern_test_bit(u32 x, u32 y, u32 pitch, const char *pat)
0024 {
0025     u32 tmp = (y * pitch) + x, index = tmp / 8,  bit = tmp % 8;
0026 
0027     pat +=index;
0028     return (*pat) & (0x80 >> bit);
0029 }
0030 
0031 static inline void pattern_set_bit(u32 x, u32 y, u32 pitch, char *pat)
0032 {
0033     u32 tmp = (y * pitch) + x, index = tmp / 8, bit = tmp % 8;
0034 
0035     pat += index;
0036 
0037     (*pat) |= 0x80 >> bit;
0038 }
0039 
0040 static inline void rotate_ud(const char *in, char *out, u32 width, u32 height)
0041 {
0042     int i, j;
0043     int shift = (8 - (width % 8)) & 7;
0044 
0045     width = (width + 7) & ~7;
0046 
0047     for (i = 0; i < height; i++) {
0048         for (j = 0; j < width - shift; j++) {
0049             if (pattern_test_bit(j, i, width, in))
0050                 pattern_set_bit(width - (1 + j + shift),
0051                         height - (1 + i),
0052                         width, out);
0053         }
0054 
0055     }
0056 }
0057 
0058 static inline void rotate_cw(const char *in, char *out, u32 width, u32 height)
0059 {
0060     int i, j, h = height, w = width;
0061     int shift = (8 - (height % 8)) & 7;
0062 
0063     width = (width + 7) & ~7;
0064     height = (height + 7) & ~7;
0065 
0066     for (i = 0; i < h; i++) {
0067         for (j = 0; j < w; j++) {
0068             if (pattern_test_bit(j, i, width, in))
0069                 pattern_set_bit(height - 1 - i - shift, j,
0070                         height, out);
0071 
0072         }
0073     }
0074 }
0075 
0076 static inline void rotate_ccw(const char *in, char *out, u32 width, u32 height)
0077 {
0078     int i, j, h = height, w = width;
0079     int shift = (8 - (width % 8)) & 7;
0080 
0081     width = (width + 7) & ~7;
0082     height = (height + 7) & ~7;
0083 
0084     for (i = 0; i < h; i++) {
0085         for (j = 0; j < w; j++) {
0086             if (pattern_test_bit(j, i, width, in))
0087                 pattern_set_bit(i, width - 1 - j - shift,
0088                         height, out);
0089         }
0090     }
0091 }
0092 
0093 extern void fbcon_rotate_cw(struct fbcon_ops *ops);
0094 extern void fbcon_rotate_ud(struct fbcon_ops *ops);
0095 extern void fbcon_rotate_ccw(struct fbcon_ops *ops);
0096 #endif