11da177e4SLinus Torvalds /* 21da177e4SLinus Torvalds * USB Empeg empeg-car player driver 31da177e4SLinus Torvalds * 41da177e4SLinus Torvalds * Copyright (C) 2000, 2001 51da177e4SLinus Torvalds * Gary Brubaker (xavyer@ix.netcom.com) 61da177e4SLinus Torvalds * 71da177e4SLinus Torvalds * Copyright (C) 1999 - 2001 81da177e4SLinus Torvalds * Greg Kroah-Hartman (greg@kroah.com) 91da177e4SLinus Torvalds * 101da177e4SLinus Torvalds * This program is free software; you can redistribute it and/or modify 111da177e4SLinus Torvalds * it under the terms of the GNU General Public License, as published by 121da177e4SLinus Torvalds * the Free Software Foundation, version 2. 131da177e4SLinus Torvalds * 1493c46795SAlan Cox * See Documentation/usb/usb-serial.txt for more information on using this 1593c46795SAlan Cox * driver 161da177e4SLinus Torvalds */ 171da177e4SLinus Torvalds 181da177e4SLinus Torvalds #include <linux/kernel.h> 191da177e4SLinus Torvalds #include <linux/errno.h> 201da177e4SLinus Torvalds #include <linux/init.h> 211da177e4SLinus Torvalds #include <linux/slab.h> 221da177e4SLinus Torvalds #include <linux/tty.h> 231da177e4SLinus Torvalds #include <linux/tty_driver.h> 241da177e4SLinus Torvalds #include <linux/tty_flip.h> 251da177e4SLinus Torvalds #include <linux/module.h> 261da177e4SLinus Torvalds #include <linux/spinlock.h> 2793c46795SAlan Cox #include <linux/uaccess.h> 281da177e4SLinus Torvalds #include <linux/usb.h> 29a969888cSGreg Kroah-Hartman #include <linux/usb/serial.h> 301da177e4SLinus Torvalds 3190ab5ee9SRusty Russell static bool debug; 321da177e4SLinus Torvalds 331da177e4SLinus Torvalds /* 341da177e4SLinus Torvalds * Version Information 351da177e4SLinus Torvalds */ 36695aaae6SJohan Hovold #define DRIVER_VERSION "v1.3" 371da177e4SLinus Torvalds #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Gary Brubaker <xavyer@ix.netcom.com>" 381da177e4SLinus Torvalds #define DRIVER_DESC "USB Empeg Mark I/II Driver" 391da177e4SLinus Torvalds 401da177e4SLinus Torvalds #define EMPEG_VENDOR_ID 0x084f 411da177e4SLinus Torvalds #define EMPEG_PRODUCT_ID 0x0001 421da177e4SLinus Torvalds 431da177e4SLinus Torvalds /* function prototypes for an empeg-car player */ 441da177e4SLinus Torvalds static int empeg_startup(struct usb_serial *serial); 45fe1ae7fdSAlan Cox static void empeg_init_termios(struct tty_struct *tty); 461da177e4SLinus Torvalds 477d40d7e8SNémeth Márton static const struct usb_device_id id_table[] = { 481da177e4SLinus Torvalds { USB_DEVICE(EMPEG_VENDOR_ID, EMPEG_PRODUCT_ID) }, 491da177e4SLinus Torvalds { } /* Terminating entry */ 501da177e4SLinus Torvalds }; 511da177e4SLinus Torvalds 521da177e4SLinus Torvalds MODULE_DEVICE_TABLE(usb, id_table); 531da177e4SLinus Torvalds 541da177e4SLinus Torvalds static struct usb_driver empeg_driver = { 551da177e4SLinus Torvalds .name = "empeg", 561da177e4SLinus Torvalds .probe = usb_serial_probe, 571da177e4SLinus Torvalds .disconnect = usb_serial_disconnect, 581da177e4SLinus Torvalds .id_table = id_table, 591da177e4SLinus Torvalds }; 601da177e4SLinus Torvalds 61ea65370dSGreg Kroah-Hartman static struct usb_serial_driver empeg_device = { 6218fcac35SGreg Kroah-Hartman .driver = { 631da177e4SLinus Torvalds .owner = THIS_MODULE, 64269bda1cSGreg Kroah-Hartman .name = "empeg", 6518fcac35SGreg Kroah-Hartman }, 661da177e4SLinus Torvalds .id_table = id_table, 671da177e4SLinus Torvalds .num_ports = 1, 68695aaae6SJohan Hovold .bulk_out_size = 256, 69695aaae6SJohan Hovold .throttle = usb_serial_generic_throttle, 70695aaae6SJohan Hovold .unthrottle = usb_serial_generic_unthrottle, 711da177e4SLinus Torvalds .attach = empeg_startup, 72fe1ae7fdSAlan Cox .init_termios = empeg_init_termios, 731da177e4SLinus Torvalds }; 741da177e4SLinus Torvalds 7597b6b6d2SAlan Stern static struct usb_serial_driver * const serial_drivers[] = { 7697b6b6d2SAlan Stern &empeg_device, NULL 7797b6b6d2SAlan Stern }; 7897b6b6d2SAlan Stern 791da177e4SLinus Torvalds static int empeg_startup(struct usb_serial *serial) 801da177e4SLinus Torvalds { 811da177e4SLinus Torvalds int r; 821da177e4SLinus Torvalds 831da177e4SLinus Torvalds if (serial->dev->actconfig->desc.bConfigurationValue != 1) { 84194343d9SGreg Kroah-Hartman dev_err(&serial->dev->dev, "active config #%d != 1 ??\n", 851da177e4SLinus Torvalds serial->dev->actconfig->desc.bConfigurationValue); 861da177e4SLinus Torvalds return -ENODEV; 871da177e4SLinus Torvalds } 88*4e512ab9SGreg Kroah-Hartman 891da177e4SLinus Torvalds r = usb_reset_configuration(serial->dev); 901da177e4SLinus Torvalds 911da177e4SLinus Torvalds /* continue on with initialization */ 921da177e4SLinus Torvalds return r; 931da177e4SLinus Torvalds } 941da177e4SLinus Torvalds 95fe1ae7fdSAlan Cox static void empeg_init_termios(struct tty_struct *tty) 961da177e4SLinus Torvalds { 9795da310eSAlan Cox struct ktermios *termios = tty->termios; 981da177e4SLinus Torvalds 991da177e4SLinus Torvalds /* 1001da177e4SLinus Torvalds * The empeg-car player wants these particular tty settings. 1011da177e4SLinus Torvalds * You could, for example, change the baud rate, however the 1021da177e4SLinus Torvalds * player only supports 115200 (currently), so there is really 1031da177e4SLinus Torvalds * no point in support for changes to the tty settings. 1041da177e4SLinus Torvalds * (at least for now) 1051da177e4SLinus Torvalds * 1061da177e4SLinus Torvalds * The default requirements for this device are: 1071da177e4SLinus Torvalds */ 108998e8638SAlan Cox termios->c_iflag 1091da177e4SLinus Torvalds &= ~(IGNBRK /* disable ignore break */ 1101da177e4SLinus Torvalds | BRKINT /* disable break causes interrupt */ 1111da177e4SLinus Torvalds | PARMRK /* disable mark parity errors */ 1121da177e4SLinus Torvalds | ISTRIP /* disable clear high bit of input characters */ 1131da177e4SLinus Torvalds | INLCR /* disable translate NL to CR */ 1141da177e4SLinus Torvalds | IGNCR /* disable ignore CR */ 1151da177e4SLinus Torvalds | ICRNL /* disable translate CR to NL */ 1161da177e4SLinus Torvalds | IXON); /* disable enable XON/XOFF flow control */ 1171da177e4SLinus Torvalds 118998e8638SAlan Cox termios->c_oflag 1191da177e4SLinus Torvalds &= ~OPOST; /* disable postprocess output characters */ 1201da177e4SLinus Torvalds 121998e8638SAlan Cox termios->c_lflag 1221da177e4SLinus Torvalds &= ~(ECHO /* disable echo input characters */ 1231da177e4SLinus Torvalds | ECHONL /* disable echo new line */ 1241da177e4SLinus Torvalds | ICANON /* disable erase, kill, werase, and rprnt special characters */ 1251da177e4SLinus Torvalds | ISIG /* disable interrupt, quit, and suspend special characters */ 1261da177e4SLinus Torvalds | IEXTEN); /* disable non-POSIX special characters */ 1271da177e4SLinus Torvalds 128998e8638SAlan Cox termios->c_cflag 1291da177e4SLinus Torvalds &= ~(CSIZE /* no size */ 1301da177e4SLinus Torvalds | PARENB /* disable parity bit */ 1311da177e4SLinus Torvalds | CBAUD); /* clear current baud rate */ 1321da177e4SLinus Torvalds 133998e8638SAlan Cox termios->c_cflag 134998e8638SAlan Cox |= CS8; /* character size 8 bits */ 1351da177e4SLinus Torvalds 13695da310eSAlan Cox tty_encode_baud_rate(tty, 115200, 115200); 1371da177e4SLinus Torvalds } 1381da177e4SLinus Torvalds 13910a6b9ceSGreg Kroah-Hartman module_usb_serial_driver(empeg_driver, serial_drivers); 1401da177e4SLinus Torvalds 1411da177e4SLinus Torvalds MODULE_AUTHOR(DRIVER_AUTHOR); 1421da177e4SLinus Torvalds MODULE_DESCRIPTION(DRIVER_DESC); 1431da177e4SLinus Torvalds MODULE_LICENSE("GPL"); 1441da177e4SLinus Torvalds 1451da177e4SLinus Torvalds module_param(debug, bool, S_IRUGO | S_IWUSR); 1461da177e4SLinus Torvalds MODULE_PARM_DESC(debug, "Debug enabled or not"); 147