saa7134-dvb.c 34 KB

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