Skip to content

Commit 7f67aa0

Browse files
committed
drm/nouveau/disp: Support more modes by checking with lower bpc
This allows us to advertise more modes especially on HDR displays. Fixes using 4K@60 modes on my TV and main display both using a HDMI to DP adapter. Also fixes similar issues for users running into this. Cc: [email protected] # 5.10+ Signed-off-by: Karol Herbst <[email protected]> Reviewed-by: Lyude Paul <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 25bbe84 commit 7f67aa0

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

drivers/gpu/drm/nouveau/dispnv50/disp.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,35 @@ nv50_outp_atomic_check_view(struct drm_encoder *encoder,
363363
return 0;
364364
}
365365

366+
static void
367+
nv50_outp_atomic_fix_depth(struct drm_encoder *encoder, struct drm_crtc_state *crtc_state)
368+
{
369+
struct nv50_head_atom *asyh = nv50_head_atom(crtc_state);
370+
struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
371+
struct drm_display_mode *mode = &asyh->state.adjusted_mode;
372+
unsigned int max_rate, mode_rate;
373+
374+
switch (nv_encoder->dcb->type) {
375+
case DCB_OUTPUT_DP:
376+
max_rate = nv_encoder->dp.link_nr * nv_encoder->dp.link_bw;
377+
378+
/* we don't support more than 10 anyway */
379+
asyh->or.bpc = min_t(u8, asyh->or.bpc, 10);
380+
381+
/* reduce the bpc until it works out */
382+
while (asyh->or.bpc > 6) {
383+
mode_rate = DIV_ROUND_UP(mode->clock * asyh->or.bpc * 3, 8);
384+
if (mode_rate <= max_rate)
385+
break;
386+
387+
asyh->or.bpc -= 2;
388+
}
389+
break;
390+
default:
391+
break;
392+
}
393+
}
394+
366395
static int
367396
nv50_outp_atomic_check(struct drm_encoder *encoder,
368397
struct drm_crtc_state *crtc_state,
@@ -381,6 +410,9 @@ nv50_outp_atomic_check(struct drm_encoder *encoder,
381410
if (crtc_state->mode_changed || crtc_state->connectors_changed)
382411
asyh->or.bpc = connector->display_info.bpc;
383412

413+
/* We might have to reduce the bpc */
414+
nv50_outp_atomic_fix_depth(encoder, crtc_state);
415+
384416
return 0;
385417
}
386418

drivers/gpu/drm/nouveau/nouveau_dp.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,6 @@ nouveau_dp_irq(struct work_struct *work)
263263
}
264264

265265
/* TODO:
266-
* - Use the minimum possible BPC here, once we add support for the max bpc
267-
* property.
268266
* - Validate against the DP caps advertised by the GPU (we don't check these
269267
* yet)
270268
*/
@@ -276,7 +274,11 @@ nv50_dp_mode_valid(struct drm_connector *connector,
276274
{
277275
const unsigned int min_clock = 25000;
278276
unsigned int max_rate, mode_rate, ds_max_dotclock, clock = mode->clock;
279-
const u8 bpp = connector->display_info.bpc * 3;
277+
/* Check with the minmum bpc always, so we can advertise better modes.
278+
* In particlar not doing this causes modes to be dropped on HDR
279+
* displays as we might check with a bpc of 16 even.
280+
*/
281+
const u8 bpp = 6 * 3;
280282

281283
if (mode->flags & DRM_MODE_FLAG_INTERLACE && !outp->caps.dp_interlace)
282284
return MODE_NO_INTERLACE;

0 commit comments

Comments
 (0)