1 /* 2 * linux/drivers/video/console/fbcon.h -- Low level frame buffer based console driver 3 * 4 * Copyright (C) 1997 Geert Uytterhoeven 5 * 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 8 * for more details. 9 */ 10 11 #ifndef _VIDEO_FBCON_H 12 #define _VIDEO_FBCON_H 13 14 #include <linux/types.h> 15 #include <linux/vt_buffer.h> 16 #include <linux/vt_kern.h> 17 #include <linux/workqueue.h> 18 19 #include <asm/io.h> 20 21 /* 22 * This is the interface between the low-level console driver and the 23 * low-level frame buffer device 24 */ 25 26 struct fbcon_display { 27 /* Filled in by the low-level console driver */ 28 const u_char *fontdata; 29 int userfont; /* != 0 if fontdata kmalloc()ed */ 30 #ifdef CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION 31 u_short scrollmode; /* Scroll Method, use fb_scrollmode() */ 32 #endif 33 u_short inverse; /* != 0 text black on white as default */ 34 short yscroll; /* Hardware scrolling */ 35 int vrows; /* number of virtual rows */ 36 int cursor_shape; 37 int con_rotate; 38 u32 xres_virtual; 39 u32 yres_virtual; 40 u32 height; 41 u32 width; 42 u32 bits_per_pixel; 43 u32 grayscale; 44 u32 nonstd; 45 u32 accel_flags; 46 u32 rotate; 47 struct fb_bitfield red; 48 struct fb_bitfield green; 49 struct fb_bitfield blue; 50 struct fb_bitfield transp; 51 const struct fb_videomode *mode; 52 }; 53 54 struct fbcon_bitops { 55 void (*bmove)(struct vc_data *vc, struct fb_info *info, int sy, 56 int sx, int dy, int dx, int height, int width); 57 void (*clear)(struct vc_data *vc, struct fb_info *info, int sy, 58 int sx, int height, int width, int fb, int bg); 59 void (*putcs)(struct vc_data *vc, struct fb_info *info, 60 const unsigned short *s, int count, int yy, int xx, 61 int fg, int bg); 62 void (*clear_margins)(struct vc_data *vc, struct fb_info *info, 63 int color, int bottom_only); 64 void (*cursor)(struct vc_data *vc, struct fb_info *info, 65 bool enable, int fg, int bg); 66 int (*update_start)(struct fb_info *info); 67 int (*rotate_font)(struct fb_info *info, struct vc_data *vc); 68 }; 69 70 struct fbcon_par { 71 struct fb_var_screeninfo var; /* copy of the current fb_var_screeninfo */ 72 struct delayed_work cursor_work; /* Cursor timer */ 73 struct fb_cursor cursor_state; 74 struct fbcon_display *p; 75 struct fb_info *info; 76 int currcon; /* Current VC. */ 77 int cur_blink_jiffies; 78 int cursor_flash; 79 int cursor_reset; 80 int blank_state; 81 int graphics; 82 int save_graphics; /* for debug enter/leave */ 83 bool initialized; 84 int rotate; 85 int cur_rotate; 86 char *cursor_data; 87 u8 *fontbuffer; 88 u8 *fontdata; 89 u8 *cursor_src; 90 u32 cursor_size; 91 u32 fd_size; 92 93 const struct fbcon_bitops *bitops; 94 }; 95 96 /* 97 * Attribute Decoding 98 */ 99 100 /* Color */ 101 #define attr_fgcol(fgshift,s) \ 102 (((s) >> (fgshift)) & 0x0f) 103 #define attr_bgcol(bgshift,s) \ 104 (((s) >> (bgshift)) & 0x0f) 105 106 /* Monochrome */ 107 #define attr_bold(s) \ 108 ((s) & 0x200) 109 #define attr_reverse(s) \ 110 ((s) & 0x800) 111 #define attr_underline(s) \ 112 ((s) & 0x400) 113 #define attr_blink(s) \ 114 ((s) & 0x8000) 115 116 static inline int mono_col(const struct fb_info *info) 117 { 118 __u32 max_len; 119 max_len = max(info->var.green.length, info->var.red.length); 120 max_len = max(info->var.blue.length, max_len); 121 return (~(0xfff << max_len)) & 0xff; 122 } 123 124 /* 125 * Scroll Method 126 */ 127 128 /* There are several methods fbcon can use to move text around the screen: 129 * 130 * Operation Pan Wrap 131 *--------------------------------------------- 132 * SCROLL_MOVE copyarea No No 133 * SCROLL_PAN_MOVE copyarea Yes No 134 * SCROLL_WRAP_MOVE copyarea No Yes 135 * SCROLL_REDRAW imageblit No No 136 * SCROLL_PAN_REDRAW imageblit Yes No 137 * SCROLL_WRAP_REDRAW imageblit No Yes 138 * 139 * (SCROLL_WRAP_REDRAW is not implemented yet) 140 * 141 * In general, fbcon will choose the best scrolling 142 * method based on the rule below: 143 * 144 * Pan/Wrap > accel imageblit > accel copyarea > 145 * soft imageblit > (soft copyarea) 146 * 147 * Exception to the rule: Pan + accel copyarea is 148 * preferred over Pan + accel imageblit. 149 * 150 * The above is typical for PCI/AGP cards. Unless 151 * overridden, fbcon will never use soft copyarea. 152 * 153 * If you need to override the above rule, set the 154 * appropriate flags in fb_info->flags. For example, 155 * to prefer copyarea over imageblit, set 156 * FBINFO_READS_FAST. 157 * 158 * Other notes: 159 * + use the hardware engine to move the text 160 * (hw-accelerated copyarea() and fillrect()) 161 * + use hardware-supported panning on a large virtual screen 162 * + amifb can not only pan, but also wrap the display by N lines 163 * (i.e. visible line i = physical line (i+N) % yres). 164 * + read what's already rendered on the screen and 165 * write it in a different place (this is cfb_copyarea()) 166 * + re-render the text to the screen 167 * 168 * Whether to use wrapping or panning can only be figured out at 169 * runtime (when we know whether our font height is a multiple 170 * of the pan/wrap step) 171 * 172 */ 173 174 #define SCROLL_MOVE 0x001 175 #define SCROLL_PAN_MOVE 0x002 176 #define SCROLL_WRAP_MOVE 0x003 177 #define SCROLL_REDRAW 0x004 178 #define SCROLL_PAN_REDRAW 0x005 179 180 static inline u_short fb_scrollmode(struct fbcon_display *fb) 181 { 182 #ifdef CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION 183 return fb->scrollmode; 184 #else 185 /* hardcoded to SCROLL_REDRAW if acceleration was disabled. */ 186 return SCROLL_REDRAW; 187 #endif 188 } 189 190 191 #ifdef CONFIG_FB_TILEBLITTING 192 extern void fbcon_set_tileops(struct vc_data *vc, struct fb_info *info); 193 #endif 194 extern void fbcon_set_bitops_ur(struct fbcon_par *par); 195 extern int soft_cursor(struct fb_info *info, struct fb_cursor *cursor); 196 197 #define FBCON_ATTRIBUTE_UNDERLINE 1 198 #define FBCON_ATTRIBUTE_REVERSE 2 199 #define FBCON_ATTRIBUTE_BOLD 4 200 201 static inline int real_y(struct fbcon_display *p, int ypos) 202 { 203 int rows = p->vrows; 204 205 ypos += p->yscroll; 206 return ypos < rows ? ypos : ypos - rows; 207 } 208 209 210 static inline int get_attribute(struct fb_info *info, u16 c) 211 { 212 int attribute = 0; 213 214 if (fb_get_color_depth(&info->var, &info->fix) == 1) { 215 if (attr_underline(c)) 216 attribute |= FBCON_ATTRIBUTE_UNDERLINE; 217 if (attr_reverse(c)) 218 attribute |= FBCON_ATTRIBUTE_REVERSE; 219 if (attr_bold(c)) 220 attribute |= FBCON_ATTRIBUTE_BOLD; 221 } 222 223 return attribute; 224 } 225 226 #define FBCON_SWAP(i,r,v) ({ \ 227 typeof(r) _r = (r); \ 228 typeof(v) _v = (v); \ 229 (void) (&_r == &_v); \ 230 (i == FB_ROTATE_UR || i == FB_ROTATE_UD) ? _r : _v; }) 231 232 #endif /* _VIDEO_FBCON_H */ 233