cx23885-cards.c 7.7 KB

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