saa7134-dvb.c 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249
  1. /*
  2. *
  3. * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
  4. *
  5. * Extended 3 / 2005 by Hartmut Hackmann to support various
  6. * cards with the tda10046 DVB-T channel decoder
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21. */
  22. #include <linux/init.h>
  23. #include <linux/list.h>
  24. #include <linux/module.h>
  25. #include <linux/kernel.h>
  26. #include <linux/slab.h>
  27. #include <linux/delay.h>
  28. #include <linux/kthread.h>
  29. #include <linux/suspend.h>
  30. #include "saa7134-reg.h"
  31. #include "saa7134.h"
  32. #include <media/v4l2-common.h>
  33. #include "dvb-pll.h"
  34. #include "mt352.h"
  35. #include "mt352_priv.h" /* FIXME */
  36. #include "tda1004x.h"
  37. #include "nxt200x.h"
  38. #include "tuner-xc2028.h"
  39. #include "tda10086.h"
  40. #include "tda826x.h"
  41. #include "tda827x.h"
  42. #include "isl6421.h"
  43. #include "isl6405.h"
  44. #include "lnbp21.h"
  45. MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
  46. MODULE_LICENSE("GPL");
  47. static unsigned int antenna_pwr;
  48. module_param(antenna_pwr, int, 0444);
  49. MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
  50. static int use_frontend;
  51. module_param(use_frontend, int, 0644);
  52. MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
  53. static int debug;
  54. module_param(debug, int, 0644);
  55. MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off).");
  56. #define dprintk(fmt, arg...) do { if (debug) \
  57. printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
  58. /* Print a warning */
  59. #define wprintk(fmt, arg...) \
  60. printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
  61. /* ------------------------------------------------------------------
  62. * mt352 based DVB-T cards
  63. */
  64. static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
  65. {
  66. u32 ok;
  67. if (!on) {
  68. saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
  69. saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
  70. return 0;
  71. }
  72. saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
  73. saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
  74. udelay(10);
  75. saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28));
  76. saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
  77. udelay(10);
  78. saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
  79. udelay(10);
  80. ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
  81. dprintk("%s %s\n", __FUNCTION__, ok ? "on" : "off");
  82. if (!ok)
  83. saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
  84. return ok;
  85. }
  86. static int mt352_pinnacle_init(struct dvb_frontend* fe)
  87. {
  88. static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 };
  89. static u8 reset [] = { RESET, 0x80 };
  90. static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
  91. static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
  92. static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
  93. static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 };
  94. static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f };
  95. static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d };
  96. static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
  97. struct saa7134_dev *dev= fe->dvb->priv;
  98. dprintk("%s called\n", __FUNCTION__);
  99. mt352_write(fe, clock_config, sizeof(clock_config));
  100. udelay(200);
  101. mt352_write(fe, reset, sizeof(reset));
  102. mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
  103. mt352_write(fe, agc_cfg, sizeof(agc_cfg));
  104. mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
  105. mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
  106. mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
  107. mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
  108. mt352_write(fe, irq_cfg, sizeof(irq_cfg));
  109. return 0;
  110. }
  111. static int mt352_aver777_init(struct dvb_frontend* fe)
  112. {
  113. static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
  114. static u8 reset [] = { RESET, 0x80 };
  115. static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
  116. static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
  117. static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
  118. mt352_write(fe, clock_config, sizeof(clock_config));
  119. udelay(200);
  120. mt352_write(fe, reset, sizeof(reset));
  121. mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
  122. mt352_write(fe, agc_cfg, sizeof(agc_cfg));
  123. mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
  124. return 0;
  125. }
  126. static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
  127. struct dvb_frontend_parameters* params)
  128. {
  129. u8 off[] = { 0x00, 0xf1};
  130. u8 on[] = { 0x00, 0x71};
  131. struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
  132. struct saa7134_dev *dev = fe->dvb->priv;
  133. struct v4l2_frequency f;
  134. /* set frequency (mt2050) */
  135. f.tuner = 0;
  136. f.type = V4L2_TUNER_DIGITAL_TV;
  137. f.frequency = params->frequency / 1000 * 16 / 1000;
  138. if (fe->ops.i2c_gate_ctrl)
  139. fe->ops.i2c_gate_ctrl(fe, 1);
  140. i2c_transfer(&dev->i2c_adap, &msg, 1);
  141. saa7134_i2c_call_clients(dev,VIDIOC_S_FREQUENCY,&f);
  142. msg.buf = on;
  143. if (fe->ops.i2c_gate_ctrl)
  144. fe->ops.i2c_gate_ctrl(fe, 1);
  145. i2c_transfer(&dev->i2c_adap, &msg, 1);
  146. pinnacle_antenna_pwr(dev, antenna_pwr);
  147. /* mt352 setup */
  148. return mt352_pinnacle_init(fe);
  149. }
  150. static struct mt352_config pinnacle_300i = {
  151. .demod_address = 0x3c >> 1,
  152. .adc_clock = 20333,
  153. .if2 = 36150,
  154. .no_tuner = 1,
  155. .demod_init = mt352_pinnacle_init,
  156. };
  157. static struct mt352_config avermedia_777 = {
  158. .demod_address = 0xf,
  159. .demod_init = mt352_aver777_init,
  160. };
  161. static struct mt352_config avermedia_e506r_mt352_dev = {
  162. .demod_address = (0x1e >> 1),
  163. .no_tuner = 1,
  164. };
  165. /* ==================================================================
  166. * tda1004x based DVB-T cards, helper functions
  167. */
  168. static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
  169. const struct firmware **fw, char *name)
  170. {
  171. struct saa7134_dev *dev = fe->dvb->priv;
  172. return request_firmware(fw, name, &dev->pci->dev);
  173. }
  174. /* ------------------------------------------------------------------
  175. * these tuners are tu1216, td1316(a)
  176. */
  177. static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  178. {
  179. struct saa7134_dev *dev = fe->dvb->priv;
  180. struct tda1004x_state *state = fe->demodulator_priv;
  181. u8 addr = state->config->tuner_address;
  182. u8 tuner_buf[4];
  183. struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
  184. sizeof(tuner_buf) };
  185. int tuner_frequency = 0;
  186. u8 band, cp, filter;
  187. /* determine charge pump */
  188. tuner_frequency = params->frequency + 36166000;
  189. if (tuner_frequency < 87000000)
  190. return -EINVAL;
  191. else if (tuner_frequency < 130000000)
  192. cp = 3;
  193. else if (tuner_frequency < 160000000)
  194. cp = 5;
  195. else if (tuner_frequency < 200000000)
  196. cp = 6;
  197. else if (tuner_frequency < 290000000)
  198. cp = 3;
  199. else if (tuner_frequency < 420000000)
  200. cp = 5;
  201. else if (tuner_frequency < 480000000)
  202. cp = 6;
  203. else if (tuner_frequency < 620000000)
  204. cp = 3;
  205. else if (tuner_frequency < 830000000)
  206. cp = 5;
  207. else if (tuner_frequency < 895000000)
  208. cp = 7;
  209. else
  210. return -EINVAL;
  211. /* determine band */
  212. if (params->frequency < 49000000)
  213. return -EINVAL;
  214. else if (params->frequency < 161000000)
  215. band = 1;
  216. else if (params->frequency < 444000000)
  217. band = 2;
  218. else if (params->frequency < 861000000)
  219. band = 4;
  220. else
  221. return -EINVAL;
  222. /* setup PLL filter */
  223. switch (params->u.ofdm.bandwidth) {
  224. case BANDWIDTH_6_MHZ:
  225. filter = 0;
  226. break;
  227. case BANDWIDTH_7_MHZ:
  228. filter = 0;
  229. break;
  230. case BANDWIDTH_8_MHZ:
  231. filter = 1;
  232. break;
  233. default:
  234. return -EINVAL;
  235. }
  236. /* calculate divisor
  237. * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
  238. */
  239. tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
  240. /* setup tuner buffer */
  241. tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
  242. tuner_buf[1] = tuner_frequency & 0xff;
  243. tuner_buf[2] = 0xca;
  244. tuner_buf[3] = (cp << 5) | (filter << 3) | band;
  245. if (fe->ops.i2c_gate_ctrl)
  246. fe->ops.i2c_gate_ctrl(fe, 1);
  247. if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
  248. wprintk("could not write to tuner at addr: 0x%02x\n",
  249. addr << 1);
  250. return -EIO;
  251. }
  252. msleep(1);
  253. return 0;
  254. }
  255. static int philips_tu1216_init(struct dvb_frontend *fe)
  256. {
  257. struct saa7134_dev *dev = fe->dvb->priv;
  258. struct tda1004x_state *state = fe->demodulator_priv;
  259. u8 addr = state->config->tuner_address;
  260. static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
  261. struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
  262. /* setup PLL configuration */
  263. if (fe->ops.i2c_gate_ctrl)
  264. fe->ops.i2c_gate_ctrl(fe, 1);
  265. if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
  266. return -EIO;
  267. msleep(1);
  268. return 0;
  269. }
  270. /* ------------------------------------------------------------------ */
  271. static struct tda1004x_config philips_tu1216_60_config = {
  272. .demod_address = 0x8,
  273. .invert = 1,
  274. .invert_oclk = 0,
  275. .xtal_freq = TDA10046_XTAL_4M,
  276. .agc_config = TDA10046_AGC_DEFAULT,
  277. .if_freq = TDA10046_FREQ_3617,
  278. .tuner_address = 0x60,
  279. .request_firmware = philips_tda1004x_request_firmware
  280. };
  281. static struct tda1004x_config philips_tu1216_61_config = {
  282. .demod_address = 0x8,
  283. .invert = 1,
  284. .invert_oclk = 0,
  285. .xtal_freq = TDA10046_XTAL_4M,
  286. .agc_config = TDA10046_AGC_DEFAULT,
  287. .if_freq = TDA10046_FREQ_3617,
  288. .tuner_address = 0x61,
  289. .request_firmware = philips_tda1004x_request_firmware
  290. };
  291. /* ------------------------------------------------------------------ */
  292. static int philips_td1316_tuner_init(struct dvb_frontend *fe)
  293. {
  294. struct saa7134_dev *dev = fe->dvb->priv;
  295. struct tda1004x_state *state = fe->demodulator_priv;
  296. u8 addr = state->config->tuner_address;
  297. static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
  298. struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
  299. /* setup PLL configuration */
  300. if (fe->ops.i2c_gate_ctrl)
  301. fe->ops.i2c_gate_ctrl(fe, 1);
  302. if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
  303. return -EIO;
  304. return 0;
  305. }
  306. static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  307. {
  308. return philips_tda6651_pll_set(fe, params);
  309. }
  310. static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
  311. {
  312. struct saa7134_dev *dev = fe->dvb->priv;
  313. struct tda1004x_state *state = fe->demodulator_priv;
  314. u8 addr = state->config->tuner_address;
  315. static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
  316. struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
  317. /* switch the tuner to analog mode */
  318. if (fe->ops.i2c_gate_ctrl)
  319. fe->ops.i2c_gate_ctrl(fe, 1);
  320. if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
  321. return -EIO;
  322. return 0;
  323. }
  324. /* ------------------------------------------------------------------ */
  325. static int philips_europa_tuner_init(struct dvb_frontend *fe)
  326. {
  327. struct saa7134_dev *dev = fe->dvb->priv;
  328. static u8 msg[] = { 0x00, 0x40};
  329. struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
  330. if (philips_td1316_tuner_init(fe))
  331. return -EIO;
  332. msleep(1);
  333. if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
  334. return -EIO;
  335. return 0;
  336. }
  337. static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
  338. {
  339. struct saa7134_dev *dev = fe->dvb->priv;
  340. static u8 msg[] = { 0x00, 0x14 };
  341. struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
  342. if (philips_td1316_tuner_sleep(fe))
  343. return -EIO;
  344. /* switch the board to analog mode */
  345. if (fe->ops.i2c_gate_ctrl)
  346. fe->ops.i2c_gate_ctrl(fe, 1);
  347. i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
  348. return 0;
  349. }
  350. static int philips_europa_demod_sleep(struct dvb_frontend *fe)
  351. {
  352. struct saa7134_dev *dev = fe->dvb->priv;
  353. if (dev->original_demod_sleep)
  354. dev->original_demod_sleep(fe);
  355. fe->ops.i2c_gate_ctrl(fe, 1);
  356. return 0;
  357. }
  358. static struct tda1004x_config philips_europa_config = {
  359. .demod_address = 0x8,
  360. .invert = 0,
  361. .invert_oclk = 0,
  362. .xtal_freq = TDA10046_XTAL_4M,
  363. .agc_config = TDA10046_AGC_IFO_AUTO_POS,
  364. .if_freq = TDA10046_FREQ_052,
  365. .tuner_address = 0x61,
  366. .request_firmware = philips_tda1004x_request_firmware
  367. };
  368. /* ------------------------------------------------------------------ */
  369. static struct tda1004x_config medion_cardbus = {
  370. .demod_address = 0x08,
  371. .invert = 1,
  372. .invert_oclk = 0,
  373. .xtal_freq = TDA10046_XTAL_16M,
  374. .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
  375. .if_freq = TDA10046_FREQ_3613,
  376. .tuner_address = 0x61,
  377. .request_firmware = philips_tda1004x_request_firmware
  378. };
  379. /* ------------------------------------------------------------------
  380. * tda 1004x based cards with philips silicon tuner
  381. */
  382. static void philips_tda827x_lna_gain(struct dvb_frontend *fe, int high)
  383. {
  384. struct saa7134_dev *dev = fe->dvb->priv;
  385. struct tda1004x_state *state = fe->demodulator_priv;
  386. u8 addr = state->config->i2c_gate;
  387. u8 config = state->config->tuner_config;
  388. u8 GP00_CF[] = {0x20, 0x01};
  389. u8 GP00_LEV[] = {0x22, 0x00};
  390. struct i2c_msg msg = {.addr = addr,.flags = 0,.buf = GP00_CF, .len = 2};
  391. if (config) {
  392. if (high) {
  393. dprintk("setting LNA to high gain\n");
  394. } else {
  395. dprintk("setting LNA to low gain\n");
  396. }
  397. }
  398. switch (config) {
  399. case 0: /* no LNA */
  400. break;
  401. case 1: /* switch is GPIO 0 of tda8290 */
  402. case 2:
  403. /* turn Vsync off */
  404. saa7134_set_gpio(dev, 22, 0);
  405. GP00_LEV[1] = high ? 0 : 1;
  406. if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
  407. wprintk("could not access tda8290 at addr: 0x%02x\n",
  408. addr << 1);
  409. return;
  410. }
  411. msg.buf = GP00_LEV;
  412. if (config == 2)
  413. GP00_LEV[1] = high ? 1 : 0;
  414. i2c_transfer(&dev->i2c_adap, &msg, 1);
  415. break;
  416. case 3: /* switch with GPIO of saa713x */
  417. saa7134_set_gpio(dev, 22, high);
  418. break;
  419. }
  420. }
  421. static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
  422. {
  423. struct tda1004x_state *state = fe->demodulator_priv;
  424. u8 addr = state->config->i2c_gate;
  425. static u8 tda8290_close[] = { 0x21, 0xc0};
  426. static u8 tda8290_open[] = { 0x21, 0x80};
  427. struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
  428. if (enable) {
  429. tda8290_msg.buf = tda8290_close;
  430. } else {
  431. tda8290_msg.buf = tda8290_open;
  432. }
  433. if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
  434. struct saa7134_dev *dev = fe->dvb->priv;
  435. wprintk("could not access tda8290 I2C gate\n");
  436. return -EIO;
  437. }
  438. msleep(20);
  439. return 0;
  440. }
  441. /* ------------------------------------------------------------------ */
  442. static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
  443. {
  444. struct saa7134_dev *dev = fe->dvb->priv;
  445. struct tda1004x_state *state = fe->demodulator_priv;
  446. switch (state->config->antenna_switch) {
  447. case 0: break;
  448. case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
  449. saa7134_set_gpio(dev, 21, 0);
  450. break;
  451. case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
  452. saa7134_set_gpio(dev, 21, 1);
  453. break;
  454. }
  455. return 0;
  456. }
  457. static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
  458. {
  459. struct saa7134_dev *dev = fe->dvb->priv;
  460. struct tda1004x_state *state = fe->demodulator_priv;
  461. switch (state->config->antenna_switch) {
  462. case 0: break;
  463. case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
  464. saa7134_set_gpio(dev, 21, 1);
  465. break;
  466. case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
  467. saa7134_set_gpio(dev, 21, 0);
  468. break;
  469. }
  470. return 0;
  471. }
  472. static struct tda827x_config tda827x_cfg = {
  473. .lna_gain = philips_tda827x_lna_gain,
  474. .init = philips_tda827x_tuner_init,
  475. .sleep = philips_tda827x_tuner_sleep
  476. };
  477. static void configure_tda827x_fe(struct saa7134_dev *dev, struct tda1004x_config *tda_conf)
  478. {
  479. dev->dvb.frontend = dvb_attach(tda10046_attach, tda_conf, &dev->i2c_adap);
  480. if (dev->dvb.frontend) {
  481. if (tda_conf->i2c_gate)
  482. dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
  483. if (dvb_attach(tda827x_attach, dev->dvb.frontend, tda_conf->tuner_address,
  484. &dev->i2c_adap,&tda827x_cfg) == NULL) {
  485. wprintk("no tda827x tuner found at addr: %02x\n",
  486. tda_conf->tuner_address);
  487. }
  488. }
  489. }
  490. /* ------------------------------------------------------------------ */
  491. static struct tda1004x_config tda827x_lifeview_config = {
  492. .demod_address = 0x08,
  493. .invert = 1,
  494. .invert_oclk = 0,
  495. .xtal_freq = TDA10046_XTAL_16M,
  496. .agc_config = TDA10046_AGC_TDA827X,
  497. .gpio_config = TDA10046_GP11_I,
  498. .if_freq = TDA10046_FREQ_045,
  499. .tuner_address = 0x60,
  500. .request_firmware = philips_tda1004x_request_firmware
  501. };
  502. static struct tda1004x_config philips_tiger_config = {
  503. .demod_address = 0x08,
  504. .invert = 1,
  505. .invert_oclk = 0,
  506. .xtal_freq = TDA10046_XTAL_16M,
  507. .agc_config = TDA10046_AGC_TDA827X,
  508. .gpio_config = TDA10046_GP11_I,
  509. .if_freq = TDA10046_FREQ_045,
  510. .i2c_gate = 0x4b,
  511. .tuner_address = 0x61,
  512. .tuner_config = 0,
  513. .antenna_switch= 1,
  514. .request_firmware = philips_tda1004x_request_firmware
  515. };
  516. static struct tda1004x_config cinergy_ht_config = {
  517. .demod_address = 0x08,
  518. .invert = 1,
  519. .invert_oclk = 0,
  520. .xtal_freq = TDA10046_XTAL_16M,
  521. .agc_config = TDA10046_AGC_TDA827X,
  522. .gpio_config = TDA10046_GP01_I,
  523. .if_freq = TDA10046_FREQ_045,
  524. .i2c_gate = 0x4b,
  525. .tuner_address = 0x61,
  526. .tuner_config = 0,
  527. .request_firmware = philips_tda1004x_request_firmware
  528. };
  529. static struct tda1004x_config cinergy_ht_pci_config = {
  530. .demod_address = 0x08,
  531. .invert = 1,
  532. .invert_oclk = 0,
  533. .xtal_freq = TDA10046_XTAL_16M,
  534. .agc_config = TDA10046_AGC_TDA827X,
  535. .gpio_config = TDA10046_GP01_I,
  536. .if_freq = TDA10046_FREQ_045,
  537. .i2c_gate = 0x4b,
  538. .tuner_address = 0x60,
  539. .tuner_config = 0,
  540. .request_firmware = philips_tda1004x_request_firmware
  541. };
  542. static struct tda1004x_config philips_tiger_s_config = {
  543. .demod_address = 0x08,
  544. .invert = 1,
  545. .invert_oclk = 0,
  546. .xtal_freq = TDA10046_XTAL_16M,
  547. .agc_config = TDA10046_AGC_TDA827X,
  548. .gpio_config = TDA10046_GP01_I,
  549. .if_freq = TDA10046_FREQ_045,
  550. .i2c_gate = 0x4b,
  551. .tuner_address = 0x61,
  552. .tuner_config = 2,
  553. .antenna_switch= 1,
  554. .request_firmware = philips_tda1004x_request_firmware
  555. };
  556. static struct tda1004x_config pinnacle_pctv_310i_config = {
  557. .demod_address = 0x08,
  558. .invert = 1,
  559. .invert_oclk = 0,
  560. .xtal_freq = TDA10046_XTAL_16M,
  561. .agc_config = TDA10046_AGC_TDA827X,
  562. .gpio_config = TDA10046_GP11_I,
  563. .if_freq = TDA10046_FREQ_045,
  564. .i2c_gate = 0x4b,
  565. .tuner_address = 0x61,
  566. .tuner_config = 1,
  567. .request_firmware = philips_tda1004x_request_firmware
  568. };
  569. static struct tda1004x_config hauppauge_hvr_1110_config = {
  570. .demod_address = 0x08,
  571. .invert = 1,
  572. .invert_oclk = 0,
  573. .xtal_freq = TDA10046_XTAL_16M,
  574. .agc_config = TDA10046_AGC_TDA827X,
  575. .gpio_config = TDA10046_GP11_I,
  576. .if_freq = TDA10046_FREQ_045,
  577. .i2c_gate = 0x4b,
  578. .tuner_address = 0x61,
  579. .tuner_config = 1,
  580. .request_firmware = philips_tda1004x_request_firmware
  581. };
  582. static struct tda1004x_config asus_p7131_dual_config = {
  583. .demod_address = 0x08,
  584. .invert = 1,
  585. .invert_oclk = 0,
  586. .xtal_freq = TDA10046_XTAL_16M,
  587. .agc_config = TDA10046_AGC_TDA827X,
  588. .gpio_config = TDA10046_GP11_I,
  589. .if_freq = TDA10046_FREQ_045,
  590. .i2c_gate = 0x4b,
  591. .tuner_address = 0x61,
  592. .tuner_config = 0,
  593. .antenna_switch= 2,
  594. .request_firmware = philips_tda1004x_request_firmware
  595. };
  596. static struct tda1004x_config lifeview_trio_config = {
  597. .demod_address = 0x09,
  598. .invert = 1,
  599. .invert_oclk = 0,
  600. .xtal_freq = TDA10046_XTAL_16M,
  601. .agc_config = TDA10046_AGC_TDA827X,
  602. .gpio_config = TDA10046_GP00_I,
  603. .if_freq = TDA10046_FREQ_045,
  604. .tuner_address = 0x60,
  605. .request_firmware = philips_tda1004x_request_firmware
  606. };
  607. static struct tda1004x_config tevion_dvbt220rf_config = {
  608. .demod_address = 0x08,
  609. .invert = 1,
  610. .invert_oclk = 0,
  611. .xtal_freq = TDA10046_XTAL_16M,
  612. .agc_config = TDA10046_AGC_TDA827X,
  613. .gpio_config = TDA10046_GP11_I,
  614. .if_freq = TDA10046_FREQ_045,
  615. .tuner_address = 0x60,
  616. .request_firmware = philips_tda1004x_request_firmware
  617. };
  618. static struct tda1004x_config md8800_dvbt_config = {
  619. .demod_address = 0x08,
  620. .invert = 1,
  621. .invert_oclk = 0,
  622. .xtal_freq = TDA10046_XTAL_16M,
  623. .agc_config = TDA10046_AGC_TDA827X,
  624. .gpio_config = TDA10046_GP01_I,
  625. .if_freq = TDA10046_FREQ_045,
  626. .i2c_gate = 0x4b,
  627. .tuner_address = 0x60,
  628. .tuner_config = 0,
  629. .request_firmware = philips_tda1004x_request_firmware
  630. };
  631. static struct tda1004x_config asus_p7131_4871_config = {
  632. .demod_address = 0x08,
  633. .invert = 1,
  634. .invert_oclk = 0,
  635. .xtal_freq = TDA10046_XTAL_16M,
  636. .agc_config = TDA10046_AGC_TDA827X,
  637. .gpio_config = TDA10046_GP01_I,
  638. .if_freq = TDA10046_FREQ_045,
  639. .i2c_gate = 0x4b,
  640. .tuner_address = 0x61,
  641. .tuner_config = 2,
  642. .antenna_switch= 2,
  643. .request_firmware = philips_tda1004x_request_firmware
  644. };
  645. static struct tda1004x_config asus_p7131_hybrid_lna_config = {
  646. .demod_address = 0x08,
  647. .invert = 1,
  648. .invert_oclk = 0,
  649. .xtal_freq = TDA10046_XTAL_16M,
  650. .agc_config = TDA10046_AGC_TDA827X,
  651. .gpio_config = TDA10046_GP11_I,
  652. .if_freq = TDA10046_FREQ_045,
  653. .i2c_gate = 0x4b,
  654. .tuner_address = 0x61,
  655. .tuner_config = 2,
  656. .antenna_switch= 2,
  657. .request_firmware = philips_tda1004x_request_firmware
  658. };
  659. static struct tda1004x_config kworld_dvb_t_210_config = {
  660. .demod_address = 0x08,
  661. .invert = 1,
  662. .invert_oclk = 0,
  663. .xtal_freq = TDA10046_XTAL_16M,
  664. .agc_config = TDA10046_AGC_TDA827X,
  665. .gpio_config = TDA10046_GP11_I,
  666. .if_freq = TDA10046_FREQ_045,
  667. .i2c_gate = 0x4b,
  668. .tuner_address = 0x61,
  669. .tuner_config = 2,
  670. .antenna_switch= 1,
  671. .request_firmware = philips_tda1004x_request_firmware
  672. };
  673. static struct tda1004x_config avermedia_super_007_config = {
  674. .demod_address = 0x08,
  675. .invert = 1,
  676. .invert_oclk = 0,
  677. .xtal_freq = TDA10046_XTAL_16M,
  678. .agc_config = TDA10046_AGC_TDA827X,
  679. .gpio_config = TDA10046_GP01_I,
  680. .if_freq = TDA10046_FREQ_045,
  681. .i2c_gate = 0x4b,
  682. .tuner_address = 0x60,
  683. .tuner_config = 0,
  684. .antenna_switch= 1,
  685. .request_firmware = philips_tda1004x_request_firmware
  686. };
  687. static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
  688. .demod_address = 0x08,
  689. .invert = 1,
  690. .invert_oclk = 0,
  691. .xtal_freq = TDA10046_XTAL_16M,
  692. .agc_config = TDA10046_AGC_TDA827X,
  693. .gpio_config = TDA10046_GP01_I,
  694. .if_freq = TDA10046_FREQ_045,
  695. .i2c_gate = 0x42,
  696. .tuner_address = 0x61,
  697. .tuner_config = 2,
  698. .antenna_switch = 1,
  699. .request_firmware = philips_tda1004x_request_firmware
  700. };
  701. /* ------------------------------------------------------------------
  702. * special case: this card uses saa713x GPIO22 for the mode switch
  703. */
  704. static int ads_duo_tuner_init(struct dvb_frontend *fe)
  705. {
  706. struct saa7134_dev *dev = fe->dvb->priv;
  707. philips_tda827x_tuner_init(fe);
  708. /* route TDA8275a AGC input to the channel decoder */
  709. saa7134_set_gpio(dev, 22, 1);
  710. return 0;
  711. }
  712. static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
  713. {
  714. struct saa7134_dev *dev = fe->dvb->priv;
  715. /* route TDA8275a AGC input to the analog IF chip*/
  716. saa7134_set_gpio(dev, 22, 0);
  717. philips_tda827x_tuner_sleep(fe);
  718. return 0;
  719. }
  720. static struct tda827x_config ads_duo_cfg = {
  721. .lna_gain = philips_tda827x_lna_gain,
  722. .init = ads_duo_tuner_init,
  723. .sleep = ads_duo_tuner_sleep
  724. };
  725. static struct tda1004x_config ads_tech_duo_config = {
  726. .demod_address = 0x08,
  727. .invert = 1,
  728. .invert_oclk = 0,
  729. .xtal_freq = TDA10046_XTAL_16M,
  730. .agc_config = TDA10046_AGC_TDA827X,
  731. .gpio_config = TDA10046_GP00_I,
  732. .if_freq = TDA10046_FREQ_045,
  733. .tuner_address = 0x61,
  734. .request_firmware = philips_tda1004x_request_firmware
  735. };
  736. /* ==================================================================
  737. * tda10086 based DVB-S cards, helper functions
  738. */
  739. static struct tda10086_config flydvbs = {
  740. .demod_address = 0x0e,
  741. .invert = 0,
  742. .diseqc_tone = 0,
  743. };
  744. /* ------------------------------------------------------------------
  745. * special case: lnb supply is connected to the gated i2c
  746. */
  747. static int md8800_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
  748. {
  749. int res = -EIO;
  750. struct saa7134_dev *dev = fe->dvb->priv;
  751. if (fe->ops.i2c_gate_ctrl) {
  752. fe->ops.i2c_gate_ctrl(fe, 1);
  753. if (dev->original_set_voltage)
  754. res = dev->original_set_voltage(fe, voltage);
  755. fe->ops.i2c_gate_ctrl(fe, 0);
  756. }
  757. return res;
  758. };
  759. static int md8800_set_high_voltage(struct dvb_frontend *fe, long arg)
  760. {
  761. int res = -EIO;
  762. struct saa7134_dev *dev = fe->dvb->priv;
  763. if (fe->ops.i2c_gate_ctrl) {
  764. fe->ops.i2c_gate_ctrl(fe, 1);
  765. if (dev->original_set_high_voltage)
  766. res = dev->original_set_high_voltage(fe, arg);
  767. fe->ops.i2c_gate_ctrl(fe, 0);
  768. }
  769. return res;
  770. };
  771. /* ==================================================================
  772. * nxt200x based ATSC cards, helper functions
  773. */
  774. static struct nxt200x_config avertvhda180 = {
  775. .demod_address = 0x0a,
  776. };
  777. static struct nxt200x_config kworldatsc110 = {
  778. .demod_address = 0x0a,
  779. };
  780. /* ==================================================================
  781. * Core code
  782. */
  783. static int dvb_init(struct saa7134_dev *dev)
  784. {
  785. int ret;
  786. int attach_xc3028 = 0;
  787. /* init struct videobuf_dvb */
  788. dev->ts.nr_bufs = 32;
  789. dev->ts.nr_packets = 32*4;
  790. dev->dvb.name = dev->name;
  791. videobuf_queue_sg_init(&dev->dvb.dvbq, &saa7134_ts_qops,
  792. &dev->pci->dev, &dev->slock,
  793. V4L2_BUF_TYPE_VIDEO_CAPTURE,
  794. V4L2_FIELD_ALTERNATE,
  795. sizeof(struct saa7134_buf),
  796. dev);
  797. switch (dev->board) {
  798. case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
  799. dprintk("pinnacle 300i dvb setup\n");
  800. dev->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
  801. &dev->i2c_adap);
  802. if (dev->dvb.frontend) {
  803. dev->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
  804. }
  805. break;
  806. case SAA7134_BOARD_AVERMEDIA_777:
  807. case SAA7134_BOARD_AVERMEDIA_A16AR:
  808. dprintk("avertv 777 dvb setup\n");
  809. dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
  810. &dev->i2c_adap);
  811. if (dev->dvb.frontend) {
  812. dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
  813. NULL, DVB_PLL_PHILIPS_TD1316);
  814. }
  815. break;
  816. case SAA7134_BOARD_MD7134:
  817. dev->dvb.frontend = dvb_attach(tda10046_attach,
  818. &medion_cardbus,
  819. &dev->i2c_adap);
  820. if (dev->dvb.frontend) {
  821. dvb_attach(dvb_pll_attach, dev->dvb.frontend, medion_cardbus.tuner_address,
  822. &dev->i2c_adap, DVB_PLL_FMD1216ME);
  823. }
  824. break;
  825. case SAA7134_BOARD_PHILIPS_TOUGH:
  826. dev->dvb.frontend = dvb_attach(tda10046_attach,
  827. &philips_tu1216_60_config,
  828. &dev->i2c_adap);
  829. if (dev->dvb.frontend) {
  830. dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
  831. dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
  832. }
  833. break;
  834. case SAA7134_BOARD_FLYDVBTDUO:
  835. case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
  836. configure_tda827x_fe(dev, &tda827x_lifeview_config);
  837. break;
  838. case SAA7134_BOARD_PHILIPS_EUROPA:
  839. case SAA7134_BOARD_VIDEOMATE_DVBT_300:
  840. dev->dvb.frontend = dvb_attach(tda10046_attach,
  841. &philips_europa_config,
  842. &dev->i2c_adap);
  843. if (dev->dvb.frontend) {
  844. dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
  845. dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
  846. dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
  847. dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
  848. dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
  849. }
  850. break;
  851. case SAA7134_BOARD_VIDEOMATE_DVBT_200:
  852. dev->dvb.frontend = dvb_attach(tda10046_attach,
  853. &philips_tu1216_61_config,
  854. &dev->i2c_adap);
  855. if (dev->dvb.frontend) {
  856. dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
  857. dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
  858. }
  859. break;
  860. case SAA7134_BOARD_KWORLD_DVBT_210:
  861. configure_tda827x_fe(dev, &kworld_dvb_t_210_config);
  862. break;
  863. case SAA7134_BOARD_PHILIPS_TIGER:
  864. configure_tda827x_fe(dev, &philips_tiger_config);
  865. break;
  866. case SAA7134_BOARD_PINNACLE_PCTV_310i:
  867. configure_tda827x_fe(dev, &pinnacle_pctv_310i_config);
  868. break;
  869. case SAA7134_BOARD_HAUPPAUGE_HVR1110:
  870. configure_tda827x_fe(dev, &hauppauge_hvr_1110_config);
  871. break;
  872. case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
  873. configure_tda827x_fe(dev, &asus_p7131_dual_config);
  874. break;
  875. case SAA7134_BOARD_FLYDVBT_LR301:
  876. configure_tda827x_fe(dev, &tda827x_lifeview_config);
  877. break;
  878. case SAA7134_BOARD_FLYDVB_TRIO:
  879. if(! use_frontend) { /* terrestrial */
  880. configure_tda827x_fe(dev, &lifeview_trio_config);
  881. } else { /* satellite */
  882. dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
  883. if (dev->dvb.frontend) {
  884. if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63,
  885. &dev->i2c_adap, 0) == NULL) {
  886. wprintk("%s: Lifeview Trio, No tda826x found!\n", __FUNCTION__);
  887. }
  888. if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap,
  889. 0x08, 0, 0) == NULL) {
  890. wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __FUNCTION__);
  891. }
  892. }
  893. }
  894. break;
  895. case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
  896. case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
  897. dev->dvb.frontend = dvb_attach(tda10046_attach,
  898. &ads_tech_duo_config,
  899. &dev->i2c_adap);
  900. if (dev->dvb.frontend) {
  901. if (dvb_attach(tda827x_attach,dev->dvb.frontend,
  902. ads_tech_duo_config.tuner_address,
  903. &dev->i2c_adap,&ads_duo_cfg) == NULL) {
  904. wprintk("no tda827x tuner found at addr: %02x\n",
  905. ads_tech_duo_config.tuner_address);
  906. }
  907. }
  908. break;
  909. case SAA7134_BOARD_TEVION_DVBT_220RF:
  910. configure_tda827x_fe(dev, &tevion_dvbt220rf_config);
  911. break;
  912. case SAA7134_BOARD_MEDION_MD8800_QUADRO:
  913. if (!use_frontend) { /* terrestrial */
  914. configure_tda827x_fe(dev, &md8800_dvbt_config);
  915. } else { /* satellite */
  916. dev->dvb.frontend = dvb_attach(tda10086_attach,
  917. &flydvbs, &dev->i2c_adap);
  918. if (dev->dvb.frontend) {
  919. struct dvb_frontend *fe;
  920. if (dvb_attach(tda826x_attach, dev->dvb.frontend,
  921. 0x60, &dev->i2c_adap, 0) == NULL)
  922. wprintk("%s: Medion Quadro, no tda826x "
  923. "found !\n", __FUNCTION__);
  924. /* Note 10.2. Hac
  925. * up to here. configuration for ctx948 and and one branch
  926. * of md8800 should be identical
  927. */
  928. /* we need to open the i2c gate (we know it exists) */
  929. fe = dev->dvb.frontend;
  930. fe->ops.i2c_gate_ctrl(fe, 1);
  931. if (dvb_attach(isl6405_attach, fe,
  932. &dev->i2c_adap, 0x08, 0, 0) == NULL)
  933. wprintk("%s: Medion Quadro, no ISL6405 "
  934. "found !\n", __FUNCTION__);
  935. fe->ops.i2c_gate_ctrl(fe, 0);
  936. dev->original_set_voltage = fe->ops.set_voltage;
  937. fe->ops.set_voltage = md8800_set_voltage;
  938. dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
  939. fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
  940. }
  941. }
  942. break;
  943. case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
  944. dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
  945. &dev->i2c_adap);
  946. if (dev->dvb.frontend) {
  947. dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
  948. NULL, DVB_PLL_TDHU2);
  949. }
  950. break;
  951. case SAA7134_BOARD_KWORLD_ATSC110:
  952. dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
  953. &dev->i2c_adap);
  954. if (dev->dvb.frontend) {
  955. dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
  956. NULL, DVB_PLL_TUV1236D);
  957. }
  958. break;
  959. case SAA7134_BOARD_FLYDVBS_LR300:
  960. dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
  961. &dev->i2c_adap);
  962. if (dev->dvb.frontend) {
  963. if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
  964. &dev->i2c_adap, 0) == NULL) {
  965. wprintk("%s: No tda826x found!\n", __FUNCTION__);
  966. }
  967. if (dvb_attach(isl6421_attach, dev->dvb.frontend,
  968. &dev->i2c_adap, 0x08, 0, 0) == NULL) {
  969. wprintk("%s: No ISL6421 found!\n", __FUNCTION__);
  970. }
  971. }
  972. break;
  973. case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
  974. dev->dvb.frontend = dvb_attach(tda10046_attach,
  975. &medion_cardbus,
  976. &dev->i2c_adap);
  977. if (dev->dvb.frontend) {
  978. dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
  979. dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
  980. dvb_attach(dvb_pll_attach, dev->dvb.frontend, medion_cardbus.tuner_address,
  981. &dev->i2c_adap, DVB_PLL_FMD1216ME);
  982. }
  983. break;
  984. case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
  985. dev->dvb.frontend = dvb_attach(tda10046_attach,
  986. &philips_europa_config,
  987. &dev->i2c_adap);
  988. if (dev->dvb.frontend) {
  989. dev->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
  990. dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
  991. }
  992. break;
  993. case SAA7134_BOARD_CINERGY_HT_PCMCIA:
  994. configure_tda827x_fe(dev, &cinergy_ht_config);
  995. break;
  996. case SAA7134_BOARD_CINERGY_HT_PCI:
  997. configure_tda827x_fe(dev, &cinergy_ht_pci_config);
  998. break;
  999. case SAA7134_BOARD_PHILIPS_TIGER_S:
  1000. configure_tda827x_fe(dev, &philips_tiger_s_config);
  1001. break;
  1002. case SAA7134_BOARD_ASUS_P7131_4871:
  1003. configure_tda827x_fe(dev, &asus_p7131_4871_config);
  1004. break;
  1005. case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
  1006. configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config);
  1007. break;
  1008. case SAA7134_BOARD_AVERMEDIA_SUPER_007:
  1009. configure_tda827x_fe(dev, &avermedia_super_007_config);
  1010. break;
  1011. case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
  1012. configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config);
  1013. break;
  1014. case SAA7134_BOARD_PHILIPS_SNAKE:
  1015. dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
  1016. &dev->i2c_adap);
  1017. if (dev->dvb.frontend) {
  1018. if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
  1019. &dev->i2c_adap, 0) == NULL)
  1020. wprintk("%s: No tda826x found!\n", __FUNCTION__);
  1021. if (dvb_attach(lnbp21_attach, dev->dvb.frontend,
  1022. &dev->i2c_adap, 0, 0) == NULL)
  1023. wprintk("%s: No lnbp21 found!\n", __FUNCTION__);
  1024. }
  1025. break;
  1026. case SAA7134_BOARD_CREATIX_CTX953:
  1027. configure_tda827x_fe(dev, &md8800_dvbt_config);
  1028. break;
  1029. case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
  1030. configure_tda827x_fe(dev, &philips_tiger_s_config);
  1031. break;
  1032. case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
  1033. dev->dvb.frontend = dvb_attach(mt352_attach,
  1034. &avermedia_e506r_mt352_dev,
  1035. &dev->i2c_adap);
  1036. attach_xc3028 = 1;
  1037. break;
  1038. default:
  1039. wprintk("Huh? unknown DVB card?\n");
  1040. break;
  1041. }
  1042. if (attach_xc3028) {
  1043. struct dvb_frontend *fe;
  1044. struct xc2028_config cfg = {
  1045. .i2c_adap = &dev->i2c_adap,
  1046. .i2c_addr = 0x61,
  1047. .video_dev = dev->i2c_adap.algo_data,
  1048. };
  1049. fe = dvb_attach(xc2028_attach, dev->dvb.frontend, &cfg);
  1050. if (!fe) {
  1051. printk(KERN_ERR "%s/2: xc3028 attach failed\n",
  1052. dev->name);
  1053. dvb_frontend_detach(dev->dvb.frontend);
  1054. dvb_unregister_frontend(dev->dvb.frontend);
  1055. dev->dvb.frontend = NULL;
  1056. return -1;
  1057. }
  1058. }
  1059. if (NULL == dev->dvb.frontend) {
  1060. printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
  1061. return -1;
  1062. }
  1063. /* register everything else */
  1064. ret = videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev);
  1065. /* this sequence is necessary to make the tda1004x load its firmware
  1066. * and to enter analog mode of hybrid boards
  1067. */
  1068. if (!ret) {
  1069. if (dev->dvb.frontend->ops.init)
  1070. dev->dvb.frontend->ops.init(dev->dvb.frontend);
  1071. if (dev->dvb.frontend->ops.sleep)
  1072. dev->dvb.frontend->ops.sleep(dev->dvb.frontend);
  1073. if (dev->dvb.frontend->ops.tuner_ops.sleep)
  1074. dev->dvb.frontend->ops.tuner_ops.sleep(dev->dvb.frontend);
  1075. }
  1076. return ret;
  1077. }
  1078. static int dvb_fini(struct saa7134_dev *dev)
  1079. {
  1080. /* FIXME: I suspect that this code is bogus, since the entry for
  1081. Pinnacle 300I DVB-T PAL already defines the proper init to allow
  1082. the detection of mt2032 (TDA9887_PORT2_INACTIVE)
  1083. */
  1084. if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
  1085. struct v4l2_priv_tun_config tda9887_cfg;
  1086. static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
  1087. tda9887_cfg.tuner = TUNER_TDA9887;
  1088. tda9887_cfg.priv = &on;
  1089. /* otherwise we don't detect the tuner on next insmod */
  1090. saa7134_i2c_call_clients(dev, TUNER_SET_CONFIG, &tda9887_cfg);
  1091. }
  1092. videobuf_dvb_unregister(&dev->dvb);
  1093. return 0;
  1094. }
  1095. static struct saa7134_mpeg_ops dvb_ops = {
  1096. .type = SAA7134_MPEG_DVB,
  1097. .init = dvb_init,
  1098. .fini = dvb_fini,
  1099. };
  1100. static int __init dvb_register(void)
  1101. {
  1102. return saa7134_ts_register(&dvb_ops);
  1103. }
  1104. static void __exit dvb_unregister(void)
  1105. {
  1106. saa7134_ts_unregister(&dvb_ops);
  1107. }
  1108. module_init(dvb_register);
  1109. module_exit(dvb_unregister);
  1110. /* ------------------------------------------------------------------ */
  1111. /*
  1112. * Local variables:
  1113. * c-basic-offset: 8
  1114. * End:
  1115. */