summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2010-03-18 12:36:25 +1000
committerDave Airlie <airlied@redhat.com>2010-03-18 12:36:25 +1000
commita0683be5cc082bdbdd3bc4e9b52f39f423650946 (patch)
treed15067bb08c5359cb8310110178e1bc967552224
parent080a5414593e9b59ed923f26aa6057747b0c868f (diff)
radeon: avoid using DRI1 init path on DRI2 driver.
I was playing with multi-seat and found this code, fixed it up to be sane and more DRI2 like. Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r--src/drmmode_display.c22
-rw-r--r--src/drmmode_display.h2
-rw-r--r--src/radeon_kms.c68
3 files changed, 63 insertions, 29 deletions
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 11210444..399a6a73 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -1151,31 +1151,11 @@ static const xf86CrtcConfigFuncsRec drmmode_xf86crtc_config_funcs = {
};
-Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, char *busId, char *driver_name, int cpp)
+Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp)
{
xf86CrtcConfigPtr xf86_config;
- RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
int i;
- Bool ret;
-
- /* Create a bus Id */
- /* Low level DRM open */
- if (!pRADEONEnt->fd) {
- ret = DRIOpenDRMMaster(pScrn, SAREA_MAX, busId, driver_name);
- if (!ret) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "[dri] DRIGetVersion failed to open the DRM\n"
- "[dri] Disabling DRI.\n");
- return FALSE;
- }
- drmmode->fd = DRIMasterFD(pScrn);
- pRADEONEnt->fd = drmmode->fd;
- } else {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- " reusing fd for second head\n");
- drmmode->fd = pRADEONEnt->fd;
- }
xf86CrtcConfigInit(pScrn, &drmmode_xf86crtc_config_funcs);
xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
diff --git a/src/drmmode_display.h b/src/drmmode_display.h
index 1576d499..2e76259e 100644
--- a/src/drmmode_display.h
+++ b/src/drmmode_display.h
@@ -74,7 +74,7 @@ typedef struct {
} drmmode_output_private_rec, *drmmode_output_private_ptr;
-extern Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, char *busId, char *driver_name, int cpp);
+extern Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp);
extern Bool drmmode_set_bufmgr(ScrnInfoPtr pScrn, drmmode_ptr drmmode, struct radeon_bo_manager *bufmgr);
extern void drmmode_set_cursor(ScrnInfoPtr scrn, drmmode_ptr drmmode, int id, struct radeon_bo *bo);
void drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y, int flags);
diff --git a/src/radeon_kms.c b/src/radeon_kms.c
index 1f9c5d4c..15e5e3fa 100644
--- a/src/radeon_kms.c
+++ b/src/radeon_kms.c
@@ -362,12 +362,67 @@ static Bool radeon_alloc_dri(ScrnInfoPtr pScrn)
return TRUE;
}
+static Bool radeon_open_drm_master(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_ERROR,
+ " reusing fd for second head\n");
+
+ info->dri2.drm_fd = pRADEONEnt->fd;
+ goto out;
+ }
+
+ busid = XNFprintf("pci:%04x:%02x:%02x.%d",
+ dev->domain, dev->bus, dev->dev, dev->func);
+
+ info->dri2.drm_fd = drmOpen("radeon", busid);
+ if (info->dri2.drm_fd == -1) {
+
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "[drm] Failed to open DRM device for %s: %s\n",
+ busid, strerror(errno));
+ xfree(busid);
+ return FALSE;
+ }
+ xfree(busid);
+
+ /* 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.
+ * (see DRIOpenDRMMaster() in DRI1)
+ */
+ sv.drm_di_major = 1;
+ sv.drm_di_minor = 1;
+ sv.drm_dd_major = -1;
+ sv.drm_dd_minor = -1;
+ err = drmSetInterfaceVersion(info->dri2.drm_fd, &sv);
+ if (err != 0) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "[drm] failed to set drm interface version.\n");
+ drmClose(info->dri2.drm_fd);
+ info->dri2.drm_fd = -1;
+
+ return FALSE;
+ }
+
+ pRADEONEnt->fd = info->dri2.drm_fd;
+ out:
+ info->drmmode.fd = info->dri2.drm_fd;
+ info->dri->drmFD = info->dri2.drm_fd;
+ return TRUE;
+}
+
Bool RADEONPreInit_KMS(ScrnInfoPtr pScrn, int flags)
{
RADEONInfoPtr info;
RADEONEntPtr pRADEONEnt;
DevUnion* pPriv;
- char *bus_id;
Gamma zeros = { 0.0, 0.0, 0.0 };
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, RADEON_LOGLEVEL_DEBUG,
@@ -434,17 +489,16 @@ Bool RADEONPreInit_KMS(ScrnInfoPtr pScrn, int flags)
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
"KMS Color Tiling: %sabled\n", info->allowColorTiling ? "en" : "dis");
- bus_id = DRICreatePCIBusID(info->PciInfo);
- if (drmmode_pre_init(pScrn, &info->drmmode, bus_id, "radeon", pScrn->bitsPerPixel / 8) == FALSE) {
- xfree(bus_id);
+ if (radeon_open_drm_master(pScrn) == FALSE) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Kernel modesetting setup failed\n");
+ goto fail;
+ }
+ if (drmmode_pre_init(pScrn, &info->drmmode, pScrn->bitsPerPixel / 8) == FALSE) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Kernel modesetting setup failed\n");
goto fail;
}
- info->dri->drmFD = info->drmmode.fd;
- info->dri2.drm_fd = info->drmmode.fd;
info->dri2.enabled = FALSE;
- xfree(bus_id);
info->dri->pKernelDRMVersion = drmGetVersion(info->dri->drmFD);
if (info->dri->pKernelDRMVersion == NULL) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,