empeg.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. #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. .name = "empeg",
  40. },
  41. .id_table = id_table,
  42. .num_ports = 1,
  43. .bulk_out_size = 256,
  44. .throttle = usb_serial_generic_throttle,
  45. .unthrottle = usb_serial_generic_unthrottle,
  46. .attach = empeg_startup,
  47. .init_termios = empeg_init_termios,
  48. };
  49. static struct usb_serial_driver * const serial_drivers[] = {
  50. &empeg_device, NULL
  51. };
  52. static int empeg_startup(struct usb_serial *serial)
  53. {
  54. int r;
  55. if (serial->dev->actconfig->desc.bConfigurationValue != 1) {
  56. dev_err(&serial->dev->dev, "active config #%d != 1 ??\n",
  57. serial->dev->actconfig->desc.bConfigurationValue);
  58. return -ENODEV;
  59. }
  60. r = usb_reset_configuration(serial->dev);
  61. /* continue on with initialization */
  62. return r;
  63. }
  64. static void empeg_init_termios(struct tty_struct *tty)
  65. {
  66. struct ktermios *termios = &tty->termios;
  67. /*
  68. * The empeg-car player wants these particular tty settings.
  69. * You could, for example, change the baud rate, however the
  70. * player only supports 115200 (currently), so there is really
  71. * no point in support for changes to the tty settings.
  72. * (at least for now)
  73. *
  74. * The default requirements for this device are:
  75. */
  76. termios->c_iflag
  77. &= ~(IGNBRK /* disable ignore break */
  78. | BRKINT /* disable break causes interrupt */
  79. | PARMRK /* disable mark parity errors */
  80. | ISTRIP /* disable clear high bit of input characters */
  81. | INLCR /* disable translate NL to CR */
  82. | IGNCR /* disable ignore CR */
  83. | ICRNL /* disable translate CR to NL */
  84. | IXON); /* disable enable XON/XOFF flow control */
  85. termios->c_oflag
  86. &= ~OPOST; /* disable postprocess output characters */
  87. termios->c_lflag
  88. &= ~(ECHO /* disable echo input characters */
  89. | ECHONL /* disable echo new line */
  90. | ICANON /* disable erase, kill, werase, and rprnt special characters */
  91. | ISIG /* disable interrupt, quit, and suspend special characters */
  92. | IEXTEN); /* disable non-POSIX special characters */
  93. termios->c_cflag
  94. &= ~(CSIZE /* no size */
  95. | PARENB /* disable parity bit */
  96. | CBAUD); /* clear current baud rate */
  97. termios->c_cflag
  98. |= CS8; /* character size 8 bits */
  99. tty_encode_baud_rate(tty, 115200, 115200);
  100. }
  101. module_usb_serial_driver(serial_drivers, id_table);
  102. MODULE_AUTHOR(DRIVER_AUTHOR);
  103. MODULE_DESCRIPTION(DRIVER_DESC);
  104. MODULE_LICENSE("GPL v2");