From 66203df660ad2230389597a942f5252074a33aac Mon Sep 17 00:00:00 2001 From: Nico Huber Date: Mon, 7 Nov 2016 17:24:47 +0100 Subject: drivers/intel/gma: Add textmode support with libgfxinit Add an alternative gfxinit implementation for textmode. The legacy VGA plane and textmode is configured through coreboot provided functions. libgfxinit uses this plane as alternative to the usual high resolution plane. Change-Id: Iad0754c50fc6faec35f49583fe1c7cb50ac6c0c5 Signed-off-by: Nico Huber Reviewed-on: https://review.coreboot.org/17279 Tested-by: build bot (Jenkins) Reviewed-by: Arthur Heymans --- src/drivers/intel/gma/Makefile.inc | 6 +- src/drivers/intel/gma/gma.adb | 117 --------------------------------- src/drivers/intel/gma/hires_fb/gma.adb | 117 +++++++++++++++++++++++++++++++++ src/drivers/intel/gma/text_fb/gma.adb | 75 +++++++++++++++++++++ 4 files changed, 197 insertions(+), 118 deletions(-) delete mode 100644 src/drivers/intel/gma/gma.adb create mode 100644 src/drivers/intel/gma/hires_fb/gma.adb create mode 100644 src/drivers/intel/gma/text_fb/gma.adb (limited to 'src/drivers') diff --git a/src/drivers/intel/gma/Makefile.inc b/src/drivers/intel/gma/Makefile.inc index a4e007c373..d4d6c08842 100644 --- a/src/drivers/intel/gma/Makefile.inc +++ b/src/drivers/intel/gma/Makefile.inc @@ -40,6 +40,10 @@ CONFIG_GFX_GMA_DEFAULT_MMIO := 0 # dummy, will be overwritten at runtime subdirs-y += ../../../../3rdparty/libgfxinit ramstage-y += gma.ads -ramstage-y += gma.adb +ifeq ($(CONFIG_FRAMEBUFFER_KEEP_VESA_MODE),y) +ramstage-y += hires_fb/gma.adb +else +ramstage-y += text_fb/gma.adb +endif endif # CONFIG_MAINBOARD_USE_LIBGFXINIT diff --git a/src/drivers/intel/gma/gma.adb b/src/drivers/intel/gma/gma.adb deleted file mode 100644 index 7ebc4f88bc..0000000000 --- a/src/drivers/intel/gma/gma.adb +++ /dev/null @@ -1,117 +0,0 @@ -with HW.GFX; -with HW.GFX.Framebuffer_Filler; -with HW.GFX.GMA; - -use HW.GFX; -use HW.GFX.GMA; - -with GMA.Mainboard; - -package body GMA -is - - vbe_valid : boolean := false; - - linear_fb_addr : word64; - - fb : Framebuffer_Type; - - function vbe_mode_info_valid return Interfaces.C.int - is - begin - return (if vbe_valid then 1 else 0); - end vbe_mode_info_valid; - - procedure fill_lb_framebuffer (framebuffer : out lb_framebuffer) - is - use type word32; - begin - framebuffer := - (tag => 0, - size => 0, - physical_address => linear_fb_addr, - x_resolution => word32 (fb.Width), - y_resolution => word32 (fb.Height), - bytes_per_line => 4 * word32 (fb.Stride), - bits_per_pixel => 32, - reserved_mask_pos => 24, - reserved_mask_size => 8, - red_mask_pos => 16, - red_mask_size => 8, - green_mask_pos => 8, - green_mask_size => 8, - blue_mask_pos => 0, - blue_mask_size => 8); - end fill_lb_framebuffer; - - ---------------------------------------------------------------------------- - - procedure gfxinit - (mmio_base : in word64; - linear_fb : in word64; - phys_fb : in word32; - lightup_ok : out Interfaces.C.int) - is - use type pos32; - - ports : Port_List; - configs : Configs_Type; - - success : boolean; - - stride : Width_Type; - max_h : pos16 := 1; - max_v : pos16 := 1; - begin - lightup_ok := 0; - - HW.GFX.GMA.Initialize - (MMIO_Base => mmio_base, - Success => success); - - if success then - ports := Mainboard.ports; - HW.GFX.GMA.Scan_Ports (configs, ports); - - if configs (Primary).Port /= Disabled then - for i in Config_Index loop - exit when configs (i).Port = Disabled; - - max_h := pos16'max (max_h, configs (i).Mode.H_Visible); - max_v := pos16'max (max_v, configs (i).Mode.V_Visible); - end loop; - - stride := ((Width_Type (max_h) + 63) / 64) * 64; - for i in Config_Index loop - exit when configs (i).Port = Disabled; - - configs (i).Framebuffer := - (Width => Width_Type (configs (i).Mode.H_Visible), - Height => Height_Type (configs (i).Mode.V_Visible), - BPC => 8, - Stride => stride, - Offset => 0); - end loop; - - HW.GFX.GMA.Dump_Configs (configs); - - fb := - (Width => Width_Type (max_h), - Height => Height_Type (max_v), - BPC => 8, - Stride => stride, - Offset => 0); - HW.GFX.GMA.Setup_Default_GTT (fb, phys_fb); - HW.GFX.Framebuffer_Filler.Fill (linear_fb, fb); - - HW.GFX.GMA.Update_Outputs (configs); - - linear_fb_addr := linear_fb; - vbe_valid := true; - - lightup_ok := 1; - end if; - end if; - end gfxinit; - -end GMA; diff --git a/src/drivers/intel/gma/hires_fb/gma.adb b/src/drivers/intel/gma/hires_fb/gma.adb new file mode 100644 index 0000000000..7ebc4f88bc --- /dev/null +++ b/src/drivers/intel/gma/hires_fb/gma.adb @@ -0,0 +1,117 @@ +with HW.GFX; +with HW.GFX.Framebuffer_Filler; +with HW.GFX.GMA; + +use HW.GFX; +use HW.GFX.GMA; + +with GMA.Mainboard; + +package body GMA +is + + vbe_valid : boolean := false; + + linear_fb_addr : word64; + + fb : Framebuffer_Type; + + function vbe_mode_info_valid return Interfaces.C.int + is + begin + return (if vbe_valid then 1 else 0); + end vbe_mode_info_valid; + + procedure fill_lb_framebuffer (framebuffer : out lb_framebuffer) + is + use type word32; + begin + framebuffer := + (tag => 0, + size => 0, + physical_address => linear_fb_addr, + x_resolution => word32 (fb.Width), + y_resolution => word32 (fb.Height), + bytes_per_line => 4 * word32 (fb.Stride), + bits_per_pixel => 32, + reserved_mask_pos => 24, + reserved_mask_size => 8, + red_mask_pos => 16, + red_mask_size => 8, + green_mask_pos => 8, + green_mask_size => 8, + blue_mask_pos => 0, + blue_mask_size => 8); + end fill_lb_framebuffer; + + ---------------------------------------------------------------------------- + + procedure gfxinit + (mmio_base : in word64; + linear_fb : in word64; + phys_fb : in word32; + lightup_ok : out Interfaces.C.int) + is + use type pos32; + + ports : Port_List; + configs : Configs_Type; + + success : boolean; + + stride : Width_Type; + max_h : pos16 := 1; + max_v : pos16 := 1; + begin + lightup_ok := 0; + + HW.GFX.GMA.Initialize + (MMIO_Base => mmio_base, + Success => success); + + if success then + ports := Mainboard.ports; + HW.GFX.GMA.Scan_Ports (configs, ports); + + if configs (Primary).Port /= Disabled then + for i in Config_Index loop + exit when configs (i).Port = Disabled; + + max_h := pos16'max (max_h, configs (i).Mode.H_Visible); + max_v := pos16'max (max_v, configs (i).Mode.V_Visible); + end loop; + + stride := ((Width_Type (max_h) + 63) / 64) * 64; + for i in Config_Index loop + exit when configs (i).Port = Disabled; + + configs (i).Framebuffer := + (Width => Width_Type (configs (i).Mode.H_Visible), + Height => Height_Type (configs (i).Mode.V_Visible), + BPC => 8, + Stride => stride, + Offset => 0); + end loop; + + HW.GFX.GMA.Dump_Configs (configs); + + fb := + (Width => Width_Type (max_h), + Height => Height_Type (max_v), + BPC => 8, + Stride => stride, + Offset => 0); + HW.GFX.GMA.Setup_Default_GTT (fb, phys_fb); + HW.GFX.Framebuffer_Filler.Fill (linear_fb, fb); + + HW.GFX.GMA.Update_Outputs (configs); + + linear_fb_addr := linear_fb; + vbe_valid := true; + + lightup_ok := 1; + end if; + end if; + end gfxinit; + +end GMA; diff --git a/src/drivers/intel/gma/text_fb/gma.adb b/src/drivers/intel/gma/text_fb/gma.adb new file mode 100644 index 0000000000..bbb6d74e3d --- /dev/null +++ b/src/drivers/intel/gma/text_fb/gma.adb @@ -0,0 +1,75 @@ +with HW.GFX; +with HW.GFX.GMA; + +use HW.GFX; +use HW.GFX.GMA; + +with GMA.Mainboard; + +package body GMA +is + + function vbe_mode_info_valid return Interfaces.C.int + is + begin + return 0; + end vbe_mode_info_valid; + + procedure fill_lb_framebuffer (framebuffer : out lb_framebuffer) + is + begin + null; + end fill_lb_framebuffer; + + ---------------------------------------------------------------------------- + + procedure gfxinit + (mmio_base : in word64; + linear_fb : in word64; + phys_fb : in word32; + lightup_ok : out Interfaces.C.int) + is + ports : Port_List; + configs : Configs_Type; + + success : boolean; + + -- from pc80/vga driver + procedure vga_io_init; + pragma Import (C, vga_io_init, "vga_io_init"); + procedure vga_textmode_init; + pragma Import (C, vga_textmode_init, "vga_textmode_init"); + begin + lightup_ok := 0; + + HW.GFX.GMA.Initialize + (MMIO_Base => mmio_base, + Success => success); + + if success then + ports := Mainboard.ports; + HW.GFX.GMA.Scan_Ports + (Configs => configs, + Ports => ports, + Max_Pipe => Primary); + + if configs (Primary).Port /= Disabled then + vga_io_init; + vga_textmode_init; + + configs (Primary).Framebuffer := + (Width => 640, + Height => 400, + BPC => Auto_BPC, -- ignored for VGA plane + Stride => 320, -- ignored + Offset => VGA_PLANE_FRAMEBUFFER_OFFSET); + + HW.GFX.GMA.Dump_Configs (configs); + HW.GFX.GMA.Update_Outputs (configs); + + lightup_ok := 1; + end if; + end if; + end gfxinit; + +end GMA; -- cgit v1.2.3