cx23885-cards.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  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. };
  134. const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards);
  135. /* ------------------------------------------------------------------ */
  136. /* PCI subsystem IDs */
  137. struct cx23885_subid cx23885_subids[] = {
  138. {
  139. .subvendor = 0x0070,
  140. .subdevice = 0x3400,
  141. .card = CX23885_BOARD_UNKNOWN,
  142. },{
  143. .subvendor = 0x0070,
  144. .subdevice = 0x7600,
  145. .card = CX23885_BOARD_HAUPPAUGE_HVR1800lp,
  146. },{
  147. .subvendor = 0x0070,
  148. .subdevice = 0x7800,
  149. .card = CX23885_BOARD_HAUPPAUGE_HVR1800,
  150. },{
  151. .subvendor = 0x0070,
  152. .subdevice = 0x7801,
  153. .card = CX23885_BOARD_HAUPPAUGE_HVR1800,
  154. },{
  155. .subvendor = 0x0070,
  156. .subdevice = 0x7809,
  157. .card = CX23885_BOARD_HAUPPAUGE_HVR1800,
  158. },{
  159. .subvendor = 0x0070,
  160. .subdevice = 0x7911,
  161. .card = CX23885_BOARD_HAUPPAUGE_HVR1250,
  162. },{
  163. .subvendor = 0x18ac,
  164. .subdevice = 0xd500,
  165. .card = CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP,
  166. },{
  167. .subvendor = 0x0070,
  168. .subdevice = 0x7790,
  169. .card = CX23885_BOARD_HAUPPAUGE_HVR1500Q,
  170. },{
  171. .subvendor = 0x0070,
  172. .subdevice = 0x7797,
  173. .card = CX23885_BOARD_HAUPPAUGE_HVR1500Q,
  174. },{
  175. .subvendor = 0x0070,
  176. .subdevice = 0x7710,
  177. .card = CX23885_BOARD_HAUPPAUGE_HVR1500,
  178. },{
  179. .subvendor = 0x0070,
  180. .subdevice = 0x7717,
  181. .card = CX23885_BOARD_HAUPPAUGE_HVR1500,
  182. }, {
  183. .subvendor = 0x0070,
  184. .subdevice = 0x71d1,
  185. .card = CX23885_BOARD_HAUPPAUGE_HVR1200,
  186. },
  187. };
  188. const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids);
  189. void cx23885_card_list(struct cx23885_dev *dev)
  190. {
  191. int i;
  192. if (0 == dev->pci->subsystem_vendor &&
  193. 0 == dev->pci->subsystem_device) {
  194. printk("%s: Your board has no valid PCIe Subsystem ID and thus can't\n"
  195. "%s: be autodetected. Please pass card=<n> insmod option to\n"
  196. "%s: workaround that. Redirect complaints to the vendor of\n"
  197. "%s: the TV card. Best regards,\n"
  198. "%s: -- tux\n",
  199. dev->name, dev->name, dev->name, dev->name, dev->name);
  200. } else {
  201. printk("%s: Your board isn't known (yet) to the driver. You can\n"
  202. "%s: try to pick one of the existing card configs via\n"
  203. "%s: card=<n> insmod option. Updating to the latest\n"
  204. "%s: version might help as well.\n",
  205. dev->name, dev->name, dev->name, dev->name);
  206. }
  207. printk("%s: Here is a list of valid choices for the card=<n> insmod option:\n",
  208. dev->name);
  209. for (i = 0; i < cx23885_bcount; i++)
  210. printk("%s: card=%d -> %s\n",
  211. dev->name, i, cx23885_boards[i].name);
  212. }
  213. static void hauppauge_eeprom(struct cx23885_dev *dev, u8 *eeprom_data)
  214. {
  215. struct tveeprom tv;
  216. tveeprom_hauppauge_analog(&dev->i2c_bus[0].i2c_client, &tv, eeprom_data);
  217. /* Make sure we support the board model */
  218. switch (tv.model)
  219. {
  220. case 76601: /* WinTV-HVR1800lp (PCIe, Retail, No IR, Dual channel ATSC and MPEG2 HW Encoder */
  221. case 77001: /* WinTV-HVR1500 (Express Card, OEM, No IR, ATSC and Basic analog */
  222. case 77011: /* WinTV-HVR1500 (Express Card, Retail, No IR, ATSC and Basic analog */
  223. case 77041: /* WinTV-HVR1500Q (Express Card, OEM, No IR, ATSC/QAM and Basic analog */
  224. case 77051: /* WinTV-HVR1500Q (Express Card, Retail, No IR, ATSC/QAM and Basic analog */
  225. case 78011: /* WinTV-HVR1800 (PCIe, Retail, 3.5mm in, IR, No FM, Dual channel ATSC and MPEG2 HW Encoder */
  226. case 78501: /* WinTV-HVR1800 (PCIe, OEM, RCA in, No IR, FM, Dual channel ATSC and MPEG2 HW Encoder */
  227. case 78521: /* WinTV-HVR1800 (PCIe, OEM, RCA in, No IR, FM, Dual channel ATSC and MPEG2 HW Encoder */
  228. case 78531: /* WinTV-HVR1800 (PCIe, OEM, RCA in, No IR, No FM, Dual channel ATSC and MPEG2 HW Encoder */
  229. case 78631: /* WinTV-HVR1800 (PCIe, OEM, No IR, No FM, Dual channel ATSC and MPEG2 HW Encoder */
  230. case 79001: /* WinTV-HVR1250 (PCIe, Retail, IR, full height, ATSC and Basic analog */
  231. case 79101: /* WinTV-HVR1250 (PCIe, Retail, IR, half height, ATSC and Basic analog */
  232. case 79561: /* WinTV-HVR1250 (PCIe, OEM, No IR, half height, ATSC and Basic analog */
  233. case 79571: /* WinTV-HVR1250 (PCIe, OEM, No IR, full height, ATSC and Basic analog */
  234. case 79671: /* WinTV-HVR1250 (PCIe, OEM, No IR, half height, ATSC and Basic analog */
  235. break;
  236. default:
  237. printk("%s: warning: unknown hauppauge model #%d\n", dev->name, tv.model);
  238. break;
  239. }
  240. printk(KERN_INFO "%s: hauppauge eeprom: model=%d\n",
  241. dev->name, tv.model);
  242. }
  243. /* Tuner callback function for cx23885 boards. Currently only needed
  244. * for HVR1500Q, which has an xc5000 tuner.
  245. */
  246. int cx23885_tuner_callback(void *priv, int command, int arg)
  247. {
  248. struct cx23885_i2c *bus = priv;
  249. struct cx23885_dev *dev = bus->dev;
  250. switch(dev->board) {
  251. case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
  252. if(command == 0) { /* Tuner Reset Command from xc5000 */
  253. /* Drive the tuner into reset and out */
  254. cx_clear(GP0_IO, 0x00000004);
  255. mdelay(200);
  256. cx_set(GP0_IO, 0x00000004);
  257. return 0;
  258. }
  259. else {
  260. printk(KERN_ERR
  261. "%s(): Unknow command.\n", __func__);
  262. return -EINVAL;
  263. }
  264. break;
  265. }
  266. return 0; /* Should never be here */
  267. }
  268. void cx23885_gpio_setup(struct cx23885_dev *dev)
  269. {
  270. switch(dev->board) {
  271. case CX23885_BOARD_HAUPPAUGE_HVR1250:
  272. /* GPIO-0 cx24227 demodulator reset */
  273. cx_set(GP0_IO, 0x00010001); /* Bring the part out of reset */
  274. break;
  275. case CX23885_BOARD_HAUPPAUGE_HVR1500:
  276. /* GPIO-0 cx24227 demodulator */
  277. /* GPIO-2 xc3028 tuner */
  278. /* Put the parts into reset */
  279. cx_set(GP0_IO, 0x00050000);
  280. cx_clear(GP0_IO, 0x00000005);
  281. msleep(5);
  282. /* Bring the parts out of reset */
  283. cx_set(GP0_IO, 0x00050005);
  284. break;
  285. case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
  286. /* GPIO-0 cx24227 demodulator reset */
  287. /* GPIO-2 xc5000 tuner reset */
  288. cx_set(GP0_IO, 0x00050005); /* Bring the part out of reset */
  289. break;
  290. case CX23885_BOARD_HAUPPAUGE_HVR1800:
  291. /* GPIO-0 656_CLK */
  292. /* GPIO-1 656_D0 */
  293. /* GPIO-2 8295A Reset */
  294. /* GPIO-3-10 cx23417 data0-7 */
  295. /* GPIO-11-14 cx23417 addr0-3 */
  296. /* GPIO-15-18 cx23417 READY, CS, RD, WR */
  297. /* GPIO-19 IR_RX */
  298. /* Force the TDA8295A into reset and back */
  299. cx_set(GP0_IO, 0x00040004);
  300. mdelay(20);
  301. cx_clear(GP0_IO, 0x00000004);
  302. mdelay(20);
  303. cx_set(GP0_IO, 0x00040004);
  304. mdelay(20);
  305. break;
  306. case CX23885_BOARD_HAUPPAUGE_HVR1200:
  307. /* GPIO-0 tda10048 demodulator reset */
  308. /* GPIO-2 tda18271 tuner reset */
  309. /* Put the parts into reset and back */
  310. cx_set(GP0_IO, 0x00050000);
  311. mdelay(20);
  312. cx_clear(GP0_IO, 0x00000005);
  313. mdelay(20);
  314. cx_set(GP0_IO, 0x00050005);
  315. break;
  316. }
  317. }
  318. int cx23885_ir_init(struct cx23885_dev *dev)
  319. {
  320. switch (dev->board) {
  321. case CX23885_BOARD_HAUPPAUGE_HVR1250:
  322. case CX23885_BOARD_HAUPPAUGE_HVR1500:
  323. case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
  324. case CX23885_BOARD_HAUPPAUGE_HVR1800:
  325. case CX23885_BOARD_HAUPPAUGE_HVR1200:
  326. /* FIXME: Implement me */
  327. break;
  328. }
  329. return 0;
  330. }
  331. void cx23885_card_setup(struct cx23885_dev *dev)
  332. {
  333. struct cx23885_tsport *ts1 = &dev->ts1;
  334. struct cx23885_tsport *ts2 = &dev->ts2;
  335. static u8 eeprom[256];
  336. if (dev->i2c_bus[0].i2c_rc == 0) {
  337. dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
  338. tveeprom_read(&dev->i2c_bus[0].i2c_client,
  339. eeprom, sizeof(eeprom));
  340. }
  341. switch (dev->board) {
  342. case CX23885_BOARD_HAUPPAUGE_HVR1250:
  343. case CX23885_BOARD_HAUPPAUGE_HVR1500:
  344. case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
  345. if (dev->i2c_bus[0].i2c_rc == 0)
  346. hauppauge_eeprom(dev, eeprom+0x80);
  347. break;
  348. case CX23885_BOARD_HAUPPAUGE_HVR1800:
  349. case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
  350. case CX23885_BOARD_HAUPPAUGE_HVR1200:
  351. if (dev->i2c_bus[0].i2c_rc == 0)
  352. hauppauge_eeprom(dev, eeprom+0xc0);
  353. break;
  354. }
  355. switch (dev->board) {
  356. case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP:
  357. ts1->gen_ctrl_val = 0xc; /* Serial bus + punctured clock */
  358. ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
  359. ts1->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
  360. break;
  361. case CX23885_BOARD_HAUPPAUGE_HVR1250:
  362. case CX23885_BOARD_HAUPPAUGE_HVR1500:
  363. case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
  364. case CX23885_BOARD_HAUPPAUGE_HVR1800:
  365. case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
  366. case CX23885_BOARD_HAUPPAUGE_HVR1200:
  367. default:
  368. ts2->gen_ctrl_val = 0xc; /* Serial bus + punctured clock */
  369. ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */
  370. ts2->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
  371. }
  372. }
  373. /* ------------------------------------------------------------------ */
  374. /*
  375. * Local variables:
  376. * c-basic-offset: 8
  377. * End:
  378. * 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
  379. */