blob: cdf61dd0731837fb0acf62fc6cd44f0a199ef38f [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>
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 Cox93c46792008-07-22 11:11:11 +010027#include <linux/uaccess.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028#include <linux/usb.h>
Greg Kroah-Hartmana9698882006-07-11 21:22:58 -070029#include <linux/usb/serial.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
Rusty Russell90ab5ee2012-01-13 09:32:20 +103031static bool debug;
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
33/*
34 * Version Information
35 */
Johan Hovold695aaae2010-05-15 17:53:45 +020036#define DRIVER_VERSION "v1.3"
Linus Torvalds1da177e2005-04-16 15:20:36 -070037#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 Cox93c46792008-07-22 11:11:11 +010044static int empeg_startup(struct usb_serial *serial);
Alan Coxfe1ae7f2009-09-19 13:13:33 -070045static void empeg_init_termios(struct tty_struct *tty);
Linus Torvalds1da177e2005-04-16 15:20:36 -070046
Németh Márton7d40d7e2010-01-10 15:34:24 +010047static const struct usb_device_id id_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 { USB_DEVICE(EMPEG_VENDOR_ID, EMPEG_PRODUCT_ID) },
49 { } /* Terminating entry */
50};
51
Alan Cox93c46792008-07-22 11:11:11 +010052MODULE_DEVICE_TABLE(usb, id_table);
Linus Torvalds1da177e2005-04-16 15:20:36 -070053
Greg Kroah-Hartmanea653702005-06-20 21:15:16 -070054static struct usb_serial_driver empeg_device = {
Greg Kroah-Hartman18fcac32005-06-20 21:15:16 -070055 .driver = {
56 .owner = THIS_MODULE,
Greg Kroah-Hartman269bda12005-06-20 21:15:16 -070057 .name = "empeg",
Greg Kroah-Hartman18fcac32005-06-20 21:15:16 -070058 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 .id_table = id_table,
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 .num_ports = 1,
Johan Hovold695aaae2010-05-15 17:53:45 +020061 .bulk_out_size = 256,
62 .throttle = usb_serial_generic_throttle,
63 .unthrottle = usb_serial_generic_unthrottle,
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 .attach = empeg_startup,
Alan Coxfe1ae7f2009-09-19 13:13:33 -070065 .init_termios = empeg_init_termios,
Linus Torvalds1da177e2005-04-16 15:20:36 -070066};
67
Alan Stern97b6b6d2012-02-23 14:56:32 -050068static struct usb_serial_driver * const serial_drivers[] = {
69 &empeg_device, NULL
70};
71
Johan Hovold695aaae2010-05-15 17:53:45 +020072static int empeg_startup(struct usb_serial *serial)
Linus Torvalds1da177e2005-04-16 15:20:36 -070073{
74 int r;
75
Linus Torvalds1da177e2005-04-16 15:20:36 -070076 if (serial->dev->actconfig->desc.bConfigurationValue != 1) {
Greg Kroah-Hartman194343d2008-08-20 16:56:34 -070077 dev_err(&serial->dev->dev, "active config #%d != 1 ??\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 serial->dev->actconfig->desc.bConfigurationValue);
79 return -ENODEV;
80 }
Greg Kroah-Hartman4e512ab2012-05-03 16:43:59 -070081
Alan Cox93c46792008-07-22 11:11:11 +010082 r = usb_reset_configuration(serial->dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -070083
84 /* continue on with initialization */
85 return r;
Linus Torvalds1da177e2005-04-16 15:20:36 -070086}
87
Alan Coxfe1ae7f2009-09-19 13:13:33 -070088static void empeg_init_termios(struct tty_struct *tty)
Linus Torvalds1da177e2005-04-16 15:20:36 -070089{
Alan Cox95da3102008-07-22 11:09:07 +010090 struct ktermios *termios = tty->termios;
Linus Torvalds1da177e2005-04-16 15:20:36 -070091
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 /*
Alan Cox93c46792008-07-22 11:11:11 +010093 * The empeg-car player wants these particular tty settings.
94 * You could, for example, change the baud rate, however the
95 * player only supports 115200 (currently), so there is really
96 * no point in support for changes to the tty settings.
97 * (at least for now)
98 *
99 * The default requirements for this device are:
100 */
Alan Cox998e8632007-10-18 01:24:19 -0700101 termios->c_iflag
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 &= ~(IGNBRK /* disable ignore break */
103 | BRKINT /* disable break causes interrupt */
104 | PARMRK /* disable mark parity errors */
105 | ISTRIP /* disable clear high bit of input characters */
106 | INLCR /* disable translate NL to CR */
107 | IGNCR /* disable ignore CR */
108 | ICRNL /* disable translate CR to NL */
109 | IXON); /* disable enable XON/XOFF flow control */
110
Alan Cox998e8632007-10-18 01:24:19 -0700111 termios->c_oflag
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112 &= ~OPOST; /* disable postprocess output characters */
113
Alan Cox998e8632007-10-18 01:24:19 -0700114 termios->c_lflag
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 &= ~(ECHO /* disable echo input characters */
116 | ECHONL /* disable echo new line */
117 | ICANON /* disable erase, kill, werase, and rprnt special characters */
118 | ISIG /* disable interrupt, quit, and suspend special characters */
119 | IEXTEN); /* disable non-POSIX special characters */
120
Alan Cox998e8632007-10-18 01:24:19 -0700121 termios->c_cflag
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122 &= ~(CSIZE /* no size */
123 | PARENB /* disable parity bit */
124 | CBAUD); /* clear current baud rate */
125
Alan Cox998e8632007-10-18 01:24:19 -0700126 termios->c_cflag
127 |= CS8; /* character size 8 bits */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128
Alan Cox95da3102008-07-22 11:09:07 +0100129 tty_encode_baud_rate(tty, 115200, 115200);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130}
131
Greg Kroah-Hartman68e24112012-05-08 15:46:14 -0700132module_usb_serial_driver(serial_drivers, id_table);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133
Alan Cox93c46792008-07-22 11:11:11 +0100134MODULE_AUTHOR(DRIVER_AUTHOR);
135MODULE_DESCRIPTION(DRIVER_DESC);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136MODULE_LICENSE("GPL");
137
138module_param(debug, bool, S_IRUGO | S_IWUSR);
139MODULE_PARM_DESC(debug, "Debug enabled or not");