forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-02-19 890e1df1bec891d9203724541e81f8fbe5183388
kernel/drivers/gpu/drm/nouveau/dispnv50/disp.c
....@@ -26,23 +26,36 @@
2626 #include "core.h"
2727 #include "head.h"
2828 #include "wndw.h"
29
+#include "handles.h"
2930
3031 #include <linux/dma-mapping.h>
3132 #include <linux/hdmi.h>
33
+#include <linux/component.h>
3234
33
-#include <drm/drmP.h>
3435 #include <drm/drm_atomic_helper.h>
35
-#include <drm/drm_crtc_helper.h>
3636 #include <drm/drm_dp_helper.h>
37
+#include <drm/drm_edid.h>
3738 #include <drm/drm_fb_helper.h>
3839 #include <drm/drm_plane_helper.h>
39
-#include <drm/drm_edid.h>
40
+#include <drm/drm_probe_helper.h>
41
+#include <drm/drm_scdc_helper.h>
42
+#include <drm/drm_vblank.h>
43
+
44
+#include <nvif/push507c.h>
4045
4146 #include <nvif/class.h>
4247 #include <nvif/cl0002.h>
4348 #include <nvif/cl5070.h>
4449 #include <nvif/cl507d.h>
4550 #include <nvif/event.h>
51
+#include <nvif/timer.h>
52
+
53
+#include <nvhw/class/cl507c.h>
54
+#include <nvhw/class/cl507d.h>
55
+#include <nvhw/class/cl837d.h>
56
+#include <nvhw/class/cl887d.h>
57
+#include <nvhw/class/cl907d.h>
58
+#include <nvhw/class/cl917d.h>
4659
4760 #include "nouveau_drv.h"
4861 #include "nouveau_dma.h"
....@@ -53,24 +66,6 @@
5366 #include "nouveau_fbcon.h"
5467
5568 #include <subdev/bios/dp.h>
56
-
57
-/******************************************************************************
58
- * Atomic state
59
- *****************************************************************************/
60
-
61
-struct nv50_outp_atom {
62
- struct list_head head;
63
-
64
- struct drm_encoder *encoder;
65
- bool flush_disable;
66
-
67
- union nv50_outp_atom_mask {
68
- struct {
69
- bool ctrl:1;
70
- };
71
- u8 mask;
72
- } set, clr;
73
-};
7469
7570 /******************************************************************************
7671 * EVO channel
....@@ -93,8 +88,9 @@
9388 while (oclass[0]) {
9489 for (i = 0; i < n; i++) {
9590 if (sclass[i].oclass == oclass[0]) {
96
- ret = nvif_object_init(disp, 0, oclass[0],
97
- data, size, &chan->user);
91
+ ret = nvif_object_ctor(disp, "kmsChan", 0,
92
+ oclass[0], data, size,
93
+ &chan->user);
9894 if (ret == 0)
9995 nvif_object_map(&chan->user, NULL, 0);
10096 nvif_object_sclass_put(&sclass);
....@@ -111,7 +107,7 @@
111107 static void
112108 nv50_chan_destroy(struct nv50_chan *chan)
113109 {
114
- nvif_object_fini(&chan->user);
110
+ nvif_object_dtor(&chan->user);
115111 }
116112
117113 /******************************************************************************
....@@ -121,12 +117,106 @@
121117 void
122118 nv50_dmac_destroy(struct nv50_dmac *dmac)
123119 {
124
- nvif_object_fini(&dmac->vram);
125
- nvif_object_fini(&dmac->sync);
120
+ nvif_object_dtor(&dmac->vram);
121
+ nvif_object_dtor(&dmac->sync);
126122
127123 nv50_chan_destroy(&dmac->base);
128124
129
- nvif_mem_fini(&dmac->push);
125
+ nvif_mem_dtor(&dmac->_push.mem);
126
+}
127
+
128
+static void
129
+nv50_dmac_kick(struct nvif_push *push)
130
+{
131
+ struct nv50_dmac *dmac = container_of(push, typeof(*dmac), _push);
132
+
133
+ dmac->cur = push->cur - (u32 *)dmac->_push.mem.object.map.ptr;
134
+ if (dmac->put != dmac->cur) {
135
+ /* Push buffer fetches are not coherent with BAR1, we need to ensure
136
+ * writes have been flushed right through to VRAM before writing PUT.
137
+ */
138
+ if (dmac->push->mem.type & NVIF_MEM_VRAM) {
139
+ struct nvif_device *device = dmac->base.device;
140
+ nvif_wr32(&device->object, 0x070000, 0x00000001);
141
+ nvif_msec(device, 2000,
142
+ if (!(nvif_rd32(&device->object, 0x070000) & 0x00000002))
143
+ break;
144
+ );
145
+ }
146
+
147
+ NVIF_WV32(&dmac->base.user, NV507C, PUT, PTR, dmac->cur);
148
+ dmac->put = dmac->cur;
149
+ }
150
+
151
+ push->bgn = push->cur;
152
+}
153
+
154
+static int
155
+nv50_dmac_free(struct nv50_dmac *dmac)
156
+{
157
+ u32 get = NVIF_RV32(&dmac->base.user, NV507C, GET, PTR);
158
+ if (get > dmac->cur) /* NVIDIA stay 5 away from GET, do the same. */
159
+ return get - dmac->cur - 5;
160
+ return dmac->max - dmac->cur;
161
+}
162
+
163
+static int
164
+nv50_dmac_wind(struct nv50_dmac *dmac)
165
+{
166
+ /* Wait for GET to depart from the beginning of the push buffer to
167
+ * prevent writing PUT == GET, which would be ignored by HW.
168
+ */
169
+ u32 get = NVIF_RV32(&dmac->base.user, NV507C, GET, PTR);
170
+ if (get == 0) {
171
+ /* Corner-case, HW idle, but non-committed work pending. */
172
+ if (dmac->put == 0)
173
+ nv50_dmac_kick(dmac->push);
174
+
175
+ if (nvif_msec(dmac->base.device, 2000,
176
+ if (NVIF_TV32(&dmac->base.user, NV507C, GET, PTR, >, 0))
177
+ break;
178
+ ) < 0)
179
+ return -ETIMEDOUT;
180
+ }
181
+
182
+ PUSH_RSVD(dmac->push, PUSH_JUMP(dmac->push, 0));
183
+ dmac->cur = 0;
184
+ return 0;
185
+}
186
+
187
+static int
188
+nv50_dmac_wait(struct nvif_push *push, u32 size)
189
+{
190
+ struct nv50_dmac *dmac = container_of(push, typeof(*dmac), _push);
191
+ int free;
192
+
193
+ if (WARN_ON(size > dmac->max))
194
+ return -EINVAL;
195
+
196
+ dmac->cur = push->cur - (u32 *)dmac->_push.mem.object.map.ptr;
197
+ if (dmac->cur + size >= dmac->max) {
198
+ int ret = nv50_dmac_wind(dmac);
199
+ if (ret)
200
+ return ret;
201
+
202
+ push->cur = dmac->_push.mem.object.map.ptr;
203
+ push->cur = push->cur + dmac->cur;
204
+ nv50_dmac_kick(push);
205
+ }
206
+
207
+ if (nvif_msec(dmac->base.device, 2000,
208
+ if ((free = nv50_dmac_free(dmac)) >= size)
209
+ break;
210
+ ) < 0) {
211
+ WARN_ON(1);
212
+ return -ETIMEDOUT;
213
+ }
214
+
215
+ push->bgn = dmac->_push.mem.object.map.ptr;
216
+ push->bgn = push->bgn + dmac->cur;
217
+ push->cur = push->bgn;
218
+ push->end = push->cur + free;
219
+ return 0;
130220 }
131221
132222 int
....@@ -153,13 +243,27 @@
153243 if (device->info.family == NV_DEVICE_INFO_V0_PASCAL)
154244 type |= NVIF_MEM_VRAM;
155245
156
- ret = nvif_mem_init_map(&cli->mmu, type, 0x1000, &dmac->push);
246
+ ret = nvif_mem_ctor_map(&cli->mmu, "kmsChanPush", type, 0x1000,
247
+ &dmac->_push.mem);
157248 if (ret)
158249 return ret;
159250
160
- dmac->ptr = dmac->push.object.map.ptr;
251
+ dmac->ptr = dmac->_push.mem.object.map.ptr;
252
+ dmac->_push.wait = nv50_dmac_wait;
253
+ dmac->_push.kick = nv50_dmac_kick;
254
+ dmac->push = &dmac->_push;
255
+ dmac->push->bgn = dmac->_push.mem.object.map.ptr;
256
+ dmac->push->cur = dmac->push->bgn;
257
+ dmac->push->end = dmac->push->bgn;
258
+ dmac->max = 0x1000/4 - 1;
161259
162
- args->pushbuf = nvif_handle(&dmac->push.object);
260
+ /* EVO channels are affected by a HW bug where the last 12 DWORDs
261
+ * of the push buffer aren't able to be used safely.
262
+ */
263
+ if (disp->oclass < GV100_DISP)
264
+ dmac->max -= 12;
265
+
266
+ args->pushbuf = nvif_handle(&dmac->_push.mem.object);
163267
164268 ret = nv50_chan_create(device, disp, oclass, head, data, size,
165269 &dmac->base);
....@@ -169,7 +273,8 @@
169273 if (syncbuf < 0)
170274 return 0;
171275
172
- ret = nvif_object_init(&dmac->base.user, 0xf0000000, NV_DMA_IN_MEMORY,
276
+ ret = nvif_object_ctor(&dmac->base.user, "kmsSyncCtxDma", NV50_DISP_HANDLE_SYNCBUF,
277
+ NV_DMA_IN_MEMORY,
173278 &(struct nv_dma_v0) {
174279 .target = NV_DMA_V0_TARGET_VRAM,
175280 .access = NV_DMA_V0_ACCESS_RDWR,
....@@ -180,7 +285,8 @@
180285 if (ret)
181286 return ret;
182287
183
- ret = nvif_object_init(&dmac->base.user, 0xf0000001, NV_DMA_IN_MEMORY,
288
+ ret = nvif_object_ctor(&dmac->base.user, "kmsVramCtxDma", NV50_DISP_HANDLE_VRAM,
289
+ NV_DMA_IN_MEMORY,
184290 &(struct nv_dma_v0) {
185291 .target = NV_DMA_V0_TARGET_VRAM,
186292 .access = NV_DMA_V0_ACCESS_RDWR,
....@@ -192,64 +298,6 @@
192298 return ret;
193299
194300 return ret;
195
-}
196
-
197
-/******************************************************************************
198
- * EVO channel helpers
199
- *****************************************************************************/
200
-static void
201
-evo_flush(struct nv50_dmac *dmac)
202
-{
203
- /* Push buffer fetches are not coherent with BAR1, we need to ensure
204
- * writes have been flushed right through to VRAM before writing PUT.
205
- */
206
- if (dmac->push.type & NVIF_MEM_VRAM) {
207
- struct nvif_device *device = dmac->base.device;
208
- nvif_wr32(&device->object, 0x070000, 0x00000001);
209
- nvif_msec(device, 2000,
210
- if (!(nvif_rd32(&device->object, 0x070000) & 0x00000002))
211
- break;
212
- );
213
- }
214
-}
215
-
216
-u32 *
217
-evo_wait(struct nv50_dmac *evoc, int nr)
218
-{
219
- struct nv50_dmac *dmac = evoc;
220
- struct nvif_device *device = dmac->base.device;
221
- u32 put = nvif_rd32(&dmac->base.user, 0x0000) / 4;
222
-
223
- mutex_lock(&dmac->lock);
224
- if (put + nr >= (PAGE_SIZE / 4) - 8) {
225
- dmac->ptr[put] = 0x20000000;
226
- evo_flush(dmac);
227
-
228
- nvif_wr32(&dmac->base.user, 0x0000, 0x00000000);
229
- if (nvif_msec(device, 2000,
230
- if (!nvif_rd32(&dmac->base.user, 0x0004))
231
- break;
232
- ) < 0) {
233
- mutex_unlock(&dmac->lock);
234
- pr_err("nouveau: evo channel stalled\n");
235
- return NULL;
236
- }
237
-
238
- put = 0;
239
- }
240
-
241
- return dmac->ptr + put;
242
-}
243
-
244
-void
245
-evo_kick(u32 *push, struct nv50_dmac *evoc)
246
-{
247
- struct nv50_dmac *dmac = evoc;
248
-
249
- evo_flush(dmac);
250
-
251
- nvif_wr32(&dmac->base.user, 0x0000, (push - dmac->ptr) << 2);
252
- mutex_unlock(&dmac->lock);
253301 }
254302
255303 /******************************************************************************
....@@ -274,7 +322,7 @@
274322 }
275323
276324 static int
277
-nv50_outp_acquire(struct nouveau_encoder *nv_encoder)
325
+nv50_outp_acquire(struct nouveau_encoder *nv_encoder, bool hda)
278326 {
279327 struct nouveau_drm *drm = nouveau_drm(nv_encoder->base.base.dev);
280328 struct nv50_disp *disp = nv50_disp(drm->dev);
....@@ -286,6 +334,7 @@
286334 .base.method = NV50_DISP_MTHD_V1_ACQUIRE,
287335 .base.hasht = nv_encoder->dcb->hasht,
288336 .base.hashm = nv_encoder->dcb->hashm,
337
+ .info.hda = hda,
289338 };
290339 int ret;
291340
....@@ -321,8 +370,13 @@
321370 switch (connector->connector_type) {
322371 case DRM_MODE_CONNECTOR_LVDS:
323372 case DRM_MODE_CONNECTOR_eDP:
324
- /* Force use of scaler for non-EDID modes. */
325
- if (adjusted_mode->type & DRM_MODE_TYPE_DRIVER)
373
+ /* Don't force scaler for EDID modes with
374
+ * same size as the native one (e.g. different
375
+ * refresh rate)
376
+ */
377
+ if (mode->hdisplay == native_mode->hdisplay &&
378
+ mode->vdisplay == native_mode->vdisplay &&
379
+ mode->type & DRM_MODE_TYPE_DRIVER)
326380 break;
327381 mode = native_mode;
328382 asyc->scaler.full = true;
....@@ -342,42 +396,132 @@
342396 return 0;
343397 }
344398
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
+
345428 static int
346429 nv50_outp_atomic_check(struct drm_encoder *encoder,
347430 struct drm_crtc_state *crtc_state,
348431 struct drm_connector_state *conn_state)
349432 {
350
- struct nouveau_connector *nv_connector =
351
- nouveau_connector(conn_state->connector);
352
- return nv50_outp_atomic_check_view(encoder, crtc_state, conn_state,
353
- nv_connector->native_mode);
433
+ struct drm_connector *connector = conn_state->connector;
434
+ struct nouveau_connector *nv_connector = nouveau_connector(connector);
435
+ struct nv50_head_atom *asyh = nv50_head_atom(crtc_state);
436
+ int ret;
437
+
438
+ ret = nv50_outp_atomic_check_view(encoder, crtc_state, conn_state,
439
+ nv_connector->native_mode);
440
+ if (ret)
441
+ return ret;
442
+
443
+ if (crtc_state->mode_changed || crtc_state->connectors_changed)
444
+ 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);
448
+
449
+ return 0;
450
+}
451
+
452
+struct nouveau_connector *
453
+nv50_outp_get_new_connector(struct nouveau_encoder *outp,
454
+ struct drm_atomic_state *state)
455
+{
456
+ struct drm_connector *connector;
457
+ struct drm_connector_state *connector_state;
458
+ struct drm_encoder *encoder = to_drm_encoder(outp);
459
+ int i;
460
+
461
+ for_each_new_connector_in_state(state, connector, connector_state, i) {
462
+ if (connector_state->best_encoder == encoder)
463
+ return nouveau_connector(connector);
464
+ }
465
+
466
+ return NULL;
467
+}
468
+
469
+struct nouveau_connector *
470
+nv50_outp_get_old_connector(struct nouveau_encoder *outp,
471
+ struct drm_atomic_state *state)
472
+{
473
+ struct drm_connector *connector;
474
+ struct drm_connector_state *connector_state;
475
+ struct drm_encoder *encoder = to_drm_encoder(outp);
476
+ int i;
477
+
478
+ for_each_old_connector_in_state(state, connector, connector_state, i) {
479
+ if (connector_state->best_encoder == encoder)
480
+ return nouveau_connector(connector);
481
+ }
482
+
483
+ return NULL;
354484 }
355485
356486 /******************************************************************************
357487 * DAC
358488 *****************************************************************************/
359489 static void
360
-nv50_dac_disable(struct drm_encoder *encoder)
490
+nv50_dac_disable(struct drm_encoder *encoder, struct drm_atomic_state *state)
361491 {
362492 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
363493 struct nv50_core *core = nv50_disp(encoder->dev)->core;
494
+ const u32 ctrl = NVDEF(NV507D, DAC_SET_CONTROL, OWNER, NONE);
364495 if (nv_encoder->crtc)
365
- core->func->dac->ctrl(core, nv_encoder->or, 0x00000000, NULL);
496
+ core->func->dac->ctrl(core, nv_encoder->or, ctrl, NULL);
366497 nv_encoder->crtc = NULL;
367498 nv50_outp_release(nv_encoder);
368499 }
369500
370501 static void
371
-nv50_dac_enable(struct drm_encoder *encoder)
502
+nv50_dac_enable(struct drm_encoder *encoder, struct drm_atomic_state *state)
372503 {
373504 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
374505 struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc);
375506 struct nv50_head_atom *asyh = nv50_head_atom(nv_crtc->base.state);
376507 struct nv50_core *core = nv50_disp(encoder->dev)->core;
508
+ u32 ctrl = 0;
377509
378
- nv50_outp_acquire(nv_encoder);
510
+ switch (nv_crtc->index) {
511
+ case 0: ctrl |= NVDEF(NV507D, DAC_SET_CONTROL, OWNER, HEAD0); break;
512
+ case 1: ctrl |= NVDEF(NV507D, DAC_SET_CONTROL, OWNER, HEAD1); break;
513
+ case 2: ctrl |= NVDEF(NV907D, DAC_SET_CONTROL, OWNER_MASK, HEAD2); break;
514
+ case 3: ctrl |= NVDEF(NV907D, DAC_SET_CONTROL, OWNER_MASK, HEAD3); break;
515
+ default:
516
+ WARN_ON(1);
517
+ break;
518
+ }
379519
380
- core->func->dac->ctrl(core, nv_encoder->or, 1 << nv_crtc->index, asyh);
520
+ ctrl |= NVDEF(NV507D, DAC_SET_CONTROL, PROTOCOL, RGB_CRT);
521
+
522
+ nv50_outp_acquire(nv_encoder, false);
523
+
524
+ core->func->dac->ctrl(core, nv_encoder->or, ctrl, asyh);
381525 asyh->or.depth = 0;
382526
383527 nv_encoder->crtc = encoder->crtc;
....@@ -413,8 +557,8 @@
413557 static const struct drm_encoder_helper_funcs
414558 nv50_dac_help = {
415559 .atomic_check = nv50_outp_atomic_check,
416
- .enable = nv50_dac_enable,
417
- .disable = nv50_dac_disable,
560
+ .atomic_enable = nv50_dac_enable,
561
+ .atomic_disable = nv50_dac_disable,
418562 .detect = nv50_dac_detect
419563 };
420564
....@@ -460,12 +604,131 @@
460604 return 0;
461605 }
462606
607
+/*
608
+ * audio component binding for ELD notification
609
+ */
610
+static void
611
+nv50_audio_component_eld_notify(struct drm_audio_component *acomp, int port,
612
+ int dev_id)
613
+{
614
+ if (acomp && acomp->audio_ops && acomp->audio_ops->pin_eld_notify)
615
+ acomp->audio_ops->pin_eld_notify(acomp->audio_ops->audio_ptr,
616
+ port, dev_id);
617
+}
618
+
619
+static int
620
+nv50_audio_component_get_eld(struct device *kdev, int port, int dev_id,
621
+ bool *enabled, unsigned char *buf, int max_bytes)
622
+{
623
+ struct drm_device *drm_dev = dev_get_drvdata(kdev);
624
+ struct nouveau_drm *drm = nouveau_drm(drm_dev);
625
+ struct drm_encoder *encoder;
626
+ struct nouveau_encoder *nv_encoder;
627
+ struct drm_connector *connector;
628
+ struct nouveau_crtc *nv_crtc;
629
+ struct drm_connector_list_iter conn_iter;
630
+ int ret = 0;
631
+
632
+ *enabled = false;
633
+
634
+ drm_for_each_encoder(encoder, drm->dev) {
635
+ struct nouveau_connector *nv_connector = NULL;
636
+
637
+ nv_encoder = nouveau_encoder(encoder);
638
+
639
+ drm_connector_list_iter_begin(drm_dev, &conn_iter);
640
+ drm_for_each_connector_iter(connector, &conn_iter) {
641
+ if (connector->state->best_encoder == encoder) {
642
+ nv_connector = nouveau_connector(connector);
643
+ break;
644
+ }
645
+ }
646
+ drm_connector_list_iter_end(&conn_iter);
647
+ if (!nv_connector)
648
+ continue;
649
+
650
+ nv_crtc = nouveau_crtc(encoder->crtc);
651
+ if (!nv_crtc || nv_encoder->or != port ||
652
+ nv_crtc->index != dev_id)
653
+ continue;
654
+ *enabled = nv_encoder->audio;
655
+ if (*enabled) {
656
+ ret = drm_eld_size(nv_connector->base.eld);
657
+ memcpy(buf, nv_connector->base.eld,
658
+ min(max_bytes, ret));
659
+ }
660
+ break;
661
+ }
662
+
663
+ return ret;
664
+}
665
+
666
+static const struct drm_audio_component_ops nv50_audio_component_ops = {
667
+ .get_eld = nv50_audio_component_get_eld,
668
+};
669
+
670
+static int
671
+nv50_audio_component_bind(struct device *kdev, struct device *hda_kdev,
672
+ void *data)
673
+{
674
+ struct drm_device *drm_dev = dev_get_drvdata(kdev);
675
+ struct nouveau_drm *drm = nouveau_drm(drm_dev);
676
+ struct drm_audio_component *acomp = data;
677
+
678
+ if (WARN_ON(!device_link_add(hda_kdev, kdev, DL_FLAG_STATELESS)))
679
+ return -ENOMEM;
680
+
681
+ drm_modeset_lock_all(drm_dev);
682
+ acomp->ops = &nv50_audio_component_ops;
683
+ acomp->dev = kdev;
684
+ drm->audio.component = acomp;
685
+ drm_modeset_unlock_all(drm_dev);
686
+ return 0;
687
+}
688
+
689
+static void
690
+nv50_audio_component_unbind(struct device *kdev, struct device *hda_kdev,
691
+ void *data)
692
+{
693
+ struct drm_device *drm_dev = dev_get_drvdata(kdev);
694
+ struct nouveau_drm *drm = nouveau_drm(drm_dev);
695
+ struct drm_audio_component *acomp = data;
696
+
697
+ drm_modeset_lock_all(drm_dev);
698
+ drm->audio.component = NULL;
699
+ acomp->ops = NULL;
700
+ acomp->dev = NULL;
701
+ drm_modeset_unlock_all(drm_dev);
702
+}
703
+
704
+static const struct component_ops nv50_audio_component_bind_ops = {
705
+ .bind = nv50_audio_component_bind,
706
+ .unbind = nv50_audio_component_unbind,
707
+};
708
+
709
+static void
710
+nv50_audio_component_init(struct nouveau_drm *drm)
711
+{
712
+ if (!component_add(drm->dev->dev, &nv50_audio_component_bind_ops))
713
+ drm->audio.component_registered = true;
714
+}
715
+
716
+static void
717
+nv50_audio_component_fini(struct nouveau_drm *drm)
718
+{
719
+ if (drm->audio.component_registered) {
720
+ component_del(drm->dev->dev, &nv50_audio_component_bind_ops);
721
+ drm->audio.component_registered = false;
722
+ }
723
+}
724
+
463725 /******************************************************************************
464726 * Audio
465727 *****************************************************************************/
466728 static void
467729 nv50_audio_disable(struct drm_encoder *encoder, struct nouveau_crtc *nv_crtc)
468730 {
731
+ struct nouveau_drm *drm = nouveau_drm(encoder->dev);
469732 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
470733 struct nv50_disp *disp = nv50_disp(encoder->dev);
471734 struct {
....@@ -479,12 +742,21 @@
479742 (0x0100 << nv_crtc->index),
480743 };
481744
745
+ if (!nv_encoder->audio)
746
+ return;
747
+
748
+ nv_encoder->audio = false;
482749 nvif_mthd(&disp->disp->object, 0, &args, sizeof(args));
750
+
751
+ nv50_audio_component_eld_notify(drm->audio.component, nv_encoder->or,
752
+ nv_crtc->index);
483753 }
484754
485755 static void
486
-nv50_audio_enable(struct drm_encoder *encoder, struct drm_display_mode *mode)
756
+nv50_audio_enable(struct drm_encoder *encoder, struct drm_atomic_state *state,
757
+ struct drm_display_mode *mode)
487758 {
759
+ struct nouveau_drm *drm = nouveau_drm(encoder->dev);
488760 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
489761 struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc);
490762 struct nouveau_connector *nv_connector;
....@@ -503,7 +775,7 @@
503775 (0x0100 << nv_crtc->index),
504776 };
505777
506
- nv_connector = nouveau_encoder_connector_get(nv_encoder);
778
+ nv_connector = nv50_outp_get_new_connector(nv_encoder, state);
507779 if (!drm_detect_monitor_audio(nv_connector->edid))
508780 return;
509781
....@@ -511,6 +783,10 @@
511783
512784 nvif_mthd(&disp->disp->object, 0, &args,
513785 sizeof(args.base) + drm_eld_size(args.data));
786
+ nv_encoder->audio = true;
787
+
788
+ nv50_audio_component_eld_notify(drm->audio.component, nv_encoder->or,
789
+ nv_crtc->index);
514790 }
515791
516792 /******************************************************************************
....@@ -536,8 +812,10 @@
536812 }
537813
538814 static void
539
-nv50_hdmi_enable(struct drm_encoder *encoder, struct drm_display_mode *mode)
815
+nv50_hdmi_enable(struct drm_encoder *encoder, struct drm_atomic_state *state,
816
+ struct drm_display_mode *mode)
540817 {
818
+ struct nouveau_drm *drm = nouveau_drm(encoder->dev);
541819 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
542820 struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc);
543821 struct nv50_disp *disp = nv50_disp(encoder->dev);
....@@ -555,18 +833,23 @@
555833 .pwr.rekey = 56, /* binary driver, and tegra, constant */
556834 };
557835 struct nouveau_connector *nv_connector;
836
+ struct drm_hdmi_info *hdmi;
558837 u32 max_ac_packet;
559838 union hdmi_infoframe avi_frame;
560839 union hdmi_infoframe vendor_frame;
840
+ bool high_tmds_clock_ratio = false, scrambling = false;
841
+ u8 config;
561842 int ret;
562843 int size;
563844
564
- nv_connector = nouveau_encoder_connector_get(nv_encoder);
845
+ nv_connector = nv50_outp_get_new_connector(nv_encoder, state);
565846 if (!drm_detect_hdmi_monitor(nv_connector->edid))
566847 return;
567848
568
- ret = drm_hdmi_avi_infoframe_from_display_mode(&avi_frame.avi, mode,
569
- false);
849
+ hdmi = &nv_connector->base.display_info.hdmi;
850
+
851
+ ret = drm_hdmi_avi_infoframe_from_display_mode(&avi_frame.avi,
852
+ &nv_connector->base, mode);
570853 if (!ret) {
571854 /* We have an AVI InfoFrame, populate it to the display */
572855 args.pwr.avi_infoframe_length
....@@ -589,12 +872,42 @@
589872 max_ac_packet -= 18; /* constant from tegra */
590873 args.pwr.max_ac_packet = max_ac_packet / 32;
591874
875
+ if (hdmi->scdc.scrambling.supported) {
876
+ high_tmds_clock_ratio = mode->clock > 340000;
877
+ scrambling = high_tmds_clock_ratio ||
878
+ hdmi->scdc.scrambling.low_rates;
879
+ }
880
+
881
+ args.pwr.scdc =
882
+ NV50_DISP_SOR_HDMI_PWR_V0_SCDC_SCRAMBLE * scrambling |
883
+ NV50_DISP_SOR_HDMI_PWR_V0_SCDC_DIV_BY_4 * high_tmds_clock_ratio;
884
+
592885 size = sizeof(args.base)
593886 + sizeof(args.pwr)
594887 + args.pwr.avi_infoframe_length
595888 + args.pwr.vendor_infoframe_length;
596889 nvif_mthd(&disp->disp->object, 0, &args, size);
597
- nv50_audio_enable(encoder, mode);
890
+
891
+ nv50_audio_enable(encoder, state, mode);
892
+
893
+ /* If SCDC is supported by the downstream monitor, update
894
+ * divider / scrambling settings to what we programmed above.
895
+ */
896
+ if (!hdmi->scdc.scrambling.supported)
897
+ return;
898
+
899
+ ret = drm_scdc_readb(nv_encoder->i2c, SCDC_TMDS_CONFIG, &config);
900
+ if (ret < 0) {
901
+ NV_ERROR(drm, "Failure to read SCDC_TMDS_CONFIG: %d\n", ret);
902
+ return;
903
+ }
904
+ config &= ~(SCDC_TMDS_BIT_CLOCK_RATIO_BY_40 | SCDC_SCRAMBLING_ENABLE);
905
+ config |= SCDC_TMDS_BIT_CLOCK_RATIO_BY_40 * high_tmds_clock_ratio;
906
+ config |= SCDC_SCRAMBLING_ENABLE * scrambling;
907
+ ret = drm_scdc_writeb(nv_encoder->i2c, SCDC_TMDS_CONFIG, config);
908
+ if (ret < 0)
909
+ NV_ERROR(drm, "Failure to write SCDC_TMDS_CONFIG = 0x%02x: %d\n",
910
+ config, ret);
598911 }
599912
600913 /******************************************************************************
....@@ -604,17 +917,6 @@
604917 #define nv50_mstc(p) container_of((p), struct nv50_mstc, connector)
605918 #define nv50_msto(p) container_of((p), struct nv50_msto, encoder)
606919
607
-struct nv50_mstm {
608
- struct nouveau_encoder *outp;
609
-
610
- struct drm_dp_mst_topology_mgr mgr;
611
- struct nv50_msto *msto[4];
612
-
613
- bool modified;
614
- bool disabled;
615
- int links;
616
-};
617
-
618920 struct nv50_mstc {
619921 struct nv50_mstm *mstm;
620922 struct drm_dp_mst_port *port;
....@@ -622,8 +924,6 @@
622924
623925 struct drm_display_mode *native;
624926 struct edid *edid;
625
-
626
- int pbn;
627927 };
628928
629929 struct nv50_msto {
....@@ -634,6 +934,19 @@
634934 bool disabled;
635935 };
636936
937
+struct nouveau_encoder *nv50_real_outp(struct drm_encoder *encoder)
938
+{
939
+ struct nv50_msto *msto;
940
+
941
+ if (encoder->encoder_type != DRM_MODE_ENCODER_DPMST)
942
+ return nouveau_encoder(encoder);
943
+
944
+ msto = nv50_msto(encoder);
945
+ if (!msto->mstc)
946
+ return NULL;
947
+ return msto->mstc->mstm->outp;
948
+}
949
+
637950 static struct drm_dp_payload *
638951 nv50_msto_payload(struct nv50_msto *msto)
639952 {
....@@ -641,6 +954,8 @@
641954 struct nv50_mstc *mstc = msto->mstc;
642955 struct nv50_mstm *mstm = mstc->mstm;
643956 int vcpi = mstc->port->vcpi.vcpi, i;
957
+
958
+ WARN_ON(!mutex_is_locked(&mstm->mgr.payload_lock));
644959
645960 NV_ATOMIC(drm, "%s: vcpi %d\n", msto->encoder.name, vcpi);
646961 for (i = 0; i < mstm->mgr.max_payloads; i++) {
....@@ -666,14 +981,15 @@
666981 struct nv50_mstc *mstc = msto->mstc;
667982 struct nv50_mstm *mstm = mstc->mstm;
668983
984
+ if (!msto->disabled)
985
+ return;
986
+
669987 NV_ATOMIC(drm, "%s: msto cleanup\n", msto->encoder.name);
670
- if (mstc->port && mstc->port->vcpi.vcpi > 0 && !nv50_msto_payload(msto))
671
- drm_dp_mst_deallocate_vcpi(&mstm->mgr, mstc->port);
672
- if (msto->disabled) {
673
- msto->mstc = NULL;
674
- msto->head = NULL;
675
- msto->disabled = false;
676
- }
988
+
989
+ drm_dp_mst_deallocate_vcpi(&mstm->mgr, mstc->port);
990
+
991
+ msto->mstc = NULL;
992
+ msto->disabled = false;
677993 }
678994
679995 static void
....@@ -693,8 +1009,10 @@
6931009 (0x0100 << msto->head->base.index),
6941010 };
6951011
1012
+ mutex_lock(&mstm->mgr.payload_lock);
1013
+
6961014 NV_ATOMIC(drm, "%s: msto prepare\n", msto->encoder.name);
697
- if (mstc->port && mstc->port->vcpi.vcpi > 0) {
1015
+ if (mstc->port->vcpi.vcpi > 0) {
6981016 struct drm_dp_payload *payload = nv50_msto_payload(msto);
6991017 if (payload) {
7001018 args.vcpi.start_slot = payload->start_slot;
....@@ -708,7 +1026,9 @@
7081026 msto->encoder.name, msto->head->base.base.name,
7091027 args.vcpi.start_slot, args.vcpi.num_slots,
7101028 args.vcpi.pbn, args.vcpi.aligned_pbn);
1029
+
7111030 nvif_mthd(&drm->display->disp.object, 0, &args, sizeof(args));
1031
+ mutex_unlock(&mstm->mgr.payload_lock);
7121032 }
7131033
7141034 static int
....@@ -716,32 +1036,67 @@
7161036 struct drm_crtc_state *crtc_state,
7171037 struct drm_connector_state *conn_state)
7181038 {
719
- struct nv50_mstc *mstc = nv50_mstc(conn_state->connector);
1039
+ struct drm_atomic_state *state = crtc_state->state;
1040
+ struct drm_connector *connector = conn_state->connector;
1041
+ struct nv50_mstc *mstc = nv50_mstc(connector);
7201042 struct nv50_mstm *mstm = mstc->mstm;
721
- int bpp = conn_state->connector->display_info.bpc * 3;
1043
+ struct nv50_head_atom *asyh = nv50_head_atom(crtc_state);
7221044 int slots;
1045
+ int ret;
7231046
724
- mstc->pbn = drm_dp_calc_pbn_mode(crtc_state->adjusted_mode.clock, bpp);
1047
+ ret = nv50_outp_atomic_check_view(encoder, crtc_state, conn_state,
1048
+ mstc->native);
1049
+ if (ret)
1050
+ return ret;
7251051
726
- slots = drm_dp_find_vcpi_slots(&mstm->mgr, mstc->pbn);
1052
+ if (!crtc_state->mode_changed && !crtc_state->connectors_changed)
1053
+ return 0;
1054
+
1055
+ /*
1056
+ * When restoring duplicated states, we need to make sure that the bw
1057
+ * remains the same and avoid recalculating it, as the connector's bpc
1058
+ * may have changed after the state was duplicated
1059
+ */
1060
+ if (!state->duplicated) {
1061
+ const int clock = crtc_state->adjusted_mode.clock;
1062
+
1063
+ asyh->or.bpc = connector->display_info.bpc;
1064
+ asyh->dp.pbn = drm_dp_calc_pbn_mode(clock, asyh->or.bpc * 3,
1065
+ false);
1066
+ }
1067
+
1068
+ slots = drm_dp_atomic_find_vcpi_slots(state, &mstm->mgr, mstc->port,
1069
+ asyh->dp.pbn, 0);
7271070 if (slots < 0)
7281071 return slots;
7291072
730
- return nv50_outp_atomic_check_view(encoder, crtc_state, conn_state,
731
- mstc->native);
1073
+ asyh->dp.tu = slots;
1074
+
1075
+ return 0;
1076
+}
1077
+
1078
+static u8
1079
+nv50_dp_bpc_to_depth(unsigned int bpc)
1080
+{
1081
+ switch (bpc) {
1082
+ case 6: return NV837D_SOR_SET_CONTROL_PIXEL_DEPTH_BPP_18_444;
1083
+ case 8: return NV837D_SOR_SET_CONTROL_PIXEL_DEPTH_BPP_24_444;
1084
+ case 10:
1085
+ default: return NV837D_SOR_SET_CONTROL_PIXEL_DEPTH_BPP_30_444;
1086
+ }
7321087 }
7331088
7341089 static void
735
-nv50_msto_enable(struct drm_encoder *encoder)
1090
+nv50_msto_enable(struct drm_encoder *encoder, struct drm_atomic_state *state)
7361091 {
7371092 struct nv50_head *head = nv50_head(encoder->crtc);
1093
+ struct nv50_head_atom *armh = nv50_head_atom(head->base.base.state);
7381094 struct nv50_msto *msto = nv50_msto(encoder);
7391095 struct nv50_mstc *mstc = NULL;
7401096 struct nv50_mstm *mstm = NULL;
7411097 struct drm_connector *connector;
7421098 struct drm_connector_list_iter conn_iter;
743
- u8 proto, depth;
744
- int slots;
1099
+ u8 proto;
7451100 bool r;
7461101
7471102 drm_connector_list_iter_begin(encoder->dev, &conn_iter);
....@@ -757,43 +1112,34 @@
7571112 if (WARN_ON(!mstc))
7581113 return;
7591114
760
- slots = drm_dp_find_vcpi_slots(&mstm->mgr, mstc->pbn);
761
- r = drm_dp_mst_allocate_vcpi(&mstm->mgr, mstc->port, mstc->pbn, slots);
1115
+ r = drm_dp_mst_allocate_vcpi(&mstm->mgr, mstc->port, armh->dp.pbn,
1116
+ armh->dp.tu);
7621117 if (!r)
7631118 DRM_DEBUG_KMS("Failed to allocate VCPI\n");
7641119
7651120 if (!mstm->links++)
766
- nv50_outp_acquire(mstm->outp);
1121
+ nv50_outp_acquire(mstm->outp, false /*XXX: MST audio.*/);
7671122
7681123 if (mstm->outp->link & 1)
769
- proto = 0x8;
1124
+ proto = NV917D_SOR_SET_CONTROL_PROTOCOL_DP_A;
7701125 else
771
- proto = 0x9;
1126
+ proto = NV917D_SOR_SET_CONTROL_PROTOCOL_DP_B;
7721127
773
- switch (mstc->connector.display_info.bpc) {
774
- case 6: depth = 0x2; break;
775
- case 8: depth = 0x5; break;
776
- case 10:
777
- default: depth = 0x6; break;
778
- }
1128
+ mstm->outp->update(mstm->outp, head->base.index, armh, proto,
1129
+ nv50_dp_bpc_to_depth(armh->or.bpc));
7791130
780
- mstm->outp->update(mstm->outp, head->base.index,
781
- nv50_head_atom(head->base.base.state), proto, depth);
782
-
783
- msto->head = head;
7841131 msto->mstc = mstc;
7851132 mstm->modified = true;
7861133 }
7871134
7881135 static void
789
-nv50_msto_disable(struct drm_encoder *encoder)
1136
+nv50_msto_disable(struct drm_encoder *encoder, struct drm_atomic_state *state)
7901137 {
7911138 struct nv50_msto *msto = nv50_msto(encoder);
7921139 struct nv50_mstc *mstc = msto->mstc;
7931140 struct nv50_mstm *mstm = mstc->mstm;
7941141
795
- if (mstc->port)
796
- drm_dp_mst_reset_vcpi_slots(&mstm->mgr, mstc->port);
1142
+ drm_dp_mst_reset_vcpi_slots(&mstm->mgr, mstc->port);
7971143
7981144 mstm->outp->update(mstm->outp, msto->head->base.index, NULL, 0, 0);
7991145 mstm->modified = true;
....@@ -804,8 +1150,8 @@
8041150
8051151 static const struct drm_encoder_helper_funcs
8061152 nv50_msto_help = {
807
- .disable = nv50_msto_disable,
808
- .enable = nv50_msto_enable,
1153
+ .atomic_disable = nv50_msto_disable,
1154
+ .atomic_enable = nv50_msto_enable,
8091155 .atomic_check = nv50_msto_atomic_check,
8101156 };
8111157
....@@ -822,52 +1168,54 @@
8221168 .destroy = nv50_msto_destroy,
8231169 };
8241170
825
-static int
826
-nv50_msto_new(struct drm_device *dev, u32 heads, const char *name, int id,
827
- struct nv50_msto **pmsto)
1171
+static struct nv50_msto *
1172
+nv50_msto_new(struct drm_device *dev, struct nv50_head *head, int id)
8281173 {
8291174 struct nv50_msto *msto;
8301175 int ret;
8311176
832
- if (!(msto = *pmsto = kzalloc(sizeof(*msto), GFP_KERNEL)))
833
- return -ENOMEM;
1177
+ msto = kzalloc(sizeof(*msto), GFP_KERNEL);
1178
+ if (!msto)
1179
+ return ERR_PTR(-ENOMEM);
8341180
8351181 ret = drm_encoder_init(dev, &msto->encoder, &nv50_msto,
836
- DRM_MODE_ENCODER_DPMST, "%s-mst-%d", name, id);
1182
+ DRM_MODE_ENCODER_DPMST, "mst-%d", id);
8371183 if (ret) {
838
- kfree(*pmsto);
839
- *pmsto = NULL;
840
- return ret;
1184
+ kfree(msto);
1185
+ return ERR_PTR(ret);
8411186 }
8421187
8431188 drm_encoder_helper_add(&msto->encoder, &nv50_msto_help);
844
- msto->encoder.possible_crtcs = heads;
845
- return 0;
1189
+ msto->encoder.possible_crtcs = drm_crtc_mask(&head->base.base);
1190
+ msto->head = head;
1191
+ return msto;
8461192 }
8471193
8481194 static struct drm_encoder *
8491195 nv50_mstc_atomic_best_encoder(struct drm_connector *connector,
8501196 struct drm_connector_state *connector_state)
8511197 {
852
- struct nv50_head *head = nv50_head(connector_state->crtc);
8531198 struct nv50_mstc *mstc = nv50_mstc(connector);
1199
+ struct drm_crtc *crtc = connector_state->crtc;
8541200
855
- return &mstc->mstm->msto[head->base.index]->encoder;
856
-}
1201
+ if (!(mstc->mstm->outp->dcb->heads & drm_crtc_mask(crtc)))
1202
+ return NULL;
8571203
858
-static struct drm_encoder *
859
-nv50_mstc_best_encoder(struct drm_connector *connector)
860
-{
861
- struct nv50_mstc *mstc = nv50_mstc(connector);
862
-
863
- return &mstc->mstm->msto[0]->encoder;
1204
+ return &nv50_head(crtc)->msto->encoder;
8641205 }
8651206
8661207 static enum drm_mode_status
8671208 nv50_mstc_mode_valid(struct drm_connector *connector,
8681209 struct drm_display_mode *mode)
8691210 {
870
- return MODE_OK;
1211
+ struct nv50_mstc *mstc = nv50_mstc(connector);
1212
+ struct nouveau_encoder *outp = mstc->mstm->outp;
1213
+
1214
+ /* TODO: calculate the PBN from the dotclock and validate against the
1215
+ * MSTB's max possible PBN
1216
+ */
1217
+
1218
+ return nv50_dp_mode_valid(connector, outp, mode, NULL);
8711219 }
8721220
8731221 static int
....@@ -881,8 +1229,17 @@
8811229 if (mstc->edid)
8821230 ret = drm_add_edid_modes(&mstc->connector, mstc->edid);
8831231
884
- if (!mstc->connector.display_info.bpc)
885
- mstc->connector.display_info.bpc = 8;
1232
+ /*
1233
+ * XXX: Since we don't use HDR in userspace quite yet, limit the bpc
1234
+ * to 8 to save bandwidth on the topology. In the future, we'll want
1235
+ * to properly fix this by dynamically selecting the highest possible
1236
+ * bpc that would fit in the topology
1237
+ */
1238
+ if (connector->display_info.bpc)
1239
+ connector->display_info.bpc =
1240
+ clamp(connector->display_info.bpc, 6U, 8U);
1241
+ else
1242
+ connector->display_info.bpc = 8;
8861243
8871244 if (mstc->native)
8881245 drm_mode_destroy(mstc->connector.dev, mstc->native);
....@@ -890,22 +1247,45 @@
8901247 return ret;
8911248 }
8921249
893
-static const struct drm_connector_helper_funcs
894
-nv50_mstc_help = {
895
- .get_modes = nv50_mstc_get_modes,
896
- .mode_valid = nv50_mstc_mode_valid,
897
- .best_encoder = nv50_mstc_best_encoder,
898
- .atomic_best_encoder = nv50_mstc_atomic_best_encoder,
899
-};
900
-
901
-static enum drm_connector_status
902
-nv50_mstc_detect(struct drm_connector *connector, bool force)
1250
+static int
1251
+nv50_mstc_atomic_check(struct drm_connector *connector,
1252
+ struct drm_atomic_state *state)
9031253 {
9041254 struct nv50_mstc *mstc = nv50_mstc(connector);
905
- enum drm_connector_status conn_status;
1255
+ struct drm_dp_mst_topology_mgr *mgr = &mstc->mstm->mgr;
1256
+ struct drm_connector_state *new_conn_state =
1257
+ drm_atomic_get_new_connector_state(state, connector);
1258
+ struct drm_connector_state *old_conn_state =
1259
+ drm_atomic_get_old_connector_state(state, connector);
1260
+ struct drm_crtc_state *crtc_state;
1261
+ struct drm_crtc *new_crtc = new_conn_state->crtc;
1262
+
1263
+ if (!old_conn_state->crtc)
1264
+ return 0;
1265
+
1266
+ /* We only want to free VCPI if this state disables the CRTC on this
1267
+ * connector
1268
+ */
1269
+ if (new_crtc) {
1270
+ crtc_state = drm_atomic_get_new_crtc_state(state, new_crtc);
1271
+
1272
+ if (!crtc_state ||
1273
+ !drm_atomic_crtc_needs_modeset(crtc_state) ||
1274
+ crtc_state->enable)
1275
+ return 0;
1276
+ }
1277
+
1278
+ return drm_dp_atomic_release_vcpi_slots(state, mgr, mstc->port);
1279
+}
1280
+
1281
+static int
1282
+nv50_mstc_detect(struct drm_connector *connector,
1283
+ struct drm_modeset_acquire_ctx *ctx, bool force)
1284
+{
1285
+ struct nv50_mstc *mstc = nv50_mstc(connector);
9061286 int ret;
9071287
908
- if (!mstc->port)
1288
+ if (drm_connector_is_unregistered(connector))
9091289 return connector_status_disconnected;
9101290
9111291 ret = pm_runtime_get_sync(connector->dev->dev);
....@@ -914,26 +1294,40 @@
9141294 return connector_status_disconnected;
9151295 }
9161296
917
- conn_status = drm_dp_mst_detect_port(connector, mstc->port->mgr,
918
- mstc->port);
1297
+ ret = drm_dp_mst_detect_port(connector, ctx, mstc->port->mgr,
1298
+ mstc->port);
1299
+ if (ret != connector_status_connected)
1300
+ goto out;
9191301
1302
+out:
9201303 pm_runtime_mark_last_busy(connector->dev->dev);
9211304 pm_runtime_put_autosuspend(connector->dev->dev);
922
- return conn_status;
1305
+ return ret;
9231306 }
1307
+
1308
+static const struct drm_connector_helper_funcs
1309
+nv50_mstc_help = {
1310
+ .get_modes = nv50_mstc_get_modes,
1311
+ .mode_valid = nv50_mstc_mode_valid,
1312
+ .atomic_best_encoder = nv50_mstc_atomic_best_encoder,
1313
+ .atomic_check = nv50_mstc_atomic_check,
1314
+ .detect_ctx = nv50_mstc_detect,
1315
+};
9241316
9251317 static void
9261318 nv50_mstc_destroy(struct drm_connector *connector)
9271319 {
9281320 struct nv50_mstc *mstc = nv50_mstc(connector);
1321
+
9291322 drm_connector_cleanup(&mstc->connector);
1323
+ drm_dp_mst_put_port_malloc(mstc->port);
1324
+
9301325 kfree(mstc);
9311326 }
9321327
9331328 static const struct drm_connector_funcs
9341329 nv50_mstc = {
9351330 .reset = nouveau_conn_reset,
936
- .detect = nv50_mstc_detect,
9371331 .fill_modes = drm_helper_probe_single_connector_modes,
9381332 .destroy = nv50_mstc_destroy,
9391333 .atomic_duplicate_state = nouveau_conn_atomic_duplicate_state,
....@@ -947,8 +1341,9 @@
9471341 const char *path, struct nv50_mstc **pmstc)
9481342 {
9491343 struct drm_device *dev = mstm->outp->base.base.dev;
1344
+ struct drm_crtc *crtc;
9501345 struct nv50_mstc *mstc;
951
- int ret, i;
1346
+ int ret;
9521347
9531348 if (!(mstc = *pmstc = kzalloc(sizeof(*mstc), GFP_KERNEL)))
9541349 return -ENOMEM;
....@@ -968,12 +1363,18 @@
9681363 mstc->connector.funcs->reset(&mstc->connector);
9691364 nouveau_conn_attach_properties(&mstc->connector);
9701365
971
- for (i = 0; i < ARRAY_SIZE(mstm->msto) && mstm->msto[i]; i++)
972
- drm_connector_attach_encoder(&mstc->connector, &mstm->msto[i]->encoder);
1366
+ drm_for_each_crtc(crtc, dev) {
1367
+ if (!(mstm->outp->dcb->heads & drm_crtc_mask(crtc)))
1368
+ continue;
1369
+
1370
+ drm_connector_attach_encoder(&mstc->connector,
1371
+ &nv50_head(crtc)->msto->encoder);
1372
+ }
9731373
9741374 drm_object_attach_property(&mstc->connector.base, dev->mode_config.path_property, 0);
9751375 drm_object_attach_property(&mstc->connector.base, dev->mode_config.tile_property, 0);
9761376 drm_connector_set_path_property(&mstc->connector, path);
1377
+ drm_dp_mst_get_port_malloc(port);
9771378 return 0;
9781379 }
9791380
....@@ -1027,41 +1428,6 @@
10271428 }
10281429 }
10291430
1030
-static void
1031
-nv50_mstm_hotplug(struct drm_dp_mst_topology_mgr *mgr)
1032
-{
1033
- struct nv50_mstm *mstm = nv50_mstm(mgr);
1034
- drm_kms_helper_hotplug_event(mstm->outp->base.base.dev);
1035
-}
1036
-
1037
-static void
1038
-nv50_mstm_destroy_connector(struct drm_dp_mst_topology_mgr *mgr,
1039
- struct drm_connector *connector)
1040
-{
1041
- struct nouveau_drm *drm = nouveau_drm(connector->dev);
1042
- struct nv50_mstc *mstc = nv50_mstc(connector);
1043
-
1044
- drm_connector_unregister(&mstc->connector);
1045
-
1046
- drm_fb_helper_remove_one_connector(&drm->fbcon->helper, &mstc->connector);
1047
-
1048
- drm_modeset_lock(&drm->dev->mode_config.connection_mutex, NULL);
1049
- mstc->port = NULL;
1050
- drm_modeset_unlock(&drm->dev->mode_config.connection_mutex);
1051
-
1052
- drm_connector_put(&mstc->connector);
1053
-}
1054
-
1055
-static void
1056
-nv50_mstm_register_connector(struct drm_connector *connector)
1057
-{
1058
- struct nouveau_drm *drm = nouveau_drm(connector->dev);
1059
-
1060
- drm_fb_helper_add_one_connector(&drm->fbcon->helper, connector);
1061
-
1062
- drm_connector_register(connector);
1063
-}
1064
-
10651431 static struct drm_connector *
10661432 nv50_mstm_add_connector(struct drm_dp_mst_topology_mgr *mgr,
10671433 struct drm_dp_mst_port *port, const char *path)
....@@ -1071,11 +1437,8 @@
10711437 int ret;
10721438
10731439 ret = nv50_mstc_new(mstm, port, path, &mstc);
1074
- if (ret) {
1075
- if (mstc)
1076
- mstc->connector.funcs->destroy(&mstc->connector);
1440
+ if (ret)
10771441 return NULL;
1078
- }
10791442
10801443 return &mstc->connector;
10811444 }
....@@ -1083,46 +1446,53 @@
10831446 static const struct drm_dp_mst_topology_cbs
10841447 nv50_mstm = {
10851448 .add_connector = nv50_mstm_add_connector,
1086
- .register_connector = nv50_mstm_register_connector,
1087
- .destroy_connector = nv50_mstm_destroy_connector,
1088
- .hotplug = nv50_mstm_hotplug,
10891449 };
10901450
1091
-void
1092
-nv50_mstm_service(struct nv50_mstm *mstm)
1451
+bool
1452
+nv50_mstm_service(struct nouveau_drm *drm,
1453
+ struct nouveau_connector *nv_connector,
1454
+ struct nv50_mstm *mstm)
10931455 {
1094
- struct drm_dp_aux *aux = mstm ? mstm->mgr.aux : NULL;
1095
- bool handled = true;
1096
- int ret;
1456
+ struct drm_dp_aux *aux = &nv_connector->aux;
1457
+ bool handled = true, ret = true;
1458
+ int rc;
10971459 u8 esi[8] = {};
10981460
1099
- if (!aux)
1100
- return;
1101
-
11021461 while (handled) {
1103
- ret = drm_dp_dpcd_read(aux, DP_SINK_COUNT_ESI, esi, 8);
1104
- if (ret != 8) {
1105
- drm_dp_mst_topology_mgr_set_mst(&mstm->mgr, false);
1106
- return;
1462
+ rc = drm_dp_dpcd_read(aux, DP_SINK_COUNT_ESI, esi, 8);
1463
+ if (rc != 8) {
1464
+ ret = false;
1465
+ break;
11071466 }
11081467
11091468 drm_dp_mst_hpd_irq(&mstm->mgr, esi, &handled);
11101469 if (!handled)
11111470 break;
11121471
1113
- drm_dp_dpcd_write(aux, DP_SINK_COUNT_ESI + 1, &esi[1], 3);
1472
+ rc = drm_dp_dpcd_write(aux, DP_SINK_COUNT_ESI + 1, &esi[1],
1473
+ 3);
1474
+ if (rc != 3) {
1475
+ ret = false;
1476
+ break;
1477
+ }
11141478 }
1479
+
1480
+ if (!ret)
1481
+ NV_DEBUG(drm, "Failed to handle ESI on %s: %d\n",
1482
+ nv_connector->base.name, rc);
1483
+
1484
+ return ret;
11151485 }
11161486
11171487 void
11181488 nv50_mstm_remove(struct nv50_mstm *mstm)
11191489 {
1120
- if (mstm)
1121
- drm_dp_mst_topology_mgr_set_mst(&mstm->mgr, false);
1490
+ mstm->is_mst = false;
1491
+ drm_dp_mst_topology_mgr_set_mst(&mstm->mgr, false);
11221492 }
11231493
11241494 static int
1125
-nv50_mstm_enable(struct nv50_mstm *mstm, u8 dpcd, int state)
1495
+nv50_mstm_enable(struct nv50_mstm *mstm, int state)
11261496 {
11271497 struct nouveau_encoder *outp = mstm->outp;
11281498 struct {
....@@ -1137,106 +1507,85 @@
11371507 };
11381508 struct nouveau_drm *drm = nouveau_drm(outp->base.base.dev);
11391509 struct nvif_object *disp = &drm->display->disp.object;
1140
- int ret;
1141
-
1142
- if (dpcd >= 0x12) {
1143
- /* Even if we're enabling MST, start with disabling the
1144
- * branching unit to clear any sink-side MST topology state
1145
- * that wasn't set by us
1146
- */
1147
- ret = drm_dp_dpcd_writeb(mstm->mgr.aux, DP_MSTM_CTRL, 0);
1148
- if (ret < 0)
1149
- return ret;
1150
-
1151
- if (state) {
1152
- /* Now, start initializing */
1153
- ret = drm_dp_dpcd_writeb(mstm->mgr.aux, DP_MSTM_CTRL,
1154
- DP_MST_EN);
1155
- if (ret < 0)
1156
- return ret;
1157
- }
1158
- }
11591510
11601511 return nvif_mthd(disp, 0, &args, sizeof(args));
11611512 }
11621513
11631514 int
1164
-nv50_mstm_detect(struct nv50_mstm *mstm, u8 dpcd[8], int allow)
1515
+nv50_mstm_detect(struct nouveau_encoder *outp)
11651516 {
1517
+ struct nv50_mstm *mstm = outp->dp.mstm;
11661518 struct drm_dp_aux *aux;
11671519 int ret;
1168
- bool old_state, new_state;
1169
- u8 mstm_ctrl;
11701520
1171
- if (!mstm)
1521
+ if (!mstm || !mstm->can_mst)
11721522 return 0;
11731523
1174
- mutex_lock(&mstm->mgr.lock);
1175
-
1176
- old_state = mstm->mgr.mst_state;
1177
- new_state = old_state;
11781524 aux = mstm->mgr.aux;
11791525
1180
- if (old_state) {
1181
- /* Just check that the MST hub is still as we expect it */
1182
- ret = drm_dp_dpcd_readb(aux, DP_MSTM_CTRL, &mstm_ctrl);
1183
- if (ret < 0 || !(mstm_ctrl & DP_MST_EN)) {
1184
- DRM_DEBUG_KMS("Hub gone, disabling MST topology\n");
1185
- new_state = false;
1186
- }
1187
- } else if (dpcd[0] >= 0x12) {
1188
- ret = drm_dp_dpcd_readb(aux, DP_MSTM_CAP, &dpcd[1]);
1189
- if (ret < 0)
1190
- goto probe_error;
1526
+ /* Clear any leftover MST state we didn't set ourselves by first
1527
+ * disabling MST if it was already enabled
1528
+ */
1529
+ ret = drm_dp_dpcd_writeb(aux, DP_MSTM_CTRL, 0);
1530
+ if (ret < 0)
1531
+ return ret;
11911532
1192
- if (!(dpcd[1] & DP_MST_CAP))
1193
- dpcd[0] = 0x11;
1194
- else
1195
- new_state = allow;
1533
+ /* And start enabling */
1534
+ ret = nv50_mstm_enable(mstm, true);
1535
+ if (ret)
1536
+ return ret;
1537
+
1538
+ ret = drm_dp_mst_topology_mgr_set_mst(&mstm->mgr, true);
1539
+ if (ret) {
1540
+ nv50_mstm_enable(mstm, false);
1541
+ return ret;
11961542 }
11971543
1198
- if (new_state == old_state) {
1199
- mutex_unlock(&mstm->mgr.lock);
1200
- return new_state;
1201
- }
1202
-
1203
- ret = nv50_mstm_enable(mstm, dpcd[0], new_state);
1204
- if (ret)
1205
- goto probe_error;
1206
-
1207
- mutex_unlock(&mstm->mgr.lock);
1208
-
1209
- ret = drm_dp_mst_topology_mgr_set_mst(&mstm->mgr, new_state);
1210
- if (ret)
1211
- return nv50_mstm_enable(mstm, dpcd[0], 0);
1212
-
1213
- return new_state;
1214
-
1215
-probe_error:
1216
- mutex_unlock(&mstm->mgr.lock);
1217
- return ret;
1544
+ mstm->is_mst = true;
1545
+ return 1;
12181546 }
12191547
12201548 static void
1221
-nv50_mstm_fini(struct nv50_mstm *mstm)
1549
+nv50_mstm_fini(struct nouveau_encoder *outp)
12221550 {
1223
- if (mstm && mstm->mgr.mst_state)
1551
+ struct nv50_mstm *mstm = outp->dp.mstm;
1552
+
1553
+ if (!mstm)
1554
+ return;
1555
+
1556
+ /* Don't change the MST state of this connector until we've finished
1557
+ * resuming, since we can't safely grab hpd_irq_lock in our resume
1558
+ * path to protect mstm->is_mst without potentially deadlocking
1559
+ */
1560
+ mutex_lock(&outp->dp.hpd_irq_lock);
1561
+ mstm->suspended = true;
1562
+ mutex_unlock(&outp->dp.hpd_irq_lock);
1563
+
1564
+ if (mstm->is_mst)
12241565 drm_dp_mst_topology_mgr_suspend(&mstm->mgr);
12251566 }
12261567
12271568 static void
1228
-nv50_mstm_init(struct nv50_mstm *mstm)
1569
+nv50_mstm_init(struct nouveau_encoder *outp, bool runtime)
12291570 {
1230
- int ret;
1571
+ struct nv50_mstm *mstm = outp->dp.mstm;
1572
+ int ret = 0;
12311573
1232
- if (!mstm || !mstm->mgr.mst_state)
1574
+ if (!mstm)
12331575 return;
12341576
1235
- ret = drm_dp_mst_topology_mgr_resume(&mstm->mgr);
1236
- if (ret == -1) {
1237
- drm_dp_mst_topology_mgr_set_mst(&mstm->mgr, false);
1238
- drm_kms_helper_hotplug_event(mstm->mgr.dev);
1577
+ if (mstm->is_mst) {
1578
+ ret = drm_dp_mst_topology_mgr_resume(&mstm->mgr, !runtime);
1579
+ if (ret == -1)
1580
+ nv50_mstm_remove(mstm);
12391581 }
1582
+
1583
+ mutex_lock(&outp->dp.hpd_irq_lock);
1584
+ mstm->suspended = false;
1585
+ mutex_unlock(&outp->dp.hpd_irq_lock);
1586
+
1587
+ if (ret == -1)
1588
+ drm_kms_helper_hotplug_event(mstm->mgr.dev);
12401589 }
12411590
12421591 static void
....@@ -1257,18 +1606,7 @@
12571606 const int max_payloads = hweight8(outp->dcb->heads);
12581607 struct drm_device *dev = outp->base.base.dev;
12591608 struct nv50_mstm *mstm;
1260
- int ret, i;
1261
- u8 dpcd;
1262
-
1263
- /* This is a workaround for some monitors not functioning
1264
- * correctly in MST mode on initial module load. I think
1265
- * some bad interaction with the VBIOS may be responsible.
1266
- *
1267
- * A good ol' off and on again seems to work here ;)
1268
- */
1269
- ret = drm_dp_dpcd_readb(aux, DP_DPCD_REV, &dpcd);
1270
- if (ret >= 0 && dpcd >= 0x12)
1271
- drm_dp_dpcd_writeb(aux, DP_MSTM_CTRL, 0);
1609
+ int ret;
12721610
12731611 if (!(mstm = *pmstm = kzalloc(sizeof(*mstm), GFP_KERNEL)))
12741612 return -ENOMEM;
....@@ -1279,13 +1617,6 @@
12791617 max_payloads, conn_base_id);
12801618 if (ret)
12811619 return ret;
1282
-
1283
- for (i = 0; i < max_payloads; i++) {
1284
- ret = nv50_msto_new(dev, outp->dcb->heads, outp->base.base.name,
1285
- i, &mstm->msto[i]);
1286
- if (ret)
1287
- return ret;
1288
- }
12891620
12901621 return 0;
12911622 }
....@@ -1302,10 +1633,10 @@
13021633
13031634 if (!asyh) {
13041635 nv_encoder->ctrl &= ~BIT(head);
1305
- if (!(nv_encoder->ctrl & 0x0000000f))
1636
+ if (NVDEF_TEST(nv_encoder->ctrl, NV507D, SOR_SET_CONTROL, OWNER, ==, NONE))
13061637 nv_encoder->ctrl = 0;
13071638 } else {
1308
- nv_encoder->ctrl |= proto << 8;
1639
+ nv_encoder->ctrl |= NVVAL(NV507D, SOR_SET_CONTROL, PROTOCOL, proto);
13091640 nv_encoder->ctrl |= BIT(head);
13101641 asyh->or.depth = depth;
13111642 }
....@@ -1314,23 +1645,27 @@
13141645 }
13151646
13161647 static void
1317
-nv50_sor_disable(struct drm_encoder *encoder)
1648
+nv50_sor_disable(struct drm_encoder *encoder,
1649
+ struct drm_atomic_state *state)
13181650 {
13191651 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
13201652 struct nouveau_crtc *nv_crtc = nouveau_crtc(nv_encoder->crtc);
1653
+ struct nouveau_connector *nv_connector =
1654
+ nv50_outp_get_old_connector(nv_encoder, state);
13211655
13221656 nv_encoder->crtc = NULL;
13231657
13241658 if (nv_crtc) {
1325
- struct nvkm_i2c_aux *aux = nv_encoder->aux;
1659
+ struct drm_dp_aux *aux = &nv_connector->aux;
13261660 u8 pwr;
13271661
1328
- if (aux) {
1329
- int ret = nvkm_rdaux(aux, DP_SET_POWER, &pwr, 1);
1662
+ if (nv_encoder->dcb->type == DCB_OUTPUT_DP) {
1663
+ int ret = drm_dp_dpcd_readb(aux, DP_SET_POWER, &pwr);
1664
+
13301665 if (ret == 0) {
13311666 pwr &= ~DP_SET_POWER_MASK;
13321667 pwr |= DP_SET_POWER_D3;
1333
- nvkm_wraux(aux, DP_SET_POWER, &pwr, 1);
1668
+ drm_dp_dpcd_writeb(aux, DP_SET_POWER, pwr);
13341669 }
13351670 }
13361671
....@@ -1342,7 +1677,7 @@
13421677 }
13431678
13441679 static void
1345
-nv50_sor_enable(struct drm_encoder *encoder)
1680
+nv50_sor_enable(struct drm_encoder *encoder, struct drm_atomic_state *state)
13461681 {
13471682 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
13481683 struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc);
....@@ -1362,17 +1697,23 @@
13621697 struct nouveau_drm *drm = nouveau_drm(dev);
13631698 struct nouveau_connector *nv_connector;
13641699 struct nvbios *bios = &drm->vbios;
1365
- u8 proto = 0xf;
1366
- u8 depth = 0x0;
1700
+ bool hda = false;
1701
+ u8 proto = NV507D_SOR_SET_CONTROL_PROTOCOL_CUSTOM;
1702
+ u8 depth = NV837D_SOR_SET_CONTROL_PIXEL_DEPTH_DEFAULT;
13671703
1368
- nv_connector = nouveau_encoder_connector_get(nv_encoder);
1704
+ nv_connector = nv50_outp_get_new_connector(nv_encoder, state);
13691705 nv_encoder->crtc = encoder->crtc;
1370
- nv50_outp_acquire(nv_encoder);
1706
+
1707
+ if ((disp->disp->object.oclass == GT214_DISP ||
1708
+ disp->disp->object.oclass >= GF110_DISP) &&
1709
+ drm_detect_monitor_audio(nv_connector->edid))
1710
+ hda = true;
1711
+ nv50_outp_acquire(nv_encoder, hda);
13711712
13721713 switch (nv_encoder->dcb->type) {
13731714 case DCB_OUTPUT_TMDS:
13741715 if (nv_encoder->link & 1) {
1375
- proto = 0x1;
1716
+ proto = NV507D_SOR_SET_CONTROL_PROTOCOL_SINGLE_TMDS_A;
13761717 /* Only enable dual-link if:
13771718 * - Need to (i.e. rate > 165MHz)
13781719 * - DCB says we can
....@@ -1382,15 +1723,15 @@
13821723 if (mode->clock >= 165000 &&
13831724 nv_encoder->dcb->duallink_possible &&
13841725 !drm_detect_hdmi_monitor(nv_connector->edid))
1385
- proto |= 0x4;
1726
+ proto = NV507D_SOR_SET_CONTROL_PROTOCOL_DUAL_TMDS;
13861727 } else {
1387
- proto = 0x2;
1728
+ proto = NV507D_SOR_SET_CONTROL_PROTOCOL_SINGLE_TMDS_B;
13881729 }
13891730
1390
- nv50_hdmi_enable(&nv_encoder->base.base, mode);
1731
+ nv50_hdmi_enable(&nv_encoder->base.base, state, mode);
13911732 break;
13921733 case DCB_OUTPUT_LVDS:
1393
- proto = 0x0;
1734
+ proto = NV507D_SOR_SET_CONTROL_PROTOCOL_LVDS_CUSTOM;
13941735
13951736 if (bios->fp_no_ddc) {
13961737 if (bios->fp.dual_link)
....@@ -1414,27 +1755,21 @@
14141755 lvds.lvds.script |= 0x0200;
14151756 }
14161757
1417
- if (nv_connector->base.display_info.bpc == 8)
1758
+ if (asyh->or.bpc == 8)
14181759 lvds.lvds.script |= 0x0200;
14191760 }
14201761
14211762 nvif_mthd(&disp->disp->object, 0, &lvds, sizeof(lvds));
14221763 break;
14231764 case DCB_OUTPUT_DP:
1424
- if (nv_connector->base.display_info.bpc == 6)
1425
- depth = 0x2;
1426
- else
1427
- if (nv_connector->base.display_info.bpc == 8)
1428
- depth = 0x5;
1429
- else
1430
- depth = 0x6;
1765
+ depth = nv50_dp_bpc_to_depth(asyh->or.bpc);
14311766
14321767 if (nv_encoder->link & 1)
1433
- proto = 0x8;
1768
+ proto = NV887D_SOR_SET_CONTROL_PROTOCOL_DP_A;
14341769 else
1435
- proto = 0x9;
1770
+ proto = NV887D_SOR_SET_CONTROL_PROTOCOL_DP_B;
14361771
1437
- nv50_audio_enable(encoder, mode);
1772
+ nv50_audio_enable(encoder, state, mode);
14381773 break;
14391774 default:
14401775 BUG();
....@@ -1447,8 +1782,8 @@
14471782 static const struct drm_encoder_helper_funcs
14481783 nv50_sor_help = {
14491784 .atomic_check = nv50_outp_atomic_check,
1450
- .enable = nv50_sor_enable,
1451
- .disable = nv50_sor_disable,
1785
+ .atomic_enable = nv50_sor_enable,
1786
+ .atomic_disable = nv50_sor_disable,
14521787 };
14531788
14541789 static void
....@@ -1457,6 +1792,10 @@
14571792 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
14581793 nv50_mstm_del(&nv_encoder->dp.mstm);
14591794 drm_encoder_cleanup(encoder);
1795
+
1796
+ if (nv_encoder->dcb->type == DCB_OUTPUT_DP)
1797
+ mutex_destroy(&nv_encoder->dp.hpd_irq_lock);
1798
+
14601799 kfree(encoder);
14611800 }
14621801
....@@ -1465,17 +1804,25 @@
14651804 .destroy = nv50_sor_destroy,
14661805 };
14671806
1807
+static bool nv50_has_mst(struct nouveau_drm *drm)
1808
+{
1809
+ struct nvkm_bios *bios = nvxx_bios(&drm->client.device);
1810
+ u32 data;
1811
+ u8 ver, hdr, cnt, len;
1812
+
1813
+ data = nvbios_dp_table(bios, &ver, &hdr, &cnt, &len);
1814
+ return data && ver >= 0x40 && (nvbios_rd08(bios, data + 0x08) & 0x04);
1815
+}
1816
+
14681817 static int
14691818 nv50_sor_create(struct drm_connector *connector, struct dcb_output *dcbe)
14701819 {
14711820 struct nouveau_connector *nv_connector = nouveau_connector(connector);
14721821 struct nouveau_drm *drm = nouveau_drm(connector->dev);
1473
- struct nvkm_bios *bios = nvxx_bios(&drm->client.device);
14741822 struct nvkm_i2c *i2c = nvxx_i2c(&drm->client.device);
14751823 struct nouveau_encoder *nv_encoder;
14761824 struct drm_encoder *encoder;
1477
- u8 ver, hdr, cnt, len;
1478
- u32 data;
1825
+ struct nv50_disp *disp = nv50_disp(connector->dev);
14791826 int type, ret;
14801827
14811828 switch (dcbe->type) {
....@@ -1502,10 +1849,14 @@
15021849
15031850 drm_connector_attach_encoder(connector, encoder);
15041851
1852
+ disp->core->func->sor->get_caps(disp, nv_encoder, ffs(dcbe->or) - 1);
1853
+
15051854 if (dcbe->type == DCB_OUTPUT_DP) {
1506
- struct nv50_disp *disp = nv50_disp(encoder->dev);
15071855 struct nvkm_i2c_aux *aux =
15081856 nvkm_i2c_aux_find(i2c, dcbe->i2c_index);
1857
+
1858
+ mutex_init(&nv_encoder->dp.hpd_irq_lock);
1859
+
15091860 if (aux) {
15101861 if (disp->disp->object.oclass < GF110_DISP) {
15111862 /* HW has no support for address-only
....@@ -1520,10 +1871,9 @@
15201871 }
15211872
15221873 if (nv_connector->type != DCB_CONNECTOR_eDP &&
1523
- (data = nvbios_dp_table(bios, &ver, &hdr, &cnt, &len)) &&
1524
- ver >= 0x40 && (nvbios_rd08(bios, data + 0x08) & 0x04)) {
1525
- ret = nv50_mstm_new(nv_encoder, &nv_connector->aux, 16,
1526
- nv_connector->base.base.id,
1874
+ nv50_has_mst(drm)) {
1875
+ ret = nv50_mstm_new(nv_encoder, &nv_connector->aux,
1876
+ 16, nv_connector->base.base.id,
15271877 &nv_encoder->dp.mstm);
15281878 if (ret)
15291879 return ret;
....@@ -1554,56 +1904,62 @@
15541904 }
15551905
15561906 static void
1557
-nv50_pior_disable(struct drm_encoder *encoder)
1907
+nv50_pior_disable(struct drm_encoder *encoder, struct drm_atomic_state *state)
15581908 {
15591909 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
15601910 struct nv50_core *core = nv50_disp(encoder->dev)->core;
1911
+ const u32 ctrl = NVDEF(NV507D, PIOR_SET_CONTROL, OWNER, NONE);
15611912 if (nv_encoder->crtc)
1562
- core->func->pior->ctrl(core, nv_encoder->or, 0x00000000, NULL);
1913
+ core->func->pior->ctrl(core, nv_encoder->or, ctrl, NULL);
15631914 nv_encoder->crtc = NULL;
15641915 nv50_outp_release(nv_encoder);
15651916 }
15661917
15671918 static void
1568
-nv50_pior_enable(struct drm_encoder *encoder)
1919
+nv50_pior_enable(struct drm_encoder *encoder, struct drm_atomic_state *state)
15691920 {
15701921 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
15711922 struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc);
1572
- struct nouveau_connector *nv_connector;
15731923 struct nv50_head_atom *asyh = nv50_head_atom(nv_crtc->base.state);
15741924 struct nv50_core *core = nv50_disp(encoder->dev)->core;
1575
- u8 owner = 1 << nv_crtc->index;
1576
- u8 proto;
1925
+ u32 ctrl = 0;
15771926
1578
- nv50_outp_acquire(nv_encoder);
1927
+ switch (nv_crtc->index) {
1928
+ case 0: ctrl |= NVDEF(NV507D, PIOR_SET_CONTROL, OWNER, HEAD0); break;
1929
+ case 1: ctrl |= NVDEF(NV507D, PIOR_SET_CONTROL, OWNER, HEAD1); break;
1930
+ default:
1931
+ WARN_ON(1);
1932
+ break;
1933
+ }
15791934
1580
- nv_connector = nouveau_encoder_connector_get(nv_encoder);
1581
- switch (nv_connector->base.display_info.bpc) {
1582
- case 10: asyh->or.depth = 0x6; break;
1583
- case 8: asyh->or.depth = 0x5; break;
1584
- case 6: asyh->or.depth = 0x2; break;
1585
- default: asyh->or.depth = 0x0; break;
1935
+ nv50_outp_acquire(nv_encoder, false);
1936
+
1937
+ switch (asyh->or.bpc) {
1938
+ case 10: asyh->or.depth = NV837D_PIOR_SET_CONTROL_PIXEL_DEPTH_BPP_30_444; break;
1939
+ case 8: asyh->or.depth = NV837D_PIOR_SET_CONTROL_PIXEL_DEPTH_BPP_24_444; break;
1940
+ case 6: asyh->or.depth = NV837D_PIOR_SET_CONTROL_PIXEL_DEPTH_BPP_18_444; break;
1941
+ default: asyh->or.depth = NV837D_PIOR_SET_CONTROL_PIXEL_DEPTH_DEFAULT; break;
15861942 }
15871943
15881944 switch (nv_encoder->dcb->type) {
15891945 case DCB_OUTPUT_TMDS:
15901946 case DCB_OUTPUT_DP:
1591
- proto = 0x0;
1947
+ ctrl |= NVDEF(NV507D, PIOR_SET_CONTROL, PROTOCOL, EXT_TMDS_ENC);
15921948 break;
15931949 default:
15941950 BUG();
15951951 break;
15961952 }
15971953
1598
- core->func->pior->ctrl(core, nv_encoder->or, (proto << 8) | owner, asyh);
1599
- nv_encoder->crtc = encoder->crtc;
1954
+ core->func->pior->ctrl(core, nv_encoder->or, ctrl, asyh);
1955
+ nv_encoder->crtc = &nv_crtc->base;
16001956 }
16011957
16021958 static const struct drm_encoder_helper_funcs
16031959 nv50_pior_help = {
16041960 .atomic_check = nv50_pior_atomic_check,
1605
- .enable = nv50_pior_enable,
1606
- .disable = nv50_pior_disable,
1961
+ .atomic_enable = nv50_pior_enable,
1962
+ .atomic_disable = nv50_pior_disable,
16071963 };
16081964
16091965 static void
....@@ -1621,7 +1977,9 @@
16211977 static int
16221978 nv50_pior_create(struct drm_connector *connector, struct dcb_output *dcbe)
16231979 {
1624
- struct nouveau_drm *drm = nouveau_drm(connector->dev);
1980
+ struct drm_device *dev = connector->dev;
1981
+ struct nouveau_drm *drm = nouveau_drm(dev);
1982
+ struct nv50_disp *disp = nv50_disp(dev);
16251983 struct nvkm_i2c *i2c = nvxx_i2c(&drm->client.device);
16261984 struct nvkm_i2c_bus *bus = NULL;
16271985 struct nvkm_i2c_aux *aux = NULL;
....@@ -1660,6 +2018,9 @@
16602018 drm_encoder_helper_add(encoder, &nv50_pior_help);
16612019
16622020 drm_connector_attach_encoder(connector, encoder);
2021
+
2022
+ disp->core->func->pior->get_caps(disp, nv_encoder, ffs(dcbe->or) - 1);
2023
+
16632024 return 0;
16642025 }
16652026
....@@ -1728,14 +2089,18 @@
17282089 struct nouveau_drm *drm = nouveau_drm(dev);
17292090 struct nv50_disp *disp = nv50_disp(dev);
17302091 struct nv50_atom *atom = nv50_atom(state);
2092
+ struct nv50_core *core = disp->core;
17312093 struct nv50_outp_atom *outp, *outt;
17322094 u32 interlock[NV50_DISP_INTERLOCK__SIZE] = {};
17332095 int i;
2096
+ bool flushed = false;
17342097
17352098 NV_ATOMIC(drm, "commit %d %d\n", atom->lock_core, atom->flush_disable);
2099
+ nv50_crc_atomic_stop_reporting(state);
17362100 drm_atomic_helper_wait_for_fences(dev, state, false);
17372101 drm_atomic_helper_wait_for_dependencies(state);
17382102 drm_atomic_helper_update_legacy_modeset_state(dev, state);
2103
+ drm_atomic_helper_calc_timestamping_constants(state);
17392104
17402105 if (atom->lock_core)
17412106 mutex_lock(&disp->mutex);
....@@ -1747,8 +2112,11 @@
17472112
17482113 NV_ATOMIC(drm, "%s: clr %04x (set %04x)\n", crtc->name,
17492114 asyh->clr.mask, asyh->set.mask);
1750
- if (old_crtc_state->active && !new_crtc_state->active)
2115
+
2116
+ if (old_crtc_state->active && !new_crtc_state->active) {
2117
+ pm_runtime_put_noidle(dev->dev);
17512118 drm_crtc_vblank_off(crtc);
2119
+ }
17522120
17532121 if (asyh->clr.mask) {
17542122 nv50_head_flush_clr(head, asyh, atom->flush_disable);
....@@ -1781,12 +2149,14 @@
17812149 outp->clr.mask, outp->set.mask);
17822150
17832151 if (outp->clr.mask) {
1784
- help->disable(encoder);
2152
+ help->atomic_disable(encoder, state);
17852153 interlock[NV50_DISP_INTERLOCK_CORE] |= 1;
17862154 if (outp->flush_disable) {
17872155 nv50_disp_atomic_commit_wndw(state, interlock);
17882156 nv50_disp_atomic_commit_core(state, interlock);
17892157 memset(interlock, 0x00, sizeof(interlock));
2158
+
2159
+ flushed = true;
17902160 }
17912161 }
17922162 }
....@@ -1797,8 +2167,14 @@
17972167 nv50_disp_atomic_commit_wndw(state, interlock);
17982168 nv50_disp_atomic_commit_core(state, interlock);
17992169 memset(interlock, 0x00, sizeof(interlock));
2170
+
2171
+ flushed = true;
18002172 }
18012173 }
2174
+
2175
+ if (flushed)
2176
+ nv50_crc_atomic_release_notifier_contexts(state);
2177
+ nv50_crc_atomic_init_notifier_contexts(state);
18022178
18032179 /* Update output path(s). */
18042180 list_for_each_entry_safe(outp, outt, &atom->outp, head) {
....@@ -1812,7 +2188,7 @@
18122188 outp->set.mask, outp->clr.mask);
18132189
18142190 if (outp->set.mask) {
1815
- help->enable(encoder);
2191
+ help->atomic_enable(encoder, state);
18162192 interlock[NV50_DISP_INTERLOCK_CORE] = 1;
18172193 }
18182194
....@@ -1834,10 +2210,54 @@
18342210 }
18352211
18362212 if (new_crtc_state->active) {
1837
- if (!old_crtc_state->active)
2213
+ if (!old_crtc_state->active) {
18382214 drm_crtc_vblank_on(crtc);
2215
+ pm_runtime_get_noresume(dev->dev);
2216
+ }
18392217 if (new_crtc_state->event)
18402218 drm_crtc_vblank_get(crtc);
2219
+ }
2220
+ }
2221
+
2222
+ /* Update window->head assignment.
2223
+ *
2224
+ * This has to happen in an update that's not interlocked with
2225
+ * any window channels to avoid hitting HW error checks.
2226
+ *
2227
+ *TODO: Proper handling of window ownership (Turing apparently
2228
+ * supports non-fixed mappings).
2229
+ */
2230
+ if (core->assign_windows) {
2231
+ core->func->wndw.owner(core);
2232
+ nv50_disp_atomic_commit_core(state, interlock);
2233
+ core->assign_windows = false;
2234
+ interlock[NV50_DISP_INTERLOCK_CORE] = 0;
2235
+ }
2236
+
2237
+ /* Finish updating head(s)...
2238
+ *
2239
+ * NVD is rather picky about both where window assignments can change,
2240
+ * *and* about certain core and window channel states matching.
2241
+ *
2242
+ * The EFI GOP driver on newer GPUs configures window channels with a
2243
+ * different output format to what we do, and the core channel update
2244
+ * in the assign_windows case above would result in a state mismatch.
2245
+ *
2246
+ * Delay some of the head update until after that point to workaround
2247
+ * the issue. This only affects the initial modeset.
2248
+ *
2249
+ * TODO: handle this better when adding flexible window mapping
2250
+ */
2251
+ for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
2252
+ struct nv50_head_atom *asyh = nv50_head_atom(new_crtc_state);
2253
+ struct nv50_head *head = nv50_head(crtc);
2254
+
2255
+ NV_ATOMIC(drm, "%s: set %04x (clr %04x)\n", crtc->name,
2256
+ asyh->set.mask, asyh->clr.mask);
2257
+
2258
+ if (asyh->set.mask) {
2259
+ nv50_head_flush_set_wndw(head, asyh);
2260
+ interlock[NV50_DISP_INTERLOCK_CORE] = 1;
18412261 }
18422262 }
18432263
....@@ -1896,10 +2316,17 @@
18962316 }
18972317 }
18982318
2319
+ nv50_crc_atomic_start_reporting(state);
2320
+ if (!flushed)
2321
+ nv50_crc_atomic_release_notifier_contexts(state);
18992322 drm_atomic_helper_commit_hw_done(state);
19002323 drm_atomic_helper_cleanup_planes(dev, state);
19012324 drm_atomic_helper_commit_cleanup_done(state);
19022325 drm_atomic_state_put(state);
2326
+
2327
+ /* Drop the RPM ref we got from nv50_disp_atomic_commit() */
2328
+ pm_runtime_mark_last_busy(dev->dev);
2329
+ pm_runtime_put_autosuspend(dev->dev);
19032330 }
19042331
19052332 static void
....@@ -1914,11 +2341,8 @@
19142341 nv50_disp_atomic_commit(struct drm_device *dev,
19152342 struct drm_atomic_state *state, bool nonblock)
19162343 {
1917
- struct nouveau_drm *drm = nouveau_drm(dev);
19182344 struct drm_plane_state *new_plane_state;
19192345 struct drm_plane *plane;
1920
- struct drm_crtc *crtc;
1921
- bool active = false;
19222346 int ret, i;
19232347
19242348 ret = pm_runtime_get_sync(dev->dev);
....@@ -1957,26 +2381,16 @@
19572381
19582382 drm_atomic_state_get(state);
19592383
2384
+ /*
2385
+ * Grab another RPM ref for the commit tail, which will release the
2386
+ * ref when it's finished
2387
+ */
2388
+ pm_runtime_get_noresume(dev->dev);
2389
+
19602390 if (nonblock)
19612391 queue_work(system_unbound_wq, &state->commit_work);
19622392 else
19632393 nv50_disp_atomic_commit_tail(state);
1964
-
1965
- drm_for_each_crtc(crtc, dev) {
1966
- if (crtc->state->active) {
1967
- if (!drm->have_disp_power_ref) {
1968
- drm->have_disp_power_ref = true;
1969
- return 0;
1970
- }
1971
- active = true;
1972
- break;
1973
- }
1974
- }
1975
-
1976
- if (!active && drm->have_disp_power_ref) {
1977
- pm_runtime_put_autosuspend(dev->dev);
1978
- drm->have_disp_power_ref = false;
1979
- }
19802394
19812395 err_cleanup:
19822396 if (ret)
....@@ -2064,11 +2478,27 @@
20642478 nv50_disp_atomic_check(struct drm_device *dev, struct drm_atomic_state *state)
20652479 {
20662480 struct nv50_atom *atom = nv50_atom(state);
2481
+ struct nv50_core *core = nv50_disp(dev)->core;
20672482 struct drm_connector_state *old_connector_state, *new_connector_state;
20682483 struct drm_connector *connector;
20692484 struct drm_crtc_state *new_crtc_state;
20702485 struct drm_crtc *crtc;
2486
+ struct nv50_head *head;
2487
+ struct nv50_head_atom *asyh;
20712488 int ret, i;
2489
+
2490
+ if (core->assign_windows && core->func->head->static_wndw_map) {
2491
+ drm_for_each_crtc(crtc, dev) {
2492
+ new_crtc_state = drm_atomic_get_crtc_state(state,
2493
+ crtc);
2494
+ if (IS_ERR(new_crtc_state))
2495
+ return PTR_ERR(new_crtc_state);
2496
+
2497
+ head = nv50_head(crtc);
2498
+ asyh = nv50_head_atom(new_crtc_state);
2499
+ core->func->head->static_wndw_map(head, asyh);
2500
+ }
2501
+ }
20722502
20732503 /* We need to handle colour management on a per-plane basis. */
20742504 for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
....@@ -2092,6 +2522,12 @@
20922522 if (ret)
20932523 return ret;
20942524 }
2525
+
2526
+ ret = drm_dp_mst_atomic_check(state);
2527
+ if (ret)
2528
+ return ret;
2529
+
2530
+ nv50_crc_atomic_check_outp(atom);
20952531
20962532 return 0;
20972533 }
....@@ -2146,60 +2582,50 @@
21462582 * Init
21472583 *****************************************************************************/
21482584
2149
-void
2150
-nv50_display_fini(struct drm_device *dev)
2585
+static void
2586
+nv50_display_fini(struct drm_device *dev, bool runtime, bool suspend)
21512587 {
2152
- struct nouveau_encoder *nv_encoder;
2588
+ struct nouveau_drm *drm = nouveau_drm(dev);
21532589 struct drm_encoder *encoder;
2154
- struct drm_plane *plane;
2155
-
2156
- drm_for_each_plane(plane, dev) {
2157
- struct nv50_wndw *wndw = nv50_wndw(plane);
2158
- if (plane->funcs != &nv50_wndw)
2159
- continue;
2160
- nv50_wndw_fini(wndw);
2161
- }
21622590
21632591 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
2164
- if (encoder->encoder_type != DRM_MODE_ENCODER_DPMST) {
2165
- nv_encoder = nouveau_encoder(encoder);
2166
- nv50_mstm_fini(nv_encoder->dp.mstm);
2167
- }
2592
+ if (encoder->encoder_type != DRM_MODE_ENCODER_DPMST)
2593
+ nv50_mstm_fini(nouveau_encoder(encoder));
21682594 }
2595
+
2596
+ if (!runtime)
2597
+ cancel_work_sync(&drm->hpd_work);
21692598 }
21702599
2171
-int
2172
-nv50_display_init(struct drm_device *dev)
2600
+static int
2601
+nv50_display_init(struct drm_device *dev, bool resume, bool runtime)
21732602 {
21742603 struct nv50_core *core = nv50_disp(dev)->core;
21752604 struct drm_encoder *encoder;
2176
- struct drm_plane *plane;
21772605
2178
- core->func->init(core);
2606
+ if (resume || runtime)
2607
+ core->func->init(core);
21792608
21802609 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
21812610 if (encoder->encoder_type != DRM_MODE_ENCODER_DPMST) {
21822611 struct nouveau_encoder *nv_encoder =
21832612 nouveau_encoder(encoder);
2184
- nv50_mstm_init(nv_encoder->dp.mstm);
2613
+ nv50_mstm_init(nv_encoder, runtime);
21852614 }
2186
- }
2187
-
2188
- drm_for_each_plane(plane, dev) {
2189
- struct nv50_wndw *wndw = nv50_wndw(plane);
2190
- if (plane->funcs != &nv50_wndw)
2191
- continue;
2192
- nv50_wndw_init(wndw);
21932615 }
21942616
21952617 return 0;
21962618 }
21972619
2198
-void
2620
+static void
21992621 nv50_display_destroy(struct drm_device *dev)
22002622 {
22012623 struct nv50_disp *disp = nv50_disp(dev);
22022624
2625
+ nv50_audio_component_fini(nouveau_drm(dev));
2626
+
2627
+ nvif_object_unmap(&disp->caps);
2628
+ nvif_object_dtor(&disp->caps);
22032629 nv50_core_del(&disp->core);
22042630
22052631 nouveau_bo_unmap(disp->sync);
....@@ -2221,6 +2647,7 @@
22212647 struct nv50_disp *disp;
22222648 struct dcb_output *dcbe;
22232649 int crtcs, ret, i;
2650
+ bool has_mst = nv50_has_mst(drm);
22242651
22252652 disp = kzalloc(sizeof(*disp), GFP_KERNEL);
22262653 if (!disp)
....@@ -2234,13 +2661,15 @@
22342661 nouveau_display(dev)->fini = nv50_display_fini;
22352662 disp->disp = &nouveau_display(dev)->disp;
22362663 dev->mode_config.funcs = &nv50_disp_func;
2237
- dev->driver->driver_features |= DRIVER_PREFER_XBGR_30BPP;
2664
+ dev->mode_config.quirk_addfb_prefer_xbgr_30bpp = true;
2665
+ dev->mode_config.normalize_zpos = true;
22382666
22392667 /* small shared memory area we use for notifiers and semaphores */
2240
- ret = nouveau_bo_new(&drm->client, 4096, 0x1000, TTM_PL_FLAG_VRAM,
2668
+ ret = nouveau_bo_new(&drm->client, 4096, 0x1000,
2669
+ NOUVEAU_GEM_DOMAIN_VRAM,
22412670 0, 0x0000, NULL, NULL, &disp->sync);
22422671 if (!ret) {
2243
- ret = nouveau_bo_pin(disp->sync, TTM_PL_FLAG_VRAM, true);
2672
+ ret = nouveau_bo_pin(disp->sync, NOUVEAU_GEM_DOMAIN_VRAM, true);
22442673 if (!ret) {
22452674 ret = nouveau_bo_map(disp->sync);
22462675 if (ret)
....@@ -2258,6 +2687,22 @@
22582687 if (ret)
22592688 goto out;
22602689
2690
+ disp->core->func->init(disp->core);
2691
+ if (disp->core->func->caps_init) {
2692
+ ret = disp->core->func->caps_init(drm, disp);
2693
+ if (ret)
2694
+ goto out;
2695
+ }
2696
+
2697
+ /* Assign the correct format modifiers */
2698
+ if (disp->disp->object.oclass >= TU102_DISP)
2699
+ nouveau_display(dev)->format_modifiers = wndwc57e_modifiers;
2700
+ else
2701
+ if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_FERMI)
2702
+ nouveau_display(dev)->format_modifiers = disp90xx_modifiers;
2703
+ else
2704
+ nouveau_display(dev)->format_modifiers = disp50xx_modifiers;
2705
+
22612706 /* create crtc objects to represent the hw heads */
22622707 if (disp->disp->object.oclass >= GV100_DISP)
22632708 crtcs = nvif_rd32(&device->object, 0x610060) & 0xff;
....@@ -2268,16 +2713,42 @@
22682713 crtcs = 0x3;
22692714
22702715 for (i = 0; i < fls(crtcs); i++) {
2716
+ struct nv50_head *head;
2717
+
22712718 if (!(crtcs & (1 << i)))
22722719 continue;
2273
- ret = nv50_head_create(dev, i);
2274
- if (ret)
2720
+
2721
+ head = nv50_head_create(dev, i);
2722
+ if (IS_ERR(head)) {
2723
+ ret = PTR_ERR(head);
22752724 goto out;
2725
+ }
2726
+
2727
+ if (has_mst) {
2728
+ head->msto = nv50_msto_new(dev, head, i);
2729
+ if (IS_ERR(head->msto)) {
2730
+ ret = PTR_ERR(head->msto);
2731
+ head->msto = NULL;
2732
+ goto out;
2733
+ }
2734
+
2735
+ /*
2736
+ * FIXME: This is a hack to workaround the following
2737
+ * issues:
2738
+ *
2739
+ * https://gitlab.gnome.org/GNOME/mutter/issues/759
2740
+ * https://gitlab.freedesktop.org/xorg/xserver/merge_requests/277
2741
+ *
2742
+ * Once these issues are closed, this should be
2743
+ * removed
2744
+ */
2745
+ head->msto->encoder.possible_crtcs = crtcs;
2746
+ }
22762747 }
22772748
22782749 /* create encoder/connector objects based on VBIOS DCB table */
22792750 for (i = 0, dcbe = &dcb->entry[0]; i < dcb->entries; i++, dcbe++) {
2280
- connector = nouveau_connector_create(dev, dcbe->connector);
2751
+ connector = nouveau_connector_create(dev, dcbe);
22812752 if (IS_ERR(connector))
22822753 continue;
22832754
....@@ -2309,7 +2780,7 @@
23092780
23102781 /* cull any connectors we created that don't have an encoder */
23112782 list_for_each_entry_safe(connector, tmp, &dev->mode_config.connector_list, head) {
2312
- if (connector->encoder_ids[0])
2783
+ if (connector->possible_encoders)
23132784 continue;
23142785
23152786 NV_WARN(drm, "%s has no encoders, removing\n",
....@@ -2320,8 +2791,60 @@
23202791 /* Disable vblank irqs aggressively for power-saving, safe on nv50+ */
23212792 dev->vblank_disable_immediate = true;
23222793
2794
+ nv50_audio_component_init(drm);
2795
+
23232796 out:
23242797 if (ret)
23252798 nv50_display_destroy(dev);
23262799 return ret;
23272800 }
2801
+
2802
+/******************************************************************************
2803
+ * Format modifiers
2804
+ *****************************************************************************/
2805
+
2806
+/****************************************************************
2807
+ * Log2(block height) ----------------------------+ *
2808
+ * Page Kind ----------------------------------+ | *
2809
+ * Gob Height/Page Kind Generation ------+ | | *
2810
+ * Sector layout -------+ | | | *
2811
+ * Compression ------+ | | | | */
2812
+const u64 disp50xx_modifiers[] = { /* | | | | | */
2813
+ DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 1, 0x7a, 0),
2814
+ DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 1, 0x7a, 1),
2815
+ DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 1, 0x7a, 2),
2816
+ DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 1, 0x7a, 3),
2817
+ DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 1, 0x7a, 4),
2818
+ DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 1, 0x7a, 5),
2819
+ DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 1, 0x78, 0),
2820
+ DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 1, 0x78, 1),
2821
+ DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 1, 0x78, 2),
2822
+ DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 1, 0x78, 3),
2823
+ DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 1, 0x78, 4),
2824
+ DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 1, 0x78, 5),
2825
+ DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 1, 0x70, 0),
2826
+ DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 1, 0x70, 1),
2827
+ DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 1, 0x70, 2),
2828
+ DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 1, 0x70, 3),
2829
+ DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 1, 0x70, 4),
2830
+ DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 1, 0x70, 5),
2831
+ DRM_FORMAT_MOD_LINEAR,
2832
+ DRM_FORMAT_MOD_INVALID
2833
+};
2834
+
2835
+/****************************************************************
2836
+ * Log2(block height) ----------------------------+ *
2837
+ * Page Kind ----------------------------------+ | *
2838
+ * Gob Height/Page Kind Generation ------+ | | *
2839
+ * Sector layout -------+ | | | *
2840
+ * Compression ------+ | | | | */
2841
+const u64 disp90xx_modifiers[] = { /* | | | | | */
2842
+ DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 0, 0xfe, 0),
2843
+ DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 0, 0xfe, 1),
2844
+ DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 0, 0xfe, 2),
2845
+ DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 0, 0xfe, 3),
2846
+ DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 0, 0xfe, 4),
2847
+ DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 0, 0xfe, 5),
2848
+ DRM_FORMAT_MOD_LINEAR,
2849
+ DRM_FORMAT_MOD_INVALID
2850
+};