cx23885-cards.c 15 KB

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