Skip to content

Commit

Permalink
platform/x86: apple-gmux: use first bit to check switch state
Browse files Browse the repository at this point in the history
On T2 Macs with MMIO gmux, when GMUX_PORT_SWITCH_DISPLAY is read, it can
have values of 2, 3, 4, and 5. Odd values correspond to the discrete gpu,
and even values correspond to the integrated gpu. The current logic is
that only 2 corresponds to IGD, but this doesn't work for T2 Macs.
Instead, check the first bit to determine the connected gpu.

As T2 Macs with gmux only can switch the internal display, it is
untested if this change (or a similar change) would be applicable
to GMUX_PORT_SWITCH_DDC and GMUX_PORT_SWITCH_EXTERNAL.

Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Orlando Chamberlain <orlandoch.dev@gmail.com>
Link: https://lore.kernel.org/r/20230303112842.3094-2-orlandoch.dev@gmail.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  • Loading branch information
Orlando Chamberlain authored and Hans de Goede committed Mar 16, 2023
1 parent fe15c26 commit 90caf1d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/platform/x86/apple-gmux.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,10 @@ static void gmux_read_switch_state(struct apple_gmux_data *gmux_data)
else
gmux_data->switch_state_ddc = VGA_SWITCHEROO_DIS;

if (gmux_read8(gmux_data, GMUX_PORT_SWITCH_DISPLAY) == 2)
gmux_data->switch_state_display = VGA_SWITCHEROO_IGD;
else
if (gmux_read8(gmux_data, GMUX_PORT_SWITCH_DISPLAY) & 1)
gmux_data->switch_state_display = VGA_SWITCHEROO_DIS;
else
gmux_data->switch_state_display = VGA_SWITCHEROO_IGD;

if (gmux_read8(gmux_data, GMUX_PORT_SWITCH_EXTERNAL) == 2)
gmux_data->switch_state_external = VGA_SWITCHEROO_IGD;
Expand Down

0 comments on commit 90caf1d

Please sign in to comment.