au0828-cards.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. struct au0828_board au0828_boards[] = {
  24. [AU0828_BOARD_UNKNOWN] = {
  25. .name = "Unknown board",
  26. },
  27. [AU0828_BOARD_HAUPPAUGE_HVR850] = {
  28. .name = "Hauppauge HVR850",
  29. },
  30. [AU0828_BOARD_HAUPPAUGE_HVR950Q] = {
  31. .name = "Hauppauge HVR950Q",
  32. },
  33. [AU0828_BOARD_DVICO_FUSIONHDTV7] = {
  34. .name = "DViCO FusionHDTV USB",
  35. },
  36. };
  37. const unsigned int au0828_bcount = ARRAY_SIZE(au0828_boards);
  38. /* Tuner callback function for au0828 boards. Currently only needed
  39. * for HVR1500Q, which has an xc5000 tuner.
  40. */
  41. int au0828_tuner_callback(void *priv, int command, int arg)
  42. {
  43. struct au0828_dev *dev = priv;
  44. dprintk(1, "%s()\n", __func__);
  45. switch (dev->board) {
  46. case AU0828_BOARD_HAUPPAUGE_HVR850:
  47. case AU0828_BOARD_HAUPPAUGE_HVR950Q:
  48. case AU0828_BOARD_DVICO_FUSIONHDTV7:
  49. if (command == 0) {
  50. /* Tuner Reset Command from xc5000 */
  51. /* Drive the tuner into reset and out */
  52. au0828_clear(dev, REG_001, 2);
  53. mdelay(200);
  54. au0828_set(dev, REG_001, 2);
  55. mdelay(50);
  56. return 0;
  57. } else {
  58. printk(KERN_ERR
  59. "%s(): Unknown command.\n", __func__);
  60. return -EINVAL;
  61. }
  62. break;
  63. }
  64. return 0; /* Should never be here */
  65. }
  66. static void hauppauge_eeprom(struct au0828_dev *dev, u8 *eeprom_data)
  67. {
  68. struct tveeprom tv;
  69. tveeprom_hauppauge_analog(&dev->i2c_client, &tv, eeprom_data);
  70. /* Make sure we support the board model */
  71. switch (tv.model) {
  72. case 72001: /* WinTV-HVR950q (Retail, IR, ATSC/QAM and basic analog video */
  73. case 72301: /* WinTV-HVR850 (Retail, IR, ATSC and basic analog video */
  74. break;
  75. default:
  76. printk(KERN_WARNING "%s: warning: "
  77. "unknown hauppauge model #%d\n", __func__, tv.model);
  78. break;
  79. }
  80. printk(KERN_INFO "%s: hauppauge eeprom: model=%d\n",
  81. __func__, tv.model);
  82. }
  83. void au0828_card_setup(struct au0828_dev *dev)
  84. {
  85. static u8 eeprom[256];
  86. dprintk(1, "%s()\n", __func__);
  87. if (dev->i2c_rc == 0) {
  88. dev->i2c_client.addr = 0xa0 >> 1;
  89. tveeprom_read(&dev->i2c_client, eeprom, sizeof(eeprom));
  90. }
  91. switch (dev->board) {
  92. case AU0828_BOARD_HAUPPAUGE_HVR850:
  93. case AU0828_BOARD_HAUPPAUGE_HVR950Q:
  94. if (dev->i2c_rc == 0)
  95. hauppauge_eeprom(dev, eeprom+0xa0);
  96. break;
  97. }
  98. }
  99. /*
  100. * The bridge has between 8 and 12 gpios.
  101. * Regs 1 and 0 deal with output enables.
  102. * Regs 3 and 2 deal with direction.
  103. */
  104. void au0828_gpio_setup(struct au0828_dev *dev)
  105. {
  106. dprintk(1, "%s()\n", __func__);
  107. switch (dev->board) {
  108. case AU0828_BOARD_HAUPPAUGE_HVR850:
  109. case AU0828_BOARD_HAUPPAUGE_HVR950Q:
  110. /* GPIO's
  111. * 4 - CS5340
  112. * 5 - AU8522 Demodulator
  113. * 6 - eeprom W/P
  114. * 9 - XC5000 Tuner
  115. */
  116. /* Into reset */
  117. au0828_write(dev, REG_003, 0x02);
  118. au0828_write(dev, REG_002, 0x88 | 0x20);
  119. au0828_write(dev, REG_001, 0x0);
  120. au0828_write(dev, REG_000, 0x0);
  121. msleep(100);
  122. /* Out of reset */
  123. au0828_write(dev, REG_003, 0x02);
  124. au0828_write(dev, REG_001, 0x02);
  125. au0828_write(dev, REG_002, 0x88 | 0x20);
  126. au0828_write(dev, REG_000, 0x88 | 0x20 | 0x40);
  127. msleep(250);
  128. break;
  129. case AU0828_BOARD_DVICO_FUSIONHDTV7:
  130. /* GPIO's
  131. * 6 - ?
  132. * 8 - AU8522 Demodulator
  133. * 9 - XC5000 Tuner
  134. */
  135. /* Into reset */
  136. au0828_write(dev, REG_003, 0x02);
  137. au0828_write(dev, REG_002, 0xa0);
  138. au0828_write(dev, REG_001, 0x0);
  139. au0828_write(dev, REG_000, 0x0);
  140. msleep(100);
  141. /* Out of reset */
  142. au0828_write(dev, REG_003, 0x02);
  143. au0828_write(dev, REG_002, 0xa0);
  144. au0828_write(dev, REG_001, 0x02);
  145. au0828_write(dev, REG_000, 0xa0);
  146. msleep(250);
  147. break;
  148. }
  149. }
  150. /* table of devices that work with this driver */
  151. struct usb_device_id au0828_usb_id_table [] = {
  152. { USB_DEVICE(0x2040, 0x7200),
  153. .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
  154. { USB_DEVICE(0x2040, 0x7240),
  155. .driver_info = AU0828_BOARD_HAUPPAUGE_HVR850 },
  156. { USB_DEVICE(0x0fe9, 0xd620),
  157. .driver_info = AU0828_BOARD_DVICO_FUSIONHDTV7 },
  158. { },
  159. };
  160. MODULE_DEVICE_TABLE(usb, au0828_usb_id_table);