| 1 | |
| 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 |
|
| 31 | static int empeg_startup(struct usb_serial *serial);
|
| 32 | static void empeg_init_termios(struct tty_struct *tty);
|
| 33 |
|
| 34 | static const struct usb_device_id id_table[] = {
|
| 35 | { USB_DEVICE(EMPEG_VENDOR_ID, EMPEG_PRODUCT_ID) },
|
| 36 | { }
|
| 37 | };
|
| 38 |
|
| 39 | MODULE_DEVICE_TABLE(usb, id_table);
|
| 40 |
|
| 41 | static 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 |
|
| 54 | static struct usb_serial_driver * const serial_drivers[] = {
|
| 55 | &empeg_device, NULL
|
| 56 | };
|
| 57 |
|
| 58 | static 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 |
|
| 71 | return r;
|
| 72 | }
|
| 73 |
|
| 74 | static 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
|
| 89 | | BRKINT
|
| 90 | | PARMRK
|
| 91 | | ISTRIP
|
| 92 | | INLCR
|
| 93 | | IGNCR
|
| 94 | | ICRNL
|
| 95 | | IXON);
|
| 96 |
|
| 97 | termios->c_oflag
|
| 98 | &= ~OPOST;
|
| 99 |
|
| 100 | termios->c_lflag
|
| 101 | &= ~(ECHO
|
| 102 | | ECHONL
|
| 103 | | ICANON
|
| 104 | | ISIG
|
| 105 | | IEXTEN);
|
| 106 |
|
| 107 | termios->c_cflag
|
| 108 | &= ~(CSIZE
|
| 109 | | PARENB
|
| 110 | | CBAUD);
|
| 111 |
|
| 112 | termios->c_cflag
|
| 113 | |= CS8;
|
| 114 |
|
| 115 | tty_encode_baud_rate(tty, 115200, 115200);
|
| 116 | }
|
| 117 |
|
| 118 | module_usb_serial_driver(serial_drivers, id_table);
|
| 119 |
|
| 120 | MODULE_AUTHOR(DRIVER_AUTHOR);
|
| 121 | MODULE_DESCRIPTION(DRIVER_DESC);
|
| 122 | MODULE_LICENSE("GPL v2");
|