Skip to content

Apple's open-source XNU kernel on Android phones: its own loader and drivers, Metal on the Adreno. Runs from RAM; a reboot gives the phone back to Android.

C

fb_ca_hz=N: the refresh rate told to CoreAnimation apart from the panel's; told 120 it drew at 60 whatever its switches said

shimoku74f6ebf314c96e
diff --git a/configs/boot-args.lst b/configs/boot-args.lst
index 0834f73..e2e05d3 100644
--- a/configs/boot-args.lst
+++ b/configs/boot-args.lst
@@ -88,6 +88,7 @@ ddr_vote k
display_probe k
epoch k
fb_beat k
+fb_ca_hz k
fb_diff k
fb_filter k
fb_hz k
diff --git a/configs/symbols.tsv b/configs/symbols.tsv
index 85ec1aa..dba06d1 100644
--- a/configs/symbols.tsv
+++ b/configs/symbols.tsv
@@ -58,7 +58,7 @@ BT_AGAIN arg bt_again User space k hakios.bt.c the second look this many seconds
BUTTONS arg buttons Touch and buttons k hakios.buttons.c
BUTTONS_STEPS arg buttons_steps Touch and buttons k hakios.buttons.c
CA_VBL arg ca_vbl User space u inject.c CoreAnimation's frame clock from the display driver's refresh notifications
-CAENV arg caenv User space u inject.c
+CAENV arg caenv User space u inject.c,inject_sb.c CoreAnimation's switches here as in the window server (inject.c), set before QuartzCore reads them
CAM_AFTER arg cam_after Cameras k hakios.camera.c
CAM_FAKE arg cam_fake Cameras k hakios.camera.c
CAM_FAKE_FPS arg cam_fake_fps Cameras k hakios.camera.c
@@ -79,6 +79,7 @@ DDR_REST arg ddr_rest CPU, memory and boot k hakios.cpufreq.c
DDR_VOTE arg ddr_vote CPU, memory and boot k hakios.cpufreq.c
DISPLAY_PROBE arg display_probe GPU and display k hakios.adreno.c before any step: read what the firmware left the display controller doing (display_probe() below; two clocks are turned on, nothing else written)
FB_BEAT arg fb_beat GPU and display k MiniIOMobileFramebuffer.cpp
+FB_CA_HZ arg fb_ca_hz GPU and display k MiniIOMobileFramebuffer.cpp the refresh rate told to CoreAnimation (IOMFBDisplayRefresh) when it is not to be fb_hz's
FB_DIFF arg fb_diff GPU and display k MiniIOMobileFramebuffer.cpp which pixels of the panel each frame changed (it costs: the panel's memory is slow to read)
FB_FILTER arg fb_filter GPU and display k MiniIOMobileFramebuffer.cpp the picture is scaled to the panel nearest neighbour, as it once was
FB_HZ arg fb_hz GPU and display k MiniIOMobileFramebuffer.cpp
diff --git a/docs/boot-args.md b/docs/boot-args.md
index fe5e30f..ed7bfb4 100644
--- a/docs/boot-args.md
+++ b/docs/boot-args.md
@@ -2,13 +2,13 @@
Made by `tools/boot-args.py --markdown`; CI fails if it is out of date with the source (`tools/boot-args.py --check`).
-Every argument that the kernel, the loader or user space of this port reads, and which file reads it. **323 arguments**: 273 read by the kernel, 14 by the loader, 46 by user space (one is read in more than one place).
+Every argument that the kernel, the loader or user space of this port reads, and which file reads it. **324 arguments**: 274 read by the kernel, 14 by the loader, 46 by user space (one is read in more than one place).
This is a catalogue of what exists and who reads it, not a manual. What an argument means is in the head of the file that reads it. The stable switches have a symbol in the configuration (`tools/hakios-config.py help SYMBOL`, `docs/configs.md`); the rest are the knobs of bring-up (a driver's steps, pauses, traces, test modes) and can change with the driver. Any of them can be given in a configuration with `CONFIG_BOOTARGS="name=value ..."`, which checks that each name is in this list.
Layers: **K** the kernel, **L** the loader, **U** user space (through `sysctl kern.bootargs`).
-## GPU and display (69)
+## GPU and display (70)
| Argument | Layer | Read by | Configuration | Set by |
|---|---|---|---|---|
@@ -26,6 +26,7 @@ Layers: **K** the kernel, **L** the loader, **U** user space (through `sysctl ke
| `adreno_watch` | K | `hakios.adreno.c` | `CONFIG_ADRENO_WATCH` | |
| `display_probe` | K | `hakios.adreno.c` | `CONFIG_DISPLAY_PROBE` | |
| `fb_beat` | K | `MiniIOMobileFramebuffer.cpp` | `CONFIG_FB_BEAT` | |
+| `fb_ca_hz` | K | `MiniIOMobileFramebuffer.cpp` | `CONFIG_FB_CA_HZ` | |
| `fb_diff` | K | `MiniIOMobileFramebuffer.cpp` | `CONFIG_FB_DIFF` | |
| `fb_filter` | K | `MiniIOMobileFramebuffer.cpp` | `CONFIG_FB_FILTER` | |
| `fb_hz` | K | `MiniIOMobileFramebuffer.cpp` | `CONFIG_FB_HZ` | |
@@ -398,7 +399,7 @@ Layers: **K** the kernel, **L** the loader, **U** user space (through `sysctl ke
| `bt` | K | `hakios.bt.c` | `CONFIG_BT` | |
| `bt_again` | K | `hakios.bt.c` | `CONFIG_BT_AGAIN` | |
| `ca_vbl` | U | `inject.c` | `CONFIG_CA_VBL` | |
-| `caenv` | U | `inject.c` | `CONFIG_CAENV` | |
+| `caenv` | U | `inject.c`, `inject_sb.c` | `CONFIG_CAENV` | |
| `cc_fade` | U | `inject_sb.c` | `CONFIG_CC_FADE` | |
| `gl` | U | `inject.c`, `inject_sb.c` | `CONFIG_GL` | |
| `glcompile` | U | `inject.c` | `CONFIG_GLCOMPILE` | |
diff --git a/xnu/files/iokit/Kernel/MiniIOMobileFramebuffer.cpp b/xnu/files/iokit/Kernel/MiniIOMobileFramebuffer.cpp
index ebadbf4..fb288f2 100644
--- a/xnu/files/iokit/Kernel/MiniIOMobileFramebuffer.cpp
+++ b/xnu/files/iokit/Kernel/MiniIOMobileFramebuffer.cpp
@@ -152,6 +152,13 @@ static TUNABLE(uint32_t, gDiff, "fb_diff", 0);
*/
static TUNABLE(uint32_t, gFilter, "fb_filter", 1);
static TUNABLE(uint32_t, gRefreshHz, "fb_hz", kFBRefreshHz);
+/*
+ * Boot-arg fb_ca_hz=N: the refresh rate told to CoreAnimation (IOMFBDisplayRefresh) when it is not to be fb_hz's. On
+ * this system CoreAnimation draws at half the rate it is told unless something asks it for more: told 120 it gave 60
+ * (tools/frames.py: frames every 16.7 ms, with or without CADisableMinimumFrameDurationOnPhone, CA_FORCE_120HZ and
+ * CA_ENABLE_HIGH_FRAME_RATE_RESTRICTION=0, 30 October). The refreshes themselves still come at fb_hz.
+ */
+static TUNABLE(uint32_t, gCARefreshHz, "fb_ca_hz", 0);
static TUNABLE(uint32_t, gOnTheBeat, "fb_beat", 1);
/*
* Boot-arg fb_threads=N (1 to 8): so many processors scale a frame onto the panel together (see
@@ -386,20 +393,21 @@ void
IOMobileFramebuffer::publishRefresh(void)
{
OSDictionary * refresh = OSDictionary::withCapacity(4);
- uint64_t interval = (1ULL << 32) / refreshHz(), ticks;
+ uint32_t told = gCARefreshHz >= 1 && gCARefreshHz <= 480 ? gCARefreshHz : refreshHz();
+ uint64_t interval = (1ULL << 32) / told, ticks;
if (refresh == NULL) {
return;
}
- nanoseconds_to_absolutetime(NSEC_PER_SEC / refreshHz(), &ticks);
+ nanoseconds_to_absolutetime(NSEC_PER_SEC / told, &ticks);
setNumber(refresh, "displayMinRefreshInterval", interval);
setNumber(refresh, "displayMaxRefreshInterval", interval);
setNumber(refresh, "displayRefreshStep", interval);
setNumber(refresh, "displayRefreshStepMachTime", ticks);
setProperty("IOMFBDisplayRefresh", refresh);
refresh->release();
- IOLog("MiniIOMobileFramebuffer: IOMFBDisplayRefresh: %u Hz, an interval of %llu (2^-32 s), %llu ticks\n",
- refreshHz(), interval, ticks);
+ IOLog("MiniIOMobileFramebuffer: IOMFBDisplayRefresh: %u Hz (the panel: %u), an interval of %llu (2^-32 s), %llu ticks\n",
+ told, refreshHz(), interval, ticks);
}
void