empeg.c 3.6 KB

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