0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef _VIDEO_FBCON_H
0012 #define _VIDEO_FBCON_H
0013
0014 #include <linux/types.h>
0015 #include <linux/vt_buffer.h>
0016 #include <linux/vt_kern.h>
0017 #include <linux/workqueue.h>
0018
0019 #include <asm/io.h>
0020
0021
0022
0023
0024
0025
0026 struct fbcon_display {
0027
0028 const u_char *fontdata;
0029 int userfont;
0030 #ifdef CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION
0031 u_short scrollmode;
0032 #endif
0033 u_short inverse;
0034 short yscroll;
0035 int vrows;
0036 int cursor_shape;
0037 int con_rotate;
0038 u32 xres_virtual;
0039 u32 yres_virtual;
0040 u32 height;
0041 u32 width;
0042 u32 bits_per_pixel;
0043 u32 grayscale;
0044 u32 nonstd;
0045 u32 accel_flags;
0046 u32 rotate;
0047 struct fb_bitfield red;
0048 struct fb_bitfield green;
0049 struct fb_bitfield blue;
0050 struct fb_bitfield transp;
0051 const struct fb_videomode *mode;
0052 };
0053
0054 struct fbcon_ops {
0055 void (*bmove)(struct vc_data *vc, struct fb_info *info, int sy,
0056 int sx, int dy, int dx, int height, int width);
0057 void (*clear)(struct vc_data *vc, struct fb_info *info, int sy,
0058 int sx, int height, int width);
0059 void (*putcs)(struct vc_data *vc, struct fb_info *info,
0060 const unsigned short *s, int count, int yy, int xx,
0061 int fg, int bg);
0062 void (*clear_margins)(struct vc_data *vc, struct fb_info *info,
0063 int color, int bottom_only);
0064 void (*cursor)(struct vc_data *vc, struct fb_info *info, int mode,
0065 int fg, int bg);
0066 int (*update_start)(struct fb_info *info);
0067 int (*rotate_font)(struct fb_info *info, struct vc_data *vc);
0068 struct fb_var_screeninfo var;
0069 struct delayed_work cursor_work;
0070 struct fb_cursor cursor_state;
0071 struct fbcon_display *p;
0072 struct fb_info *info;
0073 int currcon;
0074 int cur_blink_jiffies;
0075 int cursor_flash;
0076 int cursor_reset;
0077 int blank_state;
0078 int graphics;
0079 int save_graphics;
0080 bool initialized;
0081 int rotate;
0082 int cur_rotate;
0083 char *cursor_data;
0084 u8 *fontbuffer;
0085 u8 *fontdata;
0086 u8 *cursor_src;
0087 u32 cursor_size;
0088 u32 fd_size;
0089 };
0090
0091
0092
0093
0094
0095 #define attr_fgcol(fgshift,s) \
0096 (((s) >> (fgshift)) & 0x0f)
0097 #define attr_bgcol(bgshift,s) \
0098 (((s) >> (bgshift)) & 0x0f)
0099
0100
0101 #define attr_bold(s) \
0102 ((s) & 0x200)
0103 #define attr_reverse(s) \
0104 ((s) & 0x800)
0105 #define attr_underline(s) \
0106 ((s) & 0x400)
0107 #define attr_blink(s) \
0108 ((s) & 0x8000)
0109
0110
0111 static inline int mono_col(const struct fb_info *info)
0112 {
0113 __u32 max_len;
0114 max_len = max(info->var.green.length, info->var.red.length);
0115 max_len = max(info->var.blue.length, max_len);
0116 return (~(0xfff << max_len)) & 0xff;
0117 }
0118
0119 static inline int attr_col_ec(int shift, struct vc_data *vc,
0120 struct fb_info *info, int is_fg)
0121 {
0122 int is_mono01;
0123 int col;
0124 int fg;
0125 int bg;
0126
0127 if (!vc)
0128 return 0;
0129
0130 if (vc->vc_can_do_color)
0131 return is_fg ? attr_fgcol(shift,vc->vc_video_erase_char)
0132 : attr_bgcol(shift,vc->vc_video_erase_char);
0133
0134 if (!info)
0135 return 0;
0136
0137 col = mono_col(info);
0138 is_mono01 = info->fix.visual == FB_VISUAL_MONO01;
0139
0140 if (attr_reverse(vc->vc_video_erase_char)) {
0141 fg = is_mono01 ? col : 0;
0142 bg = is_mono01 ? 0 : col;
0143 }
0144 else {
0145 fg = is_mono01 ? 0 : col;
0146 bg = is_mono01 ? col : 0;
0147 }
0148
0149 return is_fg ? fg : bg;
0150 }
0151
0152 #define attr_bgcol_ec(bgshift, vc, info) attr_col_ec(bgshift, vc, info, 0)
0153 #define attr_fgcol_ec(fgshift, vc, info) attr_col_ec(fgshift, vc, info, 1)
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205 #define SCROLL_MOVE 0x001
0206 #define SCROLL_PAN_MOVE 0x002
0207 #define SCROLL_WRAP_MOVE 0x003
0208 #define SCROLL_REDRAW 0x004
0209 #define SCROLL_PAN_REDRAW 0x005
0210
0211 static inline u_short fb_scrollmode(struct fbcon_display *fb)
0212 {
0213 #ifdef CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION
0214 return fb->scrollmode;
0215 #else
0216
0217 return SCROLL_REDRAW;
0218 #endif
0219 }
0220
0221
0222 #ifdef CONFIG_FB_TILEBLITTING
0223 extern void fbcon_set_tileops(struct vc_data *vc, struct fb_info *info);
0224 #endif
0225 extern void fbcon_set_bitops(struct fbcon_ops *ops);
0226 extern int soft_cursor(struct fb_info *info, struct fb_cursor *cursor);
0227
0228 #define FBCON_ATTRIBUTE_UNDERLINE 1
0229 #define FBCON_ATTRIBUTE_REVERSE 2
0230 #define FBCON_ATTRIBUTE_BOLD 4
0231
0232 static inline int real_y(struct fbcon_display *p, int ypos)
0233 {
0234 int rows = p->vrows;
0235
0236 ypos += p->yscroll;
0237 return ypos < rows ? ypos : ypos - rows;
0238 }
0239
0240
0241 static inline int get_attribute(struct fb_info *info, u16 c)
0242 {
0243 int attribute = 0;
0244
0245 if (fb_get_color_depth(&info->var, &info->fix) == 1) {
0246 if (attr_underline(c))
0247 attribute |= FBCON_ATTRIBUTE_UNDERLINE;
0248 if (attr_reverse(c))
0249 attribute |= FBCON_ATTRIBUTE_REVERSE;
0250 if (attr_bold(c))
0251 attribute |= FBCON_ATTRIBUTE_BOLD;
0252 }
0253
0254 return attribute;
0255 }
0256
0257 #define FBCON_SWAP(i,r,v) ({ \
0258 typeof(r) _r = (r); \
0259 typeof(v) _v = (v); \
0260 (void) (&_r == &_v); \
0261 (i == FB_ROTATE_UR || i == FB_ROTATE_UD) ? _r : _v; })
0262
0263 #ifdef CONFIG_FRAMEBUFFER_CONSOLE_ROTATION
0264 extern void fbcon_set_rotate(struct fbcon_ops *ops);
0265 #else
0266 #define fbcon_set_rotate(x) do {} while(0)
0267 #endif
0268
0269 #endif