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

2024-01-02 22:48

本文主要是介绍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;
            }
        }



这篇关于xorg初始化过程分析,device节的自动配置的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/563865

相关文章

CentOS7更改默认SSH端口与配置指南

《CentOS7更改默认SSH端口与配置指南》SSH是Linux服务器远程管理的核心工具,其默认监听端口为22,由于端口22众所周知,这也使得服务器容易受到自动化扫描和暴力破解攻击,本文将系统性地介绍... 目录引言为什么要更改 SSH 默认端口?步骤详解:如何更改 Centos 7 的 SSH 默认端口1

Maven的使用和配置国内源的保姆级教程

《Maven的使用和配置国内源的保姆级教程》Maven是⼀个项目管理工具,基于POM(ProjectObjectModel,项目对象模型)的概念,Maven可以通过一小段描述信息来管理项目的构建,报告... 目录1. 什么是Maven?2.创建⼀个Maven项目3.Maven 核心功能4.使用Maven H

SpringBoot多数据源配置完整指南

《SpringBoot多数据源配置完整指南》在复杂的企业应用中,经常需要连接多个数据库,SpringBoot提供了灵活的多数据源配置方式,以下是详细的实现方案,需要的朋友可以参考下... 目录一、基础多数据源配置1. 添加依赖2. 配置多个数据源3. 配置数据源Bean二、JPA多数据源配置1. 配置主数据

Java程序进程起来了但是不打印日志的原因分析

《Java程序进程起来了但是不打印日志的原因分析》:本文主要介绍Java程序进程起来了但是不打印日志的原因分析,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录Java程序进程起来了但是不打印日志的原因1、日志配置问题2、日志文件权限问题3、日志文件路径问题4、程序

Spring 基于XML配置 bean管理 Bean-IOC的方法

《Spring基于XML配置bean管理Bean-IOC的方法》:本文主要介绍Spring基于XML配置bean管理Bean-IOC的方法,本文给大家介绍的非常详细,对大家的学习或工作具有一... 目录一. spring学习的核心内容二. 基于 XML 配置 bean1. 通过类型来获取 bean2. 通过

Java数组初始化的五种方式

《Java数组初始化的五种方式》数组是Java中最基础且常用的数据结构之一,其初始化方式多样且各具特点,本文详细讲解Java数组初始化的五种方式,分析其适用场景、优劣势对比及注意事项,帮助避免常见陷阱... 目录1. 静态初始化:简洁但固定代码示例核心特点适用场景注意事项2. 动态初始化:灵活但需手动管理代

如何使用Nginx配置将80端口重定向到443端口

《如何使用Nginx配置将80端口重定向到443端口》这篇文章主要为大家详细介绍了如何将Nginx配置为将HTTP(80端口)请求重定向到HTTPS(443端口),文中的示例代码讲解详细,有需要的小伙... 目录1. 创建或编辑Nginx配置文件2. 配置HTTP重定向到HTTPS3. 配置HTTPS服务器

SpringBoot中配置Redis连接池的完整指南

《SpringBoot中配置Redis连接池的完整指南》这篇文章主要为大家详细介绍了SpringBoot中配置Redis连接池的完整指南,文中的示例代码讲解详细,具有一定的借鉴价值,感兴趣的小伙伴可以... 目录一、添加依赖二、配置 Redis 连接池三、测试 Redis 操作四、完整示例代码(一)pom.

Java字符串操作技巧之语法、示例与应用场景分析

《Java字符串操作技巧之语法、示例与应用场景分析》在Java算法题和日常开发中,字符串处理是必备的核心技能,本文全面梳理Java中字符串的常用操作语法,结合代码示例、应用场景和避坑指南,可快速掌握字... 目录引言1. 基础操作1.1 创建字符串1.2 获取长度1.3 访问字符2. 字符串处理2.1 子字

Linux内核参数配置与验证详细指南

《Linux内核参数配置与验证详细指南》在Linux系统运维和性能优化中,内核参数(sysctl)的配置至关重要,本文主要来聊聊如何配置与验证这些Linux内核参数,希望对大家有一定的帮助... 目录1. 引言2. 内核参数的作用3. 如何设置内核参数3.1 临时设置(重启失效)3.2 永久设置(重启仍生效