Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * USB Empeg empeg-car player driver |
| 3 | * |
| 4 | * Copyright (C) 2000, 2001 |
| 5 | * Gary Brubaker (xavyer@ix.netcom.com) |
| 6 | * |
| 7 | * Copyright (C) 1999 - 2001 |
| 8 | * Greg Kroah-Hartman (greg@kroah.com) |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License, as published by |
| 12 | * the Free Software Foundation, version 2. |
| 13 | * |
Alan Cox | 93c4679 | 2008-07-22 11:11:11 +0100 | [diff] [blame] | 14 | * See Documentation/usb/usb-serial.txt for more information on using this |
| 15 | * driver |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | */ |
| 17 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include <linux/kernel.h> |
| 19 | #include <linux/errno.h> |
| 20 | #include <linux/init.h> |
| 21 | #include <linux/slab.h> |
| 22 | #include <linux/tty.h> |
| 23 | #include <linux/tty_driver.h> |
| 24 | #include <linux/tty_flip.h> |
| 25 | #include <linux/module.h> |
| 26 | #include <linux/spinlock.h> |
Alan Cox | 93c4679 | 2008-07-22 11:11:11 +0100 | [diff] [blame] | 27 | #include <linux/uaccess.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | #include <linux/usb.h> |
Greg Kroah-Hartman | a969888 | 2006-07-11 21:22:58 -0700 | [diff] [blame] | 29 | #include <linux/usb/serial.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
| 31 | static int debug; |
| 32 | |
| 33 | /* |
| 34 | * Version Information |
| 35 | */ |
Johan Hovold | 695aaae | 2010-05-15 17:53:45 +0200 | [diff] [blame] | 36 | #define DRIVER_VERSION "v1.3" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Gary Brubaker <xavyer@ix.netcom.com>" |
| 38 | #define DRIVER_DESC "USB Empeg Mark I/II Driver" |
| 39 | |
| 40 | #define EMPEG_VENDOR_ID 0x084f |
| 41 | #define EMPEG_PRODUCT_ID 0x0001 |
| 42 | |
| 43 | /* function prototypes for an empeg-car player */ |
Alan Cox | 93c4679 | 2008-07-22 11:11:11 +0100 | [diff] [blame] | 44 | static int empeg_startup(struct usb_serial *serial); |
Alan Cox | fe1ae7f | 2009-09-19 13:13:33 -0700 | [diff] [blame] | 45 | static void empeg_init_termios(struct tty_struct *tty); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | |
Németh Márton | 7d40d7e | 2010-01-10 15:34:24 +0100 | [diff] [blame] | 47 | static const struct usb_device_id id_table[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | { USB_DEVICE(EMPEG_VENDOR_ID, EMPEG_PRODUCT_ID) }, |
| 49 | { } /* Terminating entry */ |
| 50 | }; |
| 51 | |
Alan Cox | 93c4679 | 2008-07-22 11:11:11 +0100 | [diff] [blame] | 52 | MODULE_DEVICE_TABLE(usb, id_table); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | |
| 54 | static struct usb_driver empeg_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | .name = "empeg", |
| 56 | .probe = usb_serial_probe, |
| 57 | .disconnect = usb_serial_disconnect, |
| 58 | .id_table = id_table, |
Johan Hovold | 695aaae | 2010-05-15 17:53:45 +0200 | [diff] [blame] | 59 | .no_dynamic_id = 1, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | }; |
| 61 | |
Greg Kroah-Hartman | ea65370 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 62 | static struct usb_serial_driver empeg_device = { |
Greg Kroah-Hartman | 18fcac3 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 63 | .driver = { |
| 64 | .owner = THIS_MODULE, |
Greg Kroah-Hartman | 269bda1 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 65 | .name = "empeg", |
Greg Kroah-Hartman | 18fcac3 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 66 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | .id_table = id_table, |
Johan Hovold | 695aaae | 2010-05-15 17:53:45 +0200 | [diff] [blame] | 68 | .usb_driver = &empeg_driver, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | .num_ports = 1, |
Johan Hovold | 695aaae | 2010-05-15 17:53:45 +0200 | [diff] [blame] | 70 | .bulk_out_size = 256, |
| 71 | .throttle = usb_serial_generic_throttle, |
| 72 | .unthrottle = usb_serial_generic_unthrottle, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | .attach = empeg_startup, |
Alan Cox | fe1ae7f | 2009-09-19 13:13:33 -0700 | [diff] [blame] | 74 | .init_termios = empeg_init_termios, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | }; |
| 76 | |
Johan Hovold | 695aaae | 2010-05-15 17:53:45 +0200 | [diff] [blame] | 77 | static int empeg_startup(struct usb_serial *serial) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | { |
| 79 | int r; |
| 80 | |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 81 | dbg("%s", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | |
| 83 | if (serial->dev->actconfig->desc.bConfigurationValue != 1) { |
Greg Kroah-Hartman | 194343d | 2008-08-20 16:56:34 -0700 | [diff] [blame] | 84 | dev_err(&serial->dev->dev, "active config #%d != 1 ??\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | serial->dev->actconfig->desc.bConfigurationValue); |
| 86 | return -ENODEV; |
| 87 | } |
Harvey Harrison | 441b62c | 2008-03-03 16:08:34 -0800 | [diff] [blame] | 88 | dbg("%s - reset config", __func__); |
Alan Cox | 93c4679 | 2008-07-22 11:11:11 +0100 | [diff] [blame] | 89 | r = usb_reset_configuration(serial->dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | |
| 91 | /* continue on with initialization */ |
| 92 | return r; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | } |
| 94 | |
Alan Cox | fe1ae7f | 2009-09-19 13:13:33 -0700 | [diff] [blame] | 95 | static void empeg_init_termios(struct tty_struct *tty) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | { |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 97 | struct ktermios *termios = tty->termios; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | /* |
Alan Cox | 93c4679 | 2008-07-22 11:11:11 +0100 | [diff] [blame] | 100 | * The empeg-car player wants these particular tty settings. |
| 101 | * You could, for example, change the baud rate, however the |
| 102 | * player only supports 115200 (currently), so there is really |
| 103 | * no point in support for changes to the tty settings. |
| 104 | * (at least for now) |
| 105 | * |
| 106 | * The default requirements for this device are: |
| 107 | */ |
Alan Cox | 998e863 | 2007-10-18 01:24:19 -0700 | [diff] [blame] | 108 | termios->c_iflag |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | &= ~(IGNBRK /* disable ignore break */ |
| 110 | | BRKINT /* disable break causes interrupt */ |
| 111 | | PARMRK /* disable mark parity errors */ |
| 112 | | ISTRIP /* disable clear high bit of input characters */ |
| 113 | | INLCR /* disable translate NL to CR */ |
| 114 | | IGNCR /* disable ignore CR */ |
| 115 | | ICRNL /* disable translate CR to NL */ |
| 116 | | IXON); /* disable enable XON/XOFF flow control */ |
| 117 | |
Alan Cox | 998e863 | 2007-10-18 01:24:19 -0700 | [diff] [blame] | 118 | termios->c_oflag |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | &= ~OPOST; /* disable postprocess output characters */ |
| 120 | |
Alan Cox | 998e863 | 2007-10-18 01:24:19 -0700 | [diff] [blame] | 121 | termios->c_lflag |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | &= ~(ECHO /* disable echo input characters */ |
| 123 | | ECHONL /* disable echo new line */ |
| 124 | | ICANON /* disable erase, kill, werase, and rprnt special characters */ |
| 125 | | ISIG /* disable interrupt, quit, and suspend special characters */ |
| 126 | | IEXTEN); /* disable non-POSIX special characters */ |
| 127 | |
Alan Cox | 998e863 | 2007-10-18 01:24:19 -0700 | [diff] [blame] | 128 | termios->c_cflag |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | &= ~(CSIZE /* no size */ |
| 130 | | PARENB /* disable parity bit */ |
| 131 | | CBAUD); /* clear current baud rate */ |
| 132 | |
Alan Cox | 998e863 | 2007-10-18 01:24:19 -0700 | [diff] [blame] | 133 | termios->c_cflag |
| 134 | |= CS8; /* character size 8 bits */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | |
Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 136 | tty_encode_baud_rate(tty, 115200, 115200); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | } |
| 138 | |
Alan Cox | 93c4679 | 2008-07-22 11:11:11 +0100 | [diff] [blame] | 139 | static int __init empeg_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | { |
Johan Hovold | 695aaae | 2010-05-15 17:53:45 +0200 | [diff] [blame] | 141 | int retval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | |
| 143 | retval = usb_serial_register(&empeg_device); |
| 144 | if (retval) |
Johan Hovold | 695aaae | 2010-05-15 17:53:45 +0200 | [diff] [blame] | 145 | return retval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | retval = usb_register(&empeg_driver); |
Johan Hovold | 695aaae | 2010-05-15 17:53:45 +0200 | [diff] [blame] | 147 | if (retval) { |
| 148 | usb_serial_deregister(&empeg_device); |
| 149 | return retval; |
| 150 | } |
Greg Kroah-Hartman | c197a8d | 2008-08-18 13:21:04 -0700 | [diff] [blame] | 151 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
| 152 | DRIVER_DESC "\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | |
| 154 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | } |
| 156 | |
Alan Cox | 93c4679 | 2008-07-22 11:11:11 +0100 | [diff] [blame] | 157 | static void __exit empeg_exit(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | usb_deregister(&empeg_driver); |
Alan Cox | 93c4679 | 2008-07-22 11:11:11 +0100 | [diff] [blame] | 160 | usb_serial_deregister(&empeg_device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | |
| 164 | module_init(empeg_init); |
| 165 | module_exit(empeg_exit); |
| 166 | |
Alan Cox | 93c4679 | 2008-07-22 11:11:11 +0100 | [diff] [blame] | 167 | MODULE_AUTHOR(DRIVER_AUTHOR); |
| 168 | MODULE_DESCRIPTION(DRIVER_DESC); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | MODULE_LICENSE("GPL"); |
| 170 | |
| 171 | module_param(debug, bool, S_IRUGO | S_IWUSR); |
| 172 | MODULE_PARM_DESC(debug, "Debug enabled or not"); |