🐛 Take a colour filter scale of 1.0 with the accessibility matrix

WindowServer follows the accessibility matrix it sets with
IOMobileFramebufferSetParameter(fb, 3, &scale, 1), the matrix's scale in 16.16,
and logs "IOMFB was not able to set accessibility matrix." where that call
answers other than 0. With the matrix itself answered, that left 2 such lines a
boot on each of 14.6.1, 15.6.1, 26.6.2 and 27.0.1 (Ambrosia's g148 boots).
IOMobileFramebufferLegacy runs parameter 3 with one value as its
set_color_filter_scale_gated, which answers kIOReturnUnsupported; Apple's
paravirtual display hands parameter 3 to the class as well.

The display now overrides set_parameter: a colour filter scale of 1.0 is
answered 0, as the screen with the matrix shown is what a scale of 1.0 shows,
and every other parameter and scale goes to the class, whose answer stays. The
scale is logged, so a boot shows the one WindowServer sends. What another scale
does is not stated anywhere, so it stays the class's.
This commit is contained in:
Anees Iqbal committed 2026-11-09 21:19:41 -08:00
1 parent 821875fa99
commit 041af67669
6 files changed
+110 -8

No files matched your search

+5
View File
@@ -195,6 +195,11 @@ public:
// RgfxMobileColor.hpp), which the class answers kIOReturnUnsupported.
RgfxIOMFBWord swap_set_color_matrix(IOMFBColorFixedMatrix *matrix,
IOMFBColorMatrixFunction function, uint32_t field_2) override;
// And the colour filter scale WindowServer sets after that matrix (ReimsGraphicsMobile.cpp,
// RgfxMobileColor.hpp), which the class answers kIOReturnUnsupported: its other parameters
// go to the class.
RgfxIOMFBWord set_parameter(IOMFBParameterName name, const uint64_t *values,
uint32_t count) override;
#endif
// The display pipe (RgfxDisplayPipeUserClient, on the accelerator) presents through the
+27
View File
@@ -95,6 +95,13 @@ extern "C" void rgfxLegacyDropDummySwaps(IOMobileFramebufferLegacy *self)
extern "C" void rgfxLegacySwapInfoNotifyDispatch(IOMobileFramebufferLegacy *self,
RgfxSwapInfoRecord *record)
__asm__("__ZN25IOMobileFramebufferLegacy31swap_info_notify_dispatch_gatedEPNS_12SwapInfoBlobE");
// The class's own set_parameter, which the display's override hands each parameter it does not
// take (set_parameter): called directly, under the name every release from 14 to 27.0.1 exports,
// as the paravirtual display's override hands the class those it does not take.
extern "C" RgfxIOMFBWord rgfxLegacySetParameter(IOMobileFramebufferLegacy *self,
IOMFBParameterName name, const uint64_t *values,
uint32_t count)
__asm__("__ZN25IOMobileFramebufferLegacy13set_parameterE18IOMFBParameterNamePKyj");
// IOMobileFramebufferUserClient's enqueue of `bytes` bytes at `words` in its shared data queue,
// which IOMobileFramebuffer.framework reads a frame info record from (RgfxLegacySwapInfo.hpp):
@@ -147,6 +154,7 @@ enum MobileCall : unsigned {
kGetDotPitch,
kSetDigitalOutMode,
kSwapSetColorMatrix,
kSetParameter,
kVblank,
kPresented,
kSwapShown,
@@ -987,6 +995,25 @@ RgfxIOMFBWord ReimsGraphics::swap_set_color_matrix(IOMFBColorFixedMatrix *matrix
return word(kIOReturnSuccess);
}
// The colour filter scale WindowServer sets after its accessibility matrix, by
// IOMobileFramebufferSetParameter (RgfxMobileColor.hpp): a scale of 1.0 is answered 0, the matrix
// shown as swap_set_color_matrix shows it. Every other parameter, and another scale, goes to the
// class, which answers as it does for the paravirtual display. The user client calls it ungated,
// in WindowServer's thread, as it calls swap_set_color_matrix.
RgfxIOMFBWord ReimsGraphics::set_parameter(IOMFBParameterName name, const uint64_t *values,
uint32_t count)
{
const uint32_t parameter = static_cast<uint32_t>(name);
const bool one = rgfxColorFilterScaleIsOne(parameter, values, count);
const RgfxIOMFBWord answer = one ? word(kIOReturnSuccess)
: rgfxLegacySetParameter(this, name, values, count);
if (parameter == kRgfxColorFilterScaleParameter && logged(kSetParameter))
IOLog("ReimsGraphics: set_parameter(%u, %u values, first 0x%llx) = 0x%x%s\n", parameter,
count, (values && count) ? static_cast<unsigned long long>(values[0]) : 0ull,
static_cast<uint32_t>(answer), one ? "" : ", the class's answer");
return answer;
}
IOReturn ReimsGraphics::setMobileMode(uint32_t colorId, uint32_t timingId, Mode *shown)
{
IOLockLock(stateLock);
+20
View File
@@ -43,6 +43,26 @@ constexpr uint32_t kRgfxMobileMatrixWords = 15;
// The function QuartzCore sets its accessibility matrix with (read).
constexpr uint32_t kRgfxMobileAccessibilityMatrix = 2;
// The colour filter scale. WindowServer follows its accessibility matrix with
// IOMobileFramebufferSetParameter(fb, 3, &scale, 1): parameter 3 with one value, the matrix's
// scale in 16.16 fixed point, and logs "IOMFB was not able to set accessibility matrix." where
// that call answers other than 0, the matrix kept as set (27.0.1). The user client calls the
// display's set_parameter with them, outside the display's gate; IOMobileFramebufferLegacy's runs
// parameter 3 with one value as its set_color_filter_scale_gated, which answers
// kIOReturnUnsupported on each of 14.6.1, 15.6.1, 26.6.2 and 27.0.1 where its subclass does not
// take it. The display takes a scale of 1.0 alone: with the matrix shown, it shows what a scale of
// 1.0 shows. What another scale does is not stated, so the display leaves it to the class.
constexpr uint32_t kRgfxColorFilterScaleParameter = 3;
constexpr uint64_t kRgfxColorFilterScaleOne = 0x10000;
// Whether set_parameter's `name`, `values` and `count` are the colour filter scale of 1.0, which
// the display answers 0 to, changing nothing.
inline bool rgfxColorFilterScaleIsOne(uint32_t name, const uint64_t *values, uint32_t count)
{
return name == kRgfxColorFilterScaleParameter && count == 1 && values != nullptr &&
values[0] == kRgfxColorFilterScaleOne;
}
// The bits of `v` rounded to nearest, ties to even, at `drop` low bits (drop < 64): the kept bits.
inline uint64_t rgfxRoundNearestEven(uint64_t v, uint32_t drop)
{
+2 -1
View File
@@ -82,7 +82,8 @@
"surface_layer_unmap": {},
"get_dot_pitch": { "required": true },
"set_digital_out_mode": { "required": true },
"swap_set_color_matrix": { "required": true }
"swap_set_color_matrix": { "required": true },
"set_parameter": { "required": true }
}
}
],
+13 -6
View File
@@ -1,8 +1,9 @@
// The native test of what ReimsGraphics overrides of IOMobileFramebufferLegacy's own methods
// (ReimsGraphicsMobile.cpp): get_dot_pitch, because the class's start leaves its state unset for a
// PCI device; set_digital_out_mode, which the class answers kIOReturnUnsupported and the
// paravirtual display overrides to set its modes; and swap_set_color_matrix, which the class
// answers kIOReturnUnsupported and the display answers 0 to show the matrix
// paravirtual display overrides to set its modes; swap_set_color_matrix, which the class answers
// kIOReturnUnsupported and the display answers 0 to show the matrix; and set_parameter, whose
// colour filter scale of 1.0 the display answers 0 and hands the rest to the class
// (RgfxMobileColor.hpp, tests/mobile_color_test.cpp). start keeps its provider as an
// AppleARMIODevice in one field, NULL where the provider is not one, and the class's get_dot_pitch
// calls through that field unchecked.
@@ -60,6 +61,12 @@ constexpr Method kMethods[] = {
"override;",
"__ZN25IOMobileFramebufferLegacy21swap_set_color_matrixEP21IOMFBColorFixedMatrix"
"24IOMFBColorMatrixFunctionj"},
{"set_parameter",
"virtual graft_iomfb_word set_parameter(IOMFBParameterName name, const uint64_t *values,\n"
" uint32_t count);",
"RgfxIOMFBWord set_parameter(IOMFBParameterName name, const uint64_t *values,\n"
"\t uint32_t count) override;",
"__ZN25IOMobileFramebufferLegacy13set_parameterE18IOMFBParameterNamePKyj"},
};
constexpr size_t kMethodCount = sizeof(kMethods) / sizeof(kMethods[0]);
@@ -73,10 +80,10 @@ struct Release {
};
constexpr Release kReleases[] = {
{"14.6.1", 0x18a0, 0x1640, {292, 289, 331}},
{"15.6.1", 0x19c0, 0x1758, {292, 289, 334}},
{"26.6.2", 0x1af8, 0x1890, {293, 290, 335}},
{"27.0.1", 0x1dd8, 0x1b80, {294, 291, 343}},
{"14.6.1", 0x18a0, 0x1640, {292, 289, 331, 332}},
{"15.6.1", 0x19c0, 0x1758, {292, 289, 334, 335}},
{"26.6.2", 0x1af8, 0x1890, {293, 290, 335, 336}},
{"27.0.1", 0x1dd8, 0x1b80, {294, 291, 343, 344}},
};
// The SDK stand-in's virtual slots past its own: GRAFT_IOMFB_VTABLE_RESERVE.
+43 -1
View File
@@ -2,7 +2,8 @@
// the colour matrix WindowServer sets with a swap (ReimsGraphicsMobile.cpp's
// swap_set_color_matrix), against the same conversion done in floating point here: each word
// converted to a double, times 2^-32, rounded to a float. Also the override's source: it converts
// the matrix, posts it as the matrix stage, and answers 0.
// the matrix, posts it as the matrix stage, and answers 0. And the colour filter scale the display
// takes (set_parameter): 1.0 alone, answered 0, the rest the class's.
#include "RgfxMobileColor.hpp"
#include <cstdio>
@@ -170,6 +171,45 @@ void source()
"the post's result is not the answer", "source");
}
// The colour filter scale: parameter 3 with the one value 1.0 in 16.16 is the display's, anything
// else is not.
void filterScale()
{
const uint64_t one = 0x10000, two[2] = {0x10000, 0x10000};
check(rgfxColorFilterScaleIsOne(3, &one, 1), "a scale of 1.0 is the display's", "scale");
for (uint64_t v : {uint64_t(0), uint64_t(0x8000), uint64_t(0xffff), uint64_t(0x10001),
uint64_t(0x20000), ~uint64_t(0)})
check(!rgfxColorFilterScaleIsOne(3, &v, 1), "another scale goes to the class", "scale");
check(!rgfxColorFilterScaleIsOne(3, two, 2), "two values go to the class", "scale");
check(!rgfxColorFilterScaleIsOne(3, &one, 0), "no value goes to the class", "scale");
check(!rgfxColorFilterScaleIsOne(3, nullptr, 1), "no values go to the class", "scale");
for (uint32_t name : {0u, 1u, 2u, 4u, 0x11u, 0xffffffffu})
check(!rgfxColorFilterScaleIsOne(name, &one, 1), "another parameter goes to the class",
"scale");
}
// The override answers 0 for the scale of 1.0 and the class's answer for the rest, posting
// nothing.
void filterScaleSource()
{
const std::string src = readFile("src/ReimsGraphicsMobile.cpp");
const size_t at = src.find("RgfxIOMFBWord ReimsGraphics::set_parameter(");
check(at != std::string::npos, "the override is defined", "scale source");
const size_t end = src.find("\n}\n", at);
check(end != std::string::npos, "the override ends", "scale source");
const std::string body = src.substr(at, end - at);
check(body.find("rgfxColorFilterScaleIsOne(parameter, values, count)") != std::string::npos,
"it decides by the scale", "scale source");
check(body.find("one ? word(kIOReturnSuccess)") != std::string::npos, "1.0 is answered 0",
"scale source");
check(body.find(": rgfxLegacySetParameter(this, name, values, count)") != std::string::npos,
"the rest is the class's", "scale source");
check(body.find("postDisplayColor") == std::string::npos, "it posts nothing", "scale source");
check(src.find("__asm__(\"__ZN25IOMobileFramebufferLegacy13set_parameterE18IOMFBParameterName"
"PKyj\")") != std::string::npos,
"the class's is its own set_parameter", "scale source");
}
} // namespace
int main()
@@ -181,6 +221,8 @@ int main()
conversion();
rows();
source();
filterScale();
filterScaleSource();
std::printf("mobile_color_test: %d checks passed\n", checks);
return 0;
}