cx23885-cards.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  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 <media/cx25840.h>
  26. #include "cx23885.h"
  27. /* ------------------------------------------------------------------ */
  28. /* board config info */
  29. struct cx23885_board cx23885_boards[] = {
  30. [CX23885_BOARD_UNKNOWN] = {
  31. .name = "UNKNOWN/GENERIC",
  32. /* Ensure safe default for unknown boards */
  33. .clk_freq = 0,
  34. .input = {{
  35. .type = CX23885_VMUX_COMPOSITE1,
  36. .vmux = 0,
  37. },{
  38. .type = CX23885_VMUX_COMPOSITE2,
  39. .vmux = 1,
  40. },{
  41. .type = CX23885_VMUX_COMPOSITE3,
  42. .vmux = 2,
  43. },{
  44. .type = CX23885_VMUX_COMPOSITE4,
  45. .vmux = 3,
  46. }},
  47. },
  48. [CX23885_BOARD_HAUPPAUGE_HVR1800lp] = {
  49. .name = "Hauppauge WinTV-HVR1800lp",
  50. .portc = CX23885_MPEG_DVB,
  51. .input = {{
  52. .type = CX23885_VMUX_TELEVISION,
  53. .vmux = 0,
  54. .gpio0 = 0xff00,
  55. },{
  56. .type = CX23885_VMUX_DEBUG,
  57. .vmux = 0,
  58. .gpio0 = 0xff01,
  59. },{
  60. .type = CX23885_VMUX_COMPOSITE1,
  61. .vmux = 1,
  62. .gpio0 = 0xff02,
  63. },{
  64. .type = CX23885_VMUX_SVIDEO,
  65. .vmux = 2,
  66. .gpio0 = 0xff02,
  67. }},
  68. },
  69. [CX23885_BOARD_HAUPPAUGE_HVR1800] = {
  70. .name = "Hauppauge WinTV-HVR1800",
  71. .porta = CX23885_ANALOG_VIDEO,
  72. .portc = CX23885_MPEG_DVB,
  73. .tuner_type = TUNER_PHILIPS_TDA8290,
  74. .tuner_addr = 0x42, /* 0x84 >> 1 */
  75. .input = {{
  76. .type = CX23885_VMUX_TELEVISION,
  77. .vmux = CX25840_VIN7_CH3 |
  78. CX25840_VIN5_CH2 |
  79. CX25840_VIN2_CH1,
  80. .gpio0 = 0,
  81. },{
  82. .type = CX23885_VMUX_COMPOSITE1,
  83. .vmux = CX25840_VIN7_CH3 |
  84. CX25840_VIN4_CH2 |
  85. CX25840_VIN6_CH1,
  86. .gpio0 = 0,
  87. },{
  88. .type = CX23885_VMUX_SVIDEO,
  89. .vmux = CX25840_VIN7_CH3 |
  90. CX25840_VIN4_CH2 |
  91. CX25840_VIN8_CH1 |
  92. CX25840_SVIDEO_ON,
  93. .gpio0 = 0,
  94. }},
  95. },
  96. [CX23885_BOARD_HAUPPAUGE_HVR1250] = {
  97. .name = "Hauppauge WinTV-HVR1250",
  98. .portc = CX23885_MPEG_DVB,
  99. .input = {{
  100. .type = CX23885_VMUX_TELEVISION,
  101. .vmux = 0,
  102. .gpio0 = 0xff00,
  103. },{
  104. .type = CX23885_VMUX_DEBUG,
  105. .vmux = 0,
  106. .gpio0 = 0xff01,
  107. },{
  108. .type = CX23885_VMUX_COMPOSITE1,
  109. .vmux = 1,
  110. .gpio0 = 0xff02,
  111. },{
  112. .type = CX23885_VMUX_SVIDEO,
  113. .vmux = 2,
  114. .gpio0 = 0xff02,
  115. }},
  116. },
  117. [CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP] = {
  118. .name = "DViCO FusionHDTV5 Express",
  119. .portb = CX23885_MPEG_DVB,
  120. },
  121. [CX23885_BOARD_HAUPPAUGE_HVR1500Q] = {
  122. .name = "Hauppauge WinTV-HVR1500Q",
  123. .portc = CX23885_MPEG_DVB,
  124. },
  125. [CX23885_BOARD_HAUPPAUGE_HVR1500] = {
  126. .name = "Hauppauge WinTV-HVR1500",
  127. .portc = CX23885_MPEG_DVB,
  128. },
  129. [CX23885_BOARD_HAUPPAUGE_HVR1200] = {
  130. .name = "Hauppauge WinTV-HVR1200",
  131. .portc = CX23885_MPEG_DVB,
  132. },
  133. [CX23885_BOARD_HAUPPAUGE_HVR1700] = {
  134. .name = "Hauppauge WinTV-HVR1700",
  135. .portc = CX23885_MPEG_DVB,
  136. },
  137. };
  138. const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards);
  139. /* ------------------------------------------------------------------ */
  140. /* PCI subsystem IDs */
  141. struct cx23885_subid cx23885_subids[] = {
  142. {
  143. .subvendor = 0x0070,
  144. .subdevice = 0x3400,
  145. .card = CX23885_BOARD_UNKNOWN,
  146. },{
  147. .subvendor = 0x0070,
  148. .subdevice = 0x7600,
  149. .card = CX23885_BOARD_HAUPPAUGE_HVR1800lp,
  150. },{
  151. .subvendor = 0x0070,
  152. .subdevice = 0x7800,
  153. .card = CX23885_BOARD_HAUPPAUGE_HVR1800,
  154. },{
  155. .subvendor = 0x0070,
  156. .subdevice = 0x7801,
  157. .card = CX23885_BOARD_HAUPPAUGE_HVR1800,
  158. },{
  159. .subvendor = 0x0070,
  160. .subdevice = 0x7809,
  161. .card = CX23885_BOARD_HAUPPAUGE_HVR1800,
  162. },{
  163. .subvendor = 0x0070,
  164. .subdevice = 0x7911,
  165. .card = CX23885_BOARD_HAUPPAUGE_HVR1250,
  166. },{
  167. .subvendor = 0x18ac,
  168. .subdevice = 0xd500,
  169. .card = CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP,
  170. },{
  171. .subvendor = 0x0070,
  172. .subdevice = 0x7790,
  173. .card = CX23885_BOARD_HAUPPAUGE_HVR1500Q,
  174. },{
  175. .subvendor = 0x0070,
  176. .subdevice = 0x7797,
  177. .card = CX23885_BOARD_HAUPPAUGE_HVR1500Q,
  178. },{
  179. .subvendor = 0x0070,
  180. .subdevice = 0x7710,
  181. .card = CX23885_BOARD_HAUPPAUGE_HVR1500,
  182. },{
  183. .subvendor = 0x0070,
  184. .subdevice = 0x7717,
  185. .card = CX23885_BOARD_HAUPPAUGE_HVR1500,
  186. }, {
  187. .subvendor = 0x0070,
  188. .subdevice = 0x71d1,
  189. .card = CX23885_BOARD_HAUPPAUGE_HVR1200,
  190. }, {
  191. .subvendor = 0x0070,
  192. .subdevice = 0x8101,
  193. .card = CX23885_BOARD_HAUPPAUGE_HVR1700,
  194. },
  195. };
  196. const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids);
  197. void cx23885_card_list(struct cx23885_dev *dev)
  198. {
  199. int i;
  200. if (0 == dev->pci->subsystem_vendor &&
  201. 0 == dev->pci->subsystem_device) {
  202. printk("%s: Your board has no valid PCIe Subsystem ID and thus can't\n"
  203. "%s: be autodetected. Please pass card=<n> insmod option to\n"
  204. "%s: workaround that. Redirect complaints to the vendor of\n"
  205. "%s: the TV card. Best regards,\n"
  206. "%s: -- tux\n",
  207. dev->name, dev->name, dev->name, dev->name, dev->name);
  208. } else {
  209. printk("%s: Your board isn't known (yet) to the driver. You can\n"
  210. "%s: try to pick one of the existing card configs via\n"
  211. "%s: card=<n> insmod option. Updating to the latest\n"
  212. "%s: version might help as well.\n",
  213. dev->name, dev->name, dev->name, dev->name);
  214. }
  215. printk("%s: Here is a list of valid choices for the card=<n> insmod option:\n",
  216. dev->name);
  217. for (i = 0; i < cx23885_bcount; i++)
  218. printk("%s: card=%d -> %s\n",
  219. dev->name, i, cx23885_boards[i].name);
  220. }
  221. static void hauppauge_eeprom(struct cx23885_dev *dev, u8 *eeprom_data)
  222. {
  223. struct tveeprom tv;
  224. tveeprom_hauppauge_analog(&dev->i2c_bus[0].i2c_client, &tv, eeprom_data);
  225. /* Make sure we support the board model */
  226. switch (tv.model)
  227. {
  228. case 76601: /* WinTV-HVR1800lp (PCIe, Retail, No IR, Dual channel ATSC and MPEG2 HW Encoder */
  229. case 77001: /* WinTV-HVR1500 (Express Card, OEM, No IR, ATSC and Basic analog */
  230. case 77011: /* WinTV-HVR1500 (Express Card, Retail, No IR, ATSC and Basic analog */
  231. case 77041: /* WinTV-HVR1500Q (Express Card, OEM, No IR, ATSC/QAM and Basic analog */
  232. case 77051: /* WinTV-HVR1500Q (Express Card, Retail, No IR, ATSC/QAM and Basic analog */
  233. case 78011: /* WinTV-HVR1800 (PCIe, Retail, 3.5mm in, IR, No FM, Dual channel ATSC and MPEG2 HW Encoder */
  234. case 78501: /* WinTV-HVR1800 (PCIe, OEM, RCA in, No IR, FM, Dual channel ATSC and MPEG2 HW Encoder */
  235. case 78521: /* WinTV-HVR1800 (PCIe, OEM, RCA in, No IR, FM, Dual channel ATSC and MPEG2 HW Encoder */
  236. case 78531: /* WinTV-HVR1800 (PCIe, OEM, RCA in, No IR, No FM, Dual channel ATSC and MPEG2 HW Encoder */
  237. case 78631: /* WinTV-HVR1800 (PCIe, OEM, No IR, No FM, Dual channel ATSC and MPEG2 HW Encoder */
  238. case 79001: /* WinTV-HVR1250 (PCIe, Retail, IR, full height, ATSC and Basic analog */
  239. case 79101: /* WinTV-HVR1250 (PCIe, Retail, IR, half height, ATSC and Basic analog */
  240. case 79561: /* WinTV-HVR1250 (PCIe, OEM, No IR, half height, ATSC and Basic analog */
  241. case 79571: /* WinTV-HVR1250 (PCIe, OEM, No IR, full height, ATSC and Basic analog */
  242. case 79671: /* WinTV-HVR1250 (PCIe, OEM, No IR, half height, ATSC and Basic analog */
  243. case 81519:
  244. /* WinTV-HVR1700 (PCIe, Retail, No IR, half height,
  245. * DVB-T and MPEG2 HW Encoder */
  246. break;
  247. default:
  248. printk("%s: warning: unknown hauppauge model #%d\n", dev->name, tv.model);
  249. break;
  250. }
  251. printk(KERN_INFO "%s: hauppauge eeprom: model=%d\n",
  252. dev->name, tv.model);
  253. }
  254. /* Tuner callback function for cx23885 boards. Currently only needed
  255. * for HVR1500Q, which has an xc5000 tuner.
  256. */
  257. int cx23885_tuner_callback(void *priv, int command, int arg)
  258. {
  259. struct cx23885_i2c *bus = priv;
  260. struct cx23885_dev *dev = bus->dev;
  261. switch(dev->board) {
  262. case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
  263. if(command == 0) { /* Tuner Reset Command from xc5000 */
  264. /* Drive the tuner into reset and out */
  265. cx_clear(GP0_IO, 0x00000004);
  266. mdelay(200);
  267. cx_set(GP0_IO, 0x00000004);
  268. return 0;
  269. }
  270. else {
  271. printk(KERN_ERR
  272. "%s(): Unknow command.\n", __func__);
  273. return -EINVAL;
  274. }
  275. break;
  276. }
  277. return 0; /* Should never be here */
  278. }
  279. void cx23885_gpio_setup(struct cx23885_dev *dev)
  280. {
  281. switch(dev->board) {
  282. case CX23885_BOARD_HAUPPAUGE_HVR1250:
  283. /* GPIO-0 cx24227 demodulator reset */
  284. cx_set(GP0_IO, 0x00010001); /* Bring the part out of reset */
  285. break;
  286. case CX23885_BOARD_HAUPPAUGE_HVR1500:
  287. /* GPIO-0 cx24227 demodulator */
  288. /* GPIO-2 xc3028 tuner */
  289. /* Put the parts into reset */
  290. cx_set(GP0_IO, 0x00050000);
  291. cx_clear(GP0_IO, 0x00000005);
  292. msleep(5);
  293. /* Bring the parts out of reset */
  294. cx_set(GP0_IO, 0x00050005);
  295. break;
  296. case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
  297. /* GPIO-0 cx24227 demodulator reset */
  298. /* GPIO-2 xc5000 tuner reset */
  299. cx_set(GP0_IO, 0x00050005); /* Bring the part out of reset */
  300. break;
  301. case CX23885_BOARD_HAUPPAUGE_HVR1800:
  302. /* GPIO-0 656_CLK */
  303. /* GPIO-1 656_D0 */
  304. /* GPIO-2 8295A Reset */
  305. /* GPIO-3-10 cx23417 data0-7 */
  306. /* GPIO-11-14 cx23417 addr0-3 */
  307. /* GPIO-15-18 cx23417 READY, CS, RD, WR */
  308. /* GPIO-19 IR_RX */
  309. /* Force the TDA8295A into reset and back */
  310. cx_set(GP0_IO, 0x00040004);
  311. mdelay(20);
  312. cx_clear(GP0_IO, 0x00000004);
  313. mdelay(20);
  314. cx_set(GP0_IO, 0x00040004);
  315. mdelay(20);
  316. break;
  317. case CX23885_BOARD_HAUPPAUGE_HVR1200:
  318. /* GPIO-0 tda10048 demodulator reset */
  319. /* GPIO-2 tda18271 tuner reset */
  320. /* Put the parts into reset and back */
  321. cx_set(GP0_IO, 0x00050000);
  322. mdelay(20);
  323. cx_clear(GP0_IO, 0x00000005);
  324. mdelay(20);
  325. cx_set(GP0_IO, 0x00050005);
  326. break;
  327. case CX23885_BOARD_HAUPPAUGE_HVR1700:
  328. /* GPIO-0 TDA10048 demodulator reset */
  329. /* GPIO-2 TDA8295A Reset */
  330. /* GPIO-3-10 cx23417 data0-7 */
  331. /* GPIO-11-14 cx23417 addr0-3 */
  332. /* GPIO-15-18 cx23417 READY, CS, RD, WR */
  333. /* The following GPIO's are on the interna AVCore (cx25840) */
  334. /* GPIO-19 IR_RX */
  335. /* GPIO-20 IR_TX 416/DVBT Select */
  336. /* GPIO-21 IIS DAT */
  337. /* GPIO-22 IIS WCLK */
  338. /* GPIO-23 IIS BCLK */
  339. /* Put the parts into reset and back */
  340. cx_set(GP0_IO, 0x00050000);
  341. mdelay(20);
  342. cx_clear(GP0_IO, 0x00000005);
  343. mdelay(20);
  344. cx_set(GP0_IO, 0x00050005);
  345. break;
  346. }
  347. }
  348. int cx23885_ir_init(struct cx23885_dev *dev)
  349. {
  350. switch (dev->board) {
  351. case CX23885_BOARD_HAUPPAUGE_HVR1250:
  352. case CX23885_BOARD_HAUPPAUGE_HVR1500:
  353. case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
  354. case CX23885_BOARD_HAUPPAUGE_HVR1800:
  355. case CX23885_BOARD_HAUPPAUGE_HVR1200:
  356. /* FIXME: Implement me */
  357. break;
  358. }
  359. return 0;
  360. }
  361. void cx23885_card_setup(struct cx23885_dev *dev)
  362. {
  363. struct cx23885_tsport *ts1 = &dev->ts1;
  364. struct cx23885_tsport *ts2 = &dev->ts2;
  365. static u8 eeprom[256];
  366. if (dev->i2c_bus[0].i2c_rc == 0) {
  367. dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
  368. tveeprom_read(&dev->i2c_bus[0].i2c_client,
  369. eeprom, sizeof(eeprom));
  370. }
  371. switch (dev->board) {
  372. case CX23885_BOARD_HAUPPAUGE_HVR1250:
  373. case CX23885_BOARD_HAUPPAUGE_HVR1500:
  374. case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
  375. if (dev->i2c_bus[0].i2c_rc == 0)
  376. hauppauge_eeprom(dev, eeprom+0x80);
  377. break;
  378. case CX23885_BOARD_HAUPPAUGE_HVR1800:
  379. case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
  380. case CX23885_BOARD_HAUPPAUGE_HVR1200:
  381. case CX23885_BOARD_HAUPPAUGE_HVR1700:
  382. if (dev->i2c_bus[0].i2c_rc == 0)
  383. hauppauge_eeprom(dev, eeprom+0xc0);
  384. break;
  385. }
  386. switch (dev->board) {
  387. case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP:
  388. ts1->gen_ctrl_val = 0xc; /* Serial bus + punctured clock */
  389. ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
  390. ts1->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
  391. break;
  392. case CX23885_BOARD_HAUPPAUGE_HVR1250:
  393. case CX23885_BOARD_HAUPPAUGE_HVR1500:
  394. case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
  395. case CX23885_BOARD_HAUPPAUGE_HVR1800:
  396. case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
  397. case CX23885_BOARD_HAUPPAUGE_HVR1200:
  398. case CX23885_BOARD_HAUPPAUGE_HVR1700:
  399. default:
  400. ts2->gen_ctrl_val = 0xc; /* Serial bus + punctured clock */
  401. ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */
  402. ts2->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
  403. }
  404. }
  405. /* ------------------------------------------------------------------ */
  406. /*
  407. * Local variables:
  408. * c-basic-offset: 8
  409. * End:
  410. * 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
  411. */