├── .gitignore ├── Makefile.inc ├── gfxtest ├── hw-gfx-gma-gfx_test.ads ├── Makefile.inc ├── gfx_test_main.adb └── gfx_test.sh ├── configs ├── g45 ├── haswell ├── ironlake ├── skylake ├── alderlake ├── ironlake_edp ├── tigerlake └── broxton ├── common ├── haswell_shared │ ├── Makefile.inc │ ├── hw-gfx-gma-connectors-ddi.ads │ ├── hw-gfx-gma-ddi_phy_stub.ads │ └── hw-gfx-gma-connectors.adb ├── tigerlake │ ├── Makefile.inc │ ├── hw-gfx-gma-port_detect.adb │ ├── hw-gfx-gma-power_and_clocks.ads │ ├── hw-gfx-gma-plls.adb │ ├── hw-gfx-gma-plls.ads │ ├── hw-gfx-gma-power_and_clocks.adb │ └── hw-gfx-gma-connectors.adb ├── delete_dyncpu.sed ├── broxton │ ├── Makefile.inc │ ├── hw-gfx-gma-connectors-ddi-buffers.ads │ ├── hw-gfx-gma-spll.ads │ ├── hw-gfx-gma-power_and_clocks.ads │ ├── hw-gfx-gma-plls.ads │ └── hw-gfx-gma-ddi_phy.ads ├── g45 │ ├── hw-gfx-gma-gmch.ads │ ├── Makefile.inc │ ├── hw-gfx-gma-gmch-vga.ads │ ├── hw-gfx-gma-gmch-lvds.ads │ ├── hw-gfx-gma-gmch-hdmi.ads │ ├── hw-gfx-gma-gmch-dp.ads │ ├── hw-gfx-gma-plls.ads │ ├── hw-gfx-gma-power_and_clocks.ads │ ├── hw-gfx-gma-gmch-vga.adb │ ├── hw-gfx-gma-gmch-lvds.adb │ ├── hw-gfx-gma-gmch-hdmi.adb │ ├── hw-gfx-gma-connectors.adb │ ├── hw-gfx-gma-port_detect.adb │ └── hw-gfx-gma-power_and_clocks.adb ├── skylake │ ├── Makefile.inc │ ├── hw-gfx-gma-ddi_phy.ads │ ├── hw-gfx-gma-connectors-ddi-buffers.ads │ ├── hw-gfx-gma-spll.ads │ ├── hw-gfx-gma-plls-dpll_0.ads │ ├── hw-gfx-gma-plls-dpll.ads │ ├── hw-gfx-gma-power_and_clocks.ads │ ├── hw-gfx-gma-plls.ads │ ├── hw-gfx-gma-plls-dpll_0.adb │ └── hw-gfx-gma-plls.adb ├── haswell │ ├── Makefile.inc │ ├── hw-gfx-gma-ddi_phy.ads │ ├── hw-gfx-gma-spll.ads │ ├── hw-gfx-gma-connectors-ddi-buffers.ads │ ├── hw-gfx-gma-pch-lynxpoint.ads │ ├── hw-gfx-gma-plls-wrpll.ads │ ├── hw-gfx-gma-plls-lcpll.ads │ ├── hw-gfx-gma-plls.ads │ ├── hw-gfx-gma-power_and_clocks.ads │ ├── hw-gfx-gma-spll.adb │ ├── hw-gfx-gma-plls.adb │ ├── hw-gfx-gma-connectors-ddi-buffers.adb │ └── hw-gfx-gma-pch-lynxpoint.adb ├── ironlake │ ├── Makefile.inc │ ├── hw-gfx-gma-pch-lvds.ads │ ├── hw-gfx-gma-pch-dp.ads │ ├── hw-gfx-gma-pch-hdmi.ads │ ├── hw-gfx-gma-connectors-edp.ads │ ├── hw-gfx-gma-plls.ads │ ├── hw-gfx-gma-power_and_clocks.ads │ ├── hw-gfx-gma-connectors-fdi.ads │ ├── hw-gfx-gma-power_and_clocks.adb │ ├── hw-gfx-gma-pch-lvds.adb │ ├── hw-gfx-gma-pch-hdmi.adb │ ├── hw-gfx-gma-connectors.adb │ └── hw-gfx-gma-port_detect.adb ├── hw-gfx-gma-dp_info.ads ├── hw-gfx-gma-pch-vga.ads ├── hw-gfx-gma-dp_dual_mode.ads ├── hw-gfx-gma-dp_aux_ch.ads ├── hw-gfx-gma-pch-transcoder.ads ├── hw-gfx-i2c.ads ├── hw-gfx-dp_dual_mode.ads ├── hw-gfx-gma-port_detect.ads ├── hw-gfx-gma-i2c.ads ├── hw-gfx-framebuffer_filler.ads ├── dyncpu │ └── hw-gfx-gma-config.adb ├── hw-gfx-gma-dp_aux_request.ads ├── hw-gfx-gma-pch-fdi.ads ├── hw-gfx-gma-connector_info.ads ├── hw-gfx-dp_defs.ads ├── hw-gfx-gma-pch.ads ├── hw-gfx-gma-display_probing.ads ├── hw-gfx-gma-connectors.ads ├── hw-gfx-dp_training.ads ├── hw-gfx-framebuffer_filler.adb ├── hw-gfx-gma-panel.ads ├── hw-gfx-gma-pch-sideband.ads ├── hw-gfx-dp_aux_ch.ads ├── hw-gfx-edid.ads ├── hw-gfx-gma-pcode.ads ├── hw-gfx-gma-config_helpers.ads ├── hw-gfx-gma-connector_info.adb ├── hw-gfx-dp_info.ads ├── hw-gfx-gma-pcode.adb ├── hw-gfx-gma-pch-sideband.adb ├── Makefile.inc └── hw-gfx-gma-transcoder.ads ├── TODO ├── Makefile └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | /proof-allconfigs/ 2 | /build/ 3 | /dest/ 4 | /*.gpr 5 | /.config 6 | -------------------------------------------------------------------------------- /Makefile.inc: -------------------------------------------------------------------------------- 1 | subdirs-y += common 2 | 3 | subdirs-$(GFXINIT_TEST) += gfxtest 4 | -------------------------------------------------------------------------------- /gfxtest/hw-gfx-gma-gfx_test.ads: -------------------------------------------------------------------------------- 1 | package HW.GFX.GMA.GFX_Test is 2 | 3 | procedure Main; 4 | 5 | end HW.GFX.GMA.GFX_Test; 6 | -------------------------------------------------------------------------------- /gfxtest/Makefile.inc: -------------------------------------------------------------------------------- 1 | gfxinit-y += hw-gfx-gma-gfx_test.adb 2 | gfxinit-y += hw-gfx-gma-gfx_test.ads 3 | 4 | gfxinit-main-y = gfx_test_main.adb 5 | -------------------------------------------------------------------------------- /gfxtest/gfx_test_main.adb: -------------------------------------------------------------------------------- 1 | with HW.GFX.GMA.GFX_Test; 2 | 3 | procedure GFX_Test_Main is 4 | begin 5 | HW.GFX.GMA.GFX_Test.Main; 6 | end GFX_Test_Main; 7 | -------------------------------------------------------------------------------- /configs/g45: -------------------------------------------------------------------------------- 1 | CONFIG_GFX_GMA_DYN_CPU = y 2 | CONFIG_GFX_GMA_GENERATION = G45 3 | CONFIG_GFX_GMA_PANEL_1_PORT = LVDS 4 | CONFIG_GFX_GMA_ANALOG_I2C_PORT = PCH_DAC 5 | CONFIG_GFX_GMA_DEFAULT_MMIO = 16\#e000_0000\# 6 | -------------------------------------------------------------------------------- /configs/haswell: -------------------------------------------------------------------------------- 1 | CONFIG_GFX_GMA_DYN_CPU = y 2 | CONFIG_GFX_GMA_GENERATION = Haswell 3 | CONFIG_GFX_GMA_PCH = Lynx_Point 4 | CONFIG_GFX_GMA_PANEL_1_PORT = eDP 5 | CONFIG_GFX_GMA_ANALOG_I2C_PORT = PCH_DAC 6 | CONFIG_GFX_GMA_DEFAULT_MMIO = 16\#e000_0000\# 7 | -------------------------------------------------------------------------------- /common/haswell_shared/Makefile.inc: -------------------------------------------------------------------------------- 1 | gfxinit-y += hw-gfx-gma-connectors-ddi.adb 2 | gfxinit-y += hw-gfx-gma-connectors-ddi.ads 3 | gfxinit-y += hw-gfx-gma-connectors.adb 4 | gfxinit-y += hw-gfx-gma-ddi_phy_stub.ads 5 | gfxinit-y += hw-gfx-gma-port_detect.adb 6 | -------------------------------------------------------------------------------- /configs/ironlake: -------------------------------------------------------------------------------- 1 | CONFIG_GFX_GMA_DYN_CPU = y 2 | CONFIG_GFX_GMA_GENERATION = Ironlake 3 | CONFIG_GFX_GMA_PCH = Ibex_Peak 4 | CONFIG_GFX_GMA_PANEL_1_PORT = LVDS 5 | CONFIG_GFX_GMA_ANALOG_I2C_PORT = PCH_DAC 6 | CONFIG_GFX_GMA_DEFAULT_MMIO = 16\#e000_0000\# 7 | -------------------------------------------------------------------------------- /configs/skylake: -------------------------------------------------------------------------------- 1 | CONFIG_GFX_GMA_DYN_CPU = y 2 | CONFIG_GFX_GMA_GENERATION = Skylake 3 | CONFIG_GFX_GMA_PCH = Sunrise_Point 4 | CONFIG_GFX_GMA_PANEL_1_PORT = eDP 5 | CONFIG_GFX_GMA_ANALOG_I2C_PORT = PCH_DAC 6 | CONFIG_GFX_GMA_DEFAULT_MMIO = 16\#e000_0000\# 7 | -------------------------------------------------------------------------------- /configs/alderlake: -------------------------------------------------------------------------------- 1 | CONFIG_GFX_GMA_DYN_CPU = y 2 | CONFIG_GFX_GMA_GENERATION = Tigerlake 3 | CONFIG_GFX_GMA_PCH = Alder_Point 4 | CONFIG_GFX_GMA_PANEL_1_PORT = eDP 5 | CONFIG_GFX_GMA_ANALOG_I2C_PORT = PCH_DAC # N/A 6 | CONFIG_GFX_GMA_DEFAULT_MMIO = 16\#e000_0000\# 7 | -------------------------------------------------------------------------------- /configs/ironlake_edp: -------------------------------------------------------------------------------- 1 | CONFIG_GFX_GMA_DYN_CPU = y 2 | CONFIG_GFX_GMA_GENERATION = Ironlake 3 | CONFIG_GFX_GMA_PCH = Cougar_Point 4 | CONFIG_GFX_GMA_PANEL_1_PORT = eDP 5 | CONFIG_GFX_GMA_ANALOG_I2C_PORT = PCH_DAC 6 | CONFIG_GFX_GMA_DEFAULT_MMIO = 16\#e000_0000\# 7 | -------------------------------------------------------------------------------- /configs/tigerlake: -------------------------------------------------------------------------------- 1 | CONFIG_GFX_GMA_DYN_CPU = y 2 | CONFIG_GFX_GMA_GENERATION = Tigerlake 3 | CONFIG_GFX_GMA_PCH = Tiger_Point 4 | CONFIG_GFX_GMA_PANEL_1_PORT = eDP 5 | CONFIG_GFX_GMA_ANALOG_I2C_PORT = PCH_DAC # N/A 6 | CONFIG_GFX_GMA_DEFAULT_MMIO = 16\#e000_0000\# 7 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | medium DP re-read status if updated bit isn't set 2 | medium DP honor adjust requests also if training succeeded? 3 | unknown DP honor SINK_STATUS after training 4 | 5 | low LVDS 8bit colors, data format??? 6 | 7 | medium gfxtest take care of our own framebuffer mapping 8 | -------------------------------------------------------------------------------- /common/tigerlake/Makefile.inc: -------------------------------------------------------------------------------- 1 | gfxinit-y += hw-gfx-gma-power_and_clocks.adb 2 | gfxinit-y += hw-gfx-gma-power_and_clocks.ads 3 | gfxinit-y += hw-gfx-gma-connectors.adb 4 | gfxinit-y += hw-gfx-gma-port_detect.adb 5 | gfxinit-y += hw-gfx-gma-plls.adb 6 | gfxinit-y += hw-gfx-gma-plls.ads 7 | -------------------------------------------------------------------------------- /common/delete_dyncpu.sed: -------------------------------------------------------------------------------- 1 | # delete `Dyn_CPU` lines along with a preceding comma in the previous line: 2 | :s 3 | /,$/{ 4 | N 5 | s/,\n.*Dyn_CPU[^,)]*// 6 | ts 7 | P 8 | D 9 | } 10 | # delete all other lines about `Dyn_CPU`: 11 | /Dyn_CPU/d 12 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | name := gfxinit 2 | 3 | ifeq ($(MAKECMDGOALS),gfx_test) 4 | prefixed-name := gfx_test 5 | link-type := program 6 | GFXINIT_TEST := y 7 | endif 8 | 9 | gfxinit-deplibs := libhw 10 | 11 | libhw-dir ?= ../libhwbase/dest 12 | include $(libhw-dir)/Makefile 13 | 14 | gfx_test: $(binary) 15 | 16 | .PHONY: gfx_test 17 | -------------------------------------------------------------------------------- /configs/broxton: -------------------------------------------------------------------------------- 1 | CONFIG_GFX_GMA_DYN_CPU = 2 | CONFIG_GFX_GMA_GENERATION = Broxton 3 | CONFIG_GFX_GMA_CPU = Broxton 4 | CONFIG_GFX_GMA_CPU_VARIANT = Normal # N/A 5 | CONFIG_GFX_GMA_PANEL_1_PORT = Disabled 6 | CONFIG_GFX_GMA_PANEL_2_PORT = eDP 7 | CONFIG_GFX_GMA_ANALOG_I2C_PORT = PCH_DAC # N/A 8 | CONFIG_GFX_GMA_DEFAULT_MMIO = 16\#e000_0000\# 9 | -------------------------------------------------------------------------------- /common/broxton/Makefile.inc: -------------------------------------------------------------------------------- 1 | gfxinit-y += hw-gfx-gma-connectors-ddi-buffers.ads 2 | gfxinit-y += hw-gfx-gma-ddi_phy.adb 3 | gfxinit-y += hw-gfx-gma-ddi_phy.ads 4 | gfxinit-y += hw-gfx-gma-plls.adb 5 | gfxinit-y += hw-gfx-gma-plls.ads 6 | gfxinit-y += hw-gfx-gma-power_and_clocks.adb 7 | gfxinit-y += hw-gfx-gma-power_and_clocks.ads 8 | gfxinit-y += hw-gfx-gma-spll.ads 9 | -------------------------------------------------------------------------------- /common/g45/hw-gfx-gma-gmch.ads: -------------------------------------------------------------------------------- 1 | with HW.GFX.GMA.Config; 2 | 3 | private package HW.GFX.GMA.GMCH is 4 | 5 | GMCH_PORT_PIPE_SELECT_SHIFT : constant := 30; 6 | GMCH_PORT_PIPE_SELECT_MASK : constant := 1 * 2 ** 30; 7 | type GMCH_PORT_PIPE_SELECT_Array is array (Pipe_Index) of Word32; 8 | GMCH_PORT_PIPE_SELECT : constant GMCH_PORT_PIPE_SELECT_Array := 9 | (Primary => 0 * 2 ** GMCH_PORT_PIPE_SELECT_SHIFT, 10 | Secondary => 1 * 2 ** GMCH_PORT_PIPE_SELECT_SHIFT, 11 | Tertiary => 0); 12 | 13 | end HW.GFX.GMA.GMCH; 14 | -------------------------------------------------------------------------------- /common/skylake/Makefile.inc: -------------------------------------------------------------------------------- 1 | gfxinit-y += hw-gfx-gma-connectors-ddi-buffers.adb 2 | gfxinit-y += hw-gfx-gma-connectors-ddi-buffers.ads 3 | gfxinit-y += hw-gfx-gma-ddi_phy.ads 4 | gfxinit-y += hw-gfx-gma-plls-dpll.adb 5 | gfxinit-y += hw-gfx-gma-plls-dpll.ads 6 | gfxinit-y += hw-gfx-gma-plls-dpll_0.adb 7 | gfxinit-y += hw-gfx-gma-plls-dpll_0.ads 8 | gfxinit-y += hw-gfx-gma-plls.adb 9 | gfxinit-y += hw-gfx-gma-plls.ads 10 | gfxinit-y += hw-gfx-gma-power_and_clocks.adb 11 | gfxinit-y += hw-gfx-gma-power_and_clocks.ads 12 | gfxinit-y += hw-gfx-gma-spll.ads 13 | -------------------------------------------------------------------------------- /common/g45/Makefile.inc: -------------------------------------------------------------------------------- 1 | gfxinit-y += hw-gfx-gma-connectors.adb 2 | gfxinit-y += hw-gfx-gma-gmch-dp.adb 3 | gfxinit-y += hw-gfx-gma-gmch-dp.ads 4 | gfxinit-y += hw-gfx-gma-gmch-hdmi.adb 5 | gfxinit-y += hw-gfx-gma-gmch-hdmi.ads 6 | gfxinit-y += hw-gfx-gma-gmch-lvds.adb 7 | gfxinit-y += hw-gfx-gma-gmch-lvds.ads 8 | gfxinit-y += hw-gfx-gma-gmch-vga.adb 9 | gfxinit-y += hw-gfx-gma-gmch-vga.ads 10 | gfxinit-y += hw-gfx-gma-plls.adb 11 | gfxinit-y += hw-gfx-gma-plls.ads 12 | gfxinit-y += hw-gfx-gma-port_detect.adb 13 | gfxinit-y += hw-gfx-gma-gmch.ads 14 | gfxinit-y += hw-gfx-gma-power_and_clocks.ads 15 | gfxinit-y += hw-gfx-gma-power_and_clocks.adb -------------------------------------------------------------------------------- /common/haswell/Makefile.inc: -------------------------------------------------------------------------------- 1 | gfxinit-y += hw-gfx-gma-connectors-ddi-buffers.adb 2 | gfxinit-y += hw-gfx-gma-connectors-ddi-buffers.ads 3 | gfxinit-y += hw-gfx-gma-ddi_phy.ads 4 | gfxinit-y += hw-gfx-gma-pch-lynxpoint.adb 5 | gfxinit-y += hw-gfx-gma-pch-lynxpoint.ads 6 | gfxinit-y += hw-gfx-gma-plls-lcpll.ads 7 | gfxinit-y += hw-gfx-gma-plls-wrpll.adb 8 | gfxinit-y += hw-gfx-gma-plls-wrpll.ads 9 | gfxinit-y += hw-gfx-gma-plls.adb 10 | gfxinit-y += hw-gfx-gma-plls.ads 11 | gfxinit-y += hw-gfx-gma-power_and_clocks.adb 12 | gfxinit-y += hw-gfx-gma-power_and_clocks.ads 13 | gfxinit-y += hw-gfx-gma-spll.adb 14 | gfxinit-y += hw-gfx-gma-spll.ads 15 | -------------------------------------------------------------------------------- /common/ironlake/Makefile.inc: -------------------------------------------------------------------------------- 1 | gfxinit-y += hw-gfx-gma-connectors-edp.adb 2 | gfxinit-y += hw-gfx-gma-connectors-edp.ads 3 | gfxinit-y += hw-gfx-gma-connectors-fdi.adb 4 | gfxinit-y += hw-gfx-gma-connectors-fdi.ads 5 | gfxinit-y += hw-gfx-gma-connectors.adb 6 | gfxinit-y += hw-gfx-gma-pch-dp.adb 7 | gfxinit-y += hw-gfx-gma-pch-dp.ads 8 | gfxinit-y += hw-gfx-gma-pch-hdmi.adb 9 | gfxinit-y += hw-gfx-gma-pch-hdmi.ads 10 | gfxinit-y += hw-gfx-gma-pch-lvds.adb 11 | gfxinit-y += hw-gfx-gma-pch-lvds.ads 12 | gfxinit-y += hw-gfx-gma-plls.adb 13 | gfxinit-y += hw-gfx-gma-plls.ads 14 | gfxinit-y += hw-gfx-gma-port_detect.adb 15 | gfxinit-y += hw-gfx-gma-power_and_clocks.adb 16 | gfxinit-y += hw-gfx-gma-power_and_clocks.ads 17 | -------------------------------------------------------------------------------- /common/haswell/hw-gfx-gma-ddi_phy.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2017 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.GMA.DDI_Phy_Stub; 16 | 17 | private package HW.GFX.GMA.DDI_Phy renames HW.GFX.GMA.DDI_Phy_Stub; 18 | -------------------------------------------------------------------------------- /common/skylake/hw-gfx-gma-ddi_phy.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2017 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.GMA.DDI_Phy_Stub; 16 | 17 | private package HW.GFX.GMA.DDI_Phy renames HW.GFX.GMA.DDI_Phy_Stub; 18 | -------------------------------------------------------------------------------- /common/haswell/hw-gfx-gma-spll.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | private package HW.GFX.GMA.SPLL is 16 | 17 | procedure On; 18 | 19 | procedure Off; 20 | 21 | end HW.GFX.GMA.SPLL; 22 | -------------------------------------------------------------------------------- /common/ironlake/hw-gfx-gma-pch-lvds.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | package HW.GFX.GMA.PCH.LVDS 16 | is 17 | 18 | procedure On (Port_Cfg : Port_Config; FDI_Port : FDI_Port_Type); 19 | 20 | procedure Off; 21 | 22 | end HW.GFX.GMA.PCH.LVDS; 23 | -------------------------------------------------------------------------------- /common/g45/hw-gfx-gma-gmch-vga.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | package HW.GFX.GMA.GMCH.VGA is 16 | 17 | procedure On 18 | (Pipe : in Pipe_Index; 19 | Mode : in Mode_Type); 20 | procedure Off; 21 | 22 | end HW.GFX.GMA.GMCH.VGA; 23 | -------------------------------------------------------------------------------- /common/g45/hw-gfx-gma-gmch-lvds.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | package HW.GFX.GMA.GMCH.LVDS 16 | is 17 | 18 | procedure On (Port_Cfg : in Port_Config; 19 | Pipe : in Pipe_Index); 20 | 21 | procedure Off; 22 | 23 | end HW.GFX.GMA.GMCH.LVDS; 24 | -------------------------------------------------------------------------------- /common/haswell/hw-gfx-gma-connectors-ddi-buffers.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2017 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | private package HW.GFX.GMA.Connectors.DDI.Buffers 16 | is 17 | 18 | procedure Translations (Trans : out Buf_Trans_Array; Port : Digital_Port); 19 | 20 | end HW.GFX.GMA.Connectors.DDI.Buffers; 21 | -------------------------------------------------------------------------------- /common/skylake/hw-gfx-gma-connectors-ddi-buffers.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2017 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | private package HW.GFX.GMA.Connectors.DDI.Buffers 16 | is 17 | 18 | procedure Translations (Trans : out Buf_Trans_Array; Port : Digital_Port); 19 | 20 | end HW.GFX.GMA.Connectors.DDI.Buffers; 21 | -------------------------------------------------------------------------------- /common/haswell/hw-gfx-gma-pch-lynxpoint.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2020 Angel Pons 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | package HW.GFX.GMA.PCH.Lynxpoint is 16 | 17 | procedure Enable_Clkout_DP_And_FDI_mPHY; 18 | procedure Disable_Clkout_DP; 19 | procedure Unbend_Clkout_DP; 20 | 21 | end HW.GFX.GMA.PCH.Lynxpoint; 22 | -------------------------------------------------------------------------------- /common/broxton/hw-gfx-gma-connectors-ddi-buffers.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2017 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | private package HW.GFX.GMA.Connectors.DDI.Buffers 16 | is 17 | 18 | procedure Translations (Trans : out Buf_Trans_Array; Port : Digital_Port) 19 | is null; 20 | 21 | end HW.GFX.GMA.Connectors.DDI.Buffers; 22 | -------------------------------------------------------------------------------- /common/hw-gfx-gma-dp_info.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.DP_Info; 16 | pragma Elaborate_All (HW.GFX.DP_Info); 17 | with HW.GFX.GMA.DP_Aux_Ch; 18 | 19 | private package HW.GFX.GMA.DP_Info 20 | is new HW.GFX.DP_Info 21 | (T => DP_Port, 22 | Aux_Ch => DP_Aux_Ch); 23 | -------------------------------------------------------------------------------- /common/hw-gfx-gma-pch-vga.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | package HW.GFX.GMA.PCH.VGA is 16 | 17 | procedure On 18 | (Port : FDI_Port_Type; 19 | Mode : Mode_Type); 20 | 21 | procedure Off; 22 | 23 | procedure Clock_On (Mode : Mode_Type); 24 | 25 | end HW.GFX.GMA.PCH.VGA; 26 | -------------------------------------------------------------------------------- /common/broxton/hw-gfx-gma-spll.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | private package HW.GFX.GMA.SPLL is 16 | 17 | -- Just for a common interface with Haswell's DDI. 18 | -- There is no SPLL (no FDI) on Broxton. 19 | 20 | procedure On is null; 21 | 22 | procedure Off is null; 23 | 24 | end HW.GFX.GMA.SPLL; 25 | -------------------------------------------------------------------------------- /common/skylake/hw-gfx-gma-spll.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | private package HW.GFX.GMA.SPLL is 16 | 17 | -- Just for a common interface with Haswell's DDI. 18 | -- There is no SPLL (no FDI) on Skylake. 19 | 20 | procedure On is null; 21 | 22 | procedure Off is null; 23 | 24 | end HW.GFX.GMA.SPLL; 25 | -------------------------------------------------------------------------------- /common/hw-gfx-gma-dp_dual_mode.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2021 Angel Pons 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.DP_Dual_Mode; 16 | pragma Elaborate_All (HW.GFX.DP_Dual_Mode); 17 | with HW.GFX.GMA.DP_Aux_Ch; 18 | 19 | private package HW.GFX.GMA.DP_Dual_Mode 20 | is new HW.GFX.DP_Dual_Mode 21 | (T => DP_Port, 22 | Aux_Ch => DP_Aux_Ch); 23 | -------------------------------------------------------------------------------- /common/skylake/hw-gfx-gma-plls-dpll_0.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | private package HW.GFX.GMA.PLLs.DPLL_0 is 16 | 17 | Register_Value : constant Word32 := 0; 18 | 19 | procedure Check_Link_Rate 20 | (Link_Rate : in DP_Bandwidth; 21 | Success : out Boolean); 22 | 23 | end HW.GFX.GMA.PLLs.DPLL_0; 24 | -------------------------------------------------------------------------------- /common/hw-gfx-gma-dp_aux_ch.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.DP_Aux_Ch; 16 | pragma Elaborate_All (HW.GFX.DP_Aux_Ch); 17 | with HW.GFX.GMA.DP_Aux_Request; 18 | 19 | private package HW.GFX.GMA.DP_Aux_Ch 20 | is new HW.GFX.DP_Aux_Ch 21 | (T => DP_Port, 22 | Aux_Request => DP_Aux_Request.Do_Aux_Request); 23 | -------------------------------------------------------------------------------- /common/hw-gfx-gma-pch-transcoder.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | package HW.GFX.GMA.PCH.Transcoder is 16 | 17 | procedure On 18 | (Port_Cfg : Port_Config; 19 | Port : FDI_Port_Type; 20 | PLL : Word32); 21 | 22 | procedure Off 23 | (Port : FDI_Port_Type); 24 | 25 | end HW.GFX.GMA.PCH.Transcoder; 26 | -------------------------------------------------------------------------------- /common/hw-gfx-i2c.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | package HW.GFX.I2C is 16 | 17 | type Transfer_Address is mod 2 ** 7; 18 | subtype Transfer_Length is Natural range 0 .. 128; 19 | subtype Transfer_Index is Natural range 0 .. Transfer_Length'Last - 1; 20 | subtype Transfer_Data is Buffer (Transfer_Index); 21 | 22 | end HW.GFX.I2C; 23 | -------------------------------------------------------------------------------- /common/hw-gfx-dp_dual_mode.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2021 Angel Pons 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.DP_Aux_Ch; 16 | 17 | private generic 18 | 19 | type T (<>) is limited private; 20 | 21 | with package Aux_Ch is new DP_Aux_Ch (T => T, others => <>); 22 | 23 | package HW.GFX.DP_Dual_Mode is 24 | 25 | procedure Switch_LSPCON (Port : in T); 26 | 27 | end HW.GFX.DP_Dual_Mode; 28 | -------------------------------------------------------------------------------- /common/hw-gfx-gma-port_detect.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2016-2017 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | private package HW.GFX.GMA.Port_Detect is 16 | 17 | procedure Initialize; 18 | 19 | procedure Hotplug_Detect 20 | (Port : in Active_Port_Type; 21 | Detected : out Boolean); 22 | 23 | procedure Clear_Hotplug_Detect (Port : Active_Port_Type); 24 | 25 | end HW.GFX.GMA.Port_Detect; 26 | -------------------------------------------------------------------------------- /common/g45/hw-gfx-gma-gmch-hdmi.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | package HW.GFX.GMA.GMCH.HDMI 16 | is 17 | 18 | procedure On (Port_Cfg : in Port_Config; 19 | Pipe : in Pipe_Index) 20 | with 21 | Pre => Port_Cfg.Port in GMCH_HDMI_Port; 22 | 23 | procedure Off (Port : GMCH_HDMI_Port); 24 | procedure All_Off; 25 | 26 | end HW.GFX.GMA.GMCH.HDMI; 27 | -------------------------------------------------------------------------------- /common/g45/hw-gfx-gma-gmch-dp.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | package HW.GFX.GMA.GMCH.DP 16 | is 17 | 18 | procedure On 19 | (Port_Cfg : in Port_Config; 20 | Pipe : in Pipe_Index; 21 | Success : out Boolean) 22 | with 23 | Pre => Port_Cfg.Port in GMCH_DP_Port; 24 | 25 | procedure Off (Port : GMCH_DP_Port); 26 | procedure All_Off; 27 | 28 | end HW.GFX.GMA.GMCH.DP; 29 | -------------------------------------------------------------------------------- /common/hw-gfx-gma-i2c.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.I2C; 16 | 17 | private package HW.GFX.GMA.I2C is 18 | 19 | procedure I2C_Read 20 | (Port : in PCH_Port; 21 | Address : in HW.GFX.I2C.Transfer_Address; 22 | Length : in out HW.GFX.I2C.Transfer_Length; 23 | Data : out HW.GFX.I2C.Transfer_Data; 24 | Success : out Boolean); 25 | 26 | end HW.GFX.GMA.I2C; 27 | -------------------------------------------------------------------------------- /common/ironlake/hw-gfx-gma-pch-dp.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | package HW.GFX.GMA.PCH.DP 16 | is 17 | 18 | procedure On 19 | (Port_Cfg : in Port_Config; 20 | FDI_Port : in FDI_Port_Type; 21 | Success : out Boolean) 22 | with 23 | Pre => Port_Cfg.PCH_Port in PCH_DP_Port; 24 | 25 | procedure Off (Port : PCH_DP_Port); 26 | procedure All_Off; 27 | 28 | end HW.GFX.GMA.PCH.DP; 29 | -------------------------------------------------------------------------------- /common/hw-gfx-framebuffer_filler.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with System; 16 | 17 | package HW.GFX.Framebuffer_Filler 18 | with 19 | Abstract_State => ((State with External), Base_Address), 20 | Initializes => Base_Address 21 | is 22 | 23 | procedure Fill (Linear_FB : Word64; Framebuffer : Framebuffer_Type) 24 | with 25 | Pre => 26 | Framebuffer.Width <= Framebuffer.Stride; 27 | 28 | end HW.GFX.Framebuffer_Filler; 29 | -------------------------------------------------------------------------------- /common/ironlake/hw-gfx-gma-pch-hdmi.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | package HW.GFX.GMA.PCH.HDMI 16 | is 17 | subtype IRL_PCH_HDMI_Port is PCH_HDMI_Port range PCH_HDMI_B .. PCH_HDMI_D; 18 | 19 | procedure On (Port_Cfg : Port_Config; FDI_Port : FDI_Port_Type) 20 | with 21 | Pre => Port_Cfg.PCH_Port in IRL_PCH_HDMI_Port; 22 | 23 | procedure Off (Port : IRL_PCH_HDMI_Port); 24 | procedure All_Off; 25 | 26 | end HW.GFX.GMA.PCH.HDMI; 27 | -------------------------------------------------------------------------------- /common/skylake/hw-gfx-gma-plls-dpll.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | private package HW.GFX.GMA.PLLs.DPLL is 16 | 17 | type Value_Array is array (Configurable_DPLLs) of Word32; 18 | Register_Value : constant Value_Array := Value_Array' 19 | (DPLL1 => 1, DPLL2 => 2, DPLL3 => 3); 20 | 21 | procedure On 22 | (PLL : in Configurable_DPLLs; 23 | Port_Cfg : in Port_Config; 24 | Success : out Boolean); 25 | 26 | procedure Off (PLL : Configurable_DPLLs); 27 | 28 | end HW.GFX.GMA.PLLs.DPLL; 29 | -------------------------------------------------------------------------------- /common/haswell/hw-gfx-gma-plls-wrpll.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | private package HW.GFX.GMA.PLLs.WRPLL 16 | is 17 | 18 | type Value_Array is array (WRPLLs) of Word32; 19 | Register_Value : constant Value_Array := Value_Array' 20 | (WRPLL0 => 4 * 2 ** 29, WRPLL1 => 5 * 2 ** 29); 21 | 22 | procedure On 23 | (PLL : in WRPLLs; 24 | Target_Clock : in Frequency_Type; 25 | Success : out Boolean); 26 | 27 | procedure Off (PLL : WRPLLs); 28 | 29 | end HW.GFX.GMA.PLLs.WRPLL; 30 | -------------------------------------------------------------------------------- /common/dyncpu/hw-gfx-gma-config.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2018 Nico Huber 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | package body HW.GFX.GMA.Config 16 | is 17 | 18 | procedure Detect_CPU (Device : Word16) is 19 | begin 20 | for CPU in Gen_CPU_Type loop 21 | for CPU_Var in Gen_CPU_Variant loop 22 | if Is_GPU (Device, CPU, CPU_Var) then 23 | Config.CPU := CPU; 24 | Config.CPU_Var := CPU_Var; 25 | exit; 26 | end if; 27 | end loop; 28 | end loop; 29 | end Detect_CPU; 30 | 31 | end HW.GFX.GMA.Config; 32 | -------------------------------------------------------------------------------- /common/hw-gfx-gma-dp_aux_request.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.DP_Defs; 16 | 17 | private package HW.GFX.GMA.DP_Aux_Request is 18 | 19 | procedure Do_Aux_Request 20 | (Port : in DP_Port; 21 | Request : in DP_Defs.Aux_Request; 22 | Request_Length : in DP_Defs.Aux_Request_Length; 23 | Response : out DP_Defs.Aux_Response; 24 | Response_Length : out DP_Defs.Aux_Response_Length; 25 | Success : out Boolean); 26 | 27 | end HW.GFX.GMA.DP_Aux_Request; 28 | -------------------------------------------------------------------------------- /common/haswell/hw-gfx-gma-plls-lcpll.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | private package HW.GFX.GMA.PLLs.LCPLL 16 | is 17 | 18 | type Fixed_LCPLLs_Array is array (HW.GFX.DP_Bandwidth) of LCPLLs; 19 | 20 | Fixed_LCPLLs : constant Fixed_LCPLLs_Array := Fixed_LCPLLs_Array' 21 | (DP_Bandwidth_5_4 => LCPLL0, 22 | DP_Bandwidth_2_7 => LCPLL1, 23 | DP_Bandwidth_1_62 => LCPLL2); 24 | 25 | type Value_Array is array (LCPLLs) of Word32; 26 | Register_Value : constant Value_Array := Value_Array' 27 | (LCPLL0 => 0 * 2 ** 29, LCPLL1 => 1 * 2 ** 29, LCPLL2 => 2 * 2 ** 29); 28 | 29 | end HW.GFX.GMA.PLLs.LCPLL; 30 | -------------------------------------------------------------------------------- /common/ironlake/hw-gfx-gma-connectors-edp.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | private package HW.GFX.GMA.Connectors.EDP 16 | is 17 | 18 | procedure Pre_On (Pipe : Pipe_Index; Port_Cfg : Port_Config); 19 | 20 | procedure Post_On 21 | (Link : in DP_Link; 22 | Success : out Boolean); 23 | 24 | pragma Warnings (GNATprove, Off, "unused variable ""Port""", 25 | Reason => "Needed for a common interface"); 26 | procedure Off (Port : Digital_Port); 27 | pragma Warnings (GNATprove, On, "unused variable ""Port"""); 28 | 29 | procedure Pre_Training; 30 | 31 | end HW.GFX.GMA.Connectors.EDP; 32 | -------------------------------------------------------------------------------- /common/hw-gfx-gma-pch-fdi.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | package HW.GFX.GMA.PCH.FDI is 16 | 17 | type Training_Pattern is (TP_1, TP_2, TP_Idle, TP_None); 18 | 19 | procedure Pre_Train (Port : PCH.FDI_Port_Type; Port_Cfg : Port_Config); 20 | procedure Train 21 | (Port : in PCH.FDI_Port_Type; 22 | TP : in Training_Pattern; 23 | Success : out Boolean); 24 | procedure Auto_Train (Port : PCH.FDI_Port_Type); 25 | procedure Enable_EC (Port : PCH.FDI_Port_Type); 26 | 27 | type Off_Type is (Rx_Off, Lanes_Off, Clock_Off); 28 | procedure Off (Port : PCH.FDI_Port_Type; OT : Off_Type); 29 | 30 | end HW.GFX.GMA.PCH.FDI; 31 | -------------------------------------------------------------------------------- /common/hw-gfx-gma-connector_info.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.EDID; 16 | 17 | private package HW.GFX.GMA.Connector_Info is 18 | 19 | procedure Preferred_Link_Setting 20 | (Port_Cfg : in out Port_Config; 21 | Success : out Boolean) 22 | with 23 | Post => 24 | Port_Cfg.Port = Port_Cfg.Port'Old and 25 | Port_Cfg.Mode = Port_Cfg.Mode'Old; 26 | 27 | procedure Next_Link_Setting 28 | (Port_Cfg : in out Port_Config; 29 | Success : out Boolean) 30 | with 31 | Post => 32 | Port_Cfg.Port = Port_Cfg.Port'Old and 33 | Port_Cfg.Mode = Port_Cfg.Mode'Old; 34 | 35 | function Default_BPC (Port_Cfg : Port_Config) return BPC_Type; 36 | 37 | end HW.GFX.GMA.Connector_Info; 38 | -------------------------------------------------------------------------------- /common/g45/hw-gfx-gma-plls.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | private package HW.GFX.GMA.PLLs 16 | with 17 | Abstract_State => (State with Part_Of => GMA.State) 18 | is 19 | 20 | -- XXX: Types should be private (but that triggers a bug in SPARK GPL 2016) 21 | type T is (Invalid_PLL, DPLL_A, DPLL_B); 22 | subtype DPLLs is T range DPLL_A .. DPLL_B; 23 | Invalid : constant T := Invalid_PLL; 24 | 25 | procedure Initialize 26 | with 27 | Global => (Output => State); 28 | 29 | procedure Alloc 30 | (Port_Cfg : in Port_Config; 31 | PLL : out T; 32 | Success : out Boolean); 33 | 34 | procedure Free (PLL : T); 35 | 36 | procedure All_Off; 37 | 38 | function Register_Value (PLL : T) return Word32; 39 | 40 | end HW.GFX.GMA.PLLs; 41 | -------------------------------------------------------------------------------- /common/haswell_shared/hw-gfx-gma-connectors-ddi.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2017 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.GMA.Registers; 16 | 17 | private package HW.GFX.GMA.Connectors.DDI 18 | is 19 | 20 | procedure Initialize; 21 | 22 | procedure Pre_On 23 | (Port_Cfg : in Port_Config; 24 | PLL_Hint : in Word32; 25 | Success : out Boolean) 26 | with 27 | Pre => Port_Cfg.Port in Digital_Port; 28 | 29 | procedure Post_On (Port_Cfg : Port_Config) 30 | with 31 | Pre => Port_Cfg.Port in Digital_Port; 32 | 33 | 34 | procedure Off (Port : Digital_Port); 35 | 36 | procedure Post_Reset_Off; 37 | 38 | private 39 | type Buf_Trans_Range is range 0 .. 19; 40 | type Buf_Trans_Array is array (Buf_Trans_Range) of Word32; 41 | 42 | end HW.GFX.GMA.Connectors.DDI; 43 | -------------------------------------------------------------------------------- /common/ironlake/hw-gfx-gma-plls.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | private package HW.GFX.GMA.PLLs 16 | with 17 | Abstract_State => (State with Part_Of => GMA.State) 18 | is 19 | 20 | -- XXX: Types should be private (but that triggers a bug in SPARK GPL 2016) 21 | type T is (Invalid_PLL, DPLL_A, DPLL_B); 22 | subtype DPLLs is T range DPLL_A .. DPLL_B; 23 | Invalid : constant T := Invalid_PLL; 24 | 25 | procedure Initialize 26 | with 27 | Global => (Output => State); 28 | 29 | procedure Alloc 30 | (Port_Cfg : in Port_Config; 31 | PLL : out T; 32 | Success : out Boolean); 33 | 34 | procedure Free (PLL : T); 35 | 36 | procedure All_Off; 37 | 38 | function Register_Value (PLL : T) return Word32; 39 | 40 | end HW.GFX.GMA.PLLs; 41 | -------------------------------------------------------------------------------- /common/haswell_shared/hw-gfx-gma-ddi_phy_stub.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2017 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.GMA.DP_Info; 16 | 17 | private package HW.GFX.GMA.DDI_Phy_Stub is 18 | 19 | subtype DDI_Phy_Port is GPU_Port; 20 | 21 | Max_V_Swing : constant DP_Info.DP_Voltage_Swing := DP_Info.VS_Level_0; 22 | 23 | type Emph_Array is array (DP_Info.DP_Voltage_Swing) of DP_Info.DP_Pre_Emph; 24 | Max_Pre_Emph : constant Emph_Array := (others => DP_Info.Emph_Level_0); 25 | 26 | procedure Set_DP_Signal_Levels 27 | (Port : Digital_Port; 28 | Train_Set : DP_Info.Train_Set) is null; 29 | 30 | subtype HDMI_Buf_Trans_Range is DDI_HDMI_Buf_Trans_Range; 31 | procedure Set_HDMI_Signal_Levels 32 | (Port : DDI_Phy_Port; 33 | Level : HDMI_Buf_Trans_Range) is null; 34 | 35 | end HW.GFX.GMA.DDI_Phy_Stub; 36 | -------------------------------------------------------------------------------- /common/hw-gfx-dp_defs.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | package HW.GFX.DP_Defs is 16 | 17 | type Aux_Message_Command is mod 2 ** 4; 18 | type Aux_Message_Address is mod 2 ** 20; 19 | 20 | subtype Aux_Payload_Length is Natural range 0 .. 16; 21 | subtype Aux_Payload_Index is Natural range 0 .. Aux_Payload_Length'Last - 1; 22 | subtype Aux_Payload is Buffer (Aux_Payload_Index); 23 | 24 | subtype Aux_Request_Length is Natural range 3 .. 20; 25 | subtype Aux_Request_Index is Natural range 0 .. Aux_Request_Length'Last - 1; 26 | subtype Aux_Request is Buffer (Aux_Request_Index); 27 | 28 | subtype Aux_Response_Length is Natural range 1 .. 17; 29 | subtype Aux_Response_Index is 30 | Natural range 0 .. Aux_Response_Length'Last - 1; 31 | subtype Aux_Response is Buffer (Aux_Response_Index); 32 | 33 | end HW.GFX.DP_Defs; 34 | -------------------------------------------------------------------------------- /common/haswell/hw-gfx-gma-plls.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | private package HW.GFX.GMA.PLLs 16 | with 17 | Abstract_State => (State with Part_Of => GMA.State) 18 | is 19 | 20 | -- XXX: Types should be private (but that triggers a bug in SPARK GPL 2016) 21 | type T is (Invalid_PLL, LCPLL0, LCPLL1, LCPLL2, WRPLL0, WRPLL1); 22 | subtype LCPLLs is T range LCPLL0 .. LCPLL2; 23 | subtype WRPLLs is T range WRPLL0 .. WRPLL1; 24 | Invalid : constant T := Invalid_PLL; 25 | 26 | procedure Initialize 27 | with 28 | Global => (Output => State); 29 | 30 | procedure Alloc 31 | (Port_Cfg : in Port_Config; 32 | PLL : out T; 33 | Success : out Boolean); 34 | 35 | procedure Free (PLL : T); 36 | 37 | procedure All_Off; 38 | 39 | function Register_Value (PLL : T) return Word32; 40 | 41 | end HW.GFX.GMA.PLLs; 42 | -------------------------------------------------------------------------------- /common/broxton/hw-gfx-gma-power_and_clocks.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2016-2017 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.GMA.Config_Helpers; 16 | 17 | private package HW.GFX.GMA.Power_And_Clocks is 18 | 19 | procedure Pre_All_Off; 20 | procedure Post_All_Off; 21 | 22 | procedure Initialize; 23 | 24 | procedure Limit_Dotclocks 25 | (Configs : in out Pipe_Configs; 26 | CDClk_Switch : out Boolean) 27 | with 28 | Post => Config_Helpers.Stable_FB (Configs'Old, Configs); 29 | procedure Update_CDClk (Configs : in out Pipe_Configs) 30 | with 31 | Post => Config_Helpers.Stable_FB (Configs'Old, Configs); 32 | procedure Enable_CDClk; 33 | 34 | procedure Power_Set_To (Configs : Pipe_Configs); 35 | procedure Power_Up (Old_Configs, New_Configs : Pipe_Configs); 36 | procedure Power_Down (Old_Configs, Tmp_Configs, New_Configs : Pipe_Configs); 37 | 38 | end HW.GFX.GMA.Power_And_Clocks; 39 | -------------------------------------------------------------------------------- /common/haswell/hw-gfx-gma-power_and_clocks.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.GMA.Config_Helpers; 16 | 17 | private package HW.GFX.GMA.Power_And_Clocks is 18 | 19 | procedure Pre_All_Off; 20 | procedure Post_All_Off; 21 | 22 | procedure Initialize; 23 | 24 | procedure Limit_Dotclocks 25 | (Configs : in out Pipe_Configs; 26 | CDClk_Switch : out Boolean) 27 | with 28 | Post => Config_Helpers.Stable_FB (Configs'Old, Configs); 29 | procedure Update_CDClk (Configs : in out Pipe_Configs) 30 | with 31 | Post => Config_Helpers.Stable_FB (Configs'Old, Configs); 32 | procedure Enable_CDClk is null; 33 | 34 | procedure Power_Set_To (Configs : Pipe_Configs); 35 | procedure Power_Up (Old_Configs, New_Configs : Pipe_Configs); 36 | procedure Power_Down (Old_Configs, Tmp_Configs, New_Configs : Pipe_Configs); 37 | 38 | end HW.GFX.GMA.Power_And_Clocks; 39 | -------------------------------------------------------------------------------- /common/skylake/hw-gfx-gma-power_and_clocks.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.GMA.Config_Helpers; 16 | 17 | private package HW.GFX.GMA.Power_And_Clocks is 18 | 19 | procedure Pre_All_Off; 20 | procedure Post_All_Off; 21 | 22 | procedure Initialize; 23 | 24 | procedure Limit_Dotclocks 25 | (Configs : in out Pipe_Configs; 26 | CDClk_Switch : out Boolean) 27 | with 28 | Post => Config_Helpers.Stable_FB (Configs'Old, Configs); 29 | procedure Update_CDClk (Configs : in out Pipe_Configs) 30 | with 31 | Post => Config_Helpers.Stable_FB (Configs'Old, Configs); 32 | procedure Enable_CDClk is null; 33 | 34 | procedure Power_Set_To (Configs : Pipe_Configs); 35 | procedure Power_Up (Old_Configs, New_Configs : Pipe_Configs); 36 | procedure Power_Down (Old_Configs, Tmp_Configs, New_Configs : Pipe_Configs); 37 | 38 | end HW.GFX.GMA.Power_And_Clocks; 39 | -------------------------------------------------------------------------------- /common/hw-gfx-gma-pch.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.GMA.Config; 16 | 17 | private package HW.GFX.GMA.PCH is 18 | 19 | type FDI_Port_Type is (FDI_A, FDI_B, FDI_C); 20 | 21 | ---------------------------------------------------------------------------- 22 | 23 | -- common to all PCH outputs 24 | 25 | function PCH_TRANSCODER_SELECT_SHIFT return Natural is 26 | (if Config.Has_New_FDI_Sink then 29 else 30); 27 | 28 | function PCH_TRANSCODER_SELECT_MASK return Word32 is 29 | (if Config.Has_New_FDI_Sink then 3 * 2 ** 29 else 1 * 2 ** 30); 30 | 31 | function PCH_TRANSCODER_SELECT (Port : FDI_Port_Type) return Word32 is 32 | (case Port is 33 | when FDI_A => Shift_Left (0, PCH_TRANSCODER_SELECT_SHIFT), 34 | when FDI_B => Shift_Left (1, PCH_TRANSCODER_SELECT_SHIFT), 35 | when FDI_C => Shift_Left (2, PCH_TRANSCODER_SELECT_SHIFT)); 36 | 37 | end HW.GFX.GMA.PCH; 38 | -------------------------------------------------------------------------------- /common/skylake/hw-gfx-gma-plls.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | private package HW.GFX.GMA.PLLs 16 | with 17 | Abstract_State => (State with Part_Of => GMA.State) 18 | is 19 | 20 | -- NOTE: Order of DPLLs is twisted, as DPLL2 (WRPLL1) 21 | -- should be selected as last choice. 22 | 23 | -- XXX: Types should be private (but that triggers a bug in SPARK GPL 2016) 24 | type T is (Invalid_PLL, DPLL0, DPLL1, DPLL3, DPLL2); 25 | subtype Configurable_DPLLs is T range DPLL1 .. DPLL2; 26 | Invalid : constant T := Invalid_PLL; 27 | 28 | procedure Initialize 29 | with 30 | Global => (Output => State); 31 | 32 | procedure Alloc 33 | (Port_Cfg : in Port_Config; 34 | PLL : out T; 35 | Success : out Boolean); 36 | 37 | procedure Free (PLL : T); 38 | 39 | procedure All_Off; 40 | 41 | function Register_Value (PLL : T) return Word32; 42 | 43 | end HW.GFX.GMA.PLLs; 44 | -------------------------------------------------------------------------------- /common/g45/hw-gfx-gma-power_and_clocks.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.GMA.Config_Helpers; 16 | 17 | private package HW.GFX.GMA.Power_And_Clocks is 18 | 19 | procedure Initialize; 20 | 21 | procedure Limit_Dotclocks 22 | (Configs : in out Pipe_Configs; 23 | CDClk_Switch : out Boolean) 24 | with 25 | Post => 26 | not CDClk_Switch and 27 | Config_Helpers.Stable_FB (Configs'Old, Configs); 28 | procedure Update_CDClk (Configs : in out Pipe_Configs) is null; 29 | procedure Enable_CDClk is null; 30 | 31 | procedure Pre_All_Off is null; 32 | 33 | procedure Post_All_Off is null; 34 | 35 | procedure Power_Set_To (Configs : Pipe_Configs) is null; 36 | 37 | procedure Power_Up (Old_Configs, New_Configs : Pipe_Configs) is null; 38 | 39 | procedure Power_Down (Old_Configs, Tmp_Configs, New_Configs : Pipe_Configs) 40 | is null; 41 | 42 | end HW.GFX.GMA.Power_And_Clocks; 43 | -------------------------------------------------------------------------------- /common/hw-gfx-gma-display_probing.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.EDID; 16 | 17 | package HW.GFX.GMA.Display_Probing 18 | is 19 | 20 | type Port_List_Range is range 0 .. 8; 21 | type Port_List is array (Port_List_Range) of Port_Type; 22 | All_Ports : constant Port_List := 23 | (DP1, DP2, DP3, HDMI1, HDMI2, HDMI3, Analog, LVDS, eDP); 24 | 25 | procedure Read_EDID 26 | (Raw_EDID : out EDID.Raw_EDID_Data; 27 | Port : in Active_Port_Type; 28 | Success : out Boolean) 29 | with 30 | Post => (if Success then EDID.Valid (Raw_EDID)); 31 | 32 | procedure Scan_Ports 33 | (Configs : out Pipe_Configs; 34 | Ports : in Port_List := All_Ports; 35 | Max_Pipe : in Pipe_Index := Pipe_Index'Last; 36 | Keep_Power : in Boolean := False); 37 | 38 | procedure Hotplug_Events (Ports : out Port_List); 39 | 40 | end HW.GFX.GMA.Display_Probing; 41 | -------------------------------------------------------------------------------- /common/ironlake/hw-gfx-gma-power_and_clocks.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.GMA.Config_Helpers; 16 | 17 | private package HW.GFX.GMA.Power_And_Clocks is 18 | 19 | procedure Initialize; 20 | 21 | procedure Limit_Dotclocks 22 | (Configs : in out Pipe_Configs; 23 | CDClk_Switch : out Boolean) 24 | with 25 | Post => 26 | not CDClk_Switch and 27 | Config_Helpers.Stable_FB (Configs'Old, Configs); 28 | procedure Update_CDClk (Configs : in out Pipe_Configs) is null; 29 | procedure Enable_CDClk is null; 30 | 31 | procedure Pre_All_Off is null; 32 | 33 | procedure Post_All_Off is null; 34 | 35 | procedure Power_Set_To (Configs : Pipe_Configs) is null; 36 | 37 | procedure Power_Up (Old_Configs, New_Configs : Pipe_Configs) is null; 38 | 39 | procedure Power_Down (Old_Configs, Tmp_Configs, New_Configs : Pipe_Configs) 40 | is null; 41 | 42 | end HW.GFX.GMA.Power_And_Clocks; 43 | -------------------------------------------------------------------------------- /common/broxton/hw-gfx-gma-plls.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2017 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | private package HW.GFX.GMA.PLLs 16 | with 17 | Abstract_State => (State with Part_Of => GMA.State) 18 | is 19 | 20 | -- Broxton DDI PHY PLLs are tied to the port. 21 | -- So the allocation will be a stub. 22 | 23 | -- XXX: Types should be private (but that triggers a bug in SPARK GPL 2016) 24 | type T is (Invalid_PLL, DPLL_A, DPLL_B, DPLL_C); 25 | Invalid : constant T := Invalid_PLL; 26 | 27 | procedure Initialize 28 | with 29 | Global => (Output => State); 30 | 31 | procedure Alloc 32 | (Port_Cfg : in Port_Config; 33 | PLL : out T; 34 | Success : out Boolean); 35 | 36 | procedure Free (PLL : T); 37 | 38 | procedure All_Off; 39 | 40 | -- Just an interface stub since PLLs are tied to the port. 41 | type Word_Array is array (T) of Word32; 42 | Register_Value : constant Word_Array := (others => 0); 43 | 44 | end HW.GFX.GMA.PLLs; 45 | -------------------------------------------------------------------------------- /common/ironlake/hw-gfx-gma-connectors-fdi.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.GMA.PCH; 16 | 17 | private package HW.GFX.GMA.Connectors.FDI 18 | is 19 | 20 | subtype GPU_FDI_Port is GPU_Port range DIGI_B .. DIGI_D; 21 | 22 | type PCH_FDI_Mapping is array (GPU_FDI_Port) of PCH.FDI_Port_Type; 23 | PCH_FDIs : constant PCH_FDI_Mapping := 24 | (DIGI_B => PCH.FDI_A, 25 | DIGI_C => PCH.FDI_B, 26 | DIGI_D => PCH.FDI_C); 27 | 28 | type Off_Type is (Link_Off, Clock_Off); 29 | 30 | ---------------------------------------------------------------------------- 31 | 32 | procedure Pre_On (Port_Cfg : Port_Config) 33 | with 34 | Pre => Port_Cfg.Port in GPU_FDI_Port; 35 | 36 | procedure Post_On 37 | (Port_Cfg : in Port_Config; 38 | Success : out Boolean) 39 | with 40 | Pre => Port_Cfg.Port in GPU_FDI_Port; 41 | 42 | procedure Off (Port : GPU_FDI_Port; OT : Off_Type); 43 | 44 | end HW.GFX.GMA.Connectors.FDI; 45 | -------------------------------------------------------------------------------- /common/tigerlake/hw-gfx-gma-port_detect.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) Google, LLC 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.GMA.Config; 16 | with HW.GFX.GMA.Registers; 17 | with HW.GFX.GMA.Config_Helpers; 18 | 19 | with HW.Debug; 20 | with GNAT.Source_Info; 21 | 22 | package body HW.GFX.GMA.Port_Detect 23 | is 24 | procedure Initialize is 25 | begin 26 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 27 | end Initialize; 28 | 29 | pragma Warnings (Off, "unused variable ""Port""", 30 | Reason => "Not yet implemented."); 31 | procedure Hotplug_Detect 32 | (Port : in Active_Port_Type; 33 | Detected : out Boolean) 34 | is 35 | begin 36 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 37 | Detected := False; 38 | end Hotplug_Detect; 39 | pragma Warnings (On, "unused variable ""Port"""); 40 | 41 | procedure Clear_Hotplug_Detect (Port : Active_Port_Type) 42 | is 43 | begin 44 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 45 | end Clear_Hotplug_Detect; 46 | 47 | end HW.GFX.GMA.Port_Detect; 48 | -------------------------------------------------------------------------------- /common/haswell/hw-gfx-gma-spll.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.Time; 16 | with HW.GFX.GMA.Registers; 17 | 18 | package body HW.GFX.GMA.SPLL is 19 | 20 | SPLL_CTL_PLL_ENABLE : constant := 1 * 2 ** 31; 21 | SPLL_CTL_REF_SEL_MASK : constant := 3 * 2 ** 28; 22 | SPLL_CTL_REF_SEL_SSC : constant := 1 * 2 ** 28; 23 | SPLL_CTL_REF_SEL_NON_SSC : constant := 2 * 2 ** 28; 24 | SPLL_CTL_FREQ_SEL_MASK : constant := 3 * 2 ** 26; 25 | SPLL_CTL_FREQ_SEL_810 : constant := 0 * 2 ** 26; 26 | SPLL_CTL_FREQ_SEL_1350 : constant := 1 * 2 ** 26; 27 | 28 | procedure On is 29 | begin 30 | Registers.Write 31 | (Register => Registers.SPLL_CTL, 32 | Value => SPLL_CTL_PLL_ENABLE or 33 | SPLL_CTL_REF_SEL_SSC or 34 | SPLL_CTL_FREQ_SEL_1350); 35 | Registers.Posting_Read (Registers.SPLL_CTL); 36 | Time.U_Delay (20); 37 | end On; 38 | 39 | procedure Off is 40 | begin 41 | Registers.Unset_Mask (Registers.SPLL_CTL, SPLL_CTL_PLL_ENABLE); 42 | end Off; 43 | 44 | end HW.GFX.GMA.SPLL; 45 | -------------------------------------------------------------------------------- /common/broxton/hw-gfx-gma-ddi_phy.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2017 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.GMA.DP_Info; 16 | 17 | private package HW.GFX.GMA.DDI_Phy is 18 | 19 | type T is (BC, A); 20 | 21 | procedure Power_On (Phy : T); 22 | procedure Power_Off (Phy : T); 23 | 24 | subtype DDI_Phy_Port is GPU_Port range DIGI_A .. DIGI_C; 25 | 26 | procedure Pre_PLL (Port_Cfg : Port_Config); 27 | 28 | Max_V_Swing : constant DP_Info.DP_Voltage_Swing := DP_Info.VS_Level_3; 29 | 30 | type Emph_Array is array (DP_Info.DP_Voltage_Swing) of DP_Info.DP_Pre_Emph; 31 | Max_Pre_Emph : constant Emph_Array := 32 | (DP_Info.VS_Level_0 => DP_Info.Emph_Level_3, 33 | DP_Info.VS_Level_1 => DP_Info.Emph_Level_2, 34 | DP_Info.VS_Level_2 => DP_Info.Emph_Level_1, 35 | others => DP_Info.Emph_Level_0); 36 | 37 | procedure Set_DP_Signal_Levels 38 | (Port : Digital_Port; 39 | Train_Set : DP_Info.Train_Set); 40 | 41 | subtype HDMI_Buf_Trans_Range is DDI_HDMI_Buf_Trans_Range range 0 .. 9; 42 | procedure Set_HDMI_Signal_Levels 43 | (Port : DDI_Phy_Port; 44 | Level : HDMI_Buf_Trans_Range); 45 | 46 | end HW.GFX.GMA.DDI_Phy; 47 | -------------------------------------------------------------------------------- /common/hw-gfx-gma-connectors.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | private package HW.GFX.GMA.Connectors is 16 | 17 | pragma Warnings (GNATprove, Off, "subprogram ""*"" has no effect", 18 | Reason => "Only effects some platforms"); 19 | procedure Post_Reset_Off; 20 | procedure Initialize; 21 | pragma Warnings (GNATprove, On, "subprogram ""*"" has no effect"); 22 | 23 | pragma Warnings (GNATprove, Off, "unused variable ""P*""", 24 | Reason => "Needed for a common interface"); 25 | procedure Pre_On 26 | (Pipe : in Pipe_Index; 27 | Port_Cfg : in Port_Config; 28 | PLL_Hint : in Word32; 29 | Success : out Boolean); 30 | 31 | procedure Post_On 32 | (Pipe : in Pipe_Index; 33 | Port_Cfg : in Port_Config; 34 | PLL_Hint : in Word32; 35 | Success : out Boolean); 36 | pragma Warnings (GNATprove, On, "unused variable ""P*"""); 37 | 38 | procedure Pre_Off (Port_Cfg : Port_Config); 39 | procedure Post_Off (Port_Cfg : Port_Config); 40 | 41 | procedure Pre_All_Off; 42 | procedure Post_All_Off; 43 | 44 | end HW.GFX.GMA.Connectors; 45 | -------------------------------------------------------------------------------- /gfxtest/gfx_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | usage="Usage: $0 [ [(0|90|128|270)]]\n" 6 | 7 | err_msgs= 8 | command -v chvt >/dev/null || err_msgs="${err_msgs}"'Need `chvt`\n' 9 | command -v openvt >/dev/null || err_msgs="${err_msgs}"'Need `openvt`\n' 10 | command -v fgconsole >/dev/null || err_msgs="${err_msgs}"'Need `fgconsole`\n' 11 | [ -n "$err_msgs" ] && err_msgs="${err_msgs}"'e.g. install the `kbd` package\n' 12 | 13 | [ -x build/gfx_test ] || \ 14 | err_msgs="${err_msgs}"'Please run from *libgfxinit* source dir and build `gfx_test` first.\n' 15 | 16 | [ "$#" -gt 2 ] && err_msgs="${err_msgs}${usage}" 17 | 18 | if [ -n "$err_msgs" ]; then 19 | printf "$err_msgs" 20 | exit 1 21 | fi 22 | 23 | if [ "$#" -lt 1 ]; then 24 | # default duration of 5s 25 | set 5 26 | fi 27 | 28 | reload_i915=0 29 | prepare_vt() { 30 | # switch VT, we might be in X 31 | orig_vt=`fgconsole` 32 | openvt -s -- true 33 | 34 | # poll until the VT switch is done 35 | while [ `fgconsole` -eq $orig_vt ]; do :; done 36 | 37 | # take i915 out of charge 38 | for vtcon in /sys/devices/virtual/vtconsole/vtcon*; do 39 | if grep -q frame\ buffer $vtcon/name >/dev/null 2>&1; then 40 | echo 0 >$vtcon/bind 41 | break 42 | fi 43 | done 44 | 45 | # try unloading it 46 | if modprobe -r i915 >/dev/null 2>&1; then 47 | reload_i915=1 48 | fi 49 | } 50 | 51 | restore_vt() { 52 | # reload i915 53 | if [ $reload_i915 -eq 1 ]; then 54 | modprobe i915 modeset=1 55 | else 56 | # put i915 back in charge 57 | for vtcon in /sys/devices/virtual/vtconsole/vtcon*; do 58 | if grep -q dummy $vtcon/name >/dev/null 2>&1; then 59 | echo 0 >$vtcon/bind 60 | break 61 | fi 62 | done 63 | fi 64 | 65 | # return to original VT 66 | chvt $orig_vt 67 | } 68 | 69 | prepare_vt 70 | 71 | build/gfx_test "$@" || true 72 | 73 | restore_vt 74 | -------------------------------------------------------------------------------- /common/hw-gfx-dp_training.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.DP_Info; 16 | with HW.GFX.DP_Aux_Ch; 17 | 18 | private generic 19 | 20 | TPS3_Supported : Boolean; 21 | 22 | type T (<>) is limited private; 23 | type Aux_T (<>) is limited private; 24 | 25 | with package Aux_Ch is new DP_Aux_Ch (T => Aux_T, others => <>); 26 | 27 | with package DP_Info is new GFX.DP_Info (T => Aux_T, Aux_Ch => Aux_Ch); 28 | 29 | with function To_Aux (Port : T) return Aux_T; 30 | 31 | with function Max_V_Swing (Port : T) return DP_Info.DP_Voltage_Swing; 32 | 33 | with function Max_Pre_Emph 34 | (Port : T; 35 | Train_Set : DP_Info.Train_Set) 36 | return DP_Info.DP_Pre_Emph; 37 | 38 | with procedure Set_Pattern 39 | (Port : T; 40 | Link : DP_Link; 41 | Pattern : DP_Info.Training_Pattern); 42 | 43 | with procedure Set_Signal_Levels 44 | (Port : T; 45 | Link : DP_Link; 46 | Train_Set : DP_Info.Train_Set); 47 | 48 | with procedure Off (Connector : T); 49 | 50 | package HW.GFX.DP_Training 51 | is 52 | 53 | procedure Train_DP 54 | (Port : in T; 55 | Link : in DP_Link; 56 | Success : out Boolean); 57 | 58 | end HW.GFX.DP_Training; 59 | -------------------------------------------------------------------------------- /common/tigerlake/hw-gfx-gma-power_and_clocks.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2022 Google, LLC 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.GMA.Config_Helpers; 16 | 17 | private package HW.GFX.GMA.Power_And_Clocks is 18 | 19 | pragma Warnings (Off, "subprogram ""*"" has no effect", 20 | Reason => "Not yet implemented."); 21 | procedure Pre_All_Off; 22 | procedure Post_All_Off; 23 | 24 | procedure Initialize; 25 | 26 | pragma Warnings (Off, """Configs"" is not modified, could be IN", 27 | Reason => "Not yet implemented."); 28 | procedure Limit_Dotclocks 29 | (Configs : in out Pipe_Configs; 30 | CDClk_Switch : out Boolean) 31 | with 32 | Post => Config_Helpers.Stable_FB (Configs'Old, Configs); 33 | procedure Update_CDClk (Configs : in out Pipe_Configs) 34 | with 35 | Post => Config_Helpers.Stable_FB (Configs'Old, Configs); 36 | pragma Warnings (On, """Configs"" is not modified, could be IN"); 37 | procedure Enable_CDClk is null; 38 | 39 | procedure Power_Set_To (Configs : Pipe_Configs); 40 | procedure Power_Up (Old_Configs, New_Configs : Pipe_Configs); 41 | procedure Power_Down (Old_Configs, Tmp_Configs, New_Configs : Pipe_Configs); 42 | pragma Warnings (On, "subprogram ""*"" has no effect"); 43 | 44 | end HW.GFX.GMA.Power_And_Clocks; 45 | -------------------------------------------------------------------------------- /common/hw-gfx-framebuffer_filler.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.Config; 16 | with HW.MMIO_Range; 17 | pragma Elaborate_All (HW.MMIO_Range); 18 | 19 | package body HW.GFX.Framebuffer_Filler 20 | with 21 | Refined_State => (State => FB.State, Base_Address => FB.Base_Address) 22 | is 23 | 24 | type FB_Index is new Natural range 25 | 0 .. Natural (Width_Type'Last * Height_Type'Last) - 1; 26 | type FB_Range is array (FB_Index) of Word32 with Pack; 27 | package FB is new MMIO_Range (0, Word32, FB_Index, FB_Range); 28 | 29 | procedure Fill (Linear_FB : Word64; Framebuffer : Framebuffer_Type) 30 | is 31 | Line_Start : Int32 := 0; 32 | begin 33 | if not HW.Config.Dynamic_MMIO then 34 | return; 35 | end if; 36 | 37 | FB.Set_Base_Address (Linear_FB); 38 | for Line in 0 .. Framebuffer.Height - 1 loop 39 | pragma Loop_Invariant (Line_Start = Line * Framebuffer.Stride); 40 | for Col in 0 .. Framebuffer.Width - 1 loop 41 | pragma Loop_Invariant 42 | (Line_Start = Line * Framebuffer.Stride and 43 | Line_Start <= (Height_Type'Last - 1) * Width_Type'Last); 44 | FB.Write (FB_Index (Line_Start + Col), 16#ff000000#); 45 | end loop; 46 | Line_Start := Line_Start + Framebuffer.Stride; 47 | end loop; 48 | end Fill; 49 | 50 | end HW.GFX.Framebuffer_Filler; 51 | -------------------------------------------------------------------------------- /common/hw-gfx-gma-panel.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.Time; 16 | with HW.GFX.GMA.Registers; 17 | 18 | private package HW.GFX.GMA.Panel 19 | with 20 | Abstract_State => (Panel_State with Part_Of => GMA.State) 21 | is 22 | 23 | procedure Static_Init 24 | with 25 | Global => 26 | (Output => Panel_State, 27 | Input => Time.State); 28 | 29 | procedure Setup_PP_Sequencer (Default_Delays : Boolean := False) 30 | with 31 | Global => 32 | (In_Out => (Panel_State, Registers.Register_State)), 33 | Depends => 34 | ((Panel_State, Registers.Register_State) => 35 | (Panel_State, Registers.Register_State, Default_Delays)); 36 | 37 | ---------------------------------------------------------------------------- 38 | 39 | procedure VDD_Override (Panel : Panel_Control); 40 | 41 | procedure On (Panel : Panel_Control; Wait : Boolean := True); 42 | 43 | procedure Wait_On (Panel : Panel_Control); 44 | 45 | procedure Off (Panel : Panel_Control); 46 | 47 | ---------------------------------------------------------------------------- 48 | 49 | procedure Backlight_On (Panel : Panel_Control); 50 | 51 | procedure Backlight_Off (Panel : Panel_Control); 52 | 53 | procedure Set_Backlight (Panel : Panel_Control; Level : Word32); 54 | 55 | procedure Get_Max_Backlight (Panel : Panel_Control; Level : out Word32); 56 | 57 | end HW.GFX.GMA.Panel; 58 | -------------------------------------------------------------------------------- /common/tigerlake/hw-gfx-gma-plls.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2022 Google, LLC 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.Debug; 16 | with GNAT.Source_Info; 17 | 18 | package body HW.GFX.GMA.PLLs 19 | with 20 | Refined_State => (State => PLLs) 21 | is 22 | 23 | type Count_Range is new Natural range 0 .. 2; 24 | 25 | type PLL_State is record 26 | Use_Count : Count_Range; 27 | end record; 28 | 29 | type PLL_State_Array is array (Configurable_DPLLs) of PLL_State; 30 | PLLs : PLL_State_Array; 31 | 32 | procedure Initialize is 33 | begin 34 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 35 | PLLs := 36 | (Configurable_DPLLs => 37 | (Use_Count => 0)); 38 | end Initialize; 39 | 40 | procedure Alloc 41 | (Port_Cfg : in Port_Config; 42 | PLL : out T; 43 | Success : out Boolean) 44 | is 45 | begin 46 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 47 | PLL := Invalid_PLL; 48 | Success := True; 49 | end Alloc; 50 | 51 | procedure Free (PLL : T) is 52 | begin 53 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 54 | end Free; 55 | 56 | procedure All_Off is 57 | begin 58 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 59 | end All_Off; 60 | 61 | function Register_Value (PLL : T) return Word32 62 | is 63 | begin 64 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 65 | Return 0; 66 | end Register_Value; 67 | end HW.GFX.GMA.PLLs; 68 | -------------------------------------------------------------------------------- /common/tigerlake/hw-gfx-gma-plls.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2022 Google, LLC 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | private package HW.GFX.GMA.PLLs 16 | with 17 | Abstract_State => (State with Part_Of => GMA.State) 18 | is 19 | 20 | -- XXX: Types should be private (but that triggers a bug in SPARK GPL 2016) 21 | type T is (Invalid_PLL, DPLL0, DPLL1, DPLL4, DPLL2); 22 | subtype Configurable_DPLLs is T range DPLL0 .. DPLL4; 23 | Invalid : constant T := Invalid_PLL; 24 | 25 | procedure Initialize 26 | with 27 | Global => (Output => State); 28 | 29 | pragma Warnings (Off, "unused variable ""Port_Cfg""", 30 | Reason => "Not yet implemented."); 31 | procedure Alloc 32 | (Port_Cfg : in Port_Config; 33 | PLL : out T; 34 | Success : out Boolean); 35 | pragma Warnings (On, "unused variable ""Port_Cfg"""); 36 | 37 | 38 | pragma Warnings (Off, "subprogram ""Free"" has no effect", 39 | Reason => "Not yet implemented."); 40 | procedure Free (PLL : T); 41 | pragma Warnings (On, "subprogram ""Free"" has no effect"); 42 | 43 | pragma Warnings (Off, "subprogram ""All_Off"" has no effect", 44 | Reason => "Not yet implemented."); 45 | procedure All_Off; 46 | pragma Warnings (On, "subprogram ""All_Off"" has no effect"); 47 | 48 | pragma Warnings (Off, "unused variable ""PLL""", 49 | Reason => "Not yet implemented."); 50 | function Register_Value (PLL : T) return Word32; 51 | pragma Warnings (On, "unused variable ""PLL"""); 52 | 53 | end HW.GFX.GMA.PLLs; 54 | -------------------------------------------------------------------------------- /common/skylake/hw-gfx-gma-plls-dpll_0.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.GMA.Registers; 16 | 17 | package body HW.GFX.GMA.PLLs.DPLL_0 is 18 | 19 | DPLL_CTRL1_DPLL0_LINK_RATE_MASK : constant := 7 * 2 ** 1; 20 | DPLL_CTRL1_DPLL0_LINK_RATE_2700MHZ : constant := 0 * 2 ** 1; 21 | DPLL_CTRL1_DPLL0_LINK_RATE_1350MHZ : constant := 1 * 2 ** 1; 22 | DPLL_CTRL1_DPLL0_LINK_RATE_810MHZ : constant := 2 * 2 ** 1; 23 | DPLL_CTRL1_DPLL0_LINK_RATE_1620MHZ : constant := 3 * 2 ** 1; 24 | DPLL_CTRL1_DPLL0_LINK_RATE_1080MHZ : constant := 4 * 2 ** 1; 25 | DPLL_CTRL1_DPLL0_LINK_RATE_2160MHZ : constant := 5 * 2 ** 1; 26 | DPLL_CTRL1_DPLL0_OVERRIDE : constant := 1 * 2 ** 0; 27 | 28 | procedure Check_Link_Rate 29 | (Link_Rate : in DP_Bandwidth; 30 | Success : out Boolean) 31 | is 32 | DPLL_Ctrl1 : Word32; 33 | begin 34 | Registers.Read (Registers.DPLL_CTRL1, DPLL_Ctrl1); 35 | 36 | case DPLL_Ctrl1 and DPLL_CTRL1_DPLL0_LINK_RATE_MASK is 37 | when DPLL_CTRL1_DPLL0_LINK_RATE_2700MHZ => 38 | Success := Link_Rate = DP_Bandwidth_5_4; 39 | when DPLL_CTRL1_DPLL0_LINK_RATE_1350MHZ => 40 | Success := Link_Rate = DP_Bandwidth_2_7; 41 | when DPLL_CTRL1_DPLL0_LINK_RATE_810MHZ => 42 | Success := Link_Rate = DP_Bandwidth_1_62; 43 | when others => 44 | Success := False; 45 | end case; 46 | Success := Success and (DPLL_Ctrl1 and DPLL_CTRL1_DPLL0_OVERRIDE) /= 0; 47 | end Check_Link_Rate; 48 | 49 | end HW.GFX.GMA.PLLs.DPLL_0; 50 | -------------------------------------------------------------------------------- /common/hw-gfx-gma-pch-sideband.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | private package HW.GFX.GMA.PCH.Sideband is 16 | 17 | type Destination_Type is (SBI_ICLK, SBI_MPHY); 18 | 19 | type Register_Type is 20 | (SBI_SSCDIVINTPHASE, 21 | SBI_SSCDITHPHASE, 22 | SBI_SSCCTL, 23 | SBI_SSCDIVINTPHASE6, 24 | SBI_SSCCTL6, 25 | SBI_SSCAUXDIV, 26 | SBI_GEN0, 27 | SBI_DBUFF0, 28 | 29 | SBI_MPHY_2008, 30 | SBI_MPHY_206C, 31 | SBI_MPHY_2080, 32 | SBI_MPHY_208C, 33 | SBI_MPHY_2098, 34 | SBI_MPHY_20C4, 35 | SBI_MPHY_20EC, 36 | SBI_MPHY_2108, 37 | SBI_MPHY_216C, 38 | SBI_MPHY_2180, 39 | SBI_MPHY_218C, 40 | SBI_MPHY_2198, 41 | SBI_MPHY_21C4, 42 | SBI_MPHY_21EC, 43 | SBI_MPHY_8008); 44 | 45 | procedure Read 46 | (Dest : in Destination_Type; 47 | Register : in Register_Type; 48 | Value : out Word32); 49 | 50 | procedure Write 51 | (Dest : in Destination_Type; 52 | Register : in Register_Type; 53 | Value : in Word32); 54 | 55 | procedure Unset_Mask 56 | (Dest : in Destination_Type; 57 | Register : in Register_Type; 58 | Mask : in Word32); 59 | 60 | procedure Set_Mask 61 | (Dest : in Destination_Type; 62 | Register : in Register_Type; 63 | Mask : in Word32); 64 | 65 | procedure Unset_And_Set_Mask 66 | (Dest : in Destination_Type; 67 | Register : in Register_Type; 68 | Mask_Unset : in Word32; 69 | Mask_Set : in Word32); 70 | 71 | end HW.GFX.GMA.PCH.Sideband; 72 | -------------------------------------------------------------------------------- /common/tigerlake/hw-gfx-gma-power_and_clocks.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2022 Google, LLC 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.Debug; 16 | with GNAT.Source_Info; 17 | 18 | with HW.GFX.GMA.Config; 19 | 20 | package body HW.GFX.GMA.Power_And_Clocks is 21 | 22 | procedure Pre_All_Off is 23 | begin 24 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 25 | end Pre_All_Off; 26 | 27 | procedure Post_All_Off is 28 | begin 29 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 30 | end Post_All_Off; 31 | 32 | procedure Initialize is 33 | begin 34 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 35 | end Initialize; 36 | 37 | procedure Limit_Dotclocks 38 | (Configs : in out Pipe_Configs; 39 | CDClk_Switch : out Boolean) is 40 | begin 41 | CDClk_Switch := False; 42 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 43 | end Limit_Dotclocks; 44 | 45 | procedure Update_CDClk (Configs : in out Pipe_Configs) is 46 | begin 47 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 48 | end Update_CDClk; 49 | 50 | procedure Power_Set_To (Configs : Pipe_Configs) is 51 | begin 52 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 53 | end Power_Set_To; 54 | 55 | procedure Power_Up (Old_Configs, New_Configs : Pipe_Configs) is 56 | begin 57 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 58 | end Power_Up; 59 | 60 | procedure Power_Down (Old_Configs, Tmp_Configs, New_Configs : Pipe_Configs) 61 | is 62 | begin 63 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 64 | end Power_Down; 65 | 66 | end HW.GFX.GMA.Power_And_Clocks; 67 | -------------------------------------------------------------------------------- /common/hw-gfx-dp_aux_ch.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.I2C; 16 | with HW.GFX.DP_Defs; 17 | 18 | private generic 19 | 20 | type T (<>) is limited private; 21 | 22 | with procedure Aux_Request 23 | (Port : in T; 24 | Request : in DP_Defs.Aux_Request; 25 | Request_Length : in DP_Defs.Aux_Request_Length; 26 | Response : out DP_Defs.Aux_Response; 27 | Response_Length : out DP_Defs.Aux_Response_Length; 28 | Success : out Boolean); 29 | 30 | package HW.GFX.DP_Aux_Ch is 31 | 32 | procedure Aux_Read 33 | (Port : in T; 34 | Address : in DP_Defs.Aux_Message_Address; 35 | Length : in out DP_Defs.Aux_Payload_Length; 36 | Data : out DP_Defs.Aux_Payload; 37 | Success : out Boolean); 38 | 39 | procedure Aux_Write 40 | (Port : in T; 41 | Address : in DP_Defs.Aux_Message_Address; 42 | Length : in DP_Defs.Aux_Payload_Length; 43 | Data : in DP_Defs.Aux_Payload; 44 | Success : out Boolean); 45 | 46 | ---------------------------------------------------------------------------- 47 | 48 | procedure I2C_Write_Byte 49 | (Port : in T; 50 | Address : in I2C.Transfer_Address; 51 | Offset : in Word8; 52 | Value : in Word8; 53 | Success : out Boolean); 54 | 55 | procedure I2C_Read_Byte 56 | (Port : in T; 57 | Address : in I2C.Transfer_Address; 58 | Offset : in Word8; 59 | Value : out Word8; 60 | Success : out Boolean); 61 | 62 | procedure I2C_Read 63 | (Port : in T; 64 | Address : in I2C.Transfer_Address; 65 | Length : in out I2C.Transfer_Length; 66 | Data : out I2C.Transfer_Data; 67 | Success : out Boolean); 68 | 69 | end HW.GFX.DP_Aux_Ch; 70 | -------------------------------------------------------------------------------- /common/tigerlake/hw-gfx-gma-connectors.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2022 Google, LLC 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.GMA.Config; 16 | with HW.GFX.GMA.Panel; 17 | 18 | with HW.Debug; 19 | with GNAT.Source_Info; 20 | 21 | package body HW.GFX.GMA.Connectors is 22 | 23 | procedure Post_Reset_Off is 24 | begin 25 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 26 | end Post_Reset_Off; 27 | 28 | procedure Initialize is 29 | begin 30 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 31 | end Initialize; 32 | 33 | procedure Pre_On 34 | (Pipe : in Pipe_Index; 35 | Port_Cfg : in Port_Config; 36 | PLL_Hint : in Word32; 37 | Success : out Boolean) is 38 | begin 39 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 40 | Success := True; 41 | end Pre_On; 42 | 43 | procedure Post_On 44 | (Pipe : in Pipe_Index; 45 | Port_Cfg : in Port_Config; 46 | PLL_Hint : in Word32; 47 | Success : out Boolean) is 48 | begin 49 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 50 | Panel.Backlight_On (Port_Cfg.Panel); 51 | Success := True; 52 | end Post_On; 53 | 54 | procedure Pre_Off (Port_Cfg : Port_Config) is 55 | begin 56 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 57 | Panel.Backlight_Off (Port_Cfg.Panel); 58 | Panel.Off (Port_Cfg.Panel); 59 | end Pre_Off; 60 | 61 | procedure Post_Off (Port_Cfg : Port_Config) is 62 | begin 63 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 64 | end Post_Off; 65 | 66 | procedure Pre_All_Off is 67 | begin 68 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 69 | for P in Valid_Panels loop 70 | Panel.Backlight_Off (P); 71 | Panel.Off (P); 72 | end loop; 73 | end Pre_All_Off; 74 | 75 | procedure Post_All_Off is 76 | begin 77 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 78 | end Post_All_Off; 79 | 80 | end HW.GFX.GMA.Connectors; 81 | -------------------------------------------------------------------------------- /common/hw-gfx-edid.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | package HW.GFX.EDID 16 | is 17 | 18 | use type Word8; 19 | use type Word16; 20 | 21 | subtype Raw_EDID_Index is Natural range 0 .. 127; 22 | subtype Raw_EDID_Data is Buffer (Raw_EDID_Index); 23 | 24 | function Valid (Raw_EDID : Raw_EDID_Data) return Boolean; 25 | procedure Sanitize (Raw_EDID : in out Raw_EDID_Data; Success : out Boolean) 26 | with 27 | Post => (if Success then Valid (Raw_EDID)); 28 | 29 | DESCRIPTOR_1 : constant := 54; 30 | 31 | function Read_LE16 32 | (Raw_EDID : Raw_EDID_Data; 33 | Offset : Raw_EDID_Index) 34 | return Word16 35 | with 36 | Pre => Offset < Raw_EDID_Index'Last; 37 | 38 | function Compatible_Display 39 | (Raw_EDID : Raw_EDID_Data; 40 | Display : Display_Type) 41 | return Boolean 42 | with 43 | Pre => Valid (Raw_EDID); 44 | 45 | function Has_Preferred_Mode (Raw_EDID : Raw_EDID_Data) return Boolean is 46 | (Int64 (Read_LE16 (Raw_EDID, DESCRIPTOR_1)) * 10_000 in Frequency_Type and 47 | ( Raw_EDID (DESCRIPTOR_1 + 2) /= 0 or 48 | (Raw_EDID (DESCRIPTOR_1 + 4) and 16#f0#) /= 0) and 49 | ( Raw_EDID (DESCRIPTOR_1 + 8) /= 0 or 50 | (Raw_EDID (DESCRIPTOR_1 + 11) and 16#c0#) /= 0) and 51 | ( Raw_EDID (DESCRIPTOR_1 + 9) /= 0 or 52 | (Raw_EDID (DESCRIPTOR_1 + 11) and 16#30#) /= 0) and 53 | ( Raw_EDID (DESCRIPTOR_1 + 3) /= 0 or 54 | (Raw_EDID (DESCRIPTOR_1 + 4) and 16#0f#) /= 0) and 55 | ( Raw_EDID (DESCRIPTOR_1 + 5) /= 0 or 56 | (Raw_EDID (DESCRIPTOR_1 + 7) and 16#f0#) /= 0) and 57 | ((Raw_EDID (DESCRIPTOR_1 + 10) and 16#f0#) /= 0 or 58 | (Raw_EDID (DESCRIPTOR_1 + 11) and 16#0c#) /= 0) and 59 | ((Raw_EDID (DESCRIPTOR_1 + 10) and 16#0f#) /= 0 or 60 | (Raw_EDID (DESCRIPTOR_1 + 11) and 16#03#) /= 0) and 61 | ( Raw_EDID (DESCRIPTOR_1 + 6) /= 0 or 62 | (Raw_EDID (DESCRIPTOR_1 + 7) and 16#0f#) /= 0)) 63 | with 64 | Pre => Valid (Raw_EDID); 65 | function Preferred_Mode (Raw_EDID : Raw_EDID_Data) return Mode_Type 66 | with 67 | Pre => Valid (Raw_EDID) and then Has_Preferred_Mode (Raw_EDID); 68 | 69 | end HW.GFX.EDID; 70 | -------------------------------------------------------------------------------- /common/hw-gfx-gma-pcode.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2016, 2019 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.GMA.Registers; 16 | 17 | private package HW.GFX.GMA.PCode is 18 | 19 | -- We have to ensure that previous usage of the mailbox finished 20 | -- (Wait_Ready) or know that we already did so (Mailbox_Ready). 21 | -- 22 | -- If we wait for the other side to acknowledge (Wait_Ack), we 23 | -- know that it's ready (=> Mailbox_Ready). 24 | 25 | -- XXX: Supposed to be a `Ghost` variable, but GNAT seems too broken? 26 | Mailbox_Ready : Boolean with Part_Of => HW.GFX.GMA.State; 27 | 28 | -- Just send a command, discard the reply. 29 | procedure Mailbox_Write 30 | (MBox : in Word32; 31 | Command : in Word64; 32 | Wait_Ready : in Boolean := False; 33 | Wait_Ack : in Boolean := True; 34 | Success : out Boolean) 35 | with 36 | Pre => Mailbox_Ready or Wait_Ready, 37 | Post => (if Wait_Ack and Success then Mailbox_Ready); 38 | 39 | -- Repeatedly send a request command the expected reply is received. 40 | procedure Mailbox_Request 41 | (MBox : in Word32; 42 | Command : in Word64; 43 | Reply_Mask : in Word64; 44 | Reply : in Word64 := 16#ffff_ffff_ffff_ffff#; 45 | TOut_MS : in Natural := Registers.Default_Timeout_MS; 46 | Wait_Ready : in Boolean := False; 47 | Success : out Boolean) 48 | with 49 | Pre => Mailbox_Ready or Wait_Ready, 50 | Post => (if Success then Mailbox_Ready); 51 | 52 | -- For final mailbox commands that don't have to wait. 53 | procedure Mailbox_Write 54 | (MBox : Word32; 55 | Command : Word64; 56 | Wait_Ready : Boolean := False) 57 | with 58 | Pre => Mailbox_Ready or Wait_Ready; 59 | 60 | -- For reading data from PCode 61 | procedure Mailbox_Read 62 | (MBox : in Word32; 63 | Command : in Word64 := 0; 64 | Wait_Ready : in Boolean := False; 65 | Reply : out Word64; 66 | Success : out Boolean) 67 | with 68 | Pre => Mailbox_Ready or Wait_Ready, 69 | Post => (if Success then Mailbox_Ready); 70 | 71 | end HW.GFX.GMA.PCode; 72 | -------------------------------------------------------------------------------- /common/g45/hw-gfx-gma-gmch-vga.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.GMA.Config; 16 | with HW.GFX.GMA.Registers; 17 | 18 | with HW.Debug; 19 | with GNAT.Source_Info; 20 | 21 | use type HW.Word64; 22 | 23 | package body HW.GFX.GMA.GMCH.VGA is 24 | 25 | ADPA_DAC_ENABLE : constant := 1 * 2 ** 31; 26 | ADPA_USE_VGA_HVPOLARITY : constant := 1 * 2 ** 15; 27 | ADPA_VSYNC_DISABLE : constant := 1 * 2 ** 11; 28 | ADPA_HSYNC_DISABLE : constant := 1 * 2 ** 10; 29 | ADPA_VSYNC_ACTIVE_HIGH : constant := 1 * 2 ** 4; 30 | ADPA_HSYNC_ACTIVE_HIGH : constant := 1 * 2 ** 3; 31 | 32 | ADPA_MASK : constant Word32 := 33 | GMCH_PORT_PIPE_SELECT_MASK or 34 | ADPA_DAC_ENABLE or 35 | ADPA_VSYNC_DISABLE or 36 | ADPA_HSYNC_DISABLE or 37 | ADPA_VSYNC_ACTIVE_HIGH or 38 | ADPA_HSYNC_ACTIVE_HIGH or 39 | ADPA_USE_VGA_HVPOLARITY; 40 | 41 | ---------------------------------------------------------------------------- 42 | 43 | procedure On 44 | (Pipe : Pipe_Index; 45 | Mode : in Mode_Type) 46 | is 47 | Polarity : Word32 := 0; 48 | begin 49 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 50 | 51 | if Mode.H_Sync_Active_High then 52 | Polarity := Polarity or ADPA_HSYNC_ACTIVE_HIGH; 53 | end if; 54 | if Mode.V_Sync_Active_High then 55 | Polarity := Polarity or ADPA_VSYNC_ACTIVE_HIGH; 56 | end if; 57 | 58 | Registers.Unset_And_Set_Mask 59 | (Register => Registers.GMCH_ADPA, 60 | Mask_Unset => ADPA_MASK, 61 | Mask_Set => ADPA_DAC_ENABLE or 62 | GMCH_PORT_PIPE_SELECT (Pipe) or 63 | Polarity); 64 | end On; 65 | 66 | ---------------------------------------------------------------------------- 67 | 68 | procedure Off 69 | is 70 | begin 71 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 72 | 73 | Registers.Unset_And_Set_Mask 74 | (Register => Registers.GMCH_ADPA, 75 | Mask_Unset => ADPA_DAC_ENABLE, 76 | Mask_Set => ADPA_HSYNC_DISABLE or 77 | ADPA_VSYNC_DISABLE); 78 | end Off; 79 | 80 | end HW.GFX.GMA.GMCH.VGA; 81 | -------------------------------------------------------------------------------- /common/ironlake/hw-gfx-gma-power_and_clocks.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.Time; 16 | with HW.GFX.GMA.Config; 17 | with HW.GFX.GMA.Registers; 18 | 19 | package body HW.GFX.GMA.Power_And_Clocks is 20 | 21 | PCH_DREF_CONTROL_120MHZ_CPU_OUTPUT_MASK : constant := 3 * 2 ** 13; 22 | PCH_DREF_CONTROL_120MHZ_CPU_OUTPUT_SSC : constant := 2 * 2 ** 13; 23 | PCH_DREF_CONTROL_120MHZ_CPU_OUTPUT_NONSSC : constant := 3 * 2 ** 13; 24 | PCH_DREF_CONTROL_120MHZ_SSC_EN_MASK : constant := 3 * 2 ** 11; 25 | PCH_DREF_CONTROL_120MHZ_SSC_EN : constant := 2 * 2 ** 11; 26 | PCH_DREF_CONTROL_120MHZ_NONSSC_EN_MASK : constant := 3 * 2 ** 9; 27 | PCH_DREF_CONTROL_120MHZ_NONSSC_EN : constant := 2 * 2 ** 9; 28 | PCH_DREF_CONTROL_120MHZ_SSC4_EN_MASK : constant := 3 * 2 ** 7; 29 | PCH_DREF_CONTROL_120MHZ_SSC4_EN : constant := 2 * 2 ** 7; 30 | PCH_DREF_CONTROL_120MHZ_SSC4_DOWNSPREAD : constant := 0 * 2 ** 6; 31 | PCH_DREF_CONTROL_120MHZ_SSC4_CENTERSPREAD : constant := 1 * 2 ** 6; 32 | PCH_DREF_CONTROL_120MHZ_SSC_MODULATION_EN : constant := 1 * 2 ** 1; 33 | PCH_DREF_CONTROL_120MHZ_SSC4_MODULATION_EN : constant := 1 * 2 ** 0; 34 | 35 | procedure Initialize is 36 | begin 37 | -- ILK: enable non-spread spectrum clock, enable spread spectrum clock 38 | Registers.Write 39 | (Register => Registers.PCH_DREF_CONTROL, 40 | Value => PCH_DREF_CONTROL_120MHZ_SSC_EN or 41 | PCH_DREF_CONTROL_120MHZ_NONSSC_EN or 42 | PCH_DREF_CONTROL_120MHZ_SSC_MODULATION_EN); 43 | Registers.Posting_Read (Registers.PCH_DREF_CONTROL); 44 | Time.U_Delay (1); 45 | if Config.Valid_Port (eDP) then 46 | -- always use spread spectrum clock for CPU output 47 | Registers.Set_Mask 48 | (Register => Registers.PCH_DREF_CONTROL, 49 | Mask => PCH_DREF_CONTROL_120MHZ_CPU_OUTPUT_SSC); 50 | Registers.Posting_Read (Registers.PCH_DREF_CONTROL); 51 | Time.U_Delay (20); -- DMI latency 52 | end if; 53 | 54 | Config.CDClk := Config.Default_CDClk_Freq; 55 | Config.Max_CDClk := Config.Default_CDClk_Freq; 56 | Config.Raw_Clock := Config.Default_RawClk_Freq; 57 | end Initialize; 58 | 59 | procedure Limit_Dotclocks 60 | (Configs : in out Pipe_Configs; 61 | CDClk_Switch : out Boolean) 62 | is 63 | begin 64 | Config_Helpers.Limit_Dotclocks (Configs, Config.CDClk * 90 / 100); 65 | CDClk_Switch := False; 66 | end Limit_Dotclocks; 67 | 68 | end HW.GFX.GMA.Power_And_Clocks; 69 | -------------------------------------------------------------------------------- /common/ironlake/hw-gfx-gma-pch-lvds.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2016 secunet Security Networks AG 3 | -- Copyright (C) 2016 Nico Huber 4 | -- 5 | -- This program is free software; you can redistribute it and/or modify 6 | -- it under the terms of the GNU General Public License as published by 7 | -- the Free Software Foundation; either version 2 of the License, or 8 | -- (at your option) any later version. 9 | -- 10 | -- This program is distributed in the hope that it will be useful, 11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | -- GNU General Public License for more details. 14 | -- 15 | 16 | with HW.GFX.GMA.Config; 17 | with HW.GFX.GMA.Registers; 18 | 19 | with HW.Debug; 20 | with GNAT.Source_Info; 21 | 22 | package body HW.GFX.GMA.PCH.LVDS is 23 | 24 | PCH_LVDS_ENABLE : constant := 1 * 2 ** 31; 25 | PCH_LVDS_VSYNC_POLARITY_INVERT : constant := 1 * 2 ** 21; 26 | PCH_LVDS_HSYNC_POLARITY_INVERT : constant := 1 * 2 ** 20; 27 | PCH_LVDS_CLK_A_DATA_A0A2_POWER_MASK : constant := 3 * 2 ** 8; 28 | PCH_LVDS_CLK_A_DATA_A0A2_POWER_DOWN : constant := 0 * 2 ** 8; 29 | PCH_LVDS_CLK_A_DATA_A0A2_POWER_UP : constant := 3 * 2 ** 8; 30 | PCH_LVDS_CLK_B_POWER_MASK : constant := 3 * 2 ** 4; 31 | PCH_LVDS_CLK_B_POWER_DOWN : constant := 0 * 2 ** 4; 32 | PCH_LVDS_CLK_B_POWER_UP : constant := 3 * 2 ** 4; 33 | PCH_LVDS_DATA_B0B2_POWER_MASK : constant := 3 * 2 ** 2; 34 | PCH_LVDS_DATA_B0B2_POWER_DOWN : constant := 0 * 2 ** 2; 35 | PCH_LVDS_DATA_B0B2_POWER_UP : constant := 3 * 2 ** 2; 36 | 37 | ---------------------------------------------------------------------------- 38 | 39 | procedure On (Port_Cfg : Port_Config; FDI_Port : FDI_Port_Type) 40 | is 41 | Sync_Polarity : constant Word32 := 42 | (if Port_Cfg.Mode.H_Sync_Active_High then 0 43 | else PCH_LVDS_HSYNC_POLARITY_INVERT) or 44 | (if Port_Cfg.Mode.V_Sync_Active_High then 0 45 | else PCH_LVDS_VSYNC_POLARITY_INVERT); 46 | 47 | Two_Channel : constant Word32 := 48 | (if Port_Cfg.Mode.Dotclock >= Config.LVDS_Dual_Threshold then 49 | PCH_LVDS_CLK_B_POWER_UP or PCH_LVDS_DATA_B0B2_POWER_UP else 0); 50 | begin 51 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 52 | pragma Debug (Port_Cfg.Mode.BPC /= 6, Debug.Put_Line 53 | ("WARNING: Only 18bpp LVDS mode implemented.")); 54 | 55 | Registers.Write 56 | (Register => Registers.PCH_LVDS, 57 | Value => PCH_LVDS_ENABLE or 58 | PCH_TRANSCODER_SELECT (FDI_Port) or 59 | Sync_Polarity or 60 | PCH_LVDS_CLK_A_DATA_A0A2_POWER_UP or 61 | Two_Channel); 62 | end On; 63 | 64 | ---------------------------------------------------------------------------- 65 | 66 | procedure Off 67 | is 68 | begin 69 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 70 | 71 | Registers.Write 72 | (Register => Registers.PCH_LVDS, 73 | Value => PCH_LVDS_CLK_A_DATA_A0A2_POWER_DOWN or 74 | PCH_LVDS_CLK_B_POWER_DOWN or 75 | PCH_LVDS_DATA_B0B2_POWER_DOWN); 76 | end Off; 77 | 78 | end HW.GFX.GMA.PCH.LVDS; 79 | -------------------------------------------------------------------------------- /common/haswell_shared/hw-gfx-gma-connectors.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2017 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.GMA.Config; 16 | with HW.GFX.GMA.Panel; 17 | with HW.GFX.GMA.Connectors.DDI; 18 | 19 | with HW.Debug; 20 | with GNAT.Source_Info; 21 | 22 | package body HW.GFX.GMA.Connectors is 23 | 24 | procedure Post_Reset_Off 25 | is 26 | begin 27 | DDI.Post_Reset_Off; 28 | end Post_Reset_Off; 29 | 30 | procedure Initialize 31 | is 32 | begin 33 | DDI.Initialize; 34 | end Initialize; 35 | 36 | procedure Pre_On 37 | (Pipe : in Pipe_Index; 38 | Port_Cfg : in Port_Config; 39 | PLL_Hint : in Word32; 40 | Success : out Boolean) 41 | is 42 | begin 43 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 44 | if Port_Cfg.Port in Digital_Port then 45 | DDI.Pre_On (Port_Cfg, PLL_Hint, Success); 46 | else 47 | Success := False; -- Should not happen 48 | end if; 49 | end Pre_On; 50 | 51 | procedure Post_On 52 | (Pipe : in Pipe_Index; 53 | Port_Cfg : in Port_Config; 54 | PLL_Hint : in Word32; 55 | Success : out Boolean) 56 | is 57 | begin 58 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 59 | 60 | if Port_Cfg.Port in Digital_Port then 61 | DDI.Post_On (Port_Cfg); 62 | 63 | Panel.Backlight_On (Port_Cfg.Panel); 64 | Success := True; 65 | else 66 | Success := False; -- Should not happen 67 | end if; 68 | end Post_On; 69 | 70 | ---------------------------------------------------------------------------- 71 | 72 | procedure Pre_Off (Port_Cfg : Port_Config) 73 | is 74 | begin 75 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 76 | 77 | Panel.Backlight_Off (Port_Cfg.Panel); 78 | Panel.Off (Port_Cfg.Panel); 79 | end Pre_Off; 80 | 81 | procedure Post_Off (Port_Cfg : Port_Config) 82 | is 83 | begin 84 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 85 | if Port_Cfg.Port in Digital_Port then 86 | DDI.Off (Port_Cfg.Port); 87 | end if; 88 | end Post_Off; 89 | 90 | ---------------------------------------------------------------------------- 91 | 92 | procedure Pre_All_Off 93 | is 94 | begin 95 | for P in Valid_Panels loop 96 | Panel.Backlight_Off (P); 97 | Panel.Off (P); 98 | end loop; 99 | end Pre_All_Off; 100 | 101 | procedure Post_All_Off 102 | is 103 | begin 104 | for Port in Digital_Port range DIGI_A .. Config.Last_Digital_Port loop 105 | DDI.Off (Port); 106 | end loop; 107 | end Post_All_Off; 108 | 109 | end HW.GFX.GMA.Connectors; 110 | -------------------------------------------------------------------------------- /common/g45/hw-gfx-gma-gmch-lvds.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2016 secunet Security Networks AG 3 | -- Copyright (C) 2016 Nico Huber 4 | -- 5 | -- This program is free software; you can redistribute it and/or modify 6 | -- it under the terms of the GNU General Public License as published by 7 | -- the Free Software Foundation; either version 2 of the License, or 8 | -- (at your option) any later version. 9 | -- 10 | -- This program is distributed in the hope that it will be useful, 11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | -- GNU General Public License for more details. 14 | -- 15 | 16 | with HW.GFX.GMA.Config; 17 | with HW.GFX.GMA.Registers; 18 | 19 | with HW.Debug; 20 | with GNAT.Source_Info; 21 | 22 | package body HW.GFX.GMA.GMCH.LVDS is 23 | 24 | LVDS_ENABLE : constant := 1 * 2 ** 31; 25 | LVDS_DITHER_EN : constant := 1 * 2 ** 25; 26 | LVDS_VSYNC_POLARITY_INVERT : constant := 1 * 2 ** 21; 27 | LVDS_HSYNC_POLARITY_INVERT : constant := 1 * 2 ** 20; 28 | LVDS_CLK_A_DATA_A0A2_POWER_MASK : constant := 3 * 2 ** 8; 29 | LVDS_CLK_A_DATA_A0A2_POWER_DOWN : constant := 0 * 2 ** 8; 30 | LVDS_CLK_A_DATA_A0A2_POWER_UP : constant := 3 * 2 ** 8; 31 | LVDS_CLK_B_POWER_MASK : constant := 3 * 2 ** 4; 32 | LVDS_CLK_B_POWER_DOWN : constant := 0 * 2 ** 4; 33 | LVDS_CLK_B_POWER_UP : constant := 3 * 2 ** 4; 34 | LVDS_DATA_B0B2_POWER_MASK : constant := 3 * 2 ** 2; 35 | LVDS_DATA_B0B2_POWER_DOWN : constant := 0 * 2 ** 2; 36 | LVDS_DATA_B0B2_POWER_UP : constant := 3 * 2 ** 2; 37 | 38 | ---------------------------------------------------------------------------- 39 | 40 | procedure On (Port_Cfg : in Port_Config; 41 | Pipe : in Pipe_Index) 42 | is 43 | Sync_Polarity : constant Word32 := 44 | (if Port_Cfg.Mode.H_Sync_Active_High then 0 45 | else LVDS_HSYNC_POLARITY_INVERT) or 46 | (if Port_Cfg.Mode.V_Sync_Active_High then 0 47 | else LVDS_VSYNC_POLARITY_INVERT); 48 | 49 | Two_Channel : constant Word32 := 50 | (if Port_Cfg.Mode.Dotclock >= Config.LVDS_Dual_Threshold then 51 | LVDS_CLK_B_POWER_UP or LVDS_DATA_B0B2_POWER_UP else 0); 52 | begin 53 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 54 | pragma Debug (Port_Cfg.Mode.BPC /= 6, Debug.Put_Line 55 | ("WARNING: Only 18bpp LVDS mode implemented.")); 56 | 57 | Registers.Write 58 | (Register => Registers.GMCH_LVDS, 59 | Value => LVDS_ENABLE or 60 | GMCH_PORT_PIPE_SELECT(Pipe) or 61 | Sync_Polarity or 62 | LVDS_CLK_A_DATA_A0A2_POWER_UP or 63 | Two_Channel or 64 | LVDS_DITHER_EN); 65 | end On; 66 | 67 | ---------------------------------------------------------------------------- 68 | 69 | procedure Off 70 | is 71 | begin 72 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 73 | 74 | Registers.Write 75 | (Register => Registers.GMCH_LVDS, 76 | Value => LVDS_CLK_A_DATA_A0A2_POWER_DOWN or 77 | LVDS_CLK_B_POWER_DOWN or 78 | LVDS_DATA_B0B2_POWER_DOWN); 79 | end Off; 80 | 81 | end HW.GFX.GMA.GMCH.LVDS; 82 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | libgfxinit 2 | ========== 3 | 4 | *libgfxinit* is a graphics initialization (aka modesetting) library 5 | for embedded environments. It currently supports only Intel hardware, 6 | more specifically the Intel Core processor line. 7 | 8 | It can query and set up most kinds of displays based on their EDID 9 | information. You can, however, also specify particular mode lines. 10 | 11 | *libgfxinit* is written in SPARK, an Ada subset with formal 12 | verification aspects. Absence of runtime errors can be proved 13 | automatically with SPARK GPL 2016. 14 | 15 | 16 | Building on Linux 17 | ================= 18 | 19 | Prerequisites 20 | ------------- 21 | 22 | For compilation, the GNAT Ada compiler is required. Usual package 23 | names in Linux distributions are `gcc-ada` and `gnat`. 24 | 25 | Grab the Sources 26 | ---------------- 27 | 28 | You'll need *libhwbase* and *libgfxinit*. Best is to clone the 29 | repositories into a common parent directory (this way *libgfxinit* 30 | will know where to find *libhwbase*). 31 | 32 | $ mkdir gfxfun && cd gfxfun 33 | $ git clone https://review.coreboot.org/p/libhwbase.git 34 | $ git clone https://review.coreboot.org/p/libgfxinit.git 35 | 36 | Configure and Install libhwbase 37 | ------------------------------- 38 | 39 | Both libraries are currently configured by hand-written config files. 40 | You can either write your own `.config`, link one of the shipped files 41 | in `configs/`, e.g.: 42 | 43 | $ ln -s configs/linux libhwbase/.config 44 | 45 | or overwrite the config filename by specifying `cnf=` on 46 | the make command line. 47 | 48 | By default most debug messages won't be compiled into the binary. To 49 | include them into the build, set `DEBUG=1` on the command line or in 50 | your `.config`. 51 | 52 | Let's install *libhwbase*. We'll need `configs/linux` to build regular 53 | Linux executables: 54 | 55 | $ cd libhwbase 56 | $ make DEBUG=1 cnf=configs/linux install 57 | 58 | By default this installs into a new subdirectory `dest`. You can however 59 | overwrite this decision by specifying `DESTDIR=`. 60 | 61 | Build libgfxinit/`gfx_test` 62 | --------------------------- 63 | 64 | *libgfxinit* is configured and installed in the same manner as 65 | described above. You will have to select a configuration matching your 66 | hardware. 67 | 68 | The makefile knows an additional target `gfx_test` to build a small 69 | Linux test application: 70 | 71 | $ cd ../libgfxinit 72 | $ make DEBUG=1 cnf=configs/sandybridge gfx_test 73 | 74 | The resulting binary is `build/gfx_test`. 75 | 76 | 77 | Testing libgfxinit on Linux 78 | =========================== 79 | 80 | `gfx_test` sets up its own framebuffer in the *stolen memory*. It 81 | backs any current framebuffer mapping and contents up first and 82 | restores it before exiting. This works somehow even while the *i915* 83 | driver is running. A wrapper script `gfxtest/gfx_test.sh` is 84 | provided to help with the setup. It switches to a text console first 85 | and tries to unload the *i915* driver. But ignores failures to do 86 | so (it won't work if you still have any application running that 87 | uses the gfx driver, e.g. an X server). 88 | 89 | # gfxtest/gfx_test.sh 90 | 91 | If you chose the right config above, you should be presented with a 92 | nice test image. But please be prepared that your console might be 93 | stuck in that state afterwards. You can try to run it with *i915* 94 | deactivated then (e.g. when booting with `nomodeset` in the kernel 95 | command line or with *i915* blacklisted) and loading it afterwards. 96 | -------------------------------------------------------------------------------- /common/hw-gfx-gma-config_helpers.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2017 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.GMA.Config; 16 | 17 | private package HW.GFX.GMA.Config_Helpers 18 | is 19 | 20 | function To_GPU_Port 21 | (Pipe : Pipe_Index; 22 | Port : Active_Port_Type) 23 | return GPU_Port; 24 | 25 | function To_PCH_Port (Port : Active_Port_Type) return PCH_Port; 26 | 27 | function To_Display_Type (Port : Active_Port_Type) return Display_Type; 28 | 29 | function To_Panel (Port : Active_Port_Type) return Panel_Control; 30 | 31 | procedure Fill_Port_Config 32 | (Port_Cfg : out Port_Config; 33 | Pipe : in Pipe_Index; 34 | Port : in Port_Type; 35 | Mode : in Mode_Type; 36 | Success : out Boolean) 37 | with 38 | Post => 39 | (if Success then 40 | Port_Cfg.Mode.H_Visible = Mode.H_Visible and 41 | Port_Cfg.Mode.V_Visible = Mode.V_Visible); 42 | 43 | ---------------------------------------------------------------------------- 44 | 45 | pragma Warnings (GNAT, Off, """Integer_32"" is already use-visible *", 46 | Reason => "Needed for older compiler versions"); 47 | use type HW.Pos32; 48 | pragma Warnings (GNAT, On, """Integer_32"" is already use-visible *"); 49 | 50 | -- Validate just enough to satisfy Pipe_Setup pre conditions. 51 | function Valid_FB 52 | (FB : Framebuffer_Type; 53 | Mode : Mode_Type) 54 | return Boolean is 55 | (Rotated_Width (FB) <= Mode.H_Visible and 56 | Rotated_Height (FB) <= Mode.V_Visible and 57 | (FB.Offset = VGA_PLANE_FRAMEBUFFER_OFFSET or 58 | FB.Height + FB.Start_Y <= FB.V_Stride)); 59 | 60 | -- Also validate that we only use supported values / features. 61 | function Validate_Config 62 | (FB : Framebuffer_Type; 63 | Mode : Mode_Type; 64 | Pipe : Pipe_Index) 65 | return Boolean 66 | with 67 | Post => (if Validate_Config'Result then Valid_FB (FB, Mode)); 68 | 69 | -- For still active pipes, ensure only timings 70 | -- changed that don't affect FB validity. 71 | function Stable_FB (Old_C, New_C : Pipe_Configs) return Boolean is 72 | (for all P in Pipe_Index => 73 | New_C (P).Port = Disabled or 74 | (New_C (P).Port = Old_C (P).Port and 75 | New_C (P).Framebuffer = Old_C (P).Framebuffer and 76 | New_C (P).Cursor = Old_C (P).Cursor and 77 | New_C (P).Mode.H_Visible = Old_C (P).Mode.H_Visible and 78 | New_C (P).Mode.V_Visible = Old_C (P).Mode.V_Visible)); 79 | 80 | ---------------------------------------------------------------------------- 81 | 82 | function Highest_Dotclock (Configs : Pipe_Configs) return Frequency_Type; 83 | 84 | procedure Limit_Dotclocks 85 | (Configs : in out Pipe_Configs; 86 | Max : in Frequency_Type) 87 | with 88 | Post => Stable_FB (Configs'Old, Configs); 89 | 90 | end HW.GFX.GMA.Config_Helpers; 91 | -------------------------------------------------------------------------------- /common/g45/hw-gfx-gma-gmch-hdmi.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.GMA.Registers; 16 | 17 | with HW.Debug; 18 | with GNAT.Source_Info; 19 | 20 | package body HW.GFX.GMA.GMCH.HDMI 21 | is 22 | 23 | GMCH_HDMI_ENABLE : constant := 1 * 2 ** 31; 24 | GMCH_HDMI_COLOR_FORMAT_8BPC : constant := 0 * 2 ** 26; 25 | GMCH_HDMI_COLOR_FORMAT_12BPC : constant := 3 * 2 ** 26; 26 | GMCH_HDMI_COLOR_FORMAT_MASK : constant := 7 * 2 ** 26; 27 | GMCH_HDMI_SDVO_ENCODING_SDVO : constant := 0 * 2 ** 10; 28 | GMCH_HDMI_SDVO_ENCODING_HDMI : constant := 2 * 2 ** 10; 29 | GMCH_HDMI_SDVO_ENCODING_MASK : constant := 3 * 2 ** 10; 30 | GMCH_HDMI_MODE_SELECT_HDMI : constant := 1 * 2 ** 9; 31 | GMCH_HDMI_MODE_SELECT_DVI : constant := 0 * 2 ** 9; 32 | GMCH_HDMI_VSYNC_ACTIVE_HIGH : constant := 1 * 2 ** 4; 33 | GMCH_HDMI_HSYNC_ACTIVE_HIGH : constant := 1 * 2 ** 3; 34 | GMCH_HDMI_PORT_DETECT : constant := 1 * 2 ** 2; 35 | 36 | GMCH_HDMI_MASK : constant Word32 := 37 | GMCH_PORT_PIPE_SELECT_MASK or 38 | GMCH_HDMI_ENABLE or 39 | GMCH_HDMI_COLOR_FORMAT_MASK or 40 | GMCH_HDMI_SDVO_ENCODING_MASK or 41 | GMCH_HDMI_MODE_SELECT_HDMI or 42 | GMCH_HDMI_HSYNC_ACTIVE_HIGH or 43 | GMCH_HDMI_VSYNC_ACTIVE_HIGH; 44 | 45 | type GMCH_HDMI_Array is array (GMCH_HDMI_Port) of Registers.Registers_Index; 46 | GMCH_HDMI : constant GMCH_HDMI_Array := GMCH_HDMI_Array' 47 | (DIGI_B => Registers.GMCH_HDMIB, 48 | DIGI_C => Registers.GMCH_HDMIC); 49 | 50 | ---------------------------------------------------------------------------- 51 | 52 | procedure On (Port_Cfg : in Port_Config; 53 | Pipe : in Pipe_Index) 54 | is 55 | Polarity : constant Word32 := 56 | (if Port_Cfg.Mode.H_Sync_Active_High then 57 | GMCH_HDMI_HSYNC_ACTIVE_HIGH else 0) or 58 | (if Port_Cfg.Mode.V_Sync_Active_High then 59 | GMCH_HDMI_VSYNC_ACTIVE_HIGH else 0); 60 | begin 61 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 62 | 63 | Registers.Unset_And_Set_Mask 64 | (Register => GMCH_HDMI (Port_Cfg.Port), 65 | Mask_Unset => GMCH_HDMI_MASK, 66 | Mask_Set => GMCH_HDMI_ENABLE or 67 | GMCH_PORT_PIPE_SELECT (Pipe) or 68 | GMCH_HDMI_SDVO_ENCODING_HDMI or 69 | GMCH_HDMI_MODE_SELECT_DVI or 70 | Polarity); 71 | end On; 72 | 73 | ---------------------------------------------------------------------------- 74 | 75 | procedure Off (Port : GMCH_HDMI_Port) 76 | is 77 | begin 78 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 79 | 80 | Registers.Unset_And_Set_Mask 81 | (Register => GMCH_HDMI (Port), 82 | Mask_Unset => GMCH_HDMI_MASK, 83 | Mask_Set => GMCH_HDMI_HSYNC_ACTIVE_HIGH or 84 | GMCH_HDMI_VSYNC_ACTIVE_HIGH); 85 | end Off; 86 | 87 | procedure All_Off 88 | is 89 | begin 90 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 91 | 92 | for Port in GMCH_HDMI_Port loop 93 | Off (Port); 94 | end loop; 95 | end All_Off; 96 | 97 | end HW.GFX.GMA.GMCH.HDMI; 98 | -------------------------------------------------------------------------------- /common/hw-gfx-gma-connector_info.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2017 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.GMA.Config; 16 | with HW.GFX.GMA.Panel; 17 | with HW.GFX.GMA.DP_Dual_Mode; 18 | with HW.GFX.GMA.DP_Info; 19 | 20 | with HW.Debug; 21 | with GNAT.Source_Info; 22 | 23 | package body HW.GFX.GMA.Connector_Info is 24 | 25 | procedure Preferred_Link_Setting 26 | (Port_Cfg : in out Port_Config; 27 | Success : out Boolean) 28 | is 29 | DP_Port : constant GMA.DP_Port := 30 | (if Config.Has_Type_C_Ports 31 | then 32 | (case Port_Cfg.Port is 33 | when DIGI_A => DP_A, 34 | when DIGI_B => DP_B, 35 | when DIGI_C => DP_C, 36 | when DDI_TC1 => DP_D, 37 | when DDI_TC2 => DP_E, 38 | when DDI_TC3 => DP_F, 39 | when DDI_TC4 => DP_G, 40 | when DDI_TC5 => DP_H, 41 | when DDI_TC6 => DP_I, 42 | when others => GMA.DP_Port'First) 43 | else 44 | (if Port_Cfg.Port = DIGI_A then 45 | DP_A 46 | else 47 | (case Port_Cfg.PCH_Port is 48 | when PCH_DP_B => DP_B, 49 | when PCH_DP_C => DP_C, 50 | when PCH_DP_D => DP_D, 51 | when others => GMA.DP_Port'First))); 52 | begin 53 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 54 | 55 | if Port_Cfg.Display = DP then 56 | if GMA.Config.Use_PP_VDD_Override then 57 | Panel.VDD_Override (Port_Cfg.Panel); 58 | else 59 | Panel.On (Port_Cfg.Panel); 60 | end if; 61 | 62 | DP_Dual_Mode.Switch_LSPCON (DP_Port); 63 | 64 | DP_Info.Read_Caps 65 | (Link => Port_Cfg.DP, 66 | Port => DP_Port, 67 | Success => Success); 68 | if Success then 69 | DP_Info.Read_eDP_Rates 70 | (Link => Port_Cfg.DP, 71 | Port => DP_Port); 72 | 73 | DP_Info.Preferred_Link_Setting 74 | (Link => Port_Cfg.DP, 75 | Mode => Port_Cfg.Mode, 76 | Success => Success); 77 | pragma Debug (Success, DP_Info.Dump_Link_Setting (Port_Cfg.DP)); 78 | end if; 79 | else 80 | Success := True; 81 | end if; 82 | end Preferred_Link_Setting; 83 | 84 | procedure Next_Link_Setting 85 | (Port_Cfg : in out Port_Config; 86 | Success : out Boolean) 87 | is 88 | begin 89 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 90 | 91 | if Port_Cfg.Display = DP then 92 | DP_Info.Next_Link_Setting 93 | (Link => Port_Cfg.DP, 94 | Mode => Port_Cfg.Mode, 95 | Success => Success); 96 | pragma Debug (Success, DP_Info.Dump_Link_Setting (Port_Cfg.DP)); 97 | else 98 | Success := False; 99 | end if; 100 | end Next_Link_Setting; 101 | 102 | ---------------------------------------------------------------------------- 103 | 104 | function Default_BPC (Port_Cfg : Port_Config) return HW.GFX.BPC_Type 105 | is 106 | begin 107 | return 108 | (if Port_Cfg.Port = DIGI_A or 109 | (Port_Cfg.Is_FDI and Port_Cfg.PCH_Port = PCH_LVDS) or 110 | Port_Cfg.Port = LVDS 111 | then 6 112 | else 8); 113 | end Default_BPC; 114 | 115 | end HW.GFX.GMA.Connector_Info; 116 | -------------------------------------------------------------------------------- /common/g45/hw-gfx-gma-connectors.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2016 secunet Security Networks AG 3 | -- Copyright (C) 2016 Nico Huber 4 | -- 5 | -- This program is free software; you can redistribute it and/or modify 6 | -- it under the terms of the GNU General Public License as published by 7 | -- the Free Software Foundation; either version 2 of the License, or 8 | -- (at your option) any later version. 9 | -- 10 | -- This program is distributed in the hope that it will be useful, 11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | -- GNU General Public License for more details. 14 | -- 15 | 16 | with HW.GFX.GMA.Config; 17 | with HW.GFX.GMA.Panel; 18 | with HW.GFX.GMA.GMCH.VGA; 19 | with HW.GFX.GMA.GMCH.LVDS; 20 | with HW.GFX.GMA.GMCH.HDMI; 21 | with HW.GFX.GMA.GMCH.DP; 22 | 23 | with HW.Debug; 24 | with GNAT.Source_Info; 25 | 26 | package body HW.GFX.GMA.Connectors 27 | is 28 | 29 | procedure Post_Reset_Off is null; 30 | procedure Initialize is null; 31 | 32 | ---------------------------------------------------------------------------- 33 | 34 | procedure Pre_On 35 | (Pipe : in Pipe_Index; 36 | Port_Cfg : in Port_Config; 37 | PLL_Hint : in Word32; 38 | Success : out Boolean) 39 | is 40 | begin 41 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 42 | Success := True; 43 | end Pre_On; 44 | 45 | procedure Post_On 46 | (Pipe : in Pipe_Index; 47 | Port_Cfg : in Port_Config; 48 | PLL_Hint : in Word32; 49 | Success : out Boolean) 50 | is 51 | begin 52 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 53 | Success := True; 54 | if Port_Cfg.Port = LVDS then 55 | GMCH.LVDS.On (Port_Cfg, Pipe); 56 | elsif Port_Cfg.Port = VGA then 57 | GMCH.VGA.On (Pipe, Port_Cfg.Mode); 58 | elsif Port_Cfg.Port in Digital_Port then 59 | if Port_Cfg.Display = DP and Port_Cfg.Port in GMCH_DP_Port then 60 | GMCH.DP.On (Port_Cfg, Pipe, Success); 61 | elsif Port_Cfg.Display = HDMI and Port_Cfg.Port in GMCH_HDMI_Port then 62 | GMCH.HDMI.On (Port_Cfg, Pipe); 63 | end if; 64 | end if; 65 | 66 | Panel.On (Port_Cfg.Panel, Wait => False); 67 | Panel.Backlight_On (Port_Cfg.Panel); 68 | end Post_On; 69 | 70 | ---------------------------------------------------------------------------- 71 | 72 | procedure Pre_Off (Port_Cfg : Port_Config) 73 | is 74 | begin 75 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 76 | 77 | Panel.Backlight_Off (Port_Cfg.Panel); 78 | Panel.Off (Port_Cfg.Panel); 79 | end Pre_Off; 80 | 81 | procedure Post_Off (Port_Cfg : Port_Config) 82 | is 83 | begin 84 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 85 | if Port_Cfg.Port = LVDS then 86 | GMCH.LVDS.Off; 87 | elsif Port_Cfg.Port = VGA then 88 | GMCH.VGA.Off; 89 | elsif Port_Cfg.Display = DP and Port_Cfg.Port in GMCH_DP_Port then 90 | GMCH.DP.Off (Port_Cfg.Port); 91 | elsif Port_Cfg.Display = HDMI and Port_Cfg.Port in GMCH_HDMI_Port then 92 | GMCH.HDMI.Off (Port_Cfg.Port); 93 | end if; 94 | end Post_Off; 95 | 96 | ---------------------------------------------------------------------------- 97 | 98 | procedure Pre_All_Off 99 | is 100 | begin 101 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 102 | 103 | for P in Valid_Panels loop 104 | Panel.Backlight_Off (P); 105 | Panel.Off (P); 106 | end loop; 107 | end Pre_All_Off; 108 | 109 | procedure Post_All_Off 110 | is 111 | begin 112 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 113 | GMCH.LVDS.Off; 114 | GMCH.VGA.Off; 115 | GMCH.DP.All_Off; 116 | GMCH.HDMI.All_Off; 117 | end Post_All_Off; 118 | 119 | end HW.GFX.GMA.Connectors; 120 | -------------------------------------------------------------------------------- /common/haswell/hw-gfx-gma-plls.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2016, 2019 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.GMA.Config; 16 | with HW.GFX.GMA.PLLs.LCPLL; 17 | with HW.GFX.GMA.PLLs.WRPLL; 18 | 19 | with HW.Debug; 20 | with GNAT.Source_Info; 21 | 22 | package body HW.GFX.GMA.PLLs 23 | with 24 | Refined_State => (State => PLLs) 25 | is 26 | 27 | type Count_Range is new Natural range 0 .. 2; 28 | 29 | type PLL_State is record 30 | Use_Count : Count_Range; 31 | Mode : Mode_Type; 32 | end record; 33 | 34 | type PLL_State_Array is array (WRPLLs) of PLL_State; 35 | 36 | PLLs : PLL_State_Array; 37 | 38 | procedure Initialize 39 | is 40 | begin 41 | PLLs := (WRPLLs => (Use_Count => 0, Mode => Invalid_Mode)); 42 | end Initialize; 43 | 44 | procedure Alloc_Configurable 45 | (Mode : in Mode_Type; 46 | PLL : out T; 47 | Success : out Boolean) 48 | with 49 | Pre => True 50 | is 51 | begin 52 | -- try to find shareable PLL 53 | for P in WRPLLs loop 54 | Success := PLLs (P).Use_Count /= 0 and 55 | PLLs (P).Use_Count /= Count_Range'Last and 56 | PLLs (P).Mode = Mode; 57 | if Success then 58 | PLL := P; 59 | PLLs (PLL).Use_Count := PLLs (PLL).Use_Count + 1; 60 | return; 61 | end if; 62 | end loop; 63 | 64 | -- try to find free PLL 65 | for P in WRPLLs loop 66 | if PLLs (P).Use_Count = 0 then 67 | PLL := P; 68 | WRPLL.On (PLL, Mode.Dotclock, Success); 69 | if Success then 70 | PLLs (PLL) := (Use_Count => 1, Mode => Mode); 71 | end if; 72 | return; 73 | end if; 74 | end loop; 75 | 76 | PLL := Invalid; 77 | end Alloc_Configurable; 78 | 79 | procedure Alloc 80 | (Port_Cfg : in Port_Config; 81 | PLL : out T; 82 | Success : out Boolean) 83 | is 84 | begin 85 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 86 | 87 | if Port_Cfg.Port = DIGI_E then 88 | PLL := Invalid; 89 | Success := True; 90 | elsif Port_Cfg.Display = DP then 91 | if Config.DP_Max_2_7_GHz and then 92 | Port_Cfg.DP.Bandwidth > DP_Bandwidth_2_7 93 | then 94 | PLL := Invalid; 95 | Success := False; 96 | else 97 | PLL := LCPLL.Fixed_LCPLLs (Port_Cfg.DP.Bandwidth); 98 | Success := True; 99 | end if; 100 | else 101 | Alloc_Configurable (Port_Cfg.Mode, PLL, Success); 102 | end if; 103 | end Alloc; 104 | 105 | procedure Free (PLL : T) 106 | is 107 | begin 108 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 109 | 110 | if PLL in WRPLLs then 111 | if PLLs (PLL).Use_Count /= 0 then 112 | PLLs (PLL).Use_Count := PLLs (PLL).Use_Count - 1; 113 | if PLLs (PLL).Use_Count = 0 then 114 | WRPLL.Off (PLL); 115 | end if; 116 | end if; 117 | end if; 118 | end Free; 119 | 120 | procedure All_Off 121 | is 122 | begin 123 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 124 | 125 | for PLL in WRPLLs loop 126 | WRPLL.Off (PLL); 127 | end loop; 128 | end All_Off; 129 | 130 | function Register_Value (PLL : T) return Word32 131 | is 132 | begin 133 | return 134 | (if PLL in LCPLLs then LCPLL.Register_Value (PLL) 135 | elsif PLL in WRPLLs then WRPLL.Register_Value (PLL) 136 | else 0); 137 | end Register_Value; 138 | 139 | end HW.GFX.GMA.PLLs; 140 | -------------------------------------------------------------------------------- /common/skylake/hw-gfx-gma-plls.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.GMA.PLLs.DPLL_0; 16 | with HW.GFX.GMA.PLLs.DPLL; 17 | 18 | with HW.Debug; 19 | with GNAT.Source_Info; 20 | 21 | package body HW.GFX.GMA.PLLs 22 | with 23 | Refined_State => (State => PLLs) 24 | is 25 | 26 | type Count_Range is new Natural range 0 .. 2; 27 | 28 | type PLL_State is record 29 | Use_Count : Count_Range; 30 | Used_For_DP : Boolean; 31 | Link_Rate : DP_Bandwidth; 32 | Mode : Mode_Type; 33 | end record; 34 | 35 | type PLL_State_Array is array (Configurable_DPLLs) of PLL_State; 36 | 37 | PLLs : PLL_State_Array; 38 | 39 | procedure Initialize 40 | is 41 | begin 42 | PLLs := 43 | (Configurable_DPLLs => 44 | (Use_Count => 0, 45 | Used_For_DP => False, 46 | Link_Rate => DP_Bandwidth'First, 47 | Mode => Invalid_Mode)); 48 | end Initialize; 49 | 50 | procedure Alloc_Configurable 51 | (Port_Cfg : in Port_Config; 52 | PLL : out T; 53 | Success : out Boolean) 54 | with 55 | Pre => True 56 | is 57 | function Config_Matches (PE : PLL_State) return Boolean 58 | is 59 | begin 60 | return 61 | PE.Used_For_DP = (Port_Cfg.Display = DP) and 62 | ((PE.Used_For_DP and PE.Link_Rate = Port_Cfg.DP.Bandwidth) or 63 | (not PE.Used_For_DP and PE.Mode = Port_Cfg.Mode)); 64 | end Config_Matches; 65 | begin 66 | -- try to find shareable PLL 67 | for P in Configurable_DPLLs loop 68 | Success := PLLs (P).Use_Count /= 0 and 69 | PLLs (P).Use_Count /= Count_Range'Last and 70 | Config_Matches (PLLs (P)); 71 | if Success then 72 | PLL := P; 73 | PLLs (PLL).Use_Count := PLLs (PLL).Use_Count + 1; 74 | return; 75 | end if; 76 | end loop; 77 | 78 | -- try to find free PLL 79 | for P in Configurable_DPLLs loop 80 | if PLLs (P).Use_Count = 0 then 81 | PLL := P; 82 | DPLL.On (PLL, Port_Cfg, Success); 83 | if Success then 84 | PLLs (PLL) := 85 | (Use_Count => 1, 86 | Used_For_DP => Port_Cfg.Display = DP, 87 | Link_Rate => Port_Cfg.DP.Bandwidth, 88 | Mode => Port_Cfg.Mode); 89 | end if; 90 | return; 91 | end if; 92 | end loop; 93 | 94 | PLL := Invalid; 95 | end Alloc_Configurable; 96 | 97 | procedure Alloc 98 | (Port_Cfg : in Port_Config; 99 | PLL : out T; 100 | Success : out Boolean) 101 | is 102 | begin 103 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 104 | 105 | if Port_Cfg.Port = DIGI_A then 106 | DPLL_0.Check_Link_Rate (Port_Cfg.DP.Bandwidth, Success); 107 | else 108 | Success := False; 109 | end if; 110 | 111 | if Success then 112 | PLL := DPLL0; 113 | else 114 | Alloc_Configurable (Port_Cfg, PLL, Success); 115 | end if; 116 | end Alloc; 117 | 118 | procedure Free (PLL : T) 119 | is 120 | begin 121 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 122 | 123 | if PLL in Configurable_DPLLs then 124 | if PLLs (PLL).Use_Count /= 0 then 125 | PLLs (PLL).Use_Count := PLLs (PLL).Use_Count - 1; 126 | if PLLs (PLL).Use_Count = 0 then 127 | DPLL.Off (PLL); 128 | end if; 129 | end if; 130 | end if; 131 | end Free; 132 | 133 | procedure All_Off 134 | is 135 | begin 136 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 137 | 138 | for PLL in Configurable_DPLLs loop 139 | DPLL.Off (PLL); 140 | end loop; 141 | end All_Off; 142 | 143 | function Register_Value (PLL : T) return Word32 144 | is 145 | begin 146 | return 147 | (if PLL = DPLL0 then DPLL_0.Register_Value 148 | elsif PLL in Configurable_DPLLs then DPLL.Register_Value (PLL) 149 | else 0); 150 | end Register_Value; 151 | 152 | end HW.GFX.GMA.PLLs; 153 | -------------------------------------------------------------------------------- /common/ironlake/hw-gfx-gma-pch-hdmi.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2016 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.GMA.Registers; 16 | 17 | with HW.Debug; 18 | with GNAT.Source_Info; 19 | 20 | package body HW.GFX.GMA.PCH.HDMI 21 | is 22 | 23 | PCH_HDMI_ENABLE : constant := 1 * 2 ** 31; 24 | PCH_HDMI_COLOR_FORMAT_8BPC : constant := 0 * 2 ** 26; 25 | PCH_HDMI_COLOR_FORMAT_12BPC : constant := 3 * 2 ** 26; 26 | PCH_HDMI_COLOR_FORMAT_MASK : constant := 7 * 2 ** 26; 27 | PCH_HDMI_SDVO_ENCODING_SDVO : constant := 0 * 2 ** 10; 28 | PCH_HDMI_SDVO_ENCODING_HDMI : constant := 2 * 2 ** 10; 29 | PCH_HDMI_SDVO_ENCODING_MASK : constant := 3 * 2 ** 10; 30 | PCH_HDMI_VSYNC_ACTIVE_HIGH : constant := 1 * 2 ** 4; 31 | PCH_HDMI_HSYNC_ACTIVE_HIGH : constant := 1 * 2 ** 3; 32 | PCH_HDMI_PORT_DETECT : constant := 1 * 2 ** 2; 33 | 34 | function PCH_HDMI_MASK return Word32 is 35 | (PCH_TRANSCODER_SELECT_MASK or 36 | PCH_HDMI_ENABLE or 37 | PCH_HDMI_COLOR_FORMAT_MASK or 38 | PCH_HDMI_SDVO_ENCODING_MASK or 39 | PCH_HDMI_HSYNC_ACTIVE_HIGH or 40 | PCH_HDMI_VSYNC_ACTIVE_HIGH); 41 | 42 | type PCH_HDMI_Array is array (IRL_PCH_HDMI_Port) of Registers.Registers_Index; 43 | PCH_HDMI : constant PCH_HDMI_Array := PCH_HDMI_Array' 44 | (PCH_HDMI_B => Registers.PCH_HDMIB, 45 | PCH_HDMI_C => Registers.PCH_HDMIC, 46 | PCH_HDMI_D => Registers.PCH_HDMID); 47 | 48 | ---------------------------------------------------------------------------- 49 | 50 | procedure On (Port_Cfg : Port_Config; FDI_Port : FDI_Port_Type) 51 | is 52 | Polarity : constant Word32 := 53 | (if Port_Cfg.Mode.H_Sync_Active_High then 54 | PCH_HDMI_HSYNC_ACTIVE_HIGH else 0) or 55 | (if Port_Cfg.Mode.V_Sync_Active_High then 56 | PCH_HDMI_VSYNC_ACTIVE_HIGH else 0); 57 | begin 58 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 59 | 60 | -- registers are just sufficient for setup with DVI adaptor 61 | 62 | Registers.Unset_And_Set_Mask 63 | (Register => PCH_HDMI (Port_Cfg.PCH_Port), 64 | Mask_Unset => PCH_HDMI_MASK, 65 | Mask_Set => PCH_HDMI_ENABLE or 66 | PCH_TRANSCODER_SELECT (FDI_Port) or 67 | PCH_HDMI_SDVO_ENCODING_HDMI or 68 | Polarity); 69 | Registers.Posting_Read (PCH_HDMI (Port_Cfg.PCH_Port)); 70 | -- Set enable a second time, hardware may miss the first. 71 | Registers.Set_Mask (PCH_HDMI (Port_Cfg.PCH_Port), PCH_HDMI_ENABLE); 72 | Registers.Posting_Read (PCH_HDMI (Port_Cfg.PCH_Port)); 73 | end On; 74 | 75 | ---------------------------------------------------------------------------- 76 | 77 | procedure Off (Port : IRL_PCH_HDMI_Port) 78 | is 79 | With_Transcoder_B_Enabled : Boolean := False; 80 | begin 81 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 82 | 83 | if not Config.Has_Trans_DP_Ctl then 84 | -- Ensure transcoder select isn't set to B, 85 | -- disabled HDMI may block DP otherwise. 86 | Registers.Is_Set_Mask 87 | (Register => PCH_HDMI (Port), 88 | Mask => PCH_HDMI_ENABLE or 89 | PCH_TRANSCODER_SELECT (FDI_B), 90 | Result => With_Transcoder_B_Enabled); 91 | end if; 92 | 93 | Registers.Unset_And_Set_Mask 94 | (Register => PCH_HDMI (Port), 95 | Mask_Unset => PCH_HDMI_MASK, 96 | Mask_Set => PCH_HDMI_HSYNC_ACTIVE_HIGH or 97 | PCH_HDMI_VSYNC_ACTIVE_HIGH); 98 | Registers.Posting_Read (PCH_HDMI (Port)); 99 | 100 | if not Config.Has_Trans_DP_Ctl and then With_Transcoder_B_Enabled then 101 | -- Reenable with transcoder A selected to switch. 102 | Registers.Set_Mask (PCH_HDMI (Port), PCH_HDMI_ENABLE); 103 | Registers.Posting_Read (PCH_HDMI (Port)); 104 | -- Set enable a second time, hardware may miss the first. 105 | Registers.Set_Mask (PCH_HDMI (Port), PCH_HDMI_ENABLE); 106 | Registers.Posting_Read (PCH_HDMI (Port)); 107 | Registers.Unset_Mask (PCH_HDMI (Port), PCH_HDMI_ENABLE); 108 | Registers.Posting_Read (PCH_HDMI (Port)); 109 | end if; 110 | 111 | end Off; 112 | 113 | procedure All_Off 114 | is 115 | begin 116 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 117 | 118 | for Port in IRL_PCH_HDMI_Port loop 119 | Off (Port); 120 | end loop; 121 | end All_Off; 122 | 123 | end HW.GFX.GMA.PCH.HDMI; 124 | -------------------------------------------------------------------------------- /common/g45/hw-gfx-gma-port_detect.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2016-2017 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.GMA.Config; 16 | with HW.GFX.GMA.Registers; 17 | with HW.GFX.GMA.Config_Helpers; 18 | 19 | package body HW.GFX.GMA.Port_Detect 20 | is 21 | 22 | PORT_DETECTED : constant := 1 * 2 ** 2; 23 | 24 | PORTB_HOTPLUG_INT_EN : constant := 1 * 2 ** 29; 25 | PORTC_HOTPLUG_INT_EN : constant := 1 * 2 ** 28; 26 | PORTD_HOTPLUG_INT_EN : constant := 1 * 2 ** 27; 27 | SDVOB_HOTPLUG_INT_EN : constant := 1 * 2 ** 26; 28 | SDVOC_HOTPLUG_INT_EN : constant := 1 * 2 ** 25; 29 | CRT_HOTPLUG_INT_EN : constant := 1 * 2 ** 9; 30 | CRT_HOTPLUG_ACTIVATION_PERIOD_64 : constant := 1 * 2 ** 8; 31 | 32 | type HDMI_Port_Value is array (GMCH_HDMI_Port) of Word32; 33 | type DP_Port_Value is array (GMCH_DP_Port) of Word32; 34 | HDMI_PORT_HOTPLUG_EN : constant HDMI_Port_Value := 35 | (DIGI_B => SDVOB_HOTPLUG_INT_EN, 36 | DIGI_C => SDVOC_HOTPLUG_INT_EN); 37 | DP_PORT_HOTPLUG_EN : constant DP_Port_Value := 38 | (DIGI_B => PORTB_HOTPLUG_INT_EN, 39 | DIGI_C => PORTC_HOTPLUG_INT_EN, 40 | DIGI_D => PORTD_HOTPLUG_INT_EN); 41 | 42 | type HDMI_Regs is array (GMCH_HDMI_Port) of Registers.Registers_Index; 43 | type DP_Regs is array (GMCH_DP_Port) of Registers.Registers_Index; 44 | GMCH_HDMI : constant HDMI_Regs := 45 | (DIGI_B => Registers.GMCH_HDMIB, 46 | DIGI_C => Registers.GMCH_HDMIC); 47 | GMCH_DP : constant DP_Regs := 48 | (DIGI_B => Registers.GMCH_DP_B, 49 | DIGI_C => Registers.GMCH_DP_C, 50 | DIGI_D => Registers.GMCH_DP_D); 51 | 52 | HOTPLUG_INT_STATUS : constant array (Active_Port_Type) of word32 := 53 | (DP1 => 3 * 2 ** 17, 54 | DP2 => 3 * 2 ** 19, 55 | DP3 => 3 * 2 ** 21, 56 | HDMI1 => 1 * 2 ** 2, 57 | HDMI2 => 1 * 2 ** 3, 58 | Analog => 1 * 2 ** 11, 59 | others => 0); 60 | 61 | procedure Initialize 62 | is 63 | Detected : Boolean; 64 | hotplug_mask_set : Word32 := 65 | CRT_HOTPLUG_INT_EN or CRT_HOTPLUG_ACTIVATION_PERIOD_64; 66 | 67 | To_HDMI_Port : constant array (GMCH_HDMI_Port) of Port_Type := 68 | (DIGI_B => HDMI1, 69 | DIGI_C => HDMI2); 70 | To_DP_Port : constant array (GMCH_DP_Port) of Port_Type := 71 | (DIGI_B => DP1, 72 | DIGI_C => DP2, 73 | DIGI_D => DP3); 74 | 75 | begin 76 | Config.Valid_Port (Analog) := True; 77 | Config.Valid_Port (LVDS) := Config.GMCH_GM45; 78 | for HDMI_Port in GMCH_HDMI_Port loop 79 | Registers.Is_Set_Mask 80 | (Register => GMCH_HDMI (HDMI_Port), 81 | Mask => PORT_DETECTED, 82 | Result => Detected); 83 | Config.Valid_Port (To_HDMI_Port (HDMI_Port)) := Detected; 84 | hotplug_mask_set := hotplug_mask_set or 85 | (if Detected then HDMI_PORT_HOTPLUG_EN (HDMI_Port) else 0); 86 | end loop; 87 | for DP_Port in GMCH_DP_Port loop 88 | Registers.Is_Set_Mask 89 | (Register => GMCH_DP (DP_Port), 90 | Mask => PORT_DETECTED, 91 | Result => Detected); 92 | Config.Valid_Port (To_DP_Port (DP_Port)) := Detected; 93 | hotplug_mask_set := hotplug_mask_set or 94 | (if Detected then DP_PORT_HOTPLUG_EN (DP_Port) else 0); 95 | end loop; 96 | Registers.Write 97 | (Register => Registers.PORT_HOTPLUG_EN, 98 | Value => hotplug_mask_set); 99 | end Initialize; 100 | 101 | procedure Hotplug_Detect (Port : in Active_Port_Type; Detected : out Boolean) 102 | is 103 | Ctl32 : Word32; 104 | begin 105 | Registers.Read (Register => Registers.PORT_HOTPLUG_STAT, 106 | Value => Ctl32); 107 | Detected := (Ctl32 and HOTPLUG_INT_STATUS (Port)) /= 0; 108 | 109 | if Detected then 110 | registers.Set_Mask 111 | (Register => Registers.PORT_HOTPLUG_STAT, 112 | Mask => HOTPLUG_INT_STATUS (Port)); 113 | end if; 114 | end Hotplug_Detect; 115 | 116 | procedure Clear_Hotplug_Detect (Port : Active_Port_Type) 117 | is 118 | Ignored_HPD : Boolean; 119 | begin 120 | pragma Warnings (GNATprove, Off, "unused assignment to ""Ignored_HPD""", 121 | Reason => "We want to clear pending events only"); 122 | Port_Detect.Hotplug_Detect (Port, Ignored_HPD); 123 | pragma Warnings (GNATprove, On, "unused assignment to ""Ignored_HPD"""); 124 | end Clear_Hotplug_Detect; 125 | 126 | end HW.GFX.GMA.Port_Detect; 127 | -------------------------------------------------------------------------------- /common/hw-gfx-dp_info.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2017 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.DP_Aux_Ch; 16 | 17 | private generic 18 | 19 | type T (<>) is limited private; 20 | 21 | with package Aux_Ch is new DP_Aux_Ch (T => T, others => <>); 22 | 23 | package HW.GFX.DP_Info is 24 | 25 | type DP_Voltage_Swing is (VS_Level_0, VS_Level_1, VS_Level_2, VS_Level_3); 26 | 27 | type DP_Pre_Emph is (Emph_Level_0, Emph_Level_1, Emph_Level_2, Emph_Level_3); 28 | 29 | type Train_Set is record 30 | Voltage_Swing : DP_Voltage_Swing; 31 | Pre_Emph : DP_Pre_Emph; 32 | end record; 33 | 34 | type Training_Pattern is (TP_1, TP_2, TP_3, TP_Idle, TP_None); 35 | 36 | ---------------------------------------------------------------------------- 37 | 38 | type Lane_Index is new Natural range 0 .. 3; 39 | 40 | type Lane_Status is record 41 | CR_Done : Boolean; 42 | Channel_EQ_Done : Boolean; 43 | Symbol_Locked : Boolean; 44 | Reserved : Boolean; 45 | end record; 46 | for Lane_Status use record 47 | CR_Done at 16#00# range 0 .. 0; 48 | Channel_EQ_Done at 16#00# range 1 .. 1; 49 | Symbol_Locked at 16#00# range 2 .. 2; 50 | Reserved at 16#00# range 3 .. 3; 51 | end record; 52 | type Lanes_Status is array (Lane_Index) of Lane_Status; 53 | pragma Pack (Lanes_Status); 54 | 55 | type Adjust_Request is record 56 | Voltage_Swing : DP_Voltage_Swing; 57 | Pre_Emph : DP_Pre_Emph; 58 | end record; 59 | for Adjust_Request use record 60 | Voltage_Swing at 16#00# range 0 .. 1; 61 | Pre_Emph at 16#00# range 2 .. 3; 62 | end record; 63 | type Adjust_Requests_Array is array (Lane_Index) of Adjust_Request; 64 | pragma Pack (Adjust_Requests_Array); 65 | 66 | type Link_Status_Padding is mod 2**15; 67 | type Link_Status is record 68 | Lanes : Lanes_Status; 69 | Interlane_Align_Done : Boolean; 70 | Padding : Link_Status_Padding; 71 | Adjust_Requests : Adjust_Requests_Array; 72 | end record; 73 | for Link_Status use record 74 | Lanes at 16#00# range 0 .. 15; 75 | Interlane_Align_Done at 16#02# range 0 .. 0; 76 | Padding at 16#02# range 1 .. 15; 77 | Adjust_Requests at 16#04# range 0 .. 15; 78 | end record; 79 | for Link_Status'Size use 48; 80 | for Link_Status'Object_Size use 48; 81 | 82 | ---------------------------------------------------------------------------- 83 | 84 | procedure Read_Caps 85 | (Link : in out DP_Link; 86 | Port : in T; 87 | Success : out Boolean); 88 | 89 | procedure Read_eDP_Rates 90 | (Link : in out DP_Link; 91 | Port : in T); 92 | 93 | procedure Preferred_Link_Setting 94 | (Link : in out DP_Link; 95 | Mode : in Mode_Type; 96 | Success : out Boolean); 97 | 98 | procedure Next_Link_Setting 99 | (Link : in out DP_Link; 100 | Mode : in Mode_Type; 101 | Success : out Boolean); 102 | 103 | pragma Warnings 104 | (GNATprove, Off, "subprogram ""Dump_Link_Setting"" has no effect", 105 | Reason => "It's only used for debugging"); 106 | procedure Dump_Link_Setting (Link : DP_Link); 107 | 108 | ---------------------------------------------------------------------------- 109 | 110 | M_N_Max : constant := 2 ** 24 - 1; 111 | 112 | subtype M_Type is Int64 range 0 .. M_N_Max; 113 | subtype N_Type is Int64 range 0 .. M_N_Max; 114 | 115 | procedure Calculate_M_N 116 | (Link : in DP_Link; 117 | Mode : in Mode_Type; 118 | Data_M : out M_Type; 119 | Data_N : out N_Type; 120 | Link_M : out M_Type; 121 | Link_N : out N_Type); 122 | 123 | ---------------------------------------------------------------------------- 124 | 125 | procedure Read_Link_Status 126 | (Port : in T; 127 | Status : out Link_Status; 128 | Success : out Boolean); 129 | 130 | function All_CR_Done 131 | (Status : Link_Status; 132 | Link : DP_Link) 133 | return Boolean; 134 | 135 | function All_EQ_Done 136 | (Status : Link_Status; 137 | Link : DP_Link) 138 | return Boolean; 139 | 140 | function Max_Requested_VS 141 | (Status : Link_Status; 142 | Link : DP_Link) 143 | return DP_Voltage_Swing; 144 | 145 | function Max_Requested_Emph 146 | (Status : Link_Status; 147 | Link : DP_Link) 148 | return DP_Pre_Emph; 149 | 150 | end HW.GFX.DP_Info; 151 | -------------------------------------------------------------------------------- /common/hw-gfx-gma-pcode.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2014-2016, 2019 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with GNAT.Source_Info; 16 | 17 | with HW.Debug; 18 | with HW.GFX.GMA.Registers; 19 | 20 | use HW.GFX.GMA.Registers; 21 | 22 | package body HW.GFX.GMA.PCode is 23 | 24 | GT_MAILBOX_READY : constant := 1 * 2 ** 31; 25 | 26 | -- Send a command and optionally wait for and return the reply. 27 | procedure Mailbox_Write_Read 28 | (MBox : in Word32; 29 | Command : in Word64; 30 | Reply : out Word64; 31 | Wait_Ready : in Boolean := False; 32 | Wait_Ack : in Boolean := True; 33 | Success : out Boolean) 34 | with 35 | Pre => Mailbox_Ready or Wait_Ready, 36 | Post => (if Wait_Ack and Success then Mailbox_Ready) 37 | is 38 | use type HW.Word64; 39 | 40 | Data : Word32; 41 | begin 42 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 43 | 44 | Reply := 0; 45 | Success := True; 46 | 47 | if Wait_Ready then 48 | Wait_Unset_Mask (GT_MAILBOX, GT_MAILBOX_READY, Success => Success); 49 | if not Success then 50 | return; 51 | end if; 52 | end if; 53 | 54 | Write (GT_MAILBOX_DATA, Word32 (Command and 16#ffff_ffff#)); 55 | Write (GT_MAILBOX_DATA_1, Word32 (Shift_Right (Command, 32))); 56 | Write (GT_MAILBOX, GT_MAILBOX_READY or MBox); 57 | Mailbox_Ready := False; 58 | 59 | if Wait_Ack then 60 | Wait_Unset_Mask (GT_MAILBOX, GT_MAILBOX_READY, Success => Success); 61 | Mailbox_Ready := Success; 62 | 63 | Read (GT_MAILBOX_DATA, Data); 64 | Reply := Word64 (Data); 65 | Read (GT_MAILBOX_DATA_1, Data); 66 | Reply := Shift_Left (Word64 (Data), 32) or Reply; 67 | 68 | Write (GT_MAILBOX_DATA, 0); 69 | Write (GT_MAILBOX_DATA_1, 0); 70 | end if; 71 | end Mailbox_Write_Read; 72 | 73 | procedure Mailbox_Write 74 | (MBox : in Word32; 75 | Command : in Word64; 76 | Wait_Ready : in Boolean := False; 77 | Wait_Ack : in Boolean := True; 78 | Success : out Boolean) 79 | is 80 | pragma Warnings (GNATprove, Off, "unused assignment to ""Ignored_R"""); 81 | Ignored_R : Word64; 82 | begin 83 | Mailbox_Write_Read 84 | (MBox, Command, Ignored_R, Wait_Ready, Wait_Ack, Success); 85 | end Mailbox_Write; 86 | 87 | procedure Mailbox_Read 88 | (MBox : in Word32; 89 | Command : in Word64 := 0; 90 | Wait_Ready : in Boolean := False; 91 | Reply : out Word64; 92 | Success : out Boolean) 93 | is 94 | begin 95 | Mailbox_Write_Read (MBox, Command, Reply, Wait_Ready, True, Success); 96 | end Mailbox_Read; 97 | 98 | procedure Mailbox_Request 99 | (MBox : in Word32; 100 | Command : in Word64; 101 | Reply_Mask : in Word64; 102 | Reply : in Word64 := 16#ffff_ffff_ffff_ffff#; 103 | TOut_MS : in Natural := Registers.Default_Timeout_MS; 104 | Wait_Ready : in Boolean := False; 105 | Success : out Boolean) 106 | is 107 | use type HW.Word64; 108 | 109 | Timeout : constant Time.T := Time.MS_From_Now (TOut_MS); 110 | Timed_Out : Boolean := False; 111 | 112 | Received_Reply : Word64; 113 | begin 114 | Success := False; 115 | loop 116 | pragma Loop_Invariant ((not Success and Wait_Ready) or Mailbox_Ready); 117 | Mailbox_Write_Read 118 | (MBox => MBox, 119 | Command => Command, 120 | Reply => Received_Reply, 121 | Wait_Ready => not Success and Wait_Ready, 122 | Success => Success); 123 | exit when not Success; 124 | 125 | if (Received_Reply and Reply_Mask) = (Reply and Reply_Mask) then 126 | -- Ignore timeout if we succeeded anyway. 127 | Timed_Out := False; 128 | exit; 129 | end if; 130 | exit when Timed_Out; 131 | 132 | Timed_Out := Time.Timed_Out (Timeout); 133 | end loop; 134 | 135 | Success := Success and then not Timed_Out; 136 | end Mailbox_Request; 137 | 138 | procedure Mailbox_Write 139 | (MBox : Word32; 140 | Command : Word64; 141 | Wait_Ready : Boolean := False) 142 | is 143 | pragma Warnings (GNATprove, Off, "unused assignment to ""Ignored_S"""); 144 | Ignored_S : Boolean; 145 | begin 146 | Mailbox_Write (MBox, Command, Wait_Ready, False, Ignored_S); 147 | end Mailbox_Write; 148 | 149 | end HW.GFX.GMA.PCode; 150 | -------------------------------------------------------------------------------- /common/hw-gfx-gma-pch-sideband.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.GMA.Registers; 16 | 17 | package body HW.GFX.GMA.PCH.Sideband is 18 | 19 | SBI_CTL_DEST_ICLK : constant := 0 * 2 ** 16; 20 | SBI_CTL_DEST_MPHY : constant := 1 * 2 ** 16; 21 | SBI_CTL_OP_IORD : constant := 2 * 2 ** 8; 22 | SBI_CTL_OP_IOWR : constant := 3 * 2 ** 8; 23 | SBI_CTL_OP_CRRD : constant := 6 * 2 ** 8; 24 | SBI_CTL_OP_CRWR : constant := 7 * 2 ** 8; 25 | 26 | SBI_RESPONSE_FAIL : constant := 1 * 2 ** 1; 27 | SBI_BUSY : constant := 1 * 2 ** 0; 28 | 29 | type Register_Array is array (Register_Type) of Word32; 30 | Register_Addr : constant Register_Array := Register_Array' 31 | (SBI_SSCDIVINTPHASE => 16#0200_0000#, 32 | SBI_SSCDITHPHASE => 16#0204_0000#, 33 | SBI_SSCCTL => 16#020c_0000#, 34 | SBI_SSCDIVINTPHASE6 => 16#0600_0000#, 35 | SBI_SSCCTL6 => 16#060c_0000#, 36 | SBI_SSCAUXDIV => 16#0610_0000#, 37 | SBI_GEN0 => 16#1f00_0000#, 38 | SBI_DBUFF0 => 16#2a00_0000#, 39 | 40 | SBI_MPHY_2008 => 16#2008_0000#, 41 | SBI_MPHY_206C => 16#206c_0000#, 42 | SBI_MPHY_2080 => 16#2080_0000#, 43 | SBI_MPHY_208C => 16#208c_0000#, 44 | SBI_MPHY_2098 => 16#2098_0000#, 45 | SBI_MPHY_20C4 => 16#20c4_0000#, 46 | SBI_MPHY_20EC => 16#20ec_0000#, 47 | SBI_MPHY_2108 => 16#2108_0000#, 48 | SBI_MPHY_216C => 16#216c_0000#, 49 | SBI_MPHY_2180 => 16#2180_0000#, 50 | SBI_MPHY_218C => 16#218c_0000#, 51 | SBI_MPHY_2198 => 16#2198_0000#, 52 | SBI_MPHY_21C4 => 16#21c4_0000#, 53 | SBI_MPHY_21EC => 16#21ec_0000#, 54 | SBI_MPHY_8008 => 16#8008_0000#); 55 | 56 | ---------------------------------------------------------------------------- 57 | 58 | procedure Read 59 | (Dest : in Destination_Type; 60 | Register : in Register_Type; 61 | Value : out Word32) 62 | is 63 | begin 64 | Registers.Wait_Unset_Mask 65 | (Register => Registers.SBI_CTL_STAT, 66 | Mask => SBI_BUSY); 67 | 68 | Registers.Write 69 | (Register => Registers.SBI_ADDR, 70 | Value => Register_Addr (Register)); 71 | 72 | if Dest = SBI_ICLK then 73 | Registers.Write 74 | (Register => Registers.SBI_CTL_STAT, 75 | Value => SBI_CTL_DEST_ICLK or SBI_CTL_OP_CRRD or SBI_BUSY); 76 | else 77 | Registers.Write 78 | (Register => Registers.SBI_CTL_STAT, 79 | Value => SBI_CTL_DEST_MPHY or SBI_CTL_OP_IORD or SBI_BUSY); 80 | end if; 81 | 82 | Registers.Wait_Unset_Mask 83 | (Register => Registers.SBI_CTL_STAT, 84 | Mask => SBI_BUSY); 85 | 86 | Registers.Read 87 | (Register => Registers.SBI_DATA, 88 | Value => Value); 89 | end Read; 90 | 91 | procedure Write 92 | (Dest : in Destination_Type; 93 | Register : in Register_Type; 94 | Value : in Word32) 95 | is 96 | begin 97 | Registers.Wait_Unset_Mask 98 | (Register => Registers.SBI_CTL_STAT, 99 | Mask => SBI_BUSY); 100 | 101 | Registers.Write 102 | (Register => Registers.SBI_ADDR, 103 | Value => Register_Addr (Register)); 104 | Registers.Write 105 | (Register => Registers.SBI_DATA, 106 | Value => Value); 107 | 108 | if Dest = SBI_ICLK then 109 | Registers.Write 110 | (Register => Registers.SBI_CTL_STAT, 111 | Value => SBI_CTL_DEST_ICLK or SBI_CTL_OP_CRWR or SBI_BUSY); 112 | else 113 | Registers.Write 114 | (Register => Registers.SBI_CTL_STAT, 115 | Value => SBI_CTL_DEST_MPHY or SBI_CTL_OP_IOWR or SBI_BUSY); 116 | end if; 117 | 118 | Registers.Wait_Unset_Mask 119 | (Register => Registers.SBI_CTL_STAT, 120 | Mask => SBI_BUSY); 121 | end Write; 122 | 123 | ---------------------------------------------------------------------------- 124 | 125 | procedure Unset_Mask 126 | (Dest : in Destination_Type; 127 | Register : in Register_Type; 128 | Mask : in Word32) 129 | is 130 | Value : Word32; 131 | begin 132 | Read (Dest, Register, Value); 133 | Write (Dest, Register, Value and not Mask); 134 | end Unset_Mask; 135 | 136 | procedure Set_Mask 137 | (Dest : in Destination_Type; 138 | Register : in Register_Type; 139 | Mask : in Word32) 140 | is 141 | Value : Word32; 142 | begin 143 | Read (Dest, Register, Value); 144 | Write (Dest, Register, Value or Mask); 145 | end Set_Mask; 146 | 147 | procedure Unset_And_Set_Mask 148 | (Dest : in Destination_Type; 149 | Register : in Register_Type; 150 | Mask_Unset : in Word32; 151 | Mask_Set : in Word32) 152 | is 153 | Value : Word32; 154 | begin 155 | Read (Dest, Register, Value); 156 | Write (Dest, Register, (Value and not Mask_Unset) or Mask_Set); 157 | end Unset_And_Set_Mask; 158 | 159 | end HW.GFX.GMA.PCH.Sideband; 160 | -------------------------------------------------------------------------------- /common/haswell/hw-gfx-gma-connectors-ddi-buffers.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2017 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.GMA.Config; 16 | 17 | package body HW.GFX.GMA.Connectors.DDI.Buffers 18 | is 19 | 20 | subtype Haswell_HDMI_Range is DDI_HDMI_Buf_Trans_Range range 0 .. 11; 21 | subtype Broadwell_HDMI_Range is DDI_HDMI_Buf_Trans_Range range 0 .. 9; 22 | 23 | type HDMI_Buf_Trans is record 24 | Trans1 : Word32; 25 | Trans2 : Word32; 26 | end record; 27 | type HDMI_Buf_Trans_Array is array (Haswell_HDMI_Range) of HDMI_Buf_Trans; 28 | 29 | ---------------------------------------------------------------------------- 30 | 31 | Haswell_Trans_DP : constant Buf_Trans_Array := 32 | (16#00ff_ffff#, 16#0006_000e#, 33 | 16#00d7_5fff#, 16#0005_000a#, 34 | 16#00c3_0fff#, 16#0004_0006#, 35 | 16#80aa_afff#, 16#000b_0000#, 36 | 16#00ff_ffff#, 16#0005_000a#, 37 | 16#00d7_5fff#, 16#000c_0004#, 38 | 16#80c3_0fff#, 16#000b_0000#, 39 | 16#00ff_ffff#, 16#0004_0006#, 40 | 16#80d7_5fff#, 16#000b_0000#, 41 | others => 0); 42 | 43 | Haswell_Trans_FDI : constant Buf_Trans_Array := 44 | (16#00ff_ffff#, 16#0007_000e#, 45 | 16#00d7_5fff#, 16#000f_000a#, 46 | 16#00c3_0fff#, 16#0006_0006#, 47 | 16#00aa_afff#, 16#001e_0000#, 48 | 16#00ff_ffff#, 16#000f_000a#, 49 | 16#00d7_5fff#, 16#0016_0004#, 50 | 16#00c3_0fff#, 16#001e_0000#, 51 | 16#00ff_ffff#, 16#0006_0006#, 52 | 16#00d7_5fff#, 16#001e_0000#, 53 | others => 0); 54 | 55 | Haswell_Trans_HDMI : constant HDMI_Buf_Trans_Array := 56 | ((16#00ff_ffff#, 16#0006_000e#), 57 | (16#00e7_9fff#, 16#000e_000c#), 58 | (16#00d7_5fff#, 16#0005_000a#), 59 | (16#00ff_ffff#, 16#0005_000a#), 60 | (16#00e7_9fff#, 16#001d_0007#), 61 | (16#00d7_5fff#, 16#000c_0004#), 62 | (16#00ff_ffff#, 16#0004_0006#), 63 | (16#80e7_9fff#, 16#0003_0002#), 64 | (16#00ff_ffff#, 16#0014_0005#), 65 | (16#00ff_ffff#, 16#000c_0004#), 66 | (16#00ff_ffff#, 16#001c_0003#), 67 | (16#80ff_ffff#, 16#0003_0002#)); 68 | 69 | Broadwell_Trans_EDP : constant Buf_Trans_Array := 70 | (16#00ff_ffff#, 16#0000_0012#, 71 | 16#00eb_afff#, 16#0002_0011#, 72 | 16#00c7_1fff#, 16#0006_000f#, 73 | 16#00aa_afff#, 16#000e_000a#, 74 | 16#00ff_ffff#, 16#0002_0011#, 75 | 16#00db_6fff#, 16#0005_000f#, 76 | 16#00be_efff#, 16#000a_000c#, 77 | 16#00ff_ffff#, 16#0005_000f#, 78 | 16#00db_6fff#, 16#000a_000c#, 79 | others => 0); 80 | 81 | Broadwell_Trans_DP : constant Buf_Trans_Array := 82 | (16#00ff_ffff#, 16#0007_000e#, 83 | 16#00d7_5fff#, 16#000e_000a#, 84 | 16#00be_ffff#, 16#0014_0006#, 85 | 16#80b2_cfff#, 16#001b_0002#, 86 | 16#00ff_ffff#, 16#000e_000a#, 87 | 16#00db_6fff#, 16#0016_0005#, 88 | 16#80c7_1fff#, 16#001a_0002#, 89 | 16#00f7_dfff#, 16#0018_0004#, 90 | 16#80d7_5fff#, 16#001b_0002#, 91 | others => 0); 92 | 93 | Broadwell_Trans_FDI : constant Buf_Trans_Array := 94 | (16#00ff_ffff#, 16#0001_000e#, 95 | 16#00d7_5fff#, 16#0004_000a#, 96 | 16#00c3_0fff#, 16#0007_0006#, 97 | 16#00aa_afff#, 16#000c_0000#, 98 | 16#00ff_ffff#, 16#0004_000a#, 99 | 16#00d7_5fff#, 16#0009_0004#, 100 | 16#00c3_0fff#, 16#000c_0000#, 101 | 16#00ff_ffff#, 16#0007_0006#, 102 | 16#00d7_5fff#, 16#000c_0000#, 103 | others => 0); 104 | 105 | Broadwell_Trans_HDMI : constant HDMI_Buf_Trans_Array := 106 | ((16#00ff_ffff#, 16#0007_000e#), 107 | (16#00d7_5fff#, 16#000e_000a#), 108 | (16#00be_ffff#, 16#0014_0006#), 109 | (16#00ff_ffff#, 16#0009_000d#), 110 | (16#00ff_ffff#, 16#000e_000a#), 111 | (16#00d7_ffff#, 16#0014_0006#), 112 | (16#80cb_2fff#, 16#001b_0002#), 113 | (16#00ff_ffff#, 16#0014_0006#), 114 | (16#80e7_9fff#, 16#001b_0002#), 115 | (16#80ff_ffff#, 16#001b_0002#), 116 | others => (0, 0)); 117 | 118 | ---------------------------------------------------------------------------- 119 | 120 | procedure Translations (Trans : out Buf_Trans_Array; Port : Digital_Port) 121 | is 122 | HDMI_Trans : constant DDI_HDMI_Buf_Trans_Range := 123 | (if Config.Have_HDMI_Buf_Override 124 | then Config.DDI_HDMI_Buffer_Translation 125 | else Config.Default_DDI_HDMI_Buffer_Translation); 126 | begin 127 | Trans := 128 | (if Config.CPU_Haswell then 129 | (case Port is 130 | when DIGI_A .. DIGI_D => Haswell_Trans_DP, 131 | when DIGI_E => Haswell_Trans_FDI) 132 | else 133 | (case Port is 134 | when DIGI_A => 135 | (if Config.EDP_Low_Voltage_Swing 136 | then Broadwell_Trans_EDP 137 | else Broadwell_Trans_DP), 138 | when DIGI_B .. DIGI_D => Broadwell_Trans_DP, 139 | when DIGI_E => Broadwell_Trans_FDI)); 140 | if Config.CPU_Haswell then 141 | Trans (18) := Haswell_Trans_HDMI (HDMI_Trans).Trans1; 142 | Trans (19) := Haswell_Trans_HDMI (HDMI_Trans).Trans2; 143 | else 144 | Trans (18) := Broadwell_Trans_HDMI (HDMI_Trans).Trans1; 145 | Trans (19) := Broadwell_Trans_HDMI (HDMI_Trans).Trans2; 146 | end if; 147 | end Translations; 148 | 149 | end HW.GFX.GMA.Connectors.DDI.Buffers; 150 | -------------------------------------------------------------------------------- /common/g45/hw-gfx-gma-power_and_clocks.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2016 secunet Security Networks AG 3 | -- Copyright (C) 2019 Nico Huber 4 | -- 5 | -- This program is free software; you can redistribute it and/or modify 6 | -- it under the terms of the GNU General Public License as published by 7 | -- the Free Software Foundation; either version 2 of the License, or 8 | -- (at your option) any later version. 9 | -- 10 | -- This program is distributed in the hope that it will be useful, 11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | -- GNU General Public License for more details. 14 | -- 15 | 16 | with HW.Time; 17 | with HW.GFX.GMA.Config; 18 | with HW.GFX.GMA.Registers; 19 | 20 | package body HW.GFX.GMA.Power_And_Clocks is 21 | 22 | FSB_FREQ_SEL_MASK : constant := 7 * 2 ** 0; 23 | CLKCFG_FSB_400 : constant Frequency_Type := 100_000_000; 24 | CLKCFG_FSB_533 : constant Frequency_Type := 133_333_333; 25 | CLKCFG_FSB_667 : constant Frequency_Type := 166_666_666; 26 | CLKCFG_FSB_800 : constant Frequency_Type := 200_000_000; 27 | CLKCFG_FSB_1067 : constant Frequency_Type := 266_666_666; 28 | CLKCFG_FSB_1333 : constant Frequency_Type := 333_333_333; 29 | 30 | type Div_Array is array (0 .. 7) of Pos64; 31 | 32 | procedure Get_VCO (VCO : out Int64; Divisors : out Div_Array) 33 | is 34 | G45_3200 : constant Div_Array := (12, 10, 8, 7, 5, 16, others => 1); 35 | G45_4000 : constant Div_Array := (14, 12, 10, 8, 6, 20, others => 1); 36 | G45_4800 : constant Div_Array := (20, 14, 12, 10, 8, 24, others => 1); 37 | G45_5333 : constant Div_Array := (20, 16, 12, 12, 8, 28, others => 1); 38 | G45_Divs : constant array (Natural range 0 .. 7) of Div_Array := 39 | (G45_3200, G45_4000, G45_5333, G45_4800, others => (others => 1)); 40 | 41 | GM45_2667 : constant Div_Array := (12, 8, others => 1); 42 | GM45_3200 : constant Div_Array := (14, 10, others => 1); 43 | GM45_4000 : constant Div_Array := (18, 12, others => 1); 44 | GM45_5333 : constant Div_Array := (24, 16, others => 1); 45 | GM45_Divs : constant array (Natural range 0 .. 7) of Div_Array := 46 | (0 => GM45_3200, 1 => GM45_4000, 2 => GM45_5333, 4 => GM45_2667, 47 | others => (others => 1)); 48 | 49 | HPLLVCO : Word32; 50 | VCO_Sel : Natural range 0 .. 7; 51 | begin 52 | if Config.Has_GMCH_Mobile_VCO then 53 | Registers.Read (Registers.GMCH_HPLLVCO_MOBILE, HPLLVCO); 54 | VCO_Sel := Natural (HPLLVCO and 7); 55 | VCO := 56 | (case VCO_Sel is 57 | when 0 => 3_200_000_000, 58 | when 1 => 4_000_000_000, 59 | when 2 => 5_333_333_333, 60 | --when 3 => 6_400_000_000, 61 | when 4 => 2_666_666_667, 62 | --when 5 => 4_266_666_667, 63 | when others => 0); 64 | Divisors := GM45_Divs (VCO_Sel); 65 | else 66 | Registers.Read (Registers.GMCH_HPLLVCO, HPLLVCO); 67 | VCO_Sel := Natural (HPLLVCO and 7); 68 | VCO := 69 | (case VCO_Sel is 70 | when 0 => 3_200_000_000, 71 | when 1 => 4_000_000_000, 72 | when 2 => 5_333_333_333, 73 | when 3 => 4_800_000_000, 74 | when others => 0); 75 | Divisors := G45_Divs (VCO_Sel); 76 | end if; 77 | end Get_VCO; 78 | 79 | procedure Get_CDClk (CDClk : out Config.CDClk_Range) 80 | is 81 | use type HW.Word16; 82 | 83 | Tmp_Clk : Int64 := 0; 84 | 85 | VCO : Int64; 86 | Divisors : Div_Array; 87 | 88 | GCFGC : Word16; 89 | CDClk_Sel : Natural range 0 .. 7; 90 | begin 91 | if PCI_Usable then 92 | Get_VCO (VCO, Divisors); 93 | PCI_Read16 (GCFGC, 16#f0#); 94 | if Config.Has_GMCH_Mobile_VCO then 95 | CDClk_Sel := Natural (Shift_Right (GCFGC, 12) and 1); 96 | else 97 | CDClk_Sel := Natural (Shift_Right (GCFGC, 4) and 7); 98 | end if; 99 | Tmp_Clk := VCO / Divisors (CDClk_Sel); 100 | end if; 101 | 102 | if Tmp_Clk in Config.CDClk_Range then 103 | CDClk := Tmp_Clk; 104 | else 105 | if Config.Has_GMCH_Mobile_VCO then 106 | CDClk := 5_333_333_333 / 24; 107 | else 108 | CDClk := 5_333_333_333 / 28; 109 | end if; 110 | end if; 111 | end Get_CDClk; 112 | 113 | -- The Raw Freq is 1/4 of the FSB freq 114 | procedure Get_Raw_Clock (Raw_Clock : out Frequency_Type) 115 | is 116 | CLK_CFG : Word32; 117 | type Freq_Sel is new Natural range 0 .. 7; 118 | begin 119 | Registers.Read 120 | (Register => Registers.GMCH_CLKCFG, 121 | Value => CLK_CFG); 122 | case Freq_Sel (CLK_CFG and FSB_FREQ_SEL_MASK) is 123 | when 0 => Raw_Clock := CLKCFG_FSB_1067; 124 | when 1 => Raw_Clock := CLKCFG_FSB_533; 125 | when 2 => Raw_Clock := CLKCFG_FSB_800; 126 | when 3 => Raw_Clock := CLKCFG_FSB_667; 127 | when 4 => Raw_Clock := CLKCFG_FSB_1333; 128 | when 5 => Raw_Clock := CLKCFG_FSB_400; 129 | when 6 => Raw_Clock := CLKCFG_FSB_1067; 130 | when 7 => Raw_Clock := CLKCFG_FSB_1333; 131 | end case; 132 | end Get_Raw_Clock; 133 | 134 | procedure Initialize 135 | is 136 | CDClk : Config.CDClk_Range; 137 | begin 138 | Get_CDClk (CDClk); 139 | Config.CDClk := CDClk; 140 | Config.Max_CDClk := CDClk; 141 | 142 | Get_Raw_Clock (Config.Raw_Clock); 143 | end Initialize; 144 | 145 | procedure Limit_Dotclocks 146 | (Configs : in out Pipe_Configs; 147 | CDClk_Switch : out Boolean) 148 | is 149 | begin 150 | Config_Helpers.Limit_Dotclocks (Configs, Config.CDClk * 90 / 100); 151 | CDClk_Switch := False; 152 | end Limit_Dotclocks; 153 | 154 | end HW.GFX.GMA.Power_And_Clocks; 155 | -------------------------------------------------------------------------------- /common/ironlake/hw-gfx-gma-connectors.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2016 secunet Security Networks AG 3 | -- Copyright (C) 2016 Nico Huber 4 | -- 5 | -- This program is free software; you can redistribute it and/or modify 6 | -- it under the terms of the GNU General Public License as published by 7 | -- the Free Software Foundation; either version 2 of the License, or 8 | -- (at your option) any later version. 9 | -- 10 | -- This program is distributed in the hope that it will be useful, 11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | -- GNU General Public License for more details. 14 | -- 15 | 16 | with HW.GFX.GMA.Config; 17 | with HW.GFX.GMA.Panel; 18 | with HW.GFX.GMA.Connectors.EDP; 19 | with HW.GFX.GMA.Connectors.FDI; 20 | with HW.GFX.GMA.PCH.VGA; 21 | with HW.GFX.GMA.PCH.LVDS; 22 | with HW.GFX.GMA.PCH.HDMI; 23 | with HW.GFX.GMA.PCH.DP; 24 | with HW.GFX.GMA.PCH.Transcoder; 25 | 26 | with HW.Debug; 27 | with GNAT.Source_Info; 28 | 29 | package body HW.GFX.GMA.Connectors 30 | is 31 | 32 | procedure Post_Reset_Off is null; 33 | procedure Initialize is null; 34 | 35 | function Is_Internal (Port_Cfg : Port_Config) return Boolean 36 | is 37 | begin 38 | return 39 | Port_Cfg.Port = DIGI_A or 40 | (Port_Cfg.Is_FDI and Port_Cfg.PCH_Port = PCH_LVDS); 41 | end Is_Internal; 42 | 43 | ---------------------------------------------------------------------------- 44 | 45 | procedure Pre_On 46 | (Pipe : in Pipe_Index; 47 | Port_Cfg : in Port_Config; 48 | PLL_Hint : in Word32; 49 | Success : out Boolean) 50 | is 51 | begin 52 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 53 | 54 | if Port_Cfg.Port = DIGI_A then 55 | EDP.Pre_On (Pipe, Port_Cfg); 56 | elsif Port_Cfg.Port in FDI.GPU_FDI_Port then 57 | FDI.Pre_On (Port_Cfg); 58 | end if; 59 | Success := True; 60 | end Pre_On; 61 | 62 | procedure Post_On 63 | (Pipe : in Pipe_Index; 64 | Port_Cfg : in Port_Config; 65 | PLL_Hint : in Word32; 66 | Success : out Boolean) 67 | is 68 | begin 69 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 70 | 71 | if Port_Cfg.Port = DIGI_A then 72 | EDP.Pre_Training; 73 | Panel.On (Port_Cfg.Panel, Wait => True); 74 | EDP.Post_On (Port_Cfg.DP, Success); 75 | elsif Port_Cfg.Port in FDI.GPU_FDI_Port then 76 | declare 77 | FDI_Port : constant PCH.FDI_Port_Type := 78 | FDI.PCH_FDIs (Port_Cfg.Port); 79 | begin 80 | FDI.Post_On (Port_Cfg, Success); 81 | 82 | if Success then 83 | PCH.Transcoder.On (Port_Cfg, FDI_Port, PLL_Hint); 84 | if Port_Cfg.PCH_Port = PCH_DAC then 85 | PCH.VGA.On (FDI_Port, Port_Cfg.Mode); 86 | elsif Port_Cfg.PCH_Port = PCH_LVDS then 87 | PCH.LVDS.On (Port_Cfg, FDI_Port); 88 | elsif Port_Cfg.PCH_Port in PCH.HDMI.IRL_PCH_HDMI_Port then 89 | PCH.HDMI.On (Port_Cfg, FDI_Port); 90 | elsif Port_Cfg.PCH_Port in PCH_DP_Port then 91 | PCH.DP.On (Port_Cfg, FDI_Port, Success); 92 | end if; 93 | end if; 94 | end; 95 | else 96 | Success := False; 97 | end if; 98 | 99 | if Success and Is_Internal (Port_Cfg) then 100 | Panel.On (Port_Cfg.Panel, Wait => False); 101 | Panel.Backlight_On (Port_Cfg.Panel); 102 | end if; 103 | end Post_On; 104 | 105 | ---------------------------------------------------------------------------- 106 | 107 | procedure Pre_Off (Port_Cfg : Port_Config) 108 | is 109 | begin 110 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 111 | 112 | if Is_Internal (Port_Cfg) then 113 | Panel.Backlight_Off (Port_Cfg.Panel); 114 | Panel.Off (Port_Cfg.Panel); 115 | end if; 116 | end Pre_Off; 117 | 118 | procedure Post_Off (Port_Cfg : Port_Config) 119 | is 120 | begin 121 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 122 | 123 | if Port_Cfg.Port = DIGI_A then 124 | EDP.Off (Port_Cfg.Port); 125 | elsif Port_Cfg.Port in FDI.GPU_FDI_Port then 126 | declare 127 | FDI_Port : constant PCH.FDI_Port_Type := 128 | FDI.PCH_FDIs (Port_Cfg.Port); 129 | begin 130 | if Port_Cfg.PCH_Port in PCH_DP_Port then 131 | PCH.DP.Off (Port_Cfg.PCH_Port); 132 | end if; 133 | 134 | FDI.Off (Port_Cfg.Port, FDI.Link_Off); 135 | 136 | if Port_Cfg.PCH_Port = PCH_DAC then 137 | PCH.VGA.Off; 138 | elsif Port_Cfg.PCH_Port = PCH_LVDS then 139 | PCH.LVDS.Off; 140 | elsif Port_Cfg.PCH_Port in PCH.HDMI.IRL_PCH_HDMI_Port then 141 | PCH.HDMI.Off (Port_Cfg.PCH_Port); 142 | end if; 143 | PCH.Transcoder.Off (FDI_Port); 144 | 145 | FDI.Off (Port_Cfg.Port, FDI.Clock_Off); 146 | end; 147 | end if; 148 | end Post_Off; 149 | 150 | ---------------------------------------------------------------------------- 151 | 152 | procedure Pre_All_Off 153 | is 154 | begin 155 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 156 | 157 | for P in Valid_Panels loop 158 | Panel.Backlight_Off (P); 159 | Panel.Off (P); 160 | end loop; 161 | end Pre_All_Off; 162 | 163 | procedure Post_All_Off 164 | is 165 | begin 166 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 167 | 168 | EDP.Off (DIGI_A); 169 | 170 | for Port in FDI.GPU_FDI_Port loop 171 | FDI.Off (Port, FDI.Link_Off); 172 | end loop; 173 | PCH.VGA.Off; 174 | PCH.LVDS.Off; 175 | PCH.HDMI.All_Off; 176 | PCH.DP.All_Off; 177 | for Port in PCH.FDI_Port_Type loop 178 | PCH.Transcoder.Off (Port); 179 | end loop; 180 | for Port in FDI.GPU_FDI_Port loop 181 | FDI.Off (Port, FDI.Clock_Off); 182 | end loop; 183 | end Post_All_Off; 184 | 185 | end HW.GFX.GMA.Connectors; 186 | -------------------------------------------------------------------------------- /common/Makefile.inc: -------------------------------------------------------------------------------- 1 | gfxinit-y += hw-gfx-dp_aux_ch.adb 2 | gfxinit-y += hw-gfx-dp_aux_ch.ads 3 | gfxinit-y += hw-gfx-dp_defs.ads 4 | gfxinit-y += hw-gfx-dp_dual_mode.adb 5 | gfxinit-y += hw-gfx-dp_dual_mode.ads 6 | gfxinit-y += hw-gfx-dp_info.adb 7 | gfxinit-y += hw-gfx-dp_info.ads 8 | gfxinit-y += hw-gfx-dp_training.adb 9 | gfxinit-y += hw-gfx-dp_training.ads 10 | gfxinit-y += hw-gfx-edid.adb 11 | gfxinit-y += hw-gfx-edid.ads 12 | gfxinit-y += hw-gfx-gma-config_helpers.adb 13 | gfxinit-y += hw-gfx-gma-config_helpers.ads 14 | gfxinit-y += hw-gfx-gma-connector_info.adb 15 | gfxinit-y += hw-gfx-gma-connector_info.ads 16 | gfxinit-y += hw-gfx-gma-connectors.ads 17 | gfxinit-y += hw-gfx-gma-display_probing.adb 18 | gfxinit-y += hw-gfx-gma-display_probing.ads 19 | gfxinit-y += hw-gfx-gma-dp_aux_ch.ads 20 | gfxinit-y += hw-gfx-gma-dp_aux_request.adb 21 | gfxinit-y += hw-gfx-gma-dp_aux_request.ads 22 | gfxinit-y += hw-gfx-gma-dp_dual_mode.ads 23 | gfxinit-y += hw-gfx-gma-dp_info.ads 24 | gfxinit-y += hw-gfx-gma-i2c.adb 25 | gfxinit-y += hw-gfx-gma-i2c.ads 26 | gfxinit-y += hw-gfx-gma-panel.adb 27 | gfxinit-y += hw-gfx-gma-panel.ads 28 | gfxinit-y += hw-gfx-gma-pch-fdi.adb 29 | gfxinit-y += hw-gfx-gma-pch-fdi.ads 30 | gfxinit-y += hw-gfx-gma-pch-sideband.adb 31 | gfxinit-y += hw-gfx-gma-pch-sideband.ads 32 | gfxinit-y += hw-gfx-gma-pch-transcoder.adb 33 | gfxinit-y += hw-gfx-gma-pch-transcoder.ads 34 | gfxinit-y += hw-gfx-gma-pch-vga.adb 35 | gfxinit-y += hw-gfx-gma-pch-vga.ads 36 | gfxinit-y += hw-gfx-gma-pch.ads 37 | gfxinit-y += hw-gfx-gma-pcode.adb 38 | gfxinit-y += hw-gfx-gma-pcode.ads 39 | gfxinit-y += hw-gfx-gma-pipe_setup.adb 40 | gfxinit-y += hw-gfx-gma-pipe_setup.ads 41 | gfxinit-y += hw-gfx-gma-port_detect.ads 42 | gfxinit-y += hw-gfx-gma-registers.adb 43 | gfxinit-y += hw-gfx-gma-registers.ads 44 | gfxinit-y += hw-gfx-gma-transcoder.adb 45 | gfxinit-y += hw-gfx-gma-transcoder.ads 46 | gfxinit-y += hw-gfx-gma.adb 47 | gfxinit-y += hw-gfx-gma.ads 48 | gfxinit-y += hw-gfx-i2c.ads 49 | gfxinit-y += hw-gfx.ads 50 | gfxinit-y += hw-gfx-framebuffer_filler.adb 51 | gfxinit-y += hw-gfx-framebuffer_filler.ads 52 | 53 | CONFIG_GFX_GMA_PCH ?= No_PCH 54 | CONFIG_GFX_GMA_PANEL_2_PORT ?= Disabled 55 | 56 | CONFIG_GFX_GMA_GENERATION := $(call strip_quotes,$(CONFIG_GFX_GMA_GENERATION)) 57 | CONFIG_GFX_GMA_CPU := $(call strip_quotes,$(CONFIG_GFX_GMA_CPU)) 58 | CONFIG_GFX_GMA_CPU_VARIANT := $(call strip_quotes,$(CONFIG_GFX_GMA_CPU_VARIANT)) 59 | CONFIG_GFX_GMA_PCH := $(call strip_quotes,$(CONFIG_GFX_GMA_PCH)) 60 | CONFIG_GFX_GMA_PANEL_1_PORT := $(call strip_quotes,$(CONFIG_GFX_GMA_PANEL_1_PORT)) 61 | CONFIG_GFX_GMA_PANEL_2_PORT := $(call strip_quotes,$(CONFIG_GFX_GMA_PANEL_2_PORT)) 62 | CONFIG_GFX_GMA_ANALOG_I2C_PORT := $(call strip_quotes,$(CONFIG_GFX_GMA_ANALOG_I2C_PORT)) 63 | CONFIG_GFX_GMA_IGNORE_PRESENCE_STRAPS := $(if $(filter y,$(CONFIG_GFX_GMA_IGNORE_PRESENCE_STRAPS)),True,False) 64 | 65 | _GEN_TLA_SUBSTITUTIONS := g45 ilk hsw skl tgl 66 | 67 | _GEN_NONCONST := $(strip \ 68 | $(if $(filter G45,$(CONFIG_GFX_GMA_GENERATION)),g45, \ 69 | $(if $(filter Ironlake,$(CONFIG_GFX_GMA_GENERATION)),ilk, \ 70 | $(if $(filter Haswell,$(CONFIG_GFX_GMA_GENERATION)),hsw, \ 71 | $(if $(filter Skylake,$(CONFIG_GFX_GMA_GENERATION)),skl, \ 72 | $(if $(filter Tigerlake,$(CONFIG_GFX_GMA_GENERATION)),tgl)))))) 73 | # GNATprove (GPL 2017) doesn't realize when a boolean expression 74 | # that depends both on static values and variables can be evalu- 75 | # ated at compile time (e.g. `False and then Variable` is always 76 | # `False` and GNAT acts appropriately). So for now, we generate 77 | # functions instead of constant expressions for these mixed ex- 78 | # pressions. 79 | _GEN_CONST_TARGET := # set to `constant` to generate constants. 80 | 81 | hw-gfx-gma-config-ads := $(subst //,/,$(call src-to-obj,,$(dir)/hw-gfx-gma-config).ads) 82 | 83 | GFX_GMA_COMMON_SUBSTITUTIONS := \ 84 | -e's/<>/$(CONFIG_GFX_GMA_GENERATION)/' \ 85 | -e's/<>/$(CONFIG_GFX_GMA_PCH)/' \ 86 | -e's/<>/$(CONFIG_GFX_GMA_PANEL_1_PORT)/' \ 87 | -e's/<>/$(CONFIG_GFX_GMA_PANEL_2_PORT)/' \ 88 | -e's/<>/$(CONFIG_GFX_GMA_ANALOG_I2C_PORT)/' \ 89 | -e's/<>/$(CONFIG_GFX_GMA_DEFAULT_MMIO)/' \ 90 | -e's/<>/$(CONFIG_GFX_GMA_IGNORE_PRESENCE_STRAPS)/' \ 91 | 92 | ifeq ($(CONFIG_GFX_GMA_DYN_CPU),y) 93 | $(hw-gfx-gma-config-ads): $(dir)/hw-gfx-gma-config.ads.template $(cnf) 94 | printf " GENERATE $(patsubst /%,%,$(subst $(obj)/,,$@))\n" 95 | sed $(GFX_GMA_COMMON_SUBSTITUTIONS) \ 96 | -e'/constant Gen_CPU/d' \ 97 | -e's//constant Boolean/' \ 98 | $(foreach gen,$(_GEN_TLA_SUBSTITUTIONS), \ 99 | -e's/<\($(gen)\(...\)*\)bool>/<\1var> Boolean/') \ 100 | $(if $(_GEN_NONCONST),-e's/<\(...\)*$(_GEN_NONCONST)\(...\)*var>//') \ 101 | $(foreach gen,$(_GEN_TLA_SUBSTITUTIONS), \ 102 | -e's/<$(gen)\(...\)*var>/$(_GEN_CONST_TARGET)/') \ 103 | -e's/\(.*: *.*:=\) *\(.*\);/\1\n (\2);/' \ 104 | -e's/\([^ ][^ ]*\) *: * *\([^ ]*\) *:=/function \1 return \2 is/' \ 105 | -e's///' \ 106 | $< >$@ 107 | else 108 | $(hw-gfx-gma-config-ads): $(dir)/hw-gfx-gma-config.ads.template $(cnf) 109 | printf " GENERATE $(patsubst /%,%,$(subst $(obj)/,,$@))\n" 110 | sed $(GFX_GMA_COMMON_SUBSTITUTIONS) \ 111 | -e's/<>/$(CONFIG_GFX_GMA_CPU)/' \ 112 | -e's/<>/$(CONFIG_GFX_GMA_CPU_VARIANT)/' \ 113 | -e's//constant Boolean/' \ 114 | $(foreach gen,$(_GEN_TLA_SUBSTITUTIONS), \ 115 | -e's/<$(gen)\(...\)*bool>/constant Boolean/' \ 116 | -e's/<$(gen)\(...\)*var>/constant/') \ 117 | -e's// is null/' \ 118 | -f $(dir $<)/delete_dyncpu.sed \ 119 | $< >$@ 120 | endif 121 | gfxinit-gen-y += $(hw-gfx-gma-config-ads) 122 | gfxinit-$(CONFIG_GFX_GMA_DYN_CPU) += dyncpu/hw-gfx-gma-config.adb 123 | 124 | ifneq ($(filter G45,$(CONFIG_GFX_GMA_GENERATION)),) 125 | subdirs-y += g45 126 | else ifneq ($(filter Ironlake,$(CONFIG_GFX_GMA_GENERATION)),) 127 | subdirs-y += ironlake 128 | else ifneq ($(filter Haswell,$(CONFIG_GFX_GMA_GENERATION)),) 129 | subdirs-y += haswell_shared haswell 130 | else ifneq ($(filter Broxton,$(CONFIG_GFX_GMA_GENERATION)),) 131 | subdirs-y += haswell_shared broxton 132 | else ifneq ($(filter Skylake,$(CONFIG_GFX_GMA_GENERATION)),) 133 | subdirs-y += haswell_shared skylake 134 | else ifneq ($(filter Tigerlake,$(CONFIG_GFX_GMA_GENERATION)),) 135 | subdirs-y += tigerlake 136 | endif 137 | -------------------------------------------------------------------------------- /common/ironlake/hw-gfx-gma-port_detect.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2016-2017 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.GMA.Config; 16 | with HW.GFX.GMA.Registers; 17 | with HW.GFX.GMA.Config_Helpers; 18 | with HW.GFX.GMA.PCH.HDMI; 19 | 20 | package body HW.GFX.GMA.Port_Detect 21 | is 22 | 23 | DP_PORT_DETECTED : constant := 1 * 2 ** 2; 24 | PCH_DIGI_PORT_DETECTED : constant := 1 * 2 ** 2; 25 | PCH_LVDS_PORT_DETECTED : constant := 1 * 2 ** 1; 26 | 27 | SHOTPLUG_CTL_DETECT_MASK : constant := 16#0003_0303#; 28 | 29 | type PCH_Digital_Port_Value is array (PCH.HDMI.IRL_PCH_HDMI_Port) of Word32; 30 | SHOTPLUG_CTL_HPD_INPUT_ENABLE : constant PCH_Digital_Port_Value := 31 | (PCH_HDMI_B => 1 * 2 ** 4, 32 | PCH_HDMI_C => 1 * 2 ** 12, 33 | PCH_HDMI_D => 1 * 2 ** 20); 34 | SHOTPLUG_CTL_SHORT_PULSE_MASK : constant PCH_Digital_Port_Value := 35 | (PCH_HDMI_B => 3 * 2 ** 2, 36 | PCH_HDMI_C => 3 * 2 ** 10, 37 | PCH_HDMI_D => 3 * 2 ** 18); 38 | SHOTPLUG_CTL_HPD_STATUS : constant PCH_Digital_Port_Value := 39 | (PCH_HDMI_B => 3 * 2 ** 0, 40 | PCH_HDMI_C => 3 * 2 ** 8, 41 | PCH_HDMI_D => 3 * 2 ** 16); 42 | SHOTPLUG_CTL_LONG_DETECT : constant PCH_Digital_Port_Value := 43 | (PCH_HDMI_B => 1 * 2 ** 1, 44 | PCH_HDMI_C => 1 * 2 ** 9, 45 | PCH_HDMI_D => 1 * 2 ** 17); 46 | 47 | type PCH_Digital_Regs is array (PCH.HDMI.IRL_PCH_HDMI_Port) of Registers.Registers_Index; 48 | PCH_HDMI : constant PCH_Digital_Regs := 49 | (PCH_HDMI_B => Registers.PCH_HDMIB, 50 | PCH_HDMI_C => Registers.PCH_HDMIC, 51 | PCH_HDMI_D => Registers.PCH_HDMID); 52 | PCH_DP : constant PCH_Digital_Regs := 53 | (PCH_HDMI_B => Registers.PCH_DP_B, 54 | PCH_HDMI_C => Registers.PCH_DP_C, 55 | PCH_HDMI_D => Registers.PCH_DP_D); 56 | 57 | procedure Initialize 58 | is 59 | LVDS_Detected, 60 | eDP_Detected, 61 | HDMI_Detected, 62 | DP_Detected : Boolean; 63 | 64 | type PCH_Port_To_GMA_Port is array (PCH.HDMI.IRL_PCH_HDMI_Port) of Port_Type; 65 | To_Digital_Port : constant PCH_Port_To_GMA_Port := 66 | (PCH_HDMI_B => HDMI1, 67 | PCH_HDMI_C => HDMI2, 68 | PCH_HDMI_D => HDMI3); 69 | To_DP_Port : constant PCH_Port_To_GMA_Port := 70 | (PCH_HDMI_B => DP1, 71 | PCH_HDMI_C => DP2, 72 | PCH_HDMI_D => DP3); 73 | begin 74 | Config.Valid_Port (Analog) := True; 75 | 76 | -- PCH_LVDS 77 | Registers.Is_Set_Mask 78 | (Register => Registers.PCH_LVDS, 79 | Mask => PCH_LVDS_PORT_DETECTED, 80 | Result => LVDS_Detected); 81 | Config.Valid_Port (LVDS) := LVDS_Detected; 82 | 83 | -- eDP 84 | Registers.Is_Set_Mask 85 | (Register => Registers.DP_CTL_A, 86 | Mask => DP_PORT_DETECTED, 87 | Result => eDP_Detected); 88 | Config.Valid_Port (eDP) := eDP_Detected; 89 | 90 | -- PCH_HDMI_[BCD], PCH_DP_[BCD] share hotplug registers 91 | for PCH_Port in PCH.HDMI.IRL_PCH_HDMI_Port loop 92 | Registers.Is_Set_Mask 93 | (Register => PCH_HDMI (PCH_Port), 94 | Mask => PCH_DIGI_PORT_DETECTED, 95 | Result => HDMI_Detected); 96 | Config.Valid_Port (To_Digital_Port (PCH_Port)) := HDMI_Detected; 97 | 98 | Registers.Is_Set_Mask 99 | (Register => PCH_DP (PCH_Port), 100 | Mask => PCH_DIGI_PORT_DETECTED, 101 | Result => DP_Detected); 102 | Config.Valid_Port (To_DP_Port (PCH_Port)) := DP_Detected; 103 | 104 | if HDMI_Detected or DP_Detected then 105 | Registers.Unset_And_Set_Mask 106 | (Register => Registers.SHOTPLUG_CTL, 107 | Mask_Unset => SHOTPLUG_CTL_DETECT_MASK or 108 | SHOTPLUG_CTL_SHORT_PULSE_MASK (PCH_Port), 109 | Mask_Set => SHOTPLUG_CTL_HPD_INPUT_ENABLE (PCH_Port) or 110 | SHOTPLUG_CTL_HPD_STATUS (PCH_Port)); -- clear 111 | else 112 | Registers.Unset_Mask 113 | (Register => Registers.SHOTPLUG_CTL, 114 | Mask => SHOTPLUG_CTL_DETECT_MASK or 115 | SHOTPLUG_CTL_HPD_INPUT_ENABLE (PCH_Port)); 116 | end if; 117 | end loop; 118 | end Initialize; 119 | 120 | procedure Hotplug_Detect (Port : in Active_Port_Type; Detected : out Boolean) 121 | is 122 | Ctl32 : Word32; 123 | PCH_Port : constant GMA.PCH_Port := 124 | (case Port is 125 | when DP1 => PCH_HDMI_B, 126 | when DP2 => PCH_HDMI_C, 127 | when DP3 => PCH_HDMI_D, 128 | when others => Config_Helpers.To_PCH_Port (Port)); 129 | begin 130 | if PCH_Port in PCH_HDMI_B .. PCH_HDMI_D then 131 | Registers.Read (Registers.SHOTPLUG_CTL, Ctl32, Verbose => False); 132 | Detected := (Ctl32 and SHOTPLUG_CTL_LONG_DETECT (PCH_Port)) /= 0; 133 | 134 | if (Ctl32 and SHOTPLUG_CTL_HPD_STATUS (PCH_Port)) /= 0 then 135 | Registers.Unset_And_Set_Mask 136 | (Register => Registers.SHOTPLUG_CTL, 137 | Mask_Unset => SHOTPLUG_CTL_DETECT_MASK, 138 | Mask_Set => SHOTPLUG_CTL_HPD_STATUS (PCH_Port)); 139 | end if; 140 | else 141 | Detected := False; 142 | end if; 143 | end Hotplug_Detect; 144 | 145 | procedure Clear_Hotplug_Detect (Port : Active_Port_Type) 146 | is 147 | Ignored_HPD : Boolean; 148 | begin 149 | pragma Warnings (GNATprove, Off, "unused assignment to ""Ignored_HPD""", 150 | Reason => "We want to clear pending events only"); 151 | Port_Detect.Hotplug_Detect (Port, Ignored_HPD); 152 | pragma Warnings (GNATprove, On, "unused assignment to ""Ignored_HPD"""); 153 | end Clear_Hotplug_Detect; 154 | 155 | end HW.GFX.GMA.Port_Detect; 156 | -------------------------------------------------------------------------------- /common/hw-gfx-gma-transcoder.ads: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2015-2018 secunet Security Networks AG 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.GMA.Registers; 16 | with HW.GFX.GMA.Config; 17 | 18 | private package HW.GFX.GMA.Transcoder 19 | is 20 | 21 | procedure Setup (Pipe : Pipe_Index; Port_Cfg : Port_Config); 22 | procedure On 23 | (Pipe : Pipe_Index; 24 | Port_Cfg : Port_Config; 25 | Dither : Boolean; 26 | Scale : Boolean); 27 | 28 | procedure Off (Pipe : Pipe_Index); 29 | procedure Clk_Off (Pipe : Pipe_Index); 30 | 31 | procedure PSR_Off; 32 | 33 | function BPC_Conf (BPC : BPC_Type; Dither : Boolean) return Word32; 34 | 35 | private 36 | 37 | type Transcoder_Index is (Trans_EDP, Trans_A, Trans_B, Trans_C); 38 | 39 | type Transcoder_Regs is 40 | record 41 | HTOTAL : Registers.Registers_Index; 42 | HBLANK : Registers.Registers_Index; 43 | HSYNC : Registers.Registers_Index; 44 | VTOTAL : Registers.Registers_Index; 45 | VBLANK : Registers.Registers_Index; 46 | VSYNC : Registers.Registers_Index; 47 | CONF : Registers.Registers_Index; 48 | DATA_M1 : Registers.Registers_Index; 49 | DATA_N1 : Registers.Registers_Index; 50 | LINK_M1 : Registers.Registers_Index; 51 | LINK_N1 : Registers.Registers_Index; 52 | DDI_FUNC_CTL : Registers.Registers_Index; 53 | MSA_MISC : Registers.Registers_Index; 54 | CLK_SEL : Registers.Registers_Invalid_Index; 55 | end record; 56 | 57 | type Transcoder_Array is array (Transcoder_Index) of Transcoder_Regs; 58 | 59 | PIPE_DATA_M1 : constant array (0 .. 1) of Registers.Registers_Index := 60 | (if Config.Has_GMCH_DP_Transcoder then 61 | (0 => Registers.PIPEA_GMCH_DATA_M, 62 | 1 => Registers.PIPEB_GMCH_DATA_M) 63 | else 64 | (0 => Registers.PIPEA_DATA_M1, 65 | 1 => Registers.PIPEB_DATA_M1)); 66 | PIPE_DATA_N1 : constant array (0 .. 1) of Registers.Registers_Index := 67 | (if Config.Has_GMCH_DP_Transcoder then 68 | (0 => Registers.PIPEA_GMCH_DATA_N, 69 | 1 => Registers.PIPEB_GMCH_DATA_N) 70 | else 71 | (0 => Registers.PIPEA_DATA_N1, 72 | 1 => Registers.PIPEB_DATA_N1)); 73 | PIPE_LINK_M1 : constant array (0 .. 1) of Registers.Registers_Index := 74 | (if Config.Has_GMCH_DP_Transcoder then 75 | (0 => Registers.PIPEA_GMCH_LINK_M, 76 | 1 => Registers.PIPEB_GMCH_LINK_M) 77 | else 78 | (0 => Registers.PIPEA_LINK_M1, 79 | 1 => Registers.PIPEB_LINK_M1)); 80 | PIPE_LINK_N1 : constant array (0 .. 1) of Registers.Registers_Index := 81 | (if Config.Has_GMCH_DP_Transcoder then 82 | (0 => Registers.PIPEA_GMCH_LINK_N, 83 | 1 => Registers.PIPEB_GMCH_LINK_N) 84 | else 85 | (0 => Registers.PIPEA_LINK_N1, 86 | 1 => Registers.PIPEB_LINK_N1)); 87 | 88 | Transcoders : constant Transcoder_Array := 89 | (Trans_EDP => 90 | (HTOTAL => Registers.HTOTAL_EDP, 91 | HBLANK => Registers.HBLANK_EDP, 92 | HSYNC => Registers.HSYNC_EDP, 93 | VTOTAL => Registers.VTOTAL_EDP, 94 | VBLANK => Registers.VBLANK_EDP, 95 | VSYNC => Registers.VSYNC_EDP, 96 | CONF => Registers.PIPE_EDP_CONF, 97 | DATA_M1 => Registers.PIPE_EDP_DATA_M1, 98 | DATA_N1 => Registers.PIPE_EDP_DATA_N1, 99 | LINK_M1 => Registers.PIPE_EDP_LINK_M1, 100 | LINK_N1 => Registers.PIPE_EDP_LINK_N1, 101 | DDI_FUNC_CTL => Registers.PIPE_EDP_DDI_FUNC_CTL, 102 | MSA_MISC => Registers.PIPE_EDP_MSA_MISC, 103 | CLK_SEL => Registers.Invalid_Register), 104 | Trans_A => 105 | (HTOTAL => Registers.HTOTAL_A, 106 | HBLANK => Registers.HBLANK_A, 107 | HSYNC => Registers.HSYNC_A, 108 | VTOTAL => Registers.VTOTAL_A, 109 | VBLANK => Registers.VBLANK_A, 110 | VSYNC => Registers.VSYNC_A, 111 | CONF => Registers.PIPEACONF, 112 | DATA_M1 => PIPE_DATA_M1 (0), 113 | DATA_N1 => PIPE_DATA_N1 (0), 114 | LINK_M1 => PIPE_LINK_M1 (0), 115 | LINK_N1 => PIPE_LINK_N1 (0), 116 | DDI_FUNC_CTL => Registers.PIPEA_DDI_FUNC_CTL, 117 | MSA_MISC => Registers.PIPEA_MSA_MISC, 118 | CLK_SEL => Registers.TRANSA_CLK_SEL), 119 | Trans_B => 120 | (HTOTAL => Registers.HTOTAL_B, 121 | HBLANK => Registers.HBLANK_B, 122 | HSYNC => Registers.HSYNC_B, 123 | VTOTAL => Registers.VTOTAL_B, 124 | VBLANK => Registers.VBLANK_B, 125 | VSYNC => Registers.VSYNC_B, 126 | CONF => Registers.PIPEBCONF, 127 | DATA_M1 => PIPE_DATA_M1 (1), 128 | DATA_N1 => PIPE_DATA_N1 (1), 129 | LINK_M1 => PIPE_LINK_M1 (1), 130 | LINK_N1 => PIPE_LINK_N1 (1), 131 | DDI_FUNC_CTL => Registers.PIPEB_DDI_FUNC_CTL, 132 | MSA_MISC => Registers.PIPEB_MSA_MISC, 133 | CLK_SEL => Registers.TRANSB_CLK_SEL), 134 | Trans_C => 135 | (HTOTAL => Registers.HTOTAL_C, 136 | HBLANK => Registers.HBLANK_C, 137 | HSYNC => Registers.HSYNC_C, 138 | VTOTAL => Registers.VTOTAL_C, 139 | VBLANK => Registers.VBLANK_C, 140 | VSYNC => Registers.VSYNC_C, 141 | CONF => Registers.PIPECCONF, 142 | DATA_M1 => Registers.PIPEC_DATA_M1, 143 | DATA_N1 => Registers.PIPEC_DATA_N1, 144 | LINK_M1 => Registers.PIPEC_LINK_M1, 145 | LINK_N1 => Registers.PIPEC_LINK_N1, 146 | DDI_FUNC_CTL => Registers.PIPEC_DDI_FUNC_CTL, 147 | MSA_MISC => Registers.PIPEC_MSA_MISC, 148 | CLK_SEL => Registers.TRANSC_CLK_SEL)); 149 | 150 | end HW.GFX.GMA.Transcoder; 151 | -------------------------------------------------------------------------------- /common/haswell/hw-gfx-gma-pch-lynxpoint.adb: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright (C) 2020 Angel Pons 3 | -- 4 | -- This program is free software; you can redistribute it and/or modify 5 | -- it under the terms of the GNU General Public License as published by 6 | -- the Free Software Foundation; either version 2 of the License, or 7 | -- (at your option) any later version. 8 | -- 9 | -- This program is distributed in the hope that it will be useful, 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | -- GNU General Public License for more details. 13 | -- 14 | 15 | with HW.GFX.GMA.Config; 16 | with HW.GFX.GMA.Registers; 17 | with HW.GFX.GMA.PCH.Sideband; 18 | 19 | with HW.Debug; 20 | with GNAT.Source_Info; 21 | 22 | package body HW.GFX.GMA.PCH.Lynxpoint is 23 | 24 | FDI_MPHY_IOSFSB_RESET_CTL : constant := 1 * 2 ** 12; 25 | FDI_MPHY_IOSFSB_RESET_STATUS : constant := 1 * 2 ** 13; 26 | 27 | procedure Reset_FDI_mPHY is 28 | begin 29 | Registers.Set_Mask 30 | (Register => Registers.QUIRK_C2004, 31 | Mask => FDI_MPHY_IOSFSB_RESET_CTL); 32 | 33 | Registers.Wait_Set_Mask 34 | (Register => Registers.QUIRK_C2004, 35 | Mask => FDI_MPHY_IOSFSB_RESET_STATUS, 36 | TOut_MS => 1); -- 100 us 37 | 38 | Registers.Unset_Mask 39 | (Register => Registers.QUIRK_C2004, 40 | Mask => FDI_MPHY_IOSFSB_RESET_CTL); 41 | 42 | Registers.Wait_Unset_Mask 43 | (Register => Registers.QUIRK_C2004, 44 | Mask => FDI_MPHY_IOSFSB_RESET_STATUS, 45 | TOut_MS => 1); -- 100 us 46 | end Reset_FDI_mPHY; 47 | 48 | -- WaMPhyProgramming:hsw 49 | procedure Program_FDI_mPHY 50 | is 51 | use Sideband; 52 | subtype Bit_Index is Natural range 0 .. Word32'Size - 1; 53 | 54 | procedure mPHY_Update_Field 55 | (High_Bit : in Bit_Index; 56 | Low_Bit : in Bit_Index; 57 | Value : in Word32; 58 | Register : in Register_Type) 59 | with 60 | Pre => High_Bit >= Low_Bit 61 | is 62 | begin 63 | Unset_And_Set_Mask 64 | (Dest => SBI_MPHY, 65 | Register => Register, 66 | Mask_Unset => 2 ** (High_Bit + 1) - 2 ** Low_Bit, 67 | Mask_Set => Value * 2 ** Low_Bit); 68 | end mPHY_Update_Field; 69 | 70 | procedure mPHY_Update_Lanes 71 | (High_Bit : in Bit_Index; 72 | Low_Bit : in Bit_Index; 73 | Value : in Word32; 74 | Reg_Lane_0 : in Register_Type; 75 | Reg_Lane_1 : in Register_Type) 76 | with 77 | Pre => High_Bit >= Low_Bit 78 | is 79 | begin 80 | mPHY_Update_Field (High_Bit, Low_Bit, Value, Reg_Lane_0); 81 | mPHY_Update_Field (High_Bit, Low_Bit, Value, Reg_Lane_1); 82 | end mPHY_Update_Lanes; 83 | begin 84 | mPHY_Update_Field (31, 24, 16#12#, SBI_MPHY_8008); 85 | mPHY_Update_Lanes (11, 11, 1, SBI_MPHY_2008, SBI_MPHY_2108); 86 | mPHY_Update_Lanes (24, 24, 1, SBI_MPHY_206C, SBI_MPHY_216C); 87 | mPHY_Update_Lanes (21, 21, 1, SBI_MPHY_206C, SBI_MPHY_216C); 88 | mPHY_Update_Lanes (18, 18, 1, SBI_MPHY_206C, SBI_MPHY_216C); 89 | mPHY_Update_Lanes (15, 13, 16#05#, SBI_MPHY_2080, SBI_MPHY_2180); 90 | mPHY_Update_Lanes ( 7, 0, 16#1c#, SBI_MPHY_208C, SBI_MPHY_218C); 91 | mPHY_Update_Lanes (23, 16, 16#1c#, SBI_MPHY_2098, SBI_MPHY_2198); 92 | mPHY_Update_Lanes (27, 27, 1, SBI_MPHY_20C4, SBI_MPHY_21C4); 93 | mPHY_Update_Lanes (31, 28, 16#04#, SBI_MPHY_20EC, SBI_MPHY_21EC); 94 | end Program_FDI_mPHY; 95 | 96 | ---------------------------------------------------------------------------- 97 | 98 | SBI_SSCCTL_DISABLE : constant := 1 * 2 ** 0; 99 | SBI_SSCCTL_PATHALT : constant := 1 * 2 ** 3; 100 | SBI_GEN0_CFG_BUFFENABLE_DISABLE : constant := 1 * 2 ** 0; 101 | 102 | procedure Enable_Clkout_DP_And_FDI_mPHY is 103 | begin 104 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 105 | 106 | Sideband.Unset_And_Set_Mask 107 | (Dest => Sideband.SBI_ICLK, 108 | Register => Sideband.SBI_SSCCTL, 109 | Mask_Unset => SBI_SSCCTL_DISABLE, 110 | Mask_Set => SBI_SSCCTL_PATHALT); 111 | 112 | Time.U_Delay (24); 113 | 114 | Sideband.Unset_Mask 115 | (Dest => Sideband.SBI_ICLK, 116 | Register => Sideband.SBI_SSCCTL, 117 | Mask => SBI_SSCCTL_PATHALT); 118 | 119 | Reset_FDI_mPHY; 120 | Program_FDI_mPHY; 121 | 122 | Sideband.Set_Mask 123 | (Dest => Sideband.SBI_ICLK, 124 | Register => (if Config.Is_LP then Sideband.SBI_GEN0 else Sideband.SBI_DBUFF0), 125 | Mask => SBI_GEN0_CFG_BUFFENABLE_DISABLE); 126 | end Enable_Clkout_DP_And_FDI_mPHY; 127 | 128 | procedure Disable_Clkout_DP 129 | is 130 | function Is_Mask_Set (Value, Mask : Word32) return Boolean is 131 | ((Value and Mask) = Mask); 132 | SSC_Ctl : Word32; 133 | begin 134 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 135 | 136 | Sideband.Unset_Mask 137 | (Dest => Sideband.SBI_ICLK, 138 | Register => (if Config.Is_LP then Sideband.SBI_GEN0 else Sideband.SBI_DBUFF0), 139 | Mask => SBI_GEN0_CFG_BUFFENABLE_DISABLE); 140 | 141 | Sideband.Read 142 | (Dest => Sideband.SBI_ICLK, 143 | Register => Sideband.SBI_SSCCTL, 144 | Value => SSC_Ctl); 145 | 146 | if not Is_Mask_Set (SSC_Ctl, SBI_SSCCTL_DISABLE) then 147 | if not Is_Mask_Set (SSC_Ctl, SBI_SSCCTL_PATHALT) then 148 | Sideband.Set_Mask 149 | (Dest => Sideband.SBI_ICLK, 150 | Register => Sideband.SBI_SSCCTL, 151 | Mask => SBI_SSCCTL_PATHALT); 152 | Time.U_Delay (32); 153 | end if; 154 | Sideband.Set_Mask 155 | (Dest => Sideband.SBI_ICLK, 156 | Register => Sideband.SBI_SSCCTL, 157 | Mask => SBI_SSCCTL_DISABLE); 158 | end if; 159 | end Disable_Clkout_DP; 160 | 161 | procedure Unbend_Clkout_DP is 162 | begin 163 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); 164 | 165 | Sideband.Write 166 | (Dest => Sideband.SBI_ICLK, 167 | Register => Sideband.SBI_SSCDITHPHASE, 168 | Value => 0); 169 | 170 | Sideband.Unset_And_Set_Mask 171 | (Dest => Sideband.SBI_ICLK, 172 | Register => Sideband.SBI_SSCDIVINTPHASE, 173 | Mask_Unset => 16#ffff#, 174 | Mask_Set => 16#0025#); 175 | end Unbend_Clkout_DP; 176 | 177 | end HW.GFX.GMA.PCH.Lynxpoint; 178 | --------------------------------------------------------------------------------