saa7134-dvb.c 38 KB

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