au0828-cards.c 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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. #include "au8522.h"
  24. void hvr950q_cs5340_audio(void *priv, int enable)
  25. {
  26. /* Because the HVR-950q shares an i2s bus between the cs5340 and the
  27. au8522, we need to hold cs5340 in reset when using the au8522 */
  28. struct au0828_dev *dev = priv;
  29. if (enable == 1)
  30. au0828_set(dev, REG_000, 0x10);
  31. else
  32. au0828_clear(dev, REG_000, 0x10);
  33. }
  34. struct au0828_board au0828_boards[] = {
  35. [AU0828_BOARD_UNKNOWN] = {
  36. .name = "Unknown board",
  37. },
  38. [AU0828_BOARD_HAUPPAUGE_HVR850] = {
  39. .name = "Hauppauge HVR850",
  40. .input = {
  41. {
  42. .type = AU0828_VMUX_TELEVISION,
  43. .vmux = AU8522_COMPOSITE_CH4_SIF,
  44. .amux = AU8522_AUDIO_SIF,
  45. },
  46. {
  47. .type = AU0828_VMUX_COMPOSITE,
  48. .vmux = AU8522_COMPOSITE_CH1,
  49. .amux = AU8522_AUDIO_NONE,
  50. .audio_setup = hvr950q_cs5340_audio,
  51. },
  52. {
  53. .type = AU0828_VMUX_SVIDEO,
  54. .vmux = AU8522_SVIDEO_CH13,
  55. .amux = AU8522_AUDIO_NONE,
  56. .audio_setup = hvr950q_cs5340_audio,
  57. },
  58. },
  59. },
  60. [AU0828_BOARD_HAUPPAUGE_HVR950Q] = {
  61. .name = "Hauppauge HVR950Q",
  62. .input = {
  63. {
  64. .type = AU0828_VMUX_TELEVISION,
  65. .vmux = AU8522_COMPOSITE_CH4_SIF,
  66. .amux = AU8522_AUDIO_SIF,
  67. },
  68. {
  69. .type = AU0828_VMUX_COMPOSITE,
  70. .vmux = AU8522_COMPOSITE_CH1,
  71. .amux = AU8522_AUDIO_NONE,
  72. .audio_setup = hvr950q_cs5340_audio,
  73. },
  74. {
  75. .type = AU0828_VMUX_SVIDEO,
  76. .vmux = AU8522_SVIDEO_CH13,
  77. .amux = AU8522_AUDIO_NONE,
  78. .audio_setup = hvr950q_cs5340_audio,
  79. },
  80. },
  81. },
  82. [AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL] = {
  83. .name = "Hauppauge HVR950Q rev xxF8",
  84. },
  85. [AU0828_BOARD_DVICO_FUSIONHDTV7] = {
  86. .name = "DViCO FusionHDTV USB",
  87. },
  88. [AU0828_BOARD_HAUPPAUGE_WOODBURY] = {
  89. .name = "Hauppauge Woodbury",
  90. },
  91. };
  92. /* Tuner callback function for au0828 boards. Currently only needed
  93. * for HVR1500Q, which has an xc5000 tuner.
  94. */
  95. int au0828_tuner_callback(void *priv, int component, int command, int arg)
  96. {
  97. struct au0828_dev *dev = priv;
  98. dprintk(1, "%s()\n", __func__);
  99. switch (dev->board) {
  100. case AU0828_BOARD_HAUPPAUGE_HVR850:
  101. case AU0828_BOARD_HAUPPAUGE_HVR950Q:
  102. case AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL:
  103. case AU0828_BOARD_DVICO_FUSIONHDTV7:
  104. if (command == 0) {
  105. /* Tuner Reset Command from xc5000 */
  106. /* Drive the tuner into reset and out */
  107. au0828_clear(dev, REG_001, 2);
  108. mdelay(200);
  109. au0828_set(dev, REG_001, 2);
  110. mdelay(50);
  111. return 0;
  112. } else {
  113. printk(KERN_ERR
  114. "%s(): Unknown command.\n", __func__);
  115. return -EINVAL;
  116. }
  117. break;
  118. }
  119. return 0; /* Should never be here */
  120. }
  121. static void hauppauge_eeprom(struct au0828_dev *dev, u8 *eeprom_data)
  122. {
  123. struct tveeprom tv;
  124. tveeprom_hauppauge_analog(&dev->i2c_client, &tv, eeprom_data);
  125. /* Make sure we support the board model */
  126. switch (tv.model) {
  127. case 72000: /* WinTV-HVR950q (Retail, IR, ATSC/QAM */
  128. case 72001: /* WinTV-HVR950q (Retail, IR, ATSC/QAM and basic analog video */
  129. case 72211: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and basic analog video */
  130. case 72221: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and basic analog video */
  131. case 72231: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and basic analog video */
  132. case 72241: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM and basic analog video */
  133. case 72251: /* WinTV-HVR950q (Retail, IR, ATSC/QAM and basic analog video */
  134. case 72301: /* WinTV-HVR850 (Retail, IR, ATSC and basic analog video */
  135. case 72500: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM */
  136. break;
  137. default:
  138. printk(KERN_WARNING "%s: warning: "
  139. "unknown hauppauge model #%d\n", __func__, tv.model);
  140. break;
  141. }
  142. printk(KERN_INFO "%s: hauppauge eeprom: model=%d\n",
  143. __func__, tv.model);
  144. }
  145. void au0828_card_setup(struct au0828_dev *dev)
  146. {
  147. static u8 eeprom[256];
  148. dprintk(1, "%s()\n", __func__);
  149. if (dev->i2c_rc == 0) {
  150. dev->i2c_client.addr = 0xa0 >> 1;
  151. tveeprom_read(&dev->i2c_client, eeprom, sizeof(eeprom));
  152. }
  153. switch (dev->board) {
  154. case AU0828_BOARD_HAUPPAUGE_HVR850:
  155. case AU0828_BOARD_HAUPPAUGE_HVR950Q:
  156. case AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL:
  157. case AU0828_BOARD_HAUPPAUGE_WOODBURY:
  158. if (dev->i2c_rc == 0)
  159. hauppauge_eeprom(dev, eeprom+0xa0);
  160. break;
  161. }
  162. }
  163. /*
  164. * The bridge has between 8 and 12 gpios.
  165. * Regs 1 and 0 deal with output enables.
  166. * Regs 3 and 2 deal with direction.
  167. */
  168. void au0828_gpio_setup(struct au0828_dev *dev)
  169. {
  170. dprintk(1, "%s()\n", __func__);
  171. switch (dev->board) {
  172. case AU0828_BOARD_HAUPPAUGE_HVR850:
  173. case AU0828_BOARD_HAUPPAUGE_HVR950Q:
  174. case AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL:
  175. case AU0828_BOARD_HAUPPAUGE_WOODBURY:
  176. /* GPIO's
  177. * 4 - CS5340
  178. * 5 - AU8522 Demodulator
  179. * 6 - eeprom W/P
  180. * 7 - power supply
  181. * 9 - XC5000 Tuner
  182. */
  183. /* Into reset */
  184. au0828_write(dev, REG_003, 0x02);
  185. au0828_write(dev, REG_002, 0x80 | 0x20 | 0x10);
  186. au0828_write(dev, REG_001, 0x0);
  187. au0828_write(dev, REG_000, 0x0);
  188. msleep(100);
  189. /* Out of reset (leave the cs5340 in reset until needed) */
  190. au0828_write(dev, REG_003, 0x02);
  191. au0828_write(dev, REG_001, 0x02);
  192. au0828_write(dev, REG_002, 0x80 | 0x20 | 0x10);
  193. au0828_write(dev, REG_000, 0x80 | 0x40 | 0x20);
  194. msleep(250);
  195. break;
  196. case AU0828_BOARD_DVICO_FUSIONHDTV7:
  197. /* GPIO's
  198. * 6 - ?
  199. * 8 - AU8522 Demodulator
  200. * 9 - XC5000 Tuner
  201. */
  202. /* Into reset */
  203. au0828_write(dev, REG_003, 0x02);
  204. au0828_write(dev, REG_002, 0xa0);
  205. au0828_write(dev, REG_001, 0x0);
  206. au0828_write(dev, REG_000, 0x0);
  207. msleep(100);
  208. /* Out of reset */
  209. au0828_write(dev, REG_003, 0x02);
  210. au0828_write(dev, REG_002, 0xa0);
  211. au0828_write(dev, REG_001, 0x02);
  212. au0828_write(dev, REG_000, 0xa0);
  213. msleep(250);
  214. break;
  215. }
  216. }
  217. /* table of devices that work with this driver */
  218. struct usb_device_id au0828_usb_id_table[] = {
  219. { USB_DEVICE(0x2040, 0x7200),
  220. .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
  221. { USB_DEVICE(0x2040, 0x7240),
  222. .driver_info = AU0828_BOARD_HAUPPAUGE_HVR850 },
  223. { USB_DEVICE(0x0fe9, 0xd620),
  224. .driver_info = AU0828_BOARD_DVICO_FUSIONHDTV7 },
  225. { USB_DEVICE(0x2040, 0x7210),
  226. .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
  227. { USB_DEVICE(0x2040, 0x7217),
  228. .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
  229. { USB_DEVICE(0x2040, 0x721b),
  230. .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
  231. { USB_DEVICE(0x2040, 0x721e),
  232. .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
  233. { USB_DEVICE(0x2040, 0x721f),
  234. .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
  235. { USB_DEVICE(0x2040, 0x7280),
  236. .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
  237. { USB_DEVICE(0x0fd9, 0x0008),
  238. .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q },
  239. { USB_DEVICE(0x2040, 0x7201),
  240. .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL },
  241. { USB_DEVICE(0x2040, 0x7211),
  242. .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL },
  243. { USB_DEVICE(0x2040, 0x7281),
  244. .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL },
  245. { USB_DEVICE(0x2040, 0x8200),
  246. .driver_info = AU0828_BOARD_HAUPPAUGE_WOODBURY },
  247. { },
  248. };
  249. MODULE_DEVICE_TABLE(usb, au0828_usb_id_table);