Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 29 additions & 4 deletions drivers/gpu/drm/apple/dcp-m4-profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -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] = {
Expand All @@ -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). */
Expand All @@ -67,12 +68,36 @@ 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,
};

/* 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. */
Expand Down
43 changes: 29 additions & 14 deletions drivers/gpu/drm/apple/dcp-m4-timing.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions tools/testing/selftests/drivers/gpu/apple-dcp/README
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading
Loading