Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * USB Empeg empeg-car player driver
0004  *
0005  *  Copyright (C) 2000, 2001
0006  *      Gary Brubaker (xavyer@ix.netcom.com)
0007  *
0008  *  Copyright (C) 1999 - 2001
0009  *      Greg Kroah-Hartman (greg@kroah.com)
0010  *
0011  * See Documentation/usb/usb-serial.rst for more information on using this
0012  * driver
0013  */
0014 
0015 #include <linux/kernel.h>
0016 #include <linux/errno.h>
0017 #include <linux/slab.h>
0018 #include <linux/tty.h>
0019 #include <linux/tty_driver.h>
0020 #include <linux/tty_flip.h>
0021 #include <linux/module.h>
0022 #include <linux/spinlock.h>
0023 #include <linux/uaccess.h>
0024 #include <linux/usb.h>
0025 #include <linux/usb/serial.h>
0026 
0027 #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Gary Brubaker <xavyer@ix.netcom.com>"
0028 #define DRIVER_DESC "USB Empeg Mark I/II Driver"
0029 
0030 #define EMPEG_VENDOR_ID         0x084f
0031 #define EMPEG_PRODUCT_ID        0x0001
0032 
0033 /* function prototypes for an empeg-car player */
0034 static int  empeg_startup(struct usb_serial *serial);
0035 static void empeg_init_termios(struct tty_struct *tty);
0036 
0037 static const struct usb_device_id id_table[] = {
0038     { USB_DEVICE(EMPEG_VENDOR_ID, EMPEG_PRODUCT_ID) },
0039     { }                 /* Terminating entry */
0040 };
0041 
0042 MODULE_DEVICE_TABLE(usb, id_table);
0043 
0044 static struct usb_serial_driver empeg_device = {
0045     .driver = {
0046         .owner =    THIS_MODULE,
0047         .name =     "empeg",
0048     },
0049     .id_table =     id_table,
0050     .num_ports =        1,
0051     .bulk_out_size =    256,
0052     .throttle =     usb_serial_generic_throttle,
0053     .unthrottle =       usb_serial_generic_unthrottle,
0054     .attach =       empeg_startup,
0055     .init_termios =     empeg_init_termios,
0056 };
0057 
0058 static struct usb_serial_driver * const serial_drivers[] = {
0059     &empeg_device, NULL
0060 };
0061 
0062 static int empeg_startup(struct usb_serial *serial)
0063 {
0064     int r;
0065 
0066     if (serial->dev->actconfig->desc.bConfigurationValue != 1) {
0067         dev_err(&serial->dev->dev, "active config #%d != 1 ??\n",
0068             serial->dev->actconfig->desc.bConfigurationValue);
0069         return -ENODEV;
0070     }
0071 
0072     r = usb_reset_configuration(serial->dev);
0073 
0074     /* continue on with initialization */
0075     return r;
0076 }
0077 
0078 static void empeg_init_termios(struct tty_struct *tty)
0079 {
0080     struct ktermios *termios = &tty->termios;
0081 
0082     /*
0083      * The empeg-car player wants these particular tty settings.
0084      * You could, for example, change the baud rate, however the
0085      * player only supports 115200 (currently), so there is really
0086      * no point in support for changes to the tty settings.
0087      * (at least for now)
0088      *
0089      * The default requirements for this device are:
0090      */
0091     termios->c_iflag
0092         &= ~(IGNBRK /* disable ignore break */
0093         | BRKINT    /* disable break causes interrupt */
0094         | PARMRK    /* disable mark parity errors */
0095         | ISTRIP    /* disable clear high bit of input characters */
0096         | INLCR     /* disable translate NL to CR */
0097         | IGNCR     /* disable ignore CR */
0098         | ICRNL     /* disable translate CR to NL */
0099         | IXON);    /* disable enable XON/XOFF flow control */
0100 
0101     termios->c_oflag
0102         &= ~OPOST;  /* disable postprocess output characters */
0103 
0104     termios->c_lflag
0105         &= ~(ECHO   /* disable echo input characters */
0106         | ECHONL    /* disable echo new line */
0107         | ICANON    /* disable erase, kill, werase, and rprnt special characters */
0108         | ISIG      /* disable interrupt, quit, and suspend special characters */
0109         | IEXTEN);  /* disable non-POSIX special characters */
0110 
0111     termios->c_cflag
0112         &= ~(CSIZE  /* no size */
0113         | PARENB    /* disable parity bit */
0114         | CBAUD);   /* clear current baud rate */
0115 
0116     termios->c_cflag
0117         |= CS8;     /* character size 8 bits */
0118 
0119     tty_encode_baud_rate(tty, 115200, 115200);
0120 }
0121 
0122 module_usb_serial_driver(serial_drivers, id_table);
0123 
0124 MODULE_AUTHOR(DRIVER_AUTHOR);
0125 MODULE_DESCRIPTION(DRIVER_DESC);
0126 MODULE_LICENSE("GPL v2");