blob: 90e603d5f6603ca6e5d3bb48aff735cb642d48e4 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 Cox93c46792008-07-22 11:11:11 +010014 * See Documentation/usb/usb-serial.txt for more information on using this
15 * driver
Linus Torvalds1da177e2005-04-16 15:20:36 -070016 */
17
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <linux/kernel.h>
19#include <linux/errno.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include <linux/slab.h>
21#include <linux/tty.h>
22#include <linux/tty_driver.h>
23#include <linux/tty_flip.h>
24#include <linux/module.h>
25#include <linux/spinlock.h>
Alan Cox93c46792008-07-22 11:11:11 +010026#include <linux/uaccess.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#include <linux/usb.h>
Greg Kroah-Hartmana9698882006-07-11 21:22:58 -070028#include <linux/usb/serial.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070029
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Gary Brubaker <xavyer@ix.netcom.com>"
31#define DRIVER_DESC "USB Empeg Mark I/II Driver"
32
33#define EMPEG_VENDOR_ID 0x084f
34#define EMPEG_PRODUCT_ID 0x0001
35
36/* function prototypes for an empeg-car player */
Alan Cox93c46792008-07-22 11:11:11 +010037static int empeg_startup(struct usb_serial *serial);
Alan Coxfe1ae7f2009-09-19 13:13:33 -070038static void empeg_init_termios(struct tty_struct *tty);
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
Németh Márton7d40d7e2010-01-10 15:34:24 +010040static const struct usb_device_id id_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070041 { USB_DEVICE(EMPEG_VENDOR_ID, EMPEG_PRODUCT_ID) },
42 { } /* Terminating entry */
43};
44
Alan Cox93c46792008-07-22 11:11:11 +010045MODULE_DEVICE_TABLE(usb, id_table);
Linus Torvalds1da177e2005-04-16 15:20:36 -070046
Greg Kroah-Hartmanea653702005-06-20 21:15:16 -070047static struct usb_serial_driver empeg_device = {
Greg Kroah-Hartman18fcac32005-06-20 21:15:16 -070048 .driver = {
49 .owner = THIS_MODULE,
Greg Kroah-Hartman269bda12005-06-20 21:15:16 -070050 .name = "empeg",
Greg Kroah-Hartman18fcac32005-06-20 21:15:16 -070051 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070052 .id_table = id_table,
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 .num_ports = 1,
Johan Hovold695aaae2010-05-15 17:53:45 +020054 .bulk_out_size = 256,
55 .throttle = usb_serial_generic_throttle,
56 .unthrottle = usb_serial_generic_unthrottle,
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 .attach = empeg_startup,
Alan Coxfe1ae7f2009-09-19 13:13:33 -070058 .init_termios = empeg_init_termios,
Linus Torvalds1da177e2005-04-16 15:20:36 -070059};
60
Alan Stern97b6b6d2012-02-23 14:56:32 -050061static struct usb_serial_driver * const serial_drivers[] = {
62 &empeg_device, NULL
63};
64
Johan Hovold695aaae2010-05-15 17:53:45 +020065static int empeg_startup(struct usb_serial *serial)
Linus Torvalds1da177e2005-04-16 15:20:36 -070066{
67 int r;
68
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 if (serial->dev->actconfig->desc.bConfigurationValue != 1) {
Greg Kroah-Hartman194343d2008-08-20 16:56:34 -070070 dev_err(&serial->dev->dev, "active config #%d != 1 ??\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -070071 serial->dev->actconfig->desc.bConfigurationValue);
72 return -ENODEV;
73 }
Greg Kroah-Hartman4e512ab2012-05-03 16:43:59 -070074
Alan Cox93c46792008-07-22 11:11:11 +010075 r = usb_reset_configuration(serial->dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -070076
77 /* continue on with initialization */
78 return r;
Linus Torvalds1da177e2005-04-16 15:20:36 -070079}
80
Alan Coxfe1ae7f2009-09-19 13:13:33 -070081static void empeg_init_termios(struct tty_struct *tty)
Linus Torvalds1da177e2005-04-16 15:20:36 -070082{
Alan Coxadc8d742012-07-14 15:31:47 +010083 struct ktermios *termios = &tty->termios;
Linus Torvalds1da177e2005-04-16 15:20:36 -070084
Linus Torvalds1da177e2005-04-16 15:20:36 -070085 /*
Alan Cox93c46792008-07-22 11:11:11 +010086 * The empeg-car player wants these particular tty settings.
87 * You could, for example, change the baud rate, however the
88 * player only supports 115200 (currently), so there is really
89 * no point in support for changes to the tty settings.
90 * (at least for now)
91 *
92 * The default requirements for this device are:
93 */
Alan Cox998e8632007-10-18 01:24:19 -070094 termios->c_iflag
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 &= ~(IGNBRK /* disable ignore break */
96 | BRKINT /* disable break causes interrupt */
97 | PARMRK /* disable mark parity errors */
98 | ISTRIP /* disable clear high bit of input characters */
99 | INLCR /* disable translate NL to CR */
100 | IGNCR /* disable ignore CR */
101 | ICRNL /* disable translate CR to NL */
102 | IXON); /* disable enable XON/XOFF flow control */
103
Alan Cox998e8632007-10-18 01:24:19 -0700104 termios->c_oflag
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105 &= ~OPOST; /* disable postprocess output characters */
106
Alan Cox998e8632007-10-18 01:24:19 -0700107 termios->c_lflag
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 &= ~(ECHO /* disable echo input characters */
109 | ECHONL /* disable echo new line */
110 | ICANON /* disable erase, kill, werase, and rprnt special characters */
111 | ISIG /* disable interrupt, quit, and suspend special characters */
112 | IEXTEN); /* disable non-POSIX special characters */
113
Alan Cox998e8632007-10-18 01:24:19 -0700114 termios->c_cflag
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 &= ~(CSIZE /* no size */
116 | PARENB /* disable parity bit */
117 | CBAUD); /* clear current baud rate */
118
Alan Cox998e8632007-10-18 01:24:19 -0700119 termios->c_cflag
120 |= CS8; /* character size 8 bits */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121
Alan Cox95da3102008-07-22 11:09:07 +0100122 tty_encode_baud_rate(tty, 115200, 115200);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123}
124
Greg Kroah-Hartman68e24112012-05-08 15:46:14 -0700125module_usb_serial_driver(serial_drivers, id_table);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126
Alan Cox93c46792008-07-22 11:11:11 +0100127MODULE_AUTHOR(DRIVER_AUTHOR);
128MODULE_DESCRIPTION(DRIVER_DESC);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129MODULE_LICENSE("GPL");