[PATCH 14/14] Add DRI3 support v2
From: Michel Dänzer michel.daen...@amd.com Must be enabled with Option DRI3 in xorg.conf. v2: Adapt to v2 of patches 11/12. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- configure.ac | 4 ++ man/radeon.man| 4 ++ src/Makefile.am | 5 +- src/radeon.h | 4 ++ src/radeon_dri3.c | 201 ++ src/radeon_kms.c | 21 +- 6 files changed, 236 insertions(+), 3 deletions(-) create mode 100644 src/radeon_dri3.c diff --git a/configure.ac b/configure.ac index 71d8ff0..acd9fe0 100644 --- a/configure.ac +++ b/configure.ac @@ -143,6 +143,10 @@ AC_CHECK_HEADERS([present.h], [], [], #include X11/X.h #include xorg-server.h]) +AC_CHECK_HEADERS([dri3.h], [], [], +[#include X11/Xmd.h +#include xorg-server.h]) + CPPFLAGS=$SAVE_CPPFLAGS PKG_CHECK_MODULES([PCIACCESS], [pciaccess = 0.8.0]) diff --git a/man/radeon.man b/man/radeon.man index 7dde040..6e46f89 100644 --- a/man/radeon.man +++ b/man/radeon.man @@ -267,6 +267,10 @@ The default value is for R/RV6XX, R/RV7XX, RS780, RS880, EVERGREEN, CAYMAN, ARUBA, Southern Islands, and Sea Islands. .TP +.BI Option \*qDRI3\*q \*q boolean \*q +Enable the DRI3 extension. The default is +.B off. +.TP .BI Option \*qEnablePageFlip\*q \*q boolean \*q Enable DRI2 page flipping. The default is .B on. diff --git a/src/Makefile.am b/src/Makefile.am index a3d732a..697c08c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -29,8 +29,9 @@ ati_drv_la_LIBADD = $(PCIACCESS_LIBS) radeon_drv_la_LIBADD = $(LIBDRM_RADEON_LIBS) $(PCIACCESS_LIBS) -RADEON_KMS_SRCS=radeon_dri2.c radeon_drm_queue.c radeon_kms.c radeon_present.c \ - radeon_sync.c radeon_vbo.c radeon_bo_helper.c drmmode_display.c +RADEON_KMS_SRCS=radeon_dri2.c radeon_dri3.c radeon_drm_queue.c radeon_kms.c \ + radeon_present.c radeon_sync.c radeon_vbo.c radeon_bo_helper.c \ + drmmode_display.c RADEON_EXA_SOURCES = radeon_exa.c r600_exa.c r6xx_accel.c r600_textured_videofuncs.c r600_shader.c radeon_exa_shared.c \ evergreen_exa.c evergreen_accel.c evergreen_shader.c evergreen_textured_videofuncs.c cayman_accel.c cayman_shader.c diff --git a/src/radeon.h b/src/radeon.h index 9346fbd..6084cfe 100644 --- a/src/radeon.h +++ b/src/radeon.h @@ -150,6 +150,7 @@ typedef enum { OPTION_ZAPHOD_HEADS, OPTION_SWAPBUFFERS_WAIT, OPTION_DELETE_DP12, +OPTION_DRI3, } RADEONOpts; @@ -549,6 +550,9 @@ extern Bool RADEONGetDatatypeBpp(int bpp, uint32_t *type); extern Bool RADEONGetPixmapOffsetPitch(PixmapPtr pPix, uint32_t *pitch_offset); +/* radeon_dri3.c */ +Bool radeon_dri3_screen_init(ScreenPtr screen); + /* radeon_present.c */ Bool radeon_present_screen_init(ScreenPtr screen); diff --git a/src/radeon_dri3.c b/src/radeon_dri3.c new file mode 100644 index 000..83bffae --- /dev/null +++ b/src/radeon_dri3.c @@ -0,0 +1,201 @@ +/* + * Copyright © 2013-2014 Intel Corporation + * Copyright © 2015 Advanced Micro Devices, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided as + * is without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + + +#ifdef HAVE_CONFIG_H +#include config.h +#endif + +#include xorg-server.h +#include xf86.h +#include fb.h + +#ifdef HAVE_DRI3_H + +#include radeon.h +#include radeon_bo_gem.h +#include radeon_glamor.h +#include dri3.h + +#include sys/types.h +#include sys/stat.h +#include fcntl.h +#include errno.h + + +static int +radeon_dri3_open_client(ClientPtr client, + ScreenPtr screen, + RRProviderPtr provider, + int *out) +{ + ScrnInfoPtr scrn = xf86ScreenToScrn(screen); + RADEONInfoPtr info = RADEONPTR(scrn); + drm_magic_t magic; + int fd; + + fd = open(info-dri2.device_name, O_RDWR | O_CLOEXEC); + if (fd 0) +
[PATCH 14/14] Add DRI3 support
From: Michel Dänzer michel.daen...@amd.com Must be enabled with Option DRI3 in xorg.conf. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- configure.ac | 4 ++ man/radeon.man| 4 ++ src/Makefile.am | 5 +- src/radeon.h | 4 ++ src/radeon_dri3.c | 201 ++ src/radeon_kms.c | 23 ++- 6 files changed, 237 insertions(+), 4 deletions(-) create mode 100644 src/radeon_dri3.c diff --git a/configure.ac b/configure.ac index 71d8ff0..acd9fe0 100644 --- a/configure.ac +++ b/configure.ac @@ -143,6 +143,10 @@ AC_CHECK_HEADERS([present.h], [], [], #include X11/X.h #include xorg-server.h]) +AC_CHECK_HEADERS([dri3.h], [], [], +[#include X11/Xmd.h +#include xorg-server.h]) + CPPFLAGS=$SAVE_CPPFLAGS PKG_CHECK_MODULES([PCIACCESS], [pciaccess = 0.8.0]) diff --git a/man/radeon.man b/man/radeon.man index 7dde040..6e46f89 100644 --- a/man/radeon.man +++ b/man/radeon.man @@ -267,6 +267,10 @@ The default value is for R/RV6XX, R/RV7XX, RS780, RS880, EVERGREEN, CAYMAN, ARUBA, Southern Islands, and Sea Islands. .TP +.BI Option \*qDRI3\*q \*q boolean \*q +Enable the DRI3 extension. The default is +.B off. +.TP .BI Option \*qEnablePageFlip\*q \*q boolean \*q Enable DRI2 page flipping. The default is .B on. diff --git a/src/Makefile.am b/src/Makefile.am index a3d732a..697c08c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -29,8 +29,9 @@ ati_drv_la_LIBADD = $(PCIACCESS_LIBS) radeon_drv_la_LIBADD = $(LIBDRM_RADEON_LIBS) $(PCIACCESS_LIBS) -RADEON_KMS_SRCS=radeon_dri2.c radeon_drm_queue.c radeon_kms.c radeon_present.c \ - radeon_sync.c radeon_vbo.c radeon_bo_helper.c drmmode_display.c +RADEON_KMS_SRCS=radeon_dri2.c radeon_dri3.c radeon_drm_queue.c radeon_kms.c \ + radeon_present.c radeon_sync.c radeon_vbo.c radeon_bo_helper.c \ + drmmode_display.c RADEON_EXA_SOURCES = radeon_exa.c r600_exa.c r6xx_accel.c r600_textured_videofuncs.c r600_shader.c radeon_exa_shared.c \ evergreen_exa.c evergreen_accel.c evergreen_shader.c evergreen_textured_videofuncs.c cayman_accel.c cayman_shader.c diff --git a/src/radeon.h b/src/radeon.h index 9346fbd..6084cfe 100644 --- a/src/radeon.h +++ b/src/radeon.h @@ -150,6 +150,7 @@ typedef enum { OPTION_ZAPHOD_HEADS, OPTION_SWAPBUFFERS_WAIT, OPTION_DELETE_DP12, +OPTION_DRI3, } RADEONOpts; @@ -549,6 +550,9 @@ extern Bool RADEONGetDatatypeBpp(int bpp, uint32_t *type); extern Bool RADEONGetPixmapOffsetPitch(PixmapPtr pPix, uint32_t *pitch_offset); +/* radeon_dri3.c */ +Bool radeon_dri3_screen_init(ScreenPtr screen); + /* radeon_present.c */ Bool radeon_present_screen_init(ScreenPtr screen); diff --git a/src/radeon_dri3.c b/src/radeon_dri3.c new file mode 100644 index 000..83bffae --- /dev/null +++ b/src/radeon_dri3.c @@ -0,0 +1,201 @@ +/* + * Copyright © 2013-2014 Intel Corporation + * Copyright © 2015 Advanced Micro Devices, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided as + * is without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + + +#ifdef HAVE_CONFIG_H +#include config.h +#endif + +#include xorg-server.h +#include xf86.h +#include fb.h + +#ifdef HAVE_DRI3_H + +#include radeon.h +#include radeon_bo_gem.h +#include radeon_glamor.h +#include dri3.h + +#include sys/types.h +#include sys/stat.h +#include fcntl.h +#include errno.h + + +static int +radeon_dri3_open_client(ClientPtr client, + ScreenPtr screen, + RRProviderPtr provider, + int *out) +{ + ScrnInfoPtr scrn = xf86ScreenToScrn(screen); + RADEONInfoPtr info = RADEONPTR(scrn); + drm_magic_t magic; + int fd; + + fd = open(info-dri2.device_name, O_RDWR | O_CLOEXEC); + if (fd 0) + return BadAlloc; + + /*