本文主要是介绍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节的自动配置的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!