summaryrefslogtreecommitdiff
path: root/src/atiprobe.c
blob: 658fbd0d965d00fa073119c84b40d3f650614449 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.c,v 1.62tsi Exp $ */
/*
 * Copyright 1997 through 2004 by Marc Aurele La France (TSI @ UQV), tsi@xfree86.org
 *
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that copyright
 * notice and this permission notice appear in supporting documentation, and
 * that the name of Marc Aurele La France not be used in advertising or
 * publicity pertaining to distribution of the software without specific,
 * written prior permission.  Marc Aurele La France makes no representations
 * about the suitability of this software for any purpose.  It is provided
 * "as-is" without express or implied warranty.
 *
 * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.  IN NO
 * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 * PERFORMANCE OF THIS SOFTWARE.
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "ati.h"
#include "atiadapter.h"
#include "atiadjust.h"
#include "atibus.h"
#include "atichip.h"
#include "aticonsole.h"
#include "atiident.h"
#include "atimach64io.h"
#include "atipreinit.h"
#include "atiprobe.h"
#include "atiscreen.h"
#include "ativalid.h"
#include "ativersion.h"
#include "atividmem.h"

/*
 * NOTES:
 *
 * - The driver private structures (ATIRec's) are allocated here, rather than
 *   in ATIPreInit().  This allows ATIProbe() to pass information to later
 *   stages.
 * - A minor point, perhaps, is that XF86Config Chipset names denote functional
 *   levels, rather than specific graphics controller chips.
 * - ATIProbe() does not call xf86MatchPciInstances(), because ATIProbe()
 *   should be able to match a mix of PCI and non-PCI devices to XF86Config
 *   Device sections.  Also, PCI configuration space for Mach32's is to be
 *   largely ignored.
 */

/*
 * An internal structure definition to facilitate the matching of detected
 * adapters to XF86Config Device sections.
 */
typedef struct _ATIGDev
{
    GDevPtr pGDev;
    int     iATIPtr;
    CARD8   Chipset;
} ATIGDev, *ATIGDevPtr;

/*
 * ATIMach64Detect --
 *
 * This function determines if a Mach64 is detectable at a particular base
 * address.
 */
static Bool
ATIMach64Detect(ATIPtr pATI, const CARD16 ChipType, const ATIChipType Chip)
{
    CARD32 IOValue, bus_cntl, gen_test_cntl;

    (void)ATIMapApertures(-1, pATI);    /* Ignore errors */

#ifdef AVOID_CPIO

    if (!pATI->pBlock[0])
    {
        ATIUnmapApertures(-1, pATI);
        return FALSE;
    }

#endif /* AVOID_CPIO */

    /* Make sure any Mach64 is not in some weird state */
    bus_cntl = inr(BUS_CNTL);
    if (Chip < ATI_CHIP_264VTB)
        outr(BUS_CNTL,
             (bus_cntl & ~(BUS_HOST_ERR_INT_EN | BUS_FIFO_ERR_INT_EN)) |
             (BUS_HOST_ERR_INT | BUS_FIFO_ERR_INT));
    else if (Chip < ATI_CHIP_264VT4)
        outr(BUS_CNTL, (bus_cntl & ~BUS_HOST_ERR_INT_EN) | BUS_HOST_ERR_INT);

    gen_test_cntl = inr(GEN_TEST_CNTL);
    IOValue = gen_test_cntl &
        (GEN_OVR_OUTPUT_EN | GEN_OVR_POLARITY | GEN_CUR_EN | GEN_BLOCK_WR_EN);
    outr(GEN_TEST_CNTL, IOValue | GEN_GUI_EN);
    outr(GEN_TEST_CNTL, IOValue);
    outr(GEN_TEST_CNTL, IOValue | GEN_GUI_EN);

    /* See if a Mach64 answers */
    IOValue = inr(SCRATCH_REG0);

    /* Test odd bits */
    outr(SCRATCH_REG0, 0x55555555U);
    if (inr(SCRATCH_REG0) == 0x55555555U) {
        /* Test even bits */
        outr(SCRATCH_REG0, 0xAAAAAAAAU);
        if (inr(SCRATCH_REG0) == 0xAAAAAAAAU) {
            /*
             * *Something* has a R/W 32-bit register at this address.  Try to
             * make sure it's a Mach64.  The following assumes that ATI will
             * not be producing any more adapters that do not register
             * themselves in PCI configuration space.
             */
            ATIMach64ChipID(pATI, ChipType);
            if ((pATI->Chip != ATI_CHIP_Mach64) || (pATI->CPIODecoding == BLOCK_IO))
                pATI->Adapter = ATI_ADAPTER_MACH64;
        }
    }

    /* Restore clobbered register value */
    outr(SCRATCH_REG0, IOValue);

    /* If no Mach64 was detected, return now */
    if (pATI->Adapter != ATI_ADAPTER_MACH64) {
        outr(GEN_TEST_CNTL, gen_test_cntl);
        outr(BUS_CNTL, bus_cntl);
        ATIUnmapApertures(-1, pATI);
        return FALSE;
    }

    ATIUnmapApertures(-1, pATI);
    pATI->PCIInfo = NULL;
    return TRUE;
}

#ifdef AVOID_CPIO

/*
 * ATIMach64Probe --
 *
 * This function looks for a Mach64 at a particular MMIO address and returns an
 * ATIRec if one is found.
 */
static ATIPtr
ATIMach64Probe(pciVideoPtr pVideo, const IOADDRESS IOBase,
               const CARD8 IODecoding, const ATIChipType Chip)
{
    ATIPtr pATI = (ATIPtr)xnfcalloc(1, SizeOf(ATIRec));

    pATI->CPIOBase = IOBase;
    pATI->CPIODecoding = IODecoding;
    pATI->PCIInfo = pVideo;

    /*
     * Probe through auxiliary MMIO aperture if one exists.  Because such
     * apertures can be enabled/disabled only through PCI, this probes no
     * further.
     */
    if ((pVideo->size[2] >= 12) &&
        (pATI->Block0Base = pVideo->memBase[2]) &&
        (pATI->Block0Base < (CARD32)(-1 << pVideo->size[2]))) {
        pATI->Block0Base += 0x00000400U;
        goto LastProbe;
    }

    /*
     * Probe through the primary MMIO aperture that exists at the tail end
     * of the linear aperture.  Test for both 8MB and 4MB linear apertures.
     */
    if ((pVideo->size[0] >= 22) && (pATI->Block0Base = pVideo->memBase[0])) {
        pATI->Block0Base += 0x007FFC00U;
        if ((pVideo->size[0] >= 23) && ATIMach64Detect(pATI, pVideo->chipType, Chip))
            return pATI;

        pATI->Block0Base -= 0x00400000U;
        if (ATIMach64Detect(pATI, pVideo->chipType, Chip))
            return pATI;
    }

    /*
     * A last, perhaps desparate, probe attempt.  Note that if this succeeds,
     * there's a VGA in the system and it's likely the PIO version of the
     * driver should be used instead (barring OS issues).
     */
    pATI->Block0Base = 0x000BFC00U;

LastProbe:
    if (ATIMach64Detect(pATI, pVideo->chipType, Chip))
        return pATI;

    xfree(pATI);
    return NULL;
}

#else /* AVOID_CPIO */

/*
 * ATIMach64Probe --
 *
 * This function looks for a Mach64 at a particular PIO address and returns an
 * ATIRec if one is found.
 */
static ATIPtr
ATIMach64Probe(pciVideoPtr pVideo, const IOADDRESS IOBase,
               const CARD8 IODecoding, const ATIChipType Chip)
{
    ATIPtr pATI;

    if (!IOBase)
        return NULL;

    if ((IODecoding == BLOCK_IO) &&
        ((pVideo->size[1] < 8) ||
         (IOBase >= (CARD32)(-1 << pVideo->size[1]))))
        return NULL;
    
    pATI = (ATIPtr)xnfcalloc(1, SizeOf(ATIRec));
    pATI->CPIOBase = IOBase;
    pATI->CPIODecoding = IODecoding;
    pATI->PCIInfo = pVideo;

    if (!ATIMach64Detect(pATI, pVideo->chipType, Chip)) {
        xfree(pATI);
        return NULL;
    }

    /*
     * Determine VGA capability.  VGA can always be enabled on integrated
     * controllers.  For the GX/CX, it's a board strap.
     */
    if (pATI->Chip < ATI_CHIP_264CT) {
        CARD32 IOValue;

        IOValue = inr(CONFIG_STATUS64_0);
        pATI->BusType = GetBits(IOValue, CFG_BUS_TYPE);
        IOValue &= (CFG_VGA_EN | CFG_CHIP_EN);

        if (pATI->Chip == ATI_CHIP_88800CX)
            IOValue |= CFG_VGA_EN;

        if (IOValue == (CFG_VGA_EN | CFG_CHIP_EN)) {
            pATI->VGAAdapter = ATI_ADAPTER_MACH64;
            pATI->CPIO_VGAWonder = 0x01CEU;
            pATI->VGAOffset = 0x80U;
        } else
            pATI->VGAAdapter = ATI_ADAPTER_NONE;
    } else
        pATI->VGAAdapter = ATI_ADAPTER_MACH64;
    
    /* Ensure that the VGA isn't in sleep mode. */
    if (pATI->VGAAdapter != ATI_ADAPTER_NONE) {
        outb(GENENA, 0x16U);
        outb(GENVS, 0x01U);
        outb(GENENA, 0x0EU);
    }

    return pATI;
}

#endif /* AVOID_CPIO */

/*
 * ATIProbe --
 *
 * This function is called once, at the start of the first server generation to
 * do a minimal probe for supported hardware.
 */
Bool
ATIProbe(DriverPtr pDriver, int flags)
{
    ATIPtr                 pATI, *ATIPtrs = NULL;
    GDevPtr                pGDev;
    pciVideoPtr            pVideo, *xf86PciVideoInfo = xf86GetPciVideoInfo();
    pciConfigPtr           pPCI;
    ATIGDev                *ATIGDevs = NULL, *pATIGDev;
    ScrnInfoPtr            pScreenInfo;
    CARD32                 PciReg;
    Bool                   ProbeSuccess = FALSE;
    int                    i, j, k;
    int                    nATIGDev = -1, nATIPtr = 0;
    int                    Chipset;
    ATIChipType            Chip;

#ifndef AVOID_CPIO
    static const IOADDRESS Mach64SparseIOBases[] = {0x02ECU, 0x01CCU, 0x01C8U};
#endif /* AVOID_CPIO */

    /* We only do PCI from now on. */
    if (!xf86PciVideoInfo)
        return FALSE;

#   define                 AddAdapter(_p)                                  \
    do                                                                     \
    {                                                                      \
        nATIPtr++;                                                         \
        ATIPtrs = (ATIPtr *)xnfrealloc(ATIPtrs, SizeOf(ATIPtr) * nATIPtr); \
        ATIPtrs[nATIPtr - 1] = (_p);                                       \
        (_p)->iEntity = -2;                                                \
    } while (0)

    for (i = 0; xf86PciVideoInfo[i]; i++) {
        pVideo = xf86PciVideoInfo[i];
        
        if (!xf86CheckPciSlot(pVideo->bus, pVideo->device, pVideo->func))
            continue;
        
        if (pVideo->vendor != PCI_VENDOR_ATI)
            continue;

        /* Is this a mach64? */
        Chip = ATIChipID(pVideo->chipType, pVideo->chipRev);
        if ((Chip < ATI_CHIP_88800GXC) || (Chip > ATI_CHIP_Mach64))
            continue;

        /* Check if this one has already been detected */
        for (j = 0;  j < nATIPtr;  j++) {
            pATI = ATIPtrs[j];

            /* Block IO? */
            if ((pVideo->size[1]) && (pATI->CPIOBase == pVideo->ioBase[1])) {
                pATI->PCIInfo = pVideo;
                goto SkipThisSlot;
            }
            
            if (pATI->PCIInfo == pVideo)
                goto SkipThisSlot;
        }

        xf86SetPciVideo(pVideo, MEM_IO);
                
        /* block IO? */
        if (pVideo->size[1]) {
            pATI = ATIMach64Probe(pVideo, pVideo->ioBase[1], BLOCK_IO, Chip);
            if (pATI)
                xf86MsgVerb(X_INFO, 3, ATI_NAME ":  Mach64 detected at %d:%d:%d.\n",
                            pVideo->bus, pVideo->device, pVideo->func);
        } else {

#ifndef AVOID_CPIO
            pPCI = pVideo->thisCard;
            if (pPCI == NULL)
                continue;

            PciReg = pciReadLong(pPCI->tag, PCI_REG_USERCONFIG);
            j = PciReg & 0x03U;
            if (j == 0x03U) {
                xf86Msg(X_WARNING,
                        ATI_NAME ": Mach64 at %d:%d:%d cannot be"
                        " enabled\n because it has neither a block, nor a"
                        " sparse, I/O base.\n",
                        pVideo->bus, pVideo->device, pVideo->func);
                continue;
            }

            /* Possibly fix block I/O indicator */
            if (PciReg & 0x00000004U)
                pciWriteLong(pPCI->tag, PCI_REG_USERCONFIG, PciReg & ~0x00000004U);

            pATI = ATIMach64Probe(pVideo, Mach64SparseIOBases[j], SPARSE_IO, Chip);
            if (pATI)
                xf86MsgVerb(X_INFO, 3, ATI_NAME ": Mach64 detected at %d:%d:%d"
                            " with sparse PIO base 0x%04lX detected.\n", 
                            pVideo->bus, pVideo->device, pVideo->func,
                            Mach64SparseIOBases[j]);
#else
            /* The adapter's CPIO base is of little concern here */
            pATI = ATIMach64Probe(pVideo, 0, SPARSE_IO, Chip);
            if (pATI)
                xf86MsgVerb(X_INFO, 3, ATI_NAME ": Mach64 detected at %d:%d:%d"
                            " with Block 0 base 0x%08lX detected.\n",
                            pVideo->bus, pVideo->device, pVideo->func,
                            pATI->Block0Base);
#endif /* AVOID_CPIO */
        }

        if (!pATI) {
            xf86Msg(X_WARNING, ATI_NAME ": Mach64 at %d:%d:%d could not be"
                    " detected!\n", pVideo->bus, pVideo->device, pVideo->func);
        } else {
            AddAdapter(pATI);
            
            pATI->SharedAccelerator = TRUE;
            pATI->PCIInfo = pVideo;
        }
            
        xf86SetPciVideo(NULL, NONE);

    SkipThisSlot:; 
    }

    /*
     * Re-order list of detected devices so that the primary device is before
     * any other PCI device.
     */
    for (i = 0;  i < nATIPtr;  i++) {
        if (!ATIPtrs[i]->PCIInfo)
            continue;

        for (j = i;  j < nATIPtr;  j++) {
            pATI = ATIPtrs[j];
            if (!xf86IsPrimaryPci(pATI->PCIInfo))
                continue;

            for (;  j > i;  j--)
                ATIPtrs[j] = ATIPtrs[j - 1];
            ATIPtrs[j] = pATI;
            break;
        }
        
        break;
    }

    if (flags & PROBE_DETECT)
    {
        /*
         * No XF86Config information available, so use the default Chipset of
         * "ati", and as many device sections as there are adapters.
         */
        for (i = 0;  i < nATIPtr;  i++)
        {
            pATI = ATIPtrs[i];

            ProbeSuccess = TRUE;
            pGDev = xf86AddDeviceToConfigure(ATI_DRIVER_NAME,
                                             pATI->PCIInfo, ATI_CHIPSET_ATI);
            if (pGDev) {
                /* Fill in additional information */
                pGDev->vendor = ATI_NAME;
                pGDev->chipset = (char *)ATIChipsetNames[ATI_CHIPSET_ATI];
                if (!pATI->PCIInfo)
                    pGDev->busID = NULL;
            }

            xfree(pATI);
        }
    }
    else
    {
        GDevPtr  *GDevs;
        int   nGDev;

        /*
         * Get a list of XF86Config device sections whose "Driver" is either
         * not specified, or specified as this driver.  From this list,
         * eliminate those device sections that specify a "Chipset" or a
         * "ChipID" not recognised by the driver.  Those device sections that
         * specify a "ChipRev" without a "ChipID" are also weeded out.
         */
        nATIGDev = 0;
        if ((nGDev = xf86MatchDevice(ATI_NAME, &GDevs)) > 0)
        {
            ATIGDevs = (ATIGDevPtr)xnfcalloc(nGDev, SizeOf(ATIGDev));

            for (i = 0, pATIGDev = ATIGDevs;  i < nGDev;  i++)
            {
                pGDev = GDevs[i];
                Chipset = ATIIdentProbe(pGDev->chipset);
                if (Chipset == -1)
                    continue;

                if ((pGDev->chipID > (int)((CARD16)(-1))) ||
                    (pGDev->chipRev > (int)((CARD8)(-1))))
                    continue;

                if (pGDev->chipID >= 0)
                {
                    if (ATIChipID(pGDev->chipID, 0) == ATI_CHIP_Mach64)
                        continue;
                }
                else
                {
                    if (pGDev->chipRev >= 0)
                        continue;
                }

                pATIGDev->pGDev = pGDev;
                pATIGDev->Chipset = Chipset;
                nATIGDev++;
                pATIGDev++;

                xf86MsgVerb(X_INFO, 3,
                    ATI_NAME ":  Candidate \"Device\" section \"%s\".\n",
                    pGDev->identifier);
            }

            xfree(GDevs);

            if (!nATIGDev)
            {
                xfree(ATIGDevs);
                ATIGDevs = NULL;
            }
        }


        /*
         * Assign detected devices to XF86Config Device sections.  This is done
         * by comparing certain Device section specifications against the
         * corresponding adapter information.  Begin with those specifications
         * that are independent of the adapter's bus location.
         */
        for (i = 0, pATIGDev = ATIGDevs;  i < nATIGDev;  i++, pATIGDev++)
        {
            pGDev = pATIGDev->pGDev;

            for (j = 0;  j < nATIPtr;  j++) {
                pATI = ATIPtrs[j];
                pVideo = pATI->PCIInfo;

                if (!pVideo)
                    continue;

                /* Check chipset name if exists */
                if (pGDev->chipset && strncasecmp(pGDev->chipset, "mach64", 7))
                    continue;

                /* Is this the right busID? */
                if (pGDev->busID && pGDev->busID[0])
                    if (!xf86ComparePciBusString(pGDev->busID, pVideo->bus, 
                                                 pVideo->device, pVideo->func))
                        continue;

                /*
                 * Ensure no two adapters are assigned to the same XF86Config
                 * Device section.
                 */
                if (pATIGDev->iATIPtr)
                {
                    if (pATIGDev->iATIPtr < 0)
                        break;

                    xf86Msg(X_ERROR,
                        ATI_NAME ":  XF86Config Device section \"%s\" may not"
                        " be assigned to more than one adapter.\n",
                        pGDev->identifier);
                    pATIGDev->iATIPtr = -1;
                    break;
                }

                /* Assign adapter */
                pATIGDev->iATIPtr = j + 1;

                /*
                 * For compatibility with previous releases, assign the first
                 * applicable adapter if there is only one Device section.
                 */
                if (nATIGDev == 1)
                    break;
            }
        }

        /*
         * Ensure no two XF86Config Device sections are assigned to the same
         * adapter.  Then, generate screens for any that are left.
         */
        for (i = 0, pATIGDev = ATIGDevs;  i < nATIGDev;  i++, pATIGDev++)
        {
            pGDev = pATIGDev->pGDev;

            j = pATIGDev->iATIPtr;
            if (j <= 0)
                continue;

            for (k = i;  ++k < nATIGDev;  ) {
                if (j == ATIGDevs[k].iATIPtr) {
                    xf86Msg(X_ERROR, ATI_NAME ":  XF86Config Device sections "
                            "\"%s\" and \"%s\" may not be assigned to the same "
                            "adapter.\n", pGDev->identifier,
                            ATIGDevs[k].pGDev->identifier);
                    pATIGDev->iATIPtr = ATIGDevs[k].iATIPtr = -1;
                }
            }

            j = ATIGDevs[i].iATIPtr;
            if (j <= 0)
                continue;

            pATI = ATIPtrs[j - 1];

            if (!pATI->PCIInfo)
                continue;
            pVideo = pATI->PCIInfo;
            
            xf86MsgVerb(X_INFO, 3, ATI_NAME ": Mach64 at %d:%d:%d assigned to "
                        "%sactive \"Device\" section \"%s\".\n", pVideo->bus,
                        pVideo->device, pVideo->func,
                        pGDev->active ? "" : "in", pGDev->identifier);

            /*
             * Attach adapter to XF86Config Device section and register its
             * resources.
             */
            pATI->iEntity = xf86ClaimPciSlot(pVideo->bus, pVideo->device,
                                             pVideo->func, pDriver,
                                             pATIGDev->Chipset, pGDev,
                                             pGDev->active);
            
            if (pATI->iEntity < 0) {
                xf86Msg(X_ERROR,
                        ATI_NAME ":  Could not claim bus slot for %d:%d:%d.\n",
                        pVideo->bus, pVideo->device, pVideo->func);
                continue;
            } else 
                ATIClaimResources(pATI, pGDev->active);

            if (!pGDev->active)
                continue;

            /* Allocate screen */
            pScreenInfo = xf86AllocateScreen(pDriver, 0);

            /* Attach device to screen */
            xf86AddEntityToScreen(pScreenInfo, pATI->iEntity);

            ATIPtrs[j - 1] = NULL;

            /* Fill in probe data */
            pScreenInfo->driverVersion = ATI_VERSION_CURRENT;
            pScreenInfo->driverName    = ATI_DRIVER_NAME;
            pScreenInfo->name          = ATI_NAME;
            pScreenInfo->Probe         = ATIProbe;
            pScreenInfo->PreInit       = ATIPreInit;
            pScreenInfo->ScreenInit    = ATIScreenInit;
            pScreenInfo->SwitchMode    = ATISwitchMode;
            pScreenInfo->AdjustFrame   = ATIAdjustFrame;
            pScreenInfo->EnterVT       = ATIEnterVT;
            pScreenInfo->LeaveVT       = ATILeaveVT;
            pScreenInfo->FreeScreen    = ATIFreeScreen;
            pScreenInfo->ValidMode     = ATIValidMode;

            pScreenInfo->driverPrivate = pATI;

            pATI->Chipset = pATIGDev->Chipset;

            ProbeSuccess = TRUE;
        }

        /* ignore unassigned adapters */

        xfree(ATIGDevs);
    }

    xfree(ATIPtrs);

    return ProbeSuccess;
}