Loading...
1/*
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 *
14 * See Documentation/usb/usb-serial.txt for more information on using this
15 * driver
16 */
17
18#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>
27#include <linux/uaccess.h>
28#include <linux/usb.h>
29#include <linux/usb/serial.h>
30
31static int debug;
32
33/*
34 * Version Information
35 */
36#define DRIVER_VERSION "v1.3"
37#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 */
44static int empeg_startup(struct usb_serial *serial);
45static void empeg_init_termios(struct tty_struct *tty);
46
47static const struct usb_device_id id_table[] = {
48 { USB_DEVICE(EMPEG_VENDOR_ID, EMPEG_PRODUCT_ID) },
49 { } /* Terminating entry */
50};
51
52MODULE_DEVICE_TABLE(usb, id_table);
53
54static struct usb_driver empeg_driver = {
55 .name = "empeg",
56 .probe = usb_serial_probe,
57 .disconnect = usb_serial_disconnect,
58 .id_table = id_table,
59 .no_dynamic_id = 1,
60};
61
62static struct usb_serial_driver empeg_device = {
63 .driver = {
64 .owner = THIS_MODULE,
65 .name = "empeg",
66 },
67 .id_table = id_table,
68 .usb_driver = &empeg_driver,
69 .num_ports = 1,
70 .bulk_out_size = 256,
71 .throttle = usb_serial_generic_throttle,
72 .unthrottle = usb_serial_generic_unthrottle,
73 .attach = empeg_startup,
74 .init_termios = empeg_init_termios,
75};
76
77static int empeg_startup(struct usb_serial *serial)
78{
79 int r;
80
81 dbg("%s", __func__);
82
83 if (serial->dev->actconfig->desc.bConfigurationValue != 1) {
84 dev_err(&serial->dev->dev, "active config #%d != 1 ??\n",
85 serial->dev->actconfig->desc.bConfigurationValue);
86 return -ENODEV;
87 }
88 dbg("%s - reset config", __func__);
89 r = usb_reset_configuration(serial->dev);
90
91 /* continue on with initialization */
92 return r;
93}
94
95static void empeg_init_termios(struct tty_struct *tty)
96{
97 struct ktermios *termios = tty->termios;
98
99 /*
100 * 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 */
108 termios->c_iflag
109 &= ~(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
118 termios->c_oflag
119 &= ~OPOST; /* disable postprocess output characters */
120
121 termios->c_lflag
122 &= ~(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
128 termios->c_cflag
129 &= ~(CSIZE /* no size */
130 | PARENB /* disable parity bit */
131 | CBAUD); /* clear current baud rate */
132
133 termios->c_cflag
134 |= CS8; /* character size 8 bits */
135
136 tty_encode_baud_rate(tty, 115200, 115200);
137}
138
139static int __init empeg_init(void)
140{
141 int retval;
142
143 retval = usb_serial_register(&empeg_device);
144 if (retval)
145 return retval;
146 retval = usb_register(&empeg_driver);
147 if (retval) {
148 usb_serial_deregister(&empeg_device);
149 return retval;
150 }
151 printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
152 DRIVER_DESC "\n");
153
154 return 0;
155}
156
157static void __exit empeg_exit(void)
158{
159 usb_deregister(&empeg_driver);
160 usb_serial_deregister(&empeg_device);
161}
162
163
164module_init(empeg_init);
165module_exit(empeg_exit);
166
167MODULE_AUTHOR(DRIVER_AUTHOR);
168MODULE_DESCRIPTION(DRIVER_DESC);
169MODULE_LICENSE("GPL");
170
171module_param(debug, bool, S_IRUGO | S_IWUSR);
172MODULE_PARM_DESC(debug, "Debug enabled or not");
1// SPDX-License-Identifier: GPL-2.0
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 *
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/tty_driver.h>
20#include <linux/tty_flip.h>
21#include <linux/module.h>
22#include <linux/spinlock.h>
23#include <linux/uaccess.h>
24#include <linux/usb.h>
25#include <linux/usb/serial.h>
26
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 */
34static int empeg_startup(struct usb_serial *serial);
35static void empeg_init_termios(struct tty_struct *tty);
36
37static const struct usb_device_id id_table[] = {
38 { USB_DEVICE(EMPEG_VENDOR_ID, EMPEG_PRODUCT_ID) },
39 { } /* Terminating entry */
40};
41
42MODULE_DEVICE_TABLE(usb, id_table);
43
44static struct usb_serial_driver empeg_device = {
45 .driver = {
46 .owner = THIS_MODULE,
47 .name = "empeg",
48 },
49 .id_table = id_table,
50 .num_ports = 1,
51 .bulk_out_size = 256,
52 .throttle = usb_serial_generic_throttle,
53 .unthrottle = usb_serial_generic_unthrottle,
54 .attach = empeg_startup,
55 .init_termios = empeg_init_termios,
56};
57
58static struct usb_serial_driver * const serial_drivers[] = {
59 &empeg_device, NULL
60};
61
62static int empeg_startup(struct usb_serial *serial)
63{
64 int r;
65
66 if (serial->dev->actconfig->desc.bConfigurationValue != 1) {
67 dev_err(&serial->dev->dev, "active config #%d != 1 ??\n",
68 serial->dev->actconfig->desc.bConfigurationValue);
69 return -ENODEV;
70 }
71
72 r = usb_reset_configuration(serial->dev);
73
74 /* continue on with initialization */
75 return r;
76}
77
78static void empeg_init_termios(struct tty_struct *tty)
79{
80 struct ktermios *termios = &tty->termios;
81
82 /*
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 */
91 termios->c_iflag
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
101 termios->c_oflag
102 &= ~OPOST; /* disable postprocess output characters */
103
104 termios->c_lflag
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
111 termios->c_cflag
112 &= ~(CSIZE /* no size */
113 | PARENB /* disable parity bit */
114 | CBAUD); /* clear current baud rate */
115
116 termios->c_cflag
117 |= CS8; /* character size 8 bits */
118
119 tty_encode_baud_rate(tty, 115200, 115200);
120}
121
122module_usb_serial_driver(serial_drivers, id_table);
123
124MODULE_AUTHOR(DRIVER_AUTHOR);
125MODULE_DESCRIPTION(DRIVER_DESC);
126MODULE_LICENSE("GPL v2");