au0828-cards.c 6.3 KB

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