summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2014-03-17 10:38:13 +0100
committerHans de Goede <hdegoede@redhat.com>2014-03-17 10:53:45 +0100
commit3d7861fe112f25874319d4cdc12b745fbcd359cf (patch)
tree047edbfc62db2e3637f5833fdaf2dd78ebad73bd /src
parenta63342ad15408071437c80b411d14196f3288aed (diff)
Add radeon_get_drm_master_fd helper function
This is a preparation patch for adding server-managed-fd support without it turning into a goto fest. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/radeon_kms.c46
1 files changed, 27 insertions, 19 deletions
diff --git a/src/radeon_kms.c b/src/radeon_kms.c
index 16a1b5f3..c0f97624 100644
--- a/src/radeon_kms.c
+++ b/src/radeon_kms.c
@@ -581,23 +581,12 @@ static Bool RADEONPreInitChipType_KMS(ScrnInfoPtr pScrn)
return TRUE;
}
-static Bool radeon_open_drm_master(ScrnInfoPtr pScrn)
+static int radeon_get_drm_master_fd(ScrnInfoPtr pScrn)
{
RADEONInfoPtr info = RADEONPTR(pScrn);
- RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
struct pci_device *dev = info->PciInfo;
char *busid;
- drmSetVersion sv;
- int err;
-
- if (pRADEONEnt->fd) {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- " reusing fd for second head\n");
-
- info->drmmode.fd = info->dri2.drm_fd = pRADEONEnt->fd;
- pRADEONEnt->fd_ref++;
- return TRUE;
- }
+ int fd;
#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,9,99,901,0)
XNFasprintf(&busid, "pci:%04x:%02x:%02x.%d",
@@ -607,16 +596,35 @@ static Bool radeon_open_drm_master(ScrnInfoPtr pScrn)
dev->domain, dev->bus, dev->dev, dev->func);
#endif
- info->dri2.drm_fd = drmOpen(NULL, busid);
- if (info->dri2.drm_fd == -1) {
-
+ fd = drmOpen(NULL, busid);
+ if (fd == -1)
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"[drm] Failed to open DRM device for %s: %s\n",
busid, strerror(errno));
- free(busid);
- return FALSE;
- }
+
free(busid);
+ return fd;
+}
+
+static Bool radeon_open_drm_master(ScrnInfoPtr pScrn)
+{
+ RADEONInfoPtr info = RADEONPTR(pScrn);
+ RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
+ drmSetVersion sv;
+ int err;
+
+ if (pRADEONEnt->fd) {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ " reusing fd for second head\n");
+
+ info->drmmode.fd = info->dri2.drm_fd = pRADEONEnt->fd;
+ pRADEONEnt->fd_ref++;
+ return TRUE;
+ }
+
+ info->dri2.drm_fd = radeon_get_drm_master_fd(pScrn);
+ if (info->dri2.drm_fd == -1)
+ return FALSE;
/* Check that what we opened was a master or a master-capable FD,
* by setting the version of the interface we'll use to talk to it.