au0828-cards.c 5.9 KB

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