saa7134-dvb.c 33 KB

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