saa7134-dvb.c 34 KB

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