cx23885-cards.c 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. /*
  2. * Driver for the Conexant CX23885 PCIe bridge
  3. *
  4. * Copyright (c) 2006 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 <linux/init.h>
  22. #include <linux/module.h>
  23. #include <linux/pci.h>
  24. #include <linux/delay.h>
  25. #include "cx23885.h"
  26. /* ------------------------------------------------------------------ */
  27. /* board config info */
  28. struct cx23885_board cx23885_boards[] = {
  29. [CX23885_BOARD_UNKNOWN] = {
  30. .name = "UNKNOWN/GENERIC",
  31. .input = {{
  32. .type = CX23885_VMUX_COMPOSITE1,
  33. .vmux = 0,
  34. },{
  35. .type = CX23885_VMUX_COMPOSITE2,
  36. .vmux = 1,
  37. },{
  38. .type = CX23885_VMUX_COMPOSITE3,
  39. .vmux = 2,
  40. },{
  41. .type = CX23885_VMUX_COMPOSITE4,
  42. .vmux = 3,
  43. }},
  44. },
  45. [CX23885_BOARD_HAUPPAUGE_HVR1800lp] = {
  46. .name = "Hauppauge WinTV-HVR1800lp",
  47. .portc = CX23885_MPEG_DVB,
  48. .input = {{
  49. .type = CX23885_VMUX_TELEVISION,
  50. .vmux = 0,
  51. .gpio0 = 0xff00,
  52. },{
  53. .type = CX23885_VMUX_DEBUG,
  54. .vmux = 0,
  55. .gpio0 = 0xff01,
  56. },{
  57. .type = CX23885_VMUX_COMPOSITE1,
  58. .vmux = 1,
  59. .gpio0 = 0xff02,
  60. },{
  61. .type = CX23885_VMUX_SVIDEO,
  62. .vmux = 2,
  63. .gpio0 = 0xff02,
  64. }},
  65. },
  66. [CX23885_BOARD_HAUPPAUGE_HVR1800] = {
  67. .name = "Hauppauge WinTV-HVR1800",
  68. .portc = CX23885_MPEG_DVB,
  69. .input = {{
  70. .type = CX23885_VMUX_TELEVISION,
  71. .vmux = 0,
  72. .gpio0 = 0xff00,
  73. },{
  74. .type = CX23885_VMUX_DEBUG,
  75. .vmux = 0,
  76. .gpio0 = 0xff01,
  77. },{
  78. .type = CX23885_VMUX_COMPOSITE1,
  79. .vmux = 1,
  80. .gpio0 = 0xff02,
  81. },{
  82. .type = CX23885_VMUX_SVIDEO,
  83. .vmux = 2,
  84. .gpio0 = 0xff02,
  85. }},
  86. },
  87. [CX23885_BOARD_HAUPPAUGE_HVR1250] = {
  88. .name = "Hauppauge WinTV-HVR1250",
  89. .portc = CX23885_MPEG_DVB,
  90. .input = {{
  91. .type = CX23885_VMUX_TELEVISION,
  92. .vmux = 0,
  93. .gpio0 = 0xff00,
  94. },{
  95. .type = CX23885_VMUX_DEBUG,
  96. .vmux = 0,
  97. .gpio0 = 0xff01,
  98. },{
  99. .type = CX23885_VMUX_COMPOSITE1,
  100. .vmux = 1,
  101. .gpio0 = 0xff02,
  102. },{
  103. .type = CX23885_VMUX_SVIDEO,
  104. .vmux = 2,
  105. .gpio0 = 0xff02,
  106. }},
  107. },
  108. [CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP] = {
  109. .name = "DViCO FusionHDTV5 Express",
  110. .portb = CX23885_MPEG_DVB,
  111. },
  112. [CX23885_BOARD_HAUPPAUGE_HVR1500Q] = {
  113. .name = "Hauppauge WinTV-HVR1500Q",
  114. .portc = CX23885_MPEG_DVB,
  115. },
  116. [CX23885_BOARD_HAUPPAUGE_HVR1500] = {
  117. .name = "Hauppauge WinTV-HVR1500",
  118. .portc = CX23885_MPEG_DVB,
  119. },
  120. };
  121. const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards);
  122. /* ------------------------------------------------------------------ */
  123. /* PCI subsystem IDs */
  124. struct cx23885_subid cx23885_subids[] = {
  125. {
  126. .subvendor = 0x0070,
  127. .subdevice = 0x3400,
  128. .card = CX23885_BOARD_UNKNOWN,
  129. },{
  130. .subvendor = 0x0070,
  131. .subdevice = 0x7600,
  132. .card = CX23885_BOARD_HAUPPAUGE_HVR1800lp,
  133. },{
  134. .subvendor = 0x0070,
  135. .subdevice = 0x7800,
  136. .card = CX23885_BOARD_HAUPPAUGE_HVR1800,
  137. },{
  138. .subvendor = 0x0070,
  139. .subdevice = 0x7801,
  140. .card = CX23885_BOARD_HAUPPAUGE_HVR1800,
  141. },{
  142. .subvendor = 0x0070,
  143. .subdevice = 0x7911,
  144. .card = CX23885_BOARD_HAUPPAUGE_HVR1250,
  145. },{
  146. .subvendor = 0x18ac,
  147. .subdevice = 0xd500,
  148. .card = CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP,
  149. },{
  150. .subvendor = 0x0070,
  151. .subdevice = 0x7797,
  152. .card = CX23885_BOARD_HAUPPAUGE_HVR1500Q,
  153. },{
  154. .subvendor = 0x0070,
  155. .subdevice = 0x7717,
  156. .card = CX23885_BOARD_HAUPPAUGE_HVR1500,
  157. },
  158. };
  159. const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids);
  160. void cx23885_card_list(struct cx23885_dev *dev)
  161. {
  162. int i;
  163. if (0 == dev->pci->subsystem_vendor &&
  164. 0 == dev->pci->subsystem_device) {
  165. printk("%s: Your board has no valid PCIe Subsystem ID and thus can't\n"
  166. "%s: be autodetected. Please pass card=<n> insmod option to\n"
  167. "%s: workaround that. Redirect complaints to the vendor of\n"
  168. "%s: the TV card. Best regards,\n"
  169. "%s: -- tux\n",
  170. dev->name, dev->name, dev->name, dev->name, dev->name);
  171. } else {
  172. printk("%s: Your board isn't known (yet) to the driver. You can\n"
  173. "%s: try to pick one of the existing card configs via\n"
  174. "%s: card=<n> insmod option. Updating to the latest\n"
  175. "%s: version might help as well.\n",
  176. dev->name, dev->name, dev->name, dev->name);
  177. }
  178. printk("%s: Here is a list of valid choices for the card=<n> insmod option:\n",
  179. dev->name);
  180. for (i = 0; i < cx23885_bcount; i++)
  181. printk("%s: card=%d -> %s\n",
  182. dev->name, i, cx23885_boards[i].name);
  183. }
  184. static void hauppauge_eeprom(struct cx23885_dev *dev, u8 *eeprom_data)
  185. {
  186. struct tveeprom tv;
  187. tveeprom_hauppauge_analog(&dev->i2c_bus[0].i2c_client, &tv, eeprom_data);
  188. /* Make sure we support the board model */
  189. switch (tv.model)
  190. {
  191. case 76601: /* WinTV-HVR1800lp (PCIe, Retail, No IR, Dual channel ATSC and MPEG2 HW Encoder */
  192. case 77001: /* WinTV-HVR1500 (Express Card, Retail, No IR, ATSC and Basic analog */
  193. case 77041: /* WinTV-HVR1500Q (Express Card, Retail, No IR, ATSC/QAM and Basic analog */
  194. case 78501: /* WinTV-HVR1800 (PCIe, Retail, IR, Dual channel ATSC and MPEG2 HW Encoder */
  195. case 78521: /* WinTV-HVR1800 (PCIe, Retail, IR, Dual channel ATSC and MPEG2 HW Encoder */
  196. break;
  197. default:
  198. printk("%s: warning: unknown hauppauge model #%d\n", dev->name, tv.model);
  199. break;
  200. }
  201. printk(KERN_INFO "%s: hauppauge eeprom: model=%d\n",
  202. dev->name, tv.model);
  203. }
  204. void cx23885_gpio_setup(struct cx23885_dev *dev)
  205. {
  206. switch(dev->board) {
  207. case CX23885_BOARD_HAUPPAUGE_HVR1250:
  208. /* GPIO-0 cx24227 demodulator reset */
  209. cx_set(GP0_IO, 0x00010001); /* Bring the part out of reset */
  210. break;
  211. case CX23885_BOARD_HAUPPAUGE_HVR1500:
  212. /* GPIO-0 cx24227 demodulator */
  213. /* GPIO-2 xc3028 tuner */
  214. /* Put the parts into reset */
  215. cx_set(GP0_IO, 0x00050000);
  216. cx_clear(GP0_IO, 0x00000005);
  217. msleep(5);
  218. /* Bring the parts out of reset */
  219. cx_set(GP0_IO, 0x00050005);
  220. break;
  221. case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
  222. /* GPIO-0 cx24227 demodulator reset */
  223. /* GPIO-2 xc5000 tuner reset */
  224. cx_set(GP0_IO, 0x00050005); /* Bring the part out of reset */
  225. break;
  226. case CX23885_BOARD_HAUPPAUGE_HVR1800:
  227. /* GPIO-0 656_CLK */
  228. /* GPIO-1 656_D0 */
  229. /* GPIO-2 8295A Reset */
  230. /* GPIO-3-10 cx23417 data0-7 */
  231. /* GPIO-11-14 cx23417 addr0-3 */
  232. /* GPIO-15-18 cx23417 READY, CS, RD, WR */
  233. /* GPIO-19 IR_RX */
  234. // FIXME: Analog requires the tuner is brought out of reset
  235. break;
  236. }
  237. }
  238. int cx23885_ir_init(struct cx23885_dev *dev)
  239. {
  240. switch (dev->board) {
  241. case CX23885_BOARD_HAUPPAUGE_HVR1250:
  242. case CX23885_BOARD_HAUPPAUGE_HVR1500:
  243. case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
  244. case CX23885_BOARD_HAUPPAUGE_HVR1800:
  245. /* FIXME: Implement me */
  246. break;
  247. }
  248. return 0;
  249. }
  250. void cx23885_card_setup(struct cx23885_dev *dev)
  251. {
  252. struct cx23885_tsport *ts1 = &dev->ts1;
  253. struct cx23885_tsport *ts2 = &dev->ts2;
  254. static u8 eeprom[256];
  255. if (dev->i2c_bus[0].i2c_rc == 0) {
  256. dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
  257. tveeprom_read(&dev->i2c_bus[0].i2c_client,
  258. eeprom, sizeof(eeprom));
  259. }
  260. switch (dev->board) {
  261. case CX23885_BOARD_HAUPPAUGE_HVR1250:
  262. case CX23885_BOARD_HAUPPAUGE_HVR1500:
  263. case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
  264. case CX23885_BOARD_HAUPPAUGE_HVR1800:
  265. case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
  266. if (dev->i2c_bus[0].i2c_rc == 0)
  267. hauppauge_eeprom(dev, eeprom+0x80);
  268. break;
  269. }
  270. switch (dev->board) {
  271. case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP:
  272. ts1->gen_ctrl_val = 0xc; /* Serial bus + punctured clock */
  273. ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
  274. ts1->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
  275. break;
  276. case CX23885_BOARD_HAUPPAUGE_HVR1250:
  277. case CX23885_BOARD_HAUPPAUGE_HVR1500:
  278. case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
  279. case CX23885_BOARD_HAUPPAUGE_HVR1800:
  280. case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
  281. default:
  282. ts2->gen_ctrl_val = 0xc; /* Serial bus + punctured clock */
  283. ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */
  284. ts2->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
  285. }
  286. }
  287. /* ------------------------------------------------------------------ */
  288. /*
  289. * Local variables:
  290. * c-basic-offset: 8
  291. * End:
  292. * kate: eol "unix"; indent-width 3; remove-trailing-space on; replace-trailing-space-save on; tab-width 8; replace-tabs off; space-indent off; mixed-indent off
  293. */