2019-06-20 03:13:43 +03:00
|
|
|
/* SPDX-License-Identifier: MIT */
|
2012-07-31 10:16:21 +04:00
|
|
|
#ifndef __NOUVEAU_DISPLAY_H__
|
|
|
|
#define __NOUVEAU_DISPLAY_H__
|
2019-05-19 17:00:42 +03:00
|
|
|
|
2016-05-20 02:22:55 +03:00
|
|
|
#include "nouveau_drv.h"
|
2019-05-19 17:00:42 +03:00
|
|
|
|
2018-05-08 13:39:47 +03:00
|
|
|
#include <nvif/disp.h>
|
2012-07-31 10:16:21 +04:00
|
|
|
|
2019-05-19 17:00:42 +03:00
|
|
|
#include <drm/drm_framebuffer.h>
|
|
|
|
|
2020-02-06 13:19:41 +03:00
|
|
|
int
|
|
|
|
nouveau_framebuffer_new(struct drm_device *dev,
|
|
|
|
const struct drm_mode_fb_cmd2 *mode_cmd,
|
|
|
|
struct drm_gem_object *gem,
|
2020-02-06 13:19:42 +03:00
|
|
|
struct drm_framebuffer **pfb);
|
2012-07-31 10:16:21 +04:00
|
|
|
|
|
|
|
struct nouveau_display {
|
|
|
|
void *priv;
|
|
|
|
void (*dtor)(struct drm_device *);
|
2019-02-12 15:28:13 +03:00
|
|
|
int (*init)(struct drm_device *, bool resume, bool runtime);
|
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 21:24:44 +03:00
|
|
|
void (*fini)(struct drm_device *, bool suspend, bool runtime);
|
2012-07-31 10:16:21 +04:00
|
|
|
|
2018-05-08 13:39:47 +03:00
|
|
|
struct nvif_disp disp;
|
2014-08-09 22:10:19 +04:00
|
|
|
|
2012-07-31 10:16:21 +04:00
|
|
|
struct drm_property *dithering_mode;
|
|
|
|
struct drm_property *dithering_depth;
|
|
|
|
struct drm_property *underscan_property;
|
|
|
|
struct drm_property *underscan_hborder_property;
|
|
|
|
struct drm_property *underscan_vborder_property;
|
|
|
|
/* not really hue and saturation: */
|
|
|
|
struct drm_property *vibrant_hue_property;
|
|
|
|
struct drm_property *color_vibrance_property;
|
2016-11-04 10:20:36 +03:00
|
|
|
|
|
|
|
struct drm_atomic_state *suspend;
|
2020-02-11 02:15:53 +03:00
|
|
|
|
|
|
|
const u64 *format_modifiers;
|
2012-07-31 10:16:21 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct nouveau_display *
|
|
|
|
nouveau_display(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
return nouveau_drm(dev)->display;
|
|
|
|
}
|
|
|
|
|
|
|
|
int nouveau_display_create(struct drm_device *dev);
|
|
|
|
void nouveau_display_destroy(struct drm_device *dev);
|
2019-02-12 15:28:13 +03:00
|
|
|
int nouveau_display_init(struct drm_device *dev, bool resume, bool runtime);
|
2020-08-26 21:24:48 +03:00
|
|
|
void nouveau_display_hpd_resume(struct drm_device *dev);
|
2018-08-08 00:32:48 +03:00
|
|
|
void nouveau_display_fini(struct drm_device *dev, bool suspend, bool runtime);
|
2014-10-02 07:22:27 +04:00
|
|
|
int nouveau_display_suspend(struct drm_device *dev, bool runtime);
|
|
|
|
void nouveau_display_resume(struct drm_device *dev, bool runtime);
|
2020-01-23 16:59:30 +03:00
|
|
|
int nouveau_display_vblank_enable(struct drm_crtc *crtc);
|
|
|
|
void nouveau_display_vblank_disable(struct drm_crtc *crtc);
|
2020-01-23 16:59:29 +03:00
|
|
|
bool nouveau_display_scanoutpos(struct drm_crtc *crtc,
|
|
|
|
bool in_vblank_irq, int *vpos, int *hpos,
|
|
|
|
ktime_t *stime, ktime_t *etime,
|
|
|
|
const struct drm_display_mode *mode);
|
2012-07-31 10:16:21 +04:00
|
|
|
|
|
|
|
int nouveau_display_dumb_create(struct drm_file *, struct drm_device *,
|
|
|
|
struct drm_mode_create_dumb *args);
|
|
|
|
int nouveau_display_dumb_map_offset(struct drm_file *, struct drm_device *,
|
|
|
|
u32 handle, u64 *offset);
|
|
|
|
|
|
|
|
void nouveau_hdmi_mode_set(struct drm_encoder *, struct drm_display_mode *);
|
|
|
|
|
2020-02-11 02:15:55 +03:00
|
|
|
void
|
|
|
|
nouveau_framebuffer_get_layout(struct drm_framebuffer *fb, uint32_t *tile_mode,
|
|
|
|
uint8_t *kind);
|
|
|
|
|
2016-11-04 10:20:36 +03:00
|
|
|
struct drm_framebuffer *
|
|
|
|
nouveau_user_framebuffer_create(struct drm_device *, struct drm_file *,
|
|
|
|
const struct drm_mode_fb_cmd2 *);
|
2012-07-31 10:16:21 +04:00
|
|
|
#endif
|