| 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 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | /* | 
|  | 32 | * Version Information | 
|  | 33 | */ | 
| Johan Hovold | 695aaae | 2010-05-15 17:53:45 +0200 | [diff] [blame] | 34 | #define DRIVER_VERSION "v1.3" | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Gary Brubaker <xavyer@ix.netcom.com>" | 
|  | 36 | #define DRIVER_DESC "USB Empeg Mark I/II Driver" | 
|  | 37 |  | 
|  | 38 | #define EMPEG_VENDOR_ID			0x084f | 
|  | 39 | #define EMPEG_PRODUCT_ID		0x0001 | 
|  | 40 |  | 
|  | 41 | /* function prototypes for an empeg-car player */ | 
| Alan Cox | 93c4679 | 2008-07-22 11:11:11 +0100 | [diff] [blame] | 42 | static int  empeg_startup(struct usb_serial *serial); | 
| Alan Cox | fe1ae7f | 2009-09-19 13:13:33 -0700 | [diff] [blame] | 43 | static void empeg_init_termios(struct tty_struct *tty); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 |  | 
| Németh Márton | 7d40d7e | 2010-01-10 15:34:24 +0100 | [diff] [blame] | 45 | static const struct usb_device_id id_table[] = { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | { USB_DEVICE(EMPEG_VENDOR_ID, EMPEG_PRODUCT_ID) }, | 
|  | 47 | { }					/* Terminating entry */ | 
|  | 48 | }; | 
|  | 49 |  | 
| Alan Cox | 93c4679 | 2008-07-22 11:11:11 +0100 | [diff] [blame] | 50 | MODULE_DEVICE_TABLE(usb, id_table); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 |  | 
| Greg Kroah-Hartman | ea65370 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 52 | static struct usb_serial_driver empeg_device = { | 
| Greg Kroah-Hartman | 18fcac3 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 53 | .driver = { | 
|  | 54 | .owner =	THIS_MODULE, | 
| Greg Kroah-Hartman | 269bda1 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 55 | .name =		"empeg", | 
| Greg Kroah-Hartman | 18fcac3 | 2005-06-20 21:15:16 -0700 | [diff] [blame] | 56 | }, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | .id_table =		id_table, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | .num_ports =		1, | 
| Johan Hovold | 695aaae | 2010-05-15 17:53:45 +0200 | [diff] [blame] | 59 | .bulk_out_size =	256, | 
|  | 60 | .throttle =		usb_serial_generic_throttle, | 
|  | 61 | .unthrottle =		usb_serial_generic_unthrottle, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | .attach =		empeg_startup, | 
| Alan Cox | fe1ae7f | 2009-09-19 13:13:33 -0700 | [diff] [blame] | 63 | .init_termios =		empeg_init_termios, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | }; | 
|  | 65 |  | 
| Alan Stern | 97b6b6d | 2012-02-23 14:56:32 -0500 | [diff] [blame] | 66 | static struct usb_serial_driver * const serial_drivers[] = { | 
|  | 67 | &empeg_device, NULL | 
|  | 68 | }; | 
|  | 69 |  | 
| Johan Hovold | 695aaae | 2010-05-15 17:53:45 +0200 | [diff] [blame] | 70 | static int empeg_startup(struct usb_serial *serial) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | { | 
|  | 72 | int r; | 
|  | 73 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | if (serial->dev->actconfig->desc.bConfigurationValue != 1) { | 
| Greg Kroah-Hartman | 194343d | 2008-08-20 16:56:34 -0700 | [diff] [blame] | 75 | dev_err(&serial->dev->dev, "active config #%d != 1 ??\n", | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | serial->dev->actconfig->desc.bConfigurationValue); | 
|  | 77 | return -ENODEV; | 
|  | 78 | } | 
| Greg Kroah-Hartman | 4e512ab | 2012-05-03 16:43:59 -0700 | [diff] [blame] | 79 |  | 
| Alan Cox | 93c4679 | 2008-07-22 11:11:11 +0100 | [diff] [blame] | 80 | r = usb_reset_configuration(serial->dev); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 |  | 
|  | 82 | /* continue on with initialization */ | 
|  | 83 | return r; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | } | 
|  | 85 |  | 
| Alan Cox | fe1ae7f | 2009-09-19 13:13:33 -0700 | [diff] [blame] | 86 | static void empeg_init_termios(struct tty_struct *tty) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | { | 
| Alan Cox | adc8d74 | 2012-07-14 15:31:47 +0100 | [diff] [blame] | 88 | struct ktermios *termios = &tty->termios; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | /* | 
| Alan Cox | 93c4679 | 2008-07-22 11:11:11 +0100 | [diff] [blame] | 91 | * The empeg-car player wants these particular tty settings. | 
|  | 92 | * You could, for example, change the baud rate, however the | 
|  | 93 | * player only supports 115200 (currently), so there is really | 
|  | 94 | * no point in support for changes to the tty settings. | 
|  | 95 | * (at least for now) | 
|  | 96 | * | 
|  | 97 | * The default requirements for this device are: | 
|  | 98 | */ | 
| Alan Cox | 998e863 | 2007-10-18 01:24:19 -0700 | [diff] [blame] | 99 | termios->c_iflag | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | &= ~(IGNBRK	/* disable ignore break */ | 
|  | 101 | | BRKINT	/* disable break causes interrupt */ | 
|  | 102 | | PARMRK	/* disable mark parity errors */ | 
|  | 103 | | ISTRIP	/* disable clear high bit of input characters */ | 
|  | 104 | | INLCR		/* disable translate NL to CR */ | 
|  | 105 | | IGNCR		/* disable ignore CR */ | 
|  | 106 | | ICRNL		/* disable translate CR to NL */ | 
|  | 107 | | IXON);	/* disable enable XON/XOFF flow control */ | 
|  | 108 |  | 
| Alan Cox | 998e863 | 2007-10-18 01:24:19 -0700 | [diff] [blame] | 109 | termios->c_oflag | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | &= ~OPOST;	/* disable postprocess output characters */ | 
|  | 111 |  | 
| Alan Cox | 998e863 | 2007-10-18 01:24:19 -0700 | [diff] [blame] | 112 | termios->c_lflag | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | &= ~(ECHO	/* disable echo input characters */ | 
|  | 114 | | ECHONL	/* disable echo new line */ | 
|  | 115 | | ICANON	/* disable erase, kill, werase, and rprnt special characters */ | 
|  | 116 | | ISIG		/* disable interrupt, quit, and suspend special characters */ | 
|  | 117 | | IEXTEN);	/* disable non-POSIX special characters */ | 
|  | 118 |  | 
| Alan Cox | 998e863 | 2007-10-18 01:24:19 -0700 | [diff] [blame] | 119 | termios->c_cflag | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | &= ~(CSIZE	/* no size */ | 
|  | 121 | | PARENB	/* disable parity bit */ | 
|  | 122 | | CBAUD);	/* clear current baud rate */ | 
|  | 123 |  | 
| Alan Cox | 998e863 | 2007-10-18 01:24:19 -0700 | [diff] [blame] | 124 | termios->c_cflag | 
|  | 125 | |= CS8;		/* character size 8 bits */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 |  | 
| Alan Cox | 95da310 | 2008-07-22 11:09:07 +0100 | [diff] [blame] | 127 | tty_encode_baud_rate(tty, 115200, 115200); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | } | 
|  | 129 |  | 
| Greg Kroah-Hartman | 68e2411 | 2012-05-08 15:46:14 -0700 | [diff] [blame] | 130 | module_usb_serial_driver(serial_drivers, id_table); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 |  | 
| Alan Cox | 93c4679 | 2008-07-22 11:11:11 +0100 | [diff] [blame] | 132 | MODULE_AUTHOR(DRIVER_AUTHOR); | 
|  | 133 | MODULE_DESCRIPTION(DRIVER_DESC); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | MODULE_LICENSE("GPL"); |