projects/linux·blob master · refs

286 lines · 8.8 KiB

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
23struct fb_blit_caps;
24struct fb_info;
25struct fb_var_screeninfo;
26struct 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
33struct fbcon_display {
34 /* Filled in by the low-level console driver */
35 font_data_t *fontdata;
36#ifdef CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION
37 u_short scrollmode; /* Scroll Method, use fb_scrollmode() */
38#endif
39 short yscroll; /* Hardware scrolling */
40 int vrows; /* number of virtual rows */
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
59struct 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
75struct fbcon_par {
76 struct fb_var_screeninfo var; /* copy of the current fb_var_screeninfo */
77 struct delayed_work cursor_work; /* Cursor timer */
78 struct fb_cursor cursor_state;
79 struct fbcon_display *p;
80 struct fb_info *info;
81 int currcon; /* Current VC. */
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; /* source font */
93 u8 *buf; /* rotated glyphs */
94 size_t bufsize;
95 int buf_rotate; /* rotation of buf */
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/* Color */
109#define attr_fgcol(fgshift,s) \
110 (((s) >> (fgshift)) & 0x0f)
111#define attr_bgcol(bgshift,s) \
112 (((s) >> (bgshift)) & 0x0f)
113
114/* Monochrome */
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
124static 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/* There are several methods fbcon can use to move text around the screen:
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
188static inline u_short fb_scrollmode(struct fbcon_display *fb)
189{
190#ifdef CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION
191 return fb->scrollmode;
192#else
193 /* hardcoded to SCROLL_REDRAW if acceleration was disabled. */
194 return SCROLL_REDRAW;
195#endif
196}
197
198
199#ifdef CONFIG_FB_TILEBLITTING
200extern void fbcon_set_tileops(struct vc_data *vc, struct fb_info *info);
201#endif
202extern void fbcon_set_bitops_ur(struct fbcon_par *par);
203extern int soft_cursor(struct fb_info *info, struct fb_cursor *cursor);
204
205void 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
211static 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
220static 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
243void __init fb_console_init(void);
244void __exit fb_console_exit(void);
245int fbcon_fb_registered(struct fb_info *info);
246void fbcon_fb_unregistered(struct fb_info *info);
247void fbcon_fb_unbind(struct fb_info *info);
248void fbcon_suspended(struct fb_info *info);
249void fbcon_resumed(struct fb_info *info);
250int fbcon_mode_deleted(struct fb_info *info,
251 struct fb_videomode *mode);
252void fbcon_delete_modelist(struct list_head *head);
253void fbcon_new_modelist(struct fb_info *info);
254void fbcon_get_requirement(struct fb_info *info,
255 struct fb_blit_caps *caps);
256void fbcon_fb_blanked(struct fb_info *info, int blank);
257int fbcon_modechange_possible(struct fb_info *info,
258 struct fb_var_screeninfo *var);
259void fbcon_update_vcs(struct fb_info *info, bool all);
260void fbcon_remap_all(struct fb_info *info);
261int fbcon_set_con2fb_map_ioctl(void __user *argp);
262int fbcon_get_con2fb_map_ioctl(void __user *argp);
263#else
264static inline void fb_console_init(void) {}
265static inline void fb_console_exit(void) {}
266static inline int fbcon_fb_registered(struct fb_info *info) { return 0; }
267static inline void fbcon_fb_unregistered(struct fb_info *info) {}
268static inline void fbcon_fb_unbind(struct fb_info *info) {}
269static inline void fbcon_suspended(struct fb_info *info) {}
270static inline void fbcon_resumed(struct fb_info *info) {}
271static inline int fbcon_mode_deleted(struct fb_info *info,
272 struct fb_videomode *mode) { return 0; }
273static inline void fbcon_delete_modelist(struct list_head *head) {}
274static inline void fbcon_new_modelist(struct fb_info *info) {}
275static inline void fbcon_get_requirement(struct fb_info *info,
276 struct fb_blit_caps *caps) {}
277static inline void fbcon_fb_blanked(struct fb_info *info, int blank) {}
278static inline int fbcon_modechange_possible(struct fb_info *info,
279 struct fb_var_screeninfo *var) { return 0; }
280static inline void fbcon_update_vcs(struct fb_info *info, bool all) {}
281static inline void fbcon_remap_all(struct fb_info *info) {}
282static inline int fbcon_set_con2fb_map_ioctl(void __user *argp) { return 0; }
283static inline int fbcon_get_con2fb_map_ioctl(void __user *argp) { return 0; }
284#endif
285
286#endif /* _VIDEO_FBCON_H */