saa7134-dvb.c 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503
  1. /*
  2. *
  3. * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
  4. *
  5. * Extended 3 / 2005 by Hartmut Hackmann to support various
  6. * cards with the tda10046 DVB-T channel decoder
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21. */
  22. #include <linux/init.h>
  23. #include <linux/list.h>
  24. #include <linux/module.h>
  25. #include <linux/kernel.h>
  26. #include <linux/slab.h>
  27. #include <linux/delay.h>
  28. #include <linux/kthread.h>
  29. #include <linux/suspend.h>
  30. #include "saa7134-reg.h"
  31. #include "saa7134.h"
  32. #include <media/v4l2-common.h>
  33. #include "dvb-pll.h"
  34. #include "mt352.h"
  35. #include "mt352_priv.h" /* FIXME */
  36. #include "tda1004x.h"
  37. #include "nxt200x.h"
  38. #include "tda10086.h"
  39. #include "tda826x.h"
  40. #include "isl6421.h"
  41. MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
  42. MODULE_LICENSE("GPL");
  43. static unsigned int antenna_pwr = 0;
  44. module_param(antenna_pwr, int, 0444);
  45. MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
  46. static int use_frontend = 0;
  47. module_param(use_frontend, int, 0644);
  48. MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
  49. /* ------------------------------------------------------------------ */
  50. static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
  51. {
  52. u32 ok;
  53. if (!on) {
  54. saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
  55. saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
  56. return 0;
  57. }
  58. saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
  59. saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
  60. udelay(10);
  61. saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28));
  62. saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
  63. udelay(10);
  64. saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
  65. udelay(10);
  66. ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
  67. printk("%s: %s %s\n", dev->name, __FUNCTION__,
  68. ok ? "on" : "off");
  69. if (!ok)
  70. saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
  71. return ok;
  72. }
  73. static int mt352_pinnacle_init(struct dvb_frontend* fe)
  74. {
  75. static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 };
  76. static u8 reset [] = { RESET, 0x80 };
  77. static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
  78. static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
  79. static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
  80. static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 };
  81. static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f };
  82. static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d };
  83. static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
  84. struct saa7134_dev *dev= fe->dvb->priv;
  85. printk("%s: %s called\n",dev->name,__FUNCTION__);
  86. mt352_write(fe, clock_config, sizeof(clock_config));
  87. udelay(200);
  88. mt352_write(fe, reset, sizeof(reset));
  89. mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
  90. mt352_write(fe, agc_cfg, sizeof(agc_cfg));
  91. mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
  92. mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
  93. mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
  94. mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
  95. mt352_write(fe, irq_cfg, sizeof(irq_cfg));
  96. return 0;
  97. }
  98. static int mt352_aver777_init(struct dvb_frontend* fe)
  99. {
  100. static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
  101. static u8 reset [] = { RESET, 0x80 };
  102. static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
  103. static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
  104. static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
  105. mt352_write(fe, clock_config, sizeof(clock_config));
  106. udelay(200);
  107. mt352_write(fe, reset, sizeof(reset));
  108. mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
  109. mt352_write(fe, agc_cfg, sizeof(agc_cfg));
  110. mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
  111. return 0;
  112. }
  113. static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
  114. struct dvb_frontend_parameters* params)
  115. {
  116. u8 off[] = { 0x00, 0xf1};
  117. u8 on[] = { 0x00, 0x71};
  118. struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
  119. struct saa7134_dev *dev = fe->dvb->priv;
  120. struct v4l2_frequency f;
  121. /* set frequency (mt2050) */
  122. f.tuner = 0;
  123. f.type = V4L2_TUNER_DIGITAL_TV;
  124. f.frequency = params->frequency / 1000 * 16 / 1000;
  125. if (fe->ops.i2c_gate_ctrl)
  126. fe->ops.i2c_gate_ctrl(fe, 1);
  127. i2c_transfer(&dev->i2c_adap, &msg, 1);
  128. saa7134_i2c_call_clients(dev,VIDIOC_S_FREQUENCY,&f);
  129. msg.buf = on;
  130. if (fe->ops.i2c_gate_ctrl)
  131. fe->ops.i2c_gate_ctrl(fe, 1);
  132. i2c_transfer(&dev->i2c_adap, &msg, 1);
  133. pinnacle_antenna_pwr(dev, antenna_pwr);
  134. /* mt352 setup */
  135. return mt352_pinnacle_init(fe);
  136. }
  137. static int mt352_aver777_tuner_calc_regs(struct dvb_frontend *fe, struct dvb_frontend_parameters *params, u8* pllbuf, int buf_len)
  138. {
  139. if (buf_len < 5)
  140. return -EINVAL;
  141. pllbuf[0] = 0x61;
  142. dvb_pll_configure(&dvb_pll_philips_td1316, pllbuf+1,
  143. params->frequency,
  144. params->u.ofdm.bandwidth);
  145. return 5;
  146. }
  147. static struct mt352_config pinnacle_300i = {
  148. .demod_address = 0x3c >> 1,
  149. .adc_clock = 20333,
  150. .if2 = 36150,
  151. .no_tuner = 1,
  152. .demod_init = mt352_pinnacle_init,
  153. };
  154. static struct mt352_config avermedia_777 = {
  155. .demod_address = 0xf,
  156. .demod_init = mt352_aver777_init,
  157. };
  158. /* ------------------------------------------------------------------ */
  159. static int philips_tda6651_pll_set(u8 addr, struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  160. {
  161. struct saa7134_dev *dev = fe->dvb->priv;
  162. u8 tuner_buf[4];
  163. struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
  164. sizeof(tuner_buf) };
  165. int tuner_frequency = 0;
  166. u8 band, cp, filter;
  167. /* determine charge pump */
  168. tuner_frequency = params->frequency + 36166000;
  169. if (tuner_frequency < 87000000)
  170. return -EINVAL;
  171. else if (tuner_frequency < 130000000)
  172. cp = 3;
  173. else if (tuner_frequency < 160000000)
  174. cp = 5;
  175. else if (tuner_frequency < 200000000)
  176. cp = 6;
  177. else if (tuner_frequency < 290000000)
  178. cp = 3;
  179. else if (tuner_frequency < 420000000)
  180. cp = 5;
  181. else if (tuner_frequency < 480000000)
  182. cp = 6;
  183. else if (tuner_frequency < 620000000)
  184. cp = 3;
  185. else if (tuner_frequency < 830000000)
  186. cp = 5;
  187. else if (tuner_frequency < 895000000)
  188. cp = 7;
  189. else
  190. return -EINVAL;
  191. /* determine band */
  192. if (params->frequency < 49000000)
  193. return -EINVAL;
  194. else if (params->frequency < 161000000)
  195. band = 1;
  196. else if (params->frequency < 444000000)
  197. band = 2;
  198. else if (params->frequency < 861000000)
  199. band = 4;
  200. else
  201. return -EINVAL;
  202. /* setup PLL filter */
  203. switch (params->u.ofdm.bandwidth) {
  204. case BANDWIDTH_6_MHZ:
  205. filter = 0;
  206. break;
  207. case BANDWIDTH_7_MHZ:
  208. filter = 0;
  209. break;
  210. case BANDWIDTH_8_MHZ:
  211. filter = 1;
  212. break;
  213. default:
  214. return -EINVAL;
  215. }
  216. /* calculate divisor
  217. * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
  218. */
  219. tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
  220. /* setup tuner buffer */
  221. tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
  222. tuner_buf[1] = tuner_frequency & 0xff;
  223. tuner_buf[2] = 0xca;
  224. tuner_buf[3] = (cp << 5) | (filter << 3) | band;
  225. if (fe->ops.i2c_gate_ctrl)
  226. fe->ops.i2c_gate_ctrl(fe, 1);
  227. if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
  228. return -EIO;
  229. msleep(1);
  230. return 0;
  231. }
  232. static int philips_tda6651_pll_init(u8 addr, struct dvb_frontend *fe)
  233. {
  234. struct saa7134_dev *dev = fe->dvb->priv;
  235. static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
  236. struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
  237. /* setup PLL configuration */
  238. if (fe->ops.i2c_gate_ctrl)
  239. fe->ops.i2c_gate_ctrl(fe, 1);
  240. if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
  241. return -EIO;
  242. msleep(1);
  243. return 0;
  244. }
  245. /* ------------------------------------------------------------------ */
  246. static int philips_tu1216_tuner_60_init(struct dvb_frontend *fe)
  247. {
  248. return philips_tda6651_pll_init(0x60, fe);
  249. }
  250. static int philips_tu1216_tuner_60_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  251. {
  252. return philips_tda6651_pll_set(0x60, fe, params);
  253. }
  254. static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
  255. const struct firmware **fw, char *name)
  256. {
  257. struct saa7134_dev *dev = fe->dvb->priv;
  258. return request_firmware(fw, name, &dev->pci->dev);
  259. }
  260. static struct tda1004x_config philips_tu1216_60_config = {
  261. .demod_address = 0x8,
  262. .invert = 1,
  263. .invert_oclk = 0,
  264. .xtal_freq = TDA10046_XTAL_4M,
  265. .agc_config = TDA10046_AGC_DEFAULT,
  266. .if_freq = TDA10046_FREQ_3617,
  267. .request_firmware = philips_tda1004x_request_firmware,
  268. };
  269. /* ------------------------------------------------------------------ */
  270. static int philips_tu1216_tuner_61_init(struct dvb_frontend *fe)
  271. {
  272. return philips_tda6651_pll_init(0x61, fe);
  273. }
  274. static int philips_tu1216_tuner_61_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  275. {
  276. return philips_tda6651_pll_set(0x61, fe, params);
  277. }
  278. static struct tda1004x_config philips_tu1216_61_config = {
  279. .demod_address = 0x8,
  280. .invert = 1,
  281. .invert_oclk = 0,
  282. .xtal_freq = TDA10046_XTAL_4M,
  283. .agc_config = TDA10046_AGC_DEFAULT,
  284. .if_freq = TDA10046_FREQ_3617,
  285. .request_firmware = philips_tda1004x_request_firmware,
  286. };
  287. /* ------------------------------------------------------------------ */
  288. static int philips_td1316_tuner_init(struct dvb_frontend *fe)
  289. {
  290. struct saa7134_dev *dev = fe->dvb->priv;
  291. static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
  292. struct i2c_msg init_msg = {.addr = 0x61,.flags = 0,.buf = msg,.len = sizeof(msg) };
  293. /* setup PLL configuration */
  294. if (fe->ops.i2c_gate_ctrl)
  295. fe->ops.i2c_gate_ctrl(fe, 1);
  296. if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
  297. return -EIO;
  298. if (fe->ops.i2c_gate_ctrl)
  299. fe->ops.i2c_gate_ctrl(fe, 0);
  300. return 0;
  301. }
  302. static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  303. {
  304. return philips_tda6651_pll_set(0x61, fe, params);
  305. }
  306. static int philips_europa_tuner_init(struct dvb_frontend *fe)
  307. {
  308. struct saa7134_dev *dev = fe->dvb->priv;
  309. static u8 msg[] = { 0x00, 0x40};
  310. struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
  311. if (philips_td1316_tuner_init(fe))
  312. return -EIO;
  313. msleep(1);
  314. if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
  315. return -EIO;
  316. return 0;
  317. }
  318. static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
  319. {
  320. struct saa7134_dev *dev = fe->dvb->priv;
  321. /* this message actually turns the tuner back to analog mode */
  322. static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
  323. struct i2c_msg analog_msg = {.addr = 0x61,.flags = 0,.buf = msg,.len = sizeof(msg) };
  324. i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
  325. msleep(1);
  326. /* switch the board to analog mode */
  327. analog_msg.addr = 0x43;
  328. analog_msg.len = 0x02;
  329. msg[0] = 0x00;
  330. msg[1] = 0x14;
  331. if (fe->ops.i2c_gate_ctrl)
  332. fe->ops.i2c_gate_ctrl(fe, 1);
  333. i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
  334. return 0;
  335. }
  336. static int philips_europa_demod_sleep(struct dvb_frontend *fe)
  337. {
  338. struct saa7134_dev *dev = fe->dvb->priv;
  339. if (dev->original_demod_sleep)
  340. dev->original_demod_sleep(fe);
  341. fe->ops.i2c_gate_ctrl(fe, 1);
  342. return 0;
  343. }
  344. static struct tda1004x_config philips_europa_config = {
  345. .demod_address = 0x8,
  346. .invert = 0,
  347. .invert_oclk = 0,
  348. .xtal_freq = TDA10046_XTAL_4M,
  349. .agc_config = TDA10046_AGC_IFO_AUTO_POS,
  350. .if_freq = TDA10046_FREQ_052,
  351. .request_firmware = philips_tda1004x_request_firmware,
  352. };
  353. /* ------------------------------------------------------------------ */
  354. static int philips_fmd1216_tuner_init(struct dvb_frontend *fe)
  355. {
  356. struct saa7134_dev *dev = fe->dvb->priv;
  357. /* this message is to set up ATC and ALC */
  358. static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0xa0 };
  359. struct i2c_msg tuner_msg = {.addr = 0x61,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) };
  360. if (fe->ops.i2c_gate_ctrl)
  361. fe->ops.i2c_gate_ctrl(fe, 1);
  362. if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
  363. return -EIO;
  364. msleep(1);
  365. return 0;
  366. }
  367. static int philips_fmd1216_tuner_sleep(struct dvb_frontend *fe)
  368. {
  369. struct saa7134_dev *dev = fe->dvb->priv;
  370. /* this message actually turns the tuner back to analog mode */
  371. static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0x60 };
  372. struct i2c_msg tuner_msg = {.addr = 0x61,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) };
  373. if (fe->ops.i2c_gate_ctrl)
  374. fe->ops.i2c_gate_ctrl(fe, 1);
  375. i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
  376. msleep(1);
  377. fmd1216_init[2] = 0x86;
  378. fmd1216_init[3] = 0x54;
  379. if (fe->ops.i2c_gate_ctrl)
  380. fe->ops.i2c_gate_ctrl(fe, 1);
  381. i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
  382. msleep(1);
  383. return 0;
  384. }
  385. static int philips_fmd1216_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  386. {
  387. struct saa7134_dev *dev = fe->dvb->priv;
  388. u8 tuner_buf[4];
  389. struct i2c_msg tuner_msg = {.addr = 0x61,.flags = 0,.buf = tuner_buf,.len =
  390. sizeof(tuner_buf) };
  391. int tuner_frequency = 0;
  392. int divider = 0;
  393. u8 band, mode, cp;
  394. /* determine charge pump */
  395. tuner_frequency = params->frequency + 36130000;
  396. if (tuner_frequency < 87000000)
  397. return -EINVAL;
  398. /* low band */
  399. else if (tuner_frequency < 180000000) {
  400. band = 1;
  401. mode = 7;
  402. cp = 0;
  403. } else if (tuner_frequency < 195000000) {
  404. band = 1;
  405. mode = 6;
  406. cp = 1;
  407. /* mid band */
  408. } else if (tuner_frequency < 366000000) {
  409. if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
  410. band = 10;
  411. } else {
  412. band = 2;
  413. }
  414. mode = 7;
  415. cp = 0;
  416. } else if (tuner_frequency < 478000000) {
  417. if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
  418. band = 10;
  419. } else {
  420. band = 2;
  421. }
  422. mode = 6;
  423. cp = 1;
  424. /* high band */
  425. } else if (tuner_frequency < 662000000) {
  426. if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
  427. band = 12;
  428. } else {
  429. band = 4;
  430. }
  431. mode = 7;
  432. cp = 0;
  433. } else if (tuner_frequency < 840000000) {
  434. if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
  435. band = 12;
  436. } else {
  437. band = 4;
  438. }
  439. mode = 6;
  440. cp = 1;
  441. } else {
  442. if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
  443. band = 12;
  444. } else {
  445. band = 4;
  446. }
  447. mode = 7;
  448. cp = 1;
  449. }
  450. /* calculate divisor */
  451. /* ((36166000 + Finput) / 166666) rounded! */
  452. divider = (tuner_frequency + 83333) / 166667;
  453. /* setup tuner buffer */
  454. tuner_buf[0] = (divider >> 8) & 0x7f;
  455. tuner_buf[1] = divider & 0xff;
  456. tuner_buf[2] = 0x80 | (cp << 6) | (mode << 3) | 4;
  457. tuner_buf[3] = 0x40 | band;
  458. if (fe->ops.i2c_gate_ctrl)
  459. fe->ops.i2c_gate_ctrl(fe, 1);
  460. if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
  461. return -EIO;
  462. return 0;
  463. }
  464. static struct tda1004x_config medion_cardbus = {
  465. .demod_address = 0x08,
  466. .invert = 1,
  467. .invert_oclk = 0,
  468. .xtal_freq = TDA10046_XTAL_16M,
  469. .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
  470. .if_freq = TDA10046_FREQ_3613,
  471. .request_firmware = philips_tda1004x_request_firmware,
  472. };
  473. /* ------------------------------------------------------------------ */
  474. struct tda827x_data {
  475. u32 lomax;
  476. u8 spd;
  477. u8 bs;
  478. u8 bp;
  479. u8 cp;
  480. u8 gc3;
  481. u8 div1p5;
  482. };
  483. static struct tda827x_data tda827x_dvbt[] = {
  484. { .lomax = 62000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 1},
  485. { .lomax = 66000000, .spd = 3, .bs = 3, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 1},
  486. { .lomax = 76000000, .spd = 3, .bs = 1, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 0},
  487. { .lomax = 84000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 0},
  488. { .lomax = 93000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 1, .div1p5 = 0},
  489. { .lomax = 98000000, .spd = 3, .bs = 3, .bp = 0, .cp = 0, .gc3 = 1, .div1p5 = 0},
  490. { .lomax = 109000000, .spd = 3, .bs = 3, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0},
  491. { .lomax = 123000000, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 1},
  492. { .lomax = 133000000, .spd = 2, .bs = 3, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 1},
  493. { .lomax = 151000000, .spd = 2, .bs = 1, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0},
  494. { .lomax = 154000000, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0},
  495. { .lomax = 181000000, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 0, .div1p5 = 0},
  496. { .lomax = 185000000, .spd = 2, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
  497. { .lomax = 217000000, .spd = 2, .bs = 3, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
  498. { .lomax = 244000000, .spd = 1, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 1},
  499. { .lomax = 265000000, .spd = 1, .bs = 3, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 1},
  500. { .lomax = 302000000, .spd = 1, .bs = 1, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
  501. { .lomax = 324000000, .spd = 1, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
  502. { .lomax = 370000000, .spd = 1, .bs = 2, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0},
  503. { .lomax = 454000000, .spd = 1, .bs = 3, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0},
  504. { .lomax = 493000000, .spd = 0, .bs = 2, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 1},
  505. { .lomax = 530000000, .spd = 0, .bs = 3, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 1},
  506. { .lomax = 554000000, .spd = 0, .bs = 1, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0},
  507. { .lomax = 604000000, .spd = 0, .bs = 1, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0},
  508. { .lomax = 696000000, .spd = 0, .bs = 2, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0},
  509. { .lomax = 740000000, .spd = 0, .bs = 2, .bp = 4, .cp = 1, .gc3 = 0, .div1p5 = 0},
  510. { .lomax = 820000000, .spd = 0, .bs = 3, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0},
  511. { .lomax = 865000000, .spd = 0, .bs = 3, .bp = 4, .cp = 1, .gc3 = 0, .div1p5 = 0},
  512. { .lomax = 0, .spd = 0, .bs = 0, .bp = 0, .cp = 0, .gc3 = 0, .div1p5 = 0}
  513. };
  514. static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
  515. {
  516. return 0;
  517. }
  518. static int philips_tda827x_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  519. {
  520. struct saa7134_dev *dev = fe->dvb->priv;
  521. u8 tuner_buf[14];
  522. struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tuner_buf,
  523. .len = sizeof(tuner_buf) };
  524. int i, tuner_freq, if_freq;
  525. u32 N;
  526. switch (params->u.ofdm.bandwidth) {
  527. case BANDWIDTH_6_MHZ:
  528. if_freq = 4000000;
  529. break;
  530. case BANDWIDTH_7_MHZ:
  531. if_freq = 4500000;
  532. break;
  533. default: /* 8 MHz or Auto */
  534. if_freq = 5000000;
  535. break;
  536. }
  537. tuner_freq = params->frequency + if_freq;
  538. i = 0;
  539. while (tda827x_dvbt[i].lomax < tuner_freq) {
  540. if(tda827x_dvbt[i + 1].lomax == 0)
  541. break;
  542. i++;
  543. }
  544. N = ((tuner_freq + 125000) / 250000) << (tda827x_dvbt[i].spd + 2);
  545. tuner_buf[0] = 0;
  546. tuner_buf[1] = (N>>8) | 0x40;
  547. tuner_buf[2] = N & 0xff;
  548. tuner_buf[3] = 0;
  549. tuner_buf[4] = 0x52;
  550. tuner_buf[5] = (tda827x_dvbt[i].spd << 6) + (tda827x_dvbt[i].div1p5 << 5) +
  551. (tda827x_dvbt[i].bs << 3) + tda827x_dvbt[i].bp;
  552. tuner_buf[6] = (tda827x_dvbt[i].gc3 << 4) + 0x8f;
  553. tuner_buf[7] = 0xbf;
  554. tuner_buf[8] = 0x2a;
  555. tuner_buf[9] = 0x05;
  556. tuner_buf[10] = 0xff;
  557. tuner_buf[11] = 0x00;
  558. tuner_buf[12] = 0x00;
  559. tuner_buf[13] = 0x40;
  560. tuner_msg.len = 14;
  561. if (fe->ops.i2c_gate_ctrl)
  562. fe->ops.i2c_gate_ctrl(fe, 1);
  563. if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
  564. return -EIO;
  565. msleep(500);
  566. /* correct CP value */
  567. tuner_buf[0] = 0x30;
  568. tuner_buf[1] = 0x50 + tda827x_dvbt[i].cp;
  569. tuner_msg.len = 2;
  570. if (fe->ops.i2c_gate_ctrl)
  571. fe->ops.i2c_gate_ctrl(fe, 1);
  572. i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
  573. return 0;
  574. }
  575. static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
  576. {
  577. struct saa7134_dev *dev = fe->dvb->priv;
  578. static u8 tda827x_sleep[] = { 0x30, 0xd0};
  579. struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tda827x_sleep,
  580. .len = sizeof(tda827x_sleep) };
  581. if (fe->ops.i2c_gate_ctrl)
  582. fe->ops.i2c_gate_ctrl(fe, 1);
  583. i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
  584. return 0;
  585. }
  586. static struct tda1004x_config tda827x_lifeview_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. .request_firmware = philips_tda1004x_request_firmware,
  595. };
  596. /* ------------------------------------------------------------------ */
  597. struct tda827xa_data {
  598. u32 lomax;
  599. u8 svco;
  600. u8 spd;
  601. u8 scr;
  602. u8 sbs;
  603. u8 gc3;
  604. };
  605. static struct tda827xa_data tda827xa_dvbt[] = {
  606. { .lomax = 56875000, .svco = 3, .spd = 4, .scr = 0, .sbs = 0, .gc3 = 1},
  607. { .lomax = 67250000, .svco = 0, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 1},
  608. { .lomax = 81250000, .svco = 1, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 1},
  609. { .lomax = 97500000, .svco = 2, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 1},
  610. { .lomax = 113750000, .svco = 3, .spd = 3, .scr = 0, .sbs = 1, .gc3 = 1},
  611. { .lomax = 134500000, .svco = 0, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
  612. { .lomax = 154000000, .svco = 1, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
  613. { .lomax = 162500000, .svco = 1, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
  614. { .lomax = 183000000, .svco = 2, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
  615. { .lomax = 195000000, .svco = 2, .spd = 2, .scr = 0, .sbs = 2, .gc3 = 1},
  616. { .lomax = 227500000, .svco = 3, .spd = 2, .scr = 0, .sbs = 2, .gc3 = 1},
  617. { .lomax = 269000000, .svco = 0, .spd = 1, .scr = 0, .sbs = 2, .gc3 = 1},
  618. { .lomax = 290000000, .svco = 1, .spd = 1, .scr = 0, .sbs = 2, .gc3 = 1},
  619. { .lomax = 325000000, .svco = 1, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 1},
  620. { .lomax = 390000000, .svco = 2, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 1},
  621. { .lomax = 455000000, .svco = 3, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 1},
  622. { .lomax = 520000000, .svco = 0, .spd = 0, .scr = 0, .sbs = 3, .gc3 = 1},
  623. { .lomax = 538000000, .svco = 0, .spd = 0, .scr = 1, .sbs = 3, .gc3 = 1},
  624. { .lomax = 550000000, .svco = 1, .spd = 0, .scr = 0, .sbs = 3, .gc3 = 1},
  625. { .lomax = 620000000, .svco = 1, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0},
  626. { .lomax = 650000000, .svco = 1, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0},
  627. { .lomax = 700000000, .svco = 2, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0},
  628. { .lomax = 780000000, .svco = 2, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0},
  629. { .lomax = 820000000, .svco = 3, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0},
  630. { .lomax = 870000000, .svco = 3, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0},
  631. { .lomax = 911000000, .svco = 3, .spd = 0, .scr = 2, .sbs = 4, .gc3 = 0},
  632. { .lomax = 0, .svco = 0, .spd = 0, .scr = 0, .sbs = 0, .gc3 = 0}};
  633. static int philips_tda827xa_pll_set(u8 addr, struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  634. {
  635. struct saa7134_dev *dev = fe->dvb->priv;
  636. u8 tuner_buf[14];
  637. unsigned char reg2[2];
  638. struct i2c_msg msg = {.addr = addr,.flags = 0,.buf = tuner_buf};
  639. int i, tuner_freq, if_freq;
  640. u32 N;
  641. switch (params->u.ofdm.bandwidth) {
  642. case BANDWIDTH_6_MHZ:
  643. if_freq = 4000000;
  644. break;
  645. case BANDWIDTH_7_MHZ:
  646. if_freq = 4500000;
  647. break;
  648. default: /* 8 MHz or Auto */
  649. if_freq = 5000000;
  650. break;
  651. }
  652. tuner_freq = params->frequency + if_freq;
  653. i = 0;
  654. while (tda827xa_dvbt[i].lomax < tuner_freq) {
  655. if(tda827xa_dvbt[i + 1].lomax == 0)
  656. break;
  657. i++;
  658. }
  659. N = ((tuner_freq + 31250) / 62500) << tda827xa_dvbt[i].spd;
  660. tuner_buf[0] = 0; // subaddress
  661. tuner_buf[1] = N >> 8;
  662. tuner_buf[2] = N & 0xff;
  663. tuner_buf[3] = 0;
  664. tuner_buf[4] = 0x16;
  665. tuner_buf[5] = (tda827xa_dvbt[i].spd << 5) + (tda827xa_dvbt[i].svco << 3) +
  666. tda827xa_dvbt[i].sbs;
  667. tuner_buf[6] = 0x4b + (tda827xa_dvbt[i].gc3 << 4);
  668. tuner_buf[7] = 0x0c;
  669. tuner_buf[8] = 0x06;
  670. tuner_buf[9] = 0x24;
  671. tuner_buf[10] = 0xff;
  672. tuner_buf[11] = 0x60;
  673. tuner_buf[12] = 0x00;
  674. tuner_buf[13] = 0x39; // lpsel
  675. msg.len = 14;
  676. if (fe->ops.i2c_gate_ctrl)
  677. fe->ops.i2c_gate_ctrl(fe, 1);
  678. if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1)
  679. return -EIO;
  680. msg.buf= reg2;
  681. msg.len = 2;
  682. reg2[0] = 0x60;
  683. reg2[1] = 0x3c;
  684. if (fe->ops.i2c_gate_ctrl)
  685. fe->ops.i2c_gate_ctrl(fe, 1);
  686. i2c_transfer(&dev->i2c_adap, &msg, 1);
  687. reg2[0] = 0xa0;
  688. reg2[1] = 0x40;
  689. if (fe->ops.i2c_gate_ctrl)
  690. fe->ops.i2c_gate_ctrl(fe, 1);
  691. i2c_transfer(&dev->i2c_adap, &msg, 1);
  692. msleep(2);
  693. /* correct CP value */
  694. reg2[0] = 0x30;
  695. reg2[1] = 0x10 + tda827xa_dvbt[i].scr;
  696. msg.len = 2;
  697. if (fe->ops.i2c_gate_ctrl)
  698. fe->ops.i2c_gate_ctrl(fe, 1);
  699. i2c_transfer(&dev->i2c_adap, &msg, 1);
  700. msleep(550);
  701. reg2[0] = 0x50;
  702. reg2[1] = 0x4f + (tda827xa_dvbt[i].gc3 << 4);
  703. if (fe->ops.i2c_gate_ctrl)
  704. fe->ops.i2c_gate_ctrl(fe, 1);
  705. i2c_transfer(&dev->i2c_adap, &msg, 1);
  706. return 0;
  707. }
  708. static int philips_tda827xa_tuner_sleep(u8 addr, struct dvb_frontend *fe)
  709. {
  710. struct saa7134_dev *dev = fe->dvb->priv;
  711. static u8 tda827xa_sleep[] = { 0x30, 0x90};
  712. struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tda827xa_sleep,
  713. .len = sizeof(tda827xa_sleep) };
  714. if (fe->ops.i2c_gate_ctrl)
  715. fe->ops.i2c_gate_ctrl(fe, 1);
  716. i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
  717. if (fe->ops.i2c_gate_ctrl)
  718. fe->ops.i2c_gate_ctrl(fe, 0);
  719. return 0;
  720. }
  721. /* ------------------------------------------------------------------ */
  722. static int tda8290_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)
  723. {
  724. struct saa7134_dev *dev = fe->dvb->priv;
  725. static u8 tda8290_close[] = { 0x21, 0xc0};
  726. static u8 tda8290_open[] = { 0x21, 0x80};
  727. struct i2c_msg tda8290_msg = {.addr = 0x4b,.flags = 0, .len = 2};
  728. if (enable) {
  729. tda8290_msg.buf = tda8290_close;
  730. } else {
  731. tda8290_msg.buf = tda8290_open;
  732. }
  733. if (i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1) != 1)
  734. return -EIO;
  735. msleep(20);
  736. return 0;
  737. }
  738. /* ------------------------------------------------------------------ */
  739. static int philips_tiger_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  740. {
  741. int ret;
  742. ret = philips_tda827xa_pll_set(0x61, fe, params);
  743. if (ret != 0)
  744. return ret;
  745. return 0;
  746. }
  747. static int philips_tiger_tuner_init(struct dvb_frontend *fe)
  748. {
  749. struct saa7134_dev *dev = fe->dvb->priv;
  750. static u8 data[] = { 0x3c, 0x33, 0x6a};
  751. struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
  752. if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1)
  753. return -EIO;
  754. return 0;
  755. }
  756. static int philips_tiger_tuner_sleep(struct dvb_frontend *fe)
  757. {
  758. struct saa7134_dev *dev = fe->dvb->priv;
  759. static u8 data[] = { 0x3c, 0x33, 0x68};
  760. struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
  761. i2c_transfer(&dev->i2c_adap, &msg, 1);
  762. philips_tda827xa_tuner_sleep( 0x61, fe);
  763. return 0;
  764. }
  765. static struct tda1004x_config philips_tiger_config = {
  766. .demod_address = 0x08,
  767. .invert = 1,
  768. .invert_oclk = 0,
  769. .xtal_freq = TDA10046_XTAL_16M,
  770. .agc_config = TDA10046_AGC_TDA827X,
  771. .gpio_config = TDA10046_GP11_I,
  772. .if_freq = TDA10046_FREQ_045,
  773. .request_firmware = philips_tda1004x_request_firmware,
  774. };
  775. /* ------------------------------------------------------------------ */
  776. static int cinergy_ht_tuner_init(struct dvb_frontend *fe)
  777. {
  778. struct saa7134_dev *dev = fe->dvb->priv;
  779. static u8 data[] = { 0x3c, 0x33, 0x62};
  780. struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
  781. if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1)
  782. return -EIO;
  783. return 0;
  784. }
  785. static int cinergy_ht_tuner_sleep(struct dvb_frontend *fe)
  786. {
  787. struct saa7134_dev *dev = fe->dvb->priv;
  788. static u8 data[] = { 0x3c, 0x33, 0x60};
  789. struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
  790. i2c_transfer(&dev->i2c_adap, &msg, 1);
  791. philips_tda827xa_tuner_sleep( 0x61, fe);
  792. return 0;
  793. }
  794. static struct tda1004x_config cinergy_ht_config = {
  795. .demod_address = 0x08,
  796. .invert = 1,
  797. .invert_oclk = 0,
  798. .xtal_freq = TDA10046_XTAL_16M,
  799. .agc_config = TDA10046_AGC_TDA827X,
  800. .gpio_config = TDA10046_GP01_I,
  801. .if_freq = TDA10046_FREQ_045,
  802. .request_firmware = philips_tda1004x_request_firmware,
  803. };
  804. /* ------------------------------------------------------------------ */
  805. static struct tda1004x_config pinnacle_pctv_310i_config = {
  806. .demod_address = 0x08,
  807. .invert = 1,
  808. .invert_oclk = 0,
  809. .xtal_freq = TDA10046_XTAL_16M,
  810. .agc_config = TDA10046_AGC_TDA827X,
  811. .gpio_config = TDA10046_GP11_I,
  812. .if_freq = TDA10046_FREQ_045,
  813. .request_firmware = philips_tda1004x_request_firmware,
  814. };
  815. /* ------------------------------------------------------------------ */
  816. static struct tda1004x_config hauppauge_hvr_1110_config = {
  817. .demod_address = 0x08,
  818. .invert = 1,
  819. .invert_oclk = 0,
  820. .xtal_freq = TDA10046_XTAL_16M,
  821. .agc_config = TDA10046_AGC_TDA827X,
  822. .gpio_config = TDA10046_GP11_I,
  823. .if_freq = TDA10046_FREQ_045,
  824. .request_firmware = philips_tda1004x_request_firmware,
  825. };
  826. /* ------------------------------------------------------------------ */
  827. static struct tda1004x_config asus_p7131_dual_config = {
  828. .demod_address = 0x08,
  829. .invert = 1,
  830. .invert_oclk = 0,
  831. .xtal_freq = TDA10046_XTAL_16M,
  832. .agc_config = TDA10046_AGC_TDA827X,
  833. .gpio_config = TDA10046_GP11_I,
  834. .if_freq = TDA10046_FREQ_045,
  835. .request_firmware = philips_tda1004x_request_firmware,
  836. };
  837. static int asus_p7131_dual_tuner_init(struct dvb_frontend *fe)
  838. {
  839. struct saa7134_dev *dev = fe->dvb->priv;
  840. static u8 data[] = { 0x3c, 0x33, 0x6a};
  841. struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
  842. if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1)
  843. return -EIO;
  844. /* make sure the DVB-T antenna input is set */
  845. saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x0200000);
  846. return 0;
  847. }
  848. static int asus_p7131_dual_tuner_sleep(struct dvb_frontend *fe)
  849. {
  850. struct saa7134_dev *dev = fe->dvb->priv;
  851. static u8 data[] = { 0x3c, 0x33, 0x68};
  852. struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
  853. i2c_transfer(&dev->i2c_adap, &msg, 1);
  854. philips_tda827xa_tuner_sleep( 0x61, fe);
  855. /* reset antenna inputs for analog usage */
  856. saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x0200000);
  857. return 0;
  858. }
  859. /* ------------------------------------------------------------------ */
  860. static int lifeview_trio_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  861. {
  862. int ret;
  863. ret = philips_tda827xa_pll_set(0x60, fe, params);
  864. return ret;
  865. }
  866. static int lifeview_trio_tuner_sleep(struct dvb_frontend *fe)
  867. {
  868. philips_tda827xa_tuner_sleep(0x60, fe);
  869. return 0;
  870. }
  871. static struct tda1004x_config lifeview_trio_config = {
  872. .demod_address = 0x09,
  873. .invert = 1,
  874. .invert_oclk = 0,
  875. .xtal_freq = TDA10046_XTAL_16M,
  876. .agc_config = TDA10046_AGC_TDA827X,
  877. .gpio_config = TDA10046_GP00_I,
  878. .if_freq = TDA10046_FREQ_045,
  879. .request_firmware = philips_tda1004x_request_firmware,
  880. };
  881. /* ------------------------------------------------------------------ */
  882. static int ads_duo_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  883. {
  884. int ret;
  885. ret = philips_tda827xa_pll_set(0x61, fe, params);
  886. return ret;
  887. }
  888. static int ads_duo_tuner_init(struct dvb_frontend *fe)
  889. {
  890. struct saa7134_dev *dev = fe->dvb->priv;
  891. /* route TDA8275a AGC input to the channel decoder */
  892. saa_writeb(SAA7134_GPIO_GPSTATUS2, 0x60);
  893. return 0;
  894. }
  895. static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
  896. {
  897. struct saa7134_dev *dev = fe->dvb->priv;
  898. /* route TDA8275a AGC input to the analog IF chip*/
  899. saa_writeb(SAA7134_GPIO_GPSTATUS2, 0x20);
  900. philips_tda827xa_tuner_sleep( 0x61, fe);
  901. return 0;
  902. }
  903. static struct tda1004x_config ads_tech_duo_config = {
  904. .demod_address = 0x08,
  905. .invert = 1,
  906. .invert_oclk = 0,
  907. .xtal_freq = TDA10046_XTAL_16M,
  908. .agc_config = TDA10046_AGC_TDA827X,
  909. .gpio_config = TDA10046_GP00_I,
  910. .if_freq = TDA10046_FREQ_045,
  911. .request_firmware = philips_tda1004x_request_firmware,
  912. };
  913. /* ------------------------------------------------------------------ */
  914. static int tevion_dvb220rf_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  915. {
  916. int ret;
  917. ret = philips_tda827xa_pll_set(0x60, fe, params);
  918. return ret;
  919. }
  920. static int tevion_dvb220rf_tuner_sleep(struct dvb_frontend *fe)
  921. {
  922. philips_tda827xa_tuner_sleep( 0x61, fe);
  923. return 0;
  924. }
  925. static struct tda1004x_config tevion_dvbt220rf_config = {
  926. .demod_address = 0x08,
  927. .invert = 1,
  928. .invert_oclk = 0,
  929. .xtal_freq = TDA10046_XTAL_16M,
  930. .agc_config = TDA10046_AGC_TDA827X,
  931. .gpio_config = TDA10046_GP11_I,
  932. .if_freq = TDA10046_FREQ_045,
  933. .request_firmware = philips_tda1004x_request_firmware,
  934. };
  935. /* ------------------------------------------------------------------ */
  936. static int md8800_dvbt_analog_mode(struct dvb_frontend *fe)
  937. {
  938. struct saa7134_dev *dev = fe->dvb->priv;
  939. static u8 data[] = { 0x3c, 0x33, 0x68};
  940. struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
  941. i2c_transfer(&dev->i2c_adap, &msg, 1);
  942. philips_tda827xa_tuner_sleep( 0x61, fe);
  943. return 0;
  944. }
  945. static int md8800_dvbt_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  946. {
  947. int ret;
  948. struct saa7134_dev *dev = fe->dvb->priv;
  949. static u8 tda8290_close[] = { 0x21, 0xc0};
  950. static u8 tda8290_open[] = { 0x21, 0x80};
  951. struct i2c_msg tda8290_msg = {.addr = 0x4b,.flags = 0, .len = 2};
  952. /* close tda8290 i2c bridge */
  953. tda8290_msg.buf = tda8290_close;
  954. ret = i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1);
  955. if (ret != 1)
  956. return -EIO;
  957. msleep(20);
  958. ret = philips_tda827xa_pll_set(0x60, fe, params);
  959. if (ret != 0)
  960. return ret;
  961. /* open tda8290 i2c bridge */
  962. tda8290_msg.buf = tda8290_open;
  963. i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1);
  964. return ret;
  965. }
  966. static struct tda1004x_config md8800_dvbt_config = {
  967. .demod_address = 0x08,
  968. .invert = 1,
  969. .invert_oclk = 0,
  970. .xtal_freq = TDA10046_XTAL_16M,
  971. .agc_config = TDA10046_AGC_TDA827X,
  972. .gpio_config = TDA10046_GP11_I,
  973. .if_freq = TDA10046_FREQ_045,
  974. .request_firmware = philips_tda1004x_request_firmware,
  975. };
  976. static struct tda10086_config flydvbs = {
  977. .demod_address = 0x0e,
  978. .invert = 0,
  979. };
  980. /* ------------------------------------------------------------------ */
  981. static struct nxt200x_config avertvhda180 = {
  982. .demod_address = 0x0a,
  983. };
  984. static int nxt200x_set_pll_input(u8 *buf, int input)
  985. {
  986. if (input)
  987. buf[3] |= 0x08;
  988. else
  989. buf[3] &= ~0x08;
  990. return 0;
  991. }
  992. static struct nxt200x_config kworldatsc110 = {
  993. .demod_address = 0x0a,
  994. .set_pll_input = nxt200x_set_pll_input,
  995. };
  996. /* ------------------------------------------------------------------ */
  997. static int dvb_init(struct saa7134_dev *dev)
  998. {
  999. /* init struct videobuf_dvb */
  1000. dev->ts.nr_bufs = 32;
  1001. dev->ts.nr_packets = 32*4;
  1002. dev->dvb.name = dev->name;
  1003. videobuf_queue_init(&dev->dvb.dvbq, &saa7134_ts_qops,
  1004. dev->pci, &dev->slock,
  1005. V4L2_BUF_TYPE_VIDEO_CAPTURE,
  1006. V4L2_FIELD_ALTERNATE,
  1007. sizeof(struct saa7134_buf),
  1008. dev);
  1009. switch (dev->board) {
  1010. case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
  1011. printk("%s: pinnacle 300i dvb setup\n",dev->name);
  1012. dev->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
  1013. &dev->i2c_adap);
  1014. if (dev->dvb.frontend) {
  1015. dev->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
  1016. }
  1017. break;
  1018. case SAA7134_BOARD_AVERMEDIA_777:
  1019. case SAA7134_BOARD_AVERMEDIA_A16AR:
  1020. printk("%s: avertv 777 dvb setup\n",dev->name);
  1021. dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
  1022. &dev->i2c_adap);
  1023. if (dev->dvb.frontend) {
  1024. dev->dvb.frontend->ops.tuner_ops.calc_regs = mt352_aver777_tuner_calc_regs;
  1025. }
  1026. break;
  1027. case SAA7134_BOARD_MD7134:
  1028. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1029. &medion_cardbus,
  1030. &dev->i2c_adap);
  1031. if (dev->dvb.frontend) {
  1032. dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init;
  1033. dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep;
  1034. dev->dvb.frontend->ops.tuner_ops.set_params = philips_fmd1216_tuner_set_params;
  1035. }
  1036. break;
  1037. case SAA7134_BOARD_PHILIPS_TOUGH:
  1038. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1039. &philips_tu1216_60_config,
  1040. &dev->i2c_adap);
  1041. if (dev->dvb.frontend) {
  1042. dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_tuner_60_init;
  1043. dev->dvb.frontend->ops.tuner_ops.set_params = philips_tu1216_tuner_60_set_params;
  1044. }
  1045. break;
  1046. case SAA7134_BOARD_FLYDVBTDUO:
  1047. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1048. &tda827x_lifeview_config,
  1049. &dev->i2c_adap);
  1050. if (dev->dvb.frontend) {
  1051. dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init;
  1052. dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep;
  1053. dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda827x_tuner_set_params;
  1054. }
  1055. break;
  1056. case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
  1057. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1058. &tda827x_lifeview_config,
  1059. &dev->i2c_adap);
  1060. if (dev->dvb.frontend) {
  1061. dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init;
  1062. dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep;
  1063. dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda827x_tuner_set_params;
  1064. }
  1065. break;
  1066. case SAA7134_BOARD_PHILIPS_EUROPA:
  1067. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1068. &philips_europa_config,
  1069. &dev->i2c_adap);
  1070. if (dev->dvb.frontend) {
  1071. dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
  1072. dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
  1073. dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
  1074. dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
  1075. dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
  1076. }
  1077. break;
  1078. case SAA7134_BOARD_VIDEOMATE_DVBT_300:
  1079. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1080. &philips_europa_config,
  1081. &dev->i2c_adap);
  1082. if (dev->dvb.frontend) {
  1083. dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
  1084. dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
  1085. dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
  1086. dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
  1087. dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
  1088. }
  1089. break;
  1090. case SAA7134_BOARD_VIDEOMATE_DVBT_200:
  1091. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1092. &philips_tu1216_61_config,
  1093. &dev->i2c_adap);
  1094. if (dev->dvb.frontend) {
  1095. dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_tuner_61_init;
  1096. dev->dvb.frontend->ops.tuner_ops.set_params = philips_tu1216_tuner_61_set_params;
  1097. }
  1098. break;
  1099. case SAA7134_BOARD_PHILIPS_TIGER:
  1100. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1101. &philips_tiger_config,
  1102. &dev->i2c_adap);
  1103. if (dev->dvb.frontend) {
  1104. dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
  1105. dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
  1106. dev->dvb.frontend->ops.tuner_ops.sleep = philips_tiger_tuner_sleep;
  1107. dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
  1108. }
  1109. break;
  1110. case SAA7134_BOARD_PINNACLE_PCTV_310i:
  1111. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1112. &pinnacle_pctv_310i_config,
  1113. &dev->i2c_adap);
  1114. if (dev->dvb.frontend) {
  1115. dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
  1116. dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
  1117. dev->dvb.frontend->ops.tuner_ops.sleep = philips_tiger_tuner_sleep;
  1118. dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
  1119. }
  1120. break;
  1121. case SAA7134_BOARD_HAUPPAUGE_HVR1110:
  1122. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1123. &hauppauge_hvr_1110_config,
  1124. &dev->i2c_adap);
  1125. if (dev->dvb.frontend) {
  1126. dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
  1127. dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
  1128. dev->dvb.frontend->ops.tuner_ops.sleep = philips_tiger_tuner_sleep;
  1129. dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
  1130. }
  1131. break;
  1132. case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
  1133. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1134. &asus_p7131_dual_config,
  1135. &dev->i2c_adap);
  1136. if (dev->dvb.frontend) {
  1137. dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
  1138. dev->dvb.frontend->ops.tuner_ops.init = asus_p7131_dual_tuner_init;
  1139. dev->dvb.frontend->ops.tuner_ops.sleep = asus_p7131_dual_tuner_sleep;
  1140. dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
  1141. }
  1142. break;
  1143. case SAA7134_BOARD_FLYDVBT_LR301:
  1144. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1145. &tda827x_lifeview_config,
  1146. &dev->i2c_adap);
  1147. if (dev->dvb.frontend) {
  1148. dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init;
  1149. dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep;
  1150. dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda827x_tuner_set_params;
  1151. }
  1152. break;
  1153. case SAA7134_BOARD_FLYDVB_TRIO:
  1154. if(! use_frontend) { //terrestrial
  1155. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1156. &lifeview_trio_config,
  1157. &dev->i2c_adap);
  1158. if (dev->dvb.frontend) {
  1159. dev->dvb.frontend->ops.tuner_ops.sleep = lifeview_trio_tuner_sleep;
  1160. dev->dvb.frontend->ops.tuner_ops.set_params =
  1161. lifeview_trio_tuner_set_params;
  1162. }
  1163. } else { //satellite
  1164. dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
  1165. if (dev->dvb.frontend) {
  1166. if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63,
  1167. &dev->i2c_adap, 0) == NULL) {
  1168. printk("%s: Lifeview Trio, No tda826x found!\n", __FUNCTION__);
  1169. }
  1170. if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap,
  1171. 0x08, 0, 0) == NULL) {
  1172. printk("%s: Lifeview Trio, No ISL6421 found!\n", __FUNCTION__);
  1173. }
  1174. }
  1175. }
  1176. break;
  1177. case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
  1178. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1179. &ads_tech_duo_config,
  1180. &dev->i2c_adap);
  1181. if (dev->dvb.frontend) {
  1182. dev->dvb.frontend->ops.tuner_ops.init = ads_duo_tuner_init;
  1183. dev->dvb.frontend->ops.tuner_ops.sleep = ads_duo_tuner_sleep;
  1184. dev->dvb.frontend->ops.tuner_ops.set_params = ads_duo_tuner_set_params;
  1185. }
  1186. break;
  1187. case SAA7134_BOARD_TEVION_DVBT_220RF:
  1188. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1189. &tevion_dvbt220rf_config,
  1190. &dev->i2c_adap);
  1191. if (dev->dvb.frontend) {
  1192. dev->dvb.frontend->ops.tuner_ops.sleep = tevion_dvb220rf_tuner_sleep;
  1193. dev->dvb.frontend->ops.tuner_ops.set_params = tevion_dvb220rf_tuner_set_params;
  1194. }
  1195. break;
  1196. case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
  1197. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1198. &ads_tech_duo_config,
  1199. &dev->i2c_adap);
  1200. if (dev->dvb.frontend) {
  1201. dev->dvb.frontend->ops.tuner_ops.init = ads_duo_tuner_init;
  1202. dev->dvb.frontend->ops.tuner_ops.sleep = ads_duo_tuner_sleep;
  1203. dev->dvb.frontend->ops.tuner_ops.set_params = ads_duo_tuner_set_params;
  1204. }
  1205. break;
  1206. case SAA7134_BOARD_MEDION_MD8800_QUADRO:
  1207. dev->dvb.frontend = tda10046_attach(&md8800_dvbt_config,
  1208. &dev->i2c_adap);
  1209. if (dev->dvb.frontend) {
  1210. dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
  1211. dev->dvb.frontend->ops.tuner_ops.sleep = md8800_dvbt_analog_mode;
  1212. dev->dvb.frontend->ops.tuner_ops.set_params = md8800_dvbt_pll_set;
  1213. }
  1214. break;
  1215. case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
  1216. dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
  1217. &dev->i2c_adap);
  1218. if (dev->dvb.frontend) {
  1219. dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
  1220. NULL, &dvb_pll_tdhu2);
  1221. }
  1222. break;
  1223. case SAA7134_BOARD_KWORLD_ATSC110:
  1224. dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
  1225. &dev->i2c_adap);
  1226. if (dev->dvb.frontend) {
  1227. dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
  1228. NULL, &dvb_pll_tuv1236d);
  1229. }
  1230. break;
  1231. case SAA7134_BOARD_FLYDVBS_LR300:
  1232. dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
  1233. &dev->i2c_adap);
  1234. if (dev->dvb.frontend) {
  1235. if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
  1236. &dev->i2c_adap, 0) == NULL) {
  1237. printk("%s: No tda826x found!\n", __FUNCTION__);
  1238. }
  1239. if (dvb_attach(isl6421_attach, dev->dvb.frontend,
  1240. &dev->i2c_adap, 0x08, 0, 0) == NULL) {
  1241. printk("%s: No ISL6421 found!\n", __FUNCTION__);
  1242. }
  1243. }
  1244. break;
  1245. case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
  1246. dev->dvb.frontend = tda10046_attach(&medion_cardbus,
  1247. &dev->i2c_adap);
  1248. if (dev->dvb.frontend) {
  1249. dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
  1250. dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
  1251. dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init;
  1252. dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep;
  1253. dev->dvb.frontend->ops.tuner_ops.set_params = philips_fmd1216_tuner_set_params;
  1254. }
  1255. break;
  1256. case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
  1257. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1258. &philips_europa_config,
  1259. &dev->i2c_adap);
  1260. if (dev->dvb.frontend) {
  1261. dev->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
  1262. dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
  1263. }
  1264. break;
  1265. case SAA7134_BOARD_CINERGY_HT_PCMCIA:
  1266. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1267. &cinergy_ht_config,
  1268. &dev->i2c_adap);
  1269. if (dev->dvb.frontend) {
  1270. dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
  1271. dev->dvb.frontend->ops.tuner_ops.init = cinergy_ht_tuner_init;
  1272. dev->dvb.frontend->ops.tuner_ops.sleep = cinergy_ht_tuner_sleep;
  1273. dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
  1274. }
  1275. break;
  1276. case SAA7134_BOARD_CINERGY_HT_PCI:
  1277. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1278. &cinergy_ht_config,
  1279. &dev->i2c_adap);
  1280. if (dev->dvb.frontend) {
  1281. dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
  1282. dev->dvb.frontend->ops.tuner_ops.init = cinergy_ht_tuner_init;
  1283. dev->dvb.frontend->ops.tuner_ops.sleep = cinergy_ht_tuner_sleep;
  1284. dev->dvb.frontend->ops.tuner_ops.set_params = md8800_dvbt_pll_set;
  1285. }
  1286. break;
  1287. default:
  1288. printk("%s: Huh? unknown DVB card?\n",dev->name);
  1289. break;
  1290. }
  1291. if (NULL == dev->dvb.frontend) {
  1292. printk("%s: frontend initialization failed\n",dev->name);
  1293. return -1;
  1294. }
  1295. /* register everything else */
  1296. return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev);
  1297. }
  1298. static int dvb_fini(struct saa7134_dev *dev)
  1299. {
  1300. static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
  1301. switch (dev->board) {
  1302. case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
  1303. /* otherwise we don't detect the tuner on next insmod */
  1304. saa7134_i2c_call_clients(dev,TDA9887_SET_CONFIG,&on);
  1305. break;
  1306. };
  1307. videobuf_dvb_unregister(&dev->dvb);
  1308. return 0;
  1309. }
  1310. static struct saa7134_mpeg_ops dvb_ops = {
  1311. .type = SAA7134_MPEG_DVB,
  1312. .init = dvb_init,
  1313. .fini = dvb_fini,
  1314. };
  1315. static int __init dvb_register(void)
  1316. {
  1317. return saa7134_ts_register(&dvb_ops);
  1318. }
  1319. static void __exit dvb_unregister(void)
  1320. {
  1321. saa7134_ts_unregister(&dvb_ops);
  1322. }
  1323. module_init(dvb_register);
  1324. module_exit(dvb_unregister);
  1325. /* ------------------------------------------------------------------ */
  1326. /*
  1327. * Local variables:
  1328. * c-basic-offset: 8
  1329. * End:
  1330. */