au0828-cards.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*
  2. * Driver for the Auvitek USB bridge
  3. *
  4. * Copyright (c) 2008 Steven Toth <stoth@hauppauge.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. *
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21. #include "au0828.h"
  22. #include "au0828-cards.h"
  23. #define _dbg(level, fmt, arg...)\
  24. do {\
  25. if (debug >= level) \
  26. printk(KERN_DEBUG DRIVER_NAME "/0: " fmt, ## arg);\
  27. } while (0)
  28. struct au0828_board au0828_boards[] = {
  29. [AU0828_BOARD_UNKNOWN] = {
  30. .name = "Unknown board",
  31. },
  32. [AU0828_BOARD_HAUPPAUGE_HVR850] = {
  33. .name = "Hauppauge HVR850",
  34. },
  35. [AU0828_BOARD_HAUPPAUGE_HVR950Q] = {
  36. .name = "Hauppauge HVR950Q",
  37. },
  38. [AU0828_BOARD_DVICO_FUSIONHDTV7] = {
  39. .name = "DViCO FusionHDTV USB",
  40. },
  41. };
  42. const unsigned int au0828_bcount = ARRAY_SIZE(au0828_boards);
  43. /* Tuner callback function for au0828 boards. Currently only needed
  44. * for HVR1500Q, which has an xc5000 tuner.
  45. */
  46. int au0828_tuner_callback(void *priv, int command, int arg)
  47. {
  48. struct au0828_dev *dev = priv;
  49. switch(dev->board) {
  50. case AU0828_BOARD_HAUPPAUGE_HVR850:
  51. case AU0828_BOARD_HAUPPAUGE_HVR950Q:
  52. case AU0828_BOARD_DVICO_FUSIONHDTV7:
  53. if(command == 0) {
  54. /* Tuner Reset Command from xc5000 */
  55. /* Drive the tuner into reset and out */
  56. au0828_clear(dev, REG_001, 2);
  57. mdelay(200);
  58. au0828_set(dev, REG_001, 2);
  59. mdelay(50);
  60. return 0;
  61. }
  62. else {
  63. printk(KERN_ERR
  64. "%s(): Unknown command.\n", __FUNCTION__);
  65. return -EINVAL;
  66. }
  67. break;
  68. }
  69. return 0; /* Should never be here */
  70. }
  71. /*
  72. * The bridge has between 8 and 12 gpios.
  73. * Regs 1 and 0 deal with output enables.
  74. * Regs 3 and 2 * deal with direction.
  75. */
  76. void au0828_gpio_setup(struct au0828_dev *dev)
  77. {
  78. switch(dev->board) {
  79. case AU0828_BOARD_HAUPPAUGE_HVR850:
  80. case AU0828_BOARD_HAUPPAUGE_HVR950Q:
  81. /* GPIO's
  82. * 4 - CS5340
  83. * 5 - AU8522 Demodulator
  84. * 6 - eeprom W/P
  85. * 9 - XC5000 Tuner
  86. */
  87. /* Into reset */
  88. au0828_write(dev, REG_003, 0x02);
  89. au0828_write(dev, REG_002, 0x88 | 0x20);
  90. au0828_write(dev, REG_001, 0x0);
  91. au0828_write(dev, REG_000, 0x0);
  92. msleep(100);
  93. /* Out of reset */
  94. au0828_write(dev, REG_003, 0x02);
  95. au0828_write(dev, REG_001, 0x02);
  96. au0828_write(dev, REG_002, 0x88 | 0x20);
  97. au0828_write(dev, REG_000, 0x88 | 0x20 | 0x40);
  98. msleep(250);
  99. break;
  100. case AU0828_BOARD_DVICO_FUSIONHDTV7:
  101. /* GPIO's
  102. * 6 - ?
  103. * 8 - AU8522 Demodulator
  104. * 9 - XC5000 Tuner
  105. */
  106. /* Into reset */
  107. au0828_write(dev, REG_003, 0x02);
  108. au0828_write(dev, REG_002, 0xa0);
  109. au0828_write(dev, REG_001, 0x0);
  110. au0828_write(dev, REG_000, 0x0);
  111. msleep(100);
  112. /* Out of reset */
  113. au0828_write(dev, REG_003, 0x02);
  114. au0828_write(dev, REG_002, 0xa0);
  115. au0828_write(dev, REG_001, 0x02);
  116. au0828_write(dev, REG_000, 0xa0);
  117. msleep(250);
  118. break;
  119. }
  120. }
  121. /* table of devices that work with this driver */
  122. struct usb_device_id au0828_usb_id_table [] = {
  123. { USB_DEVICE(0x2040, 0x7200),
  124. .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
  125. { USB_DEVICE(0x2040, 0x7240),
  126. .driver_info = AU0828_BOARD_HAUPPAUGE_HVR850 },
  127. { USB_DEVICE(0x0fe9, 0xd620),
  128. .driver_info = AU0828_BOARD_DVICO_FUSIONHDTV7 },
  129. { },
  130. };
  131. MODULE_DEVICE_TABLE(usb, au0828_usb_id_table);