blob: 3d9ae3942deccf13167ae570103b28279ffd36f0 [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'Connor7c790292014-02-11 15:34:58 -05007#include "cbvga.h" // cbvga_setup
Kevin O'Connor5108c692011-12-31 19:13:45 -05008#include "clext.h" // clext_set_mode
9#include "bochsvga.h" // bochsvga_set_mode
10#include "stdvga.h" // stdvga_set_mode
Kevin O'Connord83c87b2013-01-21 01:14:12 -050011#include "geodevga.h" // geodevga_setup
Kevin O'Connorc682ffe2016-08-05 11:48:20 -040012#include "vgautil.h" // stdvga_list_modes
Kevin O'Connor5108c692011-12-31 19:13:45 -050013
Kevin O'Connor10dff3d2012-01-09 19:19:44 -050014static inline struct vgamode_s *vgahw_find_mode(int mode) {
Kevin O'Connorc4a0b972012-01-09 20:21:31 -050015 if (CONFIG_VGA_CIRRUS)
16 return clext_find_mode(mode);
17 if (CONFIG_VGA_BOCHS)
18 return bochsvga_find_mode(mode);
Kevin O'Connor7c790292014-02-11 15:34:58 -050019 if (CONFIG_VGA_COREBOOT)
20 return cbvga_find_mode(mode);
Kevin O'Connor10dff3d2012-01-09 19:19:44 -050021 return stdvga_find_mode(mode);
22}
23
Kevin O'Connore6bc4c12012-01-21 11:26:37 -050024static inline int vgahw_set_mode(struct vgamode_s *vmode_g, int flags) {
Kevin O'Connor5108c692011-12-31 19:13:45 -050025 if (CONFIG_VGA_CIRRUS)
Kevin O'Connore6bc4c12012-01-21 11:26:37 -050026 return clext_set_mode(vmode_g, flags);
Kevin O'Connor5108c692011-12-31 19:13:45 -050027 if (CONFIG_VGA_BOCHS)
Kevin O'Connore6bc4c12012-01-21 11:26:37 -050028 return bochsvga_set_mode(vmode_g, flags);
Kevin O'Connor7c790292014-02-11 15:34:58 -050029 if (CONFIG_VGA_COREBOOT)
30 return cbvga_set_mode(vmode_g, flags);
Kevin O'Connore6bc4c12012-01-21 11:26:37 -050031 return stdvga_set_mode(vmode_g, flags);
Kevin O'Connor5108c692011-12-31 19:13:45 -050032}
33
Kevin O'Connor34203cd2012-01-09 20:55:31 -050034static inline void vgahw_list_modes(u16 seg, u16 *dest, u16 *last) {
35 if (CONFIG_VGA_CIRRUS)
36 clext_list_modes(seg, dest, last);
37 else if (CONFIG_VGA_BOCHS)
38 bochsvga_list_modes(seg, dest, last);
Kevin O'Connor7c790292014-02-11 15:34:58 -050039 else if (CONFIG_VGA_COREBOOT)
40 cbvga_list_modes(seg, dest, last);
Kevin O'Connor34203cd2012-01-09 20:55:31 -050041 else
42 stdvga_list_modes(seg, dest, last);
43}
44
Kevin O'Connord83c87b2013-01-21 01:14:12 -050045static inline int vgahw_setup(void) {
Kevin O'Connor161d2012011-12-31 19:42:21 -050046 if (CONFIG_VGA_CIRRUS)
Kevin O'Connord83c87b2013-01-21 01:14:12 -050047 return clext_setup();
Kevin O'Connor161d2012011-12-31 19:42:21 -050048 if (CONFIG_VGA_BOCHS)
Kevin O'Connord83c87b2013-01-21 01:14:12 -050049 return bochsvga_setup();
Nils24ddd862012-01-14 12:15:14 -050050 if (CONFIG_VGA_GEODEGX2 || CONFIG_VGA_GEODELX)
Kevin O'Connord83c87b2013-01-21 01:14:12 -050051 return geodevga_setup();
Kevin O'Connor7c790292014-02-11 15:34:58 -050052 if (CONFIG_VGA_COREBOOT)
53 return cbvga_setup();
Kevin O'Connord83c87b2013-01-21 01:14:12 -050054 return stdvga_setup();
Kevin O'Connor161d2012011-12-31 19:42:21 -050055}
56
Kevin O'Connor9961f992012-01-21 11:53:44 -050057static inline int vgahw_get_window(struct vgamode_s *vmode_g, int window) {
58 if (CONFIG_VGA_CIRRUS)
59 return clext_get_window(vmode_g, window);
60 if (CONFIG_VGA_BOCHS)
61 return bochsvga_get_window(vmode_g, window);
Kevin O'Connor7c790292014-02-11 15:34:58 -050062 if (CONFIG_VGA_COREBOOT)
63 return cbvga_get_window(vmode_g, window);
Kevin O'Connor9961f992012-01-21 11:53:44 -050064 return stdvga_get_window(vmode_g, window);
65}
66
67static inline int vgahw_set_window(struct vgamode_s *vmode_g, int window
68 , int val) {
69 if (CONFIG_VGA_CIRRUS)
70 return clext_set_window(vmode_g, window, val);
71 if (CONFIG_VGA_BOCHS)
72 return bochsvga_set_window(vmode_g, window, val);
Kevin O'Connor7c790292014-02-11 15:34:58 -050073 if (CONFIG_VGA_COREBOOT)
74 return cbvga_set_window(vmode_g, window, val);
Kevin O'Connor9961f992012-01-21 11:53:44 -050075 return stdvga_set_window(vmode_g, window, val);
76}
77
Kevin O'Connor3876b532012-01-24 00:07:44 -050078static inline int vgahw_get_linelength(struct vgamode_s *vmode_g) {
79 if (CONFIG_VGA_CIRRUS)
80 return clext_get_linelength(vmode_g);
81 if (CONFIG_VGA_BOCHS)
82 return bochsvga_get_linelength(vmode_g);
Kevin O'Connor7c790292014-02-11 15:34:58 -050083 if (CONFIG_VGA_COREBOOT)
84 return cbvga_get_linelength(vmode_g);
Kevin O'Connor3876b532012-01-24 00:07:44 -050085 return stdvga_get_linelength(vmode_g);
86}
87
88static inline int vgahw_set_linelength(struct vgamode_s *vmode_g, int val) {
89 if (CONFIG_VGA_CIRRUS)
90 return clext_set_linelength(vmode_g, val);
91 if (CONFIG_VGA_BOCHS)
92 return bochsvga_set_linelength(vmode_g, val);
Kevin O'Connor7c790292014-02-11 15:34:58 -050093 if (CONFIG_VGA_COREBOOT)
94 return cbvga_set_linelength(vmode_g, val);
Kevin O'Connor3876b532012-01-24 00:07:44 -050095 return stdvga_set_linelength(vmode_g, val);
96}
97
Kevin O'Connord61fc532012-01-27 20:37:45 -050098static inline int vgahw_get_displaystart(struct vgamode_s *vmode_g) {
99 if (CONFIG_VGA_CIRRUS)
100 return clext_get_displaystart(vmode_g);
101 if (CONFIG_VGA_BOCHS)
102 return bochsvga_get_displaystart(vmode_g);
Kevin O'Connor7c790292014-02-11 15:34:58 -0500103 if (CONFIG_VGA_COREBOOT)
104 return cbvga_get_displaystart(vmode_g);
Kevin O'Connord61fc532012-01-27 20:37:45 -0500105 return stdvga_get_displaystart(vmode_g);
106}
107
108static inline int vgahw_set_displaystart(struct vgamode_s *vmode_g, int val) {
109 if (CONFIG_VGA_CIRRUS)
110 return clext_set_displaystart(vmode_g, val);
111 if (CONFIG_VGA_BOCHS)
112 return bochsvga_set_displaystart(vmode_g, val);
Kevin O'Connor7c790292014-02-11 15:34:58 -0500113 if (CONFIG_VGA_COREBOOT)
114 return cbvga_set_displaystart(vmode_g, val);
Kevin O'Connord61fc532012-01-27 20:37:45 -0500115 return stdvga_set_displaystart(vmode_g, val);
116}
117
Kevin O'Connore737b172012-02-04 11:08:39 -0500118static inline int vgahw_get_dacformat(struct vgamode_s *vmode_g) {
119 if (CONFIG_VGA_BOCHS)
120 return bochsvga_get_dacformat(vmode_g);
Kevin O'Connor7c790292014-02-11 15:34:58 -0500121 if (CONFIG_VGA_COREBOOT)
122 return cbvga_get_dacformat(vmode_g);
Kevin O'Connore737b172012-02-04 11:08:39 -0500123 return stdvga_get_dacformat(vmode_g);
124}
125
126static inline int vgahw_set_dacformat(struct vgamode_s *vmode_g, int val) {
127 if (CONFIG_VGA_BOCHS)
128 return bochsvga_set_dacformat(vmode_g, val);
Kevin O'Connor7c790292014-02-11 15:34:58 -0500129 if (CONFIG_VGA_COREBOOT)
130 return cbvga_set_dacformat(vmode_g, val);
Kevin O'Connore737b172012-02-04 11:08:39 -0500131 return stdvga_set_dacformat(vmode_g, val);
132}
133
Kevin O'Connor20dc4192014-02-05 20:52:25 -0500134static inline int vgahw_save_restore(int cmd, u16 seg, void *data) {
Kevin O'Connor2469f892012-02-04 12:40:02 -0500135 if (CONFIG_VGA_CIRRUS)
Kevin O'Connor20dc4192014-02-05 20:52:25 -0500136 return clext_save_restore(cmd, seg, data);
Kevin O'Connor2469f892012-02-04 12:40:02 -0500137 if (CONFIG_VGA_BOCHS)
Kevin O'Connor20dc4192014-02-05 20:52:25 -0500138 return bochsvga_save_restore(cmd, seg, data);
Kevin O'Connor7c790292014-02-11 15:34:58 -0500139 if (CONFIG_VGA_COREBOOT)
140 return cbvga_save_restore(cmd, seg, data);
Kevin O'Connor20dc4192014-02-05 20:52:25 -0500141 return stdvga_save_restore(cmd, seg, data);
Kevin O'Connor2469f892012-02-04 12:40:02 -0500142}
143
Kevin O'Connor5108c692011-12-31 19:13:45 -0500144#endif // vgahw.h