Skip to content

Commit bf1298c

Browse files
committed
NOUPSTREAM: drm: apple: Hide VRR behind a module parameter
Given that DCP requires a modeset to activate VRR, and given that this is explicitly banned by KMS API contract and VESA DisplayPort specification, hide this experimental support behind a module param. Interestingly, the HDMI spec does not require a modeset-free VRR transition. For this reason, it is expected that the KMS API contract may change in the future, as both Intel and AMD hardware require a modeset to enable VRR in some circumstances. Either VRR will be expected to be enabled whenever it is supported, *or* modesetting to toggle it on or off will be allowed. When that happens, this commit *must* be reverted. Signed-off-by: James Calligeros <[email protected]>
1 parent 7d6080c commit bf1298c

2 files changed

Lines changed: 25 additions & 18 deletions

File tree

drivers/gpu/drm/apple/dcp.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ static bool unstable_edid = true;
5858
module_param(unstable_edid, bool, 0644);
5959
MODULE_PARM_DESC(unstable_edid, "Enable unstable EDID retrival support");
6060

61+
bool force_vrr;
62+
module_param(force_vrr, bool, 0644);
63+
MODULE_PARM_DESC(force_vrr, "Always enable Adaptive Sync/ProMotion on supported displays");
64+
6165
/* copied and simplified from drm_vblank.c */
6266
static void send_vblank_event(struct drm_device *dev,
6367
struct drm_pending_vblank_event *e,
@@ -361,9 +365,9 @@ int dcp_crtc_atomic_check(struct drm_crtc *crtc, struct drm_atomic_state *state)
361365
return -EINVAL;
362366
}
363367

364-
if (dcp->vrr_enabled != crtc_state->vrr_enabled) {
365-
crtc_state->mode_changed = true;
366-
}
368+
// if (dcp->vrr_enabled != crtc_state->vrr_enabled) {
369+
// crtc_state->mode_changed = true;
370+
// }
367371

368372
return 0;
369373
}

drivers/gpu/drm/apple/iomfb_template.c

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
/* Register defines used in bandwidth setup structure */
3535
#define REG_DOORBELL_BIT(idx) (2 + (idx))
3636

37+
extern bool force_vrr;
38+
3739
struct dcp_wait_cookie {
3840
struct kref refcount;
3941
struct completion done;
@@ -546,9 +548,9 @@ static u8 dcpep_cb_prop_chunk(struct apple_dcp *dcp,
546548
static bool dcpep_process_chunks(struct apple_dcp *dcp,
547549
struct dcp_set_dcpav_prop_end_req *req)
548550
{
549-
struct apple_connector *connector = dcp->connector;
551+
// struct apple_connector *connector = dcp->connector;
550552
struct dcp_parse_ctx ctx;
551-
int ret, i;
553+
int ret; //, i;
552554

553555
if (!dcp->chunks.data) {
554556
dev_warn(dcp->dev, "ignoring spurious end\n");
@@ -590,14 +592,14 @@ static bool dcpep_process_chunks(struct apple_dcp *dcp,
590592
dcp_set_dimensions(dcp);
591593
}
592594

593-
if (connector) {
594-
for (i = 0; i < dcp->nr_modes; i++) {
595-
if (dcp->modes[i].vrr) {
596-
drm_connector_set_vrr_capable_property(&connector->base, true);
597-
break;
598-
}
599-
}
600-
}
595+
// if (connector) {
596+
// for (i = 0; i < dcp->nr_modes; i++) {
597+
// if (dcp->modes[i].vrr) {
598+
// drm_connector_set_vrr_capable_property(&connector->base, true);
599+
// break;
600+
// }
601+
// }
602+
// }
601603

602604
return true;
603605
}
@@ -1262,11 +1264,12 @@ int DCP_FW_NAME(iomfb_modeset)(struct apple_dcp *dcp,
12621264

12631265
dcp->during_modeset = true;
12641266

1265-
if (mode->vrr)
1266-
dcp_set_adaptive_sync(dcp, crtc_state->vrr_enabled ? mode->min_vrr : 0, cookie);
1267-
else
1267+
if (mode->vrr) {
1268+
dcp_set_adaptive_sync(dcp, force_vrr ? mode->min_vrr : 0, cookie);
1269+
} else {
12681270
dcp_set_digital_out_mode(dcp, false, &dcp->mode,
12691271
complete_set_digital_out_mode, cookie);
1272+
}
12701273

12711274
/*
12721275
* The DCP firmware has an internal timeout of ~8 seconds for
@@ -1294,7 +1297,7 @@ int DCP_FW_NAME(iomfb_modeset)(struct apple_dcp *dcp,
12941297
jiffies_to_msecs(ret));
12951298
}
12961299
dcp->valid_mode = true;
1297-
dcp->vrr_enabled = crtc_state->vrr_enabled;
1300+
dcp->vrr_enabled = mode->vrr && force_vrr;
12981301

12991302
return 0;
13001303
}
@@ -1422,7 +1425,7 @@ void DCP_FW_NAME(iomfb_flush)(struct apple_dcp *dcp, struct drm_crtc *crtc, stru
14221425
req->clear = 1;
14231426
}
14241427

1425-
if (has_surface && (dcp->use_timestamps || crtc_state->vrr_enabled)) {
1428+
if (has_surface && (dcp->use_timestamps || crtc_state->vrr_enabled || force_vrr)) {
14261429
/*
14271430
* TODO: ascertain with certainty what these timestamps
14281431
* are. They are something to do with presentation timing,

0 commit comments

Comments
 (0)