summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Levy <alevy@redhat.com>2012-07-22 17:21:54 +0300
committerAlon Levy <alevy@redhat.com>2012-10-23 18:46:58 +0200
commit57a5f8167fb7c86722215ed1255ebfbd82a04318 (patch)
tree10e1423c07d8d9995fc10e6f6894c1aa5b8c88ec
parent0087fd4f5a043b45582719acf18f5e40cb56a38f (diff)
qxl_driver: open drm device
-rw-r--r--src/qxl.h2
-rw-r--r--src/qxl_driver.c55
2 files changed, 53 insertions, 4 deletions
diff --git a/src/qxl.h b/src/qxl.h
index 2583c72..599f102 100644
--- a/src/qxl.h
+++ b/src/qxl.h
@@ -236,6 +236,8 @@ struct _qxl_screen_t
int enable_fallback_cache;
int enable_surfaces;
+ int drm_fd;
+
#ifdef XSPICE
/* XSpice specific */
struct QXLRom shadow_rom; /* Parameter RAM */
diff --git a/src/qxl_driver.c b/src/qxl_driver.c
index f52fec6..88156d0 100644
--- a/src/qxl_driver.c
+++ b/src/qxl_driver.c
@@ -39,6 +39,7 @@
#include <time.h>
#include <stdlib.h>
+#include <xf86drm.h>
#include <xf86Crtc.h>
#include <xf86RandR12.h>
@@ -1984,7 +1985,34 @@ print_modes (qxl_screen_t *qxl, int scrnIndex)
#ifndef XSPICE
static Bool
-qxl_check_device (ScrnInfoPtr pScrn, qxl_screen_t *qxl)
+open_drm(qxl_screen_t *qxl, ScrnInfoPtr pScrn)
+{
+ char *BusID;
+
+ if (qxl->drm_fd >= 0) {
+ return TRUE;
+ }
+ BusID = malloc(64);
+ sprintf(BusID, "PCI:%d:%d:%d",
+#if XSERVER_LIBPCIACCESS
+ ((qxl->pci->domain << 8) | qxl->pci->bus),
+ qxl->pci->dev, qxl->pci->func
+#else
+ ((pciConfigPtr) qxl->pci->thisCard)->busnum,
+ ((pciConfigPtr) qxl->pci->thisCard)->devnum,
+ ((pciConfigPtr) qxl->pci->thisCard)->funcnum
+#endif
+ );
+
+ qxl->drm_fd = drmOpen(NULL, BusID);
+ free(BusID);
+ if (qxl->drm_fd < 0)
+ return FALSE;
+ return TRUE;
+}
+
+static Bool
+qxl_check_device(ScrnInfoPtr pScrn, qxl_screen_t *qxl)
{
int scrnIndex = pScrn->scrnIndex;
struct QXLRom *rom = qxl->rom;
@@ -2351,6 +2379,18 @@ qxl_initialize_x_modes (qxl_screen_t *qxl, ScrnInfoPtr pScrn,
}
}
+static void
+set_callbacks_to_ums(qxl_screen_t *qxl)
+{
+}
+
+#ifndef XSPICE
+static void
+set_callbacks_to_kms(qxl_screen_t *qxl)
+{
+}
+#endif
+
static Bool
qxl_pre_init (ScrnInfoPtr pScrn, int flags)
{
@@ -2429,10 +2469,17 @@ qxl_pre_init (ScrnInfoPtr pScrn, int flags)
goto out;
#ifndef XSPICE
- if (!qxl_check_device (pScrn, qxl))
- goto out;
+ open_drm(qxl, pScrn);
+ if (qxl->drm_fd != -1) {
+ if (!qxl_check_device(pScrn, qxl))
+ goto out;
+ set_callbacks_to_ums(qxl);
+ } else {
+ set_callbacks_to_kms(qxl);
+ }
#else
- xspice_init_qxl_ram (qxl); /* initialize the rings */
+ set_callbacks_to_ums(qxl);
+ xspice_init_qxl_ram(qxl); /* initialize the rings */
#endif
pScrn->videoRam = (qxl->rom->num_pages * 4096) / 1024;
xf86DrvMsg (scrnIndex, X_INFO, "%d KB of video RAM\n", pScrn->videoRam);