2 * Copyright 2011 Red Hat Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
30 #include <linux/dma-mapping.h>
31 #include <linux/hdmi.h>
34 #include <drm/drm_atomic_helper.h>
35 #include <drm/drm_crtc_helper.h>
36 #include <drm/drm_dp_helper.h>
37 #include <drm/drm_fb_helper.h>
38 #include <drm/drm_plane_helper.h>
39 #include <drm/drm_scdc_helper.h>
40 #include <drm/drm_edid.h>
42 #include <nvif/class.h>
43 #include <nvif/cl0002.h>
44 #include <nvif/cl5070.h>
45 #include <nvif/cl507d.h>
46 #include <nvif/event.h>
48 #include "nouveau_drv.h"
49 #include "nouveau_dma.h"
50 #include "nouveau_gem.h"
51 #include "nouveau_connector.h"
52 #include "nouveau_encoder.h"
53 #include "nouveau_fence.h"
54 #include "nouveau_fbcon.h"
56 #include <subdev/bios/dp.h>
58 /******************************************************************************
60 *****************************************************************************/
62 struct nv50_outp_atom {
63 struct list_head head;
65 struct drm_encoder *encoder;
68 union nv50_outp_atom_mask {
76 /******************************************************************************
78 *****************************************************************************/
81 nv50_chan_create(struct nvif_device *device, struct nvif_object *disp,
82 const s32 *oclass, u8 head, void *data, u32 size,
83 struct nv50_chan *chan)
85 struct nvif_sclass *sclass;
88 chan->device = device;
90 ret = n = nvif_object_sclass_get(disp, &sclass);
95 for (i = 0; i < n; i++) {
96 if (sclass[i].oclass == oclass[0]) {
97 ret = nvif_object_init(disp, 0, oclass[0],
98 data, size, &chan->user);
100 nvif_object_map(&chan->user, NULL, 0);
101 nvif_object_sclass_put(&sclass);
108 nvif_object_sclass_put(&sclass);
113 nv50_chan_destroy(struct nv50_chan *chan)
115 nvif_object_fini(&chan->user);
118 /******************************************************************************
120 *****************************************************************************/
123 nv50_dmac_destroy(struct nv50_dmac *dmac)
125 nvif_object_fini(&dmac->vram);
126 nvif_object_fini(&dmac->sync);
128 nv50_chan_destroy(&dmac->base);
130 nvif_mem_fini(&dmac->push);
134 nv50_dmac_create(struct nvif_device *device, struct nvif_object *disp,
135 const s32 *oclass, u8 head, void *data, u32 size, u64 syncbuf,
136 struct nv50_dmac *dmac)
138 struct nouveau_cli *cli = (void *)device->object.client;
139 struct nv50_disp_core_channel_dma_v0 *args = data;
140 u8 type = NVIF_MEM_COHERENT;
143 mutex_init(&dmac->lock);
145 /* Pascal added support for 47-bit physical addresses, but some
146 * parts of EVO still only accept 40-bit PAs.
148 * To avoid issues on systems with large amounts of RAM, and on
149 * systems where an IOMMU maps pages at a high address, we need
150 * to allocate push buffers in VRAM instead.
152 * This appears to match NVIDIA's behaviour on Pascal.
154 if (device->info.family == NV_DEVICE_INFO_V0_PASCAL)
155 type |= NVIF_MEM_VRAM;
157 ret = nvif_mem_init_map(&cli->mmu, type, 0x1000, &dmac->push);
161 dmac->ptr = dmac->push.object.map.ptr;
163 args->pushbuf = nvif_handle(&dmac->push.object);
165 ret = nv50_chan_create(device, disp, oclass, head, data, size,
173 ret = nvif_object_init(&dmac->base.user, 0xf0000000, NV_DMA_IN_MEMORY,
174 &(struct nv_dma_v0) {
175 .target = NV_DMA_V0_TARGET_VRAM,
176 .access = NV_DMA_V0_ACCESS_RDWR,
177 .start = syncbuf + 0x0000,
178 .limit = syncbuf + 0x0fff,
179 }, sizeof(struct nv_dma_v0),
184 ret = nvif_object_init(&dmac->base.user, 0xf0000001, NV_DMA_IN_MEMORY,
185 &(struct nv_dma_v0) {
186 .target = NV_DMA_V0_TARGET_VRAM,
187 .access = NV_DMA_V0_ACCESS_RDWR,
189 .limit = device->info.ram_user - 1,
190 }, sizeof(struct nv_dma_v0),
198 /******************************************************************************
199 * EVO channel helpers
200 *****************************************************************************/
202 evo_wait(struct nv50_dmac *evoc, int nr)
204 struct nv50_dmac *dmac = evoc;
205 struct nvif_device *device = dmac->base.device;
206 u32 put = nvif_rd32(&dmac->base.user, 0x0000) / 4;
208 mutex_lock(&dmac->lock);
209 if (put + nr >= (PAGE_SIZE / 4) - 8) {
210 dmac->ptr[put] = 0x20000000;
212 nvif_wr32(&dmac->base.user, 0x0000, 0x00000000);
213 if (nvif_msec(device, 2000,
214 if (!nvif_rd32(&dmac->base.user, 0x0004))
217 mutex_unlock(&dmac->lock);
218 pr_err("nouveau: evo channel stalled\n");
225 return dmac->ptr + put;
229 evo_kick(u32 *push, struct nv50_dmac *evoc)
231 struct nv50_dmac *dmac = evoc;
233 /* Push buffer fetches are not coherent with BAR1, we need to ensure
234 * writes have been flushed right through to VRAM before writing PUT.
236 if (dmac->push.type & NVIF_MEM_VRAM) {
237 struct nvif_device *device = dmac->base.device;
238 nvif_wr32(&device->object, 0x070000, 0x00000001);
239 nvif_msec(device, 2000,
240 if (!(nvif_rd32(&device->object, 0x070000) & 0x00000002))
245 nvif_wr32(&dmac->base.user, 0x0000, (push - dmac->ptr) << 2);
246 mutex_unlock(&dmac->lock);
249 /******************************************************************************
250 * Output path helpers
251 *****************************************************************************/
253 nv50_outp_release(struct nouveau_encoder *nv_encoder)
255 struct nv50_disp *disp = nv50_disp(nv_encoder->base.base.dev);
257 struct nv50_disp_mthd_v1 base;
260 .base.method = NV50_DISP_MTHD_V1_RELEASE,
261 .base.hasht = nv_encoder->dcb->hasht,
262 .base.hashm = nv_encoder->dcb->hashm,
265 nvif_mthd(&disp->disp->object, 0, &args, sizeof(args));
267 nv_encoder->link = 0;
271 nv50_outp_acquire(struct nouveau_encoder *nv_encoder)
273 struct nouveau_drm *drm = nouveau_drm(nv_encoder->base.base.dev);
274 struct nv50_disp *disp = nv50_disp(drm->dev);
276 struct nv50_disp_mthd_v1 base;
277 struct nv50_disp_acquire_v0 info;
280 .base.method = NV50_DISP_MTHD_V1_ACQUIRE,
281 .base.hasht = nv_encoder->dcb->hasht,
282 .base.hashm = nv_encoder->dcb->hashm,
286 ret = nvif_mthd(&disp->disp->object, 0, &args, sizeof(args));
288 NV_ERROR(drm, "error acquiring output path: %d\n", ret);
292 nv_encoder->or = args.info.or;
293 nv_encoder->link = args.info.link;
298 nv50_outp_atomic_check_view(struct drm_encoder *encoder,
299 struct drm_crtc_state *crtc_state,
300 struct drm_connector_state *conn_state,
301 struct drm_display_mode *native_mode)
303 struct drm_display_mode *adjusted_mode = &crtc_state->adjusted_mode;
304 struct drm_display_mode *mode = &crtc_state->mode;
305 struct drm_connector *connector = conn_state->connector;
306 struct nouveau_conn_atom *asyc = nouveau_conn_atom(conn_state);
307 struct nouveau_drm *drm = nouveau_drm(encoder->dev);
309 NV_ATOMIC(drm, "%s atomic_check\n", encoder->name);
310 asyc->scaler.full = false;
314 if (asyc->scaler.mode == DRM_MODE_SCALE_NONE) {
315 switch (connector->connector_type) {
316 case DRM_MODE_CONNECTOR_LVDS:
317 case DRM_MODE_CONNECTOR_eDP:
318 /* Force use of scaler for non-EDID modes. */
319 if (adjusted_mode->type & DRM_MODE_TYPE_DRIVER)
322 asyc->scaler.full = true;
331 if (!drm_mode_equal(adjusted_mode, mode)) {
332 drm_mode_copy(adjusted_mode, mode);
333 crtc_state->mode_changed = true;
340 nv50_outp_atomic_check(struct drm_encoder *encoder,
341 struct drm_crtc_state *crtc_state,
342 struct drm_connector_state *conn_state)
344 struct nouveau_connector *nv_connector =
345 nouveau_connector(conn_state->connector);
346 return nv50_outp_atomic_check_view(encoder, crtc_state, conn_state,
347 nv_connector->native_mode);
350 /******************************************************************************
352 *****************************************************************************/
354 nv50_dac_disable(struct drm_encoder *encoder)
356 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
357 struct nv50_core *core = nv50_disp(encoder->dev)->core;
358 if (nv_encoder->crtc)
359 core->func->dac->ctrl(core, nv_encoder->or, 0x00000000, NULL);
360 nv_encoder->crtc = NULL;
361 nv50_outp_release(nv_encoder);
365 nv50_dac_enable(struct drm_encoder *encoder)
367 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
368 struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc);
369 struct nv50_head_atom *asyh = nv50_head_atom(nv_crtc->base.state);
370 struct nv50_core *core = nv50_disp(encoder->dev)->core;
372 nv50_outp_acquire(nv_encoder);
374 core->func->dac->ctrl(core, nv_encoder->or, 1 << nv_crtc->index, asyh);
377 nv_encoder->crtc = encoder->crtc;
380 static enum drm_connector_status
381 nv50_dac_detect(struct drm_encoder *encoder, struct drm_connector *connector)
383 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
384 struct nv50_disp *disp = nv50_disp(encoder->dev);
386 struct nv50_disp_mthd_v1 base;
387 struct nv50_disp_dac_load_v0 load;
390 .base.method = NV50_DISP_MTHD_V1_DAC_LOAD,
391 .base.hasht = nv_encoder->dcb->hasht,
392 .base.hashm = nv_encoder->dcb->hashm,
396 args.load.data = nouveau_drm(encoder->dev)->vbios.dactestval;
397 if (args.load.data == 0)
398 args.load.data = 340;
400 ret = nvif_mthd(&disp->disp->object, 0, &args, sizeof(args));
401 if (ret || !args.load.load)
402 return connector_status_disconnected;
404 return connector_status_connected;
407 static const struct drm_encoder_helper_funcs
409 .atomic_check = nv50_outp_atomic_check,
410 .enable = nv50_dac_enable,
411 .disable = nv50_dac_disable,
412 .detect = nv50_dac_detect
416 nv50_dac_destroy(struct drm_encoder *encoder)
418 drm_encoder_cleanup(encoder);
422 static const struct drm_encoder_funcs
424 .destroy = nv50_dac_destroy,
428 nv50_dac_create(struct drm_connector *connector, struct dcb_output *dcbe)
430 struct nouveau_drm *drm = nouveau_drm(connector->dev);
431 struct nvkm_i2c *i2c = nvxx_i2c(&drm->client.device);
432 struct nvkm_i2c_bus *bus;
433 struct nouveau_encoder *nv_encoder;
434 struct drm_encoder *encoder;
435 int type = DRM_MODE_ENCODER_DAC;
437 nv_encoder = kzalloc(sizeof(*nv_encoder), GFP_KERNEL);
440 nv_encoder->dcb = dcbe;
442 bus = nvkm_i2c_bus_find(i2c, dcbe->i2c_index);
444 nv_encoder->i2c = &bus->i2c;
446 encoder = to_drm_encoder(nv_encoder);
447 encoder->possible_crtcs = dcbe->heads;
448 encoder->possible_clones = 0;
449 drm_encoder_init(connector->dev, encoder, &nv50_dac_func, type,
450 "dac-%04x-%04x", dcbe->hasht, dcbe->hashm);
451 drm_encoder_helper_add(encoder, &nv50_dac_help);
453 drm_connector_attach_encoder(connector, encoder);
457 /******************************************************************************
459 *****************************************************************************/
461 nv50_audio_disable(struct drm_encoder *encoder, struct nouveau_crtc *nv_crtc)
463 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
464 struct nv50_disp *disp = nv50_disp(encoder->dev);
466 struct nv50_disp_mthd_v1 base;
467 struct nv50_disp_sor_hda_eld_v0 eld;
470 .base.method = NV50_DISP_MTHD_V1_SOR_HDA_ELD,
471 .base.hasht = nv_encoder->dcb->hasht,
472 .base.hashm = (0xf0ff & nv_encoder->dcb->hashm) |
473 (0x0100 << nv_crtc->index),
476 nvif_mthd(&disp->disp->object, 0, &args, sizeof(args));
480 nv50_audio_enable(struct drm_encoder *encoder, struct drm_display_mode *mode)
482 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
483 struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc);
484 struct nouveau_connector *nv_connector;
485 struct nv50_disp *disp = nv50_disp(encoder->dev);
488 struct nv50_disp_mthd_v1 mthd;
489 struct nv50_disp_sor_hda_eld_v0 eld;
491 u8 data[sizeof(nv_connector->base.eld)];
493 .base.mthd.version = 1,
494 .base.mthd.method = NV50_DISP_MTHD_V1_SOR_HDA_ELD,
495 .base.mthd.hasht = nv_encoder->dcb->hasht,
496 .base.mthd.hashm = (0xf0ff & nv_encoder->dcb->hashm) |
497 (0x0100 << nv_crtc->index),
500 nv_connector = nouveau_encoder_connector_get(nv_encoder);
501 if (!drm_detect_monitor_audio(nv_connector->edid))
504 memcpy(args.data, nv_connector->base.eld, sizeof(args.data));
506 nvif_mthd(&disp->disp->object, 0, &args,
507 sizeof(args.base) + drm_eld_size(args.data));
510 /******************************************************************************
512 *****************************************************************************/
514 nv50_hdmi_disable(struct drm_encoder *encoder, struct nouveau_crtc *nv_crtc)
516 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
517 struct nv50_disp *disp = nv50_disp(encoder->dev);
519 struct nv50_disp_mthd_v1 base;
520 struct nv50_disp_sor_hdmi_pwr_v0 pwr;
523 .base.method = NV50_DISP_MTHD_V1_SOR_HDMI_PWR,
524 .base.hasht = nv_encoder->dcb->hasht,
525 .base.hashm = (0xf0ff & nv_encoder->dcb->hashm) |
526 (0x0100 << nv_crtc->index),
529 nvif_mthd(&disp->disp->object, 0, &args, sizeof(args));
533 nv50_hdmi_enable(struct drm_encoder *encoder, struct drm_display_mode *mode)
535 struct nouveau_drm *drm = nouveau_drm(encoder->dev);
536 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
537 struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc);
538 struct nv50_disp *disp = nv50_disp(encoder->dev);
540 struct nv50_disp_mthd_v1 base;
541 struct nv50_disp_sor_hdmi_pwr_v0 pwr;
542 u8 infoframes[2 * 17]; /* two frames, up to 17 bytes each */
545 .base.method = NV50_DISP_MTHD_V1_SOR_HDMI_PWR,
546 .base.hasht = nv_encoder->dcb->hasht,
547 .base.hashm = (0xf0ff & nv_encoder->dcb->hashm) |
548 (0x0100 << nv_crtc->index),
550 .pwr.rekey = 56, /* binary driver, and tegra, constant */
552 struct nouveau_connector *nv_connector;
553 struct drm_hdmi_info *hdmi;
555 union hdmi_infoframe avi_frame;
556 union hdmi_infoframe vendor_frame;
557 bool scdc_supported, high_tmds_clock_ratio = false, scrambling = false;
562 nv_connector = nouveau_encoder_connector_get(nv_encoder);
563 if (!drm_detect_hdmi_monitor(nv_connector->edid))
566 hdmi = &nv_connector->base.display_info.hdmi;
567 scdc_supported = hdmi->scdc.supported;
569 ret = drm_hdmi_avi_infoframe_from_display_mode(&avi_frame.avi, mode,
572 /* We have an AVI InfoFrame, populate it to the display */
573 args.pwr.avi_infoframe_length
574 = hdmi_infoframe_pack(&avi_frame, args.infoframes, 17);
577 ret = drm_hdmi_vendor_infoframe_from_display_mode(&vendor_frame.vendor.hdmi,
578 &nv_connector->base, mode);
580 /* We have a Vendor InfoFrame, populate it to the display */
581 args.pwr.vendor_infoframe_length
582 = hdmi_infoframe_pack(&vendor_frame,
584 + args.pwr.avi_infoframe_length,
588 max_ac_packet = mode->htotal - mode->hdisplay;
589 max_ac_packet -= args.pwr.rekey;
590 max_ac_packet -= 18; /* constant from tegra */
591 args.pwr.max_ac_packet = max_ac_packet / 32;
593 if (hdmi->scdc.scrambling.supported) {
594 high_tmds_clock_ratio = mode->clock > 340000;
595 scrambling = high_tmds_clock_ratio ||
596 hdmi->scdc.scrambling.low_rates;
600 NV50_DISP_SOR_HDMI_PWR_V0_SCDC_SCRAMBLE * scrambling |
601 NV50_DISP_SOR_HDMI_PWR_V0_SCDC_DIV_BY_4 * high_tmds_clock_ratio;
603 size = sizeof(args.base)
605 + args.pwr.avi_infoframe_length
606 + args.pwr.vendor_infoframe_length;
607 nvif_mthd(&disp->disp->object, 0, &args, size);
609 nv50_audio_enable(encoder, mode);
611 /* If SCDC is supported by the downstream monitor, update
612 * divider / scrambling settings to what we programmed above.
614 if (!hdmi->scdc.scrambling.supported)
617 ret = drm_scdc_readb(nv_encoder->i2c, SCDC_TMDS_CONFIG, &config);
619 NV_ERROR(drm, "Failure to read SCDC_TMDS_CONFIG: %d\n", ret);
622 config &= ~(SCDC_TMDS_BIT_CLOCK_RATIO_BY_40 | SCDC_SCRAMBLING_ENABLE);
623 config |= SCDC_TMDS_BIT_CLOCK_RATIO_BY_40 * high_tmds_clock_ratio;
624 config |= SCDC_SCRAMBLING_ENABLE * scrambling;
625 ret = drm_scdc_writeb(nv_encoder->i2c, SCDC_TMDS_CONFIG, config);
627 NV_ERROR(drm, "Failure to write SCDC_TMDS_CONFIG = 0x%02x: %d\n",
631 /******************************************************************************
633 *****************************************************************************/
634 #define nv50_mstm(p) container_of((p), struct nv50_mstm, mgr)
635 #define nv50_mstc(p) container_of((p), struct nv50_mstc, connector)
636 #define nv50_msto(p) container_of((p), struct nv50_msto, encoder)
639 struct nouveau_encoder *outp;
641 struct drm_dp_mst_topology_mgr mgr;
642 struct nv50_msto *msto[4];
650 struct nv50_mstm *mstm;
651 struct drm_dp_mst_port *port;
652 struct drm_connector connector;
654 struct drm_display_mode *native;
661 struct drm_encoder encoder;
663 struct nv50_head *head;
664 struct nv50_mstc *mstc;
668 static struct drm_dp_payload *
669 nv50_msto_payload(struct nv50_msto *msto)
671 struct nouveau_drm *drm = nouveau_drm(msto->encoder.dev);
672 struct nv50_mstc *mstc = msto->mstc;
673 struct nv50_mstm *mstm = mstc->mstm;
674 int vcpi = mstc->port->vcpi.vcpi, i;
676 NV_ATOMIC(drm, "%s: vcpi %d\n", msto->encoder.name, vcpi);
677 for (i = 0; i < mstm->mgr.max_payloads; i++) {
678 struct drm_dp_payload *payload = &mstm->mgr.payloads[i];
679 NV_ATOMIC(drm, "%s: %d: vcpi %d start 0x%02x slots 0x%02x\n",
680 mstm->outp->base.base.name, i, payload->vcpi,
681 payload->start_slot, payload->num_slots);
684 for (i = 0; i < mstm->mgr.max_payloads; i++) {
685 struct drm_dp_payload *payload = &mstm->mgr.payloads[i];
686 if (payload->vcpi == vcpi)
694 nv50_msto_cleanup(struct nv50_msto *msto)
696 struct nouveau_drm *drm = nouveau_drm(msto->encoder.dev);
697 struct nv50_mstc *mstc = msto->mstc;
698 struct nv50_mstm *mstm = mstc->mstm;
700 NV_ATOMIC(drm, "%s: msto cleanup\n", msto->encoder.name);
701 if (mstc->port && mstc->port->vcpi.vcpi > 0 && !nv50_msto_payload(msto))
702 drm_dp_mst_deallocate_vcpi(&mstm->mgr, mstc->port);
703 if (msto->disabled) {
706 msto->disabled = false;
711 nv50_msto_prepare(struct nv50_msto *msto)
713 struct nouveau_drm *drm = nouveau_drm(msto->encoder.dev);
714 struct nv50_mstc *mstc = msto->mstc;
715 struct nv50_mstm *mstm = mstc->mstm;
717 struct nv50_disp_mthd_v1 base;
718 struct nv50_disp_sor_dp_mst_vcpi_v0 vcpi;
721 .base.method = NV50_DISP_MTHD_V1_SOR_DP_MST_VCPI,
722 .base.hasht = mstm->outp->dcb->hasht,
723 .base.hashm = (0xf0ff & mstm->outp->dcb->hashm) |
724 (0x0100 << msto->head->base.index),
727 NV_ATOMIC(drm, "%s: msto prepare\n", msto->encoder.name);
728 if (mstc->port && mstc->port->vcpi.vcpi > 0) {
729 struct drm_dp_payload *payload = nv50_msto_payload(msto);
731 args.vcpi.start_slot = payload->start_slot;
732 args.vcpi.num_slots = payload->num_slots;
733 args.vcpi.pbn = mstc->port->vcpi.pbn;
734 args.vcpi.aligned_pbn = mstc->port->vcpi.aligned_pbn;
738 NV_ATOMIC(drm, "%s: %s: %02x %02x %04x %04x\n",
739 msto->encoder.name, msto->head->base.base.name,
740 args.vcpi.start_slot, args.vcpi.num_slots,
741 args.vcpi.pbn, args.vcpi.aligned_pbn);
742 nvif_mthd(&drm->display->disp.object, 0, &args, sizeof(args));
746 nv50_msto_atomic_check(struct drm_encoder *encoder,
747 struct drm_crtc_state *crtc_state,
748 struct drm_connector_state *conn_state)
750 struct nv50_mstc *mstc = nv50_mstc(conn_state->connector);
751 struct nv50_mstm *mstm = mstc->mstm;
752 int bpp = conn_state->connector->display_info.bpc * 3;
755 mstc->pbn = drm_dp_calc_pbn_mode(crtc_state->adjusted_mode.clock, bpp);
757 slots = drm_dp_find_vcpi_slots(&mstm->mgr, mstc->pbn);
761 return nv50_outp_atomic_check_view(encoder, crtc_state, conn_state,
766 nv50_msto_enable(struct drm_encoder *encoder)
768 struct nv50_head *head = nv50_head(encoder->crtc);
769 struct nv50_msto *msto = nv50_msto(encoder);
770 struct nv50_mstc *mstc = NULL;
771 struct nv50_mstm *mstm = NULL;
772 struct drm_connector *connector;
773 struct drm_connector_list_iter conn_iter;
778 drm_connector_list_iter_begin(encoder->dev, &conn_iter);
779 drm_for_each_connector_iter(connector, &conn_iter) {
780 if (connector->state->best_encoder == &msto->encoder) {
781 mstc = nv50_mstc(connector);
786 drm_connector_list_iter_end(&conn_iter);
791 slots = drm_dp_find_vcpi_slots(&mstm->mgr, mstc->pbn);
792 r = drm_dp_mst_allocate_vcpi(&mstm->mgr, mstc->port, mstc->pbn, slots);
796 nv50_outp_acquire(mstm->outp);
798 if (mstm->outp->link & 1)
803 switch (mstc->connector.display_info.bpc) {
804 case 6: depth = 0x2; break;
805 case 8: depth = 0x5; break;
807 default: depth = 0x6; break;
810 mstm->outp->update(mstm->outp, head->base.index,
811 nv50_head_atom(head->base.base.state), proto, depth);
815 mstm->modified = true;
819 nv50_msto_disable(struct drm_encoder *encoder)
821 struct nv50_msto *msto = nv50_msto(encoder);
822 struct nv50_mstc *mstc = msto->mstc;
823 struct nv50_mstm *mstm = mstc->mstm;
826 drm_dp_mst_reset_vcpi_slots(&mstm->mgr, mstc->port);
828 mstm->outp->update(mstm->outp, msto->head->base.index, NULL, 0, 0);
829 mstm->modified = true;
831 mstm->disabled = true;
832 msto->disabled = true;
835 static const struct drm_encoder_helper_funcs
837 .disable = nv50_msto_disable,
838 .enable = nv50_msto_enable,
839 .atomic_check = nv50_msto_atomic_check,
843 nv50_msto_destroy(struct drm_encoder *encoder)
845 struct nv50_msto *msto = nv50_msto(encoder);
846 drm_encoder_cleanup(&msto->encoder);
850 static const struct drm_encoder_funcs
852 .destroy = nv50_msto_destroy,
856 nv50_msto_new(struct drm_device *dev, u32 heads, const char *name, int id,
857 struct nv50_msto **pmsto)
859 struct nv50_msto *msto;
862 if (!(msto = *pmsto = kzalloc(sizeof(*msto), GFP_KERNEL)))
865 ret = drm_encoder_init(dev, &msto->encoder, &nv50_msto,
866 DRM_MODE_ENCODER_DPMST, "%s-mst-%d", name, id);
873 drm_encoder_helper_add(&msto->encoder, &nv50_msto_help);
874 msto->encoder.possible_crtcs = heads;
878 static struct drm_encoder *
879 nv50_mstc_atomic_best_encoder(struct drm_connector *connector,
880 struct drm_connector_state *connector_state)
882 struct nv50_head *head = nv50_head(connector_state->crtc);
883 struct nv50_mstc *mstc = nv50_mstc(connector);
885 return &mstc->mstm->msto[head->base.index]->encoder;
888 static struct drm_encoder *
889 nv50_mstc_best_encoder(struct drm_connector *connector)
891 struct nv50_mstc *mstc = nv50_mstc(connector);
893 return &mstc->mstm->msto[0]->encoder;
896 static enum drm_mode_status
897 nv50_mstc_mode_valid(struct drm_connector *connector,
898 struct drm_display_mode *mode)
904 nv50_mstc_get_modes(struct drm_connector *connector)
906 struct nv50_mstc *mstc = nv50_mstc(connector);
909 mstc->edid = drm_dp_mst_get_edid(&mstc->connector, mstc->port->mgr, mstc->port);
910 drm_connector_update_edid_property(&mstc->connector, mstc->edid);
912 ret = drm_add_edid_modes(&mstc->connector, mstc->edid);
914 if (!mstc->connector.display_info.bpc)
915 mstc->connector.display_info.bpc = 8;
918 drm_mode_destroy(mstc->connector.dev, mstc->native);
919 mstc->native = nouveau_conn_native_mode(&mstc->connector);
923 static const struct drm_connector_helper_funcs
925 .get_modes = nv50_mstc_get_modes,
926 .mode_valid = nv50_mstc_mode_valid,
927 .best_encoder = nv50_mstc_best_encoder,
928 .atomic_best_encoder = nv50_mstc_atomic_best_encoder,
931 static enum drm_connector_status
932 nv50_mstc_detect(struct drm_connector *connector, bool force)
934 struct nv50_mstc *mstc = nv50_mstc(connector);
936 return connector_status_disconnected;
937 return drm_dp_mst_detect_port(connector, mstc->port->mgr, mstc->port);
941 nv50_mstc_destroy(struct drm_connector *connector)
943 struct nv50_mstc *mstc = nv50_mstc(connector);
944 drm_connector_cleanup(&mstc->connector);
948 static const struct drm_connector_funcs
950 .reset = nouveau_conn_reset,
951 .detect = nv50_mstc_detect,
952 .fill_modes = drm_helper_probe_single_connector_modes,
953 .destroy = nv50_mstc_destroy,
954 .atomic_duplicate_state = nouveau_conn_atomic_duplicate_state,
955 .atomic_destroy_state = nouveau_conn_atomic_destroy_state,
956 .atomic_set_property = nouveau_conn_atomic_set_property,
957 .atomic_get_property = nouveau_conn_atomic_get_property,
961 nv50_mstc_new(struct nv50_mstm *mstm, struct drm_dp_mst_port *port,
962 const char *path, struct nv50_mstc **pmstc)
964 struct drm_device *dev = mstm->outp->base.base.dev;
965 struct nv50_mstc *mstc;
968 if (!(mstc = *pmstc = kzalloc(sizeof(*mstc), GFP_KERNEL)))
973 ret = drm_connector_init(dev, &mstc->connector, &nv50_mstc,
974 DRM_MODE_CONNECTOR_DisplayPort);
981 drm_connector_helper_add(&mstc->connector, &nv50_mstc_help);
983 mstc->connector.funcs->reset(&mstc->connector);
984 nouveau_conn_attach_properties(&mstc->connector);
986 for (i = 0; i < ARRAY_SIZE(mstm->msto) && mstm->msto[i]; i++)
987 drm_connector_attach_encoder(&mstc->connector, &mstm->msto[i]->encoder);
989 drm_object_attach_property(&mstc->connector.base, dev->mode_config.path_property, 0);
990 drm_object_attach_property(&mstc->connector.base, dev->mode_config.tile_property, 0);
991 drm_connector_set_path_property(&mstc->connector, path);
996 nv50_mstm_cleanup(struct nv50_mstm *mstm)
998 struct nouveau_drm *drm = nouveau_drm(mstm->outp->base.base.dev);
999 struct drm_encoder *encoder;
1002 NV_ATOMIC(drm, "%s: mstm cleanup\n", mstm->outp->base.base.name);
1003 ret = drm_dp_check_act_status(&mstm->mgr);
1005 ret = drm_dp_update_payload_part2(&mstm->mgr);
1007 drm_for_each_encoder(encoder, mstm->outp->base.base.dev) {
1008 if (encoder->encoder_type == DRM_MODE_ENCODER_DPMST) {
1009 struct nv50_msto *msto = nv50_msto(encoder);
1010 struct nv50_mstc *mstc = msto->mstc;
1011 if (mstc && mstc->mstm == mstm)
1012 nv50_msto_cleanup(msto);
1016 mstm->modified = false;
1020 nv50_mstm_prepare(struct nv50_mstm *mstm)
1022 struct nouveau_drm *drm = nouveau_drm(mstm->outp->base.base.dev);
1023 struct drm_encoder *encoder;
1026 NV_ATOMIC(drm, "%s: mstm prepare\n", mstm->outp->base.base.name);
1027 ret = drm_dp_update_payload_part1(&mstm->mgr);
1029 drm_for_each_encoder(encoder, mstm->outp->base.base.dev) {
1030 if (encoder->encoder_type == DRM_MODE_ENCODER_DPMST) {
1031 struct nv50_msto *msto = nv50_msto(encoder);
1032 struct nv50_mstc *mstc = msto->mstc;
1033 if (mstc && mstc->mstm == mstm)
1034 nv50_msto_prepare(msto);
1038 if (mstm->disabled) {
1040 nv50_outp_release(mstm->outp);
1041 mstm->disabled = false;
1046 nv50_mstm_hotplug(struct drm_dp_mst_topology_mgr *mgr)
1048 struct nv50_mstm *mstm = nv50_mstm(mgr);
1049 drm_kms_helper_hotplug_event(mstm->outp->base.base.dev);
1053 nv50_mstm_destroy_connector(struct drm_dp_mst_topology_mgr *mgr,
1054 struct drm_connector *connector)
1056 struct nouveau_drm *drm = nouveau_drm(connector->dev);
1057 struct nv50_mstc *mstc = nv50_mstc(connector);
1059 drm_connector_unregister(&mstc->connector);
1061 drm_fb_helper_remove_one_connector(&drm->fbcon->helper, &mstc->connector);
1063 drm_modeset_lock(&drm->dev->mode_config.connection_mutex, NULL);
1065 drm_modeset_unlock(&drm->dev->mode_config.connection_mutex);
1067 drm_connector_put(&mstc->connector);
1071 nv50_mstm_register_connector(struct drm_connector *connector)
1073 struct nouveau_drm *drm = nouveau_drm(connector->dev);
1075 drm_fb_helper_add_one_connector(&drm->fbcon->helper, connector);
1077 drm_connector_register(connector);
1080 static struct drm_connector *
1081 nv50_mstm_add_connector(struct drm_dp_mst_topology_mgr *mgr,
1082 struct drm_dp_mst_port *port, const char *path)
1084 struct nv50_mstm *mstm = nv50_mstm(mgr);
1085 struct nv50_mstc *mstc;
1088 ret = nv50_mstc_new(mstm, port, path, &mstc);
1091 mstc->connector.funcs->destroy(&mstc->connector);
1095 return &mstc->connector;
1098 static const struct drm_dp_mst_topology_cbs
1100 .add_connector = nv50_mstm_add_connector,
1101 .register_connector = nv50_mstm_register_connector,
1102 .destroy_connector = nv50_mstm_destroy_connector,
1103 .hotplug = nv50_mstm_hotplug,
1107 nv50_mstm_service(struct nv50_mstm *mstm)
1109 struct drm_dp_aux *aux = mstm ? mstm->mgr.aux : NULL;
1110 bool handled = true;
1118 ret = drm_dp_dpcd_read(aux, DP_SINK_COUNT_ESI, esi, 8);
1120 drm_dp_mst_topology_mgr_set_mst(&mstm->mgr, false);
1124 drm_dp_mst_hpd_irq(&mstm->mgr, esi, &handled);
1128 drm_dp_dpcd_write(aux, DP_SINK_COUNT_ESI + 1, &esi[1], 3);
1133 nv50_mstm_remove(struct nv50_mstm *mstm)
1136 drm_dp_mst_topology_mgr_set_mst(&mstm->mgr, false);
1140 nv50_mstm_enable(struct nv50_mstm *mstm, u8 dpcd, int state)
1142 struct nouveau_encoder *outp = mstm->outp;
1144 struct nv50_disp_mthd_v1 base;
1145 struct nv50_disp_sor_dp_mst_link_v0 mst;
1148 .base.method = NV50_DISP_MTHD_V1_SOR_DP_MST_LINK,
1149 .base.hasht = outp->dcb->hasht,
1150 .base.hashm = outp->dcb->hashm,
1153 struct nouveau_drm *drm = nouveau_drm(outp->base.base.dev);
1154 struct nvif_object *disp = &drm->display->disp.object;
1158 /* Even if we're enabling MST, start with disabling the
1159 * branching unit to clear any sink-side MST topology state
1160 * that wasn't set by us
1162 ret = drm_dp_dpcd_writeb(mstm->mgr.aux, DP_MSTM_CTRL, 0);
1167 /* Now, start initializing */
1168 ret = drm_dp_dpcd_writeb(mstm->mgr.aux, DP_MSTM_CTRL,
1175 return nvif_mthd(disp, 0, &args, sizeof(args));
1179 nv50_mstm_detect(struct nv50_mstm *mstm, u8 dpcd[8], int allow)
1181 struct drm_dp_aux *aux;
1183 bool old_state, new_state;
1189 mutex_lock(&mstm->mgr.lock);
1191 old_state = mstm->mgr.mst_state;
1192 new_state = old_state;
1193 aux = mstm->mgr.aux;
1196 /* Just check that the MST hub is still as we expect it */
1197 ret = drm_dp_dpcd_readb(aux, DP_MSTM_CTRL, &mstm_ctrl);
1198 if (ret < 0 || !(mstm_ctrl & DP_MST_EN)) {
1199 DRM_DEBUG_KMS("Hub gone, disabling MST topology\n");
1202 } else if (dpcd[0] >= 0x12) {
1203 ret = drm_dp_dpcd_readb(aux, DP_MSTM_CAP, &dpcd[1]);
1207 if (!(dpcd[1] & DP_MST_CAP))
1213 if (new_state == old_state) {
1214 mutex_unlock(&mstm->mgr.lock);
1218 ret = nv50_mstm_enable(mstm, dpcd[0], new_state);
1222 mutex_unlock(&mstm->mgr.lock);
1224 ret = drm_dp_mst_topology_mgr_set_mst(&mstm->mgr, new_state);
1226 return nv50_mstm_enable(mstm, dpcd[0], 0);
1231 mutex_unlock(&mstm->mgr.lock);
1236 nv50_mstm_fini(struct nv50_mstm *mstm)
1238 if (mstm && mstm->mgr.mst_state)
1239 drm_dp_mst_topology_mgr_suspend(&mstm->mgr);
1243 nv50_mstm_init(struct nv50_mstm *mstm)
1245 if (mstm && mstm->mgr.mst_state)
1246 drm_dp_mst_topology_mgr_resume(&mstm->mgr);
1250 nv50_mstm_del(struct nv50_mstm **pmstm)
1252 struct nv50_mstm *mstm = *pmstm;
1260 nv50_mstm_new(struct nouveau_encoder *outp, struct drm_dp_aux *aux, int aux_max,
1261 int conn_base_id, struct nv50_mstm **pmstm)
1263 const int max_payloads = hweight8(outp->dcb->heads);
1264 struct drm_device *dev = outp->base.base.dev;
1265 struct nv50_mstm *mstm;
1269 /* This is a workaround for some monitors not functioning
1270 * correctly in MST mode on initial module load. I think
1271 * some bad interaction with the VBIOS may be responsible.
1273 * A good ol' off and on again seems to work here ;)
1275 ret = drm_dp_dpcd_readb(aux, DP_DPCD_REV, &dpcd);
1276 if (ret >= 0 && dpcd >= 0x12)
1277 drm_dp_dpcd_writeb(aux, DP_MSTM_CTRL, 0);
1279 if (!(mstm = *pmstm = kzalloc(sizeof(*mstm), GFP_KERNEL)))
1282 mstm->mgr.cbs = &nv50_mstm;
1284 ret = drm_dp_mst_topology_mgr_init(&mstm->mgr, dev, aux, aux_max,
1285 max_payloads, conn_base_id);
1289 for (i = 0; i < max_payloads; i++) {
1290 ret = nv50_msto_new(dev, outp->dcb->heads, outp->base.base.name,
1299 /******************************************************************************
1301 *****************************************************************************/
1303 nv50_sor_update(struct nouveau_encoder *nv_encoder, u8 head,
1304 struct nv50_head_atom *asyh, u8 proto, u8 depth)
1306 struct nv50_disp *disp = nv50_disp(nv_encoder->base.base.dev);
1307 struct nv50_core *core = disp->core;
1310 nv_encoder->ctrl &= ~BIT(head);
1311 if (!(nv_encoder->ctrl & 0x0000000f))
1312 nv_encoder->ctrl = 0;
1314 nv_encoder->ctrl |= proto << 8;
1315 nv_encoder->ctrl |= BIT(head);
1316 asyh->or.depth = depth;
1319 core->func->sor->ctrl(core, nv_encoder->or, nv_encoder->ctrl, asyh);
1323 nv50_sor_disable(struct drm_encoder *encoder)
1325 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
1326 struct nouveau_crtc *nv_crtc = nouveau_crtc(nv_encoder->crtc);
1328 nv_encoder->crtc = NULL;
1331 struct nvkm_i2c_aux *aux = nv_encoder->aux;
1335 int ret = nvkm_rdaux(aux, DP_SET_POWER, &pwr, 1);
1337 pwr &= ~DP_SET_POWER_MASK;
1338 pwr |= DP_SET_POWER_D3;
1339 nvkm_wraux(aux, DP_SET_POWER, &pwr, 1);
1343 nv_encoder->update(nv_encoder, nv_crtc->index, NULL, 0, 0);
1344 nv50_audio_disable(encoder, nv_crtc);
1345 nv50_hdmi_disable(&nv_encoder->base.base, nv_crtc);
1346 nv50_outp_release(nv_encoder);
1351 nv50_sor_enable(struct drm_encoder *encoder)
1353 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
1354 struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc);
1355 struct nv50_head_atom *asyh = nv50_head_atom(nv_crtc->base.state);
1356 struct drm_display_mode *mode = &asyh->state.adjusted_mode;
1358 struct nv50_disp_mthd_v1 base;
1359 struct nv50_disp_sor_lvds_script_v0 lvds;
1362 .base.method = NV50_DISP_MTHD_V1_SOR_LVDS_SCRIPT,
1363 .base.hasht = nv_encoder->dcb->hasht,
1364 .base.hashm = nv_encoder->dcb->hashm,
1366 struct nv50_disp *disp = nv50_disp(encoder->dev);
1367 struct drm_device *dev = encoder->dev;
1368 struct nouveau_drm *drm = nouveau_drm(dev);
1369 struct nouveau_connector *nv_connector;
1370 struct nvbios *bios = &drm->vbios;
1374 nv_connector = nouveau_encoder_connector_get(nv_encoder);
1375 nv_encoder->crtc = encoder->crtc;
1376 nv50_outp_acquire(nv_encoder);
1378 switch (nv_encoder->dcb->type) {
1379 case DCB_OUTPUT_TMDS:
1380 if (nv_encoder->link & 1) {
1382 /* Only enable dual-link if:
1383 * - Need to (i.e. rate > 165MHz)
1385 * - Not an HDMI monitor, since there's no dual-link
1388 if (mode->clock >= 165000 &&
1389 nv_encoder->dcb->duallink_possible &&
1390 !drm_detect_hdmi_monitor(nv_connector->edid))
1396 nv50_hdmi_enable(&nv_encoder->base.base, mode);
1398 case DCB_OUTPUT_LVDS:
1401 if (bios->fp_no_ddc) {
1402 if (bios->fp.dual_link)
1403 lvds.lvds.script |= 0x0100;
1404 if (bios->fp.if_is_24bit)
1405 lvds.lvds.script |= 0x0200;
1407 if (nv_connector->type == DCB_CONNECTOR_LVDS_SPWG) {
1408 if (((u8 *)nv_connector->edid)[121] == 2)
1409 lvds.lvds.script |= 0x0100;
1411 if (mode->clock >= bios->fp.duallink_transition_clk) {
1412 lvds.lvds.script |= 0x0100;
1415 if (lvds.lvds.script & 0x0100) {
1416 if (bios->fp.strapless_is_24bit & 2)
1417 lvds.lvds.script |= 0x0200;
1419 if (bios->fp.strapless_is_24bit & 1)
1420 lvds.lvds.script |= 0x0200;
1423 if (nv_connector->base.display_info.bpc == 8)
1424 lvds.lvds.script |= 0x0200;
1427 nvif_mthd(&disp->disp->object, 0, &lvds, sizeof(lvds));
1430 if (nv_connector->base.display_info.bpc == 6)
1433 if (nv_connector->base.display_info.bpc == 8)
1438 if (nv_encoder->link & 1)
1443 nv50_audio_enable(encoder, mode);
1450 nv_encoder->update(nv_encoder, nv_crtc->index, asyh, proto, depth);
1453 static const struct drm_encoder_helper_funcs
1455 .atomic_check = nv50_outp_atomic_check,
1456 .enable = nv50_sor_enable,
1457 .disable = nv50_sor_disable,
1461 nv50_sor_destroy(struct drm_encoder *encoder)
1463 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
1464 nv50_mstm_del(&nv_encoder->dp.mstm);
1465 drm_encoder_cleanup(encoder);
1469 static const struct drm_encoder_funcs
1471 .destroy = nv50_sor_destroy,
1475 nv50_sor_create(struct drm_connector *connector, struct dcb_output *dcbe)
1477 struct nouveau_connector *nv_connector = nouveau_connector(connector);
1478 struct nouveau_drm *drm = nouveau_drm(connector->dev);
1479 struct nvkm_bios *bios = nvxx_bios(&drm->client.device);
1480 struct nvkm_i2c *i2c = nvxx_i2c(&drm->client.device);
1481 struct nouveau_encoder *nv_encoder;
1482 struct drm_encoder *encoder;
1483 u8 ver, hdr, cnt, len;
1487 switch (dcbe->type) {
1488 case DCB_OUTPUT_LVDS: type = DRM_MODE_ENCODER_LVDS; break;
1489 case DCB_OUTPUT_TMDS:
1492 type = DRM_MODE_ENCODER_TMDS;
1496 nv_encoder = kzalloc(sizeof(*nv_encoder), GFP_KERNEL);
1499 nv_encoder->dcb = dcbe;
1500 nv_encoder->update = nv50_sor_update;
1502 encoder = to_drm_encoder(nv_encoder);
1503 encoder->possible_crtcs = dcbe->heads;
1504 encoder->possible_clones = 0;
1505 drm_encoder_init(connector->dev, encoder, &nv50_sor_func, type,
1506 "sor-%04x-%04x", dcbe->hasht, dcbe->hashm);
1507 drm_encoder_helper_add(encoder, &nv50_sor_help);
1509 drm_connector_attach_encoder(connector, encoder);
1511 if (dcbe->type == DCB_OUTPUT_DP) {
1512 struct nv50_disp *disp = nv50_disp(encoder->dev);
1513 struct nvkm_i2c_aux *aux =
1514 nvkm_i2c_aux_find(i2c, dcbe->i2c_index);
1516 if (disp->disp->object.oclass < GF110_DISP) {
1517 /* HW has no support for address-only
1518 * transactions, so we're required to
1519 * use custom I2C-over-AUX code.
1521 nv_encoder->i2c = &aux->i2c;
1523 nv_encoder->i2c = &nv_connector->aux.ddc;
1525 nv_encoder->aux = aux;
1528 if ((data = nvbios_dp_table(bios, &ver, &hdr, &cnt, &len)) &&
1529 ver >= 0x40 && (nvbios_rd08(bios, data + 0x08) & 0x04)) {
1530 ret = nv50_mstm_new(nv_encoder, &nv_connector->aux, 16,
1531 nv_connector->base.base.id,
1532 &nv_encoder->dp.mstm);
1537 struct nvkm_i2c_bus *bus =
1538 nvkm_i2c_bus_find(i2c, dcbe->i2c_index);
1540 nv_encoder->i2c = &bus->i2c;
1546 /******************************************************************************
1548 *****************************************************************************/
1550 nv50_pior_atomic_check(struct drm_encoder *encoder,
1551 struct drm_crtc_state *crtc_state,
1552 struct drm_connector_state *conn_state)
1554 int ret = nv50_outp_atomic_check(encoder, crtc_state, conn_state);
1557 crtc_state->adjusted_mode.clock *= 2;
1562 nv50_pior_disable(struct drm_encoder *encoder)
1564 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
1565 struct nv50_core *core = nv50_disp(encoder->dev)->core;
1566 if (nv_encoder->crtc)
1567 core->func->pior->ctrl(core, nv_encoder->or, 0x00000000, NULL);
1568 nv_encoder->crtc = NULL;
1569 nv50_outp_release(nv_encoder);
1573 nv50_pior_enable(struct drm_encoder *encoder)
1575 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
1576 struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc);
1577 struct nouveau_connector *nv_connector;
1578 struct nv50_head_atom *asyh = nv50_head_atom(nv_crtc->base.state);
1579 struct nv50_core *core = nv50_disp(encoder->dev)->core;
1580 u8 owner = 1 << nv_crtc->index;
1583 nv50_outp_acquire(nv_encoder);
1585 nv_connector = nouveau_encoder_connector_get(nv_encoder);
1586 switch (nv_connector->base.display_info.bpc) {
1587 case 10: asyh->or.depth = 0x6; break;
1588 case 8: asyh->or.depth = 0x5; break;
1589 case 6: asyh->or.depth = 0x2; break;
1590 default: asyh->or.depth = 0x0; break;
1593 switch (nv_encoder->dcb->type) {
1594 case DCB_OUTPUT_TMDS:
1603 core->func->pior->ctrl(core, nv_encoder->or, (proto << 8) | owner, asyh);
1604 nv_encoder->crtc = encoder->crtc;
1607 static const struct drm_encoder_helper_funcs
1609 .atomic_check = nv50_pior_atomic_check,
1610 .enable = nv50_pior_enable,
1611 .disable = nv50_pior_disable,
1615 nv50_pior_destroy(struct drm_encoder *encoder)
1617 drm_encoder_cleanup(encoder);
1621 static const struct drm_encoder_funcs
1623 .destroy = nv50_pior_destroy,
1627 nv50_pior_create(struct drm_connector *connector, struct dcb_output *dcbe)
1629 struct nouveau_drm *drm = nouveau_drm(connector->dev);
1630 struct nvkm_i2c *i2c = nvxx_i2c(&drm->client.device);
1631 struct nvkm_i2c_bus *bus = NULL;
1632 struct nvkm_i2c_aux *aux = NULL;
1633 struct i2c_adapter *ddc;
1634 struct nouveau_encoder *nv_encoder;
1635 struct drm_encoder *encoder;
1638 switch (dcbe->type) {
1639 case DCB_OUTPUT_TMDS:
1640 bus = nvkm_i2c_bus_find(i2c, NVKM_I2C_BUS_EXT(dcbe->extdev));
1641 ddc = bus ? &bus->i2c : NULL;
1642 type = DRM_MODE_ENCODER_TMDS;
1645 aux = nvkm_i2c_aux_find(i2c, NVKM_I2C_AUX_EXT(dcbe->extdev));
1646 ddc = aux ? &aux->i2c : NULL;
1647 type = DRM_MODE_ENCODER_TMDS;
1653 nv_encoder = kzalloc(sizeof(*nv_encoder), GFP_KERNEL);
1656 nv_encoder->dcb = dcbe;
1657 nv_encoder->i2c = ddc;
1658 nv_encoder->aux = aux;
1660 encoder = to_drm_encoder(nv_encoder);
1661 encoder->possible_crtcs = dcbe->heads;
1662 encoder->possible_clones = 0;
1663 drm_encoder_init(connector->dev, encoder, &nv50_pior_func, type,
1664 "pior-%04x-%04x", dcbe->hasht, dcbe->hashm);
1665 drm_encoder_helper_add(encoder, &nv50_pior_help);
1667 drm_connector_attach_encoder(connector, encoder);
1671 /******************************************************************************
1673 *****************************************************************************/
1676 nv50_disp_atomic_commit_core(struct drm_atomic_state *state, u32 *interlock)
1678 struct nouveau_drm *drm = nouveau_drm(state->dev);
1679 struct nv50_disp *disp = nv50_disp(drm->dev);
1680 struct nv50_core *core = disp->core;
1681 struct nv50_mstm *mstm;
1682 struct drm_encoder *encoder;
1684 NV_ATOMIC(drm, "commit core %08x\n", interlock[NV50_DISP_INTERLOCK_BASE]);
1686 drm_for_each_encoder(encoder, drm->dev) {
1687 if (encoder->encoder_type != DRM_MODE_ENCODER_DPMST) {
1688 mstm = nouveau_encoder(encoder)->dp.mstm;
1689 if (mstm && mstm->modified)
1690 nv50_mstm_prepare(mstm);
1694 core->func->ntfy_init(disp->sync, NV50_DISP_CORE_NTFY);
1695 core->func->update(core, interlock, true);
1696 if (core->func->ntfy_wait_done(disp->sync, NV50_DISP_CORE_NTFY,
1697 disp->core->chan.base.device))
1698 NV_ERROR(drm, "core notifier timeout\n");
1700 drm_for_each_encoder(encoder, drm->dev) {
1701 if (encoder->encoder_type != DRM_MODE_ENCODER_DPMST) {
1702 mstm = nouveau_encoder(encoder)->dp.mstm;
1703 if (mstm && mstm->modified)
1704 nv50_mstm_cleanup(mstm);
1710 nv50_disp_atomic_commit_wndw(struct drm_atomic_state *state, u32 *interlock)
1712 struct drm_plane_state *new_plane_state;
1713 struct drm_plane *plane;
1716 for_each_new_plane_in_state(state, plane, new_plane_state, i) {
1717 struct nv50_wndw *wndw = nv50_wndw(plane);
1718 if (interlock[wndw->interlock.type] & wndw->interlock.data) {
1719 if (wndw->func->update)
1720 wndw->func->update(wndw, interlock);
1726 nv50_disp_atomic_commit_tail(struct drm_atomic_state *state)
1728 struct drm_device *dev = state->dev;
1729 struct drm_crtc_state *new_crtc_state, *old_crtc_state;
1730 struct drm_crtc *crtc;
1731 struct drm_plane_state *new_plane_state;
1732 struct drm_plane *plane;
1733 struct nouveau_drm *drm = nouveau_drm(dev);
1734 struct nv50_disp *disp = nv50_disp(dev);
1735 struct nv50_atom *atom = nv50_atom(state);
1736 struct nv50_outp_atom *outp, *outt;
1737 u32 interlock[NV50_DISP_INTERLOCK__SIZE] = {};
1740 NV_ATOMIC(drm, "commit %d %d\n", atom->lock_core, atom->flush_disable);
1741 drm_atomic_helper_wait_for_fences(dev, state, false);
1742 drm_atomic_helper_wait_for_dependencies(state);
1743 drm_atomic_helper_update_legacy_modeset_state(dev, state);
1745 if (atom->lock_core)
1746 mutex_lock(&disp->mutex);
1748 /* Disable head(s). */
1749 for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
1750 struct nv50_head_atom *asyh = nv50_head_atom(new_crtc_state);
1751 struct nv50_head *head = nv50_head(crtc);
1753 NV_ATOMIC(drm, "%s: clr %04x (set %04x)\n", crtc->name,
1754 asyh->clr.mask, asyh->set.mask);
1755 if (old_crtc_state->active && !new_crtc_state->active)
1756 drm_crtc_vblank_off(crtc);
1758 if (asyh->clr.mask) {
1759 nv50_head_flush_clr(head, asyh, atom->flush_disable);
1760 interlock[NV50_DISP_INTERLOCK_CORE] |= 1;
1764 /* Disable plane(s). */
1765 for_each_new_plane_in_state(state, plane, new_plane_state, i) {
1766 struct nv50_wndw_atom *asyw = nv50_wndw_atom(new_plane_state);
1767 struct nv50_wndw *wndw = nv50_wndw(plane);
1769 NV_ATOMIC(drm, "%s: clr %02x (set %02x)\n", plane->name,
1770 asyw->clr.mask, asyw->set.mask);
1771 if (!asyw->clr.mask)
1774 nv50_wndw_flush_clr(wndw, interlock, atom->flush_disable, asyw);
1777 /* Disable output path(s). */
1778 list_for_each_entry(outp, &atom->outp, head) {
1779 const struct drm_encoder_helper_funcs *help;
1780 struct drm_encoder *encoder;
1782 encoder = outp->encoder;
1783 help = encoder->helper_private;
1785 NV_ATOMIC(drm, "%s: clr %02x (set %02x)\n", encoder->name,
1786 outp->clr.mask, outp->set.mask);
1788 if (outp->clr.mask) {
1789 help->disable(encoder);
1790 interlock[NV50_DISP_INTERLOCK_CORE] |= 1;
1791 if (outp->flush_disable) {
1792 nv50_disp_atomic_commit_wndw(state, interlock);
1793 nv50_disp_atomic_commit_core(state, interlock);
1794 memset(interlock, 0x00, sizeof(interlock));
1799 /* Flush disable. */
1800 if (interlock[NV50_DISP_INTERLOCK_CORE]) {
1801 if (atom->flush_disable) {
1802 nv50_disp_atomic_commit_wndw(state, interlock);
1803 nv50_disp_atomic_commit_core(state, interlock);
1804 memset(interlock, 0x00, sizeof(interlock));
1808 /* Update output path(s). */
1809 list_for_each_entry_safe(outp, outt, &atom->outp, head) {
1810 const struct drm_encoder_helper_funcs *help;
1811 struct drm_encoder *encoder;
1813 encoder = outp->encoder;
1814 help = encoder->helper_private;
1816 NV_ATOMIC(drm, "%s: set %02x (clr %02x)\n", encoder->name,
1817 outp->set.mask, outp->clr.mask);
1819 if (outp->set.mask) {
1820 help->enable(encoder);
1821 interlock[NV50_DISP_INTERLOCK_CORE] = 1;
1824 list_del(&outp->head);
1828 /* Update head(s). */
1829 for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
1830 struct nv50_head_atom *asyh = nv50_head_atom(new_crtc_state);
1831 struct nv50_head *head = nv50_head(crtc);
1833 NV_ATOMIC(drm, "%s: set %04x (clr %04x)\n", crtc->name,
1834 asyh->set.mask, asyh->clr.mask);
1836 if (asyh->set.mask) {
1837 nv50_head_flush_set(head, asyh);
1838 interlock[NV50_DISP_INTERLOCK_CORE] = 1;
1841 if (new_crtc_state->active) {
1842 if (!old_crtc_state->active)
1843 drm_crtc_vblank_on(crtc);
1844 if (new_crtc_state->event)
1845 drm_crtc_vblank_get(crtc);
1849 /* Update plane(s). */
1850 for_each_new_plane_in_state(state, plane, new_plane_state, i) {
1851 struct nv50_wndw_atom *asyw = nv50_wndw_atom(new_plane_state);
1852 struct nv50_wndw *wndw = nv50_wndw(plane);
1854 NV_ATOMIC(drm, "%s: set %02x (clr %02x)\n", plane->name,
1855 asyw->set.mask, asyw->clr.mask);
1856 if ( !asyw->set.mask &&
1857 (!asyw->clr.mask || atom->flush_disable))
1860 nv50_wndw_flush_set(wndw, interlock, asyw);
1864 nv50_disp_atomic_commit_wndw(state, interlock);
1866 if (interlock[NV50_DISP_INTERLOCK_CORE]) {
1867 if (interlock[NV50_DISP_INTERLOCK_BASE] ||
1868 interlock[NV50_DISP_INTERLOCK_OVLY] ||
1869 interlock[NV50_DISP_INTERLOCK_WNDW] ||
1870 !atom->state.legacy_cursor_update)
1871 nv50_disp_atomic_commit_core(state, interlock);
1873 disp->core->func->update(disp->core, interlock, false);
1876 if (atom->lock_core)
1877 mutex_unlock(&disp->mutex);
1879 /* Wait for HW to signal completion. */
1880 for_each_new_plane_in_state(state, plane, new_plane_state, i) {
1881 struct nv50_wndw_atom *asyw = nv50_wndw_atom(new_plane_state);
1882 struct nv50_wndw *wndw = nv50_wndw(plane);
1883 int ret = nv50_wndw_wait_armed(wndw, asyw);
1885 NV_ERROR(drm, "%s: timeout\n", plane->name);
1888 for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
1889 if (new_crtc_state->event) {
1890 unsigned long flags;
1891 /* Get correct count/ts if racing with vblank irq */
1892 if (new_crtc_state->active)
1893 drm_crtc_accurate_vblank_count(crtc);
1894 spin_lock_irqsave(&crtc->dev->event_lock, flags);
1895 drm_crtc_send_vblank_event(crtc, new_crtc_state->event);
1896 spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
1898 new_crtc_state->event = NULL;
1899 if (new_crtc_state->active)
1900 drm_crtc_vblank_put(crtc);
1904 drm_atomic_helper_commit_hw_done(state);
1905 drm_atomic_helper_cleanup_planes(dev, state);
1906 drm_atomic_helper_commit_cleanup_done(state);
1907 drm_atomic_state_put(state);
1911 nv50_disp_atomic_commit_work(struct work_struct *work)
1913 struct drm_atomic_state *state =
1914 container_of(work, typeof(*state), commit_work);
1915 nv50_disp_atomic_commit_tail(state);
1919 nv50_disp_atomic_commit(struct drm_device *dev,
1920 struct drm_atomic_state *state, bool nonblock)
1922 struct nouveau_drm *drm = nouveau_drm(dev);
1923 struct drm_plane_state *new_plane_state;
1924 struct drm_plane *plane;
1925 struct drm_crtc *crtc;
1926 bool active = false;
1929 ret = pm_runtime_get_sync(dev->dev);
1930 if (ret < 0 && ret != -EACCES)
1933 ret = drm_atomic_helper_setup_commit(state, nonblock);
1937 INIT_WORK(&state->commit_work, nv50_disp_atomic_commit_work);
1939 ret = drm_atomic_helper_prepare_planes(dev, state);
1944 ret = drm_atomic_helper_wait_for_fences(dev, state, true);
1949 ret = drm_atomic_helper_swap_state(state, true);
1953 for_each_new_plane_in_state(state, plane, new_plane_state, i) {
1954 struct nv50_wndw_atom *asyw = nv50_wndw_atom(new_plane_state);
1955 struct nv50_wndw *wndw = nv50_wndw(plane);
1957 if (asyw->set.image)
1958 nv50_wndw_ntfy_enable(wndw, asyw);
1961 drm_atomic_state_get(state);
1964 queue_work(system_unbound_wq, &state->commit_work);
1966 nv50_disp_atomic_commit_tail(state);
1968 drm_for_each_crtc(crtc, dev) {
1969 if (crtc->state->active) {
1970 if (!drm->have_disp_power_ref) {
1971 drm->have_disp_power_ref = true;
1979 if (!active && drm->have_disp_power_ref) {
1980 pm_runtime_put_autosuspend(dev->dev);
1981 drm->have_disp_power_ref = false;
1986 drm_atomic_helper_cleanup_planes(dev, state);
1988 pm_runtime_put_autosuspend(dev->dev);
1992 static struct nv50_outp_atom *
1993 nv50_disp_outp_atomic_add(struct nv50_atom *atom, struct drm_encoder *encoder)
1995 struct nv50_outp_atom *outp;
1997 list_for_each_entry(outp, &atom->outp, head) {
1998 if (outp->encoder == encoder)
2002 outp = kzalloc(sizeof(*outp), GFP_KERNEL);
2004 return ERR_PTR(-ENOMEM);
2006 list_add(&outp->head, &atom->outp);
2007 outp->encoder = encoder;
2012 nv50_disp_outp_atomic_check_clr(struct nv50_atom *atom,
2013 struct drm_connector_state *old_connector_state)
2015 struct drm_encoder *encoder = old_connector_state->best_encoder;
2016 struct drm_crtc_state *old_crtc_state, *new_crtc_state;
2017 struct drm_crtc *crtc;
2018 struct nv50_outp_atom *outp;
2020 if (!(crtc = old_connector_state->crtc))
2023 old_crtc_state = drm_atomic_get_old_crtc_state(&atom->state, crtc);
2024 new_crtc_state = drm_atomic_get_new_crtc_state(&atom->state, crtc);
2025 if (old_crtc_state->active && drm_atomic_crtc_needs_modeset(new_crtc_state)) {
2026 outp = nv50_disp_outp_atomic_add(atom, encoder);
2028 return PTR_ERR(outp);
2030 if (outp->encoder->encoder_type == DRM_MODE_ENCODER_DPMST) {
2031 outp->flush_disable = true;
2032 atom->flush_disable = true;
2034 outp->clr.ctrl = true;
2035 atom->lock_core = true;
2042 nv50_disp_outp_atomic_check_set(struct nv50_atom *atom,
2043 struct drm_connector_state *connector_state)
2045 struct drm_encoder *encoder = connector_state->best_encoder;
2046 struct drm_crtc_state *new_crtc_state;
2047 struct drm_crtc *crtc;
2048 struct nv50_outp_atom *outp;
2050 if (!(crtc = connector_state->crtc))
2053 new_crtc_state = drm_atomic_get_new_crtc_state(&atom->state, crtc);
2054 if (new_crtc_state->active && drm_atomic_crtc_needs_modeset(new_crtc_state)) {
2055 outp = nv50_disp_outp_atomic_add(atom, encoder);
2057 return PTR_ERR(outp);
2059 outp->set.ctrl = true;
2060 atom->lock_core = true;
2067 nv50_disp_atomic_check(struct drm_device *dev, struct drm_atomic_state *state)
2069 struct nv50_atom *atom = nv50_atom(state);
2070 struct drm_connector_state *old_connector_state, *new_connector_state;
2071 struct drm_connector *connector;
2072 struct drm_crtc_state *new_crtc_state;
2073 struct drm_crtc *crtc;
2076 /* We need to handle colour management on a per-plane basis. */
2077 for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
2078 if (new_crtc_state->color_mgmt_changed) {
2079 ret = drm_atomic_add_affected_planes(state, crtc);
2085 ret = drm_atomic_helper_check(dev, state);
2089 for_each_oldnew_connector_in_state(state, connector, old_connector_state, new_connector_state, i) {
2090 ret = nv50_disp_outp_atomic_check_clr(atom, old_connector_state);
2094 ret = nv50_disp_outp_atomic_check_set(atom, new_connector_state);
2103 nv50_disp_atomic_state_clear(struct drm_atomic_state *state)
2105 struct nv50_atom *atom = nv50_atom(state);
2106 struct nv50_outp_atom *outp, *outt;
2108 list_for_each_entry_safe(outp, outt, &atom->outp, head) {
2109 list_del(&outp->head);
2113 drm_atomic_state_default_clear(state);
2117 nv50_disp_atomic_state_free(struct drm_atomic_state *state)
2119 struct nv50_atom *atom = nv50_atom(state);
2120 drm_atomic_state_default_release(&atom->state);
2124 static struct drm_atomic_state *
2125 nv50_disp_atomic_state_alloc(struct drm_device *dev)
2127 struct nv50_atom *atom;
2128 if (!(atom = kzalloc(sizeof(*atom), GFP_KERNEL)) ||
2129 drm_atomic_state_init(dev, &atom->state) < 0) {
2133 INIT_LIST_HEAD(&atom->outp);
2134 return &atom->state;
2137 static const struct drm_mode_config_funcs
2139 .fb_create = nouveau_user_framebuffer_create,
2140 .output_poll_changed = nouveau_fbcon_output_poll_changed,
2141 .atomic_check = nv50_disp_atomic_check,
2142 .atomic_commit = nv50_disp_atomic_commit,
2143 .atomic_state_alloc = nv50_disp_atomic_state_alloc,
2144 .atomic_state_clear = nv50_disp_atomic_state_clear,
2145 .atomic_state_free = nv50_disp_atomic_state_free,
2148 /******************************************************************************
2150 *****************************************************************************/
2153 nv50_display_fini(struct drm_device *dev)
2155 struct nouveau_encoder *nv_encoder;
2156 struct drm_encoder *encoder;
2157 struct drm_plane *plane;
2159 drm_for_each_plane(plane, dev) {
2160 struct nv50_wndw *wndw = nv50_wndw(plane);
2161 if (plane->funcs != &nv50_wndw)
2163 nv50_wndw_fini(wndw);
2166 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
2167 if (encoder->encoder_type != DRM_MODE_ENCODER_DPMST) {
2168 nv_encoder = nouveau_encoder(encoder);
2169 nv50_mstm_fini(nv_encoder->dp.mstm);
2175 nv50_display_init(struct drm_device *dev)
2177 struct nv50_core *core = nv50_disp(dev)->core;
2178 struct drm_encoder *encoder;
2179 struct drm_plane *plane;
2181 core->func->init(core);
2183 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
2184 if (encoder->encoder_type != DRM_MODE_ENCODER_DPMST) {
2185 struct nouveau_encoder *nv_encoder =
2186 nouveau_encoder(encoder);
2187 nv50_mstm_init(nv_encoder->dp.mstm);
2191 drm_for_each_plane(plane, dev) {
2192 struct nv50_wndw *wndw = nv50_wndw(plane);
2193 if (plane->funcs != &nv50_wndw)
2195 nv50_wndw_init(wndw);
2202 nv50_display_destroy(struct drm_device *dev)
2204 struct nv50_disp *disp = nv50_disp(dev);
2206 nv50_core_del(&disp->core);
2208 nouveau_bo_unmap(disp->sync);
2210 nouveau_bo_unpin(disp->sync);
2211 nouveau_bo_ref(NULL, &disp->sync);
2213 nouveau_display(dev)->priv = NULL;
2218 nv50_display_create(struct drm_device *dev)
2220 struct nvif_device *device = &nouveau_drm(dev)->client.device;
2221 struct nouveau_drm *drm = nouveau_drm(dev);
2222 struct dcb_table *dcb = &drm->vbios.dcb;
2223 struct drm_connector *connector, *tmp;
2224 struct nv50_disp *disp;
2225 struct dcb_output *dcbe;
2228 disp = kzalloc(sizeof(*disp), GFP_KERNEL);
2232 mutex_init(&disp->mutex);
2234 nouveau_display(dev)->priv = disp;
2235 nouveau_display(dev)->dtor = nv50_display_destroy;
2236 nouveau_display(dev)->init = nv50_display_init;
2237 nouveau_display(dev)->fini = nv50_display_fini;
2238 disp->disp = &nouveau_display(dev)->disp;
2239 dev->mode_config.funcs = &nv50_disp_func;
2240 dev->mode_config.quirk_addfb_prefer_xbgr_30bpp = true;
2242 /* small shared memory area we use for notifiers and semaphores */
2243 ret = nouveau_bo_new(&drm->client, 4096, 0x1000, TTM_PL_FLAG_VRAM,
2244 0, 0x0000, NULL, NULL, &disp->sync);
2246 ret = nouveau_bo_pin(disp->sync, TTM_PL_FLAG_VRAM, true);
2248 ret = nouveau_bo_map(disp->sync);
2250 nouveau_bo_unpin(disp->sync);
2253 nouveau_bo_ref(NULL, &disp->sync);
2259 /* allocate master evo channel */
2260 ret = nv50_core_new(drm, &disp->core);
2264 /* create crtc objects to represent the hw heads */
2265 if (disp->disp->object.oclass >= GV100_DISP)
2266 crtcs = nvif_rd32(&device->object, 0x610060) & 0xff;
2268 if (disp->disp->object.oclass >= GF110_DISP)
2269 crtcs = nvif_rd32(&device->object, 0x612004) & 0xf;
2273 for (i = 0; i < fls(crtcs); i++) {
2274 if (!(crtcs & (1 << i)))
2276 ret = nv50_head_create(dev, i);
2281 /* create encoder/connector objects based on VBIOS DCB table */
2282 for (i = 0, dcbe = &dcb->entry[0]; i < dcb->entries; i++, dcbe++) {
2283 connector = nouveau_connector_create(dev, dcbe->connector);
2284 if (IS_ERR(connector))
2287 if (dcbe->location == DCB_LOC_ON_CHIP) {
2288 switch (dcbe->type) {
2289 case DCB_OUTPUT_TMDS:
2290 case DCB_OUTPUT_LVDS:
2292 ret = nv50_sor_create(connector, dcbe);
2294 case DCB_OUTPUT_ANALOG:
2295 ret = nv50_dac_create(connector, dcbe);
2302 ret = nv50_pior_create(connector, dcbe);
2306 NV_WARN(drm, "failed to create encoder %d/%d/%d: %d\n",
2307 dcbe->location, dcbe->type,
2308 ffs(dcbe->or) - 1, ret);
2313 /* cull any connectors we created that don't have an encoder */
2314 list_for_each_entry_safe(connector, tmp, &dev->mode_config.connector_list, head) {
2315 if (connector->encoder_ids[0])
2318 NV_WARN(drm, "%s has no encoders, removing\n",
2320 connector->funcs->destroy(connector);
2323 /* Disable vblank irqs aggressively for power-saving, safe on nv50+ */
2324 dev->vblank_disable_immediate = true;
2328 nv50_display_destroy(dev);