projects/linux·blob master · refs

122 lines · 3.3 KiB

1// SPDX-License-Identifier: GPL-2.0
2/*
3 * USB Empeg empeg-car player driver
4 *
5 * Copyright (C) 2000, 2001
6 * Gary Brubaker ([email protected])
7 *
8 * Copyright (C) 1999 - 2001
9 * Greg Kroah-Hartman ([email protected])
10 *
11 * See Documentation/usb/usb-serial.rst for more information on using this
12 * driver
13 */
14
15#include <linux/kernel.h>
16#include <linux/errno.h>
17#include <linux/slab.h>
18#include <linux/tty.h>
19#include <linux/module.h>
20#include <linux/spinlock.h>
21#include <linux/usb.h>
22#include <linux/usb/serial.h>
23
24#define DRIVER_AUTHOR "Greg Kroah-Hartman <[email protected]>, Gary Brubaker <[email protected]>"
25#define DRIVER_DESC "USB Empeg Mark I/II Driver"
26
27#define EMPEG_VENDOR_ID 0x084f
28#define EMPEG_PRODUCT_ID 0x0001
29
30/* function prototypes for an empeg-car player */
31static int empeg_startup(struct usb_serial *serial);
32static void empeg_init_termios(struct tty_struct *tty);
33
34static const struct usb_device_id id_table[] = {
35 { USB_DEVICE(EMPEG_VENDOR_ID, EMPEG_PRODUCT_ID) },
36 { } /* Terminating entry */
37};
38
39MODULE_DEVICE_TABLE(usb, id_table);
40
41static struct usb_serial_driver empeg_device = {
42 .driver = {
43 .name = "empeg",
44 },
45 .id_table = id_table,
46 .num_ports = 1,
47 .bulk_out_size = 256,
48 .throttle = usb_serial_generic_throttle,
49 .unthrottle = usb_serial_generic_unthrottle,
50 .attach = empeg_startup,
51 .init_termios = empeg_init_termios,
52};
53
54static struct usb_serial_driver * const serial_drivers[] = {
55 &empeg_device, NULL
56};
57
58static int empeg_startup(struct usb_serial *serial)
59{
60 int r;
61
62 if (serial->dev->actconfig->desc.bConfigurationValue != 1) {
63 dev_err(&serial->dev->dev, "active config #%d != 1 ??\n",
64 serial->dev->actconfig->desc.bConfigurationValue);
65 return -ENODEV;
66 }
67
68 r = usb_reset_configuration(serial->dev);
69
70 /* continue on with initialization */
71 return r;
72}
73
74static void empeg_init_termios(struct tty_struct *tty)
75{
76 struct ktermios *termios = &tty->termios;
77
78 /*
79 * The empeg-car player wants these particular tty settings.
80 * You could, for example, change the baud rate, however the
81 * player only supports 115200 (currently), so there is really
82 * no point in support for changes to the tty settings.
83 * (at least for now)
84 *
85 * The default requirements for this device are:
86 */
87 termios->c_iflag
88 &= ~(IGNBRK /* disable ignore break */
89 | BRKINT /* disable break causes interrupt */
90 | PARMRK /* disable mark parity errors */
91 | ISTRIP /* disable clear high bit of input characters */
92 | INLCR /* disable translate NL to CR */
93 | IGNCR /* disable ignore CR */
94 | ICRNL /* disable translate CR to NL */
95 | IXON); /* disable enable XON/XOFF flow control */
96
97 termios->c_oflag
98 &= ~OPOST; /* disable postprocess output characters */
99
100 termios->c_lflag
101 &= ~(ECHO /* disable echo input characters */
102 | ECHONL /* disable echo new line */
103 | ICANON /* disable erase, kill, werase, and rprnt special characters */
104 | ISIG /* disable interrupt, quit, and suspend special characters */
105 | IEXTEN); /* disable non-POSIX special characters */
106
107 termios->c_cflag
108 &= ~(CSIZE /* no size */
109 | PARENB /* disable parity bit */
110 | CBAUD); /* clear current baud rate */
111
112 termios->c_cflag
113 |= CS8; /* character size 8 bits */
114
115 tty_encode_baud_rate(tty, 115200, 115200);
116}
117
118module_usb_serial_driver(serial_drivers, id_table);
119
120MODULE_AUTHOR(DRIVER_AUTHOR);
121MODULE_DESCRIPTION(DRIVER_DESC);
122MODULE_LICENSE("GPL v2");