File Index
Files and directories
Sign in
FILE

fbcon.h

File preview with syntax highlighting.

linux-6.19.14/drivers/video/fbdev/core/fbcon.h C
  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/types.h>
 15#include <linux/vt_buffer.h>
 16#include <linux/vt_kern.h>
 17#include <linux/workqueue.h>
 18
 19#include <asm/io.h>
 20
 21   /*
 22    *    This is the interface between the low-level console driver and the
 23    *    low-level frame buffer device
 24    */
 25
 26struct fbcon_display {
 27    /* Filled in by the low-level console driver */
 28    const u_char *fontdata;
 29    int userfont;                   /* != 0 if fontdata kmalloc()ed */
 30#ifdef CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION
 31    u_short scrollmode;             /* Scroll Method, use fb_scrollmode() */
 32#endif
 33    short yscroll;                  /* Hardware scrolling */
 34    int vrows;                      /* number of virtual rows */
 35    int cursor_shape;
 36    int con_rotate;
 37    u32 xres_virtual;
 38    u32 yres_virtual;
 39    u32 height;
 40    u32 width;
 41    u32 bits_per_pixel;
 42    u32 grayscale;
 43    u32 nonstd;
 44    u32 accel_flags;
 45    u32 rotate;
 46    struct fb_bitfield red;
 47    struct fb_bitfield green;
 48    struct fb_bitfield blue;
 49    struct fb_bitfield transp;
 50    const struct fb_videomode *mode;
 51};
 52
 53struct fbcon_bitops {
 54	void (*bmove)(struct vc_data *vc, struct fb_info *info, int sy,
 55		      int sx, int dy, int dx, int height, int width);
 56	void (*clear)(struct vc_data *vc, struct fb_info *info, int sy,
 57		      int sx, int height, int width, int fb, int bg);
 58	void (*putcs)(struct vc_data *vc, struct fb_info *info,
 59		      const unsigned short *s, int count, int yy, int xx,
 60		      int fg, int bg);
 61	void (*clear_margins)(struct vc_data *vc, struct fb_info *info,
 62			      int color, int bottom_only);
 63	void (*cursor)(struct vc_data *vc, struct fb_info *info,
 64		       bool enable, int fg, int bg);
 65	int  (*update_start)(struct fb_info *info);
 66	int  (*rotate_font)(struct fb_info *info, struct vc_data *vc);
 67};
 68
 69struct fbcon_par {
 70	struct fb_var_screeninfo var;  /* copy of the current fb_var_screeninfo */
 71	struct delayed_work cursor_work; /* Cursor timer */
 72	struct fb_cursor cursor_state;
 73	struct fbcon_display *p;
 74	struct fb_info *info;
 75        int    currcon;	                /* Current VC. */
 76	int    cur_blink_jiffies;
 77	int    cursor_flash;
 78	int    cursor_reset;
 79	int    blank_state;
 80	int    graphics;
 81	int    save_graphics; /* for debug enter/leave */
 82	bool   initialized;
 83	int    rotate;
 84	int    cur_rotate;
 85	char  *cursor_data;
 86	u8    *fontbuffer;
 87	u8    *fontdata;
 88	u8    *cursor_src;
 89	u32    cursor_size;
 90	u32    fd_size;
 91
 92	const struct fbcon_bitops *bitops;
 93};
 94
 95    /*
 96     *  Attribute Decoding
 97     */
 98
 99/* Color */
100#define attr_fgcol(fgshift,s)    \
101	(((s) >> (fgshift)) & 0x0f)
102#define attr_bgcol(bgshift,s)    \
103	(((s) >> (bgshift)) & 0x0f)
104
105/* Monochrome */
106#define attr_bold(s) \
107	((s) & 0x200)
108#define attr_reverse(s) \
109	((s) & 0x800)
110#define attr_underline(s) \
111	((s) & 0x400)
112#define attr_blink(s) \
113	((s) & 0x8000)
114
115static inline int mono_col(const struct fb_info *info)
116{
117	__u32 max_len;
118	max_len = max(info->var.green.length, info->var.red.length);
119	max_len = max(info->var.blue.length, max_len);
120	return (~(0xfff << max_len)) & 0xff;
121}
122
123    /*
124     *  Scroll Method
125     */
126
127/* There are several methods fbcon can use to move text around the screen:
128 *
129 *                     Operation   Pan    Wrap
130 *---------------------------------------------
131 * SCROLL_MOVE         copyarea    No     No
132 * SCROLL_PAN_MOVE     copyarea    Yes    No
133 * SCROLL_WRAP_MOVE    copyarea    No     Yes
134 * SCROLL_REDRAW       imageblit   No     No
135 * SCROLL_PAN_REDRAW   imageblit   Yes    No
136 * SCROLL_WRAP_REDRAW  imageblit   No     Yes
137 *
138 * (SCROLL_WRAP_REDRAW is not implemented yet)
139 *
140 * In general, fbcon will choose the best scrolling
141 * method based on the rule below:
142 *
143 * Pan/Wrap > accel imageblit > accel copyarea >
144 * soft imageblit > (soft copyarea)
145 *
146 * Exception to the rule: Pan + accel copyarea is
147 * preferred over Pan + accel imageblit.
148 *
149 * The above is typical for PCI/AGP cards. Unless
150 * overridden, fbcon will never use soft copyarea.
151 *
152 * If you need to override the above rule, set the
153 * appropriate flags in fb_info->flags.  For example,
154 * to prefer copyarea over imageblit, set
155 * FBINFO_READS_FAST.
156 *
157 * Other notes:
158 * + use the hardware engine to move the text
159 *    (hw-accelerated copyarea() and fillrect())
160 * + use hardware-supported panning on a large virtual screen
161 * + amifb can not only pan, but also wrap the display by N lines
162 *    (i.e. visible line i = physical line (i+N) % yres).
163 * + read what's already rendered on the screen and
164 *     write it in a different place (this is cfb_copyarea())
165 * + re-render the text to the screen
166 *
167 * Whether to use wrapping or panning can only be figured out at
168 * runtime (when we know whether our font height is a multiple
169 * of the pan/wrap step)
170 *
171 */
172
173#define SCROLL_MOVE	   0x001
174#define SCROLL_PAN_MOVE	   0x002
175#define SCROLL_WRAP_MOVE   0x003
176#define SCROLL_REDRAW	   0x004
177#define SCROLL_PAN_REDRAW  0x005
178
179static inline u_short fb_scrollmode(struct fbcon_display *fb)
180{
181#ifdef CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION
182	return fb->scrollmode;
183#else
184	/* hardcoded to SCROLL_REDRAW if acceleration was disabled. */
185	return SCROLL_REDRAW;
186#endif
187}
188
189
190#ifdef CONFIG_FB_TILEBLITTING
191extern void fbcon_set_tileops(struct vc_data *vc, struct fb_info *info);
192#endif
193extern void fbcon_set_bitops_ur(struct fbcon_par *par);
194extern int  soft_cursor(struct fb_info *info, struct fb_cursor *cursor);
195
196#define FBCON_ATTRIBUTE_UNDERLINE 1
197#define FBCON_ATTRIBUTE_REVERSE   2
198#define FBCON_ATTRIBUTE_BOLD      4
199
200static inline int real_y(struct fbcon_display *p, int ypos)
201{
202	int rows = p->vrows;
203
204	ypos += p->yscroll;
205	return ypos < rows ? ypos : ypos - rows;
206}
207
208
209static inline int get_attribute(struct fb_info *info, u16 c)
210{
211	int attribute = 0;
212
213	if (fb_get_color_depth(&info->var, &info->fix) == 1) {
214		if (attr_underline(c))
215			attribute |= FBCON_ATTRIBUTE_UNDERLINE;
216		if (attr_reverse(c))
217			attribute |= FBCON_ATTRIBUTE_REVERSE;
218		if (attr_bold(c))
219			attribute |= FBCON_ATTRIBUTE_BOLD;
220	}
221
222	return attribute;
223}
224
225#define FBCON_SWAP(i,r,v) ({ \
226        typeof(r) _r = (r);  \
227        typeof(v) _v = (v);  \
228        (void) (&_r == &_v); \
229        (i == FB_ROTATE_UR || i == FB_ROTATE_UD) ? _r : _v; })
230
231#endif /* _VIDEO_FBCON_H */
~/ Read-only file preview.