2017-11-03 17:28:30 +07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2005-04-17 05:20:36 +07: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)
|
|
|
|
*
|
2008-07-22 17:11:11 +07:00
|
|
|
* See Documentation/usb/usb-serial.txt for more information on using this
|
|
|
|
* driver
|
2005-04-17 05:20:36 +07:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/errno.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 17:11:11 +07:00
|
|
|
#include <linux/uaccess.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <linux/usb.h>
|
2006-07-12 11:22:58 +07:00
|
|
|
#include <linux/usb/serial.h>
|
2005-04-17 05:20:36 +07: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 17:11:11 +07:00
|
|
|
static int empeg_startup(struct usb_serial *serial);
|
2009-09-20 03:13:33 +07:00
|
|
|
static void empeg_init_termios(struct tty_struct *tty);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2010-01-10 21:34:24 +07:00
|
|
|
static const struct usb_device_id id_table[] = {
|
2005-04-17 05:20:36 +07:00
|
|
|
{ USB_DEVICE(EMPEG_VENDOR_ID, EMPEG_PRODUCT_ID) },
|
|
|
|
{ } /* Terminating entry */
|
|
|
|
};
|
|
|
|
|
2008-07-22 17:11:11 +07:00
|
|
|
MODULE_DEVICE_TABLE(usb, id_table);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-06-21 11:15:16 +07:00
|
|
|
static struct usb_serial_driver empeg_device = {
|
2005-06-21 11:15:16 +07:00
|
|
|
.driver = {
|
|
|
|
.owner = THIS_MODULE,
|
2005-06-21 11:15:16 +07:00
|
|
|
.name = "empeg",
|
2005-06-21 11:15:16 +07:00
|
|
|
},
|
2005-04-17 05:20:36 +07:00
|
|
|
.id_table = id_table,
|
|
|
|
.num_ports = 1,
|
2010-05-15 22:53:45 +07:00
|
|
|
.bulk_out_size = 256,
|
|
|
|
.throttle = usb_serial_generic_throttle,
|
|
|
|
.unthrottle = usb_serial_generic_unthrottle,
|
2005-04-17 05:20:36 +07:00
|
|
|
.attach = empeg_startup,
|
2009-09-20 03:13:33 +07:00
|
|
|
.init_termios = empeg_init_termios,
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
2012-02-24 02:56:32 +07:00
|
|
|
static struct usb_serial_driver * const serial_drivers[] = {
|
|
|
|
&empeg_device, NULL
|
|
|
|
};
|
|
|
|
|
2010-05-15 22:53:45 +07:00
|
|
|
static int empeg_startup(struct usb_serial *serial)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
int r;
|
|
|
|
|
|
|
|
if (serial->dev->actconfig->desc.bConfigurationValue != 1) {
|
2008-08-21 06:56:34 +07:00
|
|
|
dev_err(&serial->dev->dev, "active config #%d != 1 ??\n",
|
2005-04-17 05:20:36 +07:00
|
|
|
serial->dev->actconfig->desc.bConfigurationValue);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
2012-05-04 06:43:59 +07:00
|
|
|
|
2008-07-22 17:11:11 +07:00
|
|
|
r = usb_reset_configuration(serial->dev);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* continue on with initialization */
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2009-09-20 03:13:33 +07:00
|
|
|
static void empeg_init_termios(struct tty_struct *tty)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2012-07-14 21:31:47 +07:00
|
|
|
struct ktermios *termios = &tty->termios;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/*
|
2008-07-22 17:11:11 +07: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 15:24:19 +07:00
|
|
|
termios->c_iflag
|
2005-04-17 05:20:36 +07: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 15:24:19 +07:00
|
|
|
termios->c_oflag
|
2005-04-17 05:20:36 +07:00
|
|
|
&= ~OPOST; /* disable postprocess output characters */
|
|
|
|
|
2007-10-18 15:24:19 +07:00
|
|
|
termios->c_lflag
|
2005-04-17 05:20:36 +07: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 15:24:19 +07:00
|
|
|
termios->c_cflag
|
2005-04-17 05:20:36 +07:00
|
|
|
&= ~(CSIZE /* no size */
|
|
|
|
| PARENB /* disable parity bit */
|
|
|
|
| CBAUD); /* clear current baud rate */
|
|
|
|
|
2007-10-18 15:24:19 +07:00
|
|
|
termios->c_cflag
|
|
|
|
|= CS8; /* character size 8 bits */
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-07-22 17:09:07 +07:00
|
|
|
tty_encode_baud_rate(tty, 115200, 115200);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2012-05-09 05:46:14 +07:00
|
|
|
module_usb_serial_driver(serial_drivers, id_table);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-07-22 17:11:11 +07:00
|
|
|
MODULE_AUTHOR(DRIVER_AUTHOR);
|
|
|
|
MODULE_DESCRIPTION(DRIVER_DESC);
|
2017-11-04 00:12:08 +07:00
|
|
|
MODULE_LICENSE("GPL v2");
|