Beispiel #1
0
_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;
}
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12
	pInfo->name = xstrdup(dev->identifier);
	pInfo->flags = 0;
	pInfo->conf_idev = dev;
#endif

	pInfo->private = pQubes;
	pInfo->type_name = XI_MOUSE;	/* see XI.h */
	pInfo->read_input = QubesReadInput;	/* new data avl */
	pInfo->switch_mode = NULL;	/* toggle absolute/relative mode */
	pInfo->device_control = QubesControl;	/* enable/disable dev */
	/* process driver specific options */
	pQubes->device = xf86SetStrOption(
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
			pInfo->options,
#else
			dev->commonOptions,
#endif
			"Device", "/var/run/xf86-qubes-socket");

	xf86Msg(X_INFO, "%s: Using device %s.\n", pInfo->name,
		pQubes->device);
//	xf86Msg(X_INFO, "%s: dixLookupWindow=%p.\n", pInfo->name,
//		dixLookupWindow);
//	xf86Msg(X_INFO, "%s: dixLookupResourceByClass=%p.\n", pInfo->name,
//		dixLookupResourceByClass);

	/* process generic options */
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
	xf86CollectInputOptions(pInfo, NULL);
#else
Beispiel #3
0
int
xf86SetSerial(int fd, XF86OptionPtr options)
{
    struct termios t;
    int val;
    const char *s;
    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 ((val = xf86SetIntOption(options, "BaudRate", 0))) {
        if ((baud = GetBaud(val))) {
            cfsetispeed(&t, baud);
            cfsetospeed(&t, baud);
        }
        else {
            xf86Msg(X_ERROR, "Invalid Option BaudRate value: %d\n", val);
            return -1;
        }
    }

    if ((val = xf86SetIntOption(options, "StopBits", 0))) {
        switch (val) {
        case 1:
            t.c_cflag &= ~(CSTOPB);
            break;
        case 2:
            t.c_cflag |= CSTOPB;
            break;
        default:
            xf86Msg(X_ERROR, "Invalid Option StopBits value: %d\n", val);
            return -1;
            break;
        }
    }

    if ((val = xf86SetIntOption(options, "DataBits", 0))) {
        switch (val) {
        case 5:
            t.c_cflag &= ~(CSIZE);
            t.c_cflag |= CS5;
            break;
        case 6:
            t.c_cflag &= ~(CSIZE);
            t.c_cflag |= CS6;
            break;
        case 7:
            t.c_cflag &= ~(CSIZE);
            t.c_cflag |= CS7;
            break;
        case 8:
            t.c_cflag &= ~(CSIZE);
            t.c_cflag |= CS8;
            break;
        default:
            xf86Msg(X_ERROR, "Invalid Option DataBits value: %d\n", val);
            return -1;
            break;
        }
    }

    if ((s = xf86SetStrOption(options, "Parity", NULL))) {
        if (xf86NameCmp(s, "Odd") == 0) {
            t.c_cflag |= PARENB | PARODD;
        }
        else if (xf86NameCmp(s, "Even") == 0) {
            t.c_cflag |= PARENB;
            t.c_cflag &= ~(PARODD);
        }
        else if (xf86NameCmp(s, "None") == 0) {
            t.c_cflag &= ~(PARENB);
        }
        else {
            xf86Msg(X_ERROR, "Invalid Option Parity value: %s\n", s);
            return -1;
        }
    }

    if ((val = xf86SetIntOption(options, "Vmin", -1)) != -1) {
        t.c_cc[VMIN] = val;
    }
    if ((val = xf86SetIntOption(options, "Vtime", -1)) != -1) {
        t.c_cc[VTIME] = val;
    }

    if ((s = xf86SetStrOption(options, "FlowControl", NULL))) {
        xf86MarkOptionUsedByName(options, "FlowControl");
        if (xf86NameCmp(s, "Xoff") == 0) {
            t.c_iflag |= IXOFF;
        }
        else if (xf86NameCmp(s, "Xon") == 0) {
            t.c_iflag |= IXON;
        }
        else if (xf86NameCmp(s, "XonXoff") == 0) {
            t.c_iflag |= IXON | IXOFF;
        }
        else if (xf86NameCmp(s, "None") == 0) {
            t.c_iflag &= ~(IXON | IXOFF);
        }
        else {
            xf86Msg(X_ERROR, "Invalid Option FlowControl value: %s\n", s);
            return -1;
        }
    }

    if ((xf86SetBoolOption(options, "ClearDTR", FALSE))) {
#ifdef CLEARDTR_SUPPORT
#if defined(TIOCMBIC)
        val = TIOCM_DTR;
        SYSCALL(ioctl(fd, TIOCMBIC, &val));
#else
        SYSCALL(ioctl(fd, TIOCCDTR, NULL));
#endif
#else
        xf86Msg(X_WARNING, "Option ClearDTR not supported on this OS\n");
        return -1;
#endif
        xf86MarkOptionUsedByName(options, "ClearDTR");
    }

    if ((xf86SetBoolOption(options, "ClearRTS", FALSE))) {
        xf86Msg(X_WARNING, "Option ClearRTS not supported on this OS\n");
        return -1;
        xf86MarkOptionUsedByName(options, "ClearRTS");
    }

    SYSCALL(r = tcsetattr(fd, TCSANOW, &t));
    return r;
}
Beispiel #4
0
int
xf86OpenSerial(XF86OptionPtr options)
{
    struct termios t;
    int fd, i;
    char *dev;

    dev = xf86SetStrOption(options, "Device", NULL);
    if (!dev) {
        xf86Msg(X_ERROR, "xf86OpenSerial: No Device specified.\n");
        return -1;
    }

    fd = xf86CheckIntOption(options, "fd", -1);

    if (fd == -1)
        SYSCALL(fd = open(dev, O_RDWR | O_NONBLOCK));

    if (fd == -1) {
        xf86Msg(X_ERROR,
                "xf86OpenSerial: Cannot open device %s\n\t%s.\n",
                dev, strerror(errno));
        free(dev);
        return -1;
    }

    if (!isatty(fd)) {
        /* Allow non-tty devices to be opened. */
        free(dev);
        return fd;
    }

    /* set up default port parameters */
    SYSCALL(tcgetattr(fd, &t));
    t.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR
                   | IGNCR | ICRNL | IXON);
    t.c_oflag &= ~OPOST;
    t.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
    t.c_cflag &= ~(CSIZE | PARENB);
    t.c_cflag |= CS8 | CLOCAL;

    cfsetispeed(&t, B9600);
    cfsetospeed(&t, B9600);
    t.c_cc[VMIN] = 1;
    t.c_cc[VTIME] = 0;

    SYSCALL(tcsetattr(fd, TCSANOW, &t));

    if (xf86SetSerial(fd, options) == -1) {
        SYSCALL(close(fd));
        free(dev);
        return -1;
    }

    SYSCALL(i = fcntl(fd, F_GETFL, 0));
    if (i == -1) {
        SYSCALL(close(fd));
        free(dev);
        return -1;
    }
    i &= ~O_NONBLOCK;
    SYSCALL(i = fcntl(fd, F_SETFL, i));
    if (i == -1) {
        SYSCALL(close(fd));
        free(dev);
        return -1;
    }
    free(dev);
    return fd;
}
Beispiel #5
0
_X_HIDDEN int
sunKbdInit(sunKbdPrivPtr priv, int kbdFD, const char *devName, pointer options)
{
    int	ktype, klayout, i;
    const char *ktype_name;

    priv->kbdFD 	= kbdFD;
    priv->devName 	= devName;
    priv->otranslation 	= -1;
    priv->odirect 	= -1;

    if (options != NULL) {
	priv->strmod = xf86SetStrOption(options, "StreamsModule", NULL);
	priv->audioDevName = xf86SetStrOption(options, "BellDevice", NULL);

	if (priv->audioDevName && (priv->audioDevName[0] == '\0')) {
	    xfree(priv->audioDevName);
	    priv->audioDevName = NULL;
	}	
    } else {
	priv->strmod 		= NULL;
	priv->audioDevName	= NULL;
    }

    if (priv->strmod) {
	SYSCALL(i = ioctl(priv->kbdFD, I_PUSH, priv->strmod));
	if (i < 0) {
	    xf86Msg(X_ERROR,
		    "%s: cannot push module '%s' onto keyboard device: %s\n",
		    priv->devName, priv->strmod, strerror(errno));
	}
    }
    
    SYSCALL(i = ioctl(kbdFD, KIOCTYPE, &ktype));
    if (i < 0) {
	xf86Msg(X_ERROR, "%s: Unable to determine keyboard type: %s\n", 
		devName, strerror(errno));
	return BadImplementation;
    }
    
    SYSCALL(i = ioctl(kbdFD, KIOCLAYOUT, &klayout));
    if (i < 0) {	
	xf86Msg(X_ERROR, "%s: Unable to determine keyboard layout: %s\n", 
		devName, strerror(errno));
	return BadImplementation;
    }
    
    switch (ktype) {
    case KB_SUN3:
	ktype_name = "Sun Type 3"; break;
    case KB_SUN4:
	ktype_name = "Sun Type 4/5/6"; break;
    case KB_USB:
	ktype_name = "USB"; break;
    case KB_PC:
	ktype_name = "PC"; break;
    default:
	ktype_name = "Unknown"; break;
    }

    xf86Msg(X_PROBED, "%s: Keyboard type: %s (%d)\n",
	    devName, ktype_name, ktype);
    xf86Msg(X_PROBED, "%s: Keyboard layout: %d\n", devName, klayout);

    priv->ktype 	= ktype;
    priv->keyMap	= sunGetKbdMapping(ktype);
    priv->audioState	= AB_INITIALIZING;
    priv->oleds 	= sunKbdGetLeds(priv);

    return Success;
}