blob: 504b5585ea4500bbea780b520cff4df748fd089b [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
31static int debug;
32
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
54static struct usb_driver empeg_driver = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070055 .name = "empeg",
56 .probe = usb_serial_probe,
57 .disconnect = usb_serial_disconnect,
58 .id_table = id_table,
Johan Hovold695aaae2010-05-15 17:53:45 +020059 .no_dynamic_id = 1,
Linus Torvalds1da177e2005-04-16 15:20:36 -070060};
61
Greg Kroah-Hartmanea653702005-06-20 21:15:16 -070062static struct usb_serial_driver empeg_device = {
Greg Kroah-Hartman18fcac32005-06-20 21:15:16 -070063 .driver = {
64 .owner = THIS_MODULE,
Greg Kroah-Hartman269bda12005-06-20 21:15:16 -070065 .name = "empeg",
Greg Kroah-Hartman18fcac32005-06-20 21:15:16 -070066 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 .id_table = id_table,
Johan Hovold695aaae2010-05-15 17:53:45 +020068 .usb_driver = &empeg_driver,
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 .num_ports = 1,
Johan Hovold695aaae2010-05-15 17:53:45 +020070 .bulk_out_size = 256,
71 .throttle = usb_serial_generic_throttle,
72 .unthrottle = usb_serial_generic_unthrottle,
Linus Torvalds1da177e2005-04-16 15:20:36 -070073 .attach = empeg_startup,
Alan Coxfe1ae7f2009-09-19 13:13:33 -070074 .init_termios = empeg_init_termios,
Linus Torvalds1da177e2005-04-16 15:20:36 -070075};
76
Johan Hovold695aaae2010-05-15 17:53:45 +020077static int empeg_startup(struct usb_serial *serial)
Linus Torvalds1da177e2005-04-16 15:20:36 -070078{
79 int r;
80
Harvey Harrison441b62c2008-03-03 16:08:34 -080081 dbg("%s", __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -070082
83 if (serial->dev->actconfig->desc.bConfigurationValue != 1) {
Greg Kroah-Hartman194343d2008-08-20 16:56:34 -070084 dev_err(&serial->dev->dev, "active config #%d != 1 ??\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -070085 serial->dev->actconfig->desc.bConfigurationValue);
86 return -ENODEV;
87 }
Harvey Harrison441b62c2008-03-03 16:08:34 -080088 dbg("%s - reset config", __func__);
Alan Cox93c46792008-07-22 11:11:11 +010089 r = usb_reset_configuration(serial->dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -070090
91 /* continue on with initialization */
92 return r;
Linus Torvalds1da177e2005-04-16 15:20:36 -070093}
94
Alan Coxfe1ae7f2009-09-19 13:13:33 -070095static void empeg_init_termios(struct tty_struct *tty)
Linus Torvalds1da177e2005-04-16 15:20:36 -070096{
Alan Cox95da3102008-07-22 11:09:07 +010097 struct ktermios *termios = tty->termios;
Linus Torvalds1da177e2005-04-16 15:20:36 -070098
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 /*
Alan Cox93c46792008-07-22 11:11:11 +0100100 * The empeg-car player wants these particular tty settings.
101 * You could, for example, change the baud rate, however the
102 * player only supports 115200 (currently), so there is really
103 * no point in support for changes to the tty settings.
104 * (at least for now)
105 *
106 * The default requirements for this device are:
107 */
Alan Cox998e8632007-10-18 01:24:19 -0700108 termios->c_iflag
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109 &= ~(IGNBRK /* disable ignore break */
110 | BRKINT /* disable break causes interrupt */
111 | PARMRK /* disable mark parity errors */
112 | ISTRIP /* disable clear high bit of input characters */
113 | INLCR /* disable translate NL to CR */
114 | IGNCR /* disable ignore CR */
115 | ICRNL /* disable translate CR to NL */
116 | IXON); /* disable enable XON/XOFF flow control */
117
Alan Cox998e8632007-10-18 01:24:19 -0700118 termios->c_oflag
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119 &= ~OPOST; /* disable postprocess output characters */
120
Alan Cox998e8632007-10-18 01:24:19 -0700121 termios->c_lflag
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122 &= ~(ECHO /* disable echo input characters */
123 | ECHONL /* disable echo new line */
124 | ICANON /* disable erase, kill, werase, and rprnt special characters */
125 | ISIG /* disable interrupt, quit, and suspend special characters */
126 | IEXTEN); /* disable non-POSIX special characters */
127
Alan Cox998e8632007-10-18 01:24:19 -0700128 termios->c_cflag
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129 &= ~(CSIZE /* no size */
130 | PARENB /* disable parity bit */
131 | CBAUD); /* clear current baud rate */
132
Alan Cox998e8632007-10-18 01:24:19 -0700133 termios->c_cflag
134 |= CS8; /* character size 8 bits */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135
Alan Cox95da3102008-07-22 11:09:07 +0100136 tty_encode_baud_rate(tty, 115200, 115200);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137}
138
Alan Cox93c46792008-07-22 11:11:11 +0100139static int __init empeg_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140{
Johan Hovold695aaae2010-05-15 17:53:45 +0200141 int retval;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142
143 retval = usb_serial_register(&empeg_device);
144 if (retval)
Johan Hovold695aaae2010-05-15 17:53:45 +0200145 return retval;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146 retval = usb_register(&empeg_driver);
Johan Hovold695aaae2010-05-15 17:53:45 +0200147 if (retval) {
148 usb_serial_deregister(&empeg_device);
149 return retval;
150 }
Greg Kroah-Hartmanc197a8d2008-08-18 13:21:04 -0700151 printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
152 DRIVER_DESC "\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153
154 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155}
156
Alan Cox93c46792008-07-22 11:11:11 +0100157static void __exit empeg_exit(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159 usb_deregister(&empeg_driver);
Alan Cox93c46792008-07-22 11:11:11 +0100160 usb_serial_deregister(&empeg_device);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161}
162
163
164module_init(empeg_init);
165module_exit(empeg_exit);
166
Alan Cox93c46792008-07-22 11:11:11 +0100167MODULE_AUTHOR(DRIVER_AUTHOR);
168MODULE_DESCRIPTION(DRIVER_DESC);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169MODULE_LICENSE("GPL");
170
171module_param(debug, bool, S_IRUGO | S_IWUSR);
172MODULE_PARM_DESC(debug, "Debug enabled or not");