aboutsummaryrefslogtreecommitdiffstats
path: root/vgasrc/stdvga.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2012-01-24 00:07:44 -0500
committerKevin O'Connor <kevin@koconnor.net>2012-02-01 20:38:49 -0500
commit3876b531222c53124b0eb154fb331c0c662f5e09 (patch)
tree23f39e04767b1da3b8983ab1432821ee95bdc42c /vgasrc/stdvga.c
parent9961f9958cbc169c531dbdb7c3a8f71d4f79d0c1 (diff)
downloadseabios-3876b531222c53124b0eb154fb331c0c662f5e09.tar.gz
vgabios: Add support for vbe get/set line length function.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'vgasrc/stdvga.c')
-rw-r--r--vgasrc/stdvga.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/vgasrc/stdvga.c b/vgasrc/stdvga.c
index 9c0cba93..a310167a 100644
--- a/vgasrc/stdvga.c
+++ b/vgasrc/stdvga.c
@@ -229,6 +229,22 @@ stdvga_get_crtc(void)
return VGAREG_MDA_CRTC_ADDRESS;
}
+// Return the multiplication factor needed for the vga offset register.
+int
+stdvga_bpp_factor(struct vgamode_s *vmode_g)
+{
+ switch (GET_GLOBAL(vmode_g->memmodel)) {
+ case MM_TEXT:
+ return 2;
+ case MM_CGA:
+ return GET_GLOBAL(vmode_g->depth);
+ case MM_PLANAR:
+ return 1;
+ default:
+ return 4;
+ }
+}
+
void
stdvga_set_cursor_shape(u8 start, u8 end)
{
@@ -282,6 +298,21 @@ stdvga_set_window(struct vgamode_s *vmode_g, int window, int val)
return -1;
}
+int
+stdvga_get_linelength(struct vgamode_s *vmode_g)
+{
+ u8 val = stdvga_crtc_read(stdvga_get_crtc(), 0x13);
+ return val * stdvga_bpp_factor(vmode_g) * 2;
+}
+
+int
+stdvga_set_linelength(struct vgamode_s *vmode_g, int val)
+{
+ int factor = stdvga_bpp_factor(vmode_g) * 2;
+ stdvga_crtc_write(stdvga_get_crtc(), 0x13, DIV_ROUND_UP(val, factor));
+ return 0;
+}
+
/****************************************************************
* Save/Restore/Set state