saa7134-dvb.c 38 KB

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