au0828-cards.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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. static void hauppauge_eeprom(struct au0828_dev *dev, u8 *eeprom_data)
  72. {
  73. struct tveeprom tv;
  74. tveeprom_hauppauge_analog(&dev->i2c_client, &tv, eeprom_data);
  75. /* Make sure we support the board model */
  76. switch (tv.model)
  77. {
  78. case 72001: /* WinTV-HVR950q (Retail, IR, ATSC/QAM and basic analog video */
  79. break;
  80. default:
  81. printk("%s: warning: unknown hauppauge model #%d\n", __FUNCTION__, tv.model);
  82. break;
  83. }
  84. printk(KERN_INFO "%s: hauppauge eeprom: model=%d\n", __FUNCTION__, tv.model);
  85. }
  86. void au0828_card_setup(struct au0828_dev *dev)
  87. {
  88. static u8 eeprom[256];
  89. if (dev->i2c_rc == 0) {
  90. dev->i2c_client.addr = 0xa0 >> 1;
  91. tveeprom_read(&dev->i2c_client, eeprom, sizeof(eeprom));
  92. }
  93. switch(dev->board) {
  94. case AU0828_BOARD_HAUPPAUGE_HVR850:
  95. case AU0828_BOARD_HAUPPAUGE_HVR950Q:
  96. if (dev->i2c_rc == 0)
  97. hauppauge_eeprom(dev, eeprom+0xa0);
  98. break;
  99. }
  100. }
  101. /*
  102. * The bridge has between 8 and 12 gpios.
  103. * Regs 1 and 0 deal with output enables.
  104. * Regs 3 and 2 * deal with direction.
  105. */
  106. void au0828_gpio_setup(struct au0828_dev *dev)
  107. {
  108. switch(dev->board) {
  109. case AU0828_BOARD_HAUPPAUGE_HVR850:
  110. case AU0828_BOARD_HAUPPAUGE_HVR950Q:
  111. /* GPIO's
  112. * 4 - CS5340
  113. * 5 - AU8522 Demodulator
  114. * 6 - eeprom W/P
  115. * 9 - XC5000 Tuner
  116. */
  117. /* Into reset */
  118. au0828_write(dev, REG_003, 0x02);
  119. au0828_write(dev, REG_002, 0x88 | 0x20);
  120. au0828_write(dev, REG_001, 0x0);
  121. au0828_write(dev, REG_000, 0x0);
  122. msleep(100);
  123. /* Out of reset */
  124. au0828_write(dev, REG_003, 0x02);
  125. au0828_write(dev, REG_001, 0x02);
  126. au0828_write(dev, REG_002, 0x88 | 0x20);
  127. au0828_write(dev, REG_000, 0x88 | 0x20 | 0x40);
  128. msleep(250);
  129. break;
  130. case AU0828_BOARD_DVICO_FUSIONHDTV7:
  131. /* GPIO's
  132. * 6 - ?
  133. * 8 - AU8522 Demodulator
  134. * 9 - XC5000 Tuner
  135. */
  136. /* Into reset */
  137. au0828_write(dev, REG_003, 0x02);
  138. au0828_write(dev, REG_002, 0xa0);
  139. au0828_write(dev, REG_001, 0x0);
  140. au0828_write(dev, REG_000, 0x0);
  141. msleep(100);
  142. /* Out of reset */
  143. au0828_write(dev, REG_003, 0x02);
  144. au0828_write(dev, REG_002, 0xa0);
  145. au0828_write(dev, REG_001, 0x02);
  146. au0828_write(dev, REG_000, 0xa0);
  147. msleep(250);
  148. break;
  149. }
  150. }
  151. /* table of devices that work with this driver */
  152. struct usb_device_id au0828_usb_id_table [] = {
  153. { USB_DEVICE(0x2040, 0x7200),
  154. .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
  155. { USB_DEVICE(0x2040, 0x7240),
  156. .driver_info = AU0828_BOARD_HAUPPAUGE_HVR850 },
  157. { USB_DEVICE(0x0fe9, 0xd620),
  158. .driver_info = AU0828_BOARD_DVICO_FUSIONHDTV7 },
  159. { },
  160. };
  161. MODULE_DEVICE_TABLE(usb, au0828_usb_id_table);