saa7134-dvb.c 39 KB

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