blob: 8b64660e5ef70d71b440013300bc6a63a5b9a05a [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);
Gerd Hoffmann34b6ecc2019-02-25 10:51:37 +010015 if (CONFIG_VGA_ATI)
16 return ati_find_mode(mode);
Kevin O'Connorc4a0b972012-01-09 20:21:31 -050017 if (CONFIG_VGA_BOCHS)
18 return bochsvga_find_mode(mode);
Gerd Hoffmannd9a8b862017-11-15 14:43:10 +010019 if (CONFIG_VGA_EMULATE_TEXT)
Kevin O'Connor7c790292014-02-11 15:34:58 -050020 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);
Gerd Hoffmann34b6ecc2019-02-25 10:51:37 +010027 if (CONFIG_VGA_ATI)
28 return ati_set_mode(vmode_g, flags);
Kevin O'Connor5108c692011-12-31 19:13:45 -050029 if (CONFIG_VGA_BOCHS)
Kevin O'Connore6bc4c12012-01-21 11:26:37 -050030 return bochsvga_set_mode(vmode_g, flags);
Gerd Hoffmannd9a8b862017-11-15 14:43:10 +010031 if (CONFIG_VGA_EMULATE_TEXT)
Kevin O'Connor7c790292014-02-11 15:34:58 -050032 return cbvga_set_mode(vmode_g, flags);
Kevin O'Connore6bc4c12012-01-21 11:26:37 -050033 return stdvga_set_mode(vmode_g, flags);
Kevin O'Connor5108c692011-12-31 19:13:45 -050034}
35
Kevin O'Connor34203cd2012-01-09 20:55:31 -050036static inline void vgahw_list_modes(u16 seg, u16 *dest, u16 *last) {
37 if (CONFIG_VGA_CIRRUS)
38 clext_list_modes(seg, dest, last);
Gerd Hoffmannd11c7512020-06-25 11:17:09 +020039 else if (CONFIG_VGA_ATI)
Gerd Hoffmann34b6ecc2019-02-25 10:51:37 +010040 ati_list_modes(seg, dest, last);
Kevin O'Connor34203cd2012-01-09 20:55:31 -050041 else if (CONFIG_VGA_BOCHS)
42 bochsvga_list_modes(seg, dest, last);
Gerd Hoffmannd9a8b862017-11-15 14:43:10 +010043 else if (CONFIG_VGA_EMULATE_TEXT)
Kevin O'Connor7c790292014-02-11 15:34:58 -050044 cbvga_list_modes(seg, dest, last);
Kevin O'Connor34203cd2012-01-09 20:55:31 -050045 else
46 stdvga_list_modes(seg, dest, last);
47}
48
Kevin O'Connord83c87b2013-01-21 01:14:12 -050049static inline int vgahw_setup(void) {
Kevin O'Connor161d2012011-12-31 19:42:21 -050050 if (CONFIG_VGA_CIRRUS)
Kevin O'Connord83c87b2013-01-21 01:14:12 -050051 return clext_setup();
Gerd Hoffmann34b6ecc2019-02-25 10:51:37 +010052 if (CONFIG_VGA_ATI)
53 return ati_setup();
Kevin O'Connor161d2012011-12-31 19:42:21 -050054 if (CONFIG_VGA_BOCHS)
Kevin O'Connord83c87b2013-01-21 01:14:12 -050055 return bochsvga_setup();
Nils24ddd862012-01-14 12:15:14 -050056 if (CONFIG_VGA_GEODEGX2 || CONFIG_VGA_GEODELX)
Kevin O'Connord83c87b2013-01-21 01:14:12 -050057 return geodevga_setup();
Kevin O'Connor7c790292014-02-11 15:34:58 -050058 if (CONFIG_VGA_COREBOOT)
59 return cbvga_setup();
Gerd Hoffmann77404b42017-11-15 14:43:10 +010060 if (CONFIG_DISPLAY_BOCHS)
61 return bochs_display_setup();
Gerd Hoffmannd9a8b862017-11-15 14:43:10 +010062 if (CONFIG_VGA_RAMFB)
63 return ramfb_setup();
Kevin O'Connord83c87b2013-01-21 01:14:12 -050064 return stdvga_setup();
Kevin O'Connor161d2012011-12-31 19:42:21 -050065}
66
Kevin O'Connor9961f992012-01-21 11:53:44 -050067static inline int vgahw_get_window(struct vgamode_s *vmode_g, int window) {
68 if (CONFIG_VGA_CIRRUS)
69 return clext_get_window(vmode_g, window);
70 if (CONFIG_VGA_BOCHS)
71 return bochsvga_get_window(vmode_g, window);
Gerd Hoffmannd9a8b862017-11-15 14:43:10 +010072 if (CONFIG_VGA_EMULATE_TEXT)
Kevin O'Connor7c790292014-02-11 15:34:58 -050073 return cbvga_get_window(vmode_g, window);
Kevin O'Connor9961f992012-01-21 11:53:44 -050074 return stdvga_get_window(vmode_g, window);
75}
76
77static inline int vgahw_set_window(struct vgamode_s *vmode_g, int window
78 , int val) {
79 if (CONFIG_VGA_CIRRUS)
80 return clext_set_window(vmode_g, window, val);
81 if (CONFIG_VGA_BOCHS)
82 return bochsvga_set_window(vmode_g, window, val);
Gerd Hoffmannd9a8b862017-11-15 14:43:10 +010083 if (CONFIG_VGA_EMULATE_TEXT)
Kevin O'Connor7c790292014-02-11 15:34:58 -050084 return cbvga_set_window(vmode_g, window, val);
Kevin O'Connor9961f992012-01-21 11:53:44 -050085 return stdvga_set_window(vmode_g, window, val);
86}
87
Kevin O'Connor3876b532012-01-24 00:07:44 -050088static inline int vgahw_get_linelength(struct vgamode_s *vmode_g) {
89 if (CONFIG_VGA_CIRRUS)
90 return clext_get_linelength(vmode_g);
91 if (CONFIG_VGA_BOCHS)
92 return bochsvga_get_linelength(vmode_g);
Gerd Hoffmannd9a8b862017-11-15 14:43:10 +010093 if (CONFIG_VGA_EMULATE_TEXT)
Kevin O'Connor7c790292014-02-11 15:34:58 -050094 return cbvga_get_linelength(vmode_g);
Kevin O'Connor3876b532012-01-24 00:07:44 -050095 return stdvga_get_linelength(vmode_g);
96}
97
98static inline int vgahw_set_linelength(struct vgamode_s *vmode_g, int val) {
99 if (CONFIG_VGA_CIRRUS)
100 return clext_set_linelength(vmode_g, val);
101 if (CONFIG_VGA_BOCHS)
102 return bochsvga_set_linelength(vmode_g, val);
Gerd Hoffmannd9a8b862017-11-15 14:43:10 +0100103 if (CONFIG_VGA_EMULATE_TEXT)
Kevin O'Connor7c790292014-02-11 15:34:58 -0500104 return cbvga_set_linelength(vmode_g, val);
Kevin O'Connor3876b532012-01-24 00:07:44 -0500105 return stdvga_set_linelength(vmode_g, val);
106}
107
Kevin O'Connord61fc532012-01-27 20:37:45 -0500108static inline int vgahw_get_displaystart(struct vgamode_s *vmode_g) {
109 if (CONFIG_VGA_CIRRUS)
110 return clext_get_displaystart(vmode_g);
111 if (CONFIG_VGA_BOCHS)
112 return bochsvga_get_displaystart(vmode_g);
Gerd Hoffmannd9a8b862017-11-15 14:43:10 +0100113 if (CONFIG_VGA_EMULATE_TEXT)
Kevin O'Connor7c790292014-02-11 15:34:58 -0500114 return cbvga_get_displaystart(vmode_g);
Kevin O'Connord61fc532012-01-27 20:37:45 -0500115 return stdvga_get_displaystart(vmode_g);
116}
117
118static inline int vgahw_set_displaystart(struct vgamode_s *vmode_g, int val) {
119 if (CONFIG_VGA_CIRRUS)
120 return clext_set_displaystart(vmode_g, val);
121 if (CONFIG_VGA_BOCHS)
122 return bochsvga_set_displaystart(vmode_g, val);
Gerd Hoffmannd9a8b862017-11-15 14:43:10 +0100123 if (CONFIG_VGA_EMULATE_TEXT)
Kevin O'Connor7c790292014-02-11 15:34:58 -0500124 return cbvga_set_displaystart(vmode_g, val);
Kevin O'Connord61fc532012-01-27 20:37:45 -0500125 return stdvga_set_displaystart(vmode_g, val);
126}
127
Kevin O'Connore737b172012-02-04 11:08:39 -0500128static inline int vgahw_get_dacformat(struct vgamode_s *vmode_g) {
129 if (CONFIG_VGA_BOCHS)
130 return bochsvga_get_dacformat(vmode_g);
Gerd Hoffmannd9a8b862017-11-15 14:43:10 +0100131 if (CONFIG_VGA_EMULATE_TEXT)
Kevin O'Connor7c790292014-02-11 15:34:58 -0500132 return cbvga_get_dacformat(vmode_g);
Kevin O'Connore737b172012-02-04 11:08:39 -0500133 return stdvga_get_dacformat(vmode_g);
134}
135
136static inline int vgahw_set_dacformat(struct vgamode_s *vmode_g, int val) {
137 if (CONFIG_VGA_BOCHS)
138 return bochsvga_set_dacformat(vmode_g, val);
Gerd Hoffmannd9a8b862017-11-15 14:43:10 +0100139 if (CONFIG_VGA_EMULATE_TEXT)
Kevin O'Connor7c790292014-02-11 15:34:58 -0500140 return cbvga_set_dacformat(vmode_g, val);
Kevin O'Connore737b172012-02-04 11:08:39 -0500141 return stdvga_set_dacformat(vmode_g, val);
142}
143
Kevin O'Connor20dc4192014-02-05 20:52:25 -0500144static inline int vgahw_save_restore(int cmd, u16 seg, void *data) {
Kevin O'Connor2469f892012-02-04 12:40:02 -0500145 if (CONFIG_VGA_CIRRUS)
Kevin O'Connor20dc4192014-02-05 20:52:25 -0500146 return clext_save_restore(cmd, seg, data);
Kevin O'Connor2469f892012-02-04 12:40:02 -0500147 if (CONFIG_VGA_BOCHS)
Kevin O'Connor20dc4192014-02-05 20:52:25 -0500148 return bochsvga_save_restore(cmd, seg, data);
Gerd Hoffmannd9a8b862017-11-15 14:43:10 +0100149 if (CONFIG_VGA_EMULATE_TEXT)
Kevin O'Connor7c790292014-02-11 15:34:58 -0500150 return cbvga_save_restore(cmd, seg, data);
Kevin O'Connor20dc4192014-02-05 20:52:25 -0500151 return stdvga_save_restore(cmd, seg, data);
Kevin O'Connor2469f892012-02-04 12:40:02 -0500152}
153
Patrick Rudolph4902b8a2017-05-29 19:25:12 +0200154static inline int vgahw_get_linesize(struct vgamode_s *vmode_g) {
Gerd Hoffmannd9a8b862017-11-15 14:43:10 +0100155 if (CONFIG_VGA_EMULATE_TEXT)
Patrick Rudolph4902b8a2017-05-29 19:25:12 +0200156 return cbvga_get_linesize(vmode_g);
157 return stdvga_get_linesize(vmode_g);
158}
159
Kevin O'Connor5108c692011-12-31 19:13:45 -0500160#endif // vgahw.h