Commit Graph

28 Commits

Author SHA1 Message Date
Łukasz Spintzyk 5be3b80b8d modesetting: Remove few common functions from ms namespace
A lot of that code is the same as in xf86-amdgpu and xf86-nouveau drivers. By removing that functions from
ms namespace we can move that code to common implementation.

Signed-off-by: Łukasz Spintzyk <lukasz.spintzyk@synaptics.com>
2021-04-16 10:53:43 +00:00
Olivier Fourdan 3ce05a44f3 modesetting: Fix build with DebugPresent() enabled
By default, the macro DebugPresent() is a no-op but it can be enabled
at build time for debugging purpose.

However, doing so prevents the code to build because one debug statement
tries to make use of a non-existent variable:

  present.c: In function ‘ms_present_queue_vblank’:
  present.c:147:18: error: ‘vbl’ undeclared (first use in this function)
    147 |                  vbl.request.sequence));
        |                  ^~~
  present.c:49:32: note: in definition of macro ‘DebugPresent’
    49 | #define DebugPresent(x) ErrorF x
       |                                ^

Fix the build with DebugPresent() by removing the vbl variable from the
debug message.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
2020-11-26 22:06:56 +00:00
Uday Kiran Pichika 9823ea4ed2 modesetting: Lay the foundation for enabling VRR
These changes have been ported from AMD GPU DDX driver.

This patch adds support for setting the CRTC variable refresh property
for suitable windows flipping via the Present extension.

In order for a window to be suitable for variable refresh it must have
the _VARIABLE_REFRESH property set by the MESA and inform Modesetting
DDX driver with window property updates.

Then the window must pass the checks required to be suitable for
Present extension flips - it must cover the entire X screen and no
other window may already be flipping. And also DRM connector should
be VRR capable.

With these conditions met every CRTC for the X screen will have their
variable refresh property set to true.

Kernel Changes to support this feature in I915 driver is under development.

Tested with DOTA2, Xonotic and custom GLX apps.

Signed-off-by: Uday Kiran Pichika <pichika.uday.kiran@intel.com>
2020-09-08 08:00:20 +00:00
Adam Jackson cb1b1e1847 Revert "Revert "modesetting: Indirect the glamor API through LoaderSymbol""
Now that we've fixed LoaderSymbolFromModule this should work properly.

This reverts commit 5c7c6d5cff.

Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-11-21 14:20:57 -05:00
Michel Dänzer 5c7c6d5cff Revert "modesetting: Indirect the glamor API through LoaderSymbol"
This reverts commit dd63f717fe.

Caused a crash at least on some systems.

Closes: https://gitlab.freedesktop.org/xorg/xserver/issues/934
2019-11-15 11:32:38 +01:00
Adam Jackson dd63f717fe modesetting: Indirect the glamor API through LoaderSymbol
Prerequisite for building all of xserver with -z now.

Gitlab: https://gitlab.freedesktop.org/xorg/xserver/issues/692
2019-11-13 19:49:18 +00:00
Alex Goins 562c7888be modesetting: Implement ms_covering_randr_crtc() for ms_present_get_crtc()
ms_present_get_crtc() returns an RRCrtcPtr, but derives it from a xf86CrtcPtr
found via ms_dri2_crtc_covering_drawable()=>ms_covering_crtc(). As a result, it
depends on all associated DIX ScreenRecs having an xf86CrtcConfigPtr DDX
private.

Some DIX ScreenRecs don't have an xf86CrtcConfigPtr DDX private, but do have an
rrScrPrivPtr DDX private. Given that we can derive all of the information we
need from RandR, we can support these screens by avoiding the use of xf86Crtc.
This change implements an RandR-based path for ms_present_get_crtc(), allowing
drawables to successfully fall back to syncing to the primary output, even if
the slave doesn't have an xf86CrtcConfigPtr DDX private.

Without this change, if a slave doesn't have an xf86CrtcConfigPtr DDX private,
drawables will fall back to 1 FPS if they overlap an output on that slave.

Signed-off-by: Alex Goins <agoins@nvidia.com>
2019-11-11 14:35:57 -08:00
Hans de Goede 12821852f0 modesetting: Avoid duplicate error messages on present-flip errors
Currently on present-flip failures we log 2 messages for each failure,
1 from ms_do_pageflip and then another one from ms_present_flip which
is the caller of ms_do_pageflip. This commit adds a log_prefix argument
to ms_do_pageflip so that its log messages can show if it is a DRI2 or
a Present flip which fails and removes the redundant error message from
ms_present_flip.

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-08-09 10:50:55 +02:00
Hans de Goede 0aaac8d783 modesetting: Disable pageflipping when using a swcursor
The miPointerSpriteFunc swcursor code expects there to only be a single
framebuffer and when the cursor moves it will undo the damage of the
previous draw, potentially overwriting what ever is there in a new
framebuffer installed after a flip.

This leads to all kind of artifacts, so we need to disable pageflipping
when a swcursor is used.

The code for this has shamelessly been copied from the xf86-video-amdgpu
code.

Fixes: https://gitlab.freedesktop.org/xorg/xserver/issues/828

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-08-06 17:22:02 +02:00
Louis-Francis Ratté-Boulianne 6cace4990a modesetting: Fix GBM objects leak when checking for flip
GBM objects were never destroyed after looking for format and
modifier compatibility when deciding whether flipping or copying
a presented pixmap.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106106
Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
2018-04-30 14:01:02 -04:00
Adam Jackson ba0c751772 modesetting: Fix up some XXX from removing GLAMOR_HAS_DRM_*
Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2018-03-22 15:00:06 -04:00
Emil Velikov 22b489d273 Remove always true GLAMOR_HAS_DRM_* guards
With earlier commit the required version was bumped to 2.4.89, thus the
guards always evaluate to true.

Fixes: e4e3447603 ("Add RandR leases with modesetting driver support
[v6]")
Cc: Keith Packard <keithp@keithp.com>
Cc: Daniel Stone <daniels@collabora.com>
Cc: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-03-21 10:06:12 -04:00
Louis-Francis Ratté-Boulianne 9d147305b4 modesetting: Check if buffer format is supported when flipping
Add support for 'check_flip2' so that the present core can know
why it is impossible to flip in that scenario. The core can then
let know the client that the buffer format/modifier is suboptimal.

v2: No longer need to implement 'check_flip'

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-03-05 13:27:47 -05:00
Louis-Francis Ratté-Boulianne 9817c14f6a modesetting: Use atomic modesetting to configure output/CRTCs
To make sure we also use the same primary plane and to avoid
mixing uses of two APIs, it is better to always use the atomic
modesetting API when possible.

v2: Don't use mode_output->connector_id

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-03-05 13:27:40 -05:00
Keith Packard 677c32bcda xf86-video-modesetting: Add ms_queue_vblank helper [v3]
This provides an API wrapper around the kernel interface for queueing
a vblank event, simplifying all of the callers.

v2: Fix missing '|' in computing vbl.request.type

v3: Remove spurious bit of next patch (thanks, Michel Dänzer)

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2017-10-04 15:17:41 -04:00
Eric Anholt 32957d9fae modesetting: Drop code for GLAMOR && !GLAMOR_HAS_GBM.
The glamor_egl module that the GLAMOR paths are using is only built if
GLAMOR_HAS_GBM is true, and there's no plan for implementing the
module without GBM.  Simplify modesetting's code as a result.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
2017-05-18 11:33:05 -04:00
Qiang Yu f06aef31c0 modesetting: add DRI2 page flip support
Signed-off-by: Qiang Yu <Qiang.Yu@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2016-09-02 13:58:09 -04:00
Qiang Yu 4a839da627 modesetting: move common page flip handle to pageflip.c
The common page flip handle framework can be shared with DRI2
page flip.

Signed-off-by: Qiang Yu <Qiang.Yu@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2016-09-02 13:57:42 -04:00
Qiang Yu 4f1eb7864b modesetting: move ms_do_pageflip to pageflip.c
Signed-off-by: Qiang Yu <Qiang.Yu@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2016-09-02 13:56:10 -04:00
Qiang Yu a586bf9ccf modesetting: make ms_do_pageflip generic for share with DRI2
Signed-off-by: Qiang Yu <Qiang.Yu@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2016-09-02 13:46:42 -04:00
Keith Packard d403aca70a Switch poll() users to xserver_poll()
This uses the wrapper in case we need to emulate poll with select
as we do on Windows.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2016-07-21 15:04:36 -04:00
Lyude Paul 848089e0dd modesetting: Clear drmmode->fb_id before unflipping
[fix copied from 40191d82370e in xf86-video-ati]

Without this, we end up setting rotated CRTCs back to their previous
framebuffer right after we perform a rotation. Reproducer:

- Have two monitors connected at the same resolution
- Rotate one monitor from normal straight to inverted
- Watch as the monitor you didn't rotate either freezes or shows intense
  flickering

Signed-off-by: Lyude <cpaul@redhat.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2016-06-17 11:38:13 +02:00
Alan Coopersmith fe8562f531 modesetting should not reference gbm when it's not defined
Fixes build errors of:
present.c: In function 'ms_do_pageflip':
present.c:410:17: error: 'drmmode_bo' has no member named 'gbm'
     new_front_bo.gbm = glamor_gbm_bo_from_pixmap(screen, new_front);
                 ^
present.c:412:22: error: 'drmmode_bo' has no member named 'gbm'
     if (!new_front_bo.gbm) {
                      ^
present.c: In function 'ms_present_check_flip':
present.c:536:36: error: 'drmmode_bo' has no member named 'gbm'
         if (drmmode_crtc->rotate_bo.gbm)
                                    ^
Introduced by commit 13c7d53d

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2016-01-05 13:23:56 -05:00
Dave Airlie e3624aa5fd xserver: fix build with glamor disabled.
This fixes modesetting when glamor is disabled.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2015-07-06 12:01:33 -07:00
Kenneth Graunke 13c7d53df8 modesetting: Implement page flipping support for Present.
Based on code by Keith Packard, Eric Anholt, and Jason Ekstrand.

v2:
- Fix double free and flip_count underrun (caught by Mario Kleiner).
- Don't leak flip_vblank_event on the error_out path (Mario).
- Use the updated ms_flush_drm_events API (Mario, Ken).

v3: Hack around DPMS shenanigans.  If all monitors are DPMS off, then
    there is no active framebuffer; attempting to pageflip will hit the
    error_undo paths, causing us to drmModeRmFB with no framebuffer,
    which confuses the kernel into doing full modesets and generally
    breaks things.  To avoid this, make ms_present_check_flip check that
    some CRTCs are enabled and DPMS on.  This is an ugly hack that would
    get better with atomic modesetting, or some core Present work.

v4:
- Don't do pageflipping if CRTCs are rotated (caught by Jason Ekstrand).
- Make pageflipping optional (Option "PageFlip" in xorg.conf.d), but
  enabled by default.

v5: Initialize num_crtcs_on to 0 (caught by Michel Dänzer).

[airlied: took over]
v6: merge async flip support from Mario Kleiner
free sequence after failed vblank queue
handle unflip while DPMS'ed off (Michel)
move flip tracking into its own structure, and
fix up reference counting issues, and add comments.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2015-06-30 13:44:09 +10:00
Kenneth Graunke f6853baeba modesetting: Improve the ms_flush_drm_events() API.
Previously, ms_flush_drm_events() returned a boolean value, and it was
very easy to interpret the meaning incorrectly.  Now, we return an
integer value.

The possible outcomes of this call are:
- poll() raised an error (formerly TRUE, now -1 - poll's return value)
- poll() said there are no events (formerly TRUE, now 0).
- drmHandleEvent() raised an error (formerly FALSE, now the negative
  value returned by drmHandleEvent).
- An event was successfully handled (formerly TRUE, now 1).

The nice part is that this allows you to distinguish errors (< 0),
nothing to do (= 0), and success (1).  We no longer conflate errors
with success.

v2: Change ms_present_queue_vblank to < 0 instead of <= 0, fixing an
    unintentional behavior change.  libdrm may return EBUSY if it's
    received EINTR for more than a second straight; just keep retrying
    in that case.  Suggested by Jasper St. Pierre.

Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2015-06-30 13:44:09 +10:00
Kenneth Graunke 6672606420 modesetting: Fix build with --disable-glamor.
present.c: In function 'ms_present_flush':
present.c:204:9: error: implicit declaration of function
'glamor_block_handler'

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=87858
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Jasper St. Pierre <jstpierre@mecheye.net>
Reviewed-by: Rob Clark <robdclark@gmail.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2015-01-01 10:52:30 -08:00
Kenneth Graunke 09230a2d43 modesetting: Add vblank synchronization support when using Present.
modesetting hooked up vblank support for DRI2, but was missing support
for vblanks in Present.

This is mostly copy and pasted from Keith's code in the intel driver.

v2: Use ms_crtc_msc_to_kernel_msc in ms_present_queue_vblank to hook
    up the vblank_offset workaround for bogus MSC values (which the
    DRI2 code already did).

    Also simplify the ms_present_get_crtc function.  vblank.c already
    implements the functionality; we just need to convert types.

v3: Fix ms_flush_drm_events return code.  I'd copied code where 0 meant
    success into a function that returned a boolean, so the return code
    was always backwards.

    Also add DebugPresent calls in ms_present_vblank_{handler,abort}.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Keith Packard <keithp@keithp.com>
Tested-by: Jason Ekstrand <jason.ekstrand@intel.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2014-12-25 13:39:19 -08:00