Skip to content

Commit ca49a73

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>
1 parent 03b5e18 commit ca49a73

5 files changed

Lines changed: 24 additions & 14 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+
s64 precise_sync_rate;
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: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,6 +1219,9 @@ int DCP_FW_NAME(iomfb_modeset)(struct apple_dcp *dcp,
12191219
.timing_mode_id = mode->timing_mode_id
12201220
};
12211221

1222+
/* keep around to fake timestamps in dcp_swap_submit */
1223+
dcp->precise_sync_rate = mode->precise_sync_rate;
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->main_display && (dcp->precise_sync_rate >> 16) == 120) {
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: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -499,19 +499,6 @@ static int parse_mode(struct dcp_parse_ctx *handle,
499499
if (is_virtual)
500500
return -EINVAL;
501501

502-
/*
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-
*/
510-
if (vert.precise_sync_rate >> 16 == 120 &&
511-
((horiz.active == 3024 && vert.active == 1964) ||
512-
(horiz.active == 3456 && vert.active == 2234)))
513-
return -EINVAL;
514-
515502
vert.active -= notch_height;
516503
vert.sync_width += notch_height;
517504

@@ -539,6 +526,7 @@ static int parse_mode(struct dcp_parse_ctx *handle,
539526

540527
out->timing_mode_id = id;
541528
out->color_mode_id = best_color_mode;
529+
out->precise_sync_rate = vert.precise_sync_rate;
542530

543531
trace_iomfb_timing_mode(handle->dcp, id, *score, horiz.active,
544532
vert.active, vert.precise_sync_rate,

drivers/gpu/drm/apple/parser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ struct dcp_display_mode {
8787
struct drm_display_mode mode;
8888
u32 color_mode_id;
8989
u32 timing_mode_id;
90+
s64 precise_sync_rate;
9091
struct dcp_color_mode sdr_rgb;
9192
struct dcp_color_mode sdr_444;
9293
struct dcp_color_mode sdr;

0 commit comments

Comments
 (0)