vgabios: Unify code to generate the vbe mode list.
[seabios.git] / vgasrc / vgahw.h
1 #ifndef __VGAHW_H
2 #define __VGAHW_H
3
4 #include "types.h" // u8
5 #include "config.h" // CONFIG_*
6
7 #include "clext.h" // clext_set_mode
8 #include "bochsvga.h" // bochsvga_set_mode
9 #include "stdvga.h" // stdvga_set_mode
10 #include "geodevga.h" // geodevga_init
11
12 static inline struct vgamode_s *vgahw_find_mode(int mode) {
13     if (CONFIG_VGA_CIRRUS)
14         return clext_find_mode(mode);
15     if (CONFIG_VGA_BOCHS)
16         return bochsvga_find_mode(mode);
17     return stdvga_find_mode(mode);
18 }
19
20 static inline int vgahw_set_mode(int mode, int flags) {
21     if (CONFIG_VGA_CIRRUS)
22         return clext_set_mode(mode, flags);
23     if (CONFIG_VGA_BOCHS)
24         return bochsvga_set_mode(mode, flags);
25     return stdvga_set_mode(mode, flags);
26 }
27
28 static inline void vgahw_list_modes(u16 seg, u16 *dest, u16 *last) {
29     if (CONFIG_VGA_CIRRUS)
30         clext_list_modes(seg, dest, last);
31     else if (CONFIG_VGA_BOCHS)
32         bochsvga_list_modes(seg, dest, last);
33     else
34         stdvga_list_modes(seg, dest, last);
35 }
36
37 static inline int vgahw_init(void) {
38     if (CONFIG_VGA_CIRRUS)
39         return clext_init();
40     if (CONFIG_VGA_BOCHS)
41         return bochsvga_init();
42     if (CONFIG_VGA_GEODEGX2 || CONFIG_VGA_GEODELX)
43         return geodevga_init();
44     return stdvga_init();
45 }
46
47 #endif // vgahw.h