Commit Graph

51 Commits

Author SHA1 Message Date
Louis-Francis Ratté-Boulianne
cef12efc15 glamor: Implement GetSupportedModifiers
Implement function added in DRI3 v1.1.

A newest version of libepoxy (>= 1.4.4) is required as earlier
versions use a problematic version of Khronos
EXT_image_dma_buf_import_modifiers spec.

v4: Only send scanout-supported modifiers if flipping is possible
v5: Fix memory corruption in XWayland (uninitialized pointer)

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:55 -05: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
ca1c390ec7 modesetting: Get supported formats/modifiers for scanout
Retrieve IN_FORMATS property from the plane. It gives the
allowed formats and modifiers for BO allocation.

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:42 -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
Louis-Francis Ratté-Boulianne
2f807c2324 modesetting: Add support for multi-plane pixmaps when page-flipping
This allows the uses of CCS compressed or tiled pixmaps as BOs when
page-flipping.

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:36 -05:00
Louis-Francis Ratté-Boulianne
4023d53734 modesetting: Use atomic modesetting API for pageflip if available
In order to flip between compressed and uncompressed buffers -
something drmModePageFlip explicitly bans us from doing - we need
to port use the atomic modesetting API. It's only 'fake' atomic
though given we still commit for each CRTC separately and
CRTC and connector properties are not set with the atomic API.

The helper functions to retrieve DRM properties have been borrowed
from Weston.

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:34 -05:00
Keith Packard
e4e3447603 Add RandR leases with modesetting driver support [v6]
This adds support for RandR CRTC/Output leases through the modesetting
driver, creating a lease using new kernel infrastructure and returning
that to a client through an fd which will have access to only those
resources.

v2:	Restore CRTC mode when leases terminate

	When a lease terminates for a crtc we have saved data for, go
	ahead and restore the saved mode.

v3:	Report RR_Rotate_0 rotations for leased crtcs.

	Ignore leased CRTCs when selecting screen size.

	Stop leasing encoders, the kernel doesn't do that anymore.

	Turn off crtc->enabled while leased so that modesetting
	ignores them.

	Check lease status before calling any driver mode functions

	When starting a lease, mark leased CRTCs as disabled and hide
	their cursors. Also, check to see if there are other
	non-leased CRTCs which are driving leased Outputs and mark
	them as disabled as well. Sometimes an application will lease
	an idle crtc instead of the one already associated with the
	leased output.

	When terminating a lease, reset any CRTCs which are driving
	outputs that are no longer leased so that they start working
	again.

	This required splitting the DIX level lease termination code
	into two pieces, one to remove the lease from the system
	(RRLeaseTerminated) and a new function that frees the lease
	data structure (RRLeaseFree).

v4:	Report RR_Rotate_0 rotation for leased crtcs.

v5: Terminate all leases on server reset.

	Leases hang around after the associated client exits so that
	the client doesn't need to occupy an X server client slot and
	consume a file descriptor once it has gotten the output
	resources necessary.

	Any leases still hanging around when the X server resets or
	shuts down need to be cleaned up by calling the kernel to
	terminate the lease and freeing any DIX structures.

	Note that we cannot simply use the existing
	drmmode_terminate_lease function on each lease as that wants
	to also reset the video mode, and during server shut down that

   modesetting: Validate leases on VT enter

	The kernel doesn't allow any master ioctls to run when another
	VT is active, including simple things like listing the active
	leases. To deal with that, we check the list of leases
	whenever the X server VT is activated.

   xfree86: hide disabled cursors when resetting after lease termination

	The lessee may well have played with cursors and left one
	active on our screen. Just tell the kernel to turn it off.

v6:	Add meson build infrastructure

[Also bumped libdrm requirement - ajax]

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-02-27 12:39:50 -05:00
Jeffrey Smith
9227237806 modesetting: Do not close uninitialized dri2 screen
If a dri2 screen is not successfully initialized, attempting to close it
results in a null dereference.

Maintain a flag indicating whether the dri2 screen was successfully
initialized, and check it before attempting to close the dri2 screen.

https://bugzilla.redhat.com/show_bug.cgi?id=1485811
https://bugzilla.redhat.com/show_bug.cgi?id=1493805
https://bugzilla.redhat.com/show_bug.cgi?id=1534459
https://bugzilla.redhat.com/show_bug.cgi?id=1541745
https://bugs.freedesktop.org/show_bug.cgi?id=101282

Signed-off-by: Jeff Smith <whydoubt@gmail.com>
2018-02-26 16:41:42 -05:00
Daniel Martin
d5379b350f Use ARRAY_SIZE all over the tree
Roundhouse kick replacing the various (sizeof(foo)/sizeof(foo[0])) with
the ARRAY_SIZE macro from dix.h when possible. A semantic patch for
coccinelle has been used first. Additionally, a few macros have been
inlined as they had only one or two users.

Signed-off-by: Daniel Martin <consume.noise@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2017-10-30 13:45:20 -04:00
Michel Dänzer
8e3b26ceaa Make PixmapDirtyUpdateRec::src a DrawablePtr
This allows making the master screen's pixmap_dirty_list entries
explicitly reflect that we're now tracking the root window instead of
the screen pixmap, in order to allow Present page flipping on master
outputs while there are active slave outputs.

Define HAS_DIRTYTRACKING_DRAWABLE_SRC for drivers to check, but leave
HAS_DIRTYTRACKING_ROTATION defined as well to make things slightly
easier for drivers.

Reviewed-by: Adam Jackson <ajax@redhat.com>
2017-08-15 17:01:39 +09:00
Michael Thayer
eb04b20160 modesetting: allow switching from software to hardware cursors (v5).
Currently if modesetting ever fails to set a hardware cursor it will switch
to using a software cursor and never go back.  Change this to only
permanently switch to a software cursor if -ENXIO is returned (which means
hardware cursors not supported), and to otherwise still try a hardware
cursor first every time a new one is set.  This is needed because hardware
may be able to handle some cursors in hardware and others not, or virtual
hardware may be able to handle hardware cursors at some times and not
others.

Changes since v1, v2 and v3:
 * take into account the switch to load_cursor_argb_check
 * keep the permanent software cursor fall-back if -ENXIO is returned
 * move parts of v3 into separate patches

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Michael Thayer <michael.thayer@oracle.com>
2017-02-08 12:04:42 -05:00
Michael Thayer
ecd0a62323 modesetting: Immediately handle failure to set HW cursor, v5
Based on v4 by Alexandre Courbot <acourbot@nvidia.com>

There is currently no reliable way to report failure to set a HW
cursor. Still such failures can happen if e.g. the MODE_CURSOR DRM
ioctl fails (which currently happens at least with modesetting on Tegra
for format incompatibility reasons).

As failures are currently handled by setting the HW cursor size to
(0,0), the fallback to SW cursor will not happen until the next time the
cursor changes and xf86CursorSetCursor() is called again. In the
meantime, the cursor will be invisible to the user.

This patch addresses that by adding _xf86CrtcFuncs::set_cursor_check and
_xf86CursorInfoRec::ShowCursorCheck hook variants that return booleans.
This allows to propagate errors up to xf86CursorSetCursor(), which can
then fall back to using the SW cursor immediately.

v5:
 - Removed parts of patch already committed as part of 14c21ea1.
 - Adjusted code slightly to match surrounding code.
 - Effectively reverted af916477 which is made unnecessary by this patch.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Michael Thayer <michael.thayer@oracle.com>
2017-02-08 12:04:42 -05: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
Hans De Goede
6c984ac9a7 modesetting: Do not use function local static variables
The modesetting driver may be driving 2 screens (slave and master
gpu), which may have different behavior wrt hardware cursor support.

So stop using static variables and instead store the hw-cursor support
related data in a per screen struct. While at it actually make it per
crtc data as in theory different crtc's could have different hw-cursor
support.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2016-09-02 13:04:00 -04:00
Kenneth Graunke
d3d4ff0ed4 modesetting: Delete dead drmmode_bo_for_pixmap function.
Embarassingly, it looks like I introduced this dead function in
commit 13c7d53df8 a year ago.
Nothing ever used it, not even then.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
2016-08-08 23:42:40 -07:00
Adam Jackson
fcbafdfd79 modesetting: Implement a double-buffered shadow mode
Server GPUs often have a VNC feature attached to allow remote console.
The controller implementing this feature is usually not very powerful,
and we can easily swamp it with work.  This is made somewhat worse by
damage over-reporting the size of the dirty region, and a whole lot
worse by applications (or shells) that update the screen with identical
pixel content as was already there.

Fix this by double-buffering the shadow fb, using memcmp to identify
dirty tiles on each update pass.  Since both shadows are in host memory
the memcmp is cheap, and worth it given the win in network bandwidth.
The tile size is somewhat arbitrarily chosen to be one cacheline wide at
32bpp on Intel Core.

By default we enable this behaviour for (a subset of) known server GPUs;
the heuristic could use work.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2016-07-02 09:54:07 +02:00
Adam Jackson
75e660e379 modesetting: Drop some non-functional triple-buffering variables
Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2016-07-02 09:28:04 +02:00
Dave Airlie
21217d0216 modesetting: Implement 32->24 bpp conversion in shadow update
24bpp front buffers tend to be the least well tested path for client
rendering.  On the qemu cirrus emulation, and on some Matrox G200 server
chips, the hardware can't do 32bpp at all.  It's better to just allocate
a 32bpp shadow and downconvert in the upload hook than expose a funky
pixmap format to clients.

[ajax: Ported from RHEL and separate modesetting driver, lifted kbpp
into the drmmode struct, cleaned up commit message, fixed 16bpp]

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Dave Airlied <airlied@redhat.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
[hdegoede@redhat.com: rebase, also use kbpp for rotate shadow fb]
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2016-07-02 09:28:04 +02:00
Alex Goins
b83dede9cb modesetting: Implement PRIME syncing as a source
Implements (Start/Stop)FlippingPixmapTracking, PresentSharedPixmap, and
RequestSharedPixmapNotifyDamage, the source functions for PRIME
synchronization and double buffering. Allows modesetting driver to be used
as a source with PRIME synchronization.

v1: N/A
v2: N/A
v3: N/A
v4: Initial commit
v5: Move disabling of reverse PRIME on sink to sink commit
v6: Rebase onto ToT
v7: Unchanged

Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Alex Goins <agoins@nvidia.com>
2016-06-28 12:56:45 -04:00
Alex Goins
80e64dae8a modesetting: Implement PRIME syncing as a sink
Implements (Enable/Disable)SharedPixmapFlipping and
SharedPixmapNotifyDamage, the sink functions for PRIME synchronization and
double buffering. Allows modesetting driver to be used as a sink with PRIME
synchronization.

Changes dispatch_slave_dirty to flush damage from both scanout pixmaps.

Changes drmmode_set_scanout_pixmap*() functions to
drmmode_set_target_scanout_pixmap*() that take an additional parameter
PixmapPtr *target. Then, treat *target as it did prime_pixmap. This allows
me to use it to explicitly set both prime_pixmap and prime_pixmap_back
individually. drmmode_set_scanout_pixmap() without the extra parameter
remains to cover the single-buffered case, but only works if we aren't
already double buffered.

driver.c:
    Add plumbing for rr(Enable/Disable)SharedPixmapFlipping and
    SharedPixmapNotifyDamage.

    Change dispatch_dirty_crtc to dispatch_dirty_pixmap, which functions the
    same but flushes damage associated with a ppriv instead of the crtc, and
    chanage dispatch_slave_dirty to use it on both scanout pixmaps if
    applicable.

drmmode_display.h:
    Add flip_seq field to msPixmapPrivRec to keep track of the event handler
    associated with a given pixmap, if any.

    Add wait_for_damage field to msPixmapPrivRec to keep track if we have
    requested a damage notification from the source.

    Add enable_flipping field to drmmode_crtc_private_rec to keep track if
    flipping is enabled or disabled.

    Add prime_pixmap_back to drmmode_crtc_private_rec to keep track of back
    buffer internally.

    Add declarations for drmmode_SetupPageFlipFence(),
    drmmode_EnableSharedPixmapFlipping(),
    drmmode_DisableSharedPixmapFlipping, drmmode_SharedPixmapFlip(), and
    drmmode_SharedPixmapPresentOnVBlank().

    Move slave damage from crtc to ppriv.

drmmode_display.c:
    Change drmmode_set_scanout_pixmap*() functions to
    drmmode_set_target_scanout_pixmap*() that take an additional parameter
    PixmapPtr *target for explicitly setting different scanout pixmaps.

    Add definitions for functions drmmode_SharedPixmapFlip(),
    drmmode_SharedPixmapPresentOnVBlank(),
    drmmode_SharedPixmapPresent(),
    drmmode_SharedPixmapVBlankEventHandler(),
    drmmode_SharedPixmapVBlankEventAbort(),
    drmmode_EnableSharedPixmapFlipping(), and
    drmmode_DisableSharedPixmapFlipping,
    drmmode_InitSharedPixmapFlipping(), and
    drmmode_FiniSharedPixmapFlipping, along with struct
    vblank_event_args.

    The control flow is as follows:
        pScrPriv->rrEnableSharedPixmapFlipping() makes its way to
        drmmode_EnableSharedPixmapFlipping(), which sets enable_flipping to
        TRUE and sets both scanout pixmaps prime_pixmap and
        prime_pixmap_back.

        When setting a mode, if prime_pixmap is defined, modesetting
        driver will call drmmode_InitSharedPixmapFlipping(), which if
        flipping is enabled will call drmmode_SharedPixmapPresent() on
        scanout_pixmap_back.

        drmmode_SharedPixmapPresent() requests that for the source to
        present on the given buffer using master->PresentSharedPixmap(). If
        it succeeds, it will then attempt to flip to that buffer using
        drmmode_SharedPixmapFlip(). Flipping shouldn't fail, but if it
        does, it will raise a warning and try drmmode_SharedPixmapPresent()
        again on the next vblank using
        drmmode_SharedPixmapPresentOnVBlank().

        master->PresentSharedPixmap() could fail, in most cases because
        there is no outstanding damage on the mscreenpix tracked by the
        shared pixmap. In this case, drmmode_SharedPixmapPresent() will
        attempt to use master->RequestSharedPixmapNotifyDamage() to request
        for the source driver to call slave->SharedPixmapNotifyDamage() in
        response to damage on mscreenpix. This will ultimately call
        into drmmode_SharedPixmapPresentOnVBlank() to retry
        drmmode_SharedPixmapPresent() on the next vblank after
        accumulating damage.

        drmmode_SharedPixmapFlip() sets up page flip event handler by
        packing struct vblank_event_args with the necessary parameters, and
        registering drmmode_SharedPixmapVBlankEventHandler() and
        drmmode_SharedPixmapVBlankEventAbort() with the modesetting DRM
        event handler queue. Then, it uses the drmModePageFlip() to flip on
        the next vblank and raise an event.

        drmmode_SharedPixmapPresentOnVBlank() operates similarly to
        drmmode_SharedPixmapFlip(), but uses drmWaitVBlank() instead of
        drmModePageFlip() to raise the event without flipping.

        On the next vblank, DRM will raise an event that will ultimately be
        handled by drmmode_SharedPixmapVBlankEventHandler(). If we flipped,
        it will update prime_pixmap and prime_pixmap_back to reflect that
        frontTarget is now being displayed, and use
        drmmode_SharedPixmapPresent(backTarget) to start the process again
        on the now-hidden shared pixmap. If we didn't flip, it will just
        use drmmode_SharedPixmapPresent(frontTarget) to start the process
        again on the still-hidden shared pixmap.

        Note that presentation generally happens asynchronously, so with
        these changes alone tearing is reduced, but we can't always
        guarantee that the present will finish before the flip. These
        changes are meant to be paired with changes to the sink DRM driver
        that makes flips wait on fences attached to dmabuf backed buffers.
        The source driver is responsible for attaching the fences and
        signaling them when presentation is finished.

        Note that because presentation is requested in response to a
        vblank, PRIME sources will now conform to the sink's refresh rate.

        At teardown, pScrPriv->rrDisableSharedPixmapFlipping() will be
        called, making its way to drmmode_FiniSharedPixmapFlipping().
        There, the event handlers for prime_pixmap and prime_pixmap_back
        are aborted, freeing the left over parameter structure. Then,
        prime_pixmap and prime_pixmap back are unset as scanout pixmaps.

    Register and tear down slave damage per-scanout pixmap instead of
    per-crtc.

v1: Initial commit
v2: Renamed PresentTrackedFlippingPixmap to PresentSharedPixmap
    Renamed flipSeq to flip_seq
    Warn if flip failed
    Use SharedPixmapNotifyDamage to retry on next vblank after damage
v3: Refactor to accomodate moving (rr)StartFlippingPixmapTracking and
    (rr)(Enable/Disable)SharedPixmapFlipping to rrScrPrivRec from ScreenRec
    Do damage tracking on both scanout pixmaps
v4: Tweaks to commit message
v5: Revise for internal storage of prime pixmap ptrs
    Move disabling for reverse PRIME from source commit to here
    Use drmmode_set_target_scanout_pixmap*() to set scanout pixmaps
    internally to EnableSharedPixmapFlipping().
    Don't support flipping if ms->drmmode.pageflip == FALSE.
    Move flipping_active check to this commit
v6: Rebase onto ToT
v7: Unchanged

Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Alex Goins <agoins@nvidia.com>
2016-06-28 12:56:30 -04:00
Alex Goins
f4c37eeee7 modesetting: Internal storage of scanout pixmaps
modesetting relied on randr_crtc->scanout_pixmap being consistent with
calls to SetScanoutPixmap, which is very fragile and makes a lot of
assumptions about the caller's behavior.

For example, RRReplaceScanoutPixmap(), when dropping off with !size_fits,
will set randr_crtc->scanout_pixmap = NULL and then call SetScanoutPixmap.
Without this patch, drmmode_set_scanout_pixmap_(cpu/gpu) will think that
there is no scanout pixmap to tear down, because it's already been set to
NULL.

By keeping track of the scanout pixmap in its internal state, modesetting
can avoid these types of bugs and reduce constraints on calling
conventions.

v1: N/A
v2: N/A
v3: N/A
v4: N/A
v5: Initial commit
v6: Rebase onto ToT
v7: Unchanged

Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Alex Goins <agoins@nvidia.com>
2016-06-28 12:56:21 -04:00
Dave Airlie
fa02b05645 modesetting: port clean start code from amdgpu. (v2)
Both radeon and amdgpu don't set the mode until the first blockhandler,
this means everything should be rendered on the screen correctly by
then.

This ports this code, it also removes the tail call of EnterVT from
ScreenInit, it really isn't necessary and causes us to set a dirty mode
with -modesetting always anyways.

v2: reorder set desired modes vs block handler as done for amdgpu.

Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-05-02 18:21:19 -04:00
Dave Airlie
caabc4e855 modesetting: add support for background none.
This adds support using glamor for background None.

loosely based off the amdgpu code. relies on the glamor_finish code.

Acked-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2016-05-02 18:21:10 -04:00
Dave Airlie
19e1dc8f6e modesetting: add zaphod support (v3)
This adds zaphod and ZaphodHeads support
to the the in-server modesetting driver.

this is based on a request from Mario,
and on the current radeon driver, along
with some patches from Mario to bring things
up to the state of the art in Zaphod.

v2: fixup vblank fd registring.
v3: squash Mario's fixes.
  modesetting: Allow/Fix use of multiple ZaphodHead outputs per x-screen.
  modesetting: Take shift in crtc positions for ZaphodHeads configs into account.
  modesetting: Add ZaphodHeads description to man page.
small cleanups (airlied).

Reviewed-and-tested-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2015-08-13 00:36:03 +01: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
Dave Airlie
7328fb3f2b modesetting: reverse prime support (v1.1)
This adds support for reverse prime to the modesetting driver.

Reverse prime is where we have two GPUs in the display chain,
but the second GPU can't scanout from the shared pixmap, so needs
an extra copy to the on screen pixmap.

This allows modesetting to support this scenario while still
supporting the USB offload one.

v1.1:
fix comment + ret = bits (Eric)

Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2015-06-30 12:17:56 +10:00
Dave Airlie
8fb8bbb306 modesetting: add tile property support (v2.1)
This adds tiling support to the server modesetting driver,
it retrieves the tile info from the kernel and translates
it into the server format and exposes the property.

v2.1: fix resetting tile property (Chris)

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2015-04-27 13:40:41 +10:00
Dave Airlie
33422d160b modesetting: stop caching mode resources
There is no need to cache the mode resources and with dynamic
connectors for mst support we don't want to. So first clean that
up before adding dynamic connector support.

Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2015-04-27 13:40:41 +10:00
Jason Ekstrand
3dcd591fa9 modesetting: Add support for using RandR shadow buffers
This replaces the stubs for shadow buffer creation/allocation with actual
functions and adds a shadow_destroy function.  With this, we actually get
shadow buffers and RandR now works properly.  Most of this is copied from
the xf86-video-intel driver and modified for modesetting.

v2 Jason Ekstrand <jason.ekstrand@intel.com>:
 - Fix build with --disable-glamor
 - Set the pixel data pointer in the pixmap header for dumb shadow bo's
 - Call drmmode_create_bo with the right bpp

v2 Jason Ekstrand <jason.ekstrand@intel.com>:
 - Make shadow buffers per-crtc and leave shadow_enable alone

Signed-off-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2015-01-23 10:50:00 -08:00
Kenneth Graunke
8affaade2c modesetting: Track the CRTC's DPMS mode.
We don't want to try to vblank synchronize to monitors which are off.

In order to handle that properly, we need to know the CRTC's DPMS mode.

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:12 -08:00
Keith Packard
5a541bd5e7 modesetting: [v2] Don't re-enable the cursor when loading the image
Hidden cursors also have their image updated; re-enabling the cursor
each time the image is set will cause it to re-appear.

 * Unifies the code that was in  drmmode_load_cursor_argb and
  drm_mode_show_cursor and moves it to a new drmmode_set_cursor

 * Add a new boolean, 'cursor_up', to the per-crtc
   private data to track whether the cursor should be displayed.

 * Call drmmode_set_cursor from drm_mode_show_cursor and, if
   the cursor should be displayed, from drm_mode_load_cursor_argb.

v2: Call drmModeSetCursor2 when loading a new cursor image if the
    cursor should be displayed.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2014-12-18 10:04:48 -08:00
Kenneth Graunke
7b784df51b modesetting: Use GBM for buffer allocations if Glamor supports it.
For performance, Glamor wants to render to tiled buffers, not linear
ones.  Using GBM allows us to pick the 3D driver's preferred tiling
modes.

v2: Declare drmmode->gbm as void * if !GLAMOR_HAS_GBM.
v3: Just use a forward declaration of struct gbm_device.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Tested-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2014-12-11 11:26:19 -08:00
Kenneth Graunke
980535757d modesetting: Create a drmmode_bo wrapper; use it for front_bo.
This code is going to be extended to support GBM BOs soon.  This small
abstraction removes a lot of direct dumb_bo access, so we can add that
support in one place, rather than putting conditionals at every
pitch/handle/etc access.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Tested-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2014-12-11 11:26:19 -08:00
Kenneth Graunke
87cc0c0d31 modesetting: Move dumb_bo into its own source files.
Eventually, drmmode_display will be able to use GBM for handling
buffers, and won't need dumb_bo.  Keeping the display related logic
and buffer object abstraction in separate files seems a bit tidier.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Tested-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2014-12-11 11:26:19 -08:00
Kenneth Graunke
af4f94b08e modesetting: Create helper for glamor_egl_create_textured_screen call.
This will need to change when we add GBM support; by pulling it into a
helper function, we should only have to edit one place.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Tested-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2014-12-11 11:26:19 -08:00
Daniel Martin
c0ea476b9b modesetting: Fix ifdefs s/HAVE_UDEV/CONFIG_UDEV_KMS/
We don't define HAVE_UDEV, that's a remnant from xf86-video-modesetting.
But, we have CONFIG_UDEV_KMS.

Signed-off-by: Daniel Martin <consume.noise@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
2014-12-08 15:49:42 -08:00
Daniel Martin
0d63fa5850 modesetting: Move Bool glamor into drmmode struct
Move the boolean glamor from struct modesetting into struct drmmode for
later re-use in drmmode_display.

Signed-off-by: Daniel Martin <consume.noise@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2014-12-08 15:49:33 -08:00
Eric Anholt
cac4b064f9 modesetting: Add support for DRI2 with glamor.
This is derived from the intel driver DRI2 code, with swapchain and
pageflipping dropped, functions renamed, and vblank event management
shared code moved to a vblank.c for reuse by Present.

This allows AIGLX to load, which means that you get appropriate
visuals exposed in GL, along with many extensions under
direct-rendering that require presence in GLX (which aren't supported
in glxdriswrast.c).

v2: Drop unused header includes in pageflip.c, wrap in #ifdef GLAMOR.
    Drop triple-buffering, which was totally broken in practice (I'll
    try to fix this later).  Fix up some style nits.  Document the
    general flow of pageflipping and why, rename the DRI2 frame event
    type enums to reflect what they're for, and handle them in a
    single switch statement so you can understand the state machine
    more easily.
v3: Drop pageflipping entirely -- it's unstable on my Intel laptop
    (not that the normal 2D driver is stable with pageflipping for
    me), and I won't get it fixed before the merge window.  It now
    passes all of the OML_sync_control tests from Jamey and Theo
    (except for occasional warns in timing -fullscreen -divisor 2).
v4: Fix doxygen at the top of vblank.c

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-10-27 13:16:43 -07:00
Eric Anholt
7064b00d47 modesetting: Export two functions I want to reuse from DRI2/Present.
This renames dumb_get_bo_from_handle(), since it wasn't using a handle
(GEM terminology) but a dmabuf fd.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2014-10-27 13:16:35 -07:00
Eric Anholt
3119acdab9 modesetting: Run x-indent-all.sh.
As I was editing code, the top-level .dir-locals.el was making my new
stuff conflict with the existing style.  Make it consistently use the
xorg style, instead.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2014-10-09 09:48:42 +02:00
Eric Anholt
b84d25fd53 modesetting: Drop remaining old-xserver compatibility.
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2014-09-16 16:28:50 -07:00
Eric Anholt
c7e8d4a6ee modesetting: unifdef MODESETTING_OUTPUT_SLAVE_SUPPORT
The server will always have it.

v2: Clean up some weird formatting from the unifdeffing.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2014-09-15 12:46:43 -07:00
Keith Packard
a307ac2738 Handle new DamageUnregister API which has only one argument
API change in 1.15

Signed-off-by: Keith Packard <keithp@keithp.com>
2013-11-15 13:39:52 +09:00
Dave Airlie
d4791dd97b modesetting: fix adjust frame crash
When SDL called this it was totally broken, actually hook
up to the underlying drmmode function.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=64808

Thanks to Peter Wu <lekensteyn@gmail.com> for harassing me.

Signed-off-by: Dave Airlie <airlied@redhat.com>
2013-06-11 10:29:25 +10:00
Alon Levy
f8eb8c1cb4 modesetting: add virtual connector support
[airlied: also make sure we don't crash in future.]

Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-09-14 10:40:44 +10:00
Dave Airlie
02811f1a9c modesetting: add output slave support.
This allows the driver to operate as an output slave.

It adds scan out pixmap, and the capability
checks to make sure they available.

Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-07-25 16:01:42 +10:00
Dave Airlie
d063f64b5c modesetting: attempt to work out if we want 24 or 32bpp
the cirrus driver presents certain challenges, and this is a
workaround, until we can possibly agree some sane interface
for exposing this information.

Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-05-01 17:12:29 +01:00
Dave Airlie
f3b9e52b29 modesetting: move shadow stuff to other structure
we need this for resize to work properly.

Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-02-20 11:00:56 +00:00
Dave Airlie
d94b3eaba9 modesetting: add cursor fallback if kernel rejects cursor.
If the kernel rejects a cursor, cause a fallback, this isn't 100% as
we can lose the initial cursor, but it works fine once wm starts.

Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-02-17 15:55:38 +00:00
Dave Airlie
a77fae8505 cleanup some the drmmode_display header file 2011-09-29 11:52:51 +01:00