watchthelight labs

LegionHybrid

Hybrid graphics for macOS on the Lenovo Legion 5 15IAX10 (Core Ultra 9 275HX with its Arrow Lake iGPU, RTX 5070 Laptop). The goal is what Windows gets from NVIDIA Optimus and Advanced Optimus: the RTX 5070 powered only when it is needed, apps rendering on it while the Intel GPU drives the panel, and the panel switched between the two GPUs.

Status, 2026-10-22: built, not yet run on hardware. Version 0.2 gives the primitives and a read-only probe. Turning the dGPU on and switching the panel are written but locked behind a boot-arg until a guarded test boot has shown they are safe.

What is in here

  • kext/: LegionHybrid.kext. It loads at boot and does nothing on its own. Commands go in through sysctl debug.legionhybrid and results come back in debug.legionhybrid_log:
    • probe: read-only. It reads the panel mux state, the support lists and capabilities of NVIDIA's _DSM interfaces (Optimus, JT/GC6, GPS, NBCI, PCIe), Lenovo's EC flags and the root port's link state.
    • eval, dsm, cfg, link, rescan, nv: single ACPI or PCI reads.
    • ldis, and any eval/dsm that changes state, only with the boot-arg legionhybrid=arm.
    • For the first five minutes after load it also logs every change of the root port's Link Control and Link Status, because something sets Link Disable after boot in Hybrid mode.
  • tools/legion-hybrid: the sequences, kept in a script so they can change without a new kext. Commands: probe, mux, on --yes, mux-set igpu|dgpu --yes. Every step is logged to /Users/Shared/legion-diag/legion-hybrid.log.
  • docs/RESEARCH.md: the full research behind it, with sources and confidence for each claim.
  • docs/HOW-IT-WORKS.md: the firmware interfaces, the power and mux sequences, and why the earlier attempts cut power.

Two related changes live in the NvGfx fork:

  • hybrid-2.5.3: the NVRMFB proxy head on NvGfx 2.5.3. The RTX 5070 composites the desktop and the Intel GPU only scans it out.
  • intel-xe: IGPUConsoleRange 0.5, which brings the dGPU up at boot with the same sequence when nvfbigpu=1 is set.

Build

./build.sh                         # out/LegionHybrid.kext, link-checked against the running Tahoe kernel collection

It needs the Command Line Tools with the macOS 15.5 SDK (as for the other Legion kexts). Inject the kext with OpenCore (Kernel > Add) and copy tools/legion-hybrid to /usr/local/bin.

Safety

On this machine, an earlier attempt to power the dGPU in Hybrid mode left it powered without a PCIe link, and the laptop cut its own power. The on sequence:

  • refuses unless the panel is on the iGPU and the EC has released the GPU;
  • clears Link Disable first, then calls the firmware's own power-on;
  • waits two seconds for the link, and turns the GPU off again through the firmware if no link comes up.

Even so, run it only on a machine you can power-cycle.

Other machines

The _DSM GUIDs and the GC6 and MXDS conventions come from NVIDIA and are common across Optimus laptops. The paths (RP01, PXSX, EDP1, EC0), the EC methods (WEJF, REJF) and the mux GPIO are this Legion's. Read your own ACPI tables before using any of it.

Credits

  • NVIDIA's open-gpu-kernel-modules headers (nvop.h, jt.h, nbci.h) and coreboot's NVIDIA-written Brya ACPI (nvjt.asl, power.asl), for the _DSM functions and the GC6 sequence.
  • Lenovo Legion Toolkit, for Lenovo's GPU mode and EC notification calls.
  • LenovoLegionLinux and the Linux lenovo-wmi-gamezone documentation.
  • Apple's IOPCIFamily and IOGraphics sources, and the Linux apple-gmux and vga_switcheroo code, for how macOS and Linux switch GPUs.