Skip to content

Commit 07513d5

Browse files
oliverbestmannjannau
authored andcommitted
drm: apple: set timestamps for 120hz
The dcp does not seem to care much about the values in ts1, ts2 and ts3, as long as they are non zero. This commit fills the timestamp with a dummy value of 120 if a refresh-rate of 120hz is selected. This is enough to get a refresh rate of 120hz. MacOS also sets flags1 and flags2. I have no idea what exactly those values indicate, but I did do not need to set any of them to get 120hz. Signed-off-by: Oliver Bestmann <oliver.bestmann@googlemail.com> Signed-off-by: Janne Grunau <j@jannau.net>
1 parent 0d10608 commit 07513d5

5 files changed

Lines changed: 32 additions & 11 deletions

File tree

drivers/gpu/drm/apple/dcp-internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ struct apple_dcp {
184184
/* Current display mode */
185185
bool during_modeset;
186186
bool valid_mode;
187+
bool use_timestamps;
187188
struct dcp_set_digital_out_mode_req mode;
188189

189190
/* completion for active turning true */

drivers/gpu/drm/apple/iomfb_template.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,15 +1210,18 @@ int DCP_FW_NAME(iomfb_modeset)(struct apple_dcp *dcp,
12101210
if (cmode)
12111211
dev_info(dcp->dev,
12121212
"set_digital_out_mode() color mode depth:%hhu format:%u "
1213-
"colorimetry:%u eotf:%u range:%u\n", cmode->depth,
1213+
"colorimetry:%u eotf:%u range:%u vrr:%u\n", cmode->depth,
12141214
cmode->format, cmode->colorimetry, cmode->eotf,
1215-
cmode->range);
1215+
cmode->range, mode->vrr);
12161216

12171217
dcp->mode = (struct dcp_set_digital_out_mode_req){
12181218
.color_mode_id = mode->color_mode_id,
12191219
.timing_mode_id = mode->timing_mode_id
12201220
};
12211221

1222+
/* Keep track of suspected vrr modes */
1223+
dcp->use_timestamps = mode->vrr;
1224+
12221225
cookie = kzalloc(sizeof(*cookie), GFP_KERNEL);
12231226
if (!cookie) {
12241227
return -ENOMEM;
@@ -1408,6 +1411,16 @@ void DCP_FW_NAME(iomfb_flush)(struct apple_dcp *dcp, struct drm_crtc *crtc, stru
14081411
req->clear = 1;
14091412
}
14101413

1414+
if (has_surface && dcp->use_timestamps) {
1415+
/*
1416+
* Fake timstamps to get 120hz refresh rate. It looks
1417+
* like the actual value does not matter, as long as it is non zero.
1418+
*/
1419+
req->swap.ts1 = 120;
1420+
req->swap.ts2 = 120;
1421+
req->swap.ts3 = 120;
1422+
}
1423+
14111424
/* These fields should be set together */
14121425
req->swap.swap_completed = req->swap.swap_enabled;
14131426

drivers/gpu/drm/apple/iomfb_template.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,14 @@
1818
struct DCP_FW_NAME(dcp_swap) {
1919
u64 ts1;
2020
u64 ts2;
21-
u64 unk_10[6];
21+
22+
u64 unk_10;
23+
u64 unk_18;
24+
u64 ts64_unk;
25+
u64 unk_28;
26+
u64 ts3;
27+
u64 unk_38;
28+
2229
u64 flags1;
2330
u64 flags2;
2431

drivers/gpu/drm/apple/parser.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -500,17 +500,16 @@ static int parse_mode(struct dcp_parse_ctx *handle,
500500
return -EINVAL;
501501

502502
/*
503-
* HACK:
504-
* Ignore the 120 Hz mode on j314/j316 (identified by resolution).
505-
* DCP limits normal swaps to 60 Hz anyway and the 120 Hz mode might
506-
* cause choppiness with X11.
507-
* Just downscoring it and thus making the 60 Hz mode the preferred mode
508-
* seems not enough for some user space.
509-
*/
503+
* HACK:
504+
* Mark the 120 Hz mode on j314/j316 (identified by resolution) as vrr.
505+
* We still do not know how to drive VRR but at least seetinng timestamps
506+
* in the the swap_surface message to non-zero values drives the display
507+
* at 120 fps.
508+
*/
510509
if (vert.precise_sync_rate >> 16 == 120 &&
511510
((horiz.active == 3024 && vert.active == 1964) ||
512511
(horiz.active == 3456 && vert.active == 2234)))
513-
return -EINVAL;
512+
out->vrr = true;
514513

515514
vert.active -= notch_height;
516515
vert.sync_width += notch_height;

drivers/gpu/drm/apple/parser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ struct dcp_display_mode {
9191
struct dcp_color_mode sdr_444;
9292
struct dcp_color_mode sdr;
9393
struct dcp_color_mode best;
94+
bool vrr;
9495
};
9596

9697
struct dimension {

0 commit comments

Comments
 (0)