cx23885-cards.c 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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. };
  117. const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards);
  118. /* ------------------------------------------------------------------ */
  119. /* PCI subsystem IDs */
  120. struct cx23885_subid cx23885_subids[] = {
  121. {
  122. .subvendor = 0x0070,
  123. .subdevice = 0x3400,
  124. .card = CX23885_BOARD_UNKNOWN,
  125. },{
  126. .subvendor = 0x0070,
  127. .subdevice = 0x7600,
  128. .card = CX23885_BOARD_HAUPPAUGE_HVR1800lp,
  129. },{
  130. .subvendor = 0x0070,
  131. .subdevice = 0x7800,
  132. .card = CX23885_BOARD_HAUPPAUGE_HVR1800,
  133. },{
  134. .subvendor = 0x0070,
  135. .subdevice = 0x7801,
  136. .card = CX23885_BOARD_HAUPPAUGE_HVR1800,
  137. },{
  138. .subvendor = 0x0070,
  139. .subdevice = 0x7911,
  140. .card = CX23885_BOARD_HAUPPAUGE_HVR1250,
  141. },{
  142. .subvendor = 0x18ac,
  143. .subdevice = 0xd500,
  144. .card = CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP,
  145. },{
  146. .subvendor = 0x0070,
  147. .subdevice = 0x7797,
  148. .card = CX23885_BOARD_HAUPPAUGE_HVR1500Q,
  149. },
  150. };
  151. const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids);
  152. void cx23885_card_list(struct cx23885_dev *dev)
  153. {
  154. int i;
  155. if (0 == dev->pci->subsystem_vendor &&
  156. 0 == dev->pci->subsystem_device) {
  157. printk("%s: Your board has no valid PCIe Subsystem ID and thus can't\n"
  158. "%s: be autodetected. Please pass card=<n> insmod option to\n"
  159. "%s: workaround that. Redirect complaints to the vendor of\n"
  160. "%s: the TV card. Best regards,\n"
  161. "%s: -- tux\n",
  162. dev->name, dev->name, dev->name, dev->name, dev->name);
  163. } else {
  164. printk("%s: Your board isn't known (yet) to the driver. You can\n"
  165. "%s: try to pick one of the existing card configs via\n"
  166. "%s: card=<n> insmod option. Updating to the latest\n"
  167. "%s: version might help as well.\n",
  168. dev->name, dev->name, dev->name, dev->name);
  169. }
  170. printk("%s: Here is a list of valid choices for the card=<n> insmod option:\n",
  171. dev->name);
  172. for (i = 0; i < cx23885_bcount; i++)
  173. printk("%s: card=%d -> %s\n",
  174. dev->name, i, cx23885_boards[i].name);
  175. }
  176. static void hauppauge_eeprom(struct cx23885_dev *dev, u8 *eeprom_data)
  177. {
  178. struct tveeprom tv;
  179. tveeprom_hauppauge_analog(&dev->i2c_bus[0].i2c_client, &tv, eeprom_data);
  180. /* Make sure we support the board model */
  181. switch (tv.model)
  182. {
  183. case 76601: /* WinTV-HVR1800lp (PCIe, Retail, No IR, Dual channel ATSC and MPEG2 HW Encoder */
  184. case 77001: /* WinTV-HVR1500 (Express Card, Retail, No IR, ATSC and Basic analog */
  185. case 78501: /* WinTV-HVR1800 (PCIe, Retail, IR, Dual channel ATSC and MPEG2 HW Encoder */
  186. case 78521: /* WinTV-HVR1800 (PCIe, Retail, IR, Dual channel ATSC and MPEG2 HW Encoder */
  187. break;
  188. default:
  189. printk("%s: warning: unknown hauppauge model #%d\n", dev->name, tv.model);
  190. break;
  191. }
  192. printk(KERN_INFO "%s: hauppauge eeprom: model=%d\n",
  193. dev->name, tv.model);
  194. }
  195. void cx23885_gpio_setup(struct cx23885_dev *dev)
  196. {
  197. switch(dev->board) {
  198. case CX23885_BOARD_HAUPPAUGE_HVR1250:
  199. /* GPIO-0 cx24227 demodulator reset */
  200. cx_set(GP0_IO, 0x00010001); /* Bring the part out of reset */
  201. break;
  202. case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
  203. /* GPIO-0 cx24227 demodulator reset */
  204. /* GPIO-2 xc5000 tuner reset */
  205. cx_set(GP0_IO, 0x00050005); /* Bring the part out of reset */
  206. break;
  207. case CX23885_BOARD_HAUPPAUGE_HVR1800:
  208. /* GPIO-0 656_CLK */
  209. /* GPIO-1 656_D0 */
  210. /* GPIO-2 8295A Reset */
  211. /* GPIO-3-10 cx23417 data0-7 */
  212. /* GPIO-11-14 cx23417 addr0-3 */
  213. /* GPIO-15-18 cx23417 READY, CS, RD, WR */
  214. /* GPIO-19 IR_RX */
  215. // FIXME: Analog requires the tuner is brought out of reset
  216. break;
  217. }
  218. }
  219. int cx23885_ir_init(struct cx23885_dev *dev)
  220. {
  221. switch (dev->board) {
  222. case CX23885_BOARD_HAUPPAUGE_HVR1250:
  223. case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
  224. case CX23885_BOARD_HAUPPAUGE_HVR1800:
  225. /* FIXME: Implement me */
  226. break;
  227. }
  228. return 0;
  229. }
  230. void cx23885_card_setup(struct cx23885_dev *dev)
  231. {
  232. struct cx23885_tsport *ts1 = &dev->ts1;
  233. struct cx23885_tsport *ts2 = &dev->ts2;
  234. static u8 eeprom[256];
  235. if (dev->i2c_bus[0].i2c_rc == 0) {
  236. dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
  237. tveeprom_read(&dev->i2c_bus[0].i2c_client,
  238. eeprom, sizeof(eeprom));
  239. }
  240. switch (dev->board) {
  241. case CX23885_BOARD_HAUPPAUGE_HVR1250:
  242. case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
  243. case CX23885_BOARD_HAUPPAUGE_HVR1800:
  244. case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
  245. if (dev->i2c_bus[0].i2c_rc == 0)
  246. hauppauge_eeprom(dev, eeprom+0x80);
  247. break;
  248. }
  249. switch (dev->board) {
  250. case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP:
  251. ts1->gen_ctrl_val = 0xc; /* Serial bus + punctured clock */
  252. ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
  253. ts1->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
  254. break;
  255. case CX23885_BOARD_HAUPPAUGE_HVR1250:
  256. case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
  257. case CX23885_BOARD_HAUPPAUGE_HVR1800:
  258. case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
  259. default:
  260. ts2->gen_ctrl_val = 0xc; /* Serial bus + punctured clock */
  261. ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */
  262. ts2->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
  263. }
  264. }
  265. /* ------------------------------------------------------------------ */
  266. /*
  267. * Local variables:
  268. * c-basic-offset: 8
  269. * End:
  270. * 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
  271. */