Commit | Line | Data |
---|---|---|
5fd54ace | 1 | // SPDX-License-Identifier: GPL-2.0 |
1da177e4 LT |
2 | /* |
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 | * | |
93c46795 AC |
11 | * See Documentation/usb/usb-serial.txt for more information on using this |
12 | * driver | |
1da177e4 LT |
13 | */ |
14 | ||
1da177e4 LT |
15 | #include <linux/kernel.h> |
16 | #include <linux/errno.h> | |
1da177e4 LT |
17 | #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> | |
93c46795 | 23 | #include <linux/uaccess.h> |
1da177e4 | 24 | #include <linux/usb.h> |
a969888c | 25 | #include <linux/usb/serial.h> |
1da177e4 | 26 | |
1da177e4 LT |
27 | #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 */ | |
93c46795 | 34 | static int empeg_startup(struct usb_serial *serial); |
fe1ae7fd | 35 | static void empeg_init_termios(struct tty_struct *tty); |
1da177e4 | 36 | |
7d40d7e8 | 37 | static const struct usb_device_id id_table[] = { |
1da177e4 LT |
38 | { USB_DEVICE(EMPEG_VENDOR_ID, EMPEG_PRODUCT_ID) }, |
39 | { } /* Terminating entry */ | |
40 | }; | |
41 | ||
93c46795 | 42 | MODULE_DEVICE_TABLE(usb, id_table); |
1da177e4 | 43 | |
ea65370d | 44 | static struct usb_serial_driver empeg_device = { |
18fcac35 GKH |
45 | .driver = { |
46 | .owner = THIS_MODULE, | |
269bda1c | 47 | .name = "empeg", |
18fcac35 | 48 | }, |
1da177e4 | 49 | .id_table = id_table, |
1da177e4 | 50 | .num_ports = 1, |
695aaae6 JH |
51 | .bulk_out_size = 256, |
52 | .throttle = usb_serial_generic_throttle, | |
53 | .unthrottle = usb_serial_generic_unthrottle, | |
1da177e4 | 54 | .attach = empeg_startup, |
fe1ae7fd | 55 | .init_termios = empeg_init_termios, |
1da177e4 LT |
56 | }; |
57 | ||
97b6b6d2 AS |
58 | static struct usb_serial_driver * const serial_drivers[] = { |
59 | &empeg_device, NULL | |
60 | }; | |
61 | ||
695aaae6 | 62 | static int empeg_startup(struct usb_serial *serial) |
1da177e4 LT |
63 | { |
64 | int r; | |
65 | ||
1da177e4 | 66 | if (serial->dev->actconfig->desc.bConfigurationValue != 1) { |
194343d9 | 67 | dev_err(&serial->dev->dev, "active config #%d != 1 ??\n", |
1da177e4 LT |
68 | serial->dev->actconfig->desc.bConfigurationValue); |
69 | return -ENODEV; | |
70 | } | |
4e512ab9 | 71 | |
93c46795 | 72 | r = usb_reset_configuration(serial->dev); |
1da177e4 LT |
73 | |
74 | /* continue on with initialization */ | |
75 | return r; | |
1da177e4 LT |
76 | } |
77 | ||
fe1ae7fd | 78 | static void empeg_init_termios(struct tty_struct *tty) |
1da177e4 | 79 | { |
adc8d746 | 80 | struct ktermios *termios = &tty->termios; |
1da177e4 | 81 | |
1da177e4 | 82 | /* |
93c46795 AC |
83 | * 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 | */ | |
998e8638 | 91 | termios->c_iflag |
1da177e4 LT |
92 | &= ~(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 | ||
998e8638 | 101 | termios->c_oflag |
1da177e4 LT |
102 | &= ~OPOST; /* disable postprocess output characters */ |
103 | ||
998e8638 | 104 | termios->c_lflag |
1da177e4 LT |
105 | &= ~(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 | ||
998e8638 | 111 | termios->c_cflag |
1da177e4 LT |
112 | &= ~(CSIZE /* no size */ |
113 | | PARENB /* disable parity bit */ | |
114 | | CBAUD); /* clear current baud rate */ | |
115 | ||
998e8638 AC |
116 | termios->c_cflag |
117 | |= CS8; /* character size 8 bits */ | |
1da177e4 | 118 | |
95da310e | 119 | tty_encode_baud_rate(tty, 115200, 115200); |
1da177e4 LT |
120 | } |
121 | ||
68e24113 | 122 | module_usb_serial_driver(serial_drivers, id_table); |
1da177e4 | 123 | |
93c46795 AC |
124 | MODULE_AUTHOR(DRIVER_AUTHOR); |
125 | MODULE_DESCRIPTION(DRIVER_DESC); | |
627cfa89 | 126 | MODULE_LICENSE("GPL v2"); |