-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
proxy: experiments: Add dp2hdmi.py for manual display config
SMC GPIO support is required for powering the dp2hdmi converter on. Uses m1n1's C implementation otherwise. Signed-off-by: Janne Grunau <j@jannau.net>
- Loading branch information
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env python3 | ||
# SPDX-License-Identifier: MIT | ||
|
||
import sys, pathlib | ||
sys.path.append(str(pathlib.Path(__file__).resolve().parents[1])) | ||
|
||
from m1n1.setup import * | ||
from m1n1.fw.smc import SMCClient | ||
|
||
# init SMC | ||
smc_addr = u.adt["arm-io/smc"].get_reg(0)[0] | ||
smc = SMCClient(u, smc_addr, None) | ||
smc.verbose = 3 | ||
|
||
smc.start() | ||
smc.start_ep(0x20) | ||
|
||
smcep = smc.epmap[0x20] | ||
|
||
# init/start DCP endpoints | ||
p.display_start_dcp() | ||
|
||
# power dp2hdmi converter on | ||
target_type = u.adt.getprop('target-type') | ||
if target_type in ["J180d", "J474s", "J475c"]: # mac pro m2 ultra/mini m2 pro/studio m2 max | ||
dp2hdmi_node = u.adt["/arm-io/dp2hdmi-gpio0"] | ||
elif target_type in ["J473"]: # mac mini m2 | ||
dp2hdmi_node = u.adt["/arm-io/dp2hdmi-gpio"] | ||
elif target_type in ["J475d"]: # mac studio m2 ultra | ||
dp2hdmi_node = u.adt["/arm-io/dp2hdmi-gpio1"] | ||
|
||
hdmi_pwr_en_gpio = dp2hdmi_node.getprop('function-hdmi_pwr_en').args[0].to_bytes(4, byteorder='big').decode() | ||
dp2hdmi_pwr_en_gpio = dp2hdmi_node.getprop('function-dp2hdmi_pwr_en').args[0].to_bytes(4, byteorder='big').decode() | ||
|
||
print(f"dp2hdmi_pwr_enable:{dp2hdmi_pwr_en_gpio} hdmi_pwr_enable:{hdmi_pwr_en_gpio}") | ||
smcep.write32(hdmi_pwr_en_gpio, 0x800001) | ||
smcep.write32(dp2hdmi_pwr_en_gpio, 0x800001) | ||
|
||
smc.stop() | ||
|
||
# manual display config | ||
config = u.malloc(256) | ||
p.iface.writemem(config, b'1920x1080@60\0') | ||
p.display_configure(config) |