au0828-cards.c 8.7 KB

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