Skip to content

Commit

Permalink
proxy: experiments: Add dp2hdmi.py for manual display config
Browse files Browse the repository at this point in the history
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
jannau committed Sep 5, 2023
1 parent 44d6916 commit d82b20c
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions proxyclient/experiments/dp2hdmi.py
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)

0 comments on commit d82b20c

Please sign in to comment.