saa7134-dvb.c 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320
  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. /* ------------------------------------------------------------------ */
  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 void philips_tda827x_lna_gain(struct dvb_frontend *fe, int high)
  384. {
  385. struct saa7134_dev *dev = fe->dvb->priv;
  386. struct tda1004x_state *state = fe->demodulator_priv;
  387. u8 addr = state->config->i2c_gate;
  388. u8 config = state->config->tuner_config;
  389. u8 GP00_CF[] = {0x20, 0x01};
  390. u8 GP00_LEV[] = {0x22, 0x00};
  391. struct i2c_msg msg = {.addr = addr,.flags = 0,.buf = GP00_CF, .len = 2};
  392. if (config) {
  393. if (high) {
  394. dprintk("setting LNA to high gain\n");
  395. } else {
  396. dprintk("setting LNA to low gain\n");
  397. }
  398. }
  399. switch (config) {
  400. case 0: /* no LNA */
  401. break;
  402. case 1: /* switch is GPIO 0 of tda8290 */
  403. case 2:
  404. /* turn Vsync off */
  405. saa7134_set_gpio(dev, 22, 0);
  406. GP00_LEV[1] = high ? 0 : 1;
  407. if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
  408. wprintk("could not access tda8290 at addr: 0x%02x\n",
  409. addr << 1);
  410. return;
  411. }
  412. msg.buf = GP00_LEV;
  413. if (config == 2)
  414. GP00_LEV[1] = high ? 1 : 0;
  415. i2c_transfer(&dev->i2c_adap, &msg, 1);
  416. break;
  417. case 3: /* switch with GPIO of saa713x */
  418. saa7134_set_gpio(dev, 22, high);
  419. break;
  420. }
  421. }
  422. static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
  423. {
  424. struct tda1004x_state *state = fe->demodulator_priv;
  425. u8 addr = state->config->i2c_gate;
  426. static u8 tda8290_close[] = { 0x21, 0xc0};
  427. static u8 tda8290_open[] = { 0x21, 0x80};
  428. struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
  429. if (enable) {
  430. tda8290_msg.buf = tda8290_close;
  431. } else {
  432. tda8290_msg.buf = tda8290_open;
  433. }
  434. if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
  435. struct saa7134_dev *dev = fe->dvb->priv;
  436. wprintk("could not access tda8290 I2C gate\n");
  437. return -EIO;
  438. }
  439. msleep(20);
  440. return 0;
  441. }
  442. /* ------------------------------------------------------------------ */
  443. static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
  444. {
  445. struct saa7134_dev *dev = fe->dvb->priv;
  446. struct tda1004x_state *state = fe->demodulator_priv;
  447. switch (state->config->antenna_switch) {
  448. case 0: break;
  449. case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
  450. saa7134_set_gpio(dev, 21, 0);
  451. break;
  452. case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
  453. saa7134_set_gpio(dev, 21, 1);
  454. break;
  455. }
  456. return 0;
  457. }
  458. static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
  459. {
  460. struct saa7134_dev *dev = fe->dvb->priv;
  461. struct tda1004x_state *state = fe->demodulator_priv;
  462. switch (state->config->antenna_switch) {
  463. case 0: break;
  464. case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
  465. saa7134_set_gpio(dev, 21, 1);
  466. break;
  467. case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
  468. saa7134_set_gpio(dev, 21, 0);
  469. break;
  470. }
  471. return 0;
  472. }
  473. static struct tda827x_config tda827x_cfg = {
  474. .lna_gain = philips_tda827x_lna_gain,
  475. .init = philips_tda827x_tuner_init,
  476. .sleep = philips_tda827x_tuner_sleep
  477. };
  478. static void configure_tda827x_fe(struct saa7134_dev *dev, struct tda1004x_config *tda_conf)
  479. {
  480. dev->dvb.frontend = dvb_attach(tda10046_attach, tda_conf, &dev->i2c_adap);
  481. if (dev->dvb.frontend) {
  482. if (tda_conf->i2c_gate)
  483. dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
  484. if (dvb_attach(tda827x_attach, dev->dvb.frontend, tda_conf->tuner_address,
  485. &dev->i2c_adap,&tda827x_cfg) == NULL) {
  486. wprintk("no tda827x tuner found at addr: %02x\n",
  487. tda_conf->tuner_address);
  488. }
  489. }
  490. }
  491. /* ------------------------------------------------------------------ */
  492. static struct tda1004x_config tda827x_lifeview_config = {
  493. .demod_address = 0x08,
  494. .invert = 1,
  495. .invert_oclk = 0,
  496. .xtal_freq = TDA10046_XTAL_16M,
  497. .agc_config = TDA10046_AGC_TDA827X,
  498. .gpio_config = TDA10046_GP11_I,
  499. .if_freq = TDA10046_FREQ_045,
  500. .tuner_address = 0x60,
  501. .request_firmware = philips_tda1004x_request_firmware
  502. };
  503. static struct tda1004x_config philips_tiger_config = {
  504. .demod_address = 0x08,
  505. .invert = 1,
  506. .invert_oclk = 0,
  507. .xtal_freq = TDA10046_XTAL_16M,
  508. .agc_config = TDA10046_AGC_TDA827X,
  509. .gpio_config = TDA10046_GP11_I,
  510. .if_freq = TDA10046_FREQ_045,
  511. .i2c_gate = 0x4b,
  512. .tuner_address = 0x61,
  513. .tuner_config = 0,
  514. .antenna_switch= 1,
  515. .request_firmware = philips_tda1004x_request_firmware
  516. };
  517. static struct tda1004x_config cinergy_ht_config = {
  518. .demod_address = 0x08,
  519. .invert = 1,
  520. .invert_oclk = 0,
  521. .xtal_freq = TDA10046_XTAL_16M,
  522. .agc_config = TDA10046_AGC_TDA827X,
  523. .gpio_config = TDA10046_GP01_I,
  524. .if_freq = TDA10046_FREQ_045,
  525. .i2c_gate = 0x4b,
  526. .tuner_address = 0x61,
  527. .tuner_config = 0,
  528. .request_firmware = philips_tda1004x_request_firmware
  529. };
  530. static struct tda1004x_config cinergy_ht_pci_config = {
  531. .demod_address = 0x08,
  532. .invert = 1,
  533. .invert_oclk = 0,
  534. .xtal_freq = TDA10046_XTAL_16M,
  535. .agc_config = TDA10046_AGC_TDA827X,
  536. .gpio_config = TDA10046_GP01_I,
  537. .if_freq = TDA10046_FREQ_045,
  538. .i2c_gate = 0x4b,
  539. .tuner_address = 0x60,
  540. .tuner_config = 0,
  541. .request_firmware = philips_tda1004x_request_firmware
  542. };
  543. static struct tda1004x_config philips_tiger_s_config = {
  544. .demod_address = 0x08,
  545. .invert = 1,
  546. .invert_oclk = 0,
  547. .xtal_freq = TDA10046_XTAL_16M,
  548. .agc_config = TDA10046_AGC_TDA827X,
  549. .gpio_config = TDA10046_GP01_I,
  550. .if_freq = TDA10046_FREQ_045,
  551. .i2c_gate = 0x4b,
  552. .tuner_address = 0x61,
  553. .tuner_config = 2,
  554. .antenna_switch= 1,
  555. .request_firmware = philips_tda1004x_request_firmware
  556. };
  557. static struct tda1004x_config pinnacle_pctv_310i_config = {
  558. .demod_address = 0x08,
  559. .invert = 1,
  560. .invert_oclk = 0,
  561. .xtal_freq = TDA10046_XTAL_16M,
  562. .agc_config = TDA10046_AGC_TDA827X,
  563. .gpio_config = TDA10046_GP11_I,
  564. .if_freq = TDA10046_FREQ_045,
  565. .i2c_gate = 0x4b,
  566. .tuner_address = 0x61,
  567. .tuner_config = 1,
  568. .request_firmware = philips_tda1004x_request_firmware
  569. };
  570. static struct tda1004x_config hauppauge_hvr_1110_config = {
  571. .demod_address = 0x08,
  572. .invert = 1,
  573. .invert_oclk = 0,
  574. .xtal_freq = TDA10046_XTAL_16M,
  575. .agc_config = TDA10046_AGC_TDA827X,
  576. .gpio_config = TDA10046_GP11_I,
  577. .if_freq = TDA10046_FREQ_045,
  578. .i2c_gate = 0x4b,
  579. .tuner_address = 0x61,
  580. .tuner_config = 1,
  581. .request_firmware = philips_tda1004x_request_firmware
  582. };
  583. static struct tda1004x_config asus_p7131_dual_config = {
  584. .demod_address = 0x08,
  585. .invert = 1,
  586. .invert_oclk = 0,
  587. .xtal_freq = TDA10046_XTAL_16M,
  588. .agc_config = TDA10046_AGC_TDA827X,
  589. .gpio_config = TDA10046_GP11_I,
  590. .if_freq = TDA10046_FREQ_045,
  591. .i2c_gate = 0x4b,
  592. .tuner_address = 0x61,
  593. .tuner_config = 0,
  594. .antenna_switch= 2,
  595. .request_firmware = philips_tda1004x_request_firmware
  596. };
  597. static struct tda1004x_config lifeview_trio_config = {
  598. .demod_address = 0x09,
  599. .invert = 1,
  600. .invert_oclk = 0,
  601. .xtal_freq = TDA10046_XTAL_16M,
  602. .agc_config = TDA10046_AGC_TDA827X,
  603. .gpio_config = TDA10046_GP00_I,
  604. .if_freq = TDA10046_FREQ_045,
  605. .tuner_address = 0x60,
  606. .request_firmware = philips_tda1004x_request_firmware
  607. };
  608. static struct tda1004x_config tevion_dvbt220rf_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_GP11_I,
  615. .if_freq = TDA10046_FREQ_045,
  616. .tuner_address = 0x60,
  617. .request_firmware = philips_tda1004x_request_firmware
  618. };
  619. static struct tda1004x_config md8800_dvbt_config = {
  620. .demod_address = 0x08,
  621. .invert = 1,
  622. .invert_oclk = 0,
  623. .xtal_freq = TDA10046_XTAL_16M,
  624. .agc_config = TDA10046_AGC_TDA827X,
  625. .gpio_config = TDA10046_GP01_I,
  626. .if_freq = TDA10046_FREQ_045,
  627. .i2c_gate = 0x4b,
  628. .tuner_address = 0x60,
  629. .tuner_config = 0,
  630. .request_firmware = philips_tda1004x_request_firmware
  631. };
  632. static struct tda1004x_config asus_p7131_4871_config = {
  633. .demod_address = 0x08,
  634. .invert = 1,
  635. .invert_oclk = 0,
  636. .xtal_freq = TDA10046_XTAL_16M,
  637. .agc_config = TDA10046_AGC_TDA827X,
  638. .gpio_config = TDA10046_GP01_I,
  639. .if_freq = TDA10046_FREQ_045,
  640. .i2c_gate = 0x4b,
  641. .tuner_address = 0x61,
  642. .tuner_config = 2,
  643. .antenna_switch= 2,
  644. .request_firmware = philips_tda1004x_request_firmware
  645. };
  646. static struct tda1004x_config asus_p7131_hybrid_lna_config = {
  647. .demod_address = 0x08,
  648. .invert = 1,
  649. .invert_oclk = 0,
  650. .xtal_freq = TDA10046_XTAL_16M,
  651. .agc_config = TDA10046_AGC_TDA827X,
  652. .gpio_config = TDA10046_GP11_I,
  653. .if_freq = TDA10046_FREQ_045,
  654. .i2c_gate = 0x4b,
  655. .tuner_address = 0x61,
  656. .tuner_config = 2,
  657. .antenna_switch= 2,
  658. .request_firmware = philips_tda1004x_request_firmware
  659. };
  660. static struct tda1004x_config kworld_dvb_t_210_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_GP11_I,
  667. .if_freq = TDA10046_FREQ_045,
  668. .i2c_gate = 0x4b,
  669. .tuner_address = 0x61,
  670. .tuner_config = 2,
  671. .antenna_switch= 1,
  672. .request_firmware = philips_tda1004x_request_firmware
  673. };
  674. static struct tda1004x_config avermedia_super_007_config = {
  675. .demod_address = 0x08,
  676. .invert = 1,
  677. .invert_oclk = 0,
  678. .xtal_freq = TDA10046_XTAL_16M,
  679. .agc_config = TDA10046_AGC_TDA827X,
  680. .gpio_config = TDA10046_GP01_I,
  681. .if_freq = TDA10046_FREQ_045,
  682. .i2c_gate = 0x4b,
  683. .tuner_address = 0x60,
  684. .tuner_config = 0,
  685. .antenna_switch= 1,
  686. .request_firmware = philips_tda1004x_request_firmware
  687. };
  688. static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
  689. .demod_address = 0x08,
  690. .invert = 1,
  691. .invert_oclk = 0,
  692. .xtal_freq = TDA10046_XTAL_16M,
  693. .agc_config = TDA10046_AGC_TDA827X,
  694. .gpio_config = TDA10046_GP01_I,
  695. .if_freq = TDA10046_FREQ_045,
  696. .i2c_gate = 0x42,
  697. .tuner_address = 0x61,
  698. .tuner_config = 2,
  699. .antenna_switch = 1,
  700. .request_firmware = philips_tda1004x_request_firmware
  701. };
  702. /* ------------------------------------------------------------------
  703. * special case: this card uses saa713x GPIO22 for the mode switch
  704. */
  705. static int ads_duo_tuner_init(struct dvb_frontend *fe)
  706. {
  707. struct saa7134_dev *dev = fe->dvb->priv;
  708. philips_tda827x_tuner_init(fe);
  709. /* route TDA8275a AGC input to the channel decoder */
  710. saa7134_set_gpio(dev, 22, 1);
  711. return 0;
  712. }
  713. static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
  714. {
  715. struct saa7134_dev *dev = fe->dvb->priv;
  716. /* route TDA8275a AGC input to the analog IF chip*/
  717. saa7134_set_gpio(dev, 22, 0);
  718. philips_tda827x_tuner_sleep(fe);
  719. return 0;
  720. }
  721. static struct tda827x_config ads_duo_cfg = {
  722. .lna_gain = philips_tda827x_lna_gain,
  723. .init = ads_duo_tuner_init,
  724. .sleep = ads_duo_tuner_sleep
  725. };
  726. static struct tda1004x_config ads_tech_duo_config = {
  727. .demod_address = 0x08,
  728. .invert = 1,
  729. .invert_oclk = 0,
  730. .xtal_freq = TDA10046_XTAL_16M,
  731. .agc_config = TDA10046_AGC_TDA827X,
  732. .gpio_config = TDA10046_GP00_I,
  733. .if_freq = TDA10046_FREQ_045,
  734. .tuner_address = 0x61,
  735. .request_firmware = philips_tda1004x_request_firmware
  736. };
  737. /* ==================================================================
  738. * tda10086 based DVB-S cards, helper functions
  739. */
  740. static struct tda10086_config flydvbs = {
  741. .demod_address = 0x0e,
  742. .invert = 0,
  743. .diseqc_tone = 0,
  744. };
  745. /* ------------------------------------------------------------------
  746. * special case: lnb supply is connected to the gated i2c
  747. */
  748. static int md8800_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
  749. {
  750. int res = -EIO;
  751. struct saa7134_dev *dev = fe->dvb->priv;
  752. if (fe->ops.i2c_gate_ctrl) {
  753. fe->ops.i2c_gate_ctrl(fe, 1);
  754. if (dev->original_set_voltage)
  755. res = dev->original_set_voltage(fe, voltage);
  756. fe->ops.i2c_gate_ctrl(fe, 0);
  757. }
  758. return res;
  759. };
  760. static int md8800_set_high_voltage(struct dvb_frontend *fe, long arg)
  761. {
  762. int res = -EIO;
  763. struct saa7134_dev *dev = fe->dvb->priv;
  764. if (fe->ops.i2c_gate_ctrl) {
  765. fe->ops.i2c_gate_ctrl(fe, 1);
  766. if (dev->original_set_high_voltage)
  767. res = dev->original_set_high_voltage(fe, arg);
  768. fe->ops.i2c_gate_ctrl(fe, 0);
  769. }
  770. return res;
  771. };
  772. static int md8800_set_voltage2(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
  773. {
  774. struct saa7134_dev *dev = fe->dvb->priv;
  775. u8 wbuf[2] = { 0x1f, 00 };
  776. u8 rbuf;
  777. struct i2c_msg msg[] = { { .addr = 0x08, .flags = 0, .buf = wbuf, .len = 1 },
  778. { .addr = 0x08, .flags = I2C_M_RD, .buf = &rbuf, .len = 1 } };
  779. if (i2c_transfer(&dev->i2c_adap, msg, 2) != 2)
  780. return -EIO;
  781. /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
  782. if (voltage == SEC_VOLTAGE_18)
  783. wbuf[1] = rbuf | 0x10;
  784. else
  785. wbuf[1] = rbuf & 0xef;
  786. msg[0].len = 2;
  787. i2c_transfer(&dev->i2c_adap, msg, 1);
  788. return 0;
  789. }
  790. static int md8800_set_high_voltage2(struct dvb_frontend *fe, long arg)
  791. {
  792. struct saa7134_dev *dev = fe->dvb->priv;
  793. wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__);
  794. return -EIO;
  795. }
  796. /* ==================================================================
  797. * nxt200x based ATSC cards, helper functions
  798. */
  799. static struct nxt200x_config avertvhda180 = {
  800. .demod_address = 0x0a,
  801. };
  802. static struct nxt200x_config kworldatsc110 = {
  803. .demod_address = 0x0a,
  804. };
  805. /* ==================================================================
  806. * Core code
  807. */
  808. static int dvb_init(struct saa7134_dev *dev)
  809. {
  810. int ret;
  811. int attach_xc3028 = 0;
  812. /* init struct videobuf_dvb */
  813. dev->ts.nr_bufs = 32;
  814. dev->ts.nr_packets = 32*4;
  815. dev->dvb.name = dev->name;
  816. videobuf_queue_sg_init(&dev->dvb.dvbq, &saa7134_ts_qops,
  817. &dev->pci->dev, &dev->slock,
  818. V4L2_BUF_TYPE_VIDEO_CAPTURE,
  819. V4L2_FIELD_ALTERNATE,
  820. sizeof(struct saa7134_buf),
  821. dev);
  822. switch (dev->board) {
  823. case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
  824. dprintk("pinnacle 300i dvb setup\n");
  825. dev->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
  826. &dev->i2c_adap);
  827. if (dev->dvb.frontend) {
  828. dev->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
  829. }
  830. break;
  831. case SAA7134_BOARD_AVERMEDIA_777:
  832. case SAA7134_BOARD_AVERMEDIA_A16AR:
  833. dprintk("avertv 777 dvb setup\n");
  834. dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
  835. &dev->i2c_adap);
  836. if (dev->dvb.frontend) {
  837. dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
  838. NULL, DVB_PLL_PHILIPS_TD1316);
  839. }
  840. break;
  841. case SAA7134_BOARD_MD7134:
  842. dev->dvb.frontend = dvb_attach(tda10046_attach,
  843. &medion_cardbus,
  844. &dev->i2c_adap);
  845. if (dev->dvb.frontend) {
  846. dvb_attach(dvb_pll_attach, dev->dvb.frontend, medion_cardbus.tuner_address,
  847. &dev->i2c_adap, DVB_PLL_FMD1216ME);
  848. }
  849. break;
  850. case SAA7134_BOARD_PHILIPS_TOUGH:
  851. dev->dvb.frontend = dvb_attach(tda10046_attach,
  852. &philips_tu1216_60_config,
  853. &dev->i2c_adap);
  854. if (dev->dvb.frontend) {
  855. dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
  856. dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
  857. }
  858. break;
  859. case SAA7134_BOARD_FLYDVBTDUO:
  860. case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
  861. configure_tda827x_fe(dev, &tda827x_lifeview_config);
  862. break;
  863. case SAA7134_BOARD_PHILIPS_EUROPA:
  864. case SAA7134_BOARD_VIDEOMATE_DVBT_300:
  865. dev->dvb.frontend = dvb_attach(tda10046_attach,
  866. &philips_europa_config,
  867. &dev->i2c_adap);
  868. if (dev->dvb.frontend) {
  869. dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
  870. dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
  871. dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
  872. dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
  873. dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
  874. }
  875. break;
  876. case SAA7134_BOARD_VIDEOMATE_DVBT_200:
  877. dev->dvb.frontend = dvb_attach(tda10046_attach,
  878. &philips_tu1216_61_config,
  879. &dev->i2c_adap);
  880. if (dev->dvb.frontend) {
  881. dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
  882. dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
  883. }
  884. break;
  885. case SAA7134_BOARD_KWORLD_DVBT_210:
  886. configure_tda827x_fe(dev, &kworld_dvb_t_210_config);
  887. break;
  888. case SAA7134_BOARD_PHILIPS_TIGER:
  889. configure_tda827x_fe(dev, &philips_tiger_config);
  890. break;
  891. case SAA7134_BOARD_PINNACLE_PCTV_310i:
  892. configure_tda827x_fe(dev, &pinnacle_pctv_310i_config);
  893. break;
  894. case SAA7134_BOARD_HAUPPAUGE_HVR1110:
  895. configure_tda827x_fe(dev, &hauppauge_hvr_1110_config);
  896. break;
  897. case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
  898. configure_tda827x_fe(dev, &asus_p7131_dual_config);
  899. break;
  900. case SAA7134_BOARD_FLYDVBT_LR301:
  901. configure_tda827x_fe(dev, &tda827x_lifeview_config);
  902. break;
  903. case SAA7134_BOARD_FLYDVB_TRIO:
  904. if(! use_frontend) { /* terrestrial */
  905. configure_tda827x_fe(dev, &lifeview_trio_config);
  906. } else { /* satellite */
  907. dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
  908. if (dev->dvb.frontend) {
  909. if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63,
  910. &dev->i2c_adap, 0) == NULL) {
  911. wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__);
  912. }
  913. if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap,
  914. 0x08, 0, 0) == NULL) {
  915. wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__);
  916. }
  917. }
  918. }
  919. break;
  920. case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
  921. case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
  922. dev->dvb.frontend = dvb_attach(tda10046_attach,
  923. &ads_tech_duo_config,
  924. &dev->i2c_adap);
  925. if (dev->dvb.frontend) {
  926. if (dvb_attach(tda827x_attach,dev->dvb.frontend,
  927. ads_tech_duo_config.tuner_address,
  928. &dev->i2c_adap,&ads_duo_cfg) == NULL) {
  929. wprintk("no tda827x tuner found at addr: %02x\n",
  930. ads_tech_duo_config.tuner_address);
  931. }
  932. }
  933. break;
  934. case SAA7134_BOARD_TEVION_DVBT_220RF:
  935. configure_tda827x_fe(dev, &tevion_dvbt220rf_config);
  936. break;
  937. case SAA7134_BOARD_MEDION_MD8800_QUADRO:
  938. if (!use_frontend) { /* terrestrial */
  939. configure_tda827x_fe(dev, &md8800_dvbt_config);
  940. } else { /* satellite */
  941. dev->dvb.frontend = dvb_attach(tda10086_attach,
  942. &flydvbs, &dev->i2c_adap);
  943. if (dev->dvb.frontend) {
  944. struct dvb_frontend *fe = dev->dvb.frontend;
  945. u8 dev_id = dev->eedata[2];
  946. u8 data = 0xc4;
  947. struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};
  948. if (dvb_attach(tda826x_attach, dev->dvb.frontend,
  949. 0x60, &dev->i2c_adap, 0) == NULL)
  950. wprintk("%s: Medion Quadro, no tda826x "
  951. "found !\n", __func__);
  952. if (dev_id != 0x08) {
  953. /* we need to open the i2c gate (we know it exists) */
  954. fe->ops.i2c_gate_ctrl(fe, 1);
  955. if (dvb_attach(isl6405_attach, fe,
  956. &dev->i2c_adap, 0x08, 0, 0) == NULL)
  957. wprintk("%s: Medion Quadro, no ISL6405 "
  958. "found !\n", __func__);
  959. /* fire up the 2nd section of the LNB supply since we can't do
  960. this from the other section */
  961. msg.buf = &data;
  962. i2c_transfer(&dev->i2c_adap, &msg, 1);
  963. fe->ops.i2c_gate_ctrl(fe, 0);
  964. dev->original_set_voltage = fe->ops.set_voltage;
  965. fe->ops.set_voltage = md8800_set_voltage;
  966. dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
  967. fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
  968. } else {
  969. fe->ops.set_voltage = md8800_set_voltage2;
  970. fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage2;
  971. }
  972. }
  973. }
  974. break;
  975. case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
  976. dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
  977. &dev->i2c_adap);
  978. if (dev->dvb.frontend) {
  979. dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
  980. NULL, DVB_PLL_TDHU2);
  981. }
  982. break;
  983. case SAA7134_BOARD_KWORLD_ATSC110:
  984. dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
  985. &dev->i2c_adap);
  986. if (dev->dvb.frontend) {
  987. dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
  988. NULL, DVB_PLL_TUV1236D);
  989. }
  990. break;
  991. case SAA7134_BOARD_FLYDVBS_LR300:
  992. dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
  993. &dev->i2c_adap);
  994. if (dev->dvb.frontend) {
  995. if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
  996. &dev->i2c_adap, 0) == NULL) {
  997. wprintk("%s: No tda826x found!\n", __func__);
  998. }
  999. if (dvb_attach(isl6421_attach, dev->dvb.frontend,
  1000. &dev->i2c_adap, 0x08, 0, 0) == NULL) {
  1001. wprintk("%s: No ISL6421 found!\n", __func__);
  1002. }
  1003. }
  1004. break;
  1005. case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
  1006. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1007. &medion_cardbus,
  1008. &dev->i2c_adap);
  1009. if (dev->dvb.frontend) {
  1010. dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
  1011. dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
  1012. dvb_attach(dvb_pll_attach, dev->dvb.frontend, medion_cardbus.tuner_address,
  1013. &dev->i2c_adap, DVB_PLL_FMD1216ME);
  1014. }
  1015. break;
  1016. case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
  1017. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1018. &philips_europa_config,
  1019. &dev->i2c_adap);
  1020. if (dev->dvb.frontend) {
  1021. dev->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
  1022. dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
  1023. }
  1024. break;
  1025. case SAA7134_BOARD_CINERGY_HT_PCMCIA:
  1026. configure_tda827x_fe(dev, &cinergy_ht_config);
  1027. break;
  1028. case SAA7134_BOARD_CINERGY_HT_PCI:
  1029. configure_tda827x_fe(dev, &cinergy_ht_pci_config);
  1030. break;
  1031. case SAA7134_BOARD_PHILIPS_TIGER_S:
  1032. configure_tda827x_fe(dev, &philips_tiger_s_config);
  1033. break;
  1034. case SAA7134_BOARD_ASUS_P7131_4871:
  1035. configure_tda827x_fe(dev, &asus_p7131_4871_config);
  1036. break;
  1037. case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
  1038. configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config);
  1039. break;
  1040. case SAA7134_BOARD_AVERMEDIA_SUPER_007:
  1041. configure_tda827x_fe(dev, &avermedia_super_007_config);
  1042. break;
  1043. case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
  1044. configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config);
  1045. break;
  1046. case SAA7134_BOARD_PHILIPS_SNAKE:
  1047. dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
  1048. &dev->i2c_adap);
  1049. if (dev->dvb.frontend) {
  1050. if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
  1051. &dev->i2c_adap, 0) == NULL)
  1052. wprintk("%s: No tda826x found!\n", __func__);
  1053. if (dvb_attach(lnbp21_attach, dev->dvb.frontend,
  1054. &dev->i2c_adap, 0, 0) == NULL)
  1055. wprintk("%s: No lnbp21 found!\n", __func__);
  1056. }
  1057. break;
  1058. case SAA7134_BOARD_CREATIX_CTX953:
  1059. configure_tda827x_fe(dev, &md8800_dvbt_config);
  1060. break;
  1061. case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
  1062. configure_tda827x_fe(dev, &philips_tiger_s_config);
  1063. break;
  1064. case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
  1065. dev->dvb.frontend = dvb_attach(mt352_attach,
  1066. &avermedia_e506r_mt352_dev,
  1067. &dev->i2c_adap);
  1068. attach_xc3028 = 1;
  1069. break;
  1070. case SAA7134_BOARD_MD7134_BRIDGE_2:
  1071. dev->dvb.frontend = dvb_attach(tda10086_attach,
  1072. &flydvbs, &dev->i2c_adap);
  1073. if (dev->dvb.frontend) {
  1074. struct dvb_frontend *fe;
  1075. if (dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
  1076. &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL)
  1077. wprintk("%s: MD7134 DVB-S, no SD1878 "
  1078. "found !\n", __func__);
  1079. /* we need to open the i2c gate (we know it exists) */
  1080. fe = dev->dvb.frontend;
  1081. fe->ops.i2c_gate_ctrl(fe, 1);
  1082. if (dvb_attach(isl6405_attach, fe,
  1083. &dev->i2c_adap, 0x08, 0, 0) == NULL)
  1084. wprintk("%s: MD7134 DVB-S, no ISL6405 "
  1085. "found !\n", __func__);
  1086. fe->ops.i2c_gate_ctrl(fe, 0);
  1087. dev->original_set_voltage = fe->ops.set_voltage;
  1088. fe->ops.set_voltage = md8800_set_voltage;
  1089. dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
  1090. fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
  1091. }
  1092. break;
  1093. default:
  1094. wprintk("Huh? unknown DVB card?\n");
  1095. break;
  1096. }
  1097. if (attach_xc3028) {
  1098. struct dvb_frontend *fe;
  1099. struct xc2028_config cfg = {
  1100. .i2c_adap = &dev->i2c_adap,
  1101. .i2c_addr = 0x61,
  1102. .video_dev = dev->i2c_adap.algo_data,
  1103. };
  1104. fe = dvb_attach(xc2028_attach, dev->dvb.frontend, &cfg);
  1105. if (!fe) {
  1106. printk(KERN_ERR "%s/2: xc3028 attach failed\n",
  1107. dev->name);
  1108. dvb_frontend_detach(dev->dvb.frontend);
  1109. dvb_unregister_frontend(dev->dvb.frontend);
  1110. dev->dvb.frontend = NULL;
  1111. return -1;
  1112. }
  1113. }
  1114. if (NULL == dev->dvb.frontend) {
  1115. printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
  1116. return -1;
  1117. }
  1118. /* register everything else */
  1119. ret = videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev);
  1120. /* this sequence is necessary to make the tda1004x load its firmware
  1121. * and to enter analog mode of hybrid boards
  1122. */
  1123. if (!ret) {
  1124. if (dev->dvb.frontend->ops.init)
  1125. dev->dvb.frontend->ops.init(dev->dvb.frontend);
  1126. if (dev->dvb.frontend->ops.sleep)
  1127. dev->dvb.frontend->ops.sleep(dev->dvb.frontend);
  1128. if (dev->dvb.frontend->ops.tuner_ops.sleep)
  1129. dev->dvb.frontend->ops.tuner_ops.sleep(dev->dvb.frontend);
  1130. }
  1131. return ret;
  1132. }
  1133. static int dvb_fini(struct saa7134_dev *dev)
  1134. {
  1135. /* FIXME: I suspect that this code is bogus, since the entry for
  1136. Pinnacle 300I DVB-T PAL already defines the proper init to allow
  1137. the detection of mt2032 (TDA9887_PORT2_INACTIVE)
  1138. */
  1139. if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
  1140. struct v4l2_priv_tun_config tda9887_cfg;
  1141. static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
  1142. tda9887_cfg.tuner = TUNER_TDA9887;
  1143. tda9887_cfg.priv = &on;
  1144. /* otherwise we don't detect the tuner on next insmod */
  1145. saa7134_i2c_call_clients(dev, TUNER_SET_CONFIG, &tda9887_cfg);
  1146. } else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) {
  1147. if ((dev->eedata[2] != 0x08) && use_frontend) {
  1148. /* turn off the 2nd lnb supply */
  1149. u8 data = 0x80;
  1150. struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1};
  1151. struct dvb_frontend *fe;
  1152. fe = dev->dvb.frontend;
  1153. if (fe->ops.i2c_gate_ctrl) {
  1154. fe->ops.i2c_gate_ctrl(fe, 1);
  1155. i2c_transfer(&dev->i2c_adap, &msg, 1);
  1156. fe->ops.i2c_gate_ctrl(fe, 0);
  1157. }
  1158. }
  1159. }
  1160. videobuf_dvb_unregister(&dev->dvb);
  1161. return 0;
  1162. }
  1163. static struct saa7134_mpeg_ops dvb_ops = {
  1164. .type = SAA7134_MPEG_DVB,
  1165. .init = dvb_init,
  1166. .fini = dvb_fini,
  1167. };
  1168. static int __init dvb_register(void)
  1169. {
  1170. return saa7134_ts_register(&dvb_ops);
  1171. }
  1172. static void __exit dvb_unregister(void)
  1173. {
  1174. saa7134_ts_unregister(&dvb_ops);
  1175. }
  1176. module_init(dvb_register);
  1177. module_exit(dvb_unregister);
  1178. /* ------------------------------------------------------------------ */
  1179. /*
  1180. * Local variables:
  1181. * c-basic-offset: 8
  1182. * End:
  1183. */