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 83441b62c1SHarvey Harrison dbg("%s", __func__); 841da177e4SLinus Torvalds 851da177e4SLinus Torvalds if (serial->dev->actconfig->desc.bConfigurationValue != 1) { 86194343d9SGreg Kroah-Hartman dev_err(&serial->dev->dev, "active config #%d != 1 ??\n", 871da177e4SLinus Torvalds serial->dev->actconfig->desc.bConfigurationValue); 881da177e4SLinus Torvalds return -ENODEV; 891da177e4SLinus Torvalds } 90441b62c1SHarvey Harrison dbg("%s - reset config", __func__); 911da177e4SLinus Torvalds r = usb_reset_configuration(serial->dev); 921da177e4SLinus Torvalds 931da177e4SLinus Torvalds /* continue on with initialization */ 941da177e4SLinus Torvalds return r; 951da177e4SLinus Torvalds } 961da177e4SLinus Torvalds 97fe1ae7fdSAlan Cox static void empeg_init_termios(struct tty_struct *tty) 981da177e4SLinus Torvalds { 9995da310eSAlan Cox struct ktermios *termios = tty->termios; 1001da177e4SLinus Torvalds 1011da177e4SLinus Torvalds /* 1021da177e4SLinus Torvalds * The empeg-car player wants these particular tty settings. 1031da177e4SLinus Torvalds * You could, for example, change the baud rate, however the 1041da177e4SLinus Torvalds * player only supports 115200 (currently), so there is really 1051da177e4SLinus Torvalds * no point in support for changes to the tty settings. 1061da177e4SLinus Torvalds * (at least for now) 1071da177e4SLinus Torvalds * 1081da177e4SLinus Torvalds * The default requirements for this device are: 1091da177e4SLinus Torvalds */ 110998e8638SAlan Cox termios->c_iflag 1111da177e4SLinus Torvalds &= ~(IGNBRK /* disable ignore break */ 1121da177e4SLinus Torvalds | BRKINT /* disable break causes interrupt */ 1131da177e4SLinus Torvalds | PARMRK /* disable mark parity errors */ 1141da177e4SLinus Torvalds | ISTRIP /* disable clear high bit of input characters */ 1151da177e4SLinus Torvalds | INLCR /* disable translate NL to CR */ 1161da177e4SLinus Torvalds | IGNCR /* disable ignore CR */ 1171da177e4SLinus Torvalds | ICRNL /* disable translate CR to NL */ 1181da177e4SLinus Torvalds | IXON); /* disable enable XON/XOFF flow control */ 1191da177e4SLinus Torvalds 120998e8638SAlan Cox termios->c_oflag 1211da177e4SLinus Torvalds &= ~OPOST; /* disable postprocess output characters */ 1221da177e4SLinus Torvalds 123998e8638SAlan Cox termios->c_lflag 1241da177e4SLinus Torvalds &= ~(ECHO /* disable echo input characters */ 1251da177e4SLinus Torvalds | ECHONL /* disable echo new line */ 1261da177e4SLinus Torvalds | ICANON /* disable erase, kill, werase, and rprnt special characters */ 1271da177e4SLinus Torvalds | ISIG /* disable interrupt, quit, and suspend special characters */ 1281da177e4SLinus Torvalds | IEXTEN); /* disable non-POSIX special characters */ 1291da177e4SLinus Torvalds 130998e8638SAlan Cox termios->c_cflag 1311da177e4SLinus Torvalds &= ~(CSIZE /* no size */ 1321da177e4SLinus Torvalds | PARENB /* disable parity bit */ 1331da177e4SLinus Torvalds | CBAUD); /* clear current baud rate */ 1341da177e4SLinus Torvalds 135998e8638SAlan Cox termios->c_cflag 136998e8638SAlan Cox |= CS8; /* character size 8 bits */ 1371da177e4SLinus Torvalds 13895da310eSAlan Cox tty_encode_baud_rate(tty, 115200, 115200); 1391da177e4SLinus Torvalds } 1401da177e4SLinus Torvalds 141*10a6b9ceSGreg Kroah-Hartman module_usb_serial_driver(empeg_driver, serial_drivers); 1421da177e4SLinus Torvalds 1431da177e4SLinus Torvalds MODULE_AUTHOR(DRIVER_AUTHOR); 1441da177e4SLinus Torvalds MODULE_DESCRIPTION(DRIVER_DESC); 1451da177e4SLinus Torvalds MODULE_LICENSE("GPL"); 1461da177e4SLinus Torvalds 1471da177e4SLinus Torvalds module_param(debug, bool, S_IRUGO | S_IWUSR); 1481da177e4SLinus Torvalds MODULE_PARM_DESC(debug, "Debug enabled or not"); 149