Signed-off-by: Qiang Yu <qiang...@amd.com> --- hw/xfree86/drivers/modesetting/driver.c | 64 ++++++++++++++++++++------------- hw/xfree86/drivers/modesetting/driver.h | 6 ---- 2 files changed, 39 insertions(+), 31 deletions(-)
diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c index c16bc0b..ddd7b16 100644 --- a/hw/xfree86/drivers/modesetting/driver.c +++ b/hw/xfree86/drivers/modesetting/driver.c @@ -823,32 +823,26 @@ msShouldDoubleShadow(ScrnInfoPtr pScrn, modesettingPtr ms) #define DRM_CAP_CURSOR_HEIGHT 0x9 #endif -static Bool -ms_get_drm_master_fd(ScrnInfoPtr pScrn) +static int +ms_entity_get_drm_master_fd(ScrnInfoPtr pScrn, EntityInfoPtr pEnt) { - EntityInfoPtr pEnt; - modesettingPtr ms; + int ret; modesettingEntPtr ms_ent; - char *BusID = NULL; - ms = modesettingPTR(pScrn); - ms_ent = ms_ent_priv(pScrn); - - pEnt = ms->pEnt; + ms_ent = xf86GetEntityPrivate(pEnt->index, ms_entity_index)->ptr; if (ms_ent->fd) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, " reusing fd for second head\n"); - ms->fd = ms_ent->fd; ms_ent->fd_ref++; - return TRUE; + return ms_ent->fd; } #if XSERVER_PLATFORM_BUS if (pEnt->location.type == BUS_PLATFORM) { #ifdef XF86_PDEV_SERVER_FD if (pEnt->location.id.plat->flags & XF86_PDEV_SERVER_FD) - ms->fd = + ret = xf86_platform_device_odev_attributes(pEnt->location.id.plat)-> fd; else @@ -857,39 +851,59 @@ ms_get_drm_master_fd(ScrnInfoPtr pScrn) char *path = xf86_platform_device_odev_attributes(pEnt->location.id.plat)-> path; - ms->fd = open_hw(path); + ret = open_hw(path); } } else #endif if (pEnt->location.type == BUS_PCI) { - ms->PciInfo = xf86GetPciInfoForEntity(ms->pEnt->index); - if (ms->PciInfo) { + char *BusID = NULL; +#if XSERVER_LIBPCIACCESS + struct pci_device *PciInfo; +#else + pciVideoPtr PciInfo; +#endif + PciInfo = xf86GetPciInfoForEntity(pEnt->index); + if (PciInfo) { BusID = XNFalloc(64); sprintf(BusID, "PCI:%d:%d:%d", #if XSERVER_LIBPCIACCESS - ((ms->PciInfo->domain << 8) | ms->PciInfo->bus), - ms->PciInfo->dev, ms->PciInfo->func + ((PciInfo->domain << 8) | PciInfo->bus), + PciInfo->dev, PciInfo->func #else - ((pciConfigPtr) ms->PciInfo->thisCard)->busnum, - ((pciConfigPtr) ms->PciInfo->thisCard)->devnum, - ((pciConfigPtr) ms->PciInfo->thisCard)->funcnum + ((pciConfigPtr) PciInfo->thisCard)->busnum, + ((pciConfigPtr) PciInfo->thisCard)->devnum, + ((pciConfigPtr) PciInfo->thisCard)->funcnum #endif ); } - ms->fd = drmOpen(NULL, BusID); + ret = drmOpen(NULL, BusID); free(BusID); } else { const char *devicename; - devicename = xf86FindOptionValue(ms->pEnt->device->options, "kmsdev"); - ms->fd = open_hw(devicename); + devicename = xf86FindOptionValue(pEnt->device->options, "kmsdev"); + ret = open_hw(devicename); } + if (ret < 0) + return ret; + + ms_ent->fd = ret; + ms_ent->fd_ref = 1; + return ret; +} + +static Bool +ms_get_drm_master_fd(ScrnInfoPtr pScrn) +{ + modesettingPtr ms; + + ms = modesettingPTR(pScrn); + + ms->fd = ms_entity_get_drm_master_fd(pScrn, ms->pEnt); if (ms->fd < 0) return FALSE; - ms_ent->fd = ms->fd; - ms_ent->fd_ref = 1; return TRUE; } diff --git a/hw/xfree86/drivers/modesetting/driver.h b/hw/xfree86/drivers/modesetting/driver.h index 37d6c6a..6330282 100644 --- a/hw/xfree86/drivers/modesetting/driver.h +++ b/hw/xfree86/drivers/modesetting/driver.h @@ -90,12 +90,6 @@ typedef struct _modesettingRec { int Chipset; EntityInfoPtr pEnt; -#if XSERVER_LIBPCIACCESS - struct pci_device *PciInfo; -#else - pciVideoPtr PciInfo; - PCITAG PciTag; -#endif Bool noAccel; CloseScreenProcPtr CloseScreen; -- 2.7.4 _______________________________________________ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel