From 7458629de369a220ea24afdfbf5f1dc9fdc36a5e Mon Sep 17 00:00:00 2001 From: Nico Huber Date: Mon, 18 Feb 2019 01:21:11 +0100 Subject: drivers/intel/gma: Move gfxinit into sub package Move the actual graphics init provided by libgfxinit into a sub package `GMA.GFX_Init`. This way it can be compiled in individually. Change-Id: Ib413a0d70c8dc305f4476c1d5aee6b81ff880bec Signed-off-by: Nico Huber Reviewed-on: https://review.coreboot.org/c/coreboot/+/31456 Reviewed-by: Patrick Georgi Tested-by: build bot (Jenkins) --- src/drivers/intel/gma/Makefile.inc | 8 +- src/drivers/intel/gma/gma-gfx_init.ads | 38 ++++++++ src/drivers/intel/gma/gma.ads | 38 +------- src/drivers/intel/gma/hires_fb/gma-gfx_init.adb | 117 ++++++++++++++++++++++++ src/drivers/intel/gma/hires_fb/gma.adb | 117 ------------------------ src/drivers/intel/gma/text_fb/gma-gfx_init.adb | 68 ++++++++++++++ src/drivers/intel/gma/text_fb/gma.adb | 68 -------------- 7 files changed, 229 insertions(+), 225 deletions(-) create mode 100644 src/drivers/intel/gma/gma-gfx_init.ads create mode 100644 src/drivers/intel/gma/hires_fb/gma-gfx_init.adb delete mode 100644 src/drivers/intel/gma/hires_fb/gma.adb create mode 100644 src/drivers/intel/gma/text_fb/gma-gfx_init.adb delete mode 100644 src/drivers/intel/gma/text_fb/gma.adb diff --git a/src/drivers/intel/gma/Makefile.inc b/src/drivers/intel/gma/Makefile.inc index ebc688f990..e128ad6474 100644 --- a/src/drivers/intel/gma/Makefile.inc +++ b/src/drivers/intel/gma/Makefile.inc @@ -50,11 +50,13 @@ CONFIG_GFX_GMA_DEFAULT_MMIO := 0 # dummy, will be overwritten at runtime subdirs-y += ../../../../3rdparty/libgfxinit -ramstage-$(CONFIG_MAINBOARD_USE_LIBGFXINIT) += gma.ads +ramstage-y += gma.ads + +ramstage-$(CONFIG_MAINBOARD_USE_LIBGFXINIT) += gma-gfx_init.ads ifeq ($(CONFIG_LINEAR_FRAMEBUFFER),y) -ramstage-$(CONFIG_MAINBOARD_USE_LIBGFXINIT) += hires_fb/gma.adb +ramstage-$(CONFIG_MAINBOARD_USE_LIBGFXINIT) += hires_fb/gma-gfx_init.adb else -ramstage-$(CONFIG_MAINBOARD_USE_LIBGFXINIT) += text_fb/gma.adb +ramstage-$(CONFIG_MAINBOARD_USE_LIBGFXINIT) += text_fb/gma-gfx_init.adb endif endif # CONFIG_GFX_GMA diff --git a/src/drivers/intel/gma/gma-gfx_init.ads b/src/drivers/intel/gma/gma-gfx_init.ads new file mode 100644 index 0000000000..7c96f9adf7 --- /dev/null +++ b/src/drivers/intel/gma/gma-gfx_init.ads @@ -0,0 +1,38 @@ +with Interfaces.C; + +with HW; +use HW; + +package GMA.GFX_Init +is + + procedure gfxinit (lightup_ok : out Interfaces.C.int); + pragma Export (C, gfxinit, "gma_gfxinit"); + + ---------------------------------------------------------------------------- + + type lb_framebuffer is record + tag : word32; + size : word32; + + physical_address : word64; + x_resolution : word32; + y_resolution : word32; + bytes_per_line : word32; + bits_per_pixel : word8; + red_mask_pos : word8; + red_mask_size : word8; + green_mask_pos : word8; + green_mask_size : word8; + blue_mask_pos : word8; + blue_mask_size : word8; + reserved_mask_pos : word8; + reserved_mask_size : word8; + end record; + + function fill_lb_framebuffer + (framebuffer : in out lb_framebuffer) + return Interfaces.C.int; + pragma Export (C, fill_lb_framebuffer, "fill_lb_framebuffer"); + +end GMA.GFX_Init; diff --git a/src/drivers/intel/gma/gma.ads b/src/drivers/intel/gma/gma.ads index 7286e7e568..a6ce3a4f77 100644 --- a/src/drivers/intel/gma/gma.ads +++ b/src/drivers/intel/gma/gma.ads @@ -1,38 +1,2 @@ -with Interfaces.C; - -with HW; -use HW; - -package GMA -is - - procedure gfxinit (lightup_ok : out Interfaces.C.int); - pragma Export (C, gfxinit, "gma_gfxinit"); - - ---------------------------------------------------------------------------- - - type lb_framebuffer is record - tag : word32; - size : word32; - - physical_address : word64; - x_resolution : word32; - y_resolution : word32; - bytes_per_line : word32; - bits_per_pixel : word8; - red_mask_pos : word8; - red_mask_size : word8; - green_mask_pos : word8; - green_mask_size : word8; - blue_mask_pos : word8; - blue_mask_size : word8; - reserved_mask_pos : word8; - reserved_mask_size : word8; - end record; - - function fill_lb_framebuffer - (framebuffer : in out lb_framebuffer) - return Interfaces.C.int; - pragma Export (C, fill_lb_framebuffer, "fill_lb_framebuffer"); - +package GMA is end GMA; diff --git a/src/drivers/intel/gma/hires_fb/gma-gfx_init.adb b/src/drivers/intel/gma/hires_fb/gma-gfx_init.adb new file mode 100644 index 0000000000..1393784d7b --- /dev/null +++ b/src/drivers/intel/gma/hires_fb/gma-gfx_init.adb @@ -0,0 +1,117 @@ +with CB.Config; + +use CB; + +with HW.GFX; +with HW.GFX.Framebuffer_Filler; +with HW.GFX.GMA; +with HW.GFX.GMA.Display_Probing; + +use HW.GFX; +use HW.GFX.GMA; +use HW.GFX.GMA.Display_Probing; + +with GMA.Mainboard; + +package body GMA.GFX_Init +is + + fb_valid : boolean := false; + + linear_fb_addr : word64; + + fb : Framebuffer_Type; + + function fill_lb_framebuffer + (framebuffer : in out lb_framebuffer) + return Interfaces.C.int + is + use type word32; + use type Interfaces.C.int; + begin + if fb_valid then + 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); + return 0; + else + return -1; + end if; + end fill_lb_framebuffer; + + ---------------------------------------------------------------------------- + + procedure gfxinit (lightup_ok : out Interfaces.C.int) + is + use type pos32; + use type word64; + + ports : Port_List; + configs : Pipe_Configs; + + success : boolean; + + min_h : pos32 := Config.LINEAR_FRAMEBUFFER_MAX_WIDTH; + min_v : pos32 := Config.LINEAR_FRAMEBUFFER_MAX_HEIGHT; + begin + lightup_ok := 0; + + HW.GFX.GMA.Initialize (Success => success); + + if success then + ports := Mainboard.ports; + HW.GFX.GMA.Display_Probing.Scan_Ports (configs, ports); + + if configs (Primary).Port /= Disabled then + for i in Pipe_Index loop + exit when configs (i).Port = Disabled; + + min_h := pos32'min (min_h, configs (i).Mode.H_Visible); + min_v := pos32'min (min_v, configs (i).Mode.V_Visible); + end loop; + + fb := configs (Primary).Framebuffer; + fb.Width := Width_Type (min_h); + fb.Height := Height_Type (min_v); + fb.Stride := Div_Round_Up (fb.Width, 16) * 16; + fb.V_Stride := fb.Height; + + for i in Pipe_Index loop + exit when configs (i).Port = Disabled; + + configs (i).Framebuffer := fb; + end loop; + + HW.GFX.GMA.Dump_Configs (configs); + + HW.GFX.GMA.Setup_Default_FB + (FB => fb, + Clear => true, + Success => success); + + if success then + HW.GFX.GMA.Update_Outputs (configs); + + HW.GFX.GMA.Map_Linear_FB (linear_fb_addr, fb); + fb_valid := linear_fb_addr /= 0; + + lightup_ok := (if fb_valid then 1 else 0); + end if; + end if; + end if; + end gfxinit; + +end GMA.GFX_Init; diff --git a/src/drivers/intel/gma/hires_fb/gma.adb b/src/drivers/intel/gma/hires_fb/gma.adb deleted file mode 100644 index e3553ca3c0..0000000000 --- a/src/drivers/intel/gma/hires_fb/gma.adb +++ /dev/null @@ -1,117 +0,0 @@ -with CB.Config; - -use CB; - -with HW.GFX; -with HW.GFX.Framebuffer_Filler; -with HW.GFX.GMA; -with HW.GFX.GMA.Display_Probing; - -use HW.GFX; -use HW.GFX.GMA; -use HW.GFX.GMA.Display_Probing; - -with GMA.Mainboard; - -package body GMA -is - - fb_valid : boolean := false; - - linear_fb_addr : word64; - - fb : Framebuffer_Type; - - function fill_lb_framebuffer - (framebuffer : in out lb_framebuffer) - return Interfaces.C.int - is - use type word32; - use type Interfaces.C.int; - begin - if fb_valid then - 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); - return 0; - else - return -1; - end if; - end fill_lb_framebuffer; - - ---------------------------------------------------------------------------- - - procedure gfxinit (lightup_ok : out Interfaces.C.int) - is - use type pos32; - use type word64; - - ports : Port_List; - configs : Pipe_Configs; - - success : boolean; - - min_h : pos32 := Config.LINEAR_FRAMEBUFFER_MAX_WIDTH; - min_v : pos32 := Config.LINEAR_FRAMEBUFFER_MAX_HEIGHT; - begin - lightup_ok := 0; - - HW.GFX.GMA.Initialize (Success => success); - - if success then - ports := Mainboard.ports; - HW.GFX.GMA.Display_Probing.Scan_Ports (configs, ports); - - if configs (Primary).Port /= Disabled then - for i in Pipe_Index loop - exit when configs (i).Port = Disabled; - - min_h := pos32'min (min_h, configs (i).Mode.H_Visible); - min_v := pos32'min (min_v, configs (i).Mode.V_Visible); - end loop; - - fb := configs (Primary).Framebuffer; - fb.Width := Width_Type (min_h); - fb.Height := Height_Type (min_v); - fb.Stride := Div_Round_Up (fb.Width, 16) * 16; - fb.V_Stride := fb.Height; - - for i in Pipe_Index loop - exit when configs (i).Port = Disabled; - - configs (i).Framebuffer := fb; - end loop; - - HW.GFX.GMA.Dump_Configs (configs); - - HW.GFX.GMA.Setup_Default_FB - (FB => fb, - Clear => true, - Success => success); - - if success then - HW.GFX.GMA.Update_Outputs (configs); - - HW.GFX.GMA.Map_Linear_FB (linear_fb_addr, fb); - fb_valid := linear_fb_addr /= 0; - - lightup_ok := (if fb_valid then 1 else 0); - end if; - end if; - end if; - end gfxinit; - -end GMA; diff --git a/src/drivers/intel/gma/text_fb/gma-gfx_init.adb b/src/drivers/intel/gma/text_fb/gma-gfx_init.adb new file mode 100644 index 0000000000..038b76b26a --- /dev/null +++ b/src/drivers/intel/gma/text_fb/gma-gfx_init.adb @@ -0,0 +1,68 @@ +with HW.GFX; +with HW.GFX.GMA; +with HW.GFX.GMA.Display_Probing; + +use HW.GFX; +use HW.GFX.GMA; +use HW.GFX.GMA.Display_Probing; + +with GMA.Mainboard; + +package body GMA.GFX_Init +is + + function fill_lb_framebuffer + (framebuffer : in out lb_framebuffer) + return Interfaces.C.int + is + use type Interfaces.C.int; + begin + return -1; + end fill_lb_framebuffer; + + ---------------------------------------------------------------------------- + + procedure gfxinit (lightup_ok : out Interfaces.C.int) + is + ports : Port_List; + configs : Pipe_Configs; + + 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 (Success => success); + + if success then + ports := Mainboard.ports; + HW.GFX.GMA.Display_Probing.Scan_Ports + (Configs => configs, + Ports => ports, + Max_Pipe => Primary); + + if configs (Primary).Port /= Disabled then + HW.GFX.GMA.Power_Up_VGA; + vga_io_init; + vga_textmode_init; + + -- override probed framebuffer config + configs (Primary).Framebuffer.Width := 640; + configs (Primary).Framebuffer.Height := 400; + configs (Primary).Framebuffer.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.GFX_Init; diff --git a/src/drivers/intel/gma/text_fb/gma.adb b/src/drivers/intel/gma/text_fb/gma.adb deleted file mode 100644 index 145b9a047e..0000000000 --- a/src/drivers/intel/gma/text_fb/gma.adb +++ /dev/null @@ -1,68 +0,0 @@ -with HW.GFX; -with HW.GFX.GMA; -with HW.GFX.GMA.Display_Probing; - -use HW.GFX; -use HW.GFX.GMA; -use HW.GFX.GMA.Display_Probing; - -with GMA.Mainboard; - -package body GMA -is - - function fill_lb_framebuffer - (framebuffer : in out lb_framebuffer) - return Interfaces.C.int - is - use type Interfaces.C.int; - begin - return -1; - end fill_lb_framebuffer; - - ---------------------------------------------------------------------------- - - procedure gfxinit (lightup_ok : out Interfaces.C.int) - is - ports : Port_List; - configs : Pipe_Configs; - - 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 (Success => success); - - if success then - ports := Mainboard.ports; - HW.GFX.GMA.Display_Probing.Scan_Ports - (Configs => configs, - Ports => ports, - Max_Pipe => Primary); - - if configs (Primary).Port /= Disabled then - HW.GFX.GMA.Power_Up_VGA; - vga_io_init; - vga_textmode_init; - - -- override probed framebuffer config - configs (Primary).Framebuffer.Width := 640; - configs (Primary).Framebuffer.Height := 400; - configs (Primary).Framebuffer.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