From: Jakob Bornecrantz Date: Tue, 20 Oct 2009 15:52:33 +0000 (+0200) Subject: st/xorg: Move drm init to own function X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=478332b0c1f0198bc7063300d203c21e42796045;p=mesa.git st/xorg: Move drm init to own function --- diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c index 7da10427eca..847647c1e4d 100644 --- a/src/gallium/state_trackers/xorg/xorg_driver.c +++ b/src/gallium/state_trackers/xorg/xorg_driver.c @@ -260,6 +260,37 @@ static const xf86CrtcConfigFuncsRec crtc_config_funcs = { crtc_resize }; +static Bool +InitDRM(ScrnInfoPtr pScrn) +{ + modesettingPtr ms = modesettingPTR(pScrn); + + /* deal with server regeneration */ + if (ms->fd < 0) { + char *BusID; + + BusID = xalloc(64); + sprintf(BusID, "PCI:%d:%d:%d", + ((ms->PciInfo->domain << 8) | ms->PciInfo->bus), + ms->PciInfo->dev, ms->PciInfo->func + ); + + ms->fd = drmOpen(NULL, BusID); + + if (ms->fd < 0) + return FALSE; + } + + if (!ms->api) { + ms->api = drm_api_create(); + + if (!ms->api) + return FALSE; + } + + return TRUE; +} + static Bool PreInit(ScrnInfoPtr pScrn, int flags) { @@ -268,7 +299,6 @@ PreInit(ScrnInfoPtr pScrn, int flags) rgb defaultWeight = { 0, 0, 0 }; EntityInfoPtr pEnt; EntPtr msEnt = NULL; - char *BusID; int max_width, max_height; if (pScrn->numEntities != 1) @@ -317,16 +347,9 @@ PreInit(ScrnInfoPtr pScrn, int flags) } } - BusID = xalloc(64); - sprintf(BusID, "PCI:%d:%d:%d", - ((ms->PciInfo->domain << 8) | ms->PciInfo->bus), - ms->PciInfo->dev, ms->PciInfo->func - ); - - ms->api = drm_api_create(); - ms->fd = drmOpen(NULL, BusID); - - if (ms->fd < 0) + ms->fd = -1; + ms->api = NULL; + if (!InitDRM(pScrn)) return FALSE; pScrn->monitor = pScrn->confScreen->monitor; @@ -525,24 +548,8 @@ ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) modesettingPtr ms = modesettingPTR(pScrn); VisualPtr visual; - /* deal with server regeneration */ - if (ms->fd < 0) { - char *BusID; - - BusID = xalloc(64); - sprintf(BusID, "PCI:%d:%d:%d", - ((ms->PciInfo->domain << 8) | ms->PciInfo->bus), - ms->PciInfo->dev, ms->PciInfo->func - ); - - ms->fd = drmOpen(NULL, BusID); - - if (ms->fd < 0) - return FALSE; - } - - if (!ms->api) - ms->api = drm_api_create(); + if (!InitDRM(pScrn)) + return FALSE; if (!ms->screen) { ms->screen = ms->api->create_screen(ms->api, ms->fd, NULL);