2009-12-11 19:24:15 +10:00
|
|
|
/*
|
|
|
|
* Copyright 2009 Red Hat Inc.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
* Author: Ben Skeggs
|
|
|
|
*/
|
|
|
|
|
2012-10-02 18:01:07 +01:00
|
|
|
#include <drm/drm_crtc_helper.h>
|
2009-12-11 19:24:15 +10:00
|
|
|
|
2016-05-20 09:22:55 +10:00
|
|
|
#include "nouveau_drv.h"
|
2012-07-31 16:16:21 +10:00
|
|
|
#include "nouveau_reg.h"
|
2013-03-21 15:45:11 +10:00
|
|
|
#include "hw.h"
|
2009-12-11 19:24:15 +10:00
|
|
|
#include "nouveau_encoder.h"
|
|
|
|
#include "nouveau_connector.h"
|
2019-02-12 22:28:13 +10:00
|
|
|
#include "nouveau_bo.h"
|
2020-02-06 11:19:41 +01:00
|
|
|
#include "nouveau_gem.h"
|
2020-06-22 19:48:59 +10:00
|
|
|
#include "nouveau_chan.h"
|
2009-12-11 19:24:15 +10:00
|
|
|
|
2019-02-12 22:28:13 +10:00
|
|
|
#include <nvif/if0004.h>
|
|
|
|
|
2020-08-26 14:24:42 -04:00
|
|
|
struct nouveau_connector *
|
|
|
|
nv04_encoder_get_connector(struct nouveau_encoder *encoder)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = to_drm_encoder(encoder)->dev;
|
|
|
|
struct drm_connector *connector;
|
|
|
|
struct drm_connector_list_iter conn_iter;
|
|
|
|
struct nouveau_connector *nv_connector = NULL;
|
|
|
|
|
|
|
|
drm_connector_list_iter_begin(dev, &conn_iter);
|
|
|
|
drm_for_each_connector_iter(connector, &conn_iter) {
|
|
|
|
if (connector->encoder == to_drm_encoder(encoder))
|
|
|
|
nv_connector = nouveau_connector(connector);
|
|
|
|
}
|
|
|
|
drm_connector_list_iter_end(&conn_iter);
|
|
|
|
|
|
|
|
return nv_connector;
|
|
|
|
}
|
|
|
|
|
2019-02-12 22:28:13 +10:00
|
|
|
static void
|
drm/nouveau/kms/nv50-: Refactor and cleanup DP HPD handling
First some backstory here: Currently, we keep track of whether or not
we've enabled MST or not by trying to piggy-back off the MST helpers.
This means that in order to check whether MST is enabled or not, we
actually need to grab drm_dp_mst_topology_mgr.lock.
Back when I originally wrote this, I did this piggy-backing with the
intention that I'd eventually be teaching our MST helpers how to recover
when an MST device has stopped responding, which in turn would require
the MST helpers having a way of disabling MST independently of the
driver. Note that this was before I reworked locking in the MST helpers,
so at the time we were sticking random things under &mgr->lock - which
grabbing this lock was meant to protect against.
This never came to fruition because doing such a reset safely turned out
to be a lot more painful and impossible then it sounds, and also just
risks us working around issues with our MST handlers that should be
properly fixed instead. Even if it did though, simply calling
drm_dp_mst_topology_mgr_set_mst() from the MST helpers (with the
exception of when we're tearing down our MST managers, that's always OK)
wouldn't have been a bad idea, since drivers like nouveau and i915 need
to do their own book keeping immediately after disabling MST.
So-implementing that would likely require adding a hook for
helper-triggered MST disables anyway.
So, fast forward to now - we want to start adding support for all of the
miscellaneous bits of the DP protocol (for both SST and MST) we're
missing before moving on to supporting more complicated features like
supporting different BPP values on MST, DSC, etc. Since many of these
features only exist on SST and make use of DP HPD IRQs, we want to be
able to atomically check whether we're servicing an MST IRQ or SST IRQ
in nouveau_connector_hotplug(). Currently we literally don't do this at
all, and just handle any kind of possible DP IRQ we could get including
ESIs - even if MST isn't actually enabled.
This would be very complicated and difficult to fix if we need to hold
&mgr->lock while handling SST IRQs to ensure that the MST topology
state doesn't change under us. What we really want here is to do our own
tracking of whether MST is enabled or not, similar to drivers like i915,
and define our own locking order to decomplicate things and avoid
hitting locking issues in the future.
So, let's do this by refactoring our MST probing/enabling code to use
our own MST bookkeeping, along with adding a lock for protecting DP
state that needs to be checked outside of our connector probing
functions. While we're at it, we also remove a bunch of unneeded steps
we perform when probing/enabling MST:
* Enabling bits in MSTM_CTRL before calling drm_dp_mst_topology_mgr_set_mst().
I don't think these ever actually did anything, since the nvif methods
for enabling MST don't actually do anything DPCD related and merely
indicate to nvkm that we've turned on MST.
* Checking the MSTM_CTRL bit is intact when checking the state of an
enabled MST topology in nv50_mstm_detect(). I just added this to be safe
originally, but now that we try reading the DPCD when probing DP
connectors it shouldn't be needed as that will abort our hotplug probing
if the device was removed well before we start checking for MST..
* All of the duplicate DPCD version checks.
This leaves us with much nicer looking code, a much more sensible
locking scheme, and an easy way of checking whether MST is enabled or
not for handling DP HPD IRQs.
v2:
* Get rid of accidental newlines
v4:
* Fix uninitialized usage of mstm in nv50_mstm_detect() - thanks kernel
bot!
Signed-off-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200826182456.322681-9-lyude@redhat.com
2020-08-26 14:24:44 -04:00
|
|
|
nv04_display_fini(struct drm_device *dev, bool runtime, bool suspend)
|
2019-02-12 22:28:13 +10:00
|
|
|
{
|
drm/nouveau/kms/nv50-: Refactor and cleanup DP HPD handling
First some backstory here: Currently, we keep track of whether or not
we've enabled MST or not by trying to piggy-back off the MST helpers.
This means that in order to check whether MST is enabled or not, we
actually need to grab drm_dp_mst_topology_mgr.lock.
Back when I originally wrote this, I did this piggy-backing with the
intention that I'd eventually be teaching our MST helpers how to recover
when an MST device has stopped responding, which in turn would require
the MST helpers having a way of disabling MST independently of the
driver. Note that this was before I reworked locking in the MST helpers,
so at the time we were sticking random things under &mgr->lock - which
grabbing this lock was meant to protect against.
This never came to fruition because doing such a reset safely turned out
to be a lot more painful and impossible then it sounds, and also just
risks us working around issues with our MST handlers that should be
properly fixed instead. Even if it did though, simply calling
drm_dp_mst_topology_mgr_set_mst() from the MST helpers (with the
exception of when we're tearing down our MST managers, that's always OK)
wouldn't have been a bad idea, since drivers like nouveau and i915 need
to do their own book keeping immediately after disabling MST.
So-implementing that would likely require adding a hook for
helper-triggered MST disables anyway.
So, fast forward to now - we want to start adding support for all of the
miscellaneous bits of the DP protocol (for both SST and MST) we're
missing before moving on to supporting more complicated features like
supporting different BPP values on MST, DSC, etc. Since many of these
features only exist on SST and make use of DP HPD IRQs, we want to be
able to atomically check whether we're servicing an MST IRQ or SST IRQ
in nouveau_connector_hotplug(). Currently we literally don't do this at
all, and just handle any kind of possible DP IRQ we could get including
ESIs - even if MST isn't actually enabled.
This would be very complicated and difficult to fix if we need to hold
&mgr->lock while handling SST IRQs to ensure that the MST topology
state doesn't change under us. What we really want here is to do our own
tracking of whether MST is enabled or not, similar to drivers like i915,
and define our own locking order to decomplicate things and avoid
hitting locking issues in the future.
So, let's do this by refactoring our MST probing/enabling code to use
our own MST bookkeeping, along with adding a lock for protecting DP
state that needs to be checked outside of our connector probing
functions. While we're at it, we also remove a bunch of unneeded steps
we perform when probing/enabling MST:
* Enabling bits in MSTM_CTRL before calling drm_dp_mst_topology_mgr_set_mst().
I don't think these ever actually did anything, since the nvif methods
for enabling MST don't actually do anything DPCD related and merely
indicate to nvkm that we've turned on MST.
* Checking the MSTM_CTRL bit is intact when checking the state of an
enabled MST topology in nv50_mstm_detect(). I just added this to be safe
originally, but now that we try reading the DPCD when probing DP
connectors it shouldn't be needed as that will abort our hotplug probing
if the device was removed well before we start checking for MST..
* All of the duplicate DPCD version checks.
This leaves us with much nicer looking code, a much more sensible
locking scheme, and an easy way of checking whether MST is enabled or
not for handling DP HPD IRQs.
v2:
* Get rid of accidental newlines
v4:
* Fix uninitialized usage of mstm in nv50_mstm_detect() - thanks kernel
bot!
Signed-off-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200826182456.322681-9-lyude@redhat.com
2020-08-26 14:24:44 -04:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2019-02-12 22:28:13 +10:00
|
|
|
struct nv04_display *disp = nv04_display(dev);
|
2019-02-12 22:28:13 +10:00
|
|
|
struct drm_crtc *crtc;
|
2019-02-12 22:28:13 +10:00
|
|
|
|
|
|
|
/* Disable flip completion events. */
|
2022-06-01 20:46:39 +10:00
|
|
|
nvif_event_block(&disp->flip);
|
2019-02-12 22:28:13 +10:00
|
|
|
|
2019-02-12 22:28:13 +10:00
|
|
|
/* Disable vblank interrupts. */
|
|
|
|
NVWriteCRTC(dev, 0, NV_PCRTC_INTR_EN_0, 0);
|
|
|
|
if (nv_two_heads(dev))
|
|
|
|
NVWriteCRTC(dev, 1, NV_PCRTC_INTR_EN_0, 0);
|
2019-02-12 22:28:13 +10:00
|
|
|
|
2024-06-07 15:09:32 -07:00
|
|
|
if (!runtime && !drm->headless)
|
drm/nouveau/kms/nv50-: Refactor and cleanup DP HPD handling
First some backstory here: Currently, we keep track of whether or not
we've enabled MST or not by trying to piggy-back off the MST helpers.
This means that in order to check whether MST is enabled or not, we
actually need to grab drm_dp_mst_topology_mgr.lock.
Back when I originally wrote this, I did this piggy-backing with the
intention that I'd eventually be teaching our MST helpers how to recover
when an MST device has stopped responding, which in turn would require
the MST helpers having a way of disabling MST independently of the
driver. Note that this was before I reworked locking in the MST helpers,
so at the time we were sticking random things under &mgr->lock - which
grabbing this lock was meant to protect against.
This never came to fruition because doing such a reset safely turned out
to be a lot more painful and impossible then it sounds, and also just
risks us working around issues with our MST handlers that should be
properly fixed instead. Even if it did though, simply calling
drm_dp_mst_topology_mgr_set_mst() from the MST helpers (with the
exception of when we're tearing down our MST managers, that's always OK)
wouldn't have been a bad idea, since drivers like nouveau and i915 need
to do their own book keeping immediately after disabling MST.
So-implementing that would likely require adding a hook for
helper-triggered MST disables anyway.
So, fast forward to now - we want to start adding support for all of the
miscellaneous bits of the DP protocol (for both SST and MST) we're
missing before moving on to supporting more complicated features like
supporting different BPP values on MST, DSC, etc. Since many of these
features only exist on SST and make use of DP HPD IRQs, we want to be
able to atomically check whether we're servicing an MST IRQ or SST IRQ
in nouveau_connector_hotplug(). Currently we literally don't do this at
all, and just handle any kind of possible DP IRQ we could get including
ESIs - even if MST isn't actually enabled.
This would be very complicated and difficult to fix if we need to hold
&mgr->lock while handling SST IRQs to ensure that the MST topology
state doesn't change under us. What we really want here is to do our own
tracking of whether MST is enabled or not, similar to drivers like i915,
and define our own locking order to decomplicate things and avoid
hitting locking issues in the future.
So, let's do this by refactoring our MST probing/enabling code to use
our own MST bookkeeping, along with adding a lock for protecting DP
state that needs to be checked outside of our connector probing
functions. While we're at it, we also remove a bunch of unneeded steps
we perform when probing/enabling MST:
* Enabling bits in MSTM_CTRL before calling drm_dp_mst_topology_mgr_set_mst().
I don't think these ever actually did anything, since the nvif methods
for enabling MST don't actually do anything DPCD related and merely
indicate to nvkm that we've turned on MST.
* Checking the MSTM_CTRL bit is intact when checking the state of an
enabled MST topology in nv50_mstm_detect(). I just added this to be safe
originally, but now that we try reading the DPCD when probing DP
connectors it shouldn't be needed as that will abort our hotplug probing
if the device was removed well before we start checking for MST..
* All of the duplicate DPCD version checks.
This leaves us with much nicer looking code, a much more sensible
locking scheme, and an easy way of checking whether MST is enabled or
not for handling DP HPD IRQs.
v2:
* Get rid of accidental newlines
v4:
* Fix uninitialized usage of mstm in nv50_mstm_detect() - thanks kernel
bot!
Signed-off-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200826182456.322681-9-lyude@redhat.com
2020-08-26 14:24:44 -04:00
|
|
|
cancel_work_sync(&drm->hpd_work);
|
|
|
|
|
2019-02-12 22:28:13 +10:00
|
|
|
if (!suspend)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Un-pin FB and cursors so they'll be evicted to system memory. */
|
|
|
|
list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
|
2020-02-06 11:19:41 +01:00
|
|
|
struct drm_framebuffer *fb = crtc->primary->fb;
|
|
|
|
struct nouveau_bo *nvbo;
|
2019-02-12 22:28:13 +10:00
|
|
|
|
2020-02-06 11:19:41 +01:00
|
|
|
if (!fb || !fb->obj[0])
|
2019-02-12 22:28:13 +10:00
|
|
|
continue;
|
2020-02-06 11:19:41 +01:00
|
|
|
nvbo = nouveau_gem_object(fb->obj[0]);
|
|
|
|
nouveau_bo_unpin(nvbo);
|
2019-02-12 22:28:13 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
|
|
|
|
struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
|
|
|
|
if (nv_crtc->cursor.nvbo) {
|
|
|
|
if (nv_crtc->cursor.set_offset)
|
|
|
|
nouveau_bo_unmap(nv_crtc->cursor.nvbo);
|
|
|
|
nouveau_bo_unpin(nv_crtc->cursor.nvbo);
|
|
|
|
}
|
|
|
|
}
|
2019-02-12 22:28:13 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2019-02-12 22:28:13 +10:00
|
|
|
nv04_display_init(struct drm_device *dev, bool resume, bool runtime)
|
2019-02-12 22:28:13 +10:00
|
|
|
{
|
2019-02-12 22:28:13 +10:00
|
|
|
struct nv04_display *disp = nv04_display(dev);
|
2019-02-12 22:28:13 +10:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2019-02-12 22:28:13 +10:00
|
|
|
struct nouveau_encoder *encoder;
|
2019-02-12 22:28:13 +10:00
|
|
|
struct drm_crtc *crtc;
|
|
|
|
int ret;
|
2019-02-12 22:28:13 +10:00
|
|
|
|
|
|
|
/* meh.. modeset apparently doesn't setup all the regs and depends
|
|
|
|
* on pre-existing state, for now load the state of the card *before*
|
|
|
|
* nouveau was loaded, and then do a modeset.
|
|
|
|
*
|
|
|
|
* best thing to do probably is to make save/restore routines not
|
|
|
|
* save/restore "pre-load" state, but more general so we can save
|
|
|
|
* on suspend too.
|
|
|
|
*/
|
2019-02-12 22:28:13 +10:00
|
|
|
list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
|
|
|
|
struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
|
|
|
|
nv_crtc->save(&nv_crtc->base);
|
|
|
|
}
|
2019-02-12 22:28:13 +10:00
|
|
|
|
|
|
|
list_for_each_entry(encoder, &dev->mode_config.encoder_list, base.base.head)
|
|
|
|
encoder->enc_save(&encoder->base.base);
|
|
|
|
|
2019-02-12 22:28:13 +10:00
|
|
|
/* Enable flip completion events. */
|
2022-06-01 20:46:39 +10:00
|
|
|
nvif_event_allow(&disp->flip);
|
2019-02-12 22:28:13 +10:00
|
|
|
|
|
|
|
if (!resume)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Re-pin FB/cursors. */
|
|
|
|
list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
|
2020-02-06 11:19:41 +01:00
|
|
|
struct drm_framebuffer *fb = crtc->primary->fb;
|
|
|
|
struct nouveau_bo *nvbo;
|
2019-02-12 22:28:13 +10:00
|
|
|
|
2020-02-06 11:19:41 +01:00
|
|
|
if (!fb || !fb->obj[0])
|
2019-02-12 22:28:13 +10:00
|
|
|
continue;
|
2020-02-06 11:19:41 +01:00
|
|
|
nvbo = nouveau_gem_object(fb->obj[0]);
|
2020-09-08 14:39:36 +02:00
|
|
|
ret = nouveau_bo_pin(nvbo, NOUVEAU_GEM_DOMAIN_VRAM, true);
|
2019-02-12 22:28:13 +10:00
|
|
|
if (ret)
|
|
|
|
NV_ERROR(drm, "Could not pin framebuffer\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
|
|
|
|
struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
|
|
|
|
if (!nv_crtc->cursor.nvbo)
|
|
|
|
continue;
|
|
|
|
|
2020-09-08 14:39:36 +02:00
|
|
|
ret = nouveau_bo_pin(nv_crtc->cursor.nvbo,
|
|
|
|
NOUVEAU_GEM_DOMAIN_VRAM, true);
|
2019-02-12 22:28:13 +10:00
|
|
|
if (!ret && nv_crtc->cursor.set_offset)
|
|
|
|
ret = nouveau_bo_map(nv_crtc->cursor.nvbo);
|
|
|
|
if (ret)
|
|
|
|
NV_ERROR(drm, "Could not pin/map cursor.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Force CLUT to get re-loaded during modeset. */
|
|
|
|
list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
|
|
|
|
struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
|
|
|
|
|
|
|
|
nv_crtc->lut.depth = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This should ensure we don't hit a locking problem when someone
|
|
|
|
* wakes us up via a connector. We should never go into suspend
|
|
|
|
* while the display is on anyways.
|
|
|
|
*/
|
|
|
|
if (runtime)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Restore mode. */
|
|
|
|
drm_helper_resume_force_mode(dev);
|
|
|
|
|
|
|
|
list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
|
|
|
|
struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
|
|
|
|
|
|
|
|
if (!nv_crtc->cursor.nvbo)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (nv_crtc->cursor.set_offset)
|
2020-06-24 20:26:44 +02:00
|
|
|
nv_crtc->cursor.set_offset(nv_crtc,
|
|
|
|
nv_crtc->cursor.nvbo->offset);
|
2019-02-12 22:28:13 +10:00
|
|
|
nv_crtc->cursor.set_pos(nv_crtc, nv_crtc->cursor_saved_x,
|
|
|
|
nv_crtc->cursor_saved_y);
|
|
|
|
}
|
|
|
|
|
2019-02-12 22:28:13 +10:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
nv04_display_destroy(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
struct nv04_display *disp = nv04_display(dev);
|
|
|
|
struct nouveau_encoder *encoder;
|
|
|
|
struct nouveau_crtc *nv_crtc;
|
|
|
|
|
|
|
|
/* Restore state */
|
|
|
|
list_for_each_entry(encoder, &dev->mode_config.encoder_list, base.base.head)
|
|
|
|
encoder->enc_restore(&encoder->base.base);
|
|
|
|
|
|
|
|
list_for_each_entry(nv_crtc, &dev->mode_config.crtc_list, base.head)
|
|
|
|
nv_crtc->restore(&nv_crtc->base);
|
|
|
|
|
|
|
|
nouveau_hw_save_vga_fonts(dev, 0);
|
|
|
|
|
2022-06-01 20:46:39 +10:00
|
|
|
nvif_event_dtor(&disp->flip);
|
2019-02-12 22:28:13 +10:00
|
|
|
|
2019-02-12 22:28:13 +10:00
|
|
|
nouveau_display(dev)->priv = NULL;
|
2021-03-07 12:48:53 -05:00
|
|
|
vfree(disp);
|
2019-02-12 22:28:13 +10:00
|
|
|
}
|
|
|
|
|
2009-12-11 19:24:15 +10:00
|
|
|
int
|
|
|
|
nv04_display_create(struct drm_device *dev)
|
|
|
|
{
|
2012-07-31 16:16:21 +10:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2024-07-26 14:38:18 +10:00
|
|
|
struct nvkm_i2c *i2c = nvxx_i2c(drm);
|
2012-07-31 16:16:21 +10:00
|
|
|
struct dcb_table *dcb = &drm->vbios.dcb;
|
2010-06-28 14:35:50 +10:00
|
|
|
struct drm_connector *connector, *ct;
|
2009-12-11 19:24:15 +10:00
|
|
|
struct drm_encoder *encoder;
|
2015-12-04 17:14:07 +01:00
|
|
|
struct nouveau_encoder *nv_encoder;
|
2015-12-04 17:13:38 +01:00
|
|
|
struct nouveau_crtc *crtc;
|
2012-07-18 10:00:50 +10:00
|
|
|
struct nv04_display *disp;
|
2009-12-11 19:24:15 +10:00
|
|
|
int i, ret;
|
|
|
|
|
2021-03-07 12:48:53 -05:00
|
|
|
disp = vzalloc(sizeof(*disp));
|
2012-07-18 10:00:50 +10:00
|
|
|
if (!disp)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2022-06-01 20:46:39 +10:00
|
|
|
disp->drm = drm;
|
|
|
|
|
2012-07-31 16:16:21 +10:00
|
|
|
nouveau_display(dev)->priv = disp;
|
|
|
|
nouveau_display(dev)->dtor = nv04_display_destroy;
|
|
|
|
nouveau_display(dev)->init = nv04_display_init;
|
|
|
|
nouveau_display(dev)->fini = nv04_display_fini;
|
2009-12-11 19:24:15 +10:00
|
|
|
|
2018-07-03 16:31:41 -04:00
|
|
|
/* Pre-nv50 doesn't support atomic, so don't expose the ioctls */
|
2018-09-13 19:31:46 +03:00
|
|
|
dev->driver_features &= ~DRIVER_ATOMIC;
|
2018-07-03 16:31:41 -04:00
|
|
|
|
2019-02-12 22:28:13 +10:00
|
|
|
/* Request page flip completion event. */
|
2020-06-22 19:48:59 +10:00
|
|
|
if (drm->channel) {
|
2022-06-01 20:46:39 +10:00
|
|
|
ret = nvif_event_ctor(&drm->channel->nvsw, "kmsFlip", 0, nv04_flip_complete,
|
|
|
|
true, NULL, 0, &disp->flip);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2019-02-12 22:28:13 +10:00
|
|
|
}
|
|
|
|
|
2009-12-11 23:44:49 +01:00
|
|
|
nouveau_hw_save_vga_fonts(dev, 1);
|
2009-12-11 19:24:15 +10:00
|
|
|
|
|
|
|
nv04_crtc_create(dev, 0);
|
|
|
|
if (nv_two_heads(dev))
|
|
|
|
nv04_crtc_create(dev, 1);
|
|
|
|
|
|
|
|
for (i = 0; i < dcb->entries; i++) {
|
2012-07-11 10:44:20 +10:00
|
|
|
struct dcb_output *dcbent = &dcb->entry[i];
|
2009-12-11 19:24:15 +10:00
|
|
|
|
2023-09-19 17:56:37 -04:00
|
|
|
connector = nouveau_connector_create(dev, dcbent->connector);
|
2010-06-28 14:35:50 +10:00
|
|
|
if (IS_ERR(connector))
|
|
|
|
continue;
|
|
|
|
|
2009-12-11 19:24:15 +10:00
|
|
|
switch (dcbent->type) {
|
2012-07-11 10:44:20 +10:00
|
|
|
case DCB_OUTPUT_ANALOG:
|
2010-06-28 14:35:50 +10:00
|
|
|
ret = nv04_dac_create(connector, dcbent);
|
2009-12-11 19:24:15 +10:00
|
|
|
break;
|
2012-07-11 10:44:20 +10:00
|
|
|
case DCB_OUTPUT_LVDS:
|
|
|
|
case DCB_OUTPUT_TMDS:
|
2010-06-28 14:35:50 +10:00
|
|
|
ret = nv04_dfp_create(connector, dcbent);
|
2009-12-11 19:24:15 +10:00
|
|
|
break;
|
2012-07-11 10:44:20 +10:00
|
|
|
case DCB_OUTPUT_TV:
|
2009-12-11 19:24:15 +10:00
|
|
|
if (dcbent->location == DCB_LOC_ON_CHIP)
|
2010-06-28 14:35:50 +10:00
|
|
|
ret = nv17_tv_create(connector, dcbent);
|
2009-12-11 19:24:15 +10:00
|
|
|
else
|
2010-06-28 14:35:50 +10:00
|
|
|
ret = nv04_tv_create(connector, dcbent);
|
2009-12-11 19:24:15 +10:00
|
|
|
break;
|
|
|
|
default:
|
2012-07-31 16:16:21 +10:00
|
|
|
NV_WARN(drm, "DCB type %d not known\n", dcbent->type);
|
2009-12-11 19:24:15 +10:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret)
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-06-28 14:35:50 +10:00
|
|
|
list_for_each_entry_safe(connector, ct,
|
|
|
|
&dev->mode_config.connector_list, head) {
|
2019-09-13 16:28:57 -07:00
|
|
|
if (!connector->possible_encoders) {
|
2012-07-31 16:16:21 +10:00
|
|
|
NV_WARN(drm, "%s has no encoders, removing\n",
|
2014-06-03 14:56:18 +03:00
|
|
|
connector->name);
|
2010-06-28 14:35:50 +10:00
|
|
|
connector->funcs->destroy(connector);
|
|
|
|
}
|
|
|
|
}
|
2009-12-11 19:24:15 +10:00
|
|
|
|
2013-02-11 20:15:03 +10:00
|
|
|
list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
|
|
|
|
struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
|
2015-08-20 14:54:15 +10:00
|
|
|
struct nvkm_i2c_bus *bus =
|
|
|
|
nvkm_i2c_bus_find(i2c, nv_encoder->dcb->i2c_index);
|
|
|
|
nv_encoder->i2c = bus ? &bus->i2c : NULL;
|
2013-02-11 20:15:03 +10:00
|
|
|
}
|
|
|
|
|
2009-12-11 19:24:15 +10:00
|
|
|
/* Save previous state */
|
2015-12-04 17:13:38 +01:00
|
|
|
list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head)
|
|
|
|
crtc->save(&crtc->base);
|
2009-12-11 19:24:15 +10:00
|
|
|
|
2015-12-04 17:14:07 +01:00
|
|
|
list_for_each_entry(nv_encoder, &dev->mode_config.encoder_list, base.base.head)
|
|
|
|
nv_encoder->enc_save(&nv_encoder->base.base);
|
2009-12-11 19:24:15 +10:00
|
|
|
|
2013-09-07 20:33:43 -04:00
|
|
|
nouveau_overlay_init(dev);
|
|
|
|
|
2009-12-11 19:24:15 +10:00
|
|
|
return 0;
|
|
|
|
}
|