Kevin O'Connor | 5108c69 | 2011-12-31 19:13:45 -0500 | [diff] [blame] | 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 |
Kevin O'Connor | d83c87b | 2013-01-21 01:14:12 -0500 | [diff] [blame] | 10 | #include "geodevga.h" // geodevga_setup |
Kevin O'Connor | 5108c69 | 2011-12-31 19:13:45 -0500 | [diff] [blame] | 11 | |
Kevin O'Connor | 10dff3d | 2012-01-09 19:19:44 -0500 | [diff] [blame] | 12 | static inline struct vgamode_s *vgahw_find_mode(int mode) { |
Kevin O'Connor | c4a0b97 | 2012-01-09 20:21:31 -0500 | [diff] [blame] | 13 | if (CONFIG_VGA_CIRRUS) |
| 14 | return clext_find_mode(mode); |
| 15 | if (CONFIG_VGA_BOCHS) |
| 16 | return bochsvga_find_mode(mode); |
Kevin O'Connor | 10dff3d | 2012-01-09 19:19:44 -0500 | [diff] [blame] | 17 | return stdvga_find_mode(mode); |
| 18 | } |
| 19 | |
Kevin O'Connor | e6bc4c1 | 2012-01-21 11:26:37 -0500 | [diff] [blame] | 20 | static inline int vgahw_set_mode(struct vgamode_s *vmode_g, int flags) { |
Kevin O'Connor | 5108c69 | 2011-12-31 19:13:45 -0500 | [diff] [blame] | 21 | if (CONFIG_VGA_CIRRUS) |
Kevin O'Connor | e6bc4c1 | 2012-01-21 11:26:37 -0500 | [diff] [blame] | 22 | return clext_set_mode(vmode_g, flags); |
Kevin O'Connor | 5108c69 | 2011-12-31 19:13:45 -0500 | [diff] [blame] | 23 | if (CONFIG_VGA_BOCHS) |
Kevin O'Connor | e6bc4c1 | 2012-01-21 11:26:37 -0500 | [diff] [blame] | 24 | return bochsvga_set_mode(vmode_g, flags); |
| 25 | return stdvga_set_mode(vmode_g, flags); |
Kevin O'Connor | 5108c69 | 2011-12-31 19:13:45 -0500 | [diff] [blame] | 26 | } |
| 27 | |
Kevin O'Connor | 34203cd | 2012-01-09 20:55:31 -0500 | [diff] [blame] | 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 | |
Kevin O'Connor | d83c87b | 2013-01-21 01:14:12 -0500 | [diff] [blame] | 37 | static inline int vgahw_setup(void) { |
Kevin O'Connor | 161d201 | 2011-12-31 19:42:21 -0500 | [diff] [blame] | 38 | if (CONFIG_VGA_CIRRUS) |
Kevin O'Connor | d83c87b | 2013-01-21 01:14:12 -0500 | [diff] [blame] | 39 | return clext_setup(); |
Kevin O'Connor | 161d201 | 2011-12-31 19:42:21 -0500 | [diff] [blame] | 40 | if (CONFIG_VGA_BOCHS) |
Kevin O'Connor | d83c87b | 2013-01-21 01:14:12 -0500 | [diff] [blame] | 41 | return bochsvga_setup(); |
Nils | 24ddd86 | 2012-01-14 12:15:14 -0500 | [diff] [blame] | 42 | if (CONFIG_VGA_GEODEGX2 || CONFIG_VGA_GEODELX) |
Kevin O'Connor | d83c87b | 2013-01-21 01:14:12 -0500 | [diff] [blame] | 43 | return geodevga_setup(); |
| 44 | return stdvga_setup(); |
Kevin O'Connor | 161d201 | 2011-12-31 19:42:21 -0500 | [diff] [blame] | 45 | } |
| 46 | |
Kevin O'Connor | 9961f99 | 2012-01-21 11:53:44 -0500 | [diff] [blame] | 47 | static inline int vgahw_get_window(struct vgamode_s *vmode_g, int window) { |
| 48 | if (CONFIG_VGA_CIRRUS) |
| 49 | return clext_get_window(vmode_g, window); |
| 50 | if (CONFIG_VGA_BOCHS) |
| 51 | return bochsvga_get_window(vmode_g, window); |
| 52 | return stdvga_get_window(vmode_g, window); |
| 53 | } |
| 54 | |
| 55 | static inline int vgahw_set_window(struct vgamode_s *vmode_g, int window |
| 56 | , int val) { |
| 57 | if (CONFIG_VGA_CIRRUS) |
| 58 | return clext_set_window(vmode_g, window, val); |
| 59 | if (CONFIG_VGA_BOCHS) |
| 60 | return bochsvga_set_window(vmode_g, window, val); |
| 61 | return stdvga_set_window(vmode_g, window, val); |
| 62 | } |
| 63 | |
Kevin O'Connor | 3876b53 | 2012-01-24 00:07:44 -0500 | [diff] [blame] | 64 | static inline int vgahw_get_linelength(struct vgamode_s *vmode_g) { |
| 65 | if (CONFIG_VGA_CIRRUS) |
| 66 | return clext_get_linelength(vmode_g); |
| 67 | if (CONFIG_VGA_BOCHS) |
| 68 | return bochsvga_get_linelength(vmode_g); |
| 69 | return stdvga_get_linelength(vmode_g); |
| 70 | } |
| 71 | |
| 72 | static inline int vgahw_set_linelength(struct vgamode_s *vmode_g, int val) { |
| 73 | if (CONFIG_VGA_CIRRUS) |
| 74 | return clext_set_linelength(vmode_g, val); |
| 75 | if (CONFIG_VGA_BOCHS) |
| 76 | return bochsvga_set_linelength(vmode_g, val); |
| 77 | return stdvga_set_linelength(vmode_g, val); |
| 78 | } |
| 79 | |
Kevin O'Connor | d61fc53 | 2012-01-27 20:37:45 -0500 | [diff] [blame] | 80 | static inline int vgahw_get_displaystart(struct vgamode_s *vmode_g) { |
| 81 | if (CONFIG_VGA_CIRRUS) |
| 82 | return clext_get_displaystart(vmode_g); |
| 83 | if (CONFIG_VGA_BOCHS) |
| 84 | return bochsvga_get_displaystart(vmode_g); |
| 85 | return stdvga_get_displaystart(vmode_g); |
| 86 | } |
| 87 | |
| 88 | static inline int vgahw_set_displaystart(struct vgamode_s *vmode_g, int val) { |
| 89 | if (CONFIG_VGA_CIRRUS) |
| 90 | return clext_set_displaystart(vmode_g, val); |
| 91 | if (CONFIG_VGA_BOCHS) |
| 92 | return bochsvga_set_displaystart(vmode_g, val); |
| 93 | return stdvga_set_displaystart(vmode_g, val); |
| 94 | } |
| 95 | |
Kevin O'Connor | e737b17 | 2012-02-04 11:08:39 -0500 | [diff] [blame] | 96 | static inline int vgahw_get_dacformat(struct vgamode_s *vmode_g) { |
| 97 | if (CONFIG_VGA_BOCHS) |
| 98 | return bochsvga_get_dacformat(vmode_g); |
| 99 | return stdvga_get_dacformat(vmode_g); |
| 100 | } |
| 101 | |
| 102 | static inline int vgahw_set_dacformat(struct vgamode_s *vmode_g, int val) { |
| 103 | if (CONFIG_VGA_BOCHS) |
| 104 | return bochsvga_set_dacformat(vmode_g, val); |
| 105 | return stdvga_set_dacformat(vmode_g, val); |
| 106 | } |
| 107 | |
Kevin O'Connor | 2469f89 | 2012-02-04 12:40:02 -0500 | [diff] [blame] | 108 | static inline int vgahw_size_state(int states) { |
| 109 | if (CONFIG_VGA_CIRRUS) |
| 110 | return clext_size_state(states); |
| 111 | if (CONFIG_VGA_BOCHS) |
| 112 | return bochsvga_size_state(states); |
| 113 | return stdvga_size_state(states); |
| 114 | } |
| 115 | |
| 116 | static inline int vgahw_save_state(u16 seg, void *data, int states) { |
| 117 | if (CONFIG_VGA_CIRRUS) |
| 118 | return clext_save_state(seg, data, states); |
| 119 | if (CONFIG_VGA_BOCHS) |
| 120 | return bochsvga_save_state(seg, data, states); |
| 121 | return stdvga_save_state(seg, data, states); |
| 122 | } |
| 123 | |
| 124 | static inline int vgahw_restore_state(u16 seg, void *data, int states) { |
| 125 | if (CONFIG_VGA_CIRRUS) |
| 126 | return clext_restore_state(seg, data, states); |
| 127 | if (CONFIG_VGA_BOCHS) |
| 128 | return bochsvga_restore_state(seg, data, states); |
| 129 | return stdvga_restore_state(seg, data, states); |
| 130 | } |
| 131 | |
Kevin O'Connor | 5108c69 | 2011-12-31 19:13:45 -0500 | [diff] [blame] | 132 | #endif // vgahw.h |