cx23885-cards.c 11 KB

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