2 * linux/drivers/video/console/fbcon.h -- Low level frame buffer based console driver
4 * Copyright (C) 1997 Geert Uytterhoeven
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
11 #ifndef _VIDEO_FBCON_H
12 #define _VIDEO_FBCON_H
14 #include <linux/types.h>
15 #include <linux/vt_buffer.h>
16 #include <linux/vt_kern.h>
20 #define FBCON_FLAGS_INIT 1
21 #define FBCON_FLAGS_CURSOR_TIMER 2
24 * This is the interface between the low-level console driver and the
25 * low-level frame buffer device
28 #ifdef CONFIG_BOOTSPLASH
29 struct splash_img_data {
31 int splash_color; /* transparent color */
32 int splash_fg_color; /* foreground color */
33 int splash_width; /* width of image */
34 int splash_height; /* height of image */
35 int splash_text_xo; /* text area origin of origin */
37 int splash_text_wi; /* text area size of jpeg*/
41 int splash_overpaintok; /* is it ok to overpaint boxes */
42 unsigned char *splash_boxes;
43 unsigned char *splash_jpeg; /* jpeg */
44 unsigned char *splash_sboxes;
45 unsigned char *splash_silentjpeg;
46 unsigned char *splash_palette; /* palette for 8-bit */
49 struct splash_pic_data {
51 unsigned char *splash_pic;
52 int splash_pic_stride;
57 struct splash_data *next;
58 struct splash_img_data *imgd;
59 struct splash_pic_data *pic;
60 int splash_state; /* show splash? */
62 int splash_dosilent; /* show silent jpeg */
64 int splash_vc_text_wi; /* text area size used*/
65 int splash_vc_text_he;
66 int splash_boxes_xoff;
67 int splash_boxes_yoff;
68 int splash_sboxes_xoff;
69 int splash_sboxes_yoff;
77 /* Filled in by the low-level console driver */
78 const u_char *fontdata;
79 int userfont; /* != 0 if fontdata kmalloc()ed */
80 u_short scrollmode; /* Scroll Method */
81 u_short inverse; /* != 0 text black on white as default */
82 short yscroll; /* Hardware scrolling */
83 int vrows; /* number of virtual rows */
95 struct fb_bitfield red;
96 struct fb_bitfield green;
97 struct fb_bitfield blue;
98 struct fb_bitfield transp;
99 const struct fb_videomode *mode;
103 void (*bmove)(struct vc_data *vc, struct fb_info *info, int sy,
104 int sx, int dy, int dx, int height, int width);
105 void (*clear)(struct vc_data *vc, struct fb_info *info, int sy,
106 int sx, int height, int width);
107 void (*putcs)(struct vc_data *vc, struct fb_info *info,
108 const unsigned short *s, int count, int yy, int xx,
110 void (*clear_margins)(struct vc_data *vc, struct fb_info *info,
112 void (*cursor)(struct vc_data *vc, struct fb_info *info, int mode,
113 int softback_lines, int fg, int bg);
114 int (*update_start)(struct fb_info *info);
115 int (*rotate_font)(struct fb_info *info, struct vc_data *vc);
116 struct fb_var_screeninfo var; /* copy of the current fb_var_screeninfo */
117 struct timer_list cursor_timer; /* Cursor timer */
118 struct fb_cursor cursor_state;
120 int currcon; /* Current VC. */
125 int save_graphics; /* for debug enter/leave */
141 #define attr_fgcol(fgshift,s) \
142 (((s) >> (fgshift)) & 0x0f)
143 #define attr_bgcol(bgshift,s) \
144 (((s) >> (bgshift)) & 0x0f)
147 #define attr_bold(s) \
149 #define attr_reverse(s) \
151 #define attr_underline(s) \
153 #define attr_blink(s) \
157 static inline int mono_col(const struct fb_info *info)
160 max_len = max(info->var.green.length, info->var.red.length);
161 max_len = max(info->var.blue.length, max_len);
162 return (~(0xfff << max_len)) & 0xff;
165 static inline int attr_col_ec(int shift, struct vc_data *vc,
166 struct fb_info *info, int is_fg)
176 if (vc->vc_can_do_color)
177 return is_fg ? attr_fgcol(shift,vc->vc_video_erase_char)
178 : attr_bgcol(shift,vc->vc_video_erase_char);
183 col = mono_col(info);
184 is_mono01 = info->fix.visual == FB_VISUAL_MONO01;
186 if (attr_reverse(vc->vc_video_erase_char)) {
187 fg = is_mono01 ? col : 0;
188 bg = is_mono01 ? 0 : col;
191 fg = is_mono01 ? 0 : col;
192 bg = is_mono01 ? col : 0;
195 return is_fg ? fg : bg;
198 #define attr_bgcol_ec(bgshift, vc, info) attr_col_ec(bgshift, vc, info, 0)
199 #define attr_fgcol_ec(fgshift, vc, info) attr_col_ec(fgshift, vc, info, 1)
202 #define REFCOUNT(fd) (((int *)(fd))[-1])
203 #define FNTSIZE(fd) (((int *)(fd))[-2])
204 #define FNTCHARCNT(fd) (((int *)(fd))[-3])
205 #define FNTSUM(fd) (((int *)(fd))[-4])
206 #define FONT_EXTRA_WORDS 4
212 /* There are several methods fbcon can use to move text around the screen:
215 *---------------------------------------------
216 * SCROLL_MOVE copyarea No No
217 * SCROLL_PAN_MOVE copyarea Yes No
218 * SCROLL_WRAP_MOVE copyarea No Yes
219 * SCROLL_REDRAW imageblit No No
220 * SCROLL_PAN_REDRAW imageblit Yes No
221 * SCROLL_WRAP_REDRAW imageblit No Yes
223 * (SCROLL_WRAP_REDRAW is not implemented yet)
225 * In general, fbcon will choose the best scrolling
226 * method based on the rule below:
228 * Pan/Wrap > accel imageblit > accel copyarea >
229 * soft imageblit > (soft copyarea)
231 * Exception to the rule: Pan + accel copyarea is
232 * preferred over Pan + accel imageblit.
234 * The above is typical for PCI/AGP cards. Unless
235 * overridden, fbcon will never use soft copyarea.
237 * If you need to override the above rule, set the
238 * appropriate flags in fb_info->flags. For example,
239 * to prefer copyarea over imageblit, set
243 * + use the hardware engine to move the text
244 * (hw-accelerated copyarea() and fillrect())
245 * + use hardware-supported panning on a large virtual screen
246 * + amifb can not only pan, but also wrap the display by N lines
247 * (i.e. visible line i = physical line (i+N) % yres).
248 * + read what's already rendered on the screen and
249 * write it in a different place (this is cfb_copyarea())
250 * + re-render the text to the screen
252 * Whether to use wrapping or panning can only be figured out at
253 * runtime (when we know whether our font height is a multiple
254 * of the pan/wrap step)
258 #define SCROLL_MOVE 0x001
259 #define SCROLL_PAN_MOVE 0x002
260 #define SCROLL_WRAP_MOVE 0x003
261 #define SCROLL_REDRAW 0x004
262 #define SCROLL_PAN_REDRAW 0x005
264 #ifdef CONFIG_FB_TILEBLITTING
265 extern void fbcon_set_tileops(struct vc_data *vc, struct fb_info *info);
267 extern void fbcon_set_bitops(struct fbcon_ops *ops);
268 extern int soft_cursor(struct fb_info *info, struct fb_cursor *cursor);
270 #define FBCON_ATTRIBUTE_UNDERLINE 1
271 #define FBCON_ATTRIBUTE_REVERSE 2
272 #define FBCON_ATTRIBUTE_BOLD 4
274 static inline int real_y(struct display *p, int ypos)
279 return ypos < rows ? ypos : ypos - rows;
283 static inline int get_attribute(struct fb_info *info, u16 c)
287 if (fb_get_color_depth(&info->var, &info->fix) == 1) {
288 if (attr_underline(c))
289 attribute |= FBCON_ATTRIBUTE_UNDERLINE;
291 attribute |= FBCON_ATTRIBUTE_REVERSE;
293 attribute |= FBCON_ATTRIBUTE_BOLD;
299 #define FBCON_SWAP(i,r,v) ({ \
300 typeof(r) _r = (r); \
301 typeof(v) _v = (v); \
302 (void) (&_r == &_v); \
303 (i == FB_ROTATE_UR || i == FB_ROTATE_UD) ? _r : _v; })
305 #ifdef CONFIG_FRAMEBUFFER_CONSOLE_ROTATION
306 extern void fbcon_set_rotate(struct fbcon_ops *ops);
308 #define fbcon_set_rotate(x) do {} while(0)
309 #endif /* CONFIG_FRAMEBUFFER_CONSOLE_ROTATION */
311 #endif /* _VIDEO_FBCON_H */