hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/gpu/drm/nouveau/dispnv50/disp.c
....@@ -396,6 +396,35 @@
396396 return 0;
397397 }
398398
399
+static void
400
+nv50_outp_atomic_fix_depth(struct drm_encoder *encoder, struct drm_crtc_state *crtc_state)
401
+{
402
+ struct nv50_head_atom *asyh = nv50_head_atom(crtc_state);
403
+ struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
404
+ struct drm_display_mode *mode = &asyh->state.adjusted_mode;
405
+ unsigned int max_rate, mode_rate;
406
+
407
+ switch (nv_encoder->dcb->type) {
408
+ case DCB_OUTPUT_DP:
409
+ max_rate = nv_encoder->dp.link_nr * nv_encoder->dp.link_bw;
410
+
411
+ /* we don't support more than 10 anyway */
412
+ asyh->or.bpc = min_t(u8, asyh->or.bpc, 10);
413
+
414
+ /* reduce the bpc until it works out */
415
+ while (asyh->or.bpc > 6) {
416
+ mode_rate = DIV_ROUND_UP(mode->clock * asyh->or.bpc * 3, 8);
417
+ if (mode_rate <= max_rate)
418
+ break;
419
+
420
+ asyh->or.bpc -= 2;
421
+ }
422
+ break;
423
+ default:
424
+ break;
425
+ }
426
+}
427
+
399428 static int
400429 nv50_outp_atomic_check(struct drm_encoder *encoder,
401430 struct drm_crtc_state *crtc_state,
....@@ -413,6 +442,9 @@
413442
414443 if (crtc_state->mode_changed || crtc_state->connectors_changed)
415444 asyh->or.bpc = connector->display_info.bpc;
445
+
446
+ /* We might have to reduce the bpc */
447
+ nv50_outp_atomic_fix_depth(encoder, crtc_state);
416448
417449 return 0;
418450 }
....@@ -2555,14 +2587,6 @@
25552587 {
25562588 struct nouveau_drm *drm = nouveau_drm(dev);
25572589 struct drm_encoder *encoder;
2558
- struct drm_plane *plane;
2559
-
2560
- drm_for_each_plane(plane, dev) {
2561
- struct nv50_wndw *wndw = nv50_wndw(plane);
2562
- if (plane->funcs != &nv50_wndw)
2563
- continue;
2564
- nv50_wndw_fini(wndw);
2565
- }
25662590
25672591 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
25682592 if (encoder->encoder_type != DRM_MODE_ENCODER_DPMST)
....@@ -2578,7 +2602,6 @@
25782602 {
25792603 struct nv50_core *core = nv50_disp(dev)->core;
25802604 struct drm_encoder *encoder;
2581
- struct drm_plane *plane;
25822605
25832606 if (resume || runtime)
25842607 core->func->init(core);
....@@ -2589,13 +2612,6 @@
25892612 nouveau_encoder(encoder);
25902613 nv50_mstm_init(nv_encoder, runtime);
25912614 }
2592
- }
2593
-
2594
- drm_for_each_plane(plane, dev) {
2595
- struct nv50_wndw *wndw = nv50_wndw(plane);
2596
- if (plane->funcs != &nv50_wndw)
2597
- continue;
2598
- nv50_wndw_init(wndw);
25992615 }
26002616
26012617 return 0;