• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* ----------------------------------------------------------------------- *
2  *
3  *   Copyright 2006-2008 H. Peter Anvin - All Rights Reserved
4  *
5  *   Permission is hereby granted, free of charge, to any person
6  *   obtaining a copy of this software and associated documentation
7  *   files (the "Software"), to deal in the Software without
8  *   restriction, including without limitation the rights to use,
9  *   copy, modify, merge, publish, distribute, sublicense, and/or
10  *   sell copies of the Software, and to permit persons to whom
11  *   the Software is furnished to do so, subject to the following
12  *   conditions:
13  *
14  *   The above copyright notice and this permission notice shall
15  *   be included in all copies or substantial portions of the Software.
16  *
17  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19  *   OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20  *   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21  *   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22  *   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23  *   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24  *   OTHER DEALINGS IN THE SOFTWARE.
25  *
26  * ----------------------------------------------------------------------- */
27 
28 #ifndef LIB_SYS_VESA_VIDEO_H
29 #define LIB_SYS_VESA_VIDEO_H
30 
31 #include <stdbool.h>
32 #include <colortbl.h>
33 #include "vesa.h"
34 
35 #define FONT_MAX_CHARS	256
36 #define FONT_MAX_HEIGHT	 32
37 #define FONT_WIDTH	  8
38 
39 #define DEFAULT_VESA_X_SIZE	640
40 #define DEFAULT_VESA_Y_SIZE	480
41 
42 #define VIDEO_BORDER	8
43 #define TEXT_PIXEL_ROWS (__vesa_info.mi.v_res - 2*VIDEO_BORDER)
44 #define TEXT_PIXEL_COLS (__vesa_info.mi.h_res - 2*VIDEO_BORDER)
45 
46 typedef uint16_t attr_t;
47 
48 struct vesa_char {
49     uint8_t ch;			/* Character */
50     uint8_t _filler;		/* Currently unused */
51     attr_t attr;		/* Color table index */
52 };
53 
54 struct win_info {
55     char *win_base;
56     size_t win_pos;
57     size_t win_size;
58     int win_gshift;
59     int win_num;
60 };
61 
62 /* Pixel formats in order of decreasing preference; PXF_NONE should be last */
63 /* BGR24 is preferred over BGRA32 since the I/O overhead is smaller. */
64 enum vesa_pixel_format {
65     PXF_BGR24,			/* 24-bit BGR */
66     PXF_BGRA32,			/* 32-bit BGRA */
67     PXF_LE_RGB16_565,		/* 16-bit littleendian 5:6:5 RGB */
68     PXF_LE_RGB15_555,		/* 15-bit littleendian 5:5:5 RGB */
69     PXF_NONE
70 };
71 extern enum vesa_pixel_format __vesacon_pixel_format;
72 extern unsigned int __vesacon_bytes_per_pixel;
73 typedef const void *(*__vesacon_format_pixels_t)
74     (void *, const uint32_t *, size_t);
75 extern __vesacon_format_pixels_t __vesacon_format_pixels;
76 extern const __vesacon_format_pixels_t __vesacon_format_pixels_list[PXF_NONE];
77 
78 extern struct vesa_char *__vesacon_text_display;
79 
80 extern int __vesacon_font_height;
81 extern int __vesacon_text_rows;
82 extern int __vesacon_text_cols;
83 extern uint8_t __vesacon_graphics_font[FONT_MAX_CHARS][FONT_MAX_HEIGHT];
84 extern uint32_t *__vesacon_background;
85 extern uint32_t *__vesacon_shadowfb;
86 
87 extern const uint16_t __vesacon_srgb_to_linear[256];
88 extern const uint8_t __vesacon_linear_to_srgb[4080];
89 
90 int __vesacon_init_background(void);
91 int vesacon_load_background(const char *);
92 int __vesacon_init(int *, int *);
93 void __vesacon_init_cursor(int);
94 void __vesacon_erase(int, int, int, int, attr_t);
95 void __vesacon_scroll_up(int, attr_t);
96 void __vesacon_write_char(int, int, uint8_t, attr_t);
97 void __vesacon_redraw_text(void);
98 void __vesacon_doit(void);
99 void __vesacon_set_cursor(int, int, bool);
100 void __vesacon_copy_to_screen(size_t, const uint32_t *, size_t);
101 void __vesacon_init_copy_to_screen(void);
102 
103 int __vesacon_i915resolution(int x, int y);
104 
105 #endif /* LIB_SYS_VESA_VIDEO_H */
106