4 #include "types.h" // u8
5 #include "config.h" // CONFIG_*
7 #include "cbvga.h" // cbvga_setup
8 #include "clext.h" // clext_set_mode
9 #include "bochsvga.h" // bochsvga_set_mode
10 #include "stdvga.h" // stdvga_set_mode
11 #include "geodevga.h" // geodevga_setup
13 static inline struct vgamode_s *vgahw_find_mode(int mode) {
14 if (CONFIG_VGA_CIRRUS)
15 return clext_find_mode(mode);
17 return bochsvga_find_mode(mode);
18 if (CONFIG_VGA_COREBOOT)
19 return cbvga_find_mode(mode);
20 return stdvga_find_mode(mode);
23 static inline int vgahw_set_mode(struct vgamode_s *vmode_g, int flags) {
24 if (CONFIG_VGA_CIRRUS)
25 return clext_set_mode(vmode_g, flags);
27 return bochsvga_set_mode(vmode_g, flags);
28 if (CONFIG_VGA_COREBOOT)
29 return cbvga_set_mode(vmode_g, flags);
30 return stdvga_set_mode(vmode_g, flags);
33 static inline void vgahw_list_modes(u16 seg, u16 *dest, u16 *last) {
34 if (CONFIG_VGA_CIRRUS)
35 clext_list_modes(seg, dest, last);
36 else if (CONFIG_VGA_BOCHS)
37 bochsvga_list_modes(seg, dest, last);
38 else if (CONFIG_VGA_COREBOOT)
39 cbvga_list_modes(seg, dest, last);
41 stdvga_list_modes(seg, dest, last);
44 static inline int vgahw_setup(void) {
45 if (CONFIG_VGA_CIRRUS)
48 return bochsvga_setup();
49 if (CONFIG_VGA_GEODEGX2 || CONFIG_VGA_GEODELX)
50 return geodevga_setup();
51 if (CONFIG_VGA_COREBOOT)
53 return stdvga_setup();
56 static inline int vgahw_get_window(struct vgamode_s *vmode_g, int window) {
57 if (CONFIG_VGA_CIRRUS)
58 return clext_get_window(vmode_g, window);
60 return bochsvga_get_window(vmode_g, window);
61 if (CONFIG_VGA_COREBOOT)
62 return cbvga_get_window(vmode_g, window);
63 return stdvga_get_window(vmode_g, window);
66 static inline int vgahw_set_window(struct vgamode_s *vmode_g, int window
68 if (CONFIG_VGA_CIRRUS)
69 return clext_set_window(vmode_g, window, val);
71 return bochsvga_set_window(vmode_g, window, val);
72 if (CONFIG_VGA_COREBOOT)
73 return cbvga_set_window(vmode_g, window, val);
74 return stdvga_set_window(vmode_g, window, val);
77 static inline int vgahw_get_linelength(struct vgamode_s *vmode_g) {
78 if (CONFIG_VGA_CIRRUS)
79 return clext_get_linelength(vmode_g);
81 return bochsvga_get_linelength(vmode_g);
82 if (CONFIG_VGA_COREBOOT)
83 return cbvga_get_linelength(vmode_g);
84 return stdvga_get_linelength(vmode_g);
87 static inline int vgahw_set_linelength(struct vgamode_s *vmode_g, int val) {
88 if (CONFIG_VGA_CIRRUS)
89 return clext_set_linelength(vmode_g, val);
91 return bochsvga_set_linelength(vmode_g, val);
92 if (CONFIG_VGA_COREBOOT)
93 return cbvga_set_linelength(vmode_g, val);
94 return stdvga_set_linelength(vmode_g, val);
97 static inline int vgahw_get_displaystart(struct vgamode_s *vmode_g) {
98 if (CONFIG_VGA_CIRRUS)
99 return clext_get_displaystart(vmode_g);
100 if (CONFIG_VGA_BOCHS)
101 return bochsvga_get_displaystart(vmode_g);
102 if (CONFIG_VGA_COREBOOT)
103 return cbvga_get_displaystart(vmode_g);
104 return stdvga_get_displaystart(vmode_g);
107 static inline int vgahw_set_displaystart(struct vgamode_s *vmode_g, int val) {
108 if (CONFIG_VGA_CIRRUS)
109 return clext_set_displaystart(vmode_g, val);
110 if (CONFIG_VGA_BOCHS)
111 return bochsvga_set_displaystart(vmode_g, val);
112 if (CONFIG_VGA_COREBOOT)
113 return cbvga_set_displaystart(vmode_g, val);
114 return stdvga_set_displaystart(vmode_g, val);
117 static inline int vgahw_get_dacformat(struct vgamode_s *vmode_g) {
118 if (CONFIG_VGA_BOCHS)
119 return bochsvga_get_dacformat(vmode_g);
120 if (CONFIG_VGA_COREBOOT)
121 return cbvga_get_dacformat(vmode_g);
122 return stdvga_get_dacformat(vmode_g);
125 static inline int vgahw_set_dacformat(struct vgamode_s *vmode_g, int val) {
126 if (CONFIG_VGA_BOCHS)
127 return bochsvga_set_dacformat(vmode_g, val);
128 if (CONFIG_VGA_COREBOOT)
129 return cbvga_set_dacformat(vmode_g, val);
130 return stdvga_set_dacformat(vmode_g, val);
133 static inline int vgahw_save_restore(int cmd, u16 seg, void *data) {
134 if (CONFIG_VGA_CIRRUS)
135 return clext_save_restore(cmd, seg, data);
136 if (CONFIG_VGA_BOCHS)
137 return bochsvga_save_restore(cmd, seg, data);
138 if (CONFIG_VGA_COREBOOT)
139 return cbvga_save_restore(cmd, seg, data);
140 return stdvga_save_restore(cmd, seg, data);