diff options
Diffstat (limited to 'src/mga_dri.c')
-rw-r--r-- | src/mga_dri.c | 70 |
1 files changed, 23 insertions, 47 deletions
diff --git a/src/mga_dri.c b/src/mga_dri.c index 6775cff..56ad243 100644 --- a/src/mga_dri.c +++ b/src/mga_dri.c @@ -606,8 +606,8 @@ static Bool MGADRIBootstrapDMA(ScreenPtr pScreen) xf86DrvMsg( pScreen->myNum, X_INFO, "[agp] Mode 0x%08lx [AGP 0x%04x/0x%04x; Card 0x%04x/0x%04x]\n", mode, vendor, device, - pMga->PciInfo->vendor, - pMga->PciInfo->chipType ); + pMga->PciInfo->vendor_id, + pMga->PciInfo->device_id ); if ( drmAgpEnable( pMga->drmFD, mode ) < 0 ) { xf86DrvMsg( pScreen->myNum, X_ERROR, "[agp] AGP not enabled\n" ); @@ -754,7 +754,7 @@ static Bool MGADRIBootstrapDMA(ScreenPtr pScreen) pMGADRIServer->registers.size = MGAIOMAPSIZE; if ( drmAddMap( pMga->drmFD, - (drm_handle_t)pMga->IOAddress, + (drm_handle_t)pMga->PciInfo->regions[ pMga->io_bar ].base_addr, pMGADRIServer->registers.size, DRM_REGISTERS, DRM_READ_ONLY, &pMGADRIServer->registers.handle ) < 0 ) { @@ -791,23 +791,16 @@ static Bool MGADRIKernelInit( ScreenPtr pScreen ) drm_mga_init_t init; int ret; + + if (!pMga->chip_attribs->dri_capable) { + return FALSE; + } + memset( &init, 0, sizeof(drm_mga_init_t) ); init.func = MGA_INIT_DMA; init.sarea_priv_offset = sizeof(XF86DRISAREARec); - - switch ( pMga->Chipset ) { - case PCI_CHIP_MGAG550: - case PCI_CHIP_MGAG400: - init.chipset = MGA_CARD_TYPE_G400; - break; - case PCI_CHIP_MGAG200: - case PCI_CHIP_MGAG200_PCI: - init.chipset = MGA_CARD_TYPE_G200; - break; - default: - return FALSE; - } + init.chipset = pMga->chip_attribs->dri_chipset; init.sgram = !pMga->HasSDRAM; init.maccess = pMga->MAccess; @@ -847,20 +840,19 @@ static Bool MGADRIKernelInit( ScreenPtr pScreen ) return TRUE; } +/* FIXME: This function uses the DRM to get the IRQ, but the pci_device + * FIXME: structure (PciInfo) already has that information. + */ static void MGADRIIrqInit(MGAPtr pMga, ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - /* version = drmGetVersion(pMga->drmFD); - if ( version ) { - if ( version->version_major != 3 || - version->version_minor < 0 ) {*/ if (!pMga->irq) { - pMga->irq = drmGetInterruptFromBusID( - pMga->drmFD, - ((pciConfigPtr)pMga->PciInfo->thisCard)->busnum, - ((pciConfigPtr)pMga->PciInfo->thisCard)->devnum, - ((pciConfigPtr)pMga->PciInfo->thisCard)->funcnum); + pMga->irq = drmGetInterruptFromBusID(pMga->drmFD, + ((pMga->PciInfo->domain << 8) | + pMga->PciInfo->bus), + pMga->PciInfo->dev, + pMga->PciInfo->func); if((drmCtlInstHandler(pMga->drmFD, pMga->irq)) != 0) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, @@ -908,13 +900,7 @@ Bool MGADRIScreenInit( ScreenPtr pScreen ) MGADRIPtr pMGADRI; MGADRIServerPrivatePtr pMGADRIServer; - switch(pMga->Chipset) { - case PCI_CHIP_MGAG550: - case PCI_CHIP_MGAG400: - case PCI_CHIP_MGAG200: - case PCI_CHIP_MGAG200_PCI: - break; - default: + if (!pMga->chip_attribs->dri_capable) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "[drm] Direct rendering only supported with G200/G400/G450/G550.\n"); return FALSE; } @@ -971,9 +957,10 @@ Bool MGADRIScreenInit( ScreenPtr pScreen ) } else { pDRIInfo->busIdString = xalloc(64); sprintf( pDRIInfo->busIdString, "PCI:%d:%d:%d", - ((pciConfigPtr)pMga->PciInfo->thisCard)->busnum, - ((pciConfigPtr)pMga->PciInfo->thisCard)->devnum, - ((pciConfigPtr)pMga->PciInfo->thisCard)->funcnum ); + ((pMga->PciInfo->domain << 8) | + pMga->PciInfo->bus), + pMga->PciInfo->dev, + pMga->PciInfo->func ); } pDRIInfo->ddxDriverMajorVersion = MGA_MAJOR_VERSION; pDRIInfo->ddxDriverMinorVersion = MGA_MINOR_VERSION; @@ -1205,18 +1192,7 @@ Bool MGADRIFinishScreenInit( ScreenPtr pScreen ) MGADRIIrqInit(pMga, pScreen); - switch(pMga->Chipset) { - case PCI_CHIP_MGAG550: - case PCI_CHIP_MGAG400: - pMGADRI->chipset = MGA_CARD_TYPE_G400; - break; - case PCI_CHIP_MGAG200: - case PCI_CHIP_MGAG200_PCI: - pMGADRI->chipset = MGA_CARD_TYPE_G200; - break; - default: - return FALSE; - } + pMGADRI->chipset = pMga->chip_attribs->dri_chipset; pMGADRI->width = pScrn->virtualX; pMGADRI->height = pScrn->virtualY; pMGADRI->cpp = pScrn->bitsPerPixel / 8; |