empeg.c 3.4 KB

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