blob: 39f818ab5583966c9353a05c93ae2669d665f0cb [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'Connor5108c692011-12-31 19:13:45 -050012
Kevin O'Connor10dff3d2012-01-09 19:19:44 -050013static inline struct vgamode_s *vgahw_find_mode(int mode) {
Kevin O'Connorc4a0b972012-01-09 20:21:31 -050014 if (CONFIG_VGA_CIRRUS)
15 return clext_find_mode(mode);
16 if (CONFIG_VGA_BOCHS)
17 return bochsvga_find_mode(mode);
Kevin O'Connor7c790292014-02-11 15:34:58 -050018 if (CONFIG_VGA_COREBOOT)
19 return cbvga_find_mode(mode);
Kevin O'Connor10dff3d2012-01-09 19:19:44 -050020 return stdvga_find_mode(mode);
21}
22
Kevin O'Connore6bc4c12012-01-21 11:26:37 -050023static inline int vgahw_set_mode(struct vgamode_s *vmode_g, int flags) {
Kevin O'Connor5108c692011-12-31 19:13:45 -050024 if (CONFIG_VGA_CIRRUS)
Kevin O'Connore6bc4c12012-01-21 11:26:37 -050025 return clext_set_mode(vmode_g, flags);
Kevin O'Connor5108c692011-12-31 19:13:45 -050026 if (CONFIG_VGA_BOCHS)
Kevin O'Connore6bc4c12012-01-21 11:26:37 -050027 return bochsvga_set_mode(vmode_g, flags);
Kevin O'Connor7c790292014-02-11 15:34:58 -050028 if (CONFIG_VGA_COREBOOT)
29 return cbvga_set_mode(vmode_g, flags);
Kevin O'Connore6bc4c12012-01-21 11:26:37 -050030 return stdvga_set_mode(vmode_g, flags);
Kevin O'Connor5108c692011-12-31 19:13:45 -050031}
32
Kevin O'Connor34203cd2012-01-09 20:55:31 -050033static 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);
Kevin O'Connor7c790292014-02-11 15:34:58 -050038 else if (CONFIG_VGA_COREBOOT)
39 cbvga_list_modes(seg, dest, last);
Kevin O'Connor34203cd2012-01-09 20:55:31 -050040 else
41 stdvga_list_modes(seg, dest, last);
42}
43
Kevin O'Connord83c87b2013-01-21 01:14:12 -050044static inline int vgahw_setup(void) {
Kevin O'Connor161d2012011-12-31 19:42:21 -050045 if (CONFIG_VGA_CIRRUS)
Kevin O'Connord83c87b2013-01-21 01:14:12 -050046 return clext_setup();
Kevin O'Connor161d2012011-12-31 19:42:21 -050047 if (CONFIG_VGA_BOCHS)
Kevin O'Connord83c87b2013-01-21 01:14:12 -050048 return bochsvga_setup();
Nils24ddd862012-01-14 12:15:14 -050049 if (CONFIG_VGA_GEODEGX2 || CONFIG_VGA_GEODELX)
Kevin O'Connord83c87b2013-01-21 01:14:12 -050050 return geodevga_setup();
Kevin O'Connor7c790292014-02-11 15:34:58 -050051 if (CONFIG_VGA_COREBOOT)
52 return cbvga_setup();
Kevin O'Connord83c87b2013-01-21 01:14:12 -050053 return stdvga_setup();
Kevin O'Connor161d2012011-12-31 19:42:21 -050054}
55
Kevin O'Connor9961f992012-01-21 11:53:44 -050056static 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);
59 if (CONFIG_VGA_BOCHS)
60 return bochsvga_get_window(vmode_g, window);
Kevin O'Connor7c790292014-02-11 15:34:58 -050061 if (CONFIG_VGA_COREBOOT)
62 return cbvga_get_window(vmode_g, window);
Kevin O'Connor9961f992012-01-21 11:53:44 -050063 return stdvga_get_window(vmode_g, window);
64}
65
66static inline int vgahw_set_window(struct vgamode_s *vmode_g, int window
67 , int val) {
68 if (CONFIG_VGA_CIRRUS)
69 return clext_set_window(vmode_g, window, val);
70 if (CONFIG_VGA_BOCHS)
71 return bochsvga_set_window(vmode_g, window, val);
Kevin O'Connor7c790292014-02-11 15:34:58 -050072 if (CONFIG_VGA_COREBOOT)
73 return cbvga_set_window(vmode_g, window, val);
Kevin O'Connor9961f992012-01-21 11:53:44 -050074 return stdvga_set_window(vmode_g, window, val);
75}
76
Kevin O'Connor3876b532012-01-24 00:07:44 -050077static inline int vgahw_get_linelength(struct vgamode_s *vmode_g) {
78 if (CONFIG_VGA_CIRRUS)
79 return clext_get_linelength(vmode_g);
80 if (CONFIG_VGA_BOCHS)
81 return bochsvga_get_linelength(vmode_g);
Kevin O'Connor7c790292014-02-11 15:34:58 -050082 if (CONFIG_VGA_COREBOOT)
83 return cbvga_get_linelength(vmode_g);
Kevin O'Connor3876b532012-01-24 00:07:44 -050084 return stdvga_get_linelength(vmode_g);
85}
86
87static 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);
90 if (CONFIG_VGA_BOCHS)
91 return bochsvga_set_linelength(vmode_g, val);
Kevin O'Connor7c790292014-02-11 15:34:58 -050092 if (CONFIG_VGA_COREBOOT)
93 return cbvga_set_linelength(vmode_g, val);
Kevin O'Connor3876b532012-01-24 00:07:44 -050094 return stdvga_set_linelength(vmode_g, val);
95}
96
Kevin O'Connord61fc532012-01-27 20:37:45 -050097static 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);
Kevin O'Connor7c790292014-02-11 15:34:58 -0500102 if (CONFIG_VGA_COREBOOT)
103 return cbvga_get_displaystart(vmode_g);
Kevin O'Connord61fc532012-01-27 20:37:45 -0500104 return stdvga_get_displaystart(vmode_g);
105}
106
107static 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);
Kevin O'Connor7c790292014-02-11 15:34:58 -0500112 if (CONFIG_VGA_COREBOOT)
113 return cbvga_set_displaystart(vmode_g, val);
Kevin O'Connord61fc532012-01-27 20:37:45 -0500114 return stdvga_set_displaystart(vmode_g, val);
115}
116
Kevin O'Connore737b172012-02-04 11:08:39 -0500117static inline int vgahw_get_dacformat(struct vgamode_s *vmode_g) {
118 if (CONFIG_VGA_BOCHS)
119 return bochsvga_get_dacformat(vmode_g);
Kevin O'Connor7c790292014-02-11 15:34:58 -0500120 if (CONFIG_VGA_COREBOOT)
121 return cbvga_get_dacformat(vmode_g);
Kevin O'Connore737b172012-02-04 11:08:39 -0500122 return stdvga_get_dacformat(vmode_g);
123}
124
125static 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);
Kevin O'Connor7c790292014-02-11 15:34:58 -0500128 if (CONFIG_VGA_COREBOOT)
129 return cbvga_set_dacformat(vmode_g, val);
Kevin O'Connore737b172012-02-04 11:08:39 -0500130 return stdvga_set_dacformat(vmode_g, val);
131}
132
Kevin O'Connor20dc4192014-02-05 20:52:25 -0500133static inline int vgahw_save_restore(int cmd, u16 seg, void *data) {
Kevin O'Connor2469f892012-02-04 12:40:02 -0500134 if (CONFIG_VGA_CIRRUS)
Kevin O'Connor20dc4192014-02-05 20:52:25 -0500135 return clext_save_restore(cmd, seg, data);
Kevin O'Connor2469f892012-02-04 12:40:02 -0500136 if (CONFIG_VGA_BOCHS)
Kevin O'Connor20dc4192014-02-05 20:52:25 -0500137 return bochsvga_save_restore(cmd, seg, data);
Kevin O'Connor7c790292014-02-11 15:34:58 -0500138 if (CONFIG_VGA_COREBOOT)
139 return cbvga_save_restore(cmd, seg, data);
Kevin O'Connor20dc4192014-02-05 20:52:25 -0500140 return stdvga_save_restore(cmd, seg, data);
Kevin O'Connor2469f892012-02-04 12:40:02 -0500141}
142
Kevin O'Connor5108c692011-12-31 19:13:45 -0500143#endif // vgahw.h