empeg.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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 int 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_driver empeg_driver = {
  47. .name = "empeg",
  48. .probe = usb_serial_probe,
  49. .disconnect = usb_serial_disconnect,
  50. .id_table = id_table,
  51. .no_dynamic_id = 1,
  52. };
  53. static struct usb_serial_driver empeg_device = {
  54. .driver = {
  55. .owner = THIS_MODULE,
  56. .name = "empeg",
  57. },
  58. .id_table = id_table,
  59. .usb_driver = &empeg_driver,
  60. .num_ports = 1,
  61. .bulk_out_size = 256,
  62. .throttle = usb_serial_generic_throttle,
  63. .unthrottle = usb_serial_generic_unthrottle,
  64. .attach = empeg_startup,
  65. .init_termios = empeg_init_termios,
  66. };
  67. static int empeg_startup(struct usb_serial *serial)
  68. {
  69. int r;
  70. dbg("%s", __func__);
  71. if (serial->dev->actconfig->desc.bConfigurationValue != 1) {
  72. dev_err(&serial->dev->dev, "active config #%d != 1 ??\n",
  73. serial->dev->actconfig->desc.bConfigurationValue);
  74. return -ENODEV;
  75. }
  76. dbg("%s - reset config", __func__);
  77. r = usb_reset_configuration(serial->dev);
  78. /* continue on with initialization */
  79. return r;
  80. }
  81. static void empeg_init_termios(struct tty_struct *tty)
  82. {
  83. struct ktermios *termios = tty->termios;
  84. /*
  85. * The empeg-car player wants these particular tty settings.
  86. * You could, for example, change the baud rate, however the
  87. * player only supports 115200 (currently), so there is really
  88. * no point in support for changes to the tty settings.
  89. * (at least for now)
  90. *
  91. * The default requirements for this device are:
  92. */
  93. termios->c_iflag
  94. &= ~(IGNBRK /* disable ignore break */
  95. | BRKINT /* disable break causes interrupt */
  96. | PARMRK /* disable mark parity errors */
  97. | ISTRIP /* disable clear high bit of input characters */
  98. | INLCR /* disable translate NL to CR */
  99. | IGNCR /* disable ignore CR */
  100. | ICRNL /* disable translate CR to NL */
  101. | IXON); /* disable enable XON/XOFF flow control */
  102. termios->c_oflag
  103. &= ~OPOST; /* disable postprocess output characters */
  104. termios->c_lflag
  105. &= ~(ECHO /* disable echo input characters */
  106. | ECHONL /* disable echo new line */
  107. | ICANON /* disable erase, kill, werase, and rprnt special characters */
  108. | ISIG /* disable interrupt, quit, and suspend special characters */
  109. | IEXTEN); /* disable non-POSIX special characters */
  110. termios->c_cflag
  111. &= ~(CSIZE /* no size */
  112. | PARENB /* disable parity bit */
  113. | CBAUD); /* clear current baud rate */
  114. termios->c_cflag
  115. |= CS8; /* character size 8 bits */
  116. tty_encode_baud_rate(tty, 115200, 115200);
  117. }
  118. static int __init empeg_init(void)
  119. {
  120. int retval;
  121. retval = usb_serial_register(&empeg_device);
  122. if (retval)
  123. return retval;
  124. retval = usb_register(&empeg_driver);
  125. if (retval) {
  126. usb_serial_deregister(&empeg_device);
  127. return retval;
  128. }
  129. printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
  130. DRIVER_DESC "\n");
  131. return 0;
  132. }
  133. static void __exit empeg_exit(void)
  134. {
  135. usb_deregister(&empeg_driver);
  136. usb_serial_deregister(&empeg_device);
  137. }
  138. module_init(empeg_init);
  139. module_exit(empeg_exit);
  140. MODULE_AUTHOR(DRIVER_AUTHOR);
  141. MODULE_DESCRIPTION(DRIVER_DESC);
  142. MODULE_LICENSE("GPL");
  143. module_param(debug, bool, S_IRUGO | S_IWUSR);
  144. MODULE_PARM_DESC(debug, "Debug enabled or not");