Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  *  linux/drivers/video/console/fbcon.h -- Low level frame buffer based console driver
0003  *
0004  *  Copyright (C) 1997 Geert Uytterhoeven
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 _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     *    This is the interface between the low-level console driver and the
0023     *    low-level frame buffer device
0024     */
0025 
0026 struct fbcon_display {
0027     /* Filled in by the low-level console driver */
0028     const u_char *fontdata;
0029     int userfont;                   /* != 0 if fontdata kmalloc()ed */
0030 #ifdef CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION
0031     u_short scrollmode;             /* Scroll Method, use fb_scrollmode() */
0032 #endif
0033     u_short inverse;                /* != 0 text black on white as default */
0034     short yscroll;                  /* Hardware scrolling */
0035     int vrows;                      /* number of virtual rows */
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;  /* copy of the current fb_var_screeninfo */
0069     struct delayed_work cursor_work; /* Cursor timer */
0070     struct fb_cursor cursor_state;
0071     struct fbcon_display *p;
0072     struct fb_info *info;
0073         int    currcon;                 /* Current VC. */
0074     int    cur_blink_jiffies;
0075     int    cursor_flash;
0076     int    cursor_reset;
0077     int    blank_state;
0078     int    graphics;
0079     int    save_graphics; /* for debug enter/leave */
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      *  Attribute Decoding
0092      */
0093 
0094 /* Color */
0095 #define attr_fgcol(fgshift,s)    \
0096     (((s) >> (fgshift)) & 0x0f)
0097 #define attr_bgcol(bgshift,s)    \
0098     (((s) >> (bgshift)) & 0x0f)
0099 
0100 /* Monochrome */
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      *  Scroll Method
0157      */
0158 
0159 /* There are several methods fbcon can use to move text around the screen:
0160  *
0161  *                     Operation   Pan    Wrap
0162  *---------------------------------------------
0163  * SCROLL_MOVE         copyarea    No     No
0164  * SCROLL_PAN_MOVE     copyarea    Yes    No
0165  * SCROLL_WRAP_MOVE    copyarea    No     Yes
0166  * SCROLL_REDRAW       imageblit   No     No
0167  * SCROLL_PAN_REDRAW   imageblit   Yes    No
0168  * SCROLL_WRAP_REDRAW  imageblit   No     Yes
0169  *
0170  * (SCROLL_WRAP_REDRAW is not implemented yet)
0171  *
0172  * In general, fbcon will choose the best scrolling
0173  * method based on the rule below:
0174  *
0175  * Pan/Wrap > accel imageblit > accel copyarea >
0176  * soft imageblit > (soft copyarea)
0177  *
0178  * Exception to the rule: Pan + accel copyarea is
0179  * preferred over Pan + accel imageblit.
0180  *
0181  * The above is typical for PCI/AGP cards. Unless
0182  * overridden, fbcon will never use soft copyarea.
0183  *
0184  * If you need to override the above rule, set the
0185  * appropriate flags in fb_info->flags.  For example,
0186  * to prefer copyarea over imageblit, set
0187  * FBINFO_READS_FAST.
0188  *
0189  * Other notes:
0190  * + use the hardware engine to move the text
0191  *    (hw-accelerated copyarea() and fillrect())
0192  * + use hardware-supported panning on a large virtual screen
0193  * + amifb can not only pan, but also wrap the display by N lines
0194  *    (i.e. visible line i = physical line (i+N) % yres).
0195  * + read what's already rendered on the screen and
0196  *     write it in a different place (this is cfb_copyarea())
0197  * + re-render the text to the screen
0198  *
0199  * Whether to use wrapping or panning can only be figured out at
0200  * runtime (when we know whether our font height is a multiple
0201  * of the pan/wrap step)
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     /* hardcoded to SCROLL_REDRAW if acceleration was disabled. */
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 /* CONFIG_FRAMEBUFFER_CONSOLE_ROTATION */
0268 
0269 #endif /* _VIDEO_FBCON_H */