static XF86ConfLayoutPtr configureLayoutSection (void) { int scrnum = 0; parsePrologue (XF86ConfLayoutPtr, XF86ConfLayoutRec) ptr->lay_identifier = "X.org Configured"; { XF86ConfInputrefPtr iptr; iptr = xf86confmalloc (sizeof (XF86ConfInputrefRec)); iptr->list.next = NULL; iptr->iref_option_lst = NULL; iptr->iref_inputdev_str = "Mouse0"; iptr->iref_option_lst = xf86addNewOption (iptr->iref_option_lst, xstrdup("CorePointer"), NULL); ptr->lay_input_lst = (XF86ConfInputrefPtr) xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr); } { XF86ConfInputrefPtr iptr; iptr = xf86confmalloc (sizeof (XF86ConfInputrefRec)); iptr->list.next = NULL; iptr->iref_option_lst = NULL; iptr->iref_inputdev_str = "Keyboard0"; iptr->iref_option_lst = xf86addNewOption (iptr->iref_option_lst, xstrdup("CoreKeyboard"), NULL); ptr->lay_input_lst = (XF86ConfInputrefPtr) xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr); } for (scrnum = 0; scrnum < nDevToConfig; scrnum++) { XF86ConfAdjacencyPtr aptr; aptr = xf86confmalloc (sizeof (XF86ConfAdjacencyRec)); aptr->list.next = NULL; aptr->adj_x = 0; aptr->adj_y = 0; aptr->adj_scrnum = scrnum; aptr->adj_screen_str = xnfalloc(18); sprintf(aptr->adj_screen_str, "Screen%d", scrnum); if (scrnum == 0) { aptr->adj_where = CONF_ADJ_ABSOLUTE; aptr->adj_refscreen = NULL; } else { aptr->adj_where = CONF_ADJ_RIGHTOF; aptr->adj_refscreen = xnfalloc(18); sprintf(aptr->adj_refscreen, "Screen%d", scrnum - 1); } ptr->lay_adjacency_lst = (XF86ConfAdjacencyPtr)xf86addListItem((glp)ptr->lay_adjacency_lst, (glp)aptr); } return ptr; }
/* * This is called by the driver, either through xf86Match???Instances() or * directly. We allocate a GDevRec and fill it in as much as we can, letting * the caller fill in the rest and/or change it as it sees fit. */ GDevPtr xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int chipset) { int ret, i, j; if (!xf86DoConfigure || !xf86DoConfigurePass1) return NULL; /* Check for duplicates */ switch (bus) { case BUS_PCI: ret = bus_pci_configure(busData); break; case BUS_SBUS: ret = bus_sbus_configure(busData); break; default: return NULL; } if (ret == 0) goto out; /* Allocate new structure occurrence */ i = nDevToConfig++; DevToConfig = xnfrealloc(DevToConfig, nDevToConfig * sizeof(DevToConfigRec)); memset(DevToConfig + i, 0, sizeof(DevToConfigRec)); DevToConfig[i].GDev.chipID = DevToConfig[i].GDev.chipRev = DevToConfig[i].GDev.irq = -1; DevToConfig[i].iDriver = CurrentDriver; /* Fill in what we know, converting the driver name to lower case */ DevToConfig[i].GDev.driver = xnfalloc(strlen(driver) + 1); for (j = 0; (DevToConfig[i].GDev.driver[j] = tolower(driver[j])); j++); switch (bus) { case BUS_PCI: bus_pci_newdev_configure(busData, i, &chipset); break; case BUS_SBUS: bus_sbus_newdev_configure(busData, i); break; default: break; } /* Get driver's available options */ if (xf86DriverList[CurrentDriver]->AvailableOptions) DevToConfig[i].GDev.options = (OptionInfoPtr) (*xf86DriverList[CurrentDriver]->AvailableOptions)(chipset, bus); return &DevToConfig[i].GDev; out: return NULL; }
void xf86SetSilkenMouse (ScreenPtr pScreen) { Bool useSM = TRUE; MessageType from = X_DEFAULT; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; OptionInfoPtr options; options = xnfalloc(sizeof(SMOptions)); (void)memcpy(options, SMOptions, sizeof(SMOptions)); xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options); /* check for commandline option here */ /* disable if screen shares resources */ /* TODO VGA arb disable silken mouse */ if (xf86silkenMouseDisableFlag) { from = X_CMDLINE; useSM = FALSE; } else { if (xf86GetOptValBool(options, OPTION_SILKEN_MOUSE, &useSM)) from = X_CONFIG; } free(options); /* * XXX quick hack to report correctly for OSs that can't do SilkenMouse * yet. Should handle this differently so that alternate async methods * work correctly with this too. */ pScrn->silkenMouse = useSM && xf86Info.useSIGIO && xf86SIGIOSupported(); if (serverGeneration == 1) xf86DrvMsg(pScreen->myNum, from, "Silken mouse %s\n", pScrn->silkenMouse ? "enabled" : "disabled"); }
Bool drmmode_pre_init(ScrnInfoPtr scrn, int fd, int cpp) { xf86CrtcConfigPtr xf86_config; drmmode_ptr drmmode; int i; drmmode = xnfalloc(sizeof *drmmode); drmmode->fd = fd; drmmode->fb_id = 0; xf86CrtcConfigInit(scrn, &drmmode_xf86crtc_config_funcs); xf86_config = XF86_CRTC_CONFIG_PTR(scrn); drmmode->cpp = cpp; drmmode->mode_res = drmModeGetResources(drmmode->fd); if (!drmmode->mode_res) { xf86DrvMsg(scrn->scrnIndex, X_ERROR, "failed to get resources: %s\n", strerror(errno)); return FALSE; } xf86CrtcSetSizeRange(scrn, 320, 200, drmmode->mode_res->max_width, drmmode->mode_res->max_height); for (i = 0; i < drmmode->mode_res->count_crtcs; i++) drmmode_crtc_init(scrn, drmmode, i); for (i = 0; i < drmmode->mode_res->count_connectors; i++) drmmode_output_init(scrn, drmmode, i); xf86InitialConfiguration(scrn, TRUE); return TRUE; }
void xf86AddDriver(DriverPtr driver, pointer module, int flags) { /* Don't add null entries */ if (!driver) return; if (xf86DriverList == NULL) xf86NumDrivers = 0; xf86NumDrivers++; xf86DriverList = xnfrealloc(xf86DriverList, xf86NumDrivers * sizeof(DriverPtr)); xf86DriverList[xf86NumDrivers - 1] = xnfalloc(sizeof(DriverRec)); if (flags & HaveDriverFuncs) *xf86DriverList[xf86NumDrivers - 1] = *driver; else { (void) memset( xf86DriverList[xf86NumDrivers - 1], 0, sizeof( DriverRec ) ); (void) memcpy( xf86DriverList[xf86NumDrivers - 1], driver, sizeof(DriverRec1)); } xf86DriverList[xf86NumDrivers - 1]->module = module; xf86DriverList[xf86NumDrivers - 1]->refCount = 0; }
void xf86SetBackingStore(ScreenPtr pScreen) { Bool useBS = FALSE; MessageType from = X_DEFAULT; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; OptionInfoPtr options; options = xnfalloc(sizeof(BSOptions)); (void)memcpy(options, BSOptions, sizeof(BSOptions)); xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options); /* check for commandline option here */ if (xf86bsEnableFlag) { from = X_CMDLINE; useBS = TRUE; } else if (xf86bsDisableFlag) { from = X_CMDLINE; useBS = FALSE; } else { if (xf86GetOptValBool(options, OPTION_BACKING_STORE, &useBS)) from = X_CONFIG; } free(options); pScreen->backingStoreSupport = useBS ? Always : NotUseful; if (serverGeneration == 1) xf86DrvMsg(pScreen->myNum, from, "Backing store %s\n", useBS ? "enabled" : "disabled"); }
static void bus_pci_newdev_configure(void *busData, int i, int *chipset) { const char *VendorName; const char *CardName; char busnum[8]; struct pci_device * pVideo = NULL; pVideo = (struct pci_device *) busData; DevToConfig[i].pVideo = pVideo; VendorName = pci_device_get_vendor_name( pVideo ); CardName = pci_device_get_device_name( pVideo ); if (!VendorName) { VendorName = xnfalloc(15); sprintf((char*)VendorName, "Unknown Vendor"); } if (!CardName) { CardName = xnfalloc(14); sprintf((char*)CardName, "Unknown Board"); } DevToConfig[i].GDev.identifier = xnfalloc(strlen(VendorName) + strlen(CardName) + 2); sprintf(DevToConfig[i].GDev.identifier, "%s %s", VendorName, CardName); DevToConfig[i].GDev.vendor = (char *)VendorName; DevToConfig[i].GDev.board = (char *)CardName; DevToConfig[i].GDev.busID = xnfalloc(16); xf86FormatPciBusNumber(pVideo->bus, busnum); sprintf(DevToConfig[i].GDev.busID, "PCI:%s:%d:%d", busnum, pVideo->dev, pVideo->func); DevToConfig[i].GDev.chipID = pVideo->device_id; DevToConfig[i].GDev.chipRev = pVideo->revision; if (*chipset < 0) { *chipset = (pVideo->vendor_id << 16) | pVideo->device_id; } }
void xf86STimestamp(xf86TsPtr* timestamp) { if (*timestamp) { gettimeofday((struct timeval*)*timestamp,NULL); } else { *timestamp = xnfalloc(sizeof(xf86TsRec)); gettimeofday((struct timeval*)*timestamp,NULL); } }
void xf86SbusConfigureNewDev(void *busData, sbusDevicePtr sBus, GDevRec *GDev) { char *promPath = NULL; sBus = (sbusDevicePtr) busData; GDev->identifier = sBus->descr; if (sparcPromInit() >= 0) { promPath = sparcPromNode2Pathname(&sBus->node); sparcPromClose(); } if (promPath) { GDev->busID = xnfalloc(strlen(promPath) + 6); sprintf(GDev->busID, "SBUS:%s", promPath); free(promPath); } else { GDev->busID = xnfalloc(12); sprintf(GDev->busID, "SBUS:fb%d", sBus->fbNum); } }
/* This gets called at the start of each server generation */ static Bool VoodooScreenInit(SCREEN_INIT_ARGS_DECL) { ScrnInfoPtr pScrn; VoodooPtr pVoo; int ret; VisualPtr visual; void *FBStart; CARD32 displayWidth; /* * First get the ScrnInfoRec */ pScrn = xf86ScreenToScrn(pScreen); pVoo = VoodooPTR(pScrn); if (!VoodooModeInit(pScrn, pScrn->currentMode)) return FALSE; VoodooClear(pVoo); /* * The next step is to setup the screen's visuals, and initialise the * framebuffer code. In cases where the framebuffer's default * choices for things like visual layouts and bits per RGB are OK, * this may be as simple as calling the framebuffer's ScreenInit() * function. If not, the visuals will need to be setup before calling * a fb ScreenInit() function and fixed up after. * * For most PC hardware at depths >= 8, the defaults that fb uses * are not appropriate. In this driver, we fixup the visuals after. */ /* * Reset the visual list. */ miClearVisualTypes(); /* Setup the visuals we support. Only TrueColor. */ if (!miSetVisualTypes(pScrn->depth, miGetDefaultVisualMask(pScrn->depth), pScrn->rgbBits, pScrn->defaultVisual)) return FALSE; miSetPixmapDepths (); if(pVoo->ShadowFB) { pVoo->ShadowPitch = ((pScrn->virtualX * pScrn->bitsPerPixel >> 3) + 3) & ~3L; pVoo->ShadowPtr = xnfalloc(pVoo->ShadowPitch * pScrn->virtualY); FBStart = pVoo->ShadowPtr; displayWidth = pScrn->virtualX; }
static void bus_sbus_newdev_configure(void *busData, int i) { #if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) char *promPath = NULL; DevToConfig[i].sVideo = (sbusDevicePtr) busData; DevToConfig[i].GDev.identifier = DevToConfig[i].sVideo->descr; if (sparcPromInit() >= 0) { promPath = sparcPromNode2Pathname(&DevToConfig[i].sVideo->node); sparcPromClose(); } if (promPath) { DevToConfig[i].GDev.busID = xnfalloc(strlen(promPath) + 6); sprintf(DevToConfig[i].GDev.busID, "SBUS:%s", promPath); xfree(promPath); } else { DevToConfig[i].GDev.busID = xnfalloc(12); sprintf(DevToConfig[i].GDev.busID, "SBUS:fb%d", DevToConfig[i].sVideo->fbNum); } #endif }
void miMarkWindow(WindowPtr pWin) { ValidatePtr val; if (pWin->valdata) return; val = (ValidatePtr)xnfalloc(sizeof(ValidateRec)); val->before.oldAbsCorner.x = pWin->drawable.x; val->before.oldAbsCorner.y = pWin->drawable.y; val->before.borderVisible = NullRegion; val->before.resized = FALSE; pWin->valdata = val; }
void InitConnectionLimits(void) { lastfdesc = -1; #ifndef __CYGWIN__ #if !defined(XNO_SYSCONF) && defined(_SC_OPEN_MAX) lastfdesc = sysconf(_SC_OPEN_MAX) - 1; #endif #ifdef HAS_GETDTABLESIZE if (lastfdesc < 0) lastfdesc = getdtablesize() - 1; #endif #ifdef _NFILE if (lastfdesc < 0) lastfdesc = _NFILE - 1; #endif #endif /* __CYGWIN__ */ /* This is the fallback */ if (lastfdesc < 0) lastfdesc = MAXSOCKS; if (lastfdesc > MAXSELECT) lastfdesc = MAXSELECT; if (lastfdesc > MAXCLIENTS) { lastfdesc = MAXCLIENTS; if (debug_conns) ErrorF( "REACHED MAXIMUM CLIENTS LIMIT %d\n", MAXCLIENTS); } MaxClients = lastfdesc; #ifdef DEBUG ErrorF("InitConnectionLimits: MaxClients = %d\n", MaxClients); #endif #if !defined(WIN32) if (!ConnectionTranslation) ConnectionTranslation = (int *)xnfalloc(sizeof(int)*(lastfdesc + 1)); #else InitConnectionTranslation(); #endif }
static void checkMtrrOption(VidMapPtr vp) { if (!vp->mtrrOptChecked && vp->pScrn && vp->pScrn->options != NULL) { OptionInfoPtr options; options = xnfalloc(sizeof(opts)); (void) memcpy(options, opts, sizeof(opts)); xf86ProcessOptions(vp->pScrn->scrnIndex, vp->pScrn->options, options); if (xf86GetOptValBool(options, OPTION_MTRR, &vp->mtrrEnabled)) vp->mtrrFrom = X_CONFIG; free(options); vp->mtrrOptChecked = TRUE; } }
static void AppendToList(const char *s, const char ***list, int *lines) { char *str, *newstr, *p; str = xnfstrdup(s); for (p = strtok(str, "\n"); p; p = strtok(NULL, "\n")) { (*lines)++; *list = xnfrealloc(*list, (*lines + 1) * sizeof(**list)); newstr = xnfalloc(strlen(p) + 2); strcpy(newstr, p); strcat(newstr, "\n"); (*list)[*lines - 1] = newstr; (*list)[*lines] = NULL; } free(str); }
void xf86AddInputDriver(InputDriverPtr driver, pointer module, int flags) { /* Don't add null entries */ if (!driver) return; if (xf86InputDriverList == NULL) xf86NumInputDrivers = 0; xf86NumInputDrivers++; xf86InputDriverList = xnfrealloc(xf86InputDriverList, xf86NumInputDrivers * sizeof(InputDriverPtr)); xf86InputDriverList[xf86NumInputDrivers - 1] = xnfalloc(sizeof(InputDriverRec)); *xf86InputDriverList[xf86NumInputDrivers - 1] = *driver; xf86InputDriverList[xf86NumInputDrivers - 1]->module = module; }
/** * Try to find the framebuffer device for a given PCI device */ static int fbdev_open_pci(struct pci_device *pPci, char **namep) { struct fb_fix_screeninfo fix; char filename[256]; int fd, i; for (i = 0; i < 8; i++) { snprintf(filename, sizeof(filename), "/sys/bus/pci/devices/%04x:%02x:%02x.%d/graphics/fb%d", pPci->domain, pPci->bus, pPci->dev, pPci->func, i); fd = open(filename, O_RDONLY, 0); if (fd < 0) { snprintf(filename, sizeof(filename), "/sys/bus/pci/devices/%04x:%02x:%02x.%d/graphics:fb%d", pPci->domain, pPci->bus, pPci->dev, pPci->func, i); fd = open(filename, O_RDONLY, 0); } if (fd >= 0) { close(fd); snprintf(filename, sizeof(filename), "/dev/fb%d", i); fd = open(filename, O_RDWR, 0); if (fd != -1) { if (ioctl(fd, FBIOGET_FSCREENINFO, (void *) &fix) != -1) { if (namep) { *namep = xnfalloc(16); strncpy(*namep, fix.id, 16); } return fd; } close(fd); } } } if (namep) *namep = NULL; xf86DrvMsg(-1, X_ERROR, "Unable to find a valid framebuffer device\n"); return -1; }
xf86MonPtr xf86DoEDID_DDC2(int scrnIndex, I2CBusPtr pBus) { ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; unsigned char *EDID_block = NULL; unsigned char *VDIF_Block = NULL; xf86MonPtr tmp = NULL; /* Default DDC and DDC2 to enabled. */ Bool noddc = FALSE, noddc2 = FALSE; OptionInfoPtr options; options = xnfalloc(sizeof(DDCOptions)); (void)memcpy(options, DDCOptions, sizeof(DDCOptions)); xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options); xf86GetOptValBool(options, DDCOPT_NODDC, &noddc); xf86GetOptValBool(options, DDCOPT_NODDC2, &noddc2); xfree(options); if (noddc || noddc2) return NULL; EDID_block = EDID1Read_DDC2(scrnIndex,pBus); if (EDID_block){ tmp = xf86InterpretEDID(scrnIndex,EDID_block); } else { #ifdef DEBUG ErrorF("No EDID block returned\n"); #endif return NULL; } #ifdef DEBUG if (!tmp) ErrorF("Cannot interpret EDID block\n"); ErrorF("Sections to follow: %i\n",tmp->no_sections); #endif VDIF_Block = VDIFRead(scrnIndex, pBus, EDID1_LEN * (tmp->no_sections + 1)); tmp->vdif = xf86InterpretVdif(VDIF_Block); return tmp; }
void xf86SPTimestamp(xf86TsPtr* timestamp, char *str) { if (*timestamp) { long diff; struct timeval ts; ts = **(struct timeval**)timestamp; gettimeofday((struct timeval*)*timestamp,NULL); if (ts.tv_usec > (*timestamp)->usec) diff = ((*timestamp)->sec - ts.tv_sec - 1) * 1000 + (ts.tv_usec - (*timestamp)->usec) / 1000; else diff = ((*timestamp)->sec - ts.tv_sec) * 1000 +(- ts.tv_usec + (*timestamp)->usec) / 1000; ErrorF("%s Elapsed: %li\n",str,diff); } else { *timestamp = xnfalloc(sizeof(xf86TsRec)); gettimeofday((struct timeval*)*timestamp,NULL); } }
static int fbdev_open(int scrnIndex, char *dev, char **namep) { struct fb_fix_screeninfo fix; int fd; /* try argument (from XF86Config) first */ if (dev) { fd = open(dev, O_RDWR, 0); } else { /* second: environment variable */ dev = getenv("FRAMEBUFFER"); if ((NULL == dev) || ((fd = open(dev, O_RDWR, 0)) == -1)) { /* last try: default device */ dev = "/dev/fb0"; fd = open(dev, O_RDWR, 0); } } if (fd == -1) { xf86DrvMsg(scrnIndex, X_ERROR, "open %s: %s\n", dev, strerror(errno)); return -1; } if (namep) { if (-1 == ioctl(fd, FBIOGET_FSCREENINFO, (void *) (&fix))) { *namep = NULL; xf86DrvMsg(scrnIndex, X_ERROR, "FBIOGET_FSCREENINFO: %s\n", strerror(errno)); return -1; } else { *namep = xnfalloc(16); strncpy(*namep, fix.id, 16); } } return fd; }
xf86MonPtr xf86DoEDID_DDC1( int scrnIndex, void (*DDC1SetSpeed)(ScrnInfoPtr, xf86ddcSpeed), unsigned int (*DDC1Read)(ScrnInfoPtr) ) { ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; unsigned char *EDID_block = NULL; xf86MonPtr tmp = NULL; int sigio; /* Default DDC and DDC1 to enabled. */ Bool noddc = FALSE, noddc1 = FALSE; OptionInfoPtr options; options = xnfalloc(sizeof(DDCOptions)); (void)memcpy(options, DDCOptions, sizeof(DDCOptions)); xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options); xf86GetOptValBool(options, DDCOPT_NODDC, &noddc); xf86GetOptValBool(options, DDCOPT_NODDC1, &noddc1); xfree(options); if (noddc || noddc1) return NULL; sigio = xf86BlockSIGIO(); EDID_block = EDIDRead_DDC1(pScrn,DDC1SetSpeed,DDC1Read); xf86UnblockSIGIO(sigio); if (EDID_block){ tmp = xf86InterpretEDID(scrnIndex,EDID_block); } #ifdef DEBUG else ErrorF("No EDID block returned\n"); if (!tmp) ErrorF("Cannot interpret EDID block\n"); #endif return tmp; }
static struct mem_range_desc * getAllRanges(int *nmr) { struct mem_range_desc *mrd; struct mem_range_op mro; /* * Find how many ranges there are. If this fails, then the kernel * probably doesn't have MTRR support. */ mro.mo_arg[0] = 0; if (ioctl(devMemFd, MEMRANGE_GET, &mro)) return NULL; *nmr = mro.mo_arg[0]; mrd = xnfalloc(*nmr * sizeof(struct mem_range_desc)); mro.mo_arg[0] = *nmr; mro.mo_desc = mrd; if (ioctl(devMemFd, MEMRANGE_GET, &mro)) { free(mrd); return NULL; } return mrd; }
/** * Attempts to probe the monitor for EDID information, if NoDDC and NoDDC1 are * unset. EDID information blocks are interpreted and the results returned in * an xf86MonPtr. * * This function does not affect the list of modes used by drivers -- it is up * to the driver to decide policy on what to do with EDID information. * * @return pointer to a new xf86MonPtr containing the EDID information. * @return NULL if no monitor attached or failure to interpret the EDID. */ xf86MonPtr xf86DoEDID_DDC1(ScrnInfoPtr pScrn, DDC1SetSpeedProc DDC1SetSpeed, unsigned int (*DDC1Read) (ScrnInfoPtr)) { unsigned char *EDID_block = NULL; xf86MonPtr tmp = NULL; /* Default DDC and DDC1 to enabled. */ Bool noddc = FALSE, noddc1 = FALSE; OptionInfoPtr options; options = xnfalloc(sizeof(DDCOptions)); (void) memcpy(options, DDCOptions, sizeof(DDCOptions)); xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options); xf86GetOptValBool(options, DDCOPT_NODDC, &noddc); xf86GetOptValBool(options, DDCOPT_NODDC1, &noddc1); free(options); if (noddc || noddc1) return NULL; OsBlockSignals(); EDID_block = EDIDRead_DDC1(pScrn, DDC1SetSpeed, DDC1Read); OsReleaseSignals(); if (EDID_block) { tmp = xf86InterpretEDID(pScrn->scrnIndex, EDID_block); } #ifdef DEBUG else ErrorF("No EDID block returned\n"); if (!tmp) ErrorF("Cannot interpret EDID block\n"); #endif return tmp; }
Bool XPAccelInit(ScreenPtr pScreen) { XAAInfoRecPtr infoPtr; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; TRIDENTPtr pTrident = TRIDENTPTR(pScrn); if (pTrident->NoAccel) return FALSE; pTrident->AccelInfoRec = infoPtr = XAACreateInfoRec(); if (!infoPtr) return FALSE; infoPtr->Flags = PIXMAP_CACHE | OFFSCREEN_PIXMAPS | LINEAR_FRAMEBUFFER; pTrident->InitializeAccelerator = XPInitializeAccelerator; XPInitializeAccelerator(pScrn); infoPtr->Sync = XPSync; #if 0 /* TO DO for the XP */ infoPtr->SolidLineFlags = NO_PLANEMASK; infoPtr->SetupForSolidLine = XPSetupForSolidLine; infoPtr->SolidBresenhamLineErrorTermBits = 12; infoPtr->SubsequentSolidBresenhamLine = XPSubsequentSolidBresenhamLine; infoPtr->DashedLineFlags = LINE_PATTERN_MSBFIRST_LSBJUSTIFIED | NO_PLANEMASK | LINE_PATTERN_POWER_OF_2_ONLY; infoPtr->SetupForDashedLine = XPSetupForDashedLine; infoPtr->DashedBresenhamLineErrorTermBits = 12; infoPtr->SubsequentDashedBresenhamLine = XPSubsequentDashedBresenhamLine; infoPtr->DashPatternMaxLength = 16; #endif infoPtr->SolidFillFlags = NO_PLANEMASK; infoPtr->SetupForSolidFill = XPSetupForFillRectSolid; infoPtr->SubsequentSolidFillRect = XPSubsequentFillRectSolid; infoPtr->SubsequentSolidHorVertLine = XPSubsequentSolidHorVertLine; infoPtr->ScreenToScreenCopyFlags = NO_PLANEMASK | NO_TRANSPARENCY; infoPtr->SetupForScreenToScreenCopy = XPSetupForScreenToScreenCopy; infoPtr->SubsequentScreenToScreenCopy = XPSubsequentScreenToScreenCopy; infoPtr->Mono8x8PatternFillFlags = NO_PLANEMASK | HARDWARE_PATTERN_PROGRAMMED_BITS | BIT_ORDER_IN_BYTE_MSBFIRST; infoPtr->SetupForMono8x8PatternFill = XPSetupForMono8x8PatternFill; infoPtr->SubsequentMono8x8PatternFillRect = XPSubsequentMono8x8PatternFillRect; #if 0 /* Needs fixing */ infoPtr->ScanlineCPUToScreenColorExpandFillFlags = NO_PLANEMASK | BIT_ORDER_IN_BYTE_MSBFIRST; pTrident->XAAScanlineColorExpandBuffers[0] = xnfalloc(((pScrn->virtualX + 63)) *4* (pScrn->bitsPerPixel / 8)); infoPtr->NumScanlineColorExpandBuffers = 1; infoPtr->ScanlineColorExpandBuffers = pTrident->XAAScanlineColorExpandBuffers; infoPtr->SetupForScanlineCPUToScreenColorExpandFill = XPSetupForScanlineCPUToScreenColorExpandFill; infoPtr->SubsequentScanlineCPUToScreenColorExpandFill = XPSubsequentScanlineCPUToScreenColorExpandFill; infoPtr->SubsequentColorExpandScanline = XPSubsequentColorExpandScanline; #endif return(XAAInit(pScreen, infoPtr)); }
/* * This is called by the driver, either through xf86Match???Instances() or * directly. We allocate a GDevRec and fill it in as much as we can, letting * the caller fill in the rest and/or change it as it sees fit. */ GDevPtr xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int chipset) { int i, j; pciVideoPtr pVideo = NULL; Bool isPrimary = FALSE; if (xf86DoProbe || !xf86DoConfigure || !xf86DoConfigurePass1) return NULL; /* Check for duplicates */ switch (bus) { case BUS_PCI: pVideo = (pciVideoPtr) busData; for (i = 0; i < nDevToConfig; i++) if (DevToConfig[i].pVideo && (DevToConfig[i].pVideo->bus == pVideo->bus) && (DevToConfig[i].pVideo->device == pVideo->device) && (DevToConfig[i].pVideo->func == pVideo->func)) return NULL; isPrimary = xf86IsPrimaryPci(pVideo); break; case BUS_ISA: /* * This needs to be revisited as it doesn't allow for non-PCI * multihead. */ if (!xf86IsPrimaryIsa()) return NULL; isPrimary = TRUE; for (i = 0; i < nDevToConfig; i++) if (!DevToConfig[i].pVideo) return NULL; break; #if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) case BUS_SBUS: for (i = 0; i < nDevToConfig; i++) if (DevToConfig[i].sVideo && DevToConfig[i].sVideo->fbNum == ((sbusDevicePtr) busData)->fbNum) return NULL; break; #endif default: return NULL; } /* Allocate new structure occurrence */ i = nDevToConfig++; DevToConfig = xnfrealloc(DevToConfig, nDevToConfig * sizeof(DevToConfigRec)); #if 1 /* Doesn't work when a driver detects more than one adapter */ if ((i > 0) && isPrimary) { memmove(DevToConfig + 1,DevToConfig, (nDevToConfig - 1) * sizeof(DevToConfigRec)); i = 0; } #endif memset(DevToConfig + i, 0, sizeof(DevToConfigRec)); # define NewDevice DevToConfig[i] NewDevice.GDev.chipID = NewDevice.GDev.chipRev = NewDevice.GDev.irq = -1; NewDevice.iDriver = CurrentDriver; /* Fill in what we know, converting the driver name to lower case */ NewDevice.GDev.driver = xnfalloc(strlen(driver) + 1); for (j = 0; (NewDevice.GDev.driver[j] = tolower(driver[j])); j++); switch (bus) { case BUS_PCI: { const char *VendorName; const char *CardName; char busnum[8]; NewDevice.pVideo = pVideo; xf86FindPciNamesByDevice(pVideo->vendor, pVideo->chipType, NOVENDOR, NOSUBSYS, &VendorName, &CardName, NULL, NULL); if (!VendorName) { VendorName = xnfalloc(15); sprintf((char*)VendorName, "Unknown Vendor"); } if (!CardName) { CardName = xnfalloc(14); sprintf((char*)CardName, "Unknown Board"); } NewDevice.GDev.identifier = xnfalloc(strlen(VendorName) + strlen(CardName) + 2); sprintf(NewDevice.GDev.identifier, "%s %s", VendorName, CardName); NewDevice.GDev.vendor = (char *)VendorName; NewDevice.GDev.board = (char *)CardName; NewDevice.GDev.busID = xnfalloc(16); xf86FormatPciBusNumber(pVideo->bus, busnum); sprintf(NewDevice.GDev.busID, "PCI:%s:%d:%d", busnum, pVideo->device, pVideo->func); NewDevice.GDev.chipID = pVideo->chipType; NewDevice.GDev.chipRev = pVideo->chipRev; if (chipset < 0) chipset = (pVideo->vendor << 16) | pVideo->chipType; } break; case BUS_ISA: NewDevice.GDev.identifier = "ISA Adapter"; NewDevice.GDev.busID = "ISA"; break; #if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) case BUS_SBUS: { char *promPath = NULL; NewDevice.sVideo = (sbusDevicePtr) busData; NewDevice.GDev.identifier = NewDevice.sVideo->descr; if (sparcPromInit() >= 0) { promPath = sparcPromNode2Pathname(&NewDevice.sVideo->node); sparcPromClose(); } if (promPath) { NewDevice.GDev.busID = xnfalloc(strlen(promPath) + 6); sprintf(NewDevice.GDev.busID, "SBUS:%s", promPath); xfree(promPath); } else { NewDevice.GDev.busID = xnfalloc(12); sprintf(NewDevice.GDev.busID, "SBUS:fb%d", NewDevice.sVideo->fbNum); } } break; #endif default: break; } /* Get driver's available options */ if (xf86DriverList[CurrentDriver]->AvailableOptions) NewDevice.GDev.options = (OptionInfoPtr) (*xf86DriverList[CurrentDriver]->AvailableOptions)(chipset, bus); return &NewDevice.GDev; # undef NewDevice }
Bool TridentAccelInit(ScreenPtr pScreen) { XAAInfoRecPtr infoPtr; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; TRIDENTPtr pTrident = TRIDENTPTR(pScrn); if (pTrident->NoAccel) return FALSE; pTrident->AccelInfoRec = infoPtr = XAACreateInfoRec(); if (!infoPtr) return FALSE; if (!(pTrident->Chipset == TGUI9440AGi && pScrn->bitsPerPixel > 8)) infoPtr->Flags = PIXMAP_CACHE | OFFSCREEN_PIXMAPS | LINEAR_FRAMEBUFFER; pTrident->InitializeAccelerator = TridentInitializeAccelerator; TridentInitializeAccelerator(pScrn); infoPtr->PixmapCacheFlags = DO_NOT_BLIT_STIPPLES; infoPtr->Sync = TridentSync; infoPtr->SolidLineFlags = NO_PLANEMASK; infoPtr->SetupForSolidLine = TridentSetupForSolidLine; infoPtr->SolidBresenhamLineErrorTermBits = 12; infoPtr->SubsequentSolidBresenhamLine = TridentSubsequentSolidBresenhamLine; infoPtr->SubsequentSolidHorVertLine = TridentSubsequentSolidHorVertLine; infoPtr->DashedLineFlags = LINE_PATTERN_MSBFIRST_LSBJUSTIFIED | NO_PLANEMASK | LINE_PATTERN_POWER_OF_2_ONLY; infoPtr->SetupForDashedLine = TridentSetupForDashedLine; infoPtr->DashedBresenhamLineErrorTermBits = 12; infoPtr->SubsequentDashedBresenhamLine = TridentSubsequentDashedBresenhamLine; infoPtr->DashPatternMaxLength = 16; infoPtr->SolidFillFlags = NO_PLANEMASK; infoPtr->SetupForSolidFill = TridentSetupForFillRectSolid; infoPtr->SubsequentSolidFillRect = TridentSubsequentFillRectSolid; infoPtr->ScreenToScreenCopyFlags = NO_PLANEMASK; if (!HAS_DST_TRANS) infoPtr->ScreenToScreenCopyFlags |= NO_TRANSPARENCY; infoPtr->SetupForScreenToScreenCopy = TridentSetupForScreenToScreenCopy; infoPtr->SubsequentScreenToScreenCopy = TridentSubsequentScreenToScreenCopy; if (!((pTrident->Chipset == PROVIDIA9685 || pTrident->Chipset == CYBER9388) && pScrn->bitsPerPixel > 8)) { infoPtr->Mono8x8PatternFillFlags = NO_PLANEMASK | HARDWARE_PATTERN_SCREEN_ORIGIN | BIT_ORDER_IN_BYTE_MSBFIRST; infoPtr->SetupForMono8x8PatternFill = TridentSetupForMono8x8PatternFill; infoPtr->SubsequentMono8x8PatternFillRect = TridentSubsequentMono8x8PatternFillRect; } #if 0 /* Not convinced this works 100% yet */ infoPtr->Color8x8PatternFillFlags = NO_PLANEMASK | HARDWARE_PATTERN_SCREEN_ORIGIN | BIT_ORDER_IN_BYTE_MSBFIRST; if (!HAS_DST_TRANS) infoPtr->Color8x8PatternFillFlags |= NO_TRANSPARENCY; infoPtr->SetupForColor8x8PatternFill = TridentSetupForColor8x8PatternFill; infoPtr->SubsequentColor8x8PatternFillRect = TridentSubsequentColor8x8PatternFillRect; #endif #if 0 /* This is buggy, it only seems to work 95% of the time.... */ { infoPtr->ScanlineCPUToScreenColorExpandFillFlags = NO_PLANEMASK | NO_TRANSPARENCY | BIT_ORDER_IN_BYTE_MSBFIRST; pTrident->XAAScanlineColorExpandBuffers[0] = xnfalloc(((pScrn->virtualX + 63)) *4* (pScrn->bitsPerPixel / 8)); infoPtr->NumScanlineColorExpandBuffers = 1; infoPtr->ScanlineColorExpandBuffers = pTrident->XAAScanlineColorExpandBuffers; infoPtr->SetupForScanlineCPUToScreenColorExpandFill = TridentSetupForScanlineCPUToScreenColorExpandFill; infoPtr->SubsequentScanlineCPUToScreenColorExpandFill = TridentSubsequentScanlineCPUToScreenColorExpandFill; infoPtr->SubsequentColorExpandScanline = TridentSubsequentColorExpandScanline; } #endif return(XAAInit(pScreen, infoPtr)); }
Bool Neo2097AccelInit(ScreenPtr pScreen) { XAAInfoRecPtr infoPtr; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; NEOPtr nPtr = NEOPTR(pScrn); NEOACLPtr nAcl = NEOACLPTR(pScrn); nPtr->AccelInfoRec = infoPtr = XAACreateInfoRec(); if(!infoPtr) return FALSE; /* * Set up the main acceleration flags. */ infoPtr->Flags = LINEAR_FRAMEBUFFER | OFFSCREEN_PIXMAPS; if(nAcl->cacheEnd > nAcl->cacheStart) infoPtr->Flags |= PIXMAP_CACHE; infoPtr->PixmapCacheFlags = DO_NOT_BLIT_STIPPLES; /* sync */ infoPtr->Sync = Neo2097Sync; /* screen to screen copy */ infoPtr->ScreenToScreenCopyFlags = (NO_TRANSPARENCY | NO_PLANEMASK); infoPtr->SetupForScreenToScreenCopy = Neo2097SetupForScreenToScreenCopy; infoPtr->SubsequentScreenToScreenCopy = Neo2097SubsequentScreenToScreenCopy; /* solid filled rectangles */ infoPtr->SolidFillFlags = NO_PLANEMASK; infoPtr->SetupForSolidFill = Neo2097SetupForSolidFillRect; infoPtr->SubsequentSolidFillRect = Neo2097SubsequentSolidFillRect; if (!nPtr->strangeLockups) { /* cpu to screen color expansion */ /* * We do CPUToScreenColorExpand (ab)using the Scanline functions: * the neo chipsets need byte padding however we can only do dword * padding. Fortunately the graphics engine doesn't choke if we * transfer up to 3 bytes more than it wants. */ infoPtr->ScanlineColorExpandBuffers = (unsigned char **)xnfalloc(sizeof(char*)); infoPtr->ScanlineColorExpandBuffers[0] = (unsigned char *)(nPtr->NeoMMIOBase + 0x100000); infoPtr->NumScanlineColorExpandBuffers = 1; infoPtr->ScanlineCPUToScreenColorExpandFillFlags = ( NO_PLANEMASK | #ifdef NEO_DO_CLIPPING LEFT_EDGE_CLIPPING | #endif CPU_TRANSFER_PAD_DWORD | BIT_ORDER_IN_BYTE_MSBFIRST ); infoPtr->SetupForScanlineCPUToScreenColorExpandFill = Neo2097SetupScanlineForCPUToScreenColorExpandFill; infoPtr->SubsequentScanlineCPUToScreenColorExpandFill = Neo2097SubsequentScanlineCPUToScreenColorExpandFill; infoPtr->SubsequentColorExpandScanline = Neo2097SubsequentColorExpandScanline; } #if 0 /* 8x8 pattern fills */ infoPtr->Mono8x8PatternFillFlags = NO_PLANEMASK | HARDWARE_PATTERN_PROGRAMMED_ORIGIN | BIT_ORDER_IN_BYTE_MSBFIRST; infoPtr->SetupForMono8x8PatternFill = Neo2097SetupForMono8x8PatternFill; infoPtr->SubsequentMono8x8PatternFillRect = Neo2097SubsequentMono8x8PatternFill; #endif if (!nPtr->strangeLockups) { /* image writes */ infoPtr->ScanlineImageWriteFlags = ( CPU_TRANSFER_PAD_DWORD | SCANLINE_PAD_DWORD | NO_TRANSPARENCY | NO_PLANEMASK ); infoPtr->SetupForScanlineImageWrite = Neo2097SetupForScanlineImageWrite; infoPtr->SubsequentScanlineImageWriteRect = Neo2097SubsequentScanlineImageWriteRect; infoPtr->SubsequentImageWriteScanline = Neo2097SubsequentImageWriteScanline; infoPtr->NumScanlineImageWriteBuffers = 1; infoPtr->ScanlineImageWriteBuffers = infoPtr->ScanlineColorExpandBuffers; } /* * Setup some global variables */ nAcl->ColorShiftAmt = 0; /* Initialize for 8bpp or 15/16bpp support accellerated */ switch (pScrn->bitsPerPixel) { case 8: nAcl->BltCntlFlags = NEO_BC1_DEPTH8; nAcl->ColorShiftAmt = 8; break; case 15: case 16: nAcl->BltCntlFlags = NEO_BC1_DEPTH16; nAcl->ColorShiftAmt = 0; break; case 24: default: return FALSE; } /* Initialize for widths */ switch (pScrn->displayWidth) { case 640: nAcl->BltCntlFlags |= NEO_BC1_X_640; break; case 800: nAcl->BltCntlFlags |= NEO_BC1_X_800; break; case 1024: nAcl->BltCntlFlags |= NEO_BC1_X_1024; break; default: return FALSE; } return (xaaSetupWrapper(pScreen, infoPtr, pScrn->depth, &nPtr->accelSync)); }
/* * This checks for, and validates, the presence of the 460GX chipset, and sets * cbn_460gx to a positive value accordingly. This function returns TRUE if * the chipset scan is to be stopped, or FALSE if the scan is to move on to the * next chipset. */ Bool xf86PreScan460GX(void) { pciBusInfo_t *pBusInfo; PCITAG tag; CARD32 tmp; int i, devno; /* Bus zero should already be set up */ if (!(pBusInfo = pciBusInfo[0])) { cbn_460gx = -1; return FALSE; } /* First look for a 460GX's primary host bridge */ tag = PCI_MAKE_TAG(0, 0x10, 0); if (pciReadLong(tag, PCI_ID_REG) != DEVID(INTEL, 460GX_SAC)) { cbn_460gx = -1; return FALSE; } /* Get CBN (Chipset bus number) */ if (!(cbn_460gx = (unsigned int)pciReadByte(tag, CBN))) { /* Sanity check failed */ cbn_460gx = -1; return TRUE; } if (pciNumBuses <= cbn_460gx) pciNumBuses = cbn_460gx + 1; /* Set up bus CBN */ if (!pciBusInfo[cbn_460gx]) { pciBusInfo[cbn_460gx] = xnfalloc(sizeof(pciBusInfo_t)); *pciBusInfo[cbn_460gx] = *pBusInfo; } tag = PCI_MAKE_TAG(cbn_460gx, 0, 0); if (pciReadLong(tag, PCI_ID_REG) != DEVID(INTEL, 460GX_SAC)) { /* Sanity check failed */ cbn_460gx = -1; return TRUE; } /* * Find out which CBN devices the firmware thinks are present. Of these, * we are only interested in devices 0x10 through 0x17. */ cbdevs_460gx = pciReadLong(tag, DEVNPRES); for (i = 0, devno = 0x10; devno <= 0x17; i++, devno++) { tag = PCI_MAKE_TAG(cbn_460gx, devno, 0); if (pciReadLong(tag, PCI_ID_REG) != DEVID(INTEL, 460GX_SAC)) { /* Sanity check failed */ cbn_460gx = -1; return TRUE; } if (devno == 0x10) iord_460gx = pciReadWord(tag, IORD); busno_460gx[i] = (unsigned int)pciReadByte(tag, BUSNO); subno_460gx[i] = (unsigned int)pciReadByte(tag, SUBNO); pcis_460gx[i] = pciReadByte(tag, PCIS); ior_460gx[i] = pciReadByte(tag, IOR); has_err_460gx[i] = err_460gx[i] = 0; /* Insurance */ tag = PCI_MAKE_TAG(cbn_460gx, devno, 1); tmp = pciReadLong(tag, PCI_ID_REG); switch (tmp) { case DEVID(INTEL, 460GX_PXB): case DEVID(INTEL, 460GX_WXB): if (cbdevs_460gx & (1 << devno)) { /* Sanity check failed */ cbn_460gx = -1; return TRUE; } /* * XXX I don't have WXB docs, but PCI register dumps indicate that * the registers we are interested in are consistent with those of * the PXB. */ err_460gx[i] = pciReadByte(tag, ERRCMD); has_err_460gx[i] = 1; break; case DEVID(INTEL, 460GX_GXB_1): if (cbdevs_460gx & (1 << devno)) { /* Sanity check failed */ cbn_460gx = -1; return TRUE; } /* * XXX GXB isn't documented to have an ERRCMD register, nor any * other means of failing master aborts. For now, assume master * aborts are always allowed to complete normally. */ break; default: if (((CARD16)(tmp + 1U) <= (CARD16)1U) && (cbdevs_460gx & (1U << devno))) break; /* Sanity check failed */ cbn_460gx = -1; return TRUE; } } /* Allow master aborts to complete normally */ for (i = 0, devno = 0x10; devno <= 0x17; i++, devno++) { if (!(err_460gx[i] & 0x01)) continue; pciWriteByte(PCI_MAKE_TAG(cbn_460gx, devno, 1), ERRCMD, err_460gx[i] & ~0x01); } /* * The 460GX spec says that any access to busses higher than CBN will be * master-aborted. It seems possible however that this is not the case in * all 460GX implementations. For now, limit the bus scan to CBN, unless * we have already found a higher bus number. */ for (i = 0; subno_460gx[i] < cbn_460gx; ) { if (++i < 8) continue; pciMaxBusNum = cbn_460gx + 1; break; } return TRUE; }
/** * This will be called during exaDriverInit, giving us the chance to set options * and hook in our EnableDisableFBAccess. */ void exaDDXDriverInit(ScreenPtr pScreen) { ExaScreenPriv(pScreen); /* Do NOT use XF86SCRNINFO macro here!! */ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; ExaXorgScreenPrivPtr pScreenPriv; pScreenPriv = xcalloc (1, sizeof(ExaXorgScreenPrivRec)); if (pScreenPriv == NULL) return; pScreenPriv->options = xnfalloc (sizeof(EXAOptions)); memcpy(pScreenPriv->options, EXAOptions, sizeof(EXAOptions)); xf86ProcessOptions (pScrn->scrnIndex, pScrn->options, pScreenPriv->options); if (pExaScr->info->flags & EXA_OFFSCREEN_PIXMAPS) { if (!(pExaScr->info->flags & EXA_HANDLES_PIXMAPS) && pExaScr->info->offScreenBase < pExaScr->info->memorySize) { char *heuristicName; heuristicName = xf86GetOptValString (pScreenPriv->options, EXAOPT_MIGRATION_HEURISTIC); if (heuristicName != NULL) { if (strcmp(heuristicName, "greedy") == 0) pExaScr->migration = ExaMigrationGreedy; else if (strcmp(heuristicName, "always") == 0) pExaScr->migration = ExaMigrationAlways; else if (strcmp(heuristicName, "smart") == 0) pExaScr->migration = ExaMigrationSmart; else { xf86DrvMsg (pScreen->myNum, X_WARNING, "EXA: unknown migration heuristic %s\n", heuristicName); } } } pExaScr->optimize_migration = xf86ReturnOptValBool(pScreenPriv->options, EXAOPT_OPTIMIZE_MIGRATION, TRUE); } if (xf86ReturnOptValBool(pScreenPriv->options, EXAOPT_NO_COMPOSITE, FALSE)) { xf86DrvMsg(pScreen->myNum, X_CONFIG, "EXA: Disabling Composite operation " "(RENDER acceleration)\n"); pExaScr->info->CheckComposite = NULL; pExaScr->info->PrepareComposite = NULL; } if (xf86ReturnOptValBool(pScreenPriv->options, EXAOPT_NO_UTS, FALSE)) { xf86DrvMsg(pScreen->myNum, X_CONFIG, "EXA: Disabling UploadToScreen\n"); pExaScr->info->UploadToScreen = NULL; } if (xf86ReturnOptValBool(pScreenPriv->options, EXAOPT_NO_DFS, FALSE)) { xf86DrvMsg(pScreen->myNum, X_CONFIG, "EXA: Disabling DownloadFromScreen\n"); pExaScr->info->DownloadFromScreen = NULL; } dixSetPrivate(&pScreen->devPrivates, exaXorgScreenPrivateKey, pScreenPriv); pScreenPriv->SavedEnableDisableFBAccess = pScrn->EnableDisableFBAccess; pScrn->EnableDisableFBAccess = exaXorgEnableDisableFBAccess; pScreenPriv->SavedCloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = exaXorgCloseScreen; }
/* * This is called by the driver, either through xf86Match???Instances() or * directly. We allocate a GDevRec and fill it in as much as we can, letting * the caller fill in the rest and/or change it as it sees fit. */ GDevPtr xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int chipset) { int ret, i, j; if (!xf86DoConfigure || !xf86DoConfigurePass1) return NULL; /* Check for duplicates */ for (i = 0; i < nDevToConfig; i++) { switch (bus) { #ifdef XSERVER_LIBPCIACCESS case BUS_PCI: ret = xf86PciConfigure(busData, DevToConfig[i].pVideo); break; #endif #if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) case BUS_SBUS: ret = xf86SbusConfigure(busData, DevToConfig[i].sVideo); break; #endif default: return NULL; } if (ret == 0) goto out; } /* Allocate new structure occurrence */ i = nDevToConfig++; DevToConfig = xnfrealloc(DevToConfig, nDevToConfig * sizeof(DevToConfigRec)); memset(DevToConfig + i, 0, sizeof(DevToConfigRec)); DevToConfig[i].GDev.chipID = DevToConfig[i].GDev.chipRev = DevToConfig[i].GDev.irq = -1; DevToConfig[i].iDriver = CurrentDriver; /* Fill in what we know, converting the driver name to lower case */ DevToConfig[i].GDev.driver = xnfalloc(strlen(driver) + 1); for (j = 0; (DevToConfig[i].GDev.driver[j] = tolower(driver[j])); j++); switch (bus) { #ifdef XSERVER_LIBPCIACCESS case BUS_PCI: xf86PciConfigureNewDev(busData, DevToConfig[i].pVideo, &DevToConfig[i].GDev, &chipset); break; #endif #if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) case BUS_SBUS: xf86SbusConfigureNewDev(busData, DevToConfig[i].sVideo, &DevToConfig[i].GDev); break; #endif default: break; } /* Get driver's available options */ if (xf86DriverList[CurrentDriver]->AvailableOptions) DevToConfig[i].GDev.options = (OptionInfoPtr) (*xf86DriverList[CurrentDriver]->AvailableOptions)(chipset, bus); return &DevToConfig[i].GDev; out: return NULL; }