1-- SPDX-License-Identifier: GPL-2.0-only 2 3with CB.Config; 4 5use CB; 6 7with HW.GFX; 8with HW.GFX.Framebuffer_Filler; 9with HW.GFX.GMA; 10with HW.GFX.GMA.Display_Probing; 11 12use HW.GFX; 13use HW.GFX.GMA; 14use HW.GFX.GMA.Display_Probing; 15 16with GMA.Mainboard; 17 18package body GMA.GFX_Init 19is 20 21 configs : Pipe_Configs; 22 ---------------------------------------------------------------------------- 23 24 procedure gfxinit (lightup_ok : out Interfaces.C.int) 25 is 26 use type pos32; 27 use type word64; 28 use type word32; 29 use type Interfaces.C.size_t; 30 31 ports : Port_List; 32 33 success : boolean; 34 35 linear_fb_addr : word64; 36 37 fb : Framebuffer_Type; 38 39 min_h : pos32 := Config.LINEAR_FRAMEBUFFER_MAX_WIDTH; 40 min_v : pos32 := Config.LINEAR_FRAMEBUFFER_MAX_HEIGHT; 41 42 fbinfo : Interfaces.C.size_t; 43 44 begin 45 lightup_ok := 0; 46 47 HW.GFX.GMA.Initialize (Success => success); 48 49 if success then 50 ports := Mainboard.ports; 51 HW.GFX.GMA.Display_Probing.Scan_Ports (configs, ports); 52 53 if configs (Primary).Port /= Disabled then 54 for i in Pipe_Index loop 55 exit when configs (i).Port = Disabled; 56 57 min_h := pos32'min (min_h, configs (i).Mode.H_Visible); 58 min_v := pos32'min (min_v, configs (i).Mode.V_Visible); 59 end loop; 60 61 fb := configs (Primary).Framebuffer; 62 fb.Width := Width_Type (min_h); 63 fb.Height := Height_Type (min_v); 64 fb.Stride := Div_Round_Up (fb.Width, 16) * 16; 65 fb.V_Stride := fb.Height; 66 67 for i in Pipe_Index loop 68 exit when configs (i).Port = Disabled; 69 70 configs (i).Framebuffer := fb; 71 end loop; 72 73 pragma Debug (HW.GFX.GMA.Dump_Configs (configs)); 74 75 HW.GFX.GMA.Setup_Default_FB 76 (FB => fb, 77 Clear => true, 78 Success => success); 79 80 if success then 81 HW.GFX.GMA.Update_Outputs (configs); 82 83 HW.GFX.GMA.Map_Linear_FB (linear_fb_addr, fb); 84 if linear_fb_addr /= 0 then 85 fbinfo := c_fb_add_framebuffer_info 86 (fb_addr => Interfaces.C.size_t (linear_fb_addr), 87 x_resolution => word32 (fb.Width), 88 y_resolution => word32 (fb.Height), 89 bytes_per_line => word32 (fb.Stride) * 4, 90 bits_per_pixel => 32); 91 if fbinfo /= 0 then 92 lightup_ok := 1; 93 end if; 94 end if; 95 end if; 96 end if; 97 end if; 98 end gfxinit; 99 100 procedure gfxstop 101 is 102 begin 103 if configs (Primary).Port /= Disabled then 104 for i in Pipe_Index loop 105 configs (i).Port := Disabled; 106 end loop; 107 HW.GFX.GMA.Update_Outputs (configs); 108 end if; 109 end gfxstop; 110 111end GMA.GFX_Init; 112