| 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/compiler_types.h>
|
| 15 | #include <linux/font.h>
|
| 16 | #include <linux/types.h>
|
| 17 | #include <linux/vt_buffer.h>
|
| 18 | #include <linux/vt_kern.h>
|
| 19 | #include <linux/workqueue.h>
|
| 20 |
|
| 21 | #include <asm/io.h>
|
| 22 |
|
| 23 | struct fb_blit_caps;
|
| 24 | struct fb_info;
|
| 25 | struct fb_var_screeninfo;
|
| 26 | struct fb_videomode;
|
| 27 |
|
| 28 | |
| 29 | * This is the interface between the low-level console driver and the
|
| 30 | * low-level frame buffer device
|
| 31 |
|
| 32 |
|
| 33 | struct fbcon_display {
|
| 34 |
|
| 35 | font_data_t *fontdata;
|
| 36 | #ifdef CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION
|
| 37 | u_short scrollmode;
|
| 38 | #endif
|
| 39 | short yscroll;
|
| 40 | int vrows;
|
| 41 | int cursor_shape;
|
| 42 | int con_rotate;
|
| 43 | u32 xres_virtual;
|
| 44 | u32 yres_virtual;
|
| 45 | u32 height;
|
| 46 | u32 width;
|
| 47 | u32 bits_per_pixel;
|
| 48 | u32 grayscale;
|
| 49 | u32 nonstd;
|
| 50 | u32 accel_flags;
|
| 51 | u32 rotate;
|
| 52 | struct fb_bitfield red;
|
| 53 | struct fb_bitfield green;
|
| 54 | struct fb_bitfield blue;
|
| 55 | struct fb_bitfield transp;
|
| 56 | const struct fb_videomode *mode;
|
| 57 | };
|
| 58 |
|
| 59 | struct fbcon_bitops {
|
| 60 | void (*bmove)(struct vc_data *vc, struct fb_info *info, int sy,
|
| 61 | int sx, int dy, int dx, int height, int width);
|
| 62 | void (*clear)(struct vc_data *vc, struct fb_info *info, int sy,
|
| 63 | int sx, int height, int width, int fb, int bg);
|
| 64 | void (*putcs)(struct vc_data *vc, struct fb_info *info,
|
| 65 | const unsigned short *s, int count, int yy, int xx,
|
| 66 | int fg, int bg);
|
| 67 | void (*clear_margins)(struct vc_data *vc, struct fb_info *info,
|
| 68 | int color, int bottom_only);
|
| 69 | void (*cursor)(struct vc_data *vc, struct fb_info *info,
|
| 70 | bool enable, int fg, int bg);
|
| 71 | int (*update_start)(struct fb_info *info);
|
| 72 | int (*rotate_font)(struct fb_info *info, struct vc_data *vc);
|
| 73 | };
|
| 74 |
|
| 75 | struct fbcon_par {
|
| 76 | struct fb_var_screeninfo var;
|
| 77 | struct delayed_work cursor_work;
|
| 78 | struct fb_cursor cursor_state;
|
| 79 | struct fbcon_display *p;
|
| 80 | struct fb_info *info;
|
| 81 | int currcon;
|
| 82 | int cur_blink_jiffies;
|
| 83 | int cursor_flash;
|
| 84 | int cursor_reset;
|
| 85 | int blank_state;
|
| 86 | int graphics;
|
| 87 | bool initialized;
|
| 88 | int rotate;
|
| 89 | char *cursor_data;
|
| 90 | #ifdef CONFIG_FRAMEBUFFER_CONSOLE_ROTATION
|
| 91 | struct {
|
| 92 | font_data_t *fontdata;
|
| 93 | u8 *buf;
|
| 94 | size_t bufsize;
|
| 95 | int buf_rotate;
|
| 96 | } rotated;
|
| 97 | #endif
|
| 98 | u8 *cursor_src;
|
| 99 | u32 cursor_size;
|
| 100 |
|
| 101 | const struct fbcon_bitops *bitops;
|
| 102 | };
|
| 103 |
|
| 104 | |
| 105 | * Attribute Decoding
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 | #define attr_fgcol(fgshift,s) \
|
| 110 | (((s) >> (fgshift)) & 0x0f)
|
| 111 | #define attr_bgcol(bgshift,s) \
|
| 112 | (((s) >> (bgshift)) & 0x0f)
|
| 113 |
|
| 114 |
|
| 115 | #define attr_bold(s) \
|
| 116 | ((s) & 0x200)
|
| 117 | #define attr_reverse(s) \
|
| 118 | ((s) & 0x800)
|
| 119 | #define attr_underline(s) \
|
| 120 | ((s) & 0x400)
|
| 121 | #define attr_blink(s) \
|
| 122 | ((s) & 0x8000)
|
| 123 |
|
| 124 | static inline int mono_col(const struct fb_info *info)
|
| 125 | {
|
| 126 | __u32 max_len;
|
| 127 | max_len = max(info->var.green.length, info->var.red.length);
|
| 128 | max_len = max(info->var.blue.length, max_len);
|
| 129 | return (~(0xfff << max_len)) & 0xff;
|
| 130 | }
|
| 131 |
|
| 132 | |
| 133 | * Scroll Method
|
| 134 |
|
| 135 |
|
| 136 | |
| 137 | *
|
| 138 | * Operation Pan Wrap
|
| 139 | *---------------------------------------------
|
| 140 | * SCROLL_MOVE copyarea No No
|
| 141 | * SCROLL_PAN_MOVE copyarea Yes No
|
| 142 | * SCROLL_WRAP_MOVE copyarea No Yes
|
| 143 | * SCROLL_REDRAW imageblit No No
|
| 144 | * SCROLL_PAN_REDRAW imageblit Yes No
|
| 145 | * SCROLL_WRAP_REDRAW imageblit No Yes
|
| 146 | *
|
| 147 | * (SCROLL_WRAP_REDRAW is not implemented yet)
|
| 148 | *
|
| 149 | * In general, fbcon will choose the best scrolling
|
| 150 | * method based on the rule below:
|
| 151 | *
|
| 152 | * Pan/Wrap > accel imageblit > accel copyarea >
|
| 153 | * soft imageblit > (soft copyarea)
|
| 154 | *
|
| 155 | * Exception to the rule: Pan + accel copyarea is
|
| 156 | * preferred over Pan + accel imageblit.
|
| 157 | *
|
| 158 | * The above is typical for PCI/AGP cards. Unless
|
| 159 | * overridden, fbcon will never use soft copyarea.
|
| 160 | *
|
| 161 | * If you need to override the above rule, set the
|
| 162 | * appropriate flags in fb_info->flags. For example,
|
| 163 | * to prefer copyarea over imageblit, set
|
| 164 | * FBINFO_READS_FAST.
|
| 165 | *
|
| 166 | * Other notes:
|
| 167 | * + use the hardware engine to move the text
|
| 168 | * (hw-accelerated copyarea() and fillrect())
|
| 169 | * + use hardware-supported panning on a large virtual screen
|
| 170 | * + amifb can not only pan, but also wrap the display by N lines
|
| 171 | * (i.e. visible line i = physical line (i+N) % yres).
|
| 172 | * + read what's already rendered on the screen and
|
| 173 | * write it in a different place (this is cfb_copyarea())
|
| 174 | * + re-render the text to the screen
|
| 175 | *
|
| 176 | * Whether to use wrapping or panning can only be figured out at
|
| 177 | * runtime (when we know whether our font height is a multiple
|
| 178 | * of the pan/wrap step)
|
| 179 | *
|
| 180 |
|
| 181 |
|
| 182 | #define SCROLL_MOVE 0x001
|
| 183 | #define SCROLL_PAN_MOVE 0x002
|
| 184 | #define SCROLL_WRAP_MOVE 0x003
|
| 185 | #define SCROLL_REDRAW 0x004
|
| 186 | #define SCROLL_PAN_REDRAW 0x005
|
| 187 |
|
| 188 | static inline u_short fb_scrollmode(struct fbcon_display *fb)
|
| 189 | {
|
| 190 | #ifdef CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION
|
| 191 | return fb->scrollmode;
|
| 192 | #else
|
| 193 |
|
| 194 | return SCROLL_REDRAW;
|
| 195 | #endif
|
| 196 | }
|
| 197 |
|
| 198 |
|
| 199 | #ifdef CONFIG_FB_TILEBLITTING
|
| 200 | extern void fbcon_set_tileops(struct vc_data *vc, struct fb_info *info);
|
| 201 | #endif
|
| 202 | extern void fbcon_set_bitops_ur(struct fbcon_par *par);
|
| 203 | extern int soft_cursor(struct fb_info *info, struct fb_cursor *cursor);
|
| 204 |
|
| 205 | void fbcon_fill_cursor_mask(struct fbcon_par *par, struct vc_data *vc, unsigned char *mask);
|
| 206 |
|
| 207 | #define FBCON_ATTRIBUTE_UNDERLINE 1
|
| 208 | #define FBCON_ATTRIBUTE_REVERSE 2
|
| 209 | #define FBCON_ATTRIBUTE_BOLD 4
|
| 210 |
|
| 211 | static inline int real_y(struct fbcon_display *p, int ypos)
|
| 212 | {
|
| 213 | int rows = p->vrows;
|
| 214 |
|
| 215 | ypos += p->yscroll;
|
| 216 | return ypos < rows ? ypos : ypos - rows;
|
| 217 | }
|
| 218 |
|
| 219 |
|
| 220 | static inline int get_attribute(struct fb_info *info, u16 c)
|
| 221 | {
|
| 222 | int attribute = 0;
|
| 223 |
|
| 224 | if (fb_get_color_depth(&info->var, &info->fix) == 1) {
|
| 225 | if (attr_underline(c))
|
| 226 | attribute |= FBCON_ATTRIBUTE_UNDERLINE;
|
| 227 | if (attr_reverse(c))
|
| 228 | attribute |= FBCON_ATTRIBUTE_REVERSE;
|
| 229 | if (attr_bold(c))
|
| 230 | attribute |= FBCON_ATTRIBUTE_BOLD;
|
| 231 | }
|
| 232 |
|
| 233 | return attribute;
|
| 234 | }
|
| 235 |
|
| 236 | #define FBCON_SWAP(i,r,v) ({ \
|
| 237 | typeof(r) _r = (r); \
|
| 238 | typeof(v) _v = (v); \
|
| 239 | (void) (&_r == &_v); \
|
| 240 | (i == FB_ROTATE_UR || i == FB_ROTATE_UD) ? _r : _v; })
|
| 241 |
|
| 242 | #ifdef CONFIG_FRAMEBUFFER_CONSOLE
|
| 243 | void __init fb_console_init(void);
|
| 244 | void __exit fb_console_exit(void);
|
| 245 | int fbcon_fb_registered(struct fb_info *info);
|
| 246 | void fbcon_fb_unregistered(struct fb_info *info);
|
| 247 | void fbcon_fb_unbind(struct fb_info *info);
|
| 248 | void fbcon_suspended(struct fb_info *info);
|
| 249 | void fbcon_resumed(struct fb_info *info);
|
| 250 | int fbcon_mode_deleted(struct fb_info *info,
|
| 251 | struct fb_videomode *mode);
|
| 252 | void fbcon_delete_modelist(struct list_head *head);
|
| 253 | void fbcon_new_modelist(struct fb_info *info);
|
| 254 | void fbcon_get_requirement(struct fb_info *info,
|
| 255 | struct fb_blit_caps *caps);
|
| 256 | void fbcon_fb_blanked(struct fb_info *info, int blank);
|
| 257 | int fbcon_modechange_possible(struct fb_info *info,
|
| 258 | struct fb_var_screeninfo *var);
|
| 259 | void fbcon_update_vcs(struct fb_info *info, bool all);
|
| 260 | void fbcon_remap_all(struct fb_info *info);
|
| 261 | int fbcon_set_con2fb_map_ioctl(void __user *argp);
|
| 262 | int fbcon_get_con2fb_map_ioctl(void __user *argp);
|
| 263 | #else
|
| 264 | static inline void fb_console_init(void) {}
|
| 265 | static inline void fb_console_exit(void) {}
|
| 266 | static inline int fbcon_fb_registered(struct fb_info *info) { return 0; }
|
| 267 | static inline void fbcon_fb_unregistered(struct fb_info *info) {}
|
| 268 | static inline void fbcon_fb_unbind(struct fb_info *info) {}
|
| 269 | static inline void fbcon_suspended(struct fb_info *info) {}
|
| 270 | static inline void fbcon_resumed(struct fb_info *info) {}
|
| 271 | static inline int fbcon_mode_deleted(struct fb_info *info,
|
| 272 | struct fb_videomode *mode) { return 0; }
|
| 273 | static inline void fbcon_delete_modelist(struct list_head *head) {}
|
| 274 | static inline void fbcon_new_modelist(struct fb_info *info) {}
|
| 275 | static inline void fbcon_get_requirement(struct fb_info *info,
|
| 276 | struct fb_blit_caps *caps) {}
|
| 277 | static inline void fbcon_fb_blanked(struct fb_info *info, int blank) {}
|
| 278 | static inline int fbcon_modechange_possible(struct fb_info *info,
|
| 279 | struct fb_var_screeninfo *var) { return 0; }
|
| 280 | static inline void fbcon_update_vcs(struct fb_info *info, bool all) {}
|
| 281 | static inline void fbcon_remap_all(struct fb_info *info) {}
|
| 282 | static inline int fbcon_set_con2fb_map_ioctl(void __user *argp) { return 0; }
|
| 283 | static inline int fbcon_get_con2fb_map_ioctl(void __user *argp) { return 0; }
|
| 284 | #endif
|
| 285 |
|
| 286 | #endif
|