cx23885-cards.c 9.6 KB

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