empeg.c 3.8 KB

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