blob: dab2b4dd37e4604f6e5c7b2f7860b45bd03d6591 [file] [log] [blame]
Kevin O'Connor5108c692011-12-31 19:13:45 -05001#ifndef __VGAHW_H
2#define __VGAHW_H
3
4#include "types.h" // u8
5#include "config.h" // CONFIG_*
6
Kevin O'Connor5108c692011-12-31 19:13:45 -05007#include "bochsvga.h" // bochsvga_set_mode
8#include "stdvga.h" // stdvga_set_mode
Kevin O'Connord83c87b2013-01-21 01:14:12 -05009#include "geodevga.h" // geodevga_setup
Kevin O'Connorc682ffe2016-08-05 11:48:20 -040010#include "vgautil.h" // stdvga_list_modes
Kevin O'Connor5108c692011-12-31 19:13:45 -050011
Kevin O'Connor10dff3d2012-01-09 19:19:44 -050012static inline struct vgamode_s *vgahw_find_mode(int mode) {
Kevin O'Connorc4a0b972012-01-09 20:21:31 -050013 if (CONFIG_VGA_CIRRUS)
14 return clext_find_mode(mode);
15 if (CONFIG_VGA_BOCHS)
16 return bochsvga_find_mode(mode);
Kevin O'Connor7c790292014-02-11 15:34:58 -050017 if (CONFIG_VGA_COREBOOT)
18 return cbvga_find_mode(mode);
Kevin O'Connor10dff3d2012-01-09 19:19:44 -050019 return stdvga_find_mode(mode);
20}
21
Kevin O'Connore6bc4c12012-01-21 11:26:37 -050022static inline int vgahw_set_mode(struct vgamode_s *vmode_g, int flags) {
Kevin O'Connor5108c692011-12-31 19:13:45 -050023 if (CONFIG_VGA_CIRRUS)
Kevin O'Connore6bc4c12012-01-21 11:26:37 -050024 return clext_set_mode(vmode_g, flags);
Kevin O'Connor5108c692011-12-31 19:13:45 -050025 if (CONFIG_VGA_BOCHS)
Kevin O'Connore6bc4c12012-01-21 11:26:37 -050026 return bochsvga_set_mode(vmode_g, flags);
Kevin O'Connor7c790292014-02-11 15:34:58 -050027 if (CONFIG_VGA_COREBOOT)
28 return cbvga_set_mode(vmode_g, flags);
Kevin O'Connore6bc4c12012-01-21 11:26:37 -050029 return stdvga_set_mode(vmode_g, flags);
Kevin O'Connor5108c692011-12-31 19:13:45 -050030}
31
Kevin O'Connor34203cd2012-01-09 20:55:31 -050032static inline void vgahw_list_modes(u16 seg, u16 *dest, u16 *last) {
33 if (CONFIG_VGA_CIRRUS)
34 clext_list_modes(seg, dest, last);
35 else if (CONFIG_VGA_BOCHS)
36 bochsvga_list_modes(seg, dest, last);
Kevin O'Connor7c790292014-02-11 15:34:58 -050037 else if (CONFIG_VGA_COREBOOT)
38 cbvga_list_modes(seg, dest, last);
Kevin O'Connor34203cd2012-01-09 20:55:31 -050039 else
40 stdvga_list_modes(seg, dest, last);
41}
42
Kevin O'Connord83c87b2013-01-21 01:14:12 -050043static inline int vgahw_setup(void) {
Kevin O'Connor161d2012011-12-31 19:42:21 -050044 if (CONFIG_VGA_CIRRUS)
Kevin O'Connord83c87b2013-01-21 01:14:12 -050045 return clext_setup();
Kevin O'Connor161d2012011-12-31 19:42:21 -050046 if (CONFIG_VGA_BOCHS)
Kevin O'Connord83c87b2013-01-21 01:14:12 -050047 return bochsvga_setup();
Nils24ddd862012-01-14 12:15:14 -050048 if (CONFIG_VGA_GEODEGX2 || CONFIG_VGA_GEODELX)
Kevin O'Connord83c87b2013-01-21 01:14:12 -050049 return geodevga_setup();
Kevin O'Connor7c790292014-02-11 15:34:58 -050050 if (CONFIG_VGA_COREBOOT)
51 return cbvga_setup();
Kevin O'Connord83c87b2013-01-21 01:14:12 -050052 return stdvga_setup();
Kevin O'Connor161d2012011-12-31 19:42:21 -050053}
54
Kevin O'Connor9961f992012-01-21 11:53:44 -050055static inline int vgahw_get_window(struct vgamode_s *vmode_g, int window) {
56 if (CONFIG_VGA_CIRRUS)
57 return clext_get_window(vmode_g, window);
58 if (CONFIG_VGA_BOCHS)
59 return bochsvga_get_window(vmode_g, window);
Kevin O'Connor7c790292014-02-11 15:34:58 -050060 if (CONFIG_VGA_COREBOOT)
61 return cbvga_get_window(vmode_g, window);
Kevin O'Connor9961f992012-01-21 11:53:44 -050062 return stdvga_get_window(vmode_g, window);
63}
64
65static inline int vgahw_set_window(struct vgamode_s *vmode_g, int window
66 , int val) {
67 if (CONFIG_VGA_CIRRUS)
68 return clext_set_window(vmode_g, window, val);
69 if (CONFIG_VGA_BOCHS)
70 return bochsvga_set_window(vmode_g, window, val);
Kevin O'Connor7c790292014-02-11 15:34:58 -050071 if (CONFIG_VGA_COREBOOT)
72 return cbvga_set_window(vmode_g, window, val);
Kevin O'Connor9961f992012-01-21 11:53:44 -050073 return stdvga_set_window(vmode_g, window, val);
74}
75
Kevin O'Connor3876b532012-01-24 00:07:44 -050076static inline int vgahw_get_linelength(struct vgamode_s *vmode_g) {
77 if (CONFIG_VGA_CIRRUS)
78 return clext_get_linelength(vmode_g);
79 if (CONFIG_VGA_BOCHS)
80 return bochsvga_get_linelength(vmode_g);
Kevin O'Connor7c790292014-02-11 15:34:58 -050081 if (CONFIG_VGA_COREBOOT)
82 return cbvga_get_linelength(vmode_g);
Kevin O'Connor3876b532012-01-24 00:07:44 -050083 return stdvga_get_linelength(vmode_g);
84}
85
86static inline int vgahw_set_linelength(struct vgamode_s *vmode_g, int val) {
87 if (CONFIG_VGA_CIRRUS)
88 return clext_set_linelength(vmode_g, val);
89 if (CONFIG_VGA_BOCHS)
90 return bochsvga_set_linelength(vmode_g, val);
Kevin O'Connor7c790292014-02-11 15:34:58 -050091 if (CONFIG_VGA_COREBOOT)
92 return cbvga_set_linelength(vmode_g, val);
Kevin O'Connor3876b532012-01-24 00:07:44 -050093 return stdvga_set_linelength(vmode_g, val);
94}
95
Kevin O'Connord61fc532012-01-27 20:37:45 -050096static inline int vgahw_get_displaystart(struct vgamode_s *vmode_g) {
97 if (CONFIG_VGA_CIRRUS)
98 return clext_get_displaystart(vmode_g);
99 if (CONFIG_VGA_BOCHS)
100 return bochsvga_get_displaystart(vmode_g);
Kevin O'Connor7c790292014-02-11 15:34:58 -0500101 if (CONFIG_VGA_COREBOOT)
102 return cbvga_get_displaystart(vmode_g);
Kevin O'Connord61fc532012-01-27 20:37:45 -0500103 return stdvga_get_displaystart(vmode_g);
104}
105
106static inline int vgahw_set_displaystart(struct vgamode_s *vmode_g, int val) {
107 if (CONFIG_VGA_CIRRUS)
108 return clext_set_displaystart(vmode_g, val);
109 if (CONFIG_VGA_BOCHS)
110 return bochsvga_set_displaystart(vmode_g, val);
Kevin O'Connor7c790292014-02-11 15:34:58 -0500111 if (CONFIG_VGA_COREBOOT)
112 return cbvga_set_displaystart(vmode_g, val);
Kevin O'Connord61fc532012-01-27 20:37:45 -0500113 return stdvga_set_displaystart(vmode_g, val);
114}
115
Kevin O'Connore737b172012-02-04 11:08:39 -0500116static inline int vgahw_get_dacformat(struct vgamode_s *vmode_g) {
117 if (CONFIG_VGA_BOCHS)
118 return bochsvga_get_dacformat(vmode_g);
Kevin O'Connor7c790292014-02-11 15:34:58 -0500119 if (CONFIG_VGA_COREBOOT)
120 return cbvga_get_dacformat(vmode_g);
Kevin O'Connore737b172012-02-04 11:08:39 -0500121 return stdvga_get_dacformat(vmode_g);
122}
123
124static inline int vgahw_set_dacformat(struct vgamode_s *vmode_g, int val) {
125 if (CONFIG_VGA_BOCHS)
126 return bochsvga_set_dacformat(vmode_g, val);
Kevin O'Connor7c790292014-02-11 15:34:58 -0500127 if (CONFIG_VGA_COREBOOT)
128 return cbvga_set_dacformat(vmode_g, val);
Kevin O'Connore737b172012-02-04 11:08:39 -0500129 return stdvga_set_dacformat(vmode_g, val);
130}
131
Kevin O'Connor20dc4192014-02-05 20:52:25 -0500132static inline int vgahw_save_restore(int cmd, u16 seg, void *data) {
Kevin O'Connor2469f892012-02-04 12:40:02 -0500133 if (CONFIG_VGA_CIRRUS)
Kevin O'Connor20dc4192014-02-05 20:52:25 -0500134 return clext_save_restore(cmd, seg, data);
Kevin O'Connor2469f892012-02-04 12:40:02 -0500135 if (CONFIG_VGA_BOCHS)
Kevin O'Connor20dc4192014-02-05 20:52:25 -0500136 return bochsvga_save_restore(cmd, seg, data);
Kevin O'Connor7c790292014-02-11 15:34:58 -0500137 if (CONFIG_VGA_COREBOOT)
138 return cbvga_save_restore(cmd, seg, data);
Kevin O'Connor20dc4192014-02-05 20:52:25 -0500139 return stdvga_save_restore(cmd, seg, data);
Kevin O'Connor2469f892012-02-04 12:40:02 -0500140}
141
Kevin O'Connor5108c692011-12-31 19:13:45 -0500142#endif // vgahw.h