gma display_probing: Add Hotplug_Events()

The Hotplug_Events() procedure returns a list of ports with hotplug
events. The events are automatically cleared, so it's the caller's
responsibility to act accordingly (e.g. run Update_Outputs() with
updated configurations).

Change-Id: Iff5e812d3119bfd44f5ea58e5086aa3ccba7c0bf
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/libgfxinit/+/35720
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Matt DeVillier <matt.devillier@gmail.com>
diff --git a/common/hw-gfx-gma-display_probing.adb b/common/hw-gfx-gma-display_probing.adb
index 74e2ad8..0d7cd37 100644
--- a/common/hw-gfx-gma-display_probing.adb
+++ b/common/hw-gfx-gma-display_probing.adb
@@ -19,6 +19,7 @@
 with HW.GFX.GMA.I2C;
 with HW.GFX.GMA.DP_Aux_Ch;
 with HW.GFX.GMA.Panel;
+with HW.GFX.GMA.Port_Detect;
 with HW.GFX.GMA.Power_And_Clocks;
 
 with HW.Debug;
@@ -215,4 +216,20 @@
       end if;
    end Scan_Ports;
 
+   procedure Hotplug_Events (Ports : out Port_List)
+   is
+      I : Port_List_Range := Port_List_Range'First;
+      Detected : Boolean;
+   begin
+      Ports := (others => Disabled);
+      for P in Active_Port_Type loop
+         Port_Detect.Hotplug_Detect (P, Detected);
+         if Detected then
+            Ports (I) := P;
+            exit when I = Port_List_Range'Last;
+            I := Port_List_Range'Succ (I);
+         end if;
+      end loop;
+   end Hotplug_Events;
+
 end HW.GFX.GMA.Display_Probing;