Commit graph

38 commits

Author SHA1 Message Date
Nick Chan
869d2ae35c Skip over features unsupported in A7-A11 SoCs.
This includes
- GXF
- SPRR
- PAN (A7-A9)
- Atomics (A7-A10)
- FIPI (A7-A10)
- DCP

SPRR on T8030 seems to be quite different from M1 (at least according to
qemu-t8030), so keep it disabled for those CPU parts.

Signed-off-by: Nick Chan <towinchenmi@gmail.com>
2024-10-31 01:32:39 +09:00
Hector Martin
277e8e71de display: Exclude j413 from Sequoia workaround by changing the logic
It seems this model does not need it *and* it somehow causes
nondeterministic problems.

Also add a delay to the poweroff/on sequence to be more conservative.

Fixes: #406
Signed-off-by: Hector Martin <marcan@marcan.st>
2024-09-28 22:22:15 +09:00
Hector Martin
cdb6d41aa2 display: Add workaround for Sequoia DCP handoff bug
Signed-off-by: Hector Martin <marcan@marcan.st>
2024-09-17 23:42:42 +09:00
Hector Martin
dfffdf6609 display: Avoid placing FBs at IOVA 0
Also search harder for a matching dcp/disp iova, in case it matters.

Fixes: #391
Signed-off-by: Hector Martin <marcan@marcan.st>
2024-05-17 10:22:55 +09:00
Janne Grunau
11b9d4475b display: Fix pmgr device id for t6022 dcpext4
Signed-off-by: Janne Grunau <j@jannau.net>
2023-12-16 17:17:37 +09:00
Janne Grunau
5006e083c7 display: Use dcpext0 for HDMI out on t8112/t6020/t6021
dcpext0 behaves like dcp on M1* devices and can sleep after display
init. This has the advantage of not breaking macOS when starting with an
initialized display.
dcpext* are according to Apple's tech specs slightly more powerful than
dcp. They are advertised as 6K at 60Hz while dcp seems to be limited to
5K at 60Hz.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-11-27 13:33:08 +09:00
Janne Grunau
ba69847862 display: Add NO_DISPLAY build config to skip display init
Required for stage 1 loader to allow chainloaded display/dcp experiments
to start with the state left by iboot.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-11-27 13:33:08 +09:00
Janne Grunau
69e3610737 display: Optionally use dcpext0/1 on t6020 and t6021
Allows emulating a t6022 system with fused off dcp0/dcp1 display
controllers.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-11-14 18:57:15 +09:00
Janne Grunau
8c99a189e0 dptx: Add the number of dptxport services
Avoids waiting 500 ms for the second dptxport service on t6020 and
possibly t6021.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-11-14 18:57:15 +09:00
Hector Martin
787eb8c220 display: More Sonoma workarounds
Power up display early (fixes HPD sometimes) and delay at least one
frame after swapping before quiescing DCP, otherwise the swap somehow
doesn't complete.

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-11-02 19:19:10 +09:00
Hector Martin
40a9444484 display,fb: Clear framebuffer early in the Sonoma stage2 fixup path
stage1 ends up with an ugly Asahi 100% logo on top of a 200% Apple logo.
Let's just clear it so it looks nicer.

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-11-02 18:12:33 +09:00
Hector Martin
6af39a9b40 display: Try to modeset twice
This works around issues switching to 120Hz mode on systems affected by
the Sonoma situation, and in general it's probably a good idea anyway.

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-11-02 18:12:27 +09:00
Hector Martin
c887c3cb54 display: Work around macOS Sonoma firmware bugs
It appears that when macOS is set to non-ProMotion mode, DCP firmware
<14.0 booted from DCP firmware 14.0+ needs a delay before modesetting to
complete the modeset properly.

The cases here are:
- Older m1n1 stage1 will, as far as it's concerned, initialize the
  display properly, but it won't work. It also misses the retina flag,
  since this codepath was intended for external displays. Use the
  missing retina flag as a signal to trigger reconfig.
- If installed as stage1, we reconfigure the display as usual, now with
  the extra delay. We also set the Retina flag now.

The persistence mechanism for the ProMotion flag is unknown. It doesn't
seem to be nvram. It also doesn't matter if we successfully modeset to
120Hz mode and then reboot, it breaks again, so it's not about the
"current" mode sticking.

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-11-02 18:12:26 +09:00
Janne Grunau
31ee1499f8 display: Support the HDMI output on M2* desktop systems
On M2* desktop systems the HDMI output is not managed by dcp/dcp0. This
allows more flexibility, for example dcp on the M2 Mac mini can be
routed to the USB-C/ThunderBolt ports.
For m1n1 this adds quite ab bit of complexity. In addition to the DCP
iboot endpoint/protocol two additional endpoints have to be started.
Only the dptx-port endpoint has a meaningful AP <=> DCP communication.
In addition we start the system endpoint to optionally enable more
verbose syslog messages (if RTKIT_SYSLOG is defined).
In addition the dptx-phy or lpdptx-phy has to be programmed. Those two
phy look mostly identical. MacOS seems to use a static DP configuration
(4 lanes, HBR3*) regardless of the connected display.
The added SMC gpio support is used to power the MCDP29xx DP to HDMI
converter on.
Config  is unfortunately a mess since Apple can't name the device tree
nodes consistently. On M2 Ultra devices only the four dcpext*/dispext*
on each die are used. M2 Ultra support is untested.

* link rate might differ on t602x based devices for 8k60 support

Signed-off-by: Janne Grunau <j@jannau.net>
2023-10-05 12:33:35 +09:00
Janne Grunau
b72407ed23 display: Use dcp iboot SetSurface instead of SwapLayer
iboot uses this and it's simpler. m1n1 doesn't need to swap surfaces
for tear free display.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-10-05 12:33:35 +09:00
Martin Povišer
fa820a7164 display: Factor out top of memory allocation
Move it into utils.c before we reuse it for SIO data.

Signed-off-by: Martin Povišer <povik@cutebit.org>
2023-08-17 19:49:43 +09:00
Hector Martin
bb0e9ace57 display: Make M2+ desktop disable hack more generic
This should work on the Mac Pro.

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-08-07 19:27:47 +09:00
Janne Grunau
076217a802 display: Skip init on j473/474s while it's not supported
Signed-off-by: Janne Grunau <j@jannau.net>
2023-05-16 18:23:44 +09:00
Janne Grunau
c8c0bd5dc5 display: Check if FB IOVA is available on dart-disp0
Fixes a copy and paste error in 1b5dee2496 checking dart-dcp twice.

Fixes: 1b5dee2496 ("display: Map the framebuffer if it is not mapped")
Signed-off-by: Janne Grunau <j@jannau.net>
2023-02-02 09:50:33 +09:00
Janne Grunau
4e7398e3a8 display: Start scanning for fb IOVA at vm-base
Required for M2 devices as the M2 Mac mini.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-02-02 09:50:33 +09:00
Janne Grunau
f1664ccef4 dart: Add DART_PTR_ERR to indicate failures for IOVA returning functions
0 is a valid and used device virtual address. Daart functions returning
device address can not use 0 to indicate errors.

Signed-off-by: Janne Grunau <j@jannau.net>
2022-10-23 17:21:26 +09:00
Hector Martin
b1f9d72554 hv: Don't touch DCP on laptops
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-28 01:47:02 +09:00
Hector Martin
17abe8f94b display: Report time spent modesetting
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-01 02:03:32 +09:00
Hector Martin
714420a694 display: Put DCP to sleep if display is external
This stops DCP from killing our modeset if the connection cycles.

Also force a (potential) configure cycle if the display is external;
this makes sure updated stage2s will have a chance at fixing issues of
old stage1s. Modesetting is fast when it's the same mode as before.

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-01 01:54:11 +09:00
Hector Martin
09013da441 display: Don't crash if shutdown is called twice
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-01 00:57:17 +09:00
Janne Grunau
8147c2d374 display: Add 'retina' flag to display_parse_mode
Signed-off-by: Janne Grunau <j@jannau.net>
2022-05-30 23:01:01 +09:00
Janne Grunau
7f4347ebe8 display: Reallocate framebuffer if required for wanted display mode
If an explicitly specified display mode exceeds the allocated
framebuffer allocate a new one from the top of RAM.

Note: macOS panics immediately with a realloced framebuffer.

Signed-off-by: Janne Grunau <j@jannau.net>
2022-05-30 23:01:01 +09:00
Janne Grunau
079659dfea display: Move dcp iboot swap into its own function
Signed-off-by: Janne Grunau <j@jannau.net>
2022-05-30 23:01:01 +09:00
Janne Grunau
c577e94d75 display: limit timing modes by framebuffer size
The reserved framebuffer on the Mac Studio is 0x854000 bytes. This is
too small for 1920x1200 with 4 byte per pixel. Setting 1920x1200 as
mode crashes dcp but not the actual display controller. The display
remains working and even comes back after display hotplug/power cycle.

Signed-off-by: Janne Grunau <j@jannau.net>
2022-05-30 23:01:01 +09:00
Janne Grunau
1b5dee2496 display: Map the framebuffer if it is not mapped
iboot on Mac Studio (M1 Ultra) does not map the framebuffer("/vram")
for dcp and disp0.

Signed-off-by: Janne Grunau <j@jannau.net>
2022-04-19 21:29:30 +09:00
Hector Martin
1d19e74ca8 display: Implement mode selection
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-03-27 17:57:37 +09:00
Hector Martin
ebf1cf3aa3 display: Reinit FB if resolution changed 2022-03-27 17:02:00 +09:00
Hector Martin
3248c91aef display: Allow forcing re-config via payload (WIP)
Doesn't actually let you specify a mode yet.

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-03-27 16:46:53 +09:00
Hector Martin
8af401ade1 display: Also prefer <4K modes in the vertical dimension
Apparently 2:1 scaled modes like 1920x2160 are a thing?

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-03-27 16:08:39 +09:00
Hector Martin
5531b9ae32 display: statify local functions
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-02-22 00:54:17 +09:00
Hector Martin
d1dcf16c66 display: Update boot args in place for HV guests
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-02-21 16:03:23 +09:00
Janne Grunau
b2cb605832 display: Retry dcp_ib_get_hpd() for up to 2 seconds
After boot DCP will need some time to detect connected displays.

Signed-off-by: Janne Grunau <j@jannau.net>
2022-01-17 23:12:49 +09:00
Hector Martin
1c2a2db1dd display: Add logic to initialize the Mac Mini HDMI display
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-01-17 04:42:00 +09:00