From 5d00c9d686f9f7465aaaa9964d0ae1ac1023e24c Mon Sep 17 00:00:00 2001 From: Diljit Singh Date: Sat, 7 Nov 2026 13:26:11 -0500 Subject: [PATCH 1/2] drm/apple: m4: select the preferred timing among several The M4 backend adopts the internal panel only when the DCP's PreferredTimingElements holds exactly one element, ID 2, matching the profile. That fits the J713 and J715. macOS 26B123 reports six timing elements for the J604's ProMotion panel, the preferred 120 Hz one (ID 2) and five 48 to 60 Hz ones, and such a report would be refused. Give each profile the most elements its panel reports, one for the J713 and J715, and select the element with ID 2 among them. It is matched exactly as before. Every element must be a dictionary with an integer ID, ID 2 must appear once and no other element may be preferred. With one element allowed, the J713 and J715 accept and refuse the same reports as before. Add a host test that runs the parser on encoded reports: J713 and J715 single-element reports with each timing value changed in turn, and the J604's six-element report from macOS as a fixture. Signed-off-by: Diljit Singh --- drivers/gpu/drm/apple/dcp-m4-profile.h | 9 +- drivers/gpu/drm/apple/dcp-m4-timing.h | 43 +- .../selftests/drivers/gpu/apple-dcp/README | 9 + .../m4-fixtures/timing-elements.json | 396 ++++++++++++++++++ .../selftests/drivers/gpu/apple-dcp/m4.py | 185 ++++++++ .../selftests/drivers/gpu/apple-dcp/run.py | 1 + 6 files changed, 625 insertions(+), 18 deletions(-) create mode 100644 tools/testing/selftests/drivers/gpu/apple-dcp/m4-fixtures/timing-elements.json diff --git a/drivers/gpu/drm/apple/dcp-m4-profile.h b/drivers/gpu/drm/apple/dcp-m4-profile.h index 2ea10cca57577..7ccb08f046a5b 100644 --- a/drivers/gpu/drm/apple/dcp-m4-profile.h +++ b/drivers/gpu/drm/apple/dcp-m4-profile.h @@ -24,12 +24,13 @@ struct dcp_m4_profile { u32 brightness_max, brightness_default; u32 width_mm, height_mm; /* - * The qualified preferred timing, horizontal then vertical: Active, - * Total, FrontPorch, SyncWidth, BackPorch, PreciseSyncRate, + * The qualified preferred timing (ID 2), horizontal then vertical: + * Active, Total, FrontPorch, SyncWidth, BackPorch, PreciseSyncRate, * SyncPolarity, PixelRepetition. NULL: none, so the panel is not * adopted. */ const u32 (*timing)[8]; + u32 timing_elements; /* most timing elements reported */ }; static const u32 dcp_m4_timing_j713[2][8] = { @@ -47,7 +48,7 @@ static const struct dcp_m4_profile dcp_m4_profile_j713 = { .done_method = 590, .done_size = 0x730, .open_method = 457, .brightness_max = 500, .brightness_default = 120, .width_mm = 0, .height_mm = 0, - .timing = dcp_m4_timing_j713, + .timing = dcp_m4_timing_j713, .timing_elements = 1, }; /* The J715's panel timing, as macOS reports it (TimingElements, ID 2). */ @@ -67,7 +68,7 @@ static const struct dcp_m4_profile dcp_m4_profile_j715 = { .done_method = 590, .done_size = 0x730, .open_method = 457, .brightness_max = 500, .brightness_default = 120, .width_mm = 0, .height_mm = 0, - .timing = dcp_m4_timing_j715, + .timing = dcp_m4_timing_j715, .timing_elements = 1, }; static const struct dcp_m4_profile *const dcp_m4_profiles[] = { diff --git a/drivers/gpu/drm/apple/dcp-m4-timing.h b/drivers/gpu/drm/apple/dcp-m4-timing.h index b8eabc880c7be..13af59e83c770 100644 --- a/drivers/gpu/drm/apple/dcp-m4-timing.h +++ b/drivers/gpu/drm/apple/dcp-m4-timing.h @@ -170,6 +170,7 @@ static inline int dcp_m4_parse_timing(const void *data, size_t size, struct dcp_ }; static const u32 color_values[] = { 1, 8, 0, 0, 0, 16, 0 }; int ret = -EINVAL, colors, color; + unsigned int mode = 0, element = 1; const u32 *h, *v; if (!dcp_m4_pf->timing) @@ -186,21 +187,35 @@ static inline int dcp_m4_parse_timing(const void *data, size_t size, struct dcp_ if (ret) goto done; ret = -EINVAL; - if (p->pos != size || p->token[0].type != 2 || p->token[0].count != 1 || - p->token[1].type != 1 || - !dcp_m4_timing_equals(p, 1, "ID", 4, 2) || - !dcp_m4_timing_equals(p, 1, "IsVirtual", 11, 0) || - !dcp_m4_timing_equals(p, 1, "IsPreferred", 11, 1) || - !dcp_m4_timing_equals(p, 1, "IsInterlaced", 11, 0) || - !dcp_m4_timing_equals(p, 1, "IsSplit", 11, 0) || - !dcp_m4_timing_equals(p, 1, "IsOverscanned", 11, 0) || - !dcp_m4_timing_equals(p, 1, "TimingType", 4, 3) || - !dcp_m4_timing_equals(p, 1, "MinimumVariableRefreshRate", 4, 0) || - !dcp_m4_timing_equals(p, 1, "MaximumVariableRefreshRate", 4, 0) || - dcp_m4_timing_axis(p, 1, "HorizontalAttributes", false) || - dcp_m4_timing_axis(p, 1, "VerticalAttributes", true)) + if (p->pos != size || p->token[0].type != 2 || !p->token[0].count || + p->token[0].count > dcp_m4_pf->timing_elements) goto done; - colors = dcp_m4_timing_field(p, 1, "ColorModes", 2); + /* Exactly one element is ID 2, and no other is preferred. */ + for (unsigned int i = 0; i < p->token[0].count; + i++, element = p->token[element].next) { + if (dcp_m4_timing_field(p, element, "ID", 4) < 0) + goto done; + if (dcp_m4_timing_equals(p, element, "ID", 4, 2)) { + if (mode) + goto done; + mode = element; + } else if (!dcp_m4_timing_equals(p, element, "IsPreferred", 11, 0)) { + goto done; + } + } + if (!mode || + !dcp_m4_timing_equals(p, mode, "IsVirtual", 11, 0) || + !dcp_m4_timing_equals(p, mode, "IsPreferred", 11, 1) || + !dcp_m4_timing_equals(p, mode, "IsInterlaced", 11, 0) || + !dcp_m4_timing_equals(p, mode, "IsSplit", 11, 0) || + !dcp_m4_timing_equals(p, mode, "IsOverscanned", 11, 0) || + !dcp_m4_timing_equals(p, mode, "TimingType", 4, 3) || + !dcp_m4_timing_equals(p, mode, "MinimumVariableRefreshRate", 4, 0) || + !dcp_m4_timing_equals(p, mode, "MaximumVariableRefreshRate", 4, 0) || + dcp_m4_timing_axis(p, mode, "HorizontalAttributes", false) || + dcp_m4_timing_axis(p, mode, "VerticalAttributes", true)) + goto done; + colors = dcp_m4_timing_field(p, mode, "ColorModes", 2); if (colors < 0 || p->token[colors].count != 1) goto done; color = colors + 1; diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/README b/tools/testing/selftests/drivers/gpu/apple-dcp/README index 4934b7eb7eef2..633702781763c 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/README +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/README @@ -150,6 +150,15 @@ the real common backlight state/wrappers run with a bounded mock transport, covering DPMS-off before delayed work and retaining active plus uncertain framebuffers when one of the two required receipts never arrives. +The m4-panel-timing case runs the actual internal-panel timing parser on +encoded TimingElements reports. The J713 and J715 reports have one element. +The J604 fixture is the six-element report from macOS 26B123: a preferred +120 Hz element and five 48-60 Hz ones. Only the preferred ID 2 element is +adopted, and only with the profile's exact values. The parser refuses a +changed value, a missing or duplicated ID 2, a second preferred element and +more elements than the profile allows. This does not show what the firmware +reports on hardware. + run-native-m4-kms.py defaults to dry run; --compile-only needs libdrm development headers and never opens DRM. Explicit --execute requires root, an exact fresh source/Image/boot identity, the common appledrm module, a stopped display diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/m4-fixtures/timing-elements.json b/tools/testing/selftests/drivers/gpu/apple-dcp/m4-fixtures/timing-elements.json new file mode 100644 index 0000000000000..0e4e0bd94084c --- /dev/null +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/m4-fixtures/timing-elements.json @@ -0,0 +1,396 @@ +{ + "schema": 1, + "scope": "J604 (MacBook Pro 14-inch, M4) internal panel TimingElements as macOS 26B123 reports them (ioreg disp0). Types: integer, boolean, string, {\"data\": hex}, array, dictionary; key order kept.", + "j604": [ + { + "StandardType": 0, + "DiscreteMediaRefreshRates": [], + "ElementType": 0, + "IsSplit": false, + "IsPromoted": false, + "IsInterlaced": false, + "HorizontalAttributes": { + "Total": 3104, + "Active": 3024, + "PixelRepetition": 0, + "PreciseSyncRate": 16986999, + "BackPorch": 40, + "SyncWidth": 32, + "FrontPorch": 8, + "SyncPolarity": 1, + "SyncRate": 16973824 + }, + "VerticalAttributes": { + "Total": 2160, + "Active": 1964, + "PixelRepetition": 0, + "PreciseSyncRate": 7864351, + "BackPorch": 86, + "SyncWidth": 8, + "FrontPorch": 102, + "SyncPolarity": 1, + "SyncRate": 7864320 + }, + "UnsafeColorElementIDs": [], + "Score": 16813, + "MinimumVariableRefreshRate": 0, + "ColorModes": [ + { + "ElementData": { + "data": "0800000000000000000000001000000000000000000000000000000000000000" + }, + "StandardType": 0, + "Score": 240999, + "IsVirtual": false, + "ID": 1, + "PixelEncoding": 0, + "ElementType": 1, + "SupportsDSC": 0, + "EOTF": 0, + "Colorimetry": 16, + "DynamicRange": 0, + "Depth": 8 + } + ], + "IsOverscanned": false, + "IsVirtual": false, + "ElementData": { + "data": "00000000200c0000d00b000020000000280000000800000077330301010000000000000070080000ac0700000800000056000000660000001f0078000100000000000000809cf42f0c00000000000000" + }, + "IsPreferred": true, + "ScanInformation": 0, + "TimingType": 3, + "DSCRequiredColorElementIDs": [], + "ID": 2, + "AspectRatio": 12, + "MaximumVariableRefreshRate": 0, + "ValidPixelEncodings": 1, + "PreciseAspectRatio": 100906 + }, + { + "StandardType": 0, + "DiscreteMediaRefreshRates": [], + "ElementType": 0, + "IsSplit": false, + "IsPromoted": true, + "IsInterlaced": false, + "HorizontalAttributes": { + "Total": 3104, + "Active": 3024, + "PixelRepetition": 0, + "PreciseSyncRate": 16986999, + "BackPorch": 40, + "SyncWidth": 32, + "FrontPorch": 8, + "SyncPolarity": 1, + "SyncRate": 16973824 + }, + "VerticalAttributes": { + "Total": 2160, + "Active": 1964, + "PixelRepetition": 0, + "PreciseSyncRate": 3932160, + "BackPorch": 86, + "SyncWidth": 8, + "FrontPorch": 102, + "SyncPolarity": 1, + "SyncRate": 3932160 + }, + "UnsafeColorElementIDs": [], + "Score": 15416, + "MinimumVariableRefreshRate": 0, + "ColorModes": [ + { + "ElementData": { + "data": "0800000000000000000000001000000000000000000000000000000000000000" + }, + "StandardType": 0, + "Score": 240999, + "IsVirtual": false, + "ID": 1, + "PixelEncoding": 0, + "ElementType": 1, + "SupportsDSC": 0, + "EOTF": 0, + "Colorimetry": 16, + "DynamicRange": 0, + "Depth": 8 + } + ], + "IsOverscanned": false, + "IsVirtual": false, + "ElementData": { + "data": "00000000200c0000d00b000020000000280000000800000077330301010000000000000070080000ac07000008000000560000006600000000003c000100000000000000809cf42f0c00000000000000" + }, + "IsPreferred": false, + "ScanInformation": 0, + "TimingType": 3, + "DSCRequiredColorElementIDs": [], + "ID": 3, + "AspectRatio": 12, + "MaximumVariableRefreshRate": 0, + "ValidPixelEncodings": 1, + "PreciseAspectRatio": 100906 + }, + { + "StandardType": 0, + "DiscreteMediaRefreshRates": [], + "ElementType": 0, + "IsSplit": false, + "IsPromoted": true, + "IsInterlaced": false, + "HorizontalAttributes": { + "Total": 3104, + "Active": 3024, + "PixelRepetition": 0, + "PreciseSyncRate": 16986999, + "BackPorch": 40, + "SyncWidth": 32, + "FrontPorch": 8, + "SyncPolarity": 1, + "SyncRate": 16973824 + }, + "VerticalAttributes": { + "Total": 2160, + "Active": 1964, + "PixelRepetition": 0, + "PreciseSyncRate": 3145728, + "BackPorch": 86, + "SyncWidth": 8, + "FrontPorch": 102, + "SyncPolarity": 1, + "SyncRate": 3145728 + }, + "UnsafeColorElementIDs": [], + "Score": 15333, + "MinimumVariableRefreshRate": 0, + "ColorModes": [ + { + "ElementData": { + "data": "0800000000000000000000001000000000000000000000000000000000000000" + }, + "StandardType": 0, + "Score": 240999, + "IsVirtual": false, + "ID": 1, + "PixelEncoding": 0, + "ElementType": 1, + "SupportsDSC": 0, + "EOTF": 0, + "Colorimetry": 16, + "DynamicRange": 0, + "Depth": 8 + } + ], + "IsOverscanned": false, + "IsVirtual": false, + "ElementData": { + "data": "00000000200c0000d00b000020000000280000000800000077330301010000000000000070080000ac070000080000005600000066000000000030000100000000000000809cf42f0c00000000000000" + }, + "IsPreferred": false, + "ScanInformation": 0, + "TimingType": 3, + "DSCRequiredColorElementIDs": [], + "ID": 4, + "AspectRatio": 12, + "MaximumVariableRefreshRate": 0, + "ValidPixelEncodings": 1, + "PreciseAspectRatio": 100906 + }, + { + "StandardType": 0, + "DiscreteMediaRefreshRates": [], + "ElementType": 0, + "IsSplit": false, + "IsPromoted": true, + "IsInterlaced": false, + "HorizontalAttributes": { + "Total": 3104, + "Active": 3024, + "PixelRepetition": 0, + "PreciseSyncRate": 16969960, + "BackPorch": 40, + "SyncWidth": 32, + "FrontPorch": 8, + "SyncPolarity": 1, + "SyncRate": 16973824 + }, + "VerticalAttributes": { + "Total": 2160, + "Active": 1964, + "PixelRepetition": 0, + "PreciseSyncRate": 3928232, + "BackPorch": 86, + "SyncWidth": 8, + "FrontPorch": 102, + "SyncPolarity": 1, + "SyncRate": 3932160 + }, + "UnsafeColorElementIDs": [], + "Score": 15416, + "MinimumVariableRefreshRate": 0, + "ColorModes": [ + { + "ElementData": { + "data": "0800000000000000000000001000000000000000000000000000000000000000" + }, + "StandardType": 0, + "Score": 240999, + "IsVirtual": false, + "ID": 1, + "PixelEncoding": 0, + "ElementType": 1, + "SupportsDSC": 0, + "EOTF": 0, + "Colorimetry": 16, + "DynamicRange": 0, + "Depth": 8 + } + ], + "IsOverscanned": false, + "IsVirtual": false, + "ElementData": { + "data": "00000000200c0000d00b0000200000002800000008000000e8f00201010000000000000070080000ac070000080000005600000066000000a8f03b000100000000000000284ce82f0c00000000000000" + }, + "IsPreferred": false, + "ScanInformation": 0, + "TimingType": 3, + "DSCRequiredColorElementIDs": [], + "ID": 5, + "AspectRatio": 12, + "MaximumVariableRefreshRate": 0, + "ValidPixelEncodings": 1, + "PreciseAspectRatio": 100906 + }, + { + "StandardType": 0, + "DiscreteMediaRefreshRates": [], + "ElementType": 0, + "IsSplit": false, + "IsPromoted": true, + "IsInterlaced": false, + "HorizontalAttributes": { + "Total": 3104, + "Active": 3024, + "PixelRepetition": 0, + "PreciseSyncRate": 16969960, + "BackPorch": 40, + "SyncWidth": 32, + "FrontPorch": 8, + "SyncPolarity": 1, + "SyncRate": 16973824 + }, + "VerticalAttributes": { + "Total": 2160, + "Active": 1964, + "PixelRepetition": 0, + "PreciseSyncRate": 3142585, + "BackPorch": 86, + "SyncWidth": 8, + "FrontPorch": 102, + "SyncPolarity": 1, + "SyncRate": 3145728 + }, + "UnsafeColorElementIDs": [], + "Score": 15333, + "MinimumVariableRefreshRate": 0, + "ColorModes": [ + { + "ElementData": { + "data": "0800000000000000000000001000000000000000000000000000000000000000" + }, + "StandardType": 0, + "Score": 240999, + "IsVirtual": false, + "ID": 1, + "PixelEncoding": 0, + "ElementType": 1, + "SupportsDSC": 0, + "EOTF": 0, + "Colorimetry": 16, + "DynamicRange": 0, + "Depth": 8 + } + ], + "IsOverscanned": false, + "IsVirtual": false, + "ElementData": { + "data": "00000000200c0000d00b0000200000002800000008000000e8f00201010000000000000070080000ac070000080000005600000066000000b9f32f000100000000000000284ce82f0c00000000000000" + }, + "IsPreferred": false, + "ScanInformation": 0, + "TimingType": 3, + "DSCRequiredColorElementIDs": [], + "ID": 6, + "AspectRatio": 12, + "MaximumVariableRefreshRate": 0, + "ValidPixelEncodings": 1, + "PreciseAspectRatio": 100906 + }, + { + "StandardType": 0, + "DiscreteMediaRefreshRates": [], + "ElementType": 0, + "IsSplit": false, + "IsPromoted": true, + "IsInterlaced": false, + "HorizontalAttributes": { + "Total": 3104, + "Active": 3024, + "PixelRepetition": 0, + "PreciseSyncRate": 16986931, + "BackPorch": 40, + "SyncWidth": 32, + "FrontPorch": 8, + "SyncPolarity": 1, + "SyncRate": 16973824 + }, + "VerticalAttributes": { + "Total": 2592, + "Active": 1964, + "PixelRepetition": 0, + "PreciseSyncRate": 3276800, + "BackPorch": 86, + "SyncWidth": 8, + "FrontPorch": 534, + "SyncPolarity": 1, + "SyncRate": 3276800 + }, + "UnsafeColorElementIDs": [], + "Score": 15347, + "MinimumVariableRefreshRate": 0, + "ColorModes": [ + { + "ElementData": { + "data": "0800000000000000000000001000000000000000000000000000000000000000" + }, + "StandardType": 0, + "Score": 240999, + "IsVirtual": false, + "ID": 1, + "PixelEncoding": 0, + "ElementType": 1, + "SupportsDSC": 0, + "EOTF": 0, + "Colorimetry": 16, + "DynamicRange": 0, + "Depth": 8 + } + ], + "IsOverscanned": false, + "IsVirtual": false, + "ElementData": { + "data": "00000000200c0000d00b0000200000002800000008000000333303010100000000000000200a0000ac0700000800000056000000160200000000320001000000000000000090f42f0c00000000000000" + }, + "IsPreferred": false, + "ScanInformation": 0, + "TimingType": 3, + "DSCRequiredColorElementIDs": [], + "ID": 7, + "AspectRatio": 12, + "MaximumVariableRefreshRate": 0, + "ValidPixelEncodings": 1, + "PreciseAspectRatio": 100906 + } + ] +} diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/m4.py b/tools/testing/selftests/drivers/gpu/apple-dcp/m4.py index 79f4c23ebc677..ccb0bef82485a 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/m4.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/m4.py @@ -5,8 +5,10 @@ not the implementation under test. Transport, MMIO and DRM core are not emulated. """ import base64 +import copy import hashlib import json +import struct import subprocess import zlib from pathlib import Path @@ -645,3 +647,186 @@ def blank(root): return 0; } ''' + + +# macOS's preferred internal-panel timings (ID 2), horizontal then vertical, in +# the profile's field order. The J604's also come from its fixture report. +TIMING_FIELDS = ('Active', 'Total', 'FrontPorch', 'SyncWidth', 'BackPorch', + 'PreciseSyncRate', 'SyncPolarity', 'PixelRepetition') +PANEL_TIMINGS = { + 'j713': ((2560, 2640, 8, 32, 40, 6877358, 1, 0), (1664, 1749, 33, 8, 44, 3932166, 1, 0)), + 'j715': ((2880, 2960, 8, 32, 40, 7710975, 1, 0), (1864, 1961, 47, 8, 42, 3932165, 1, 0)), + 'j604': ((3024, 3104, 8, 32, 40, 16986999, 1, 0), (1964, 2160, 102, 8, 86, 7864351, 1, 0)), +} +# hdisplay, hsync_start, hsync_end, htotal, vdisplay, vsync_start, vsync_end, +# vtotal, clock_khz, refresh_16_16 +PANEL_MODES = { + 'j713': (2560, 2568, 2600, 2640, 1664, 1697, 1705, 1749, 277042, 3932166), + 'j715': (2880, 2888, 2920, 2960, 1864, 1911, 1919, 1961, 348274, 3932165), +} + +TIMING_SHIMS = r''' +#include +#define GFP_KERNEL 0 +static void *kzalloc(size_t size, int flags) { (void)flags; return calloc(1, size); } +static void kfree(void *p) { free(p); } +static inline u64 get_unaligned_le64(const void *p) { + const u8 *b = p; u64 v = 0; + for (unsigned i = 0; i < 8; i++) v |= (u64)b[i] << (8 * i); + return v; +} +''' + +TIMING_MAIN = r''' +struct timing_case { + const char *name; + const struct dcp_m4_profile *profile; + const u8 *data; + size_t size; + int expect; + u32 mode[10]; +}; +static const struct timing_case cases[] = { +%s +}; +int main(void) +{ + for (size_t i = 0; i < sizeof(cases) / sizeof(cases[0]); i++) { + const struct timing_case *c = &cases[i]; + struct dcp_m4_timing t; + int ret; + memset(&t, 0xa5, sizeof(t)); + dcp_m4_pf = c->profile; + ret = dcp_m4_parse_timing(c->data, c->size, &t); + if (ret != c->expect) { + printf("FAIL %%s: %%d, expected %%d\n", c->name, ret, c->expect); + return 1; + } + if (!ret) { + const u32 got[10] = {t.hdisplay, t.hsync_start, t.hsync_end, t.htotal, + t.vdisplay, t.vsync_start, t.vsync_end, t.vtotal, t.clock_khz, t.refresh_16_16}; + if (t.id != 2 || t.color_id != 1 || memcmp(got, c->mode, sizeof(got))) { + printf("FAIL %%s: wrong mode\n", c->name); + return 1; + } + } + printf("PASS %%s: %%s\n", c->name, ret ? "refused" : "adopted"); + } + return 0; +} +''' + + +def serialize(elements): + """The DCP's binary dictionary encoding of a TimingElements array.""" + out = bytearray(struct.pack(' Date: Sat, 7 Nov 2026 13:26:38 -0500 Subject: [PATCH 2/2] drm/apple: m4: add a J604 panel profile The J604 (MacBook Pro 14-inch, M4) has a 3024x1964 ProMotion XDR panel. macOS 26B123 reports six timing elements for it. Each has the Airs' single 8-bit color mode, 3024 active pixels on a 3104 total, horizontal porches 8 and 40, sync widths 32 and 8 and positive syncs: ID rate vtotal vertical front/back porch 2 120 Hz 2160 102/86 (preferred) 3 60 Hz 2160 102/86 4 48 Hz 2160 102/86 5 59.94 Hz 2160 102/86 6 47.95 Hz 2160 102/86 7 50 Hz 2592 534/86 Add a profile with the preferred 120 Hz timing that allows six elements. Only that mode is adopted; switching to the lower ProMotion rates is not supported. The J604 runs the Airs' 26.6.2 DCP firmware, so the profile assumes the same swap and callback offsets. The boot framebuffer stride is assumed unpadded, 3024 * 4 bytes, as on the Airs. brightness_max is the panel's rated SDR maximum, 1000 nits, as 500 is the Airs'. The default stays at the Airs' 120 nits, since these values are absolute nits. The M4 backend does not read either field yet: it sets every panel up for 500 and 120 nits. The internal DCP still does not probe on a J604: the PMP display power bridge, the display DARTs and the display gate are limited to the J713 and J715. Signed-off-by: Diljit Singh --- drivers/gpu/drm/apple/dcp-m4-profile.h | 24 +++++++++++++++++ .../selftests/drivers/gpu/apple-dcp/m4.py | 26 +++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/drivers/gpu/drm/apple/dcp-m4-profile.h b/drivers/gpu/drm/apple/dcp-m4-profile.h index 7ccb08f046a5b..82485a3048b2e 100644 --- a/drivers/gpu/drm/apple/dcp-m4-profile.h +++ b/drivers/gpu/drm/apple/dcp-m4-profile.h @@ -71,9 +71,33 @@ static const struct dcp_m4_profile dcp_m4_profile_j715 = { .timing = dcp_m4_timing_j715, .timing_elements = 1, }; +/* The J604's preferred 120 Hz timing (macOS TimingElements, ID 2). */ +static const u32 dcp_m4_timing_j604[2][8] = { + { 3024, 3104, 8, 32, 40, 16986999, 1, 0 }, + { 1964, 2160, 102, 8, 86, 7864351, 1, 0 }, +}; + +/* + * The J604: assumed to be the same firmware ABI, with a 3024x1964 XDR panel + * rated 1000 nits for SDR. It reports six timings; only ID 2 is adopted. + */ +static const struct dcp_m4_profile dcp_m4_profile_j604 = { + .name = "J604", .machine = "apple,j604", + .panel_width = 3024, .panel_height = 1964, .boot_stride = 12096, + .swap_size = 0x1bd8, .swap_surface = 0x588, .swap_dva = 0xe38, + .swap_nullable = 0x1bcb, .swap_tail = 0x1bd6, .swap_nits = 0x35e, + .swap_intent = 0x17c, + .disabled_color = 0xff000000, + .done_method = 590, .done_size = 0x730, .open_method = 457, + .brightness_max = 1000, .brightness_default = 120, + .width_mm = 0, .height_mm = 0, + .timing = dcp_m4_timing_j604, .timing_elements = 6, +}; + static const struct dcp_m4_profile *const dcp_m4_profiles[] = { &dcp_m4_profile_j713, &dcp_m4_profile_j715, + &dcp_m4_profile_j604, }; /* The machine's profile, set before the first DCP session starts. */ diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/m4.py b/tools/testing/selftests/drivers/gpu/apple-dcp/m4.py index ccb0bef82485a..4d0e9c50a1082 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/m4.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/m4.py @@ -663,6 +663,7 @@ def blank(root): PANEL_MODES = { 'j713': (2560, 2568, 2600, 2640, 1664, 1697, 1705, 1749, 277042, 3932166), 'j715': (2880, 2888, 2920, 2960, 1864, 1911, 1919, 1961, 348274, 3932165), + 'j604': (3024, 3032, 3064, 3104, 1964, 2066, 2074, 2160, 804560, 7864351), } TIMING_SHIMS = r''' @@ -813,8 +814,33 @@ def perturbed(name, profile, report): perturbed('J713', 'j713', j713) perturbed('J715', 'j715', j715) + case('J604 six elements', 'j604', j604, 'j604') + case('J604 six elements, ID 2 last', 'j604', j604[1:] + j604[:1], 'j604') + case('J604 preferred element only', 'j604', j604[:1], 'j604') + case('J604 changed non-preferred timing', 'j604', + edit(j604, 1, setter('VerticalAttributes', 'PreciseSyncRate', value=3932161)), 'j604') + perturbed('J604', 'j604', j604) + for field, value in (('IsVirtual', True), ('IsInterlaced', True), ('IsSplit', True), + ('IsOverscanned', True), ('TimingType', 4), + ('MinimumVariableRefreshRate', 48 << 16), + ('MaximumVariableRefreshRate', 120 << 16)): + case('J604 %s changed' % field, 'j604', edit(j604, 0, setter(field, value=value))) + case('J604 color depth changed', 'j604', + edit(j604, 0, setter('ColorModes', 0, 'Depth', value=10))) + case('J604 second color mode', 'j604', + edit(j604, 0, lambda e: e['ColorModes'].append(dict(e['ColorModes'][0], ID=2)))) + case('J604 without ID 2 (renumbered)', 'j604', edit(j604, 0, setter('ID', value=8))) + case('J604 without ID 2 (removed)', 'j604', j604[1:]) + case('J604 with two ID 2 elements', 'j604', edit(j604, 1, setter('ID', value=2))) + case('J604 with a second preferred element', 'j604', + edit(j604, 1, setter('IsPreferred', value=True))) + case('J604 element without IsPreferred', 'j604', edit(j604, 1, lambda e: e.pop('IsPreferred'))) + case('J604 element without an ID', 'j604', edit(j604, 1, lambda e: e.pop('ID'))) + case('J604 element that is not a dictionary', 'j604', j604[:1] + [7] + j604[2:]) + case('J604 seven elements', 'j604', j604 + [dict(j604[5], ID=9)]) case('J604 report on the J713', 'j713', j604) case('J604 preferred element on the J713', 'j713', j604[:1]) + case('J713 report on the J604', 'j604', j713) case('J604 report on the J715', 'j715', j604) return cases