au0828-cards.c 4.5 KB

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