2011-09-29 11:49:26 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2007 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 (including the next
|
|
|
|
|
* paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
|
|
|
|
|
*
|
|
|
|
|
* Authors:
|
|
|
|
|
* Dave Airlie <airlied@redhat.com>
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
#ifndef DRMMODE_DISPLAY_H
|
|
|
|
|
#define DRMMODE_DISPLAY_H
|
|
|
|
|
|
|
|
|
|
#include "xf86drmMode.h"
|
2014-11-28 11:20:49 +01:00
|
|
|
#ifdef CONFIG_UDEV_KMS
|
2011-09-29 11:49:26 +01:00
|
|
|
#include "libudev.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-12-09 11:17:30 -08:00
|
|
|
#include "dumb_bo.h"
|
2011-09-29 11:49:26 +01:00
|
|
|
|
2014-12-09 12:43:57 -08:00
|
|
|
struct gbm_device;
|
|
|
|
|
|
2014-12-09 15:20:44 -08:00
|
|
|
typedef struct {
|
|
|
|
|
struct dumb_bo *dumb;
|
2014-12-09 12:43:57 -08:00
|
|
|
#ifdef GLAMOR_HAS_GBM
|
|
|
|
|
struct gbm_bo *gbm;
|
|
|
|
|
#endif
|
2014-12-09 15:20:44 -08:00
|
|
|
} drmmode_bo;
|
|
|
|
|
|
2011-09-29 11:49:26 +01:00
|
|
|
typedef struct {
|
2011-09-29 11:52:51 +01:00
|
|
|
int fd;
|
|
|
|
|
unsigned fb_id;
|
|
|
|
|
drmModeFBPtr mode_fb;
|
|
|
|
|
int cpp;
|
|
|
|
|
ScrnInfoPtr scrn;
|
2014-12-09 12:43:57 -08:00
|
|
|
|
|
|
|
|
struct gbm_device *gbm;
|
|
|
|
|
|
2014-11-28 11:20:49 +01:00
|
|
|
#ifdef CONFIG_UDEV_KMS
|
2011-09-29 11:52:51 +01:00
|
|
|
struct udev_monitor *uevent_monitor;
|
|
|
|
|
InputHandlerProc uevent_handler;
|
2011-09-29 11:49:26 +01:00
|
|
|
#endif
|
2011-09-29 11:52:51 +01:00
|
|
|
drmEventContext event_context;
|
2014-12-09 15:20:44 -08:00
|
|
|
drmmode_bo front_bo;
|
2011-11-14 11:22:44 +00:00
|
|
|
Bool sw_cursor;
|
2012-02-20 11:00:56 +00:00
|
|
|
|
2015-07-22 03:56:13 +01:00
|
|
|
/* Broken-out options. */
|
|
|
|
|
OptionInfoPtr Options;
|
|
|
|
|
|
2014-11-28 11:20:47 +01:00
|
|
|
Bool glamor;
|
2012-02-20 11:00:56 +00:00
|
|
|
Bool shadow_enable;
|
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-01-26 21:29:23 -08:00
|
|
|
/** Is Option "PageFlip" enabled? */
|
|
|
|
|
Bool pageflip;
|
2012-02-20 11:00:56 +00:00
|
|
|
void *shadow_fb;
|
|
|
|
|
|
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>
2013-12-30 17:23:38 -08:00
|
|
|
/**
|
|
|
|
|
* A screen-sized pixmap when we're doing triple-buffered DRI2
|
|
|
|
|
* pageflipping.
|
|
|
|
|
*
|
|
|
|
|
* One is shared between all drawables that flip to the front
|
|
|
|
|
* buffer, and it only gets reallocated when root pixmap size
|
|
|
|
|
* changes.
|
|
|
|
|
*/
|
|
|
|
|
PixmapPtr triple_buffer_pixmap;
|
|
|
|
|
|
|
|
|
|
/** The GEM name for triple_buffer_pixmap */
|
|
|
|
|
uint32_t triple_buffer_name;
|
|
|
|
|
|
2012-07-19 14:12:59 +10:00
|
|
|
DevPrivateKeyRec pixmapPrivateKeyRec;
|
2015-06-10 13:41:02 +10:00
|
|
|
|
|
|
|
|
Bool reverse_prime_offload_mode;
|
2015-07-22 03:56:13 +01:00
|
|
|
|
|
|
|
|
Bool is_secondary;
|
2016-05-03 06:54:56 +10:00
|
|
|
|
|
|
|
|
PixmapPtr fbcon_pixmap;
|
2011-09-29 11:49:26 +01:00
|
|
|
} drmmode_rec, *drmmode_ptr;
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
drmmode_ptr drmmode;
|
|
|
|
|
drmModeCrtcPtr mode_crtc;
|
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>
2013-12-30 17:23:38 -08:00
|
|
|
uint32_t vblank_pipe;
|
2014-12-18 17:55:29 -08:00
|
|
|
int dpms_mode;
|
2011-09-29 11:49:26 +01:00
|
|
|
struct dumb_bo *cursor_bo;
|
2014-12-16 23:14:34 -08:00
|
|
|
Bool cursor_up;
|
2011-09-29 11:49:26 +01:00
|
|
|
uint16_t lut_r[256], lut_g[256], lut_b[256];
|
2012-07-19 14:12:59 +10:00
|
|
|
DamagePtr slave_damage;
|
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>
2013-12-30 17:23:38 -08:00
|
|
|
|
2015-01-13 15:08:37 -08:00
|
|
|
drmmode_bo rotate_bo;
|
|
|
|
|
unsigned rotate_fb_id;
|
2015-06-10 13:41:02 +10:00
|
|
|
unsigned prime_pixmap_x;
|
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>
2013-12-30 17:23:38 -08:00
|
|
|
/**
|
|
|
|
|
* @{ MSC (vblank count) handling for the PRESENT extension.
|
|
|
|
|
*
|
|
|
|
|
* The kernel's vblank counters are 32 bits and apparently full of
|
|
|
|
|
* lies, and we need to give a reliable 64-bit msc for GL, so we
|
|
|
|
|
* have to track and convert to a userland-tracked 64-bit msc.
|
|
|
|
|
*/
|
|
|
|
|
int32_t vblank_offset;
|
|
|
|
|
uint32_t msc_prev;
|
|
|
|
|
uint64_t msc_high;
|
|
|
|
|
/** @} */
|
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-01-26 21:29:23 -08:00
|
|
|
|
|
|
|
|
Bool need_modeset;
|
2011-09-29 11:49:26 +01:00
|
|
|
} drmmode_crtc_private_rec, *drmmode_crtc_private_ptr;
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
drmModePropertyPtr mode_prop;
|
|
|
|
|
uint64_t value;
|
2014-10-08 00:39:15 -07:00
|
|
|
int num_atoms; /* if range prop, num_atoms == 1; if enum prop, num_atoms == num_enums + 1 */
|
2011-09-29 11:49:26 +01:00
|
|
|
Atom *atoms;
|
|
|
|
|
} drmmode_prop_rec, *drmmode_prop_ptr;
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
drmmode_ptr drmmode;
|
|
|
|
|
int output_id;
|
|
|
|
|
drmModeConnectorPtr mode_output;
|
|
|
|
|
drmModeEncoderPtr *mode_encoders;
|
|
|
|
|
drmModePropertyBlobPtr edid_blob;
|
2015-03-23 11:33:23 +10:00
|
|
|
drmModePropertyBlobPtr tile_blob;
|
2011-09-29 11:49:26 +01:00
|
|
|
int dpms_enum_id;
|
|
|
|
|
int num_props;
|
|
|
|
|
drmmode_prop_ptr props;
|
|
|
|
|
int enc_mask;
|
|
|
|
|
int enc_clone_mask;
|
|
|
|
|
} drmmode_output_private_rec, *drmmode_output_private_ptr;
|
|
|
|
|
|
2012-07-19 14:12:59 +10:00
|
|
|
typedef struct _msPixmapPriv {
|
|
|
|
|
uint32_t fb_id;
|
|
|
|
|
struct dumb_bo *backing_bo; /* if this pixmap is backed by a dumb bo */
|
|
|
|
|
} msPixmapPrivRec, *msPixmapPrivPtr;
|
|
|
|
|
|
|
|
|
|
extern DevPrivateKeyRec msPixmapPrivateKeyRec;
|
2014-10-08 00:39:15 -07:00
|
|
|
|
2012-07-19 14:12:59 +10:00
|
|
|
#define msPixmapPrivateKey (&msPixmapPrivateKeyRec)
|
|
|
|
|
|
|
|
|
|
#define msGetPixmapPriv(drmmode, p) ((msPixmapPrivPtr)dixGetPrivateAddr(&(p)->devPrivates, &(drmmode)->pixmapPrivateKeyRec))
|
|
|
|
|
|
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-01-26 21:29:23 -08:00
|
|
|
Bool drmmode_bo_for_pixmap(drmmode_ptr drmmode, drmmode_bo *bo, PixmapPtr pixmap);
|
|
|
|
|
int drmmode_bo_destroy(drmmode_ptr drmmode, drmmode_bo *bo);
|
|
|
|
|
uint32_t drmmode_bo_get_pitch(drmmode_bo *bo);
|
2014-12-09 15:20:44 -08:00
|
|
|
uint32_t drmmode_bo_get_handle(drmmode_bo *bo);
|
2014-12-09 15:18:39 -08:00
|
|
|
Bool drmmode_glamor_handle_new_screen_pixmap(drmmode_ptr drmmode);
|
2012-07-19 14:12:59 +10:00
|
|
|
void *drmmode_map_slave_bo(drmmode_ptr drmmode, msPixmapPrivPtr ppriv);
|
|
|
|
|
Bool drmmode_SetSlaveBO(PixmapPtr ppix,
|
2014-10-08 00:39:15 -07:00
|
|
|
drmmode_ptr drmmode,
|
|
|
|
|
int fd_handle, int pitch, int size);
|
2011-09-29 11:49:26 +01:00
|
|
|
|
|
|
|
|
extern Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp);
|
2013-06-11 10:29:25 +10:00
|
|
|
void drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y);
|
2011-09-29 11:49:26 +01:00
|
|
|
extern Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
|
|
|
|
|
extern Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn);
|
|
|
|
|
|
|
|
|
|
extern void drmmode_uevent_init(ScrnInfoPtr scrn, drmmode_ptr drmmode);
|
|
|
|
|
extern void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode);
|
|
|
|
|
|
|
|
|
|
Bool drmmode_create_initial_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
|
|
|
|
|
void *drmmode_map_front_bo(drmmode_ptr drmmode);
|
|
|
|
|
Bool drmmode_map_cursor_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
|
|
|
|
|
void drmmode_free_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
|
2014-10-08 00:39:15 -07:00
|
|
|
void drmmode_get_default_bpp(ScrnInfoPtr pScrn, drmmode_ptr drmmmode,
|
|
|
|
|
int *depth, int *bpp);
|
2013-12-30 00:25:37 -08:00
|
|
|
|
2016-05-03 06:54:56 +10:00
|
|
|
void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
|
2012-05-01 17:12:29 +01:00
|
|
|
#ifndef DRM_CAP_DUMB_PREFERRED_DEPTH
|
|
|
|
|
#define DRM_CAP_DUMB_PREFERRED_DEPTH 3
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef DRM_CAP_DUMB_PREFER_SHADOW
|
|
|
|
|
#define DRM_CAP_DUMB_PREFER_SHADOW 4
|
|
|
|
|
#endif
|
|
|
|
|
|
2012-08-28 11:46:47 +10:00
|
|
|
#define MS_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
|
|
|
|
|
|
2011-09-29 11:49:26 +01:00
|
|
|
#endif
|