cx23885-cards.c 10 KB

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