[PATCH 3/3] glamor: Avoid generating GEM flink names for BOs shared via DRI3

2015-03-18 Thread Michel Dänzer
From: Michel Dänzer 

We can't create our own struct radeon_bo representation in this case
because destroying that would make the GEM handle inaccessible to glamor
as well. So just get the handle directly via dma-buf.

Signed-off-by: Michel Dänzer 
---
 src/radeon.h |  4 
 src/radeon_dri3.c| 10 ++
 src/radeon_glamor.h  |  1 +
 src/radeon_present.c | 34 ++
 4 files changed, 49 insertions(+)

diff --git a/src/radeon.h b/src/radeon.h
index 6084cfe..6a60bd3 100644
--- a/src/radeon.h
+++ b/src/radeon.h
@@ -252,6 +252,10 @@ struct radeon_pixmap {
 
uint32_t tiling_flags;
int stride;
+
+   /* GEM handle for glamor-only pixmaps shared via DRI3 */
+   Bool handle_valid;
+   uint32_t handle;
 };
 
 #if HAS_DEVPRIVATEKEYREC
diff --git a/src/radeon_dri3.c b/src/radeon_dri3.c
index 993c7a7..3a7322e 100644
--- a/src/radeon_dri3.c
+++ b/src/radeon_dri3.c
@@ -96,6 +96,16 @@ static PixmapPtr radeon_dri3_pixmap_from_fd(ScreenPtr screen,
 {
PixmapPtr pixmap;
 
+#ifdef USE_GLAMOR
+   /* Avoid generating a GEM flink name if possible */
+   if (RADEONPTR(xf86ScreenToScrn(screen))->use_glamor) {
+   pixmap = glamor_pixmap_from_fd(screen, fd, width, height,
+  stride, depth, bpp);
+   if (pixmap)
+   return pixmap;
+   }
+#endif
+
if (depth < 8)
return NULL;
 
diff --git a/src/radeon_glamor.h b/src/radeon_glamor.h
index f450f0e..7cef1a9 100644
--- a/src/radeon_glamor.h
+++ b/src/radeon_glamor.h
@@ -37,6 +37,7 @@
 
 #ifndef GLAMOR_NO_DRI3
 #define glamor_fd_from_pixmap glamor_dri3_fd_from_pixmap
+#define glamor_pixmap_from_fd glamor_egl_dri3_pixmap_from_fd
 #endif
 
 Bool radeon_glamor_pre_init(ScrnInfoPtr scrn);
diff --git a/src/radeon_present.c b/src/radeon_present.c
index 85f1bfc..6782513 100644
--- a/src/radeon_present.c
+++ b/src/radeon_present.c
@@ -42,6 +42,7 @@
 #include 
 #include 
 
+#include "radeon_glamor.h"
 #include "radeon_video.h"
 
 #include "present.h"
@@ -220,12 +221,45 @@ static Bool
 radeon_present_get_pixmap_handle(PixmapPtr pixmap, uint32_t *handle)
 {
 struct radeon_bo *bo = radeon_get_pixmap_bo(pixmap);
+#ifdef USE_GLAMOR
+ScreenPtr screen = pixmap->drawable.pScreen;
+RADEONInfoPtr info = RADEONPTR(xf86ScreenToScrn(screen));
+#endif
 
 if (bo) {
*handle = bo->handle;
return TRUE;
 }
 
+#ifdef USE_GLAMOR
+if (info->use_glamor) {
+   struct radeon_pixmap *priv = radeon_get_pixmap_private(pixmap);
+   CARD16 stride;
+   CARD32 size;
+   int fd;
+
+   if (!priv) {
+   priv = calloc(1, sizeof(*priv));
+   radeon_set_pixmap_private(pixmap, priv);
+   }
+
+   if (priv->handle_valid) {
+   *handle = priv->handle;
+   return TRUE;
+   }
+
+   fd = glamor_fd_from_pixmap(screen, pixmap, &stride, &size);
+   if (fd < 0)
+   return FALSE;
+
+   if (drmPrimeFDToHandle(info->dri2.drm_fd, fd, &priv->handle) == 0) {
+   priv->handle_valid = TRUE;
+   *handle = priv->handle;
+   return TRUE;
+   }
+}
+#endif
+
 return FALSE;
 }
 
-- 
2.1.4

___
xorg-driver-ati mailing list
xorg-driver-ati@lists.x.org
http://lists.x.org/mailman/listinfo/xorg-driver-ati


[PATCH 2/3] Present: Add radeon_present_get_pixmap_handle helper

2015-03-18 Thread Michel Dänzer
From: Michel Dänzer 

Signed-off-by: Michel Dänzer 
---
 src/radeon_present.c | 27 +++
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/src/radeon_present.c b/src/radeon_present.c
index 9d774ab..85f1bfc 100644
--- a/src/radeon_present.c
+++ b/src/radeon_present.c
@@ -216,6 +216,19 @@ get_drmmode_crtc(ScrnInfoPtr scrn, RRCrtcPtr crtc)
 return NULL;
 }
 
+static Bool
+radeon_present_get_pixmap_handle(PixmapPtr pixmap, uint32_t *handle)
+{
+struct radeon_bo *bo = radeon_get_pixmap_bo(pixmap);
+
+if (bo) {
+   *handle = bo->handle;
+   return TRUE;
+}
+
+return FALSE;
+}
+
 /*
  * Test to see if page flipping is possible on the target crtc
  */
@@ -282,7 +295,7 @@ radeon_present_flip(RRCrtcPtr crtc, uint64_t event_id, 
uint64_t target_msc,
 struct radeon_present_vblank_event *event;
 drmmode_crtc_private_ptr drmmode_crtc = get_drmmode_crtc(scrn, crtc);
 int crtc_id = drmmode_crtc->mode_crtc->crtc_id;
-struct radeon_bo *bo;
+uint32_t handle;
 Bool ret;
 
 if (!sync_flip)
@@ -291,8 +304,7 @@ radeon_present_flip(RRCrtcPtr crtc, uint64_t event_id, 
uint64_t target_msc,
 if (!radeon_present_check_flip(crtc, screen->root, pixmap, sync_flip))
return FALSE;
 
-bo = radeon_get_pixmap_bo(pixmap);
-if (!bo)
+if (!radeon_present_get_pixmap_handle(pixmap, &handle))
return FALSE;
 
 event = calloc(1, sizeof(struct radeon_present_vblank_event));
@@ -301,7 +313,7 @@ radeon_present_flip(RRCrtcPtr crtc, uint64_t event_id, 
uint64_t target_msc,
 
 event->event_id = event_id;
 
-ret = radeon_do_pageflip(scrn, RADEON_DRM_QUEUE_CLIENT_DEFAULT, bo->handle,
+ret = radeon_do_pageflip(scrn, RADEON_DRM_QUEUE_CLIENT_DEFAULT, handle,
 event_id, event, crtc_id,
 radeon_present_flip_event,
 radeon_present_flip_abort);
@@ -320,14 +332,13 @@ radeon_present_unflip(ScreenPtr screen, uint64_t event_id)
 ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 struct radeon_present_vblank_event *event;
 PixmapPtr pixmap = screen->GetScreenPixmap(screen);
-struct radeon_bo *bo;
+uint32_t handle;
 Bool ret;
 
 if (!radeon_present_check_flip(NULL, screen->root, pixmap, TRUE))
return;
 
-bo = radeon_get_pixmap_bo(pixmap);
-if (!bo)
+if (!radeon_present_get_pixmap_handle(pixmap, &handle))
return;
 
 event = calloc(1, sizeof(struct radeon_present_vblank_event));
@@ -336,7 +347,7 @@ radeon_present_unflip(ScreenPtr screen, uint64_t event_id)
 
 event->event_id = event_id;
 
-ret = radeon_do_pageflip(scrn, RADEON_DRM_QUEUE_CLIENT_DEFAULT, bo->handle,
+ret = radeon_do_pageflip(scrn, RADEON_DRM_QUEUE_CLIENT_DEFAULT, handle,
 event_id, event, -1, radeon_present_flip_event,
 radeon_present_flip_abort);
 if (!ret)
-- 
2.1.4

___
xorg-driver-ati mailing list
xorg-driver-ati@lists.x.org
http://lists.x.org/mailman/listinfo/xorg-driver-ati


[PATCH 1/3] Make radeon_do_pageflip take a BO handle directly

2015-03-18 Thread Michel Dänzer
From: Michel Dänzer 

Signed-off-by: Michel Dänzer 
---
 src/drmmode_display.c | 4 ++--
 src/drmmode_display.h | 2 +-
 src/radeon_dri2.c | 5 +++--
 src/radeon_present.c  | 4 ++--
 4 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 86bc446..f719f0c 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -2265,7 +2265,7 @@ void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr 
drmmode)
 }
 
 Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
-   struct radeon_bo *new_front, uint64_t id, void *data,
+   uint32_t new_front_handle, uint64_t id, void *data,
int ref_crtc_hw_id, radeon_drm_handler_proc handler,
radeon_drm_abort_proc abort)
 {
@@ -2301,7 +2301,7 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr 
client,
old_fb_id = drmmode->fb_id;
if (drmModeAddFB(drmmode->fd, scrn->virtualX, height,
 scrn->depth, scrn->bitsPerPixel, pitch,
-new_front->handle, &drmmode->fb_id))
+new_front_handle, &drmmode->fb_id))
goto error_out;
 
 flipdata = calloc(1, sizeof(drmmode_flipdata_rec));
diff --git a/src/drmmode_display.h b/src/drmmode_display.h
index 6f883c0..b3804ba 100644
--- a/src/drmmode_display.h
+++ b/src/drmmode_display.h
@@ -129,7 +129,7 @@ extern int drmmode_get_pitch_align(ScrnInfoPtr scrn, int 
bpe, uint32_t tiling);
 extern int drmmode_get_base_align(ScrnInfoPtr scrn, int bpe, uint32_t tiling);
 
 Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
-   struct radeon_bo *new_front, uint64_t id, void *data,
+   uint32_t new_front_handle, uint64_t id, void *data,
int ref_crtc_hw_id, radeon_drm_handler_proc handler,
radeon_drm_abort_proc abort);
 int drmmode_crtc_get_ust_msc(xf86CrtcPtr crtc, CARD64 *ust, CARD64 *msc);
diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c
index 02e8e8f..2636456 100644
--- a/src/radeon_dri2.c
+++ b/src/radeon_dri2.c
@@ -647,8 +647,9 @@ radeon_dri2_schedule_flip(ScrnInfoPtr scrn, ClientPtr 
client,
 back_priv = back->driverPrivate;
 bo = radeon_get_pixmap_bo(back_priv->pixmap);
 
-return radeon_do_pageflip(scrn, client, bo, RADEON_DRM_QUEUE_ID_DEFAULT,
- flip_info, ref_crtc_hw_id,
+return radeon_do_pageflip(scrn, client, bo->handle,
+ RADEON_DRM_QUEUE_ID_DEFAULT, flip_info,
+ ref_crtc_hw_id,
  radeon_dri2_flip_event_handler,
  radeon_dri2_flip_event_abort);
 }
diff --git a/src/radeon_present.c b/src/radeon_present.c
index 0aa96cf..9d774ab 100644
--- a/src/radeon_present.c
+++ b/src/radeon_present.c
@@ -301,7 +301,7 @@ radeon_present_flip(RRCrtcPtr crtc, uint64_t event_id, 
uint64_t target_msc,
 
 event->event_id = event_id;
 
-ret = radeon_do_pageflip(scrn, RADEON_DRM_QUEUE_CLIENT_DEFAULT, bo,
+ret = radeon_do_pageflip(scrn, RADEON_DRM_QUEUE_CLIENT_DEFAULT, bo->handle,
 event_id, event, crtc_id,
 radeon_present_flip_event,
 radeon_present_flip_abort);
@@ -336,7 +336,7 @@ radeon_present_unflip(ScreenPtr screen, uint64_t event_id)
 
 event->event_id = event_id;
 
-ret = radeon_do_pageflip(scrn, RADEON_DRM_QUEUE_CLIENT_DEFAULT, bo,
+ret = radeon_do_pageflip(scrn, RADEON_DRM_QUEUE_CLIENT_DEFAULT, bo->handle,
 event_id, event, -1, radeon_present_flip_event,
 radeon_present_flip_abort);
 if (!ret)
-- 
2.1.4

___
xorg-driver-ati mailing list
xorg-driver-ati@lists.x.org
http://lists.x.org/mailman/listinfo/xorg-driver-ati


[Bug 89667] undefined symbol: radeon_drm_queue_handler

2015-03-18 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=89667

Alexandre Demers  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |NOTABUG

--- Comment #2 from Alexandre Demers  ---
(In reply to Michel Dänzer from comment #1)
> Looks like the build files didn't get re-generated after you updated from
> Git. Try re-running autogen.sh and rebuilding.

You are right, I must have forgotten to do that. It runs fine now.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
xorg-driver-ati mailing list
xorg-driver-ati@lists.x.org
http://lists.x.org/mailman/listinfo/xorg-driver-ati


[PATCH r128] Look for VGA ports in the VBIOS

2015-03-18 Thread Connor Behan
It appears that not all r128 chipsets marked as DFP capable have DVI
ports. Some have VGA which we should detect. The old driver "detected"
this by attempting a DVI based probe for monitors. Anything that failed
this was assumed to be VGA.

Signed-off-by: Connor Behan 
Tested-by: Tobias Powalowski 
---
 src/r128_output.c | 20 +++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/r128_output.c b/src/r128_output.c
index 0160880..c042c98 100644
--- a/src/r128_output.c
+++ b/src/r128_output.c
@@ -400,6 +400,24 @@ void R128SetupGenericConnectors(ScrnInfoPtr pScrn, 
R128OutputType *otypes)
 otypes[1] = OUTPUT_VGA;
 }
 
+void R128GetConnectorInfoFromBIOS(ScrnInfoPtr pScrn, R128OutputType *otypes)
+{
+R128InfoPtr info = R128PTR(pScrn);
+uint16_t bios_header;
+int offset;
+
+/* XXX: Currently, this function only finds VGA ports misidentified as 
DVI. */
+if (!info->VBIOS || otypes[0] != OUTPUT_DVI) return;
+
+bios_header = R128_BIOS16(0x48);
+offset = R128_BIOS16(bios_header + 0x60);
+
+if (offset) {
+otypes[0] = OUTPUT_VGA;
+   xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Found CRT table, assuming VGA 
connector\n");
+}
+}
+
 Bool R128SetupConnectors(ScrnInfoPtr pScrn)
 {
 R128InfoPtr info= R128PTR(pScrn);
@@ -411,8 +429,8 @@ Bool R128SetupConnectors(ScrnInfoPtr pScrn)
 int num_dvi = 0;
 int i;
 
-/* XXX: Can we make R128GetConnectorInfoFromBIOS()? */
 R128SetupGenericConnectors(pScrn, otypes);
+R128GetConnectorInfoFromBIOS(pScrn, otypes);
 
 for (i = 0; i < R128_MAX_BIOS_CONNECTOR; i++) {
 if (otypes[i] == OUTPUT_VGA)
-- 
2.3.2

___
xorg-driver-ati mailing list
xorg-driver-ati@lists.x.org
http://lists.x.org/mailman/listinfo/xorg-driver-ati


[PATCH r128] Fix allocation of private entity

2015-03-18 Thread Connor Behan
In the past, pR128Ent was only used for Xinerama-style dualhead and
therefore only allocated for cards with two outputs. However, recent
patches have repurposed pR128Ent as a general struct for things that are
card-specific instead of instance-specific. It therefore needs to be
allocated for all cards.
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=89236

Signed-off-by: Connor Behan 
Tested-by: Tobias Powalowski 
---
 src/r128_probe.c | 32 +++-
 1 file changed, 15 insertions(+), 17 deletions(-)

diff --git a/src/r128_probe.c b/src/r128_probe.c
index 9771d52..0fd31c6 100644
--- a/src/r128_probe.c
+++ b/src/r128_probe.c
@@ -234,6 +234,7 @@ r128_get_scrninfo(int entity_num)
 {
 ScrnInfoPtr   pScrn = NULL;
 EntityInfoPtr pEnt;
+DevUnion* pPriv;
 
 pScrn = xf86ConfigPciEntity(pScrn, 0, entity_num, R128PciChipsets,
 NULL,
@@ -261,6 +262,20 @@ r128_get_scrninfo(int entity_num)
 
 pEnt = xf86GetEntityInfo(entity_num);
 
+/* Allocate private entity used for convenience with one or two heads. */
+if (gR128EntityIndex < 0) {
+gR128EntityIndex = xf86AllocateEntityPrivateIndex();
+pPriv = xf86GetEntityPrivate(pScrn->entityList[0], gR128EntityIndex);
+
+   if (!pPriv->ptr) {
+   R128EntPtr pR128Ent;
+   pPriv->ptr = xnfcalloc(sizeof(R128EntRec), 1);
+   pR128Ent = pPriv->ptr;
+   pR128Ent->HasSecondary = FALSE;
+   pR128Ent->IsSecondaryRestored = FALSE;
+   }
+}
+
 /* mobility cards support Dual-Head, mark the entity as sharable*/
 if (pEnt->chipset == PCI_CHIP_RAGE128LE ||
 pEnt->chipset == PCI_CHIP_RAGE128LF ||
@@ -268,7 +283,6 @@ r128_get_scrninfo(int entity_num)
 pEnt->chipset == PCI_CHIP_RAGE128ML)
 {
 static int instance = 0;
-DevUnion* pPriv;
 
 xf86SetEntitySharable(entity_num);
 
@@ -276,22 +290,6 @@ r128_get_scrninfo(int entity_num)
pScrn->entityList[0],
instance);
 
-if (gR128EntityIndex < 0)
-{
-gR128EntityIndex = xf86AllocateEntityPrivateIndex();
-
-pPriv = xf86GetEntityPrivate(pScrn->entityList[0],
- gR128EntityIndex);
-
-if (!pPriv->ptr)
-{
-R128EntPtr pR128Ent;
-pPriv->ptr = xnfcalloc(sizeof(R128EntRec), 1);
-pR128Ent = pPriv->ptr;
-pR128Ent->HasSecondary = FALSE;
-pR128Ent->IsSecondaryRestored = FALSE;
-}
-}
 instance++;
 }
 
-- 
2.3.2

___
xorg-driver-ati mailing list
xorg-driver-ati@lists.x.org
http://lists.x.org/mailman/listinfo/xorg-driver-ati


[Bug 89667] undefined symbol: radeon_drm_queue_handler

2015-03-18 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=89667

--- Comment #1 from Michel Dänzer  ---
Looks like the build files didn't get re-generated after you updated from Git.
Try re-running autogen.sh and rebuilding.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
xorg-driver-ati mailing list
xorg-driver-ati@lists.x.org
http://lists.x.org/mailman/listinfo/xorg-driver-ati


[Bug 89667] New: undefined symbol: radeon_drm_queue_handler

2015-03-18 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=89667

Bug ID: 89667
   Summary: undefined symbol: radeon_drm_queue_handler
   Product: xorg
   Version: git
  Hardware: Other
OS: All
Status: NEW
  Severity: normal
  Priority: medium
 Component: Driver/Radeon
  Assignee: xorg-driver-ati@lists.x.org
  Reporter: alexandre.f.dem...@gmail.com
QA Contact: xorg-t...@lists.x.org

Created attachment 114454
  --> https://bugs.freedesktop.org/attachment.cgi?id=114454&action=edit
Xorg fails to load radeon driver

Using latest ddx radeon driver (6291ba), Xorg fails to start. I'm hitting the
following error.

Failed to load /usr/lib/xorg/modules/drivers/radeon_drv.so:
/usr/lib/xorg/modules/drivers/radeon_drv.so: undefined symbol:
radeon_drm_queue_handler

DRI3 is enabled in xorg.conf.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
xorg-driver-ati mailing list
xorg-driver-ati@lists.x.org
http://lists.x.org/mailman/listinfo/xorg-driver-ati