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
13 changes: 13 additions & 0 deletions drivers/gpu/drm/apple/dcp-peer-frames-v27.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,23 @@
* outstanding swaps, as in the existing single-pipe retirement path.
*/
struct dcp_peer_frames_v27 {
u32 timing;
u32 color;
u32 min_vrr;
bool output_hdr;
u32 first, submitted, engine[2], retired, shown[2];
bool active, armed, failed, have[2], have_retired, have_shown[2];
};

static inline bool dcp_peer_vrr_only_v27(const struct dcp_peer_frames_v27 *frames,
u32 timing, u32 color, u32 min_vrr,
bool output_hdr)
{
return frames->active && !frames->failed && frames->timing == timing &&
frames->color == color && frames->min_vrr != min_vrr &&
frames->output_hdr == output_hdr;
}

static inline void dcp_peer_frame_submit_v27(struct dcp_peer_frames_v27 *s, u32 id)
{
if (!s->armed) {
Expand Down
51 changes: 49 additions & 2 deletions drivers/gpu/drm/apple/dcp-peer-runtime-v27.inc
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ static int dcp_peer_limited_stop_v27(struct apple_dcp *dcp, struct apple_dcp *pe
int dcp_peer_modeset_v27(struct apple_dcp *dcp, u32 timing, u32 color, u32 min_vrr)
{
struct apple_dcp *peer;
bool limited, prepared;
bool limited, prepared, vrr_only;
int ret = -EOPNOTSUPP;

if (!peer_scanout || !peer_allocation_probe ||
Expand Down Expand Up @@ -145,11 +145,52 @@ int dcp_peer_modeset_v27(struct apple_dcp *dcp, u32 timing, u32 color, u32 min_v
ret = -EBUSY;
goto unlock;
}
vrr_only = dcp->peer_tiling.modeset_complete &&
peer->peer_tiling.modeset_complete &&
dcp_peer_vrr_only_v27(&dcp->peer_frames, timing, color,
min_vrr, dcp->output_hdr);
}
if (limited) {
ret = dcp_peer_limited_stop_v27(dcp, peer);
goto peer_unlock;
}
/*
* Adaptive sync uses parameter 15 on both engines. Leave a running
* pair installed when its timing and color are still current. If
* either engine refuses the update, rebuild both with the new rate.
*/
if (vrr_only) {
bool still_owned, updated = false;

ret = dcp_peer_param_v27(dcp, peer, 15, 3, min_vrr);
scoped_guard(mutex, &dcp_peer_lock) {
still_owned = dcp->peer_reserved == peer &&
peer->peer_owner == dcp;
limited = still_owned &&
dcp_peer_limited_pair_locked(dcp, &prepared);
if (!ret && !limited && still_owned &&
dcp->peer_tiling.modeset_complete &&
peer->peer_tiling.modeset_complete &&
dcp_peer_vrr_only_v27(&dcp->peer_frames, timing,
color, min_vrr,
dcp->output_hdr)) {
dcp->peer_frames.min_vrr = min_vrr;
dev_dbg(dcp->dev, "paired adaptive sync minimum %#x\n", min_vrr);
updated = true;
}
}
if (updated)
goto peer_unlock;
if (!still_owned) {
ret = -EBUSY;
goto peer_unlock;
}
if (limited) {
ret = prepared ? dcp_peer_limited_stop_v27(dcp, peer)
: -EOPNOTSUPP;
goto peer_unlock;
}
}
ret = dcp_peer_prepare_v27(dcp, peer, min_vrr);
if (ret)
goto peer_unlock;
Expand All @@ -158,7 +199,13 @@ int dcp_peer_modeset_v27(struct apple_dcp *dcp, u32 timing, u32 color, u32 min_v
dcp_peer_finish_v27(dcp, peer);
if (!ret) {
guard(mutex)(&dcp_peer_lock);
dcp->peer_frames = (struct dcp_peer_frames_v27){ .active = true };
dcp->peer_frames = (struct dcp_peer_frames_v27){
.timing = timing,
.color = color,
.min_vrr = min_vrr,
.output_hdr = dcp->output_hdr,
.active = true,
};
dev_info(dcp->dev, "paired DRM mode ready: timing=%u color=%u min_vrr=%#x\n",
timing, color, min_vrr);
}
Expand Down
13 changes: 13 additions & 0 deletions tools/asahi/dcp-peer-shown-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@
u32 w = 0;
bool shown = true;

/* A new adaptive-sync minimum can reuse only the installed mode. */
s = (struct dcp_peer_frames_v27){ .timing = 81, .color = 86, .active = true };
assert(dcp_peer_vrr_only_v27(&s, 81, 86, 0x300000, false));
assert(!dcp_peer_vrr_only_v27(&s, 81, 86, 0, false));
assert(!dcp_peer_vrr_only_v27(&s, 80, 86, 0x300000, false));
assert(!dcp_peer_vrr_only_v27(&s, 81, 85, 0x300000, false));
assert(!dcp_peer_vrr_only_v27(&s, 81, 86, 0x300000, true));
s.failed = true;
assert(!dcp_peer_vrr_only_v27(&s, 81, 86, 0x300000, false));
s.failed = false;
s.active = false;
assert(!dcp_peer_vrr_only_v27(&s, 81, 86, 0x300000, false));

/* First modeset of a pair: both engines display swap 5. */
s = paired(5, 5);
assert(!dcp_peer_frame_complete_v27(&s, 0, 5, true, &w, &shown));
Expand Down
Loading