blob: 405e835e93dd93e0de7f26098ac1a61bd401d808 [file] [log] [blame]
Greg Kroah-Hartman5fd54ac2017-11-03 11:28:30 +01001// SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * USB Empeg empeg-car player driver
4 *
5 * Copyright (C) 2000, 2001
6 * Gary Brubaker (xavyer@ix.netcom.com)
7 *
8 * Copyright (C) 1999 - 2001
9 * Greg Kroah-Hartman (greg@kroah.com)
10 *
Mauro Carvalho Chehabecefae62019-06-18 18:05:38 -030011 * See Documentation/usb/usb-serial.rst for more information on using this
Alan Cox93c46792008-07-22 11:11:11 +010012 * driver
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 */
14
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include <linux/kernel.h>
16#include <linux/errno.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include <linux/slab.h>
18#include <linux/tty.h>
19#include <linux/tty_driver.h>
20#include <linux/tty_flip.h>
21#include <linux/module.h>
22#include <linux/spinlock.h>
Alan Cox93c46792008-07-22 11:11:11 +010023#include <linux/uaccess.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#include <linux/usb.h>
Greg Kroah-Hartmana9698882006-07-11 21:22:58 -070025#include <linux/usb/serial.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Gary Brubaker <xavyer@ix.netcom.com>"
28#define DRIVER_DESC "USB Empeg Mark I/II Driver"
29
30#define EMPEG_VENDOR_ID 0x084f
31#define EMPEG_PRODUCT_ID 0x0001
32
33/* function prototypes for an empeg-car player */
Alan Cox93c46792008-07-22 11:11:11 +010034static int empeg_startup(struct usb_serial *serial);
Alan Coxfe1ae7f2009-09-19 13:13:33 -070035static void empeg_init_termios(struct tty_struct *tty);
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
Németh Márton7d40d7e2010-01-10 15:34:24 +010037static const struct usb_device_id id_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 { USB_DEVICE(EMPEG_VENDOR_ID, EMPEG_PRODUCT_ID) },
39 { } /* Terminating entry */
40};
41
Alan Cox93c46792008-07-22 11:11:11 +010042MODULE_DEVICE_TABLE(usb, id_table);
Linus Torvalds1da177e2005-04-16 15:20:36 -070043
Greg Kroah-Hartmanea653702005-06-20 21:15:16 -070044static struct usb_serial_driver empeg_device = {
Greg Kroah-Hartman18fcac32005-06-20 21:15:16 -070045 .driver = {
46 .owner = THIS_MODULE,
Greg Kroah-Hartman269bda12005-06-20 21:15:16 -070047 .name = "empeg",
Greg Kroah-Hartman18fcac32005-06-20 21:15:16 -070048 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070049 .id_table = id_table,
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 .num_ports = 1,
Johan Hovold695aaae2010-05-15 17:53:45 +020051 .bulk_out_size = 256,
52 .throttle = usb_serial_generic_throttle,
53 .unthrottle = usb_serial_generic_unthrottle,
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 .attach = empeg_startup,
Alan Coxfe1ae7f2009-09-19 13:13:33 -070055 .init_termios = empeg_init_termios,
Linus Torvalds1da177e2005-04-16 15:20:36 -070056};
57
Alan Stern97b6b6d2012-02-23 14:56:32 -050058static struct usb_serial_driver * const serial_drivers[] = {
59 &empeg_device, NULL
60};
61
Johan Hovold695aaae2010-05-15 17:53:45 +020062static int empeg_startup(struct usb_serial *serial)
Linus Torvalds1da177e2005-04-16 15:20:36 -070063{
64 int r;
65
Linus Torvalds1da177e2005-04-16 15:20:36 -070066 if (serial->dev->actconfig->desc.bConfigurationValue != 1) {
Greg Kroah-Hartman194343d2008-08-20 16:56:34 -070067 dev_err(&serial->dev->dev, "active config #%d != 1 ??\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 serial->dev->actconfig->desc.bConfigurationValue);
69 return -ENODEV;
70 }
Greg Kroah-Hartman4e512ab2012-05-03 16:43:59 -070071
Alan Cox93c46792008-07-22 11:11:11 +010072 r = usb_reset_configuration(serial->dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -070073
74 /* continue on with initialization */
75 return r;
Linus Torvalds1da177e2005-04-16 15:20:36 -070076}
77
Alan Coxfe1ae7f2009-09-19 13:13:33 -070078static void empeg_init_termios(struct tty_struct *tty)
Linus Torvalds1da177e2005-04-16 15:20:36 -070079{
Alan Coxadc8d742012-07-14 15:31:47 +010080 struct ktermios *termios = &tty->termios;
Linus Torvalds1da177e2005-04-16 15:20:36 -070081
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 /*
Alan Cox93c46792008-07-22 11:11:11 +010083 * The empeg-car player wants these particular tty settings.
84 * You could, for example, change the baud rate, however the
85 * player only supports 115200 (currently), so there is really
86 * no point in support for changes to the tty settings.
87 * (at least for now)
88 *
89 * The default requirements for this device are:
90 */
Alan Cox998e8632007-10-18 01:24:19 -070091 termios->c_iflag
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 &= ~(IGNBRK /* disable ignore break */
93 | BRKINT /* disable break causes interrupt */
94 | PARMRK /* disable mark parity errors */
95 | ISTRIP /* disable clear high bit of input characters */
96 | INLCR /* disable translate NL to CR */
97 | IGNCR /* disable ignore CR */
98 | ICRNL /* disable translate CR to NL */
99 | IXON); /* disable enable XON/XOFF flow control */
100
Alan Cox998e8632007-10-18 01:24:19 -0700101 termios->c_oflag
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 &= ~OPOST; /* disable postprocess output characters */
103
Alan Cox998e8632007-10-18 01:24:19 -0700104 termios->c_lflag
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105 &= ~(ECHO /* disable echo input characters */
106 | ECHONL /* disable echo new line */
107 | ICANON /* disable erase, kill, werase, and rprnt special characters */
108 | ISIG /* disable interrupt, quit, and suspend special characters */
109 | IEXTEN); /* disable non-POSIX special characters */
110
Alan Cox998e8632007-10-18 01:24:19 -0700111 termios->c_cflag
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112 &= ~(CSIZE /* no size */
113 | PARENB /* disable parity bit */
114 | CBAUD); /* clear current baud rate */
115
Alan Cox998e8632007-10-18 01:24:19 -0700116 termios->c_cflag
117 |= CS8; /* character size 8 bits */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118
Alan Cox95da3102008-07-22 11:09:07 +0100119 tty_encode_baud_rate(tty, 115200, 115200);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120}
121
Greg Kroah-Hartman68e24112012-05-08 15:46:14 -0700122module_usb_serial_driver(serial_drivers, id_table);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123
Alan Cox93c46792008-07-22 11:11:11 +0100124MODULE_AUTHOR(DRIVER_AUTHOR);
125MODULE_DESCRIPTION(DRIVER_DESC);
Johan Hovold627cfa82017-11-03 18:12:08 +0100126MODULE_LICENSE("GPL v2");