saa7134-dvb.c 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189
  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. static void philips_tda1004x_set_board_name(struct dvb_frontend *fe, char *name)
  176. {
  177. size_t len;
  178. len = sizeof(fe->ops.info.name);
  179. strncpy(fe->ops.info.name, name, len);
  180. fe->ops.info.name[len - 1] = 0;
  181. }
  182. /* ------------------------------------------------------------------
  183. * these tuners are tu1216, td1316(a)
  184. */
  185. static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  186. {
  187. struct saa7134_dev *dev = fe->dvb->priv;
  188. struct tda1004x_state *state = fe->demodulator_priv;
  189. u8 addr = state->config->tuner_address;
  190. u8 tuner_buf[4];
  191. struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
  192. sizeof(tuner_buf) };
  193. int tuner_frequency = 0;
  194. u8 band, cp, filter;
  195. /* determine charge pump */
  196. tuner_frequency = params->frequency + 36166000;
  197. if (tuner_frequency < 87000000)
  198. return -EINVAL;
  199. else if (tuner_frequency < 130000000)
  200. cp = 3;
  201. else if (tuner_frequency < 160000000)
  202. cp = 5;
  203. else if (tuner_frequency < 200000000)
  204. cp = 6;
  205. else if (tuner_frequency < 290000000)
  206. cp = 3;
  207. else if (tuner_frequency < 420000000)
  208. cp = 5;
  209. else if (tuner_frequency < 480000000)
  210. cp = 6;
  211. else if (tuner_frequency < 620000000)
  212. cp = 3;
  213. else if (tuner_frequency < 830000000)
  214. cp = 5;
  215. else if (tuner_frequency < 895000000)
  216. cp = 7;
  217. else
  218. return -EINVAL;
  219. /* determine band */
  220. if (params->frequency < 49000000)
  221. return -EINVAL;
  222. else if (params->frequency < 161000000)
  223. band = 1;
  224. else if (params->frequency < 444000000)
  225. band = 2;
  226. else if (params->frequency < 861000000)
  227. band = 4;
  228. else
  229. return -EINVAL;
  230. /* setup PLL filter */
  231. switch (params->u.ofdm.bandwidth) {
  232. case BANDWIDTH_6_MHZ:
  233. filter = 0;
  234. break;
  235. case BANDWIDTH_7_MHZ:
  236. filter = 0;
  237. break;
  238. case BANDWIDTH_8_MHZ:
  239. filter = 1;
  240. break;
  241. default:
  242. return -EINVAL;
  243. }
  244. /* calculate divisor
  245. * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
  246. */
  247. tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
  248. /* setup tuner buffer */
  249. tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
  250. tuner_buf[1] = tuner_frequency & 0xff;
  251. tuner_buf[2] = 0xca;
  252. tuner_buf[3] = (cp << 5) | (filter << 3) | band;
  253. if (fe->ops.i2c_gate_ctrl)
  254. fe->ops.i2c_gate_ctrl(fe, 1);
  255. if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
  256. printk("%s/dvb: could not write to tuner at addr: 0x%02x\n",dev->name, addr << 1);
  257. return -EIO;
  258. }
  259. msleep(1);
  260. return 0;
  261. }
  262. static int philips_tu1216_init(struct dvb_frontend *fe)
  263. {
  264. struct saa7134_dev *dev = fe->dvb->priv;
  265. struct tda1004x_state *state = fe->demodulator_priv;
  266. u8 addr = state->config->tuner_address;
  267. static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
  268. struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
  269. /* setup PLL configuration */
  270. if (fe->ops.i2c_gate_ctrl)
  271. fe->ops.i2c_gate_ctrl(fe, 1);
  272. if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
  273. return -EIO;
  274. msleep(1);
  275. return 0;
  276. }
  277. /* ------------------------------------------------------------------ */
  278. static struct tda1004x_config philips_tu1216_60_config = {
  279. .demod_address = 0x8,
  280. .invert = 1,
  281. .invert_oclk = 0,
  282. .xtal_freq = TDA10046_XTAL_4M,
  283. .agc_config = TDA10046_AGC_DEFAULT,
  284. .if_freq = TDA10046_FREQ_3617,
  285. .tuner_address = 0x60,
  286. .request_firmware = philips_tda1004x_request_firmware
  287. };
  288. static struct tda1004x_config philips_tu1216_61_config = {
  289. .demod_address = 0x8,
  290. .invert = 1,
  291. .invert_oclk = 0,
  292. .xtal_freq = TDA10046_XTAL_4M,
  293. .agc_config = TDA10046_AGC_DEFAULT,
  294. .if_freq = TDA10046_FREQ_3617,
  295. .tuner_address = 0x61,
  296. .request_firmware = philips_tda1004x_request_firmware
  297. };
  298. /* ------------------------------------------------------------------ */
  299. static int philips_td1316_tuner_init(struct dvb_frontend *fe)
  300. {
  301. struct saa7134_dev *dev = fe->dvb->priv;
  302. struct tda1004x_state *state = fe->demodulator_priv;
  303. u8 addr = state->config->tuner_address;
  304. static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
  305. struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
  306. /* setup PLL configuration */
  307. if (fe->ops.i2c_gate_ctrl)
  308. fe->ops.i2c_gate_ctrl(fe, 1);
  309. if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
  310. return -EIO;
  311. return 0;
  312. }
  313. static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  314. {
  315. return philips_tda6651_pll_set(fe, params);
  316. }
  317. static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
  318. {
  319. struct saa7134_dev *dev = fe->dvb->priv;
  320. struct tda1004x_state *state = fe->demodulator_priv;
  321. u8 addr = state->config->tuner_address;
  322. static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
  323. struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
  324. /* switch the tuner to analog mode */
  325. if (fe->ops.i2c_gate_ctrl)
  326. fe->ops.i2c_gate_ctrl(fe, 1);
  327. if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
  328. return -EIO;
  329. return 0;
  330. }
  331. /* ------------------------------------------------------------------ */
  332. static int philips_europa_tuner_init(struct dvb_frontend *fe)
  333. {
  334. struct saa7134_dev *dev = fe->dvb->priv;
  335. static u8 msg[] = { 0x00, 0x40};
  336. struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
  337. if (philips_td1316_tuner_init(fe))
  338. return -EIO;
  339. msleep(1);
  340. if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
  341. return -EIO;
  342. return 0;
  343. }
  344. static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
  345. {
  346. struct saa7134_dev *dev = fe->dvb->priv;
  347. static u8 msg[] = { 0x00, 0x14 };
  348. struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
  349. if (philips_td1316_tuner_sleep(fe))
  350. return -EIO;
  351. /* switch the board to analog mode */
  352. if (fe->ops.i2c_gate_ctrl)
  353. fe->ops.i2c_gate_ctrl(fe, 1);
  354. i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
  355. return 0;
  356. }
  357. static int philips_europa_demod_sleep(struct dvb_frontend *fe)
  358. {
  359. struct saa7134_dev *dev = fe->dvb->priv;
  360. if (dev->original_demod_sleep)
  361. dev->original_demod_sleep(fe);
  362. fe->ops.i2c_gate_ctrl(fe, 1);
  363. return 0;
  364. }
  365. static struct tda1004x_config philips_europa_config = {
  366. .demod_address = 0x8,
  367. .invert = 0,
  368. .invert_oclk = 0,
  369. .xtal_freq = TDA10046_XTAL_4M,
  370. .agc_config = TDA10046_AGC_IFO_AUTO_POS,
  371. .if_freq = TDA10046_FREQ_052,
  372. .tuner_address = 0x61,
  373. .request_firmware = philips_tda1004x_request_firmware
  374. };
  375. /* ------------------------------------------------------------------ */
  376. static int philips_fmd1216_tuner_init(struct dvb_frontend *fe)
  377. {
  378. struct saa7134_dev *dev = fe->dvb->priv;
  379. struct tda1004x_state *state = fe->demodulator_priv;
  380. u8 addr = state->config->tuner_address;
  381. /* this message is to set up ATC and ALC */
  382. static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0xa0 };
  383. struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) };
  384. if (fe->ops.i2c_gate_ctrl)
  385. fe->ops.i2c_gate_ctrl(fe, 1);
  386. if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
  387. return -EIO;
  388. msleep(1);
  389. return 0;
  390. }
  391. static int philips_fmd1216_tuner_sleep(struct dvb_frontend *fe)
  392. {
  393. struct saa7134_dev *dev = fe->dvb->priv;
  394. struct tda1004x_state *state = fe->demodulator_priv;
  395. u8 addr = state->config->tuner_address;
  396. /* this message actually turns the tuner back to analog mode */
  397. static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0x60 };
  398. struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) };
  399. if (fe->ops.i2c_gate_ctrl)
  400. fe->ops.i2c_gate_ctrl(fe, 1);
  401. i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
  402. msleep(1);
  403. fmd1216_init[2] = 0x86;
  404. fmd1216_init[3] = 0x54;
  405. if (fe->ops.i2c_gate_ctrl)
  406. fe->ops.i2c_gate_ctrl(fe, 1);
  407. i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
  408. msleep(1);
  409. return 0;
  410. }
  411. static int philips_fmd1216_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  412. {
  413. struct saa7134_dev *dev = fe->dvb->priv;
  414. struct tda1004x_state *state = fe->demodulator_priv;
  415. u8 addr = state->config->tuner_address;
  416. u8 tuner_buf[4];
  417. struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
  418. sizeof(tuner_buf) };
  419. int tuner_frequency = 0;
  420. int divider = 0;
  421. u8 band, mode, cp;
  422. /* determine charge pump */
  423. tuner_frequency = params->frequency + 36130000;
  424. if (tuner_frequency < 87000000)
  425. return -EINVAL;
  426. /* low band */
  427. else if (tuner_frequency < 180000000) {
  428. band = 1;
  429. mode = 7;
  430. cp = 0;
  431. } else if (tuner_frequency < 195000000) {
  432. band = 1;
  433. mode = 6;
  434. cp = 1;
  435. /* mid band */
  436. } else if (tuner_frequency < 366000000) {
  437. if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
  438. band = 10;
  439. } else {
  440. band = 2;
  441. }
  442. mode = 7;
  443. cp = 0;
  444. } else if (tuner_frequency < 478000000) {
  445. if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
  446. band = 10;
  447. } else {
  448. band = 2;
  449. }
  450. mode = 6;
  451. cp = 1;
  452. /* high band */
  453. } else if (tuner_frequency < 662000000) {
  454. if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
  455. band = 12;
  456. } else {
  457. band = 4;
  458. }
  459. mode = 7;
  460. cp = 0;
  461. } else if (tuner_frequency < 840000000) {
  462. if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
  463. band = 12;
  464. } else {
  465. band = 4;
  466. }
  467. mode = 6;
  468. cp = 1;
  469. } else {
  470. if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
  471. band = 12;
  472. } else {
  473. band = 4;
  474. }
  475. mode = 7;
  476. cp = 1;
  477. }
  478. /* calculate divisor */
  479. /* ((36166000 + Finput) / 166666) rounded! */
  480. divider = (tuner_frequency + 83333) / 166667;
  481. /* setup tuner buffer */
  482. tuner_buf[0] = (divider >> 8) & 0x7f;
  483. tuner_buf[1] = divider & 0xff;
  484. tuner_buf[2] = 0x80 | (cp << 6) | (mode << 3) | 4;
  485. tuner_buf[3] = 0x40 | band;
  486. if (fe->ops.i2c_gate_ctrl)
  487. fe->ops.i2c_gate_ctrl(fe, 1);
  488. if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
  489. printk("%s/dvb: could not write to tuner at addr: 0x%02x\n",dev->name, addr << 1);
  490. return -EIO;
  491. }
  492. return 0;
  493. }
  494. static struct tda1004x_config medion_cardbus = {
  495. .demod_address = 0x08,
  496. .invert = 1,
  497. .invert_oclk = 0,
  498. .xtal_freq = TDA10046_XTAL_16M,
  499. .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
  500. .if_freq = TDA10046_FREQ_3613,
  501. .tuner_address = 0x61,
  502. .request_firmware = philips_tda1004x_request_firmware
  503. };
  504. /* ------------------------------------------------------------------
  505. * tda 1004x based cards with philips silicon tuner
  506. */
  507. static void philips_tda827x_lna_gain(struct dvb_frontend *fe, int high)
  508. {
  509. struct saa7134_dev *dev = fe->dvb->priv;
  510. struct tda1004x_state *state = fe->demodulator_priv;
  511. u8 addr = state->config->i2c_gate;
  512. u8 config = state->config->tuner_config;
  513. u8 GP00_CF[] = {0x20, 0x01};
  514. u8 GP00_LEV[] = {0x22, 0x00};
  515. struct i2c_msg msg = {.addr = addr,.flags = 0,.buf = GP00_CF, .len = 2};
  516. if (config) {
  517. if (high) {
  518. dprintk("setting LNA to high gain\n");
  519. } else {
  520. dprintk("setting LNA to low gain\n");
  521. }
  522. }
  523. switch (config) {
  524. case 0: /* no LNA */
  525. break;
  526. case 1: /* switch is GPIO 0 of tda8290 */
  527. case 2:
  528. /* turn Vsync off */
  529. saa7134_set_gpio(dev, 22, 0);
  530. GP00_LEV[1] = high ? 0 : 1;
  531. if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
  532. printk("%s/dvb: could not access tda8290 at addr: 0x%02x\n",dev->name, addr << 1);
  533. return;
  534. }
  535. msg.buf = GP00_LEV;
  536. if (config == 2)
  537. GP00_LEV[1] = high ? 1 : 0;
  538. i2c_transfer(&dev->i2c_adap, &msg, 1);
  539. break;
  540. case 3: /* switch with GPIO of saa713x */
  541. saa7134_set_gpio(dev, 22, high);
  542. break;
  543. }
  544. }
  545. static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
  546. {
  547. struct tda1004x_state *state = fe->demodulator_priv;
  548. u8 addr = state->config->i2c_gate;
  549. static u8 tda8290_close[] = { 0x21, 0xc0};
  550. static u8 tda8290_open[] = { 0x21, 0x80};
  551. struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
  552. if (enable) {
  553. tda8290_msg.buf = tda8290_close;
  554. } else {
  555. tda8290_msg.buf = tda8290_open;
  556. }
  557. if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
  558. printk("saa7134/dvb: could not access tda8290 I2C gate\n");
  559. return -EIO;
  560. }
  561. msleep(20);
  562. return 0;
  563. }
  564. /* ------------------------------------------------------------------ */
  565. static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
  566. {
  567. struct saa7134_dev *dev = fe->dvb->priv;
  568. struct tda1004x_state *state = fe->demodulator_priv;
  569. switch (state->config->antenna_switch) {
  570. case 0: break;
  571. case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
  572. saa7134_set_gpio(dev, 21, 0);
  573. break;
  574. case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
  575. saa7134_set_gpio(dev, 21, 1);
  576. break;
  577. }
  578. return 0;
  579. }
  580. static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
  581. {
  582. struct saa7134_dev *dev = fe->dvb->priv;
  583. struct tda1004x_state *state = fe->demodulator_priv;
  584. switch (state->config->antenna_switch) {
  585. case 0: break;
  586. case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
  587. saa7134_set_gpio(dev, 21, 1);
  588. break;
  589. case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
  590. saa7134_set_gpio(dev, 21, 0);
  591. break;
  592. }
  593. return 0;
  594. }
  595. static struct tda827x_config tda827x_cfg = {
  596. .lna_gain = philips_tda827x_lna_gain,
  597. .init = philips_tda827x_tuner_init,
  598. .sleep = philips_tda827x_tuner_sleep
  599. };
  600. static void configure_tda827x_fe(struct saa7134_dev *dev, struct tda1004x_config *tda_conf,
  601. char *board_name)
  602. {
  603. dev->dvb.frontend = dvb_attach(tda10046_attach, tda_conf, &dev->i2c_adap);
  604. if (dev->dvb.frontend) {
  605. if (tda_conf->i2c_gate)
  606. dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
  607. dvb_attach(tda827x_attach,dev->dvb.frontend,
  608. tda_conf->tuner_address,&dev->i2c_adap,&tda827x_cfg);
  609. }
  610. philips_tda1004x_set_board_name(dev->dvb.frontend, board_name);
  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. /* ------------------------------------------------------------------
  753. * special case: this card uses saa713x GPIO22 for the mode switch
  754. */
  755. static int ads_duo_tuner_init(struct dvb_frontend *fe)
  756. {
  757. struct saa7134_dev *dev = fe->dvb->priv;
  758. philips_tda827x_tuner_init(fe);
  759. /* route TDA8275a AGC input to the channel decoder */
  760. saa7134_set_gpio(dev, 22, 1);
  761. return 0;
  762. }
  763. static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
  764. {
  765. struct saa7134_dev *dev = fe->dvb->priv;
  766. /* route TDA8275a AGC input to the analog IF chip*/
  767. saa7134_set_gpio(dev, 22, 0);
  768. philips_tda827x_tuner_sleep(fe);
  769. return 0;
  770. }
  771. static struct tda827x_config ads_duo_cfg = {
  772. .lna_gain = philips_tda827x_lna_gain,
  773. .init = ads_duo_tuner_init,
  774. .sleep = ads_duo_tuner_sleep
  775. };
  776. static struct tda1004x_config ads_tech_duo_config = {
  777. .demod_address = 0x08,
  778. .invert = 1,
  779. .invert_oclk = 0,
  780. .xtal_freq = TDA10046_XTAL_16M,
  781. .agc_config = TDA10046_AGC_TDA827X,
  782. .gpio_config = TDA10046_GP00_I,
  783. .if_freq = TDA10046_FREQ_045,
  784. .tuner_address = 0x61,
  785. .request_firmware = philips_tda1004x_request_firmware
  786. };
  787. /* ==================================================================
  788. * tda10086 based DVB-S cards, helper functions
  789. */
  790. static struct tda10086_config flydvbs = {
  791. .demod_address = 0x0e,
  792. .invert = 0,
  793. };
  794. /* ==================================================================
  795. * nxt200x based ATSC cards, helper functions
  796. */
  797. static struct nxt200x_config avertvhda180 = {
  798. .demod_address = 0x0a,
  799. };
  800. static int nxt200x_set_pll_input(u8 *buf, int input)
  801. {
  802. if (input)
  803. buf[3] |= 0x08;
  804. else
  805. buf[3] &= ~0x08;
  806. return 0;
  807. }
  808. static struct nxt200x_config kworldatsc110 = {
  809. .demod_address = 0x0a,
  810. .set_pll_input = nxt200x_set_pll_input,
  811. };
  812. /* ==================================================================
  813. * Core code
  814. */
  815. static int dvb_init(struct saa7134_dev *dev)
  816. {
  817. char *board_name;
  818. /* init struct videobuf_dvb */
  819. dev->ts.nr_bufs = 32;
  820. dev->ts.nr_packets = 32*4;
  821. dev->dvb.name = dev->name;
  822. videobuf_queue_init(&dev->dvb.dvbq, &saa7134_ts_qops,
  823. dev->pci, &dev->slock,
  824. V4L2_BUF_TYPE_VIDEO_CAPTURE,
  825. V4L2_FIELD_ALTERNATE,
  826. sizeof(struct saa7134_buf),
  827. dev);
  828. switch (dev->board) {
  829. case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
  830. printk("%s: pinnacle 300i dvb setup\n",dev->name);
  831. dev->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
  832. &dev->i2c_adap);
  833. if (dev->dvb.frontend) {
  834. dev->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
  835. }
  836. break;
  837. case SAA7134_BOARD_AVERMEDIA_777:
  838. case SAA7134_BOARD_AVERMEDIA_A16AR:
  839. printk("%s: avertv 777 dvb setup\n",dev->name);
  840. dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
  841. &dev->i2c_adap);
  842. if (dev->dvb.frontend) {
  843. dev->dvb.frontend->ops.tuner_ops.calc_regs = mt352_aver777_tuner_calc_regs;
  844. }
  845. break;
  846. case SAA7134_BOARD_MD7134:
  847. dev->dvb.frontend = dvb_attach(tda10046_attach,
  848. &medion_cardbus,
  849. &dev->i2c_adap);
  850. if (dev->dvb.frontend) {
  851. dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init;
  852. dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep;
  853. dev->dvb.frontend->ops.tuner_ops.set_params = philips_fmd1216_tuner_set_params;
  854. philips_tda1004x_set_board_name(dev->dvb.frontend, "DVB-T Medion MD7134");
  855. }
  856. break;
  857. case SAA7134_BOARD_PHILIPS_TOUGH:
  858. dev->dvb.frontend = dvb_attach(tda10046_attach,
  859. &philips_tu1216_60_config,
  860. &dev->i2c_adap);
  861. if (dev->dvb.frontend) {
  862. dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
  863. dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
  864. philips_tda1004x_set_board_name(dev->dvb.frontend, "DVB-T Philips TOUGH");
  865. }
  866. break;
  867. case SAA7134_BOARD_FLYDVBTDUO:
  868. case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
  869. configure_tda827x_fe(dev, &tda827x_lifeview_config, "DVB-T Lifeview FlyDVB Duo");
  870. break;
  871. case SAA7134_BOARD_PHILIPS_EUROPA:
  872. case SAA7134_BOARD_VIDEOMATE_DVBT_300:
  873. dev->dvb.frontend = dvb_attach(tda10046_attach,
  874. &philips_europa_config,
  875. &dev->i2c_adap);
  876. if (dev->dvb.frontend) {
  877. dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
  878. dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
  879. dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
  880. dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
  881. dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
  882. if (dev->board == SAA7134_BOARD_VIDEOMATE_DVBT_300)
  883. board_name = "DVB-T Compro VideoMate 300";
  884. else
  885. board_name = "DVB-T Philips Europa";
  886. philips_tda1004x_set_board_name(dev->dvb.frontend, board_name);
  887. }
  888. break;
  889. case SAA7134_BOARD_VIDEOMATE_DVBT_200:
  890. dev->dvb.frontend = dvb_attach(tda10046_attach,
  891. &philips_tu1216_61_config,
  892. &dev->i2c_adap);
  893. if (dev->dvb.frontend) {
  894. dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
  895. dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
  896. philips_tda1004x_set_board_name(dev->dvb.frontend, "DVB-T Compro VideoMate 200");
  897. }
  898. break;
  899. case SAA7134_BOARD_PHILIPS_TIGER:
  900. configure_tda827x_fe(dev, &philips_tiger_config, "DVB-T Philips Tiger");
  901. break;
  902. case SAA7134_BOARD_PINNACLE_PCTV_310i:
  903. configure_tda827x_fe(dev, &pinnacle_pctv_310i_config, "DVB-T Pinnacle PCTV 310i");
  904. break;
  905. case SAA7134_BOARD_HAUPPAUGE_HVR1110:
  906. configure_tda827x_fe(dev, &hauppauge_hvr_1110_config, "DVB-T Hauppauge HVR 1110");
  907. break;
  908. case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
  909. configure_tda827x_fe(dev, &asus_p7131_dual_config, "DVB-T Asus P7131 Dual");
  910. break;
  911. case SAA7134_BOARD_FLYDVBT_LR301:
  912. configure_tda827x_fe(dev, &tda827x_lifeview_config, "DVB-T Lifeview FlyDVBT LR301");
  913. break;
  914. case SAA7134_BOARD_FLYDVB_TRIO:
  915. if(! use_frontend) { //terrestrial
  916. configure_tda827x_fe(dev, &lifeview_trio_config, NULL);
  917. } else { //satellite
  918. dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
  919. if (dev->dvb.frontend) {
  920. if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63,
  921. &dev->i2c_adap, 0) == NULL) {
  922. printk("%s: Lifeview Trio, No tda826x found!\n", __FUNCTION__);
  923. }
  924. if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap,
  925. 0x08, 0, 0) == NULL) {
  926. printk("%s: Lifeview Trio, No ISL6421 found!\n", __FUNCTION__);
  927. }
  928. }
  929. }
  930. break;
  931. case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
  932. case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
  933. dev->dvb.frontend = dvb_attach(tda10046_attach,
  934. &ads_tech_duo_config,
  935. &dev->i2c_adap);
  936. if (dev->dvb.frontend) {
  937. dvb_attach(tda827x_attach,dev->dvb.frontend,
  938. ads_tech_duo_config.tuner_address,
  939. &dev->i2c_adap,&ads_duo_cfg);
  940. if (dev->board == SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331)
  941. board_name = "DVB-T ADS DUO Cardbus PTV331";
  942. else
  943. board_name = "DVB-T Lifeview FlyDVT Cardbus";
  944. philips_tda1004x_set_board_name(dev->dvb.frontend, board_name);
  945. }
  946. break;
  947. case SAA7134_BOARD_TEVION_DVBT_220RF:
  948. configure_tda827x_fe(dev, &tevion_dvbt220rf_config, "DVB-T Tevion 220RF");
  949. break;
  950. case SAA7134_BOARD_MEDION_MD8800_QUADRO:
  951. configure_tda827x_fe(dev, &md8800_dvbt_config, "DVB-T Medion MD8800");
  952. break;
  953. case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
  954. dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
  955. &dev->i2c_adap);
  956. if (dev->dvb.frontend) {
  957. dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
  958. NULL, &dvb_pll_tdhu2);
  959. }
  960. break;
  961. case SAA7134_BOARD_KWORLD_ATSC110:
  962. dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
  963. &dev->i2c_adap);
  964. if (dev->dvb.frontend) {
  965. dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
  966. NULL, &dvb_pll_tuv1236d);
  967. }
  968. break;
  969. case SAA7134_BOARD_FLYDVBS_LR300:
  970. dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
  971. &dev->i2c_adap);
  972. if (dev->dvb.frontend) {
  973. if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
  974. &dev->i2c_adap, 0) == NULL) {
  975. printk("%s: No tda826x found!\n", __FUNCTION__);
  976. }
  977. if (dvb_attach(isl6421_attach, dev->dvb.frontend,
  978. &dev->i2c_adap, 0x08, 0, 0) == NULL) {
  979. printk("%s: No ISL6421 found!\n", __FUNCTION__);
  980. }
  981. }
  982. break;
  983. case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
  984. dev->dvb.frontend = tda10046_attach(&medion_cardbus,
  985. &dev->i2c_adap);
  986. if (dev->dvb.frontend) {
  987. dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
  988. dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
  989. dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init;
  990. dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep;
  991. dev->dvb.frontend->ops.tuner_ops.set_params = philips_fmd1216_tuner_set_params;
  992. philips_tda1004x_set_board_name(dev->dvb.frontend, "DVBT Asus Europa 2 Hybrid");
  993. }
  994. break;
  995. case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
  996. dev->dvb.frontend = dvb_attach(tda10046_attach,
  997. &philips_europa_config,
  998. &dev->i2c_adap);
  999. if (dev->dvb.frontend) {
  1000. dev->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
  1001. dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
  1002. philips_tda1004x_set_board_name(dev->dvb.frontend, "DVBT Compro Videomate 200a");
  1003. }
  1004. break;
  1005. case SAA7134_BOARD_CINERGY_HT_PCMCIA:
  1006. configure_tda827x_fe(dev, &cinergy_ht_config, "DVB-T Terratec Cinergy HT Cardbus");
  1007. break;
  1008. case SAA7134_BOARD_CINERGY_HT_PCI:
  1009. configure_tda827x_fe(dev, &cinergy_ht_pci_config, "DVB-T Terratec Cinergy HT PCI");
  1010. break;
  1011. case SAA7134_BOARD_PHILIPS_TIGER_S:
  1012. configure_tda827x_fe(dev, &philips_tiger_s_config, "DVB-T Philips Tiger S");
  1013. break;
  1014. default:
  1015. printk("%s: Huh? unknown DVB card?\n",dev->name);
  1016. break;
  1017. }
  1018. if (NULL == dev->dvb.frontend) {
  1019. printk("%s: frontend initialization failed\n",dev->name);
  1020. return -1;
  1021. }
  1022. /* register everything else */
  1023. return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev);
  1024. }
  1025. static int dvb_fini(struct saa7134_dev *dev)
  1026. {
  1027. static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
  1028. switch (dev->board) {
  1029. case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
  1030. /* otherwise we don't detect the tuner on next insmod */
  1031. saa7134_i2c_call_clients(dev,TDA9887_SET_CONFIG,&on);
  1032. break;
  1033. };
  1034. videobuf_dvb_unregister(&dev->dvb);
  1035. return 0;
  1036. }
  1037. static struct saa7134_mpeg_ops dvb_ops = {
  1038. .type = SAA7134_MPEG_DVB,
  1039. .init = dvb_init,
  1040. .fini = dvb_fini,
  1041. };
  1042. static int __init dvb_register(void)
  1043. {
  1044. return saa7134_ts_register(&dvb_ops);
  1045. }
  1046. static void __exit dvb_unregister(void)
  1047. {
  1048. saa7134_ts_unregister(&dvb_ops);
  1049. }
  1050. module_init(dvb_register);
  1051. module_exit(dvb_unregister);
  1052. /* ------------------------------------------------------------------ */
  1053. /*
  1054. * Local variables:
  1055. * c-basic-offset: 8
  1056. * End:
  1057. */