empeg.c 3.7 KB

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