/* * Initialize and enable the mouse wheel, if present. * * Returns 1 if mouse wheel was successfully enabled. * Returns 0 if an error occurred or if there is no mouse wheel. */ static int vuidMouseWheelInit(InputInfoPtr pInfo) { #ifdef HAVE_VUID_WHEEL wheel_state wstate; int nwheel = -1; int i; wstate.vers = VUID_WHEEL_STATE_VERS; wstate.id = 0; wstate.stateflags = (uint32_t) -1; SYSCALL(i = ioctl(pInfo->fd, VUIDGWHEELCOUNT, &nwheel)); if (i != 0) return (0); SYSCALL(i = ioctl(pInfo->fd, VUIDGWHEELSTATE, &wstate)); if (i != 0) { xf86Msg(X_WARNING, "%s: couldn't get wheel state\n", pInfo->name); return (0); } wstate.stateflags |= VUID_WHEEL_STATE_ENABLED; SYSCALL(i = ioctl(pInfo->fd, VUIDSWHEELSTATE, &wstate)); if (i != 0) { xf86Msg(X_WARNING, "%s: couldn't enable wheel\n", pInfo->name); return (0); } return (1); #else return (0); #endif }
void xf86OSInitVidMem(VidMemInfoPtr pVidMem) { pVidMem->linearSupported = TRUE; #ifdef __alpha__ if (axpSystem == -1) { axpSystem = lnxGetAXP(); if ((needSparse = (_bus_base_sparse() > 0))) { hae_thresh = xf86AXPParams[axpSystem].hae_thresh; hae_mask = xf86AXPParams[axpSystem].hae_mask; } bus_base = _bus_base(); } if (needSparse) { xf86Msg(X_INFO,"Machine needs sparse mapping\n"); pVidMem->mapMem = mapVidMemSparse; pVidMem->unmapMem = unmapVidMemSparse; } else { xf86Msg(X_INFO,"Machine type has 8/16 bit access\n"); pVidMem->mapMem = mapVidMem; pVidMem->unmapMem = unmapVidMem; } #else pVidMem->mapMem = mapVidMem; pVidMem->unmapMem = unmapVidMem; #endif /* __alpha__ */ #ifdef HAS_MTRR_SUPPORT pVidMem->setWC = setWC; pVidMem->undoWC = undoWC; #endif pVidMem->initialised = TRUE; }
Bool xf86EnableIO() { int fd; pointer base; if (ExtendedEnabled) return TRUE; if ((fd = open("/dev/ttyC0", O_RDWR)) >= 0) { /* Try to map a page at the pccons I/O space */ base = (pointer)mmap((caddr_t)0, 65536, PROT_READ | PROT_WRITE, MAP_FLAGS, fd, (off_t)0x0000); if (base != (pointer)-1) { IOPortBase = base; } else { xf86Msg(X_WARNING,"EnableIO: failed to mmap %s (%s)\n", "/dev/ttyC0", strerror(errno)); return FALSE; } } else { xf86Msg("EnableIO: failed to open %s (%s)\n", "/dev/ttyC0", strerror(errno)); return FALSE; } ExtendedEnabled = TRUE; return TRUE; }
_X_HIDDEN void sunKbdSoundBell(sunKbdPrivPtr priv, int loudness, int pitch, int duration) { int kbdCmd, i; if (loudness && pitch) { #ifdef AUDIO_BELL if (priv->audioDevName != NULL) { if (sunKbdAudioBell(priv, loudness, pitch, duration) == 0) { return; } } #endif kbdCmd = KBD_CMD_BELL; SYSCALL(i = ioctl (priv->kbdFD, KIOCCMD, &kbdCmd)); if (i < 0) { xf86Msg(X_ERROR, "%s: Failed to activate bell: %s\n", priv->devName, strerror(errno)); } usleep(duration * loudness * 20); kbdCmd = KBD_CMD_NOBELL; SYSCALL(i = ioctl (priv->kbdFD, KIOCCMD, &kbdCmd)); if (i < 0) { xf86Msg(X_ERROR, "%s: Failed to deactivate bell: %s\n", priv->devName, strerror(errno)); } } }
int XkbDDXPrivate(DeviceIntPtr dev,KeyCode key,XkbAction *act) { XkbAnyAction *xf86act = &(act->any); char msgbuf[XkbAnyActionDataSize+1]; if (xf86act->type == XkbSA_XFree86Private) { memcpy(msgbuf, xf86act->data, XkbAnyActionDataSize); msgbuf[XkbAnyActionDataSize]= '\0'; if (strcasecmp(msgbuf, "-vmode")==0) xf86ProcessActionEvent(ACTION_PREV_MODE, NULL); else if (strcasecmp(msgbuf, "+vmode")==0) xf86ProcessActionEvent(ACTION_NEXT_MODE, NULL); else if (strcasecmp(msgbuf, "prgrbs")==0) { DeviceIntPtr tmp; xf86Msg(X_INFO, "Printing all currently active device grabs:\n"); for (tmp = inputInfo.devices; tmp; tmp = tmp->next) if (tmp->deviceGrab.grab) PrintDeviceGrabInfo(tmp); xf86Msg(X_INFO, "End list of active device grabs\n"); } else if (strcasecmp(msgbuf, "ungrab")==0) UngrabAllDevices(FALSE); else if (strcasecmp(msgbuf, "clsgrb")==0) UngrabAllDevices(TRUE); else if (strcasecmp(msgbuf, "prwins")==0) PrintWindowTree(); } return 0; }
int xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, int Len) { int fd; #ifdef __ia64__ if ((fd = open(DEV_MEM, O_RDONLY | O_SYNC)) < 0) #else if ((fd = open(DEV_MEM, O_RDONLY)) < 0) #endif { xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n", DEV_MEM, strerror(errno)); return(-1); } if (lseek(fd, (Base+Offset), SEEK_SET) < 0) { xf86Msg(X_WARNING, "xf86ReadBIOS: %s seek failed (%s)\n", DEV_MEM, strerror(errno)); close(fd); return(-1); } if (read(fd, Buf, Len) != Len) { xf86Msg(X_WARNING, "xf86ReadBIOS: %s read failed (%s)\n", DEV_MEM, strerror(errno)); close(fd); return(-1); } close(fd); return(Len); }
int xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, int Len) { int fd; unsigned char *ptr; int psize; int mlen; if ((fd = open(DEV_MEM, O_RDONLY)) < 0) { xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n", DEV_MEM, strerror(errno)); return -1; } psize = getpagesize(); Offset += Base & (psize - 1); Base &= ~(psize - 1); mlen = (Offset + Len + psize - 1) & ~(psize - 1); ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ, MAP_SHARED, fd, (off_t)Base); if (ptr == MAP_FAILED) { xf86Msg(X_WARNING, "xf86ReadBIOS: %s mmap failed (%s)\n", DEV_MEM, strerror(errno)); close(fd); return -1; } DebugF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n", Base, ptr[0] | (ptr[1] << 8)); (void)memcpy(Buf, (void *)(ptr + Offset), Len); (void)munmap((caddr_t)ptr, mlen); (void)close(fd); return Len; }
static Bool linearVidMem() { #ifdef SVR4 return TRUE; #elif defined(HAS_SVR3_MMAPDRV) xf86MsgVerb(X_INFO, MMAP_DEBUG, "# xf86LinearVidMem: MMAP 2.2.2 called\n"); if(mmapFd >= 0) return TRUE; if ((mmapFd = open("/dev/mmap", O_RDWR)) != -1) { if(ioctl(mmapFd, GETVERSION) < 0x0222) { xf86Msg(X_WARNING, "xf86LinearVidMem: MMAP 2.2.2 or above required\n"); xf86ErrorF("\tlinear memory access disabled\n"); return FALSE; } return TRUE; } xf86Msg(X_WARNING, "xf86LinearVidMem: failed to open /dev/mmap (%s)\n", strerror(errno)); xf86ErrorF("\tlinear memory access disabled\n"); return FALSE; #endif }
void xf86CloseConsole(void) { struct vt_mode VT; if (ShareVTs) { close(xf86Info.consoleFd); return; } if (console_handler) { xf86RemoveGeneralHandler(console_handler); console_handler = NULL; }; /* Back to text mode ... */ if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT) < 0) xf86Msg(X_WARNING, "xf86CloseConsole: KDSETMODE failed: %s\n", strerror(errno)); ioctl(xf86Info.consoleFd, KDSKBMODE, tty_mode); tcsetattr(xf86Info.consoleFd, TCSANOW, &tty_attr); if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0) xf86Msg(X_WARNING, "xf86CloseConsole: VT_GETMODE failed: %s\n", strerror(errno)); else { /* set dflt vt handling */ VT.mode = VT_AUTO; if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0) xf86Msg(X_WARNING, "xf86CloseConsole: VT_SETMODE failed: %s\n", strerror(errno)); } if (VTSwitch) { /* * Perform a switch back to the active VT when we were started */ if (activeVT >= 0) { if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, activeVT) < 0) xf86Msg(X_WARNING, "xf86CloseConsole: VT_ACTIVATE failed: %s\n", strerror(errno)); if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, activeVT) < 0) xf86Msg(X_WARNING, "xf86CloseConsole: VT_WAITACTIVE failed: %s\n", strerror(errno)); activeVT = -1; } } close(xf86Info.consoleFd); /* make the vt-manager happy */ restoreVtPerms(); /* restore the permissions */ }
/* callbacks from the library */ int error_callback_from_library(TouchpadDevicePtr tdev, const char* string) { InputInfoPtr pInfo = tdev->parent; const char *name = "At Synaptix Initialization"; if (pInfo) name = pInfo->name; if (errno) xf86Msg(X_WARNING,"%s: %s(%s)", name, string, strerror(errno)); else xf86Msg(X_INFO,"%s: %s\n", name, string); return 0; }
void xf86OSInitVidMem(VidMemInfoPtr pVidMem) { checkDevMem(TRUE); if (has_bwx()) { xf86Msg(X_PROBED, "Machine type has 8/16 bit access\n"); } else { xf86Msg(X_PROBED, "Machine needs sparse mapping\n"); } pVidMem->initialised = TRUE; }
void xf86CloseConsole(void) { struct vt_mode VT; int ret; if (xf86Info.ShareVTs) { close(xf86Info.consoleFd); return; } /* * unregister the drain_console handler * - what to do if someone else changed it in the meantime? */ xf86SetConsoleHandler(NULL, NULL); /* Back to text mode ... */ SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT)); if (ret < 0) xf86Msg(X_WARNING, "xf86CloseConsole: KDSETMODE failed: %s\n", strerror(errno)); SYSCALL(ioctl(xf86Info.consoleFd, KDSKBMUTE, 0)); SYSCALL(ioctl(xf86Info.consoleFd, KDSKBMODE, tty_mode)); tcsetattr(xf86Info.consoleFd, TCSANOW, &tty_attr); SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_GETMODE, &VT)); if (ret < 0) xf86Msg(X_WARNING, "xf86CloseConsole: VT_GETMODE failed: %s\n", strerror(errno)); else { /* set dflt vt handling */ VT.mode = VT_AUTO; SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_SETMODE, &VT)); if (ret < 0) xf86Msg(X_WARNING, "xf86CloseConsole: VT_SETMODE failed: %s\n", strerror(errno)); } if (xf86Info.autoVTSwitch) { /* * Perform a switch back to the active VT when we were started */ if (activeVT >= 0) { switch_to(activeVT, "xf86CloseConsole"); activeVT = -1; } } close(xf86Info.consoleFd); /* make the vt-manager happy */ }
static void handle_gestures(LocalDevicePtr local, struct Gestures* gs) { struct MTouch *mt = local->private; static bitmask_t buttons_prev = 0U; int i; if(mt->absolute_mode == FALSE){ if (mt->cfg.scroll_smooth){ /* Copy states from button_prev into current buttons state */ MODBIT(gs->buttons, 3, GETBIT(buttons_prev, 3)); MODBIT(gs->buttons, 4, GETBIT(buttons_prev, 4)); MODBIT(gs->buttons, 5, GETBIT(buttons_prev, 5)); MODBIT(gs->buttons, 6, GETBIT(buttons_prev, 6)); set_and_post_mask(mt, local->dev, timertoms(&gs->dt)); } else{ // mt->absolute_mode == FALSE if (gs->move_dx != 0 || gs->move_dy != 0) xf86PostMotionEvent(local->dev, 0, 0, 2, gs->move_dx, gs->move_dy); } } else{ /* Give the HW coordinates to Xserver as absolute coordinates, these coordinates * are not scaled, this is oke if the touchscreen has the same resolution as the display. */ xf86PostMotionEvent(local->dev, 1, 0, 2, mt->state.touch[0].x + get_cap_xmid(&mt->caps), mt->state.touch[0].y + get_cap_ymid(&mt->caps)); } for (i = 0; i < 32; i++) { if (GETBIT(gs->buttons, i) == GETBIT(buttons_prev, i)) continue; if (GETBIT(gs->buttons, i)) { xf86PostButtonEvent(local->dev, FALSE, i+1, 1, 0, 0); #define DEBUG_DRIVER 0 #if DEBUG_DRIVER xf86Msg(X_INFO, "button %d down\n", i+1); #endif } else { xf86PostButtonEvent(local->dev, FALSE, i+1, 0, 0, 0); #if DEBUG_DRIVER xf86Msg(X_INFO, "button %d up\n", i+1); #endif #undef DEBUG_DRIVER } } buttons_prev = gs->buttons; }
int xf86JoystickOn(char * name, int *timeout, int *centerX, int *centerY) { int status; int changed = 0; int timeinmicros; struct joystick js; #ifdef DEBUG ErrorF("xf86JoystickOn: %s\n", name); #endif if ((status = open(name, O_RDWR | O_NDELAY, 0)) < 0) { xf86Msg(X_WARNING, "xf86JoystickOn: Cannot open joystick '%s' (%s)\n", name, strerror(errno)); return -1; } if (*timeout <= 0) { /* Use the current setting */ ioctl(status, JOY_GETTIMEOUT, (char *)&timeinmicros); *timeout = timeinmicros / 1000; if (*timeout == 0) *timeout = 1; changed = 1; } /* Maximum allowed timeout in the FreeBSD driver is 10ms */ if (*timeout > 10) { *timeout = 10; changed = 1; } if (changed) xf86Msg(X_PROBED, "Joystick: timeout value = %d\n", *timeout); timeinmicros = *timeout * 1000; /* Assume the joystick is centred when this is called */ read(status, &js, JS_RETURN); if (*centerX < 0) { *centerX = js.x; xf86Msg(X_PROBED, "Joystick: CenterX set to %d\n", *centerX); } if (*centerY < 0) { *centerY = js.y; xf86Msg(X_PROBED, "Joystick: CenterY set to %d\n", *centerY); } return status; }
static unsigned long memory_base(void) { if (abw_count < 0) init_abw(); if (abw_count > 0) { xf86Msg(X_INFO, "memory base = %#lx\n", abw[1].abw_abst.abst_sys_start); /* XXXX */ return abw[1].abw_abst.abst_sys_start; } else { xf86Msg(X_INFO, "no memory base\n"); /* XXXX */ return 0; } }
static int device_on(InputInfoPtr local) { struct mtev_mtouch *mt = local->private; local->fd = xf86OpenSerial(local->options); if (local->fd < 0) { xf86Msg(X_ERROR, "mtev: cannot open device\n"); return !Success; } if (mtouch_open(mt, local->fd)) { xf86Msg(X_ERROR, "mtev: cannot grab device\n"); return !Success; } xf86AddEnabledDevice(local); return Success; }
/* * Handle keyboard events that cause some kind of "action" * (i.e., server termination, video mode changes, VT switches, etc.) */ void xf86ProcessActionEvent(ActionEvent action, void *arg) { DebugF("ProcessActionEvent(%d,%x)\n", (int) action, arg); switch (action) { case ACTION_TERMINATE: if (!xf86Info.dontZap) { xf86Msg(X_INFO, "Server zapped. Shutting down.\n"); #ifdef XFreeXDGA DGAShutdown(); #endif GiveUp(0); } break; case ACTION_NEXT_MODE: if (!xf86Info.dontZoom) xf86ZoomViewport(xf86Info.currentScreen, 1); break; case ACTION_PREV_MODE: if (!xf86Info.dontZoom) xf86ZoomViewport(xf86Info.currentScreen, -1); break; case ACTION_SWITCHSCREEN: if (VTSwitchEnabled && !xf86Info.dontVTSwitch && arg) { int vtno = *((int *) arg); if (vtno != xf86Info.vtno) { if (!xf86VTActivate(vtno)) { ErrorF("Failed to switch from vt%02d to vt%02d: %s\n", xf86Info.vtno, vtno, strerror(errno)); } } } break; case ACTION_SWITCHSCREEN_NEXT: if (VTSwitchEnabled && !xf86Info.dontVTSwitch) { if (!xf86VTActivate(xf86Info.vtno + 1)) { /* If first try failed, assume this is the last VT and * try wrapping around to the first vt. */ if (!xf86VTActivate(1)) { ErrorF("Failed to switch from vt%02d to next vt: %s\n", xf86Info.vtno, strerror(errno)); } } } break; case ACTION_SWITCHSCREEN_PREV: if (VTSwitchEnabled && !xf86Info.dontVTSwitch && xf86Info.vtno > 0) { if (!xf86VTActivate(xf86Info.vtno - 1)) { /* Don't know what the maximum VT is, so can't wrap around */ ErrorF("Failed to switch from vt%02d to previous vt: %s\n", xf86Info.vtno, strerror(errno)); } } break; default: break; } }
/** * Call the driver's correct probe function. * * If the driver implements the \c DriverRec::PciProbe entry-point and an * appropriate PCI device (with matching Device section in the xorg.conf file) * is found, it is called. If \c DriverRec::PciProbe or no devices can be * successfully probed with it (e.g., only non-PCI devices are available), * the driver's \c DriverRec::Probe function is called. * * \param drv Driver to probe * * \return * If a device can be successfully probed by the driver, \c TRUE is * returned. Otherwise, \c FALSE is returned. */ Bool xf86CallDriverProbe(DriverPtr drv, Bool detect_only) { Bool foundScreen = FALSE; #ifdef XSERVER_PLATFORM_BUS if (drv->platformProbe != NULL) { foundScreen = xf86platformProbeDev(drv); } if (ServerIsNotSeat0() && foundScreen) return foundScreen; #endif #ifdef XSERVER_LIBPCIACCESS if (!foundScreen && (drv->PciProbe != NULL)) { if (xf86DoConfigure && xf86DoConfigurePass1) { assert(detect_only); foundScreen = xf86PciAddMatchingDev(drv); } else { assert(!detect_only); foundScreen = xf86PciProbeDev(drv); } } #endif if (!foundScreen && (drv->Probe != NULL)) { xf86Msg(X_WARNING, "Falling back to old probe method for %s\n", drv->driverName); foundScreen = (*drv->Probe) (drv, (detect_only) ? PROBE_DETECT : PROBE_DEFAULT); } return foundScreen; }
/* * SIGIO gives no way of discovering which fd signalled, select * to discover */ static void xf86SIGIO (int sig) { int i; fd_set ready; struct timeval to; int r; ready = xf86SigIOMask; to.tv_sec = 0; to.tv_usec = 0; SYSCALL (r = select (xf86SigIOMaxFd, &ready, 0, 0, &to)); for (i = 0; r > 0 && i < xf86SigIOMax; i++) if (xf86SigIOFuncs[i].f && FD_ISSET (xf86SigIOFuncs[i].fd, &ready)) { (*xf86SigIOFuncs[i].f)(xf86SigIOFuncs[i].fd, xf86SigIOFuncs[i].closure); r--; } #ifdef XFree86Server if (r > 0) { xf86Msg(X_ERROR, "SIGIO %d descriptors not handled\n", r); } #endif }
axpDevice bsdGetAXP(void) { int i; char sysname[64]; size_t len = sizeof(sysname); #ifdef __OpenBSD__ int mib[3]; int error; mib[0] = CTL_MACHDEP; mib[1] = CPU_CHIPSET; mib[2] = CPU_CHIPSET_TYPE; if ((error = sysctl(mib, 3, &sysname, &len, NULL, 0)) < 0) #else if ((sysctlbyname("hw.chipset.type", &sysname, &len, 0, 0)) < 0) #endif FatalError("bsdGetAXP: can't find machine type\n"); #ifdef DEBUG xf86Msg(X_INFO,"AXP is a: %s\n",sysname); #endif for (i=0;;i++) { if (axpList[i].name == NULL) return NONE; if (!strcmp(sysname, axpList[i].name)) return axpList[i].type; } }
static pointer glxSetup(pointer module, pointer opts, int *errmaj, int *errmin) { static Bool setupDone = FALSE; __GLXprovider *provider; if (setupDone) { if (errmaj) *errmaj = LDR_ONCEONLY; return NULL; } setupDone = TRUE; xf86Msg(xf86Info.aiglxFrom, "AIGLX %s\n", xf86Info.aiglx ? "enabled" : "disabled"); if (xf86Info.aiglx) { provider = LoaderSymbol("__glXDRIProvider"); if (provider) GlxPushProvider(provider); provider = LoaderSymbol("__glXDRI2Provider"); if (provider) GlxPushProvider(provider); } LoadExtension(&GLXExt, FALSE); return module; }
_X_EXPORT int xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, int Len) { unsigned char *ptr; int psize; int mlen; psize = xf86getpagesize(); Offset += Base & (psize - 1); Base &= ~(psize - 1); mlen = (Offset + Len + psize - 1) & ~(psize - 1); ptr = (unsigned char *)mmap_device_memory((caddr_t)0, mlen, PROT_READ, 0, (off_t)Base); if ((long)ptr == -1) { xf86Msg(X_WARNING, "xf86ReadBIOS: %s mmap[s=%x,a=%lx,o=%lx] failed (%s)\n", DEV_MEM, Len, Base, Offset, strerror(errno)); return(-1); } #ifdef DEBUG ErrorF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n", Base, ptr[0] | (ptr[1] << 8)); #endif (void)memcpy(Buf, (void *)(ptr + Offset), Len); (void)munmap_device_memory((caddr_t)ptr, mlen); #ifdef DEBUG xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)" "-> %02x %02x %02x %02x...\n", Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]); #endif return(Len); }
_X_EXPORT int xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, int Len) { int rv; if (Base < 0x80000000) { xf86Msg(X_WARNING, "No VGA Base=%#lx\n", Base); return 0; } if (kmem == -1) { kmem = open(DEV_MEM, 2); if (kmem == -1) { FatalError("xf86ReadBIOS: open %s", DEV_MEM); } } #ifdef DEBUG xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS() %lx %lx, %x\n", Base, Offset, Len); #endif lseek(kmem, Base + Offset, 0); rv = read(kmem, Buf, Len); return rv; }
_X_HIDDEN int sunKbdOpen(const char *devName, pointer options) { int kbdFD; const char *kbdPath = NULL; const char *defaultKbd = "/dev/kbd"; if (options != NULL) { kbdPath = xf86SetStrOption(options, "Device", NULL); } if (kbdPath == NULL) { kbdPath = defaultKbd; } kbdFD = open(kbdPath, O_RDONLY | O_NONBLOCK); if (kbdFD == -1) { xf86Msg(X_ERROR, "%s: cannot open \"%s\"\n", devName, kbdPath); } else { xf86MsgVerb(X_INFO, 3, "%s: Opened device \"%s\"\n", devName, kbdPath); } if ((kbdPath != NULL) && (kbdPath != defaultKbd)) { xfree(kbdPath); } return kbdFD; }
int xf86SetSerialSpeed(int fd, int speed) { struct termios t; int baud, r; if (fd < 0) return -1; /* Don't try to set parameters for non-tty devices. */ if (!isatty(fd)) return 0; SYSCALL(tcgetattr(fd, &t)); if ((baud = GetBaud(speed))) { cfsetispeed(&t, baud); cfsetospeed(&t, baud); } else { xf86Msg(X_ERROR, "Invalid Option BaudRate value: %d\n", speed); return -1; } SYSCALL(r = tcsetattr(fd, TCSANOW, &t)); return r; }
static Bool xf86CreateRootWindow(WindowPtr pWin) { int ret = TRUE; int err = Success; ScreenPtr pScreen = pWin->drawable.pScreen; RootWinPropPtr pProp; CreateWindowProcPtr CreateWindow = (CreateWindowProcPtr) dixLookupPrivate(&pScreen->devPrivates, xf86CreateRootWindowKey); DebugF("xf86CreateRootWindow(%p)\n", pWin); if ( pScreen->CreateWindow != xf86CreateRootWindow ) { /* Can't find hook we are hung on */ xf86DrvMsg(pScreen->myNum, X_WARNING /* X_ERROR */, "xf86CreateRootWindow %p called when not in pScreen->CreateWindow %p n", (void *)xf86CreateRootWindow, (void *)pScreen->CreateWindow ); } /* Unhook this function ... */ pScreen->CreateWindow = CreateWindow; dixSetPrivate(&pScreen->devPrivates, xf86CreateRootWindowKey, NULL); /* ... and call the previous CreateWindow fuction, if any */ if (NULL!=pScreen->CreateWindow) { ret = (*pScreen->CreateWindow)(pWin); } /* Now do our stuff */ if (xf86RegisteredPropertiesTable != NULL) { if (pWin->parent == NULL && xf86RegisteredPropertiesTable != NULL) { for (pProp = xf86RegisteredPropertiesTable[pScreen->myNum]; pProp != NULL && err==Success; pProp = pProp->next ) { Atom prop; prop = MakeAtom(pProp->name, strlen(pProp->name), TRUE); err = dixChangeWindowProperty(serverClient, pWin, prop, pProp->type, pProp->format, PropModeReplace, pProp->size, pProp->data, FALSE); } /* Look at err */ ret &= (err==Success); } else { xf86Msg(X_ERROR, "xf86CreateRootWindow unexpectedly called with " "non-root window %p (parent %p)\n", (void *)pWin, (void *)pWin->parent); ret = FALSE; } } DebugF("xf86CreateRootWindow() returns %d\n", ret); return ret; }
/* * SIGIO gives no way of discovering which fd signalled, select * to discover */ static void xf86SIGIO(int sig) { int i; fd_set ready; struct timeval to; int save_errno = errno; /* do not clobber the global errno */ int r; inSignalContext = TRUE; ready = xf86SigIOMask; to.tv_sec = 0; to.tv_usec = 0; SYSCALL(r = select(xf86SigIOMaxFd, &ready, 0, 0, &to)); for (i = 0; r > 0 && i < xf86SigIOMax; i++) if (xf86SigIOFuncs[i].f && FD_ISSET(xf86SigIOFuncs[i].fd, &ready)) { (*xf86SigIOFuncs[i].f) (xf86SigIOFuncs[i].fd, xf86SigIOFuncs[i].closure); r--; } if (r > 0) { xf86Msg(X_ERROR, "SIGIO %d descriptors not handled\n", r); } /* restore global errno */ errno = save_errno; inSignalContext = FALSE; }
/* * pciInit - choose correct platform/OS specific PCI init routine */ void pciInit() { if (pciInitialized) return; pciInitialized = 1; /* XXX */ #if defined(DEBUGPCI) if (DEBUGPCI >= xf86Verbose) xf86Verbose = DEBUGPCI; #endif ARCH_PCI_INIT(); #if defined(ARCH_PCI_OS_INIT) if (pciNumBuses <= 0) ARCH_PCI_OS_INIT(); #endif if (xf86MaxPciDevs == 0) { xf86Msg(X_WARNING, "OS did not count PCI devices, guessing wildly\n"); xf86MaxPciDevs = MAX_PCI_DEVICES; } if (pci_devp) xfree(pci_devp); pci_devp = xnfcalloc(xf86MaxPciDevs + 1, sizeof(pciConfigPtr)); }
static Bool CheckVersion(const char *module, XF86ModuleVersionInfo * data, const XF86ModReqInfo * req) { int vercode[4]; char verstr[4]; long ver = data->xf86version; MessageType errtype; xf86Msg(X_INFO, "Module %s: vendor=\"%s\"\n", data->modname ? data->modname : "UNKNOWN!", data->vendor ? data->vendor : "UNKNOWN!"); if (ver > (4 << 24)) { /* 4.0.x and earlier */ verstr[1] = verstr[3] = 0; verstr[2] = (ver & 0x1f) ? (ver & 0x1f) + 'a' - 1 : 0; ver >>= 5; verstr[0] = (ver & 0x1f) ? (ver & 0x1f) + 'A' - 1 : 0; ver >>= 5; vercode[2] = ver & 0x7f; ver >>= 7; vercode[1] = ver & 0x7f; ver >>= 7; vercode[0] = ver; xf86ErrorF("\tcompiled for %d.%d", vercode[0], vercode[1]); if (vercode[2] != 0) xf86ErrorF(".%d", vercode[2]); xf86ErrorF("%s%s, module version = %d.%d.%d\n", verstr, verstr + 2, data->majorversion, data->minorversion, data->patchlevel); } else {
int xf86OpenSerial (pointer options) { APIRET rc; HFILE fd, i; ULONG action; GLINECTL linectl; char* dev = xf86FindOptionValue (options, "Device"); xf86MarkOptionUsedByName (options, "Device"); if (!dev) { xf86Msg (X_ERROR, "xf86OpenSerial: No Device specified.\n"); return -1; } rc = DosOpen(dev, &fd, &action, 0, FILE_NORMAL, FILE_OPEN, OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE, NULL); if (rc) { xf86Msg (X_ERROR, "xf86OpenSerial: Cannot open device %s, rc=%d.\n", dev, rc); return -1; } /* check whether it is an async device */ if (_get_linectrl(fd,&linectl)) { xf86Msg (X_WARNING, "xf86OpenSerial: Specified device %s is not a tty\n", dev); DosClose(fd); return -1; } /* set up default port parameters */ _set_baudrate(fd, 9600); linectl.databits = 8; linectl.parity = 0; linectl.stopbits = 0; _set_linectl(fd, &linectl); if (xf86SetSerial (fd, options) == -1) { DosClose(fd); return -1; } return fd; }