2005-04-17 02:20:36 +04:00
/*
* USB Empeg empeg - car player driver
*
* Copyright ( C ) 2000 , 2001
* Gary Brubaker ( xavyer @ ix . netcom . com )
*
* Copyright ( C ) 1999 - 2001
* Greg Kroah - Hartman ( greg @ kroah . com )
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License , as published by
* the Free Software Foundation , version 2.
*
2008-07-22 14:11:11 +04:00
* See Documentation / usb / usb - serial . txt for more information on using this
* driver
2005-04-17 02:20:36 +04:00
*/
# include <linux/kernel.h>
# include <linux/errno.h>
# include <linux/init.h>
# include <linux/slab.h>
# include <linux/tty.h>
# include <linux/tty_driver.h>
# include <linux/tty_flip.h>
# include <linux/module.h>
# include <linux/spinlock.h>
2008-07-22 14:11:11 +04:00
# include <linux/uaccess.h>
2005-04-17 02:20:36 +04:00
# include <linux/usb.h>
2006-07-12 08:22:58 +04:00
# include <linux/usb/serial.h>
2005-04-17 02:20:36 +04:00
# define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Gary Brubaker <xavyer@ix.netcom.com>"
# define DRIVER_DESC "USB Empeg Mark I / II Driver"
# define EMPEG_VENDOR_ID 0x084f
# define EMPEG_PRODUCT_ID 0x0001
/* function prototypes for an empeg-car player */
2008-07-22 14:11:11 +04:00
static int empeg_startup ( struct usb_serial * serial ) ;
2009-09-20 00:13:33 +04:00
static void empeg_init_termios ( struct tty_struct * tty ) ;
2005-04-17 02:20:36 +04:00
2010-01-10 17:34:24 +03:00
static const struct usb_device_id id_table [ ] = {
2005-04-17 02:20:36 +04:00
{ USB_DEVICE ( EMPEG_VENDOR_ID , EMPEG_PRODUCT_ID ) } ,
{ } /* Terminating entry */
} ;
2008-07-22 14:11:11 +04:00
MODULE_DEVICE_TABLE ( usb , id_table ) ;
2005-04-17 02:20:36 +04:00
2005-06-21 08:15:16 +04:00
static struct usb_serial_driver empeg_device = {
2005-06-21 08:15:16 +04:00
. driver = {
. owner = THIS_MODULE ,
2005-06-21 08:15:16 +04:00
. name = " empeg " ,
2005-06-21 08:15:16 +04:00
} ,
2005-04-17 02:20:36 +04:00
. id_table = id_table ,
. num_ports = 1 ,
2010-05-15 19:53:45 +04:00
. bulk_out_size = 256 ,
. throttle = usb_serial_generic_throttle ,
. unthrottle = usb_serial_generic_unthrottle ,
2005-04-17 02:20:36 +04:00
. attach = empeg_startup ,
2009-09-20 00:13:33 +04:00
. init_termios = empeg_init_termios ,
2005-04-17 02:20:36 +04:00
} ;
2012-02-23 23:56:32 +04:00
static struct usb_serial_driver * const serial_drivers [ ] = {
& empeg_device , NULL
} ;
2010-05-15 19:53:45 +04:00
static int empeg_startup ( struct usb_serial * serial )
2005-04-17 02:20:36 +04:00
{
int r ;
if ( serial - > dev - > actconfig - > desc . bConfigurationValue ! = 1 ) {
2008-08-21 03:56:34 +04:00
dev_err ( & serial - > dev - > dev , " active config #%d != 1 ?? \n " ,
2005-04-17 02:20:36 +04:00
serial - > dev - > actconfig - > desc . bConfigurationValue ) ;
return - ENODEV ;
}
2012-05-04 03:43:59 +04:00
2008-07-22 14:11:11 +04:00
r = usb_reset_configuration ( serial - > dev ) ;
2005-04-17 02:20:36 +04:00
/* continue on with initialization */
return r ;
}
2009-09-20 00:13:33 +04:00
static void empeg_init_termios ( struct tty_struct * tty )
2005-04-17 02:20:36 +04:00
{
2012-07-14 18:31:47 +04:00
struct ktermios * termios = & tty - > termios ;
2005-04-17 02:20:36 +04:00
/*
2008-07-22 14:11:11 +04:00
* The empeg - car player wants these particular tty settings .
* You could , for example , change the baud rate , however the
* player only supports 115200 ( currently ) , so there is really
* no point in support for changes to the tty settings .
* ( at least for now )
*
* The default requirements for this device are :
*/
2007-10-18 12:24:19 +04:00
termios - > c_iflag
2005-04-17 02:20:36 +04:00
& = ~ ( IGNBRK /* disable ignore break */
| BRKINT /* disable break causes interrupt */
| PARMRK /* disable mark parity errors */
| ISTRIP /* disable clear high bit of input characters */
| INLCR /* disable translate NL to CR */
| IGNCR /* disable ignore CR */
| ICRNL /* disable translate CR to NL */
| IXON ) ; /* disable enable XON/XOFF flow control */
2007-10-18 12:24:19 +04:00
termios - > c_oflag
2005-04-17 02:20:36 +04:00
& = ~ OPOST ; /* disable postprocess output characters */
2007-10-18 12:24:19 +04:00
termios - > c_lflag
2005-04-17 02:20:36 +04:00
& = ~ ( ECHO /* disable echo input characters */
| ECHONL /* disable echo new line */
| ICANON /* disable erase, kill, werase, and rprnt special characters */
| ISIG /* disable interrupt, quit, and suspend special characters */
| IEXTEN ) ; /* disable non-POSIX special characters */
2007-10-18 12:24:19 +04:00
termios - > c_cflag
2005-04-17 02:20:36 +04:00
& = ~ ( CSIZE /* no size */
| PARENB /* disable parity bit */
| CBAUD ) ; /* clear current baud rate */
2007-10-18 12:24:19 +04:00
termios - > c_cflag
| = CS8 ; /* character size 8 bits */
2005-04-17 02:20:36 +04:00
2008-07-22 14:09:07 +04:00
tty_encode_baud_rate ( tty , 115200 , 115200 ) ;
2005-04-17 02:20:36 +04:00
}
2012-05-09 02:46:14 +04:00
module_usb_serial_driver ( serial_drivers , id_table ) ;
2005-04-17 02:20:36 +04:00
2008-07-22 14:11:11 +04:00
MODULE_AUTHOR ( DRIVER_AUTHOR ) ;
MODULE_DESCRIPTION ( DRIVER_DESC ) ;
2005-04-17 02:20:36 +04:00
MODULE_LICENSE ( " GPL " ) ;