cx23885-cards.c 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856
  1. /*
  2. * Driver for the Conexant CX23885 PCIe bridge
  3. *
  4. * Copyright (c) 2006 Steven Toth <stoth@linuxtv.org>
  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. #include "tuner-xc2028.h"
  28. #include "netup-init.h"
  29. /* ------------------------------------------------------------------ */
  30. /* board config info */
  31. struct cx23885_board cx23885_boards[] = {
  32. [CX23885_BOARD_UNKNOWN] = {
  33. .name = "UNKNOWN/GENERIC",
  34. /* Ensure safe default for unknown boards */
  35. .clk_freq = 0,
  36. .input = {{
  37. .type = CX23885_VMUX_COMPOSITE1,
  38. .vmux = 0,
  39. }, {
  40. .type = CX23885_VMUX_COMPOSITE2,
  41. .vmux = 1,
  42. }, {
  43. .type = CX23885_VMUX_COMPOSITE3,
  44. .vmux = 2,
  45. }, {
  46. .type = CX23885_VMUX_COMPOSITE4,
  47. .vmux = 3,
  48. } },
  49. },
  50. [CX23885_BOARD_HAUPPAUGE_HVR1800lp] = {
  51. .name = "Hauppauge WinTV-HVR1800lp",
  52. .portc = CX23885_MPEG_DVB,
  53. .input = {{
  54. .type = CX23885_VMUX_TELEVISION,
  55. .vmux = 0,
  56. .gpio0 = 0xff00,
  57. }, {
  58. .type = CX23885_VMUX_DEBUG,
  59. .vmux = 0,
  60. .gpio0 = 0xff01,
  61. }, {
  62. .type = CX23885_VMUX_COMPOSITE1,
  63. .vmux = 1,
  64. .gpio0 = 0xff02,
  65. }, {
  66. .type = CX23885_VMUX_SVIDEO,
  67. .vmux = 2,
  68. .gpio0 = 0xff02,
  69. } },
  70. },
  71. [CX23885_BOARD_HAUPPAUGE_HVR1800] = {
  72. .name = "Hauppauge WinTV-HVR1800",
  73. .porta = CX23885_ANALOG_VIDEO,
  74. .portb = CX23885_MPEG_ENCODER,
  75. .portc = CX23885_MPEG_DVB,
  76. .tuner_type = TUNER_PHILIPS_TDA8290,
  77. .tuner_addr = 0x42, /* 0x84 >> 1 */
  78. .input = {{
  79. .type = CX23885_VMUX_TELEVISION,
  80. .vmux = CX25840_VIN7_CH3 |
  81. CX25840_VIN5_CH2 |
  82. CX25840_VIN2_CH1,
  83. .gpio0 = 0,
  84. }, {
  85. .type = CX23885_VMUX_COMPOSITE1,
  86. .vmux = CX25840_VIN7_CH3 |
  87. CX25840_VIN4_CH2 |
  88. CX25840_VIN6_CH1,
  89. .gpio0 = 0,
  90. }, {
  91. .type = CX23885_VMUX_SVIDEO,
  92. .vmux = CX25840_VIN7_CH3 |
  93. CX25840_VIN4_CH2 |
  94. CX25840_VIN8_CH1 |
  95. CX25840_SVIDEO_ON,
  96. .gpio0 = 0,
  97. } },
  98. },
  99. [CX23885_BOARD_HAUPPAUGE_HVR1250] = {
  100. .name = "Hauppauge WinTV-HVR1250",
  101. .portc = CX23885_MPEG_DVB,
  102. .input = {{
  103. .type = CX23885_VMUX_TELEVISION,
  104. .vmux = 0,
  105. .gpio0 = 0xff00,
  106. }, {
  107. .type = CX23885_VMUX_DEBUG,
  108. .vmux = 0,
  109. .gpio0 = 0xff01,
  110. }, {
  111. .type = CX23885_VMUX_COMPOSITE1,
  112. .vmux = 1,
  113. .gpio0 = 0xff02,
  114. }, {
  115. .type = CX23885_VMUX_SVIDEO,
  116. .vmux = 2,
  117. .gpio0 = 0xff02,
  118. } },
  119. },
  120. [CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP] = {
  121. .name = "DViCO FusionHDTV5 Express",
  122. .portb = CX23885_MPEG_DVB,
  123. },
  124. [CX23885_BOARD_HAUPPAUGE_HVR1500Q] = {
  125. .name = "Hauppauge WinTV-HVR1500Q",
  126. .portc = CX23885_MPEG_DVB,
  127. },
  128. [CX23885_BOARD_HAUPPAUGE_HVR1500] = {
  129. .name = "Hauppauge WinTV-HVR1500",
  130. .portc = CX23885_MPEG_DVB,
  131. },
  132. [CX23885_BOARD_HAUPPAUGE_HVR1200] = {
  133. .name = "Hauppauge WinTV-HVR1200",
  134. .portc = CX23885_MPEG_DVB,
  135. },
  136. [CX23885_BOARD_HAUPPAUGE_HVR1700] = {
  137. .name = "Hauppauge WinTV-HVR1700",
  138. .portc = CX23885_MPEG_DVB,
  139. },
  140. [CX23885_BOARD_HAUPPAUGE_HVR1400] = {
  141. .name = "Hauppauge WinTV-HVR1400",
  142. .portc = CX23885_MPEG_DVB,
  143. },
  144. [CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP] = {
  145. .name = "DViCO FusionHDTV7 Dual Express",
  146. .portb = CX23885_MPEG_DVB,
  147. .portc = CX23885_MPEG_DVB,
  148. },
  149. [CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP] = {
  150. .name = "DViCO FusionHDTV DVB-T Dual Express",
  151. .portb = CX23885_MPEG_DVB,
  152. .portc = CX23885_MPEG_DVB,
  153. },
  154. [CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H] = {
  155. .name = "Leadtek Winfast PxDVR3200 H",
  156. .portc = CX23885_MPEG_DVB,
  157. },
  158. [CX23885_BOARD_COMPRO_VIDEOMATE_E650F] = {
  159. .name = "Compro VideoMate E650F",
  160. .portc = CX23885_MPEG_DVB,
  161. },
  162. [CX23885_BOARD_TBS_6920] = {
  163. .name = "TurboSight TBS 6920",
  164. .portb = CX23885_MPEG_DVB,
  165. },
  166. [CX23885_BOARD_TEVII_S470] = {
  167. .name = "TeVii S470",
  168. .portb = CX23885_MPEG_DVB,
  169. },
  170. [CX23885_BOARD_DVBWORLD_2005] = {
  171. .name = "DVBWorld DVB-S2 2005",
  172. .portb = CX23885_MPEG_DVB,
  173. },
  174. [CX23885_BOARD_NETUP_DUAL_DVBS2_CI] = {
  175. .cimax = 1,
  176. .name = "NetUP Dual DVB-S2 CI",
  177. .portb = CX23885_MPEG_DVB,
  178. .portc = CX23885_MPEG_DVB,
  179. },
  180. [CX23885_BOARD_HAUPPAUGE_HVR1270] = {
  181. .name = "Hauppauge WinTV-HVR1270",
  182. .portc = CX23885_MPEG_DVB,
  183. },
  184. [CX23885_BOARD_HAUPPAUGE_HVR1275] = {
  185. .name = "Hauppauge WinTV-HVR1275",
  186. .portc = CX23885_MPEG_DVB,
  187. },
  188. [CX23885_BOARD_HAUPPAUGE_HVR1255] = {
  189. .name = "Hauppauge WinTV-HVR1255",
  190. .portc = CX23885_MPEG_DVB,
  191. },
  192. [CX23885_BOARD_HAUPPAUGE_HVR1210] = {
  193. .name = "Hauppauge WinTV-HVR1210",
  194. .portc = CX23885_MPEG_DVB,
  195. },
  196. };
  197. const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards);
  198. /* ------------------------------------------------------------------ */
  199. /* PCI subsystem IDs */
  200. struct cx23885_subid cx23885_subids[] = {
  201. {
  202. .subvendor = 0x0070,
  203. .subdevice = 0x3400,
  204. .card = CX23885_BOARD_UNKNOWN,
  205. }, {
  206. .subvendor = 0x0070,
  207. .subdevice = 0x7600,
  208. .card = CX23885_BOARD_HAUPPAUGE_HVR1800lp,
  209. }, {
  210. .subvendor = 0x0070,
  211. .subdevice = 0x7800,
  212. .card = CX23885_BOARD_HAUPPAUGE_HVR1800,
  213. }, {
  214. .subvendor = 0x0070,
  215. .subdevice = 0x7801,
  216. .card = CX23885_BOARD_HAUPPAUGE_HVR1800,
  217. }, {
  218. .subvendor = 0x0070,
  219. .subdevice = 0x7809,
  220. .card = CX23885_BOARD_HAUPPAUGE_HVR1800,
  221. }, {
  222. .subvendor = 0x0070,
  223. .subdevice = 0x7911,
  224. .card = CX23885_BOARD_HAUPPAUGE_HVR1250,
  225. }, {
  226. .subvendor = 0x18ac,
  227. .subdevice = 0xd500,
  228. .card = CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP,
  229. }, {
  230. .subvendor = 0x0070,
  231. .subdevice = 0x7790,
  232. .card = CX23885_BOARD_HAUPPAUGE_HVR1500Q,
  233. }, {
  234. .subvendor = 0x0070,
  235. .subdevice = 0x7797,
  236. .card = CX23885_BOARD_HAUPPAUGE_HVR1500Q,
  237. }, {
  238. .subvendor = 0x0070,
  239. .subdevice = 0x7710,
  240. .card = CX23885_BOARD_HAUPPAUGE_HVR1500,
  241. }, {
  242. .subvendor = 0x0070,
  243. .subdevice = 0x7717,
  244. .card = CX23885_BOARD_HAUPPAUGE_HVR1500,
  245. }, {
  246. .subvendor = 0x0070,
  247. .subdevice = 0x71d1,
  248. .card = CX23885_BOARD_HAUPPAUGE_HVR1200,
  249. }, {
  250. .subvendor = 0x0070,
  251. .subdevice = 0x71d3,
  252. .card = CX23885_BOARD_HAUPPAUGE_HVR1200,
  253. }, {
  254. .subvendor = 0x0070,
  255. .subdevice = 0x8101,
  256. .card = CX23885_BOARD_HAUPPAUGE_HVR1700,
  257. }, {
  258. .subvendor = 0x0070,
  259. .subdevice = 0x8010,
  260. .card = CX23885_BOARD_HAUPPAUGE_HVR1400,
  261. }, {
  262. .subvendor = 0x18ac,
  263. .subdevice = 0xd618,
  264. .card = CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP,
  265. }, {
  266. .subvendor = 0x18ac,
  267. .subdevice = 0xdb78,
  268. .card = CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP,
  269. }, {
  270. .subvendor = 0x107d,
  271. .subdevice = 0x6681,
  272. .card = CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H,
  273. }, {
  274. .subvendor = 0x185b,
  275. .subdevice = 0xe800,
  276. .card = CX23885_BOARD_COMPRO_VIDEOMATE_E650F,
  277. }, {
  278. .subvendor = 0x6920,
  279. .subdevice = 0x8888,
  280. .card = CX23885_BOARD_TBS_6920,
  281. }, {
  282. .subvendor = 0xd470,
  283. .subdevice = 0x9022,
  284. .card = CX23885_BOARD_TEVII_S470,
  285. }, {
  286. .subvendor = 0x0001,
  287. .subdevice = 0x2005,
  288. .card = CX23885_BOARD_DVBWORLD_2005,
  289. }, {
  290. .subvendor = 0x1b55,
  291. .subdevice = 0x2a2c,
  292. .card = CX23885_BOARD_NETUP_DUAL_DVBS2_CI,
  293. }, {
  294. .subvendor = 0x0070,
  295. .subdevice = 0x2211,
  296. .card = CX23885_BOARD_HAUPPAUGE_HVR1270,
  297. }, {
  298. .subvendor = 0x0070,
  299. .subdevice = 0x2215,
  300. .card = CX23885_BOARD_HAUPPAUGE_HVR1275,
  301. }, {
  302. .subvendor = 0x0070,
  303. .subdevice = 0x2251,
  304. .card = CX23885_BOARD_HAUPPAUGE_HVR1255,
  305. }, {
  306. .subvendor = 0x0070,
  307. .subdevice = 0x2291,
  308. .card = CX23885_BOARD_HAUPPAUGE_HVR1210,
  309. }, {
  310. .subvendor = 0x0070,
  311. .subdevice = 0x2295,
  312. .card = CX23885_BOARD_HAUPPAUGE_HVR1210,
  313. },
  314. };
  315. const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids);
  316. void cx23885_card_list(struct cx23885_dev *dev)
  317. {
  318. int i;
  319. if (0 == dev->pci->subsystem_vendor &&
  320. 0 == dev->pci->subsystem_device) {
  321. printk(KERN_INFO
  322. "%s: Board has no valid PCIe Subsystem ID and can't\n"
  323. "%s: be autodetected. Pass card=<n> insmod option\n"
  324. "%s: to workaround that. Redirect complaints to the\n"
  325. "%s: vendor of the TV card. Best regards,\n"
  326. "%s: -- tux\n",
  327. dev->name, dev->name, dev->name, dev->name, dev->name);
  328. } else {
  329. printk(KERN_INFO
  330. "%s: Your board isn't known (yet) to the driver.\n"
  331. "%s: Try to pick one of the existing card configs via\n"
  332. "%s: card=<n> insmod option. Updating to the latest\n"
  333. "%s: version might help as well.\n",
  334. dev->name, dev->name, dev->name, dev->name);
  335. }
  336. printk(KERN_INFO "%s: Here is a list of valid choices for the card=<n> insmod option:\n",
  337. dev->name);
  338. for (i = 0; i < cx23885_bcount; i++)
  339. printk(KERN_INFO "%s: card=%d -> %s\n",
  340. dev->name, i, cx23885_boards[i].name);
  341. }
  342. static void hauppauge_eeprom(struct cx23885_dev *dev, u8 *eeprom_data)
  343. {
  344. struct tveeprom tv;
  345. tveeprom_hauppauge_analog(&dev->i2c_bus[0].i2c_client, &tv,
  346. eeprom_data);
  347. /* Make sure we support the board model */
  348. switch (tv.model) {
  349. case 22001:
  350. /* WinTV-HVR1270 (PCIe, Retail, half height)
  351. * ATSC/QAM and basic analog, IR Blast */
  352. case 22009:
  353. /* WinTV-HVR1210 (PCIe, Retail, half height)
  354. * DVB-T and basic analog, IR Blast */
  355. case 22011:
  356. /* WinTV-HVR1270 (PCIe, Retail, half height)
  357. * ATSC/QAM and basic analog, IR Recv */
  358. case 22019:
  359. /* WinTV-HVR1210 (PCIe, Retail, half height)
  360. * DVB-T and basic analog, IR Recv */
  361. case 22021:
  362. /* WinTV-HVR1275 (PCIe, Retail, half height)
  363. * ATSC/QAM and basic analog, IR Recv */
  364. case 22029:
  365. /* WinTV-HVR1210 (PCIe, Retail, half height)
  366. * DVB-T and basic analog, IR Recv */
  367. case 22101:
  368. /* WinTV-HVR1270 (PCIe, Retail, full height)
  369. * ATSC/QAM and basic analog, IR Blast */
  370. case 22109:
  371. /* WinTV-HVR1210 (PCIe, Retail, full height)
  372. * DVB-T and basic analog, IR Blast */
  373. case 22111:
  374. /* WinTV-HVR1270 (PCIe, Retail, full height)
  375. * ATSC/QAM and basic analog, IR Recv */
  376. case 22119:
  377. /* WinTV-HVR1210 (PCIe, Retail, full height)
  378. * DVB-T and basic analog, IR Recv */
  379. case 22121:
  380. /* WinTV-HVR1275 (PCIe, Retail, full height)
  381. * ATSC/QAM and basic analog, IR Recv */
  382. case 22129:
  383. /* WinTV-HVR1210 (PCIe, Retail, full height)
  384. * DVB-T and basic analog, IR Recv */
  385. case 71009:
  386. /* WinTV-HVR1200 (PCIe, Retail, full height)
  387. * DVB-T and basic analog */
  388. case 71359:
  389. /* WinTV-HVR1200 (PCIe, OEM, half height)
  390. * DVB-T and basic analog */
  391. case 71439:
  392. /* WinTV-HVR1200 (PCIe, OEM, half height)
  393. * DVB-T and basic analog */
  394. case 71449:
  395. /* WinTV-HVR1200 (PCIe, OEM, full height)
  396. * DVB-T and basic analog */
  397. case 71939:
  398. /* WinTV-HVR1200 (PCIe, OEM, half height)
  399. * DVB-T and basic analog */
  400. case 71949:
  401. /* WinTV-HVR1200 (PCIe, OEM, full height)
  402. * DVB-T and basic analog */
  403. case 71959:
  404. /* WinTV-HVR1200 (PCIe, OEM, full height)
  405. * DVB-T and basic analog */
  406. case 71979:
  407. /* WinTV-HVR1200 (PCIe, OEM, half height)
  408. * DVB-T and basic analog */
  409. case 71999:
  410. /* WinTV-HVR1200 (PCIe, OEM, full height)
  411. * DVB-T and basic analog */
  412. case 76601:
  413. /* WinTV-HVR1800lp (PCIe, Retail, No IR, Dual
  414. channel ATSC and MPEG2 HW Encoder */
  415. case 77001:
  416. /* WinTV-HVR1500 (Express Card, OEM, No IR, ATSC
  417. and Basic analog */
  418. case 77011:
  419. /* WinTV-HVR1500 (Express Card, Retail, No IR, ATSC
  420. and Basic analog */
  421. case 77041:
  422. /* WinTV-HVR1500Q (Express Card, OEM, No IR, ATSC/QAM
  423. and Basic analog */
  424. case 77051:
  425. /* WinTV-HVR1500Q (Express Card, Retail, No IR, ATSC/QAM
  426. and Basic analog */
  427. case 78011:
  428. /* WinTV-HVR1800 (PCIe, Retail, 3.5mm in, IR, No FM,
  429. Dual channel ATSC and MPEG2 HW Encoder */
  430. case 78501:
  431. /* WinTV-HVR1800 (PCIe, OEM, RCA in, No IR, FM,
  432. Dual channel ATSC and MPEG2 HW Encoder */
  433. case 78521:
  434. /* WinTV-HVR1800 (PCIe, OEM, RCA in, No IR, FM,
  435. Dual channel ATSC and MPEG2 HW Encoder */
  436. case 78531:
  437. /* WinTV-HVR1800 (PCIe, OEM, RCA in, No IR, No FM,
  438. Dual channel ATSC and MPEG2 HW Encoder */
  439. case 78631:
  440. /* WinTV-HVR1800 (PCIe, OEM, No IR, No FM,
  441. Dual channel ATSC and MPEG2 HW Encoder */
  442. case 79001:
  443. /* WinTV-HVR1250 (PCIe, Retail, IR, full height,
  444. ATSC and Basic analog */
  445. case 79101:
  446. /* WinTV-HVR1250 (PCIe, Retail, IR, half height,
  447. ATSC and Basic analog */
  448. case 79561:
  449. /* WinTV-HVR1250 (PCIe, OEM, No IR, half height,
  450. ATSC and Basic analog */
  451. case 79571:
  452. /* WinTV-HVR1250 (PCIe, OEM, No IR, full height,
  453. ATSC and Basic analog */
  454. case 79671:
  455. /* WinTV-HVR1250 (PCIe, OEM, No IR, half height,
  456. ATSC and Basic analog */
  457. case 80019:
  458. /* WinTV-HVR1400 (Express Card, Retail, IR,
  459. * DVB-T and Basic analog */
  460. case 81509:
  461. /* WinTV-HVR1700 (PCIe, OEM, No IR, half height)
  462. * DVB-T and MPEG2 HW Encoder */
  463. case 81519:
  464. /* WinTV-HVR1700 (PCIe, OEM, No IR, full height)
  465. * DVB-T and MPEG2 HW Encoder */
  466. break;
  467. default:
  468. printk(KERN_WARNING "%s: warning: unknown hauppauge model #%d\n",
  469. dev->name, tv.model);
  470. break;
  471. }
  472. printk(KERN_INFO "%s: hauppauge eeprom: model=%d\n",
  473. dev->name, tv.model);
  474. }
  475. int cx23885_tuner_callback(void *priv, int component, int command, int arg)
  476. {
  477. struct cx23885_tsport *port = priv;
  478. struct cx23885_dev *dev = port->dev;
  479. u32 bitmask = 0;
  480. if (command == XC2028_RESET_CLK)
  481. return 0;
  482. if (command != 0) {
  483. printk(KERN_ERR "%s(): Unknown command 0x%x.\n",
  484. __func__, command);
  485. return -EINVAL;
  486. }
  487. switch (dev->board) {
  488. case CX23885_BOARD_HAUPPAUGE_HVR1400:
  489. case CX23885_BOARD_HAUPPAUGE_HVR1500:
  490. case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
  491. case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
  492. case CX23885_BOARD_COMPRO_VIDEOMATE_E650F:
  493. /* Tuner Reset Command */
  494. bitmask = 0x04;
  495. break;
  496. case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP:
  497. case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP:
  498. /* Two identical tuners on two different i2c buses,
  499. * we need to reset the correct gpio. */
  500. if (port->nr == 1)
  501. bitmask = 0x01;
  502. else if (port->nr == 2)
  503. bitmask = 0x04;
  504. break;
  505. }
  506. if (bitmask) {
  507. /* Drive the tuner into reset and back out */
  508. cx_clear(GP0_IO, bitmask);
  509. mdelay(200);
  510. cx_set(GP0_IO, bitmask);
  511. }
  512. return 0;
  513. }
  514. void cx23885_gpio_setup(struct cx23885_dev *dev)
  515. {
  516. switch (dev->board) {
  517. case CX23885_BOARD_HAUPPAUGE_HVR1250:
  518. /* GPIO-0 cx24227 demodulator reset */
  519. cx_set(GP0_IO, 0x00010001); /* Bring the part out of reset */
  520. break;
  521. case CX23885_BOARD_HAUPPAUGE_HVR1500:
  522. /* GPIO-0 cx24227 demodulator */
  523. /* GPIO-2 xc3028 tuner */
  524. /* Put the parts into reset */
  525. cx_set(GP0_IO, 0x00050000);
  526. cx_clear(GP0_IO, 0x00000005);
  527. msleep(5);
  528. /* Bring the parts out of reset */
  529. cx_set(GP0_IO, 0x00050005);
  530. break;
  531. case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
  532. /* GPIO-0 cx24227 demodulator reset */
  533. /* GPIO-2 xc5000 tuner reset */
  534. cx_set(GP0_IO, 0x00050005); /* Bring the part out of reset */
  535. break;
  536. case CX23885_BOARD_HAUPPAUGE_HVR1800:
  537. /* GPIO-0 656_CLK */
  538. /* GPIO-1 656_D0 */
  539. /* GPIO-2 8295A Reset */
  540. /* GPIO-3-10 cx23417 data0-7 */
  541. /* GPIO-11-14 cx23417 addr0-3 */
  542. /* GPIO-15-18 cx23417 READY, CS, RD, WR */
  543. /* GPIO-19 IR_RX */
  544. /* CX23417 GPIO's */
  545. /* EIO15 Zilog Reset */
  546. /* EIO14 S5H1409/CX24227 Reset */
  547. /* Force the TDA8295A into reset and back */
  548. cx_set(GP0_IO, 0x00040004);
  549. mdelay(20);
  550. cx_clear(GP0_IO, 0x00000004);
  551. mdelay(20);
  552. cx_set(GP0_IO, 0x00040004);
  553. mdelay(20);
  554. break;
  555. case CX23885_BOARD_HAUPPAUGE_HVR1200:
  556. /* GPIO-0 tda10048 demodulator reset */
  557. /* GPIO-2 tda18271 tuner reset */
  558. /* Put the parts into reset and back */
  559. cx_set(GP0_IO, 0x00050000);
  560. mdelay(20);
  561. cx_clear(GP0_IO, 0x00000005);
  562. mdelay(20);
  563. cx_set(GP0_IO, 0x00050005);
  564. break;
  565. case CX23885_BOARD_HAUPPAUGE_HVR1700:
  566. /* GPIO-0 TDA10048 demodulator reset */
  567. /* GPIO-2 TDA8295A Reset */
  568. /* GPIO-3-10 cx23417 data0-7 */
  569. /* GPIO-11-14 cx23417 addr0-3 */
  570. /* GPIO-15-18 cx23417 READY, CS, RD, WR */
  571. /* The following GPIO's are on the interna AVCore (cx25840) */
  572. /* GPIO-19 IR_RX */
  573. /* GPIO-20 IR_TX 416/DVBT Select */
  574. /* GPIO-21 IIS DAT */
  575. /* GPIO-22 IIS WCLK */
  576. /* GPIO-23 IIS BCLK */
  577. /* Put the parts into reset and back */
  578. cx_set(GP0_IO, 0x00050000);
  579. mdelay(20);
  580. cx_clear(GP0_IO, 0x00000005);
  581. mdelay(20);
  582. cx_set(GP0_IO, 0x00050005);
  583. break;
  584. case CX23885_BOARD_HAUPPAUGE_HVR1400:
  585. /* GPIO-0 Dibcom7000p demodulator reset */
  586. /* GPIO-2 xc3028L tuner reset */
  587. /* GPIO-13 LED */
  588. /* Put the parts into reset and back */
  589. cx_set(GP0_IO, 0x00050000);
  590. mdelay(20);
  591. cx_clear(GP0_IO, 0x00000005);
  592. mdelay(20);
  593. cx_set(GP0_IO, 0x00050005);
  594. break;
  595. case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP:
  596. /* GPIO-0 xc5000 tuner reset i2c bus 0 */
  597. /* GPIO-1 s5h1409 demod reset i2c bus 0 */
  598. /* GPIO-2 xc5000 tuner reset i2c bus 1 */
  599. /* GPIO-3 s5h1409 demod reset i2c bus 0 */
  600. /* Put the parts into reset and back */
  601. cx_set(GP0_IO, 0x000f0000);
  602. mdelay(20);
  603. cx_clear(GP0_IO, 0x0000000f);
  604. mdelay(20);
  605. cx_set(GP0_IO, 0x000f000f);
  606. break;
  607. case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP:
  608. /* GPIO-0 portb xc3028 reset */
  609. /* GPIO-1 portb zl10353 reset */
  610. /* GPIO-2 portc xc3028 reset */
  611. /* GPIO-3 portc zl10353 reset */
  612. /* Put the parts into reset and back */
  613. cx_set(GP0_IO, 0x000f0000);
  614. mdelay(20);
  615. cx_clear(GP0_IO, 0x0000000f);
  616. mdelay(20);
  617. cx_set(GP0_IO, 0x000f000f);
  618. break;
  619. case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
  620. case CX23885_BOARD_COMPRO_VIDEOMATE_E650F:
  621. /* GPIO-2 xc3028 tuner reset */
  622. /* The following GPIO's are on the internal AVCore (cx25840) */
  623. /* GPIO-? zl10353 demod reset */
  624. /* Put the parts into reset and back */
  625. cx_set(GP0_IO, 0x00040000);
  626. mdelay(20);
  627. cx_clear(GP0_IO, 0x00000004);
  628. mdelay(20);
  629. cx_set(GP0_IO, 0x00040004);
  630. break;
  631. case CX23885_BOARD_TBS_6920:
  632. case CX23885_BOARD_TEVII_S470:
  633. cx_write(MC417_CTL, 0x00000036);
  634. cx_write(MC417_OEN, 0x00001000);
  635. cx_write(MC417_RWD, 0x00001800);
  636. break;
  637. case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
  638. /* GPIO-0 INTA from CiMax1
  639. GPIO-1 INTB from CiMax2
  640. GPIO-2 reset chips
  641. GPIO-3 to GPIO-10 data/addr for CA
  642. GPIO-11 ~CS0 to CiMax1
  643. GPIO-12 ~CS1 to CiMax2
  644. GPIO-13 ADL0 load LSB addr
  645. GPIO-14 ADL1 load MSB addr
  646. GPIO-15 ~RDY from CiMax
  647. GPIO-17 ~RD to CiMax
  648. GPIO-18 ~WR to CiMax
  649. */
  650. cx_set(GP0_IO, 0x00040000); /* GPIO as out */
  651. /* GPIO1 and GPIO2 as INTA and INTB from CiMaxes, reset low */
  652. cx_clear(GP0_IO, 0x00030004);
  653. mdelay(100);/* reset delay */
  654. cx_set(GP0_IO, 0x00040004); /* GPIO as out, reset high */
  655. cx_write(MC417_CTL, 0x00000037);/* enable GPIO3-18 pins */
  656. /* GPIO-15 IN as ~ACK, rest as OUT */
  657. cx_write(MC417_OEN, 0x00001000);
  658. /* ~RD, ~WR high; ADL0, ADL1 low; ~CS0, ~CS1 high */
  659. cx_write(MC417_RWD, 0x0000c300);
  660. /* enable irq */
  661. cx_write(GPIO_ISM, 0x00000000);/* INTERRUPTS active low*/
  662. break;
  663. case CX23885_BOARD_HAUPPAUGE_HVR1270:
  664. case CX23885_BOARD_HAUPPAUGE_HVR1275:
  665. case CX23885_BOARD_HAUPPAUGE_HVR1255:
  666. case CX23885_BOARD_HAUPPAUGE_HVR1210:
  667. /* GPIO-5 RF Control: 0 = RF1 Terrestrial, 1 = RF2 Cable */
  668. /* GPIO-6 I2C Gate which can isolate the demod from the bus */
  669. /* GPIO-9 Demod reset */
  670. /* Put the parts into reset and back */
  671. cx23885_gpio_enable(dev, GPIO_9 | GPIO_6 | GPIO_5, 1);
  672. cx23885_gpio_set(dev, GPIO_9 | GPIO_6 | GPIO_5);
  673. cx23885_gpio_clear(dev, GPIO_9);
  674. mdelay(20);
  675. cx23885_gpio_set(dev, GPIO_9);
  676. break;
  677. }
  678. }
  679. int cx23885_ir_init(struct cx23885_dev *dev)
  680. {
  681. switch (dev->board) {
  682. case CX23885_BOARD_HAUPPAUGE_HVR1250:
  683. case CX23885_BOARD_HAUPPAUGE_HVR1500:
  684. case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
  685. case CX23885_BOARD_HAUPPAUGE_HVR1800:
  686. case CX23885_BOARD_HAUPPAUGE_HVR1200:
  687. case CX23885_BOARD_HAUPPAUGE_HVR1400:
  688. case CX23885_BOARD_HAUPPAUGE_HVR1270:
  689. case CX23885_BOARD_HAUPPAUGE_HVR1275:
  690. case CX23885_BOARD_HAUPPAUGE_HVR1255:
  691. case CX23885_BOARD_HAUPPAUGE_HVR1210:
  692. /* FIXME: Implement me */
  693. break;
  694. case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP:
  695. request_module("ir-kbd-i2c");
  696. break;
  697. }
  698. return 0;
  699. }
  700. void cx23885_card_setup(struct cx23885_dev *dev)
  701. {
  702. struct cx23885_tsport *ts1 = &dev->ts1;
  703. struct cx23885_tsport *ts2 = &dev->ts2;
  704. static u8 eeprom[256];
  705. if (dev->i2c_bus[0].i2c_rc == 0) {
  706. dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
  707. tveeprom_read(&dev->i2c_bus[0].i2c_client,
  708. eeprom, sizeof(eeprom));
  709. }
  710. switch (dev->board) {
  711. case CX23885_BOARD_HAUPPAUGE_HVR1250:
  712. case CX23885_BOARD_HAUPPAUGE_HVR1500:
  713. case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
  714. case CX23885_BOARD_HAUPPAUGE_HVR1400:
  715. if (dev->i2c_bus[0].i2c_rc == 0)
  716. hauppauge_eeprom(dev, eeprom+0x80);
  717. break;
  718. case CX23885_BOARD_HAUPPAUGE_HVR1800:
  719. case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
  720. case CX23885_BOARD_HAUPPAUGE_HVR1200:
  721. case CX23885_BOARD_HAUPPAUGE_HVR1700:
  722. case CX23885_BOARD_HAUPPAUGE_HVR1270:
  723. case CX23885_BOARD_HAUPPAUGE_HVR1275:
  724. case CX23885_BOARD_HAUPPAUGE_HVR1255:
  725. case CX23885_BOARD_HAUPPAUGE_HVR1210:
  726. if (dev->i2c_bus[0].i2c_rc == 0)
  727. hauppauge_eeprom(dev, eeprom+0xc0);
  728. break;
  729. }
  730. switch (dev->board) {
  731. case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP:
  732. case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP:
  733. ts2->gen_ctrl_val = 0xc; /* Serial bus + punctured clock */
  734. ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */
  735. ts2->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
  736. /* break omitted intentionally */
  737. case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP:
  738. ts1->gen_ctrl_val = 0xc; /* Serial bus + punctured clock */
  739. ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
  740. ts1->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
  741. break;
  742. case CX23885_BOARD_HAUPPAUGE_HVR1800:
  743. /* Defaults for VID B - Analog encoder */
  744. /* DREQ_POL, SMODE, PUNC_CLK, MCLK_POL Serial bus + punc clk */
  745. ts1->gen_ctrl_val = 0x10e;
  746. ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
  747. ts1->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
  748. /* APB_TSVALERR_POL (active low)*/
  749. ts1->vld_misc_val = 0x2000;
  750. ts1->hw_sop_ctrl_val = (0x47 << 16 | 188 << 4 | 0xc);
  751. /* Defaults for VID C */
  752. ts2->gen_ctrl_val = 0xc; /* Serial bus + punctured clock */
  753. ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */
  754. ts2->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
  755. break;
  756. case CX23885_BOARD_TEVII_S470:
  757. case CX23885_BOARD_TBS_6920:
  758. case CX23885_BOARD_DVBWORLD_2005:
  759. ts1->gen_ctrl_val = 0x5; /* Parallel */
  760. ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
  761. ts1->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
  762. break;
  763. case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
  764. ts1->gen_ctrl_val = 0xc; /* Serial bus + punctured clock */
  765. ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
  766. ts1->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
  767. ts2->gen_ctrl_val = 0xc; /* Serial bus + punctured clock */
  768. ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */
  769. ts2->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
  770. break;
  771. case CX23885_BOARD_HAUPPAUGE_HVR1250:
  772. case CX23885_BOARD_HAUPPAUGE_HVR1500:
  773. case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
  774. case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
  775. case CX23885_BOARD_HAUPPAUGE_HVR1200:
  776. case CX23885_BOARD_HAUPPAUGE_HVR1700:
  777. case CX23885_BOARD_HAUPPAUGE_HVR1400:
  778. case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
  779. case CX23885_BOARD_COMPRO_VIDEOMATE_E650F:
  780. case CX23885_BOARD_HAUPPAUGE_HVR1270:
  781. case CX23885_BOARD_HAUPPAUGE_HVR1275:
  782. case CX23885_BOARD_HAUPPAUGE_HVR1255:
  783. case CX23885_BOARD_HAUPPAUGE_HVR1210:
  784. default:
  785. ts2->gen_ctrl_val = 0xc; /* Serial bus + punctured clock */
  786. ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */
  787. ts2->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
  788. }
  789. /* Certain boards support analog, or require the avcore to be
  790. * loaded, ensure this happens.
  791. */
  792. switch (dev->board) {
  793. case CX23885_BOARD_HAUPPAUGE_HVR1800:
  794. case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
  795. case CX23885_BOARD_HAUPPAUGE_HVR1700:
  796. case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
  797. case CX23885_BOARD_COMPRO_VIDEOMATE_E650F:
  798. case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
  799. dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev,
  800. &dev->i2c_bus[2].i2c_adap,
  801. "cx25840", "cx25840", 0x88 >> 1);
  802. v4l2_subdev_call(dev->sd_cx25840, core, load_fw);
  803. break;
  804. }
  805. /* AUX-PLL 27MHz CLK */
  806. switch (dev->board) {
  807. case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
  808. netup_initialize(dev);
  809. break;
  810. }
  811. }
  812. /* ------------------------------------------------------------------ */