xorg初始化过程分析,device节的自动配置

下面的紫色的是

#ifdef XSERVER_PLATFORM_BUS
    i = xf86PlatformMatchDriver(matches, nmatches);
#endif

产生的。

蓝色的是

#ifdef XSERVER_LIBPCIACCESS
    if (i < (nmatches - 1))
        i = xf86PciMatchDriver(matches, nmatches);
#endif

产生的

红色的和下面的代码有关:

#if defined(__linux__)
    matches[i++] = xnfstrdup("modesetting");
#endif

#if !defined(sun)
    /* Fallback to platform default frame buffer driver */
    if (i < (nmatches - 1)) {
#if !defined(__linux__) && defined(__sparc__)
        matches[i++] = xnfstrdup("wsfb");
#else
        matches[i++] = xnfstrdup("fbdev");
#endif
    }
#endif                          /* !sun */

    /* Fallback to platform default hardware */
    if (i < (nmatches - 1)) {
#if defined(__i386__) || defined(__amd64__) || defined(__hurd__)
        matches[i++] = xnfstrdup("vesa");
#elif defined(__sparc__) && !defined(sun)
        matches[i++] = xnfstrdup("sunffb");
#endif
    }


[    32.426] (==) Matched fglrx as autoconfigured driver 0

[    32.426] (==) Matched ati as autoconfigured driver 1
[    32.426] (==) Matched fglrx as autoconfigured driver 2
[    32.426] (==) Matched ati as autoconfigured driver 3

[    32.426] (==) Matched modesetting as autoconfigured driver 4
[    32.426] (==) Matched fbdev as autoconfigured driver 5

[    32.426] (==) Matched vesa as autoconfigured driver 6

GDevPtr

autoConfigDevice(GDevPtr preconf_device)
{
    GDevPtr ptr = NULL;
    char *matches[20];          /* If we have more than 20 drivers we're in trouble */
    int num_matches = 0, num_screens = 0, i;
    screenLayoutPtr slp;

    if (!xf86configptr) {
        return NULL;
    }

    /* If there's a configured section with no driver chosen, use it */
    if (preconf_device) {
        ptr = preconf_device;
    }
    else {
        ptr = calloc(1, sizeof(GDevRec));
        if (!ptr) {
            return NULL;
        }
        ptr->chipID = -1;
        ptr->chipRev = -1;
        ptr->irq = -1;

        ptr->active = TRUE;
        ptr->claimed = FALSE;
        ptr->identifier = "Autoconfigured Video Device";
        ptr->driver = NULL;
    }
    if (!ptr->driver) {
        /* get all possible video drivers and count them */
        listPossibleVideoDrivers(matches, 20);
        for (; matches[num_matches]; num_matches++) {
            xf86Msg(X_DEFAULT, "Matched %s as autoconfigured driver %d\n",
                    matches[num_matches], num_matches);

        }


......




static void
listPossibleVideoDrivers(char *matches[], int nmatches)
{
    int i;
/*matches[i]先赋值为NULL,到现在为止matches[i]还是NULL。*/
    for (i = 0; i < nmatches; i++) {
        matches[i] = NULL;
    }
    i = 0;

#ifdef XSERVER_PLATFORM_BUS
    i = xf86PlatformMatchDriver(matches, nmatches);
#endif
#ifdef sun
    /* Check for driver type based on /dev/fb type and if valid, use
       it instead of PCI bus probe results */
    if (xf86Info.consoleFd >= 0 && (i < (nmatches - 1))) {
        struct vis_identifier visid;
        const char *cp;
        extern char xf86SolarisFbDev[PATH_MAX];
        int iret;

        SYSCALL(iret = ioctl(xf86Info.consoleFd, VIS_GETIDENTIFIER, &visid));
        if (iret < 0) {
            int fbfd;

            fbfd = open(xf86SolarisFbDev, O_RDONLY);
            if (fbfd >= 0) {
                SYSCALL(iret = ioctl(fbfd, VIS_GETIDENTIFIER, &visid));
                close(fbfd);
            }
        }

        if (iret < 0) {
            xf86Msg(X_WARNING,
                    "could not get frame buffer identifier from %s\n",
                    xf86SolarisFbDev);
        }
        else {
            xf86Msg(X_PROBED, "console driver: %s\n", visid.name);

            /* Special case from before the general case was set */
            if (strcmp(visid.name, "NVDAnvda") == 0) {
                matches[i++] = xnfstrdup("nvidia");
            }

            /* General case - split into vendor name (initial all-caps
               prefix) & driver name (rest of the string). */
            if (strcmp(visid.name, "SUNWtext") != 0) {
                for (cp = visid.name; (*cp != '\0') && isupper(*cp); cp++) {
                    /* find end of all uppercase vendor section */
                }
                if ((cp != visid.name) && (*cp != '\0')) {
                    char *driverName = xnfstrdup(cp);
                    char *vendorName = xnfstrdup(visid.name);

                    vendorName[cp - visid.name] = '\0';

                    matches[i++] = vendorName;
                    matches[i++] = driverName;
                }
            }
        }
    }
#endif
#ifdef __sparc__
    if (i < (nmatches - 1))
    {
        char *sbusDriver = sparcDriverName();

        if (sbusDriver)
            matches[i++] = xnfstrdup(sbusDriver);
    }
#endif
#ifdef XSERVER_LIBPCIACCESS
    if (i < (nmatches - 1))
        i = xf86PciMatchDriver(matches, nmatches);
#endif

#if defined(__linux__)
    matches[i++] = xnfstrdup("modesetting");
#endif

#if !defined(sun)
    /* Fallback to platform default frame buffer driver */
    if (i < (nmatches - 1)) {
#if !defined(__linux__) && defined(__sparc__)
        matches[i++] = xnfstrdup("wsfb");
#else
        matches[i++] = xnfstrdup("fbdev");
#endif
    }
#endif                          /* !sun */

    /* Fallback to platform default hardware */
    if (i < (nmatches - 1)) {
#if defined(__i386__) || defined(__amd64__) || defined(__hurd__)
        matches[i++] = xnfstrdup("vesa");
#elif defined(__sparc__) && !defined(sun)
        matches[i++] = xnfstrdup("sunffb");
#endif
    }
}



InitOutput()函数里面有调用到autoConfigDevice()函数!

/*
 * InitOutput --
 *    Initialize screenInfo for all actually accessible framebuffers.
 *      That includes vt-manager setup, querying all possible devices and
 *      collecting the pixmap formats.
 */
void
InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
{




......

       if ((!configured_device) || (!configured_device->driver)) {
            if (!autoConfigDevice(configured_device)) {
                xf86Msg(X_ERROR, "Automatic driver configuration failed\n");
                return;
            }
        }



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值