saa7134-dvb.c 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854
  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/delay.h>
  27. #include <linux/kthread.h>
  28. #include <linux/suspend.h>
  29. #include "saa7134-reg.h"
  30. #include "saa7134.h"
  31. #include <media/v4l2-common.h>
  32. #include "dvb-pll.h"
  33. #include <dvb_frontend.h>
  34. #include "mt352.h"
  35. #include "mt352_priv.h" /* FIXME */
  36. #include "tda1004x.h"
  37. #include "nxt200x.h"
  38. #include "tuner-xc2028.h"
  39. #include "xc5000.h"
  40. #include "tda10086.h"
  41. #include "tda826x.h"
  42. #include "tda827x.h"
  43. #include "isl6421.h"
  44. #include "isl6405.h"
  45. #include "lnbp21.h"
  46. #include "tuner-simple.h"
  47. #include "tda10048.h"
  48. #include "tda18271.h"
  49. #include "lgdt3305.h"
  50. #include "tda8290.h"
  51. #include "mb86a20s.h"
  52. #include "lgs8gxx.h"
  53. #include "zl10353.h"
  54. #include "qt1010.h"
  55. #include "zl10036.h"
  56. #include "zl10039.h"
  57. #include "mt312.h"
  58. MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
  59. MODULE_LICENSE("GPL");
  60. static unsigned int antenna_pwr;
  61. module_param(antenna_pwr, int, 0444);
  62. MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
  63. static int use_frontend;
  64. module_param(use_frontend, int, 0644);
  65. MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
  66. static int debug;
  67. module_param(debug, int, 0644);
  68. MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off).");
  69. DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
  70. #define dprintk(fmt, arg...) do { if (debug) \
  71. printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
  72. /* Print a warning */
  73. #define wprintk(fmt, arg...) \
  74. printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
  75. /* ------------------------------------------------------------------
  76. * mt352 based DVB-T cards
  77. */
  78. static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
  79. {
  80. u32 ok;
  81. if (!on) {
  82. saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
  83. saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
  84. return 0;
  85. }
  86. saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
  87. saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
  88. udelay(10);
  89. saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28));
  90. saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
  91. udelay(10);
  92. saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
  93. udelay(10);
  94. ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
  95. dprintk("%s %s\n", __func__, ok ? "on" : "off");
  96. if (!ok)
  97. saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
  98. return ok;
  99. }
  100. static int mt352_pinnacle_init(struct dvb_frontend* fe)
  101. {
  102. static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 };
  103. static u8 reset [] = { RESET, 0x80 };
  104. static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
  105. static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
  106. static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
  107. static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 };
  108. static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f };
  109. static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d };
  110. static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
  111. struct saa7134_dev *dev= fe->dvb->priv;
  112. dprintk("%s called\n", __func__);
  113. mt352_write(fe, clock_config, sizeof(clock_config));
  114. udelay(200);
  115. mt352_write(fe, reset, sizeof(reset));
  116. mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
  117. mt352_write(fe, agc_cfg, sizeof(agc_cfg));
  118. mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
  119. mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
  120. mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
  121. mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
  122. mt352_write(fe, irq_cfg, sizeof(irq_cfg));
  123. return 0;
  124. }
  125. static int mt352_aver777_init(struct dvb_frontend* fe)
  126. {
  127. static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
  128. static u8 reset [] = { RESET, 0x80 };
  129. static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
  130. static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
  131. static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
  132. mt352_write(fe, clock_config, sizeof(clock_config));
  133. udelay(200);
  134. mt352_write(fe, reset, sizeof(reset));
  135. mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
  136. mt352_write(fe, agc_cfg, sizeof(agc_cfg));
  137. mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
  138. return 0;
  139. }
  140. static int mt352_avermedia_xc3028_init(struct dvb_frontend *fe)
  141. {
  142. static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
  143. static u8 reset [] = { RESET, 0x80 };
  144. static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
  145. static u8 agc_cfg [] = { AGC_TARGET, 0xe };
  146. static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
  147. mt352_write(fe, clock_config, sizeof(clock_config));
  148. udelay(200);
  149. mt352_write(fe, reset, sizeof(reset));
  150. mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
  151. mt352_write(fe, agc_cfg, sizeof(agc_cfg));
  152. mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
  153. return 0;
  154. }
  155. static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
  156. struct dvb_frontend_parameters* params)
  157. {
  158. struct dtv_frontend_properties *c = &fe->dtv_property_cache;
  159. u8 off[] = { 0x00, 0xf1};
  160. u8 on[] = { 0x00, 0x71};
  161. struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
  162. struct saa7134_dev *dev = fe->dvb->priv;
  163. struct v4l2_frequency f;
  164. /* set frequency (mt2050) */
  165. f.tuner = 0;
  166. f.type = V4L2_TUNER_DIGITAL_TV;
  167. f.frequency = c->frequency / 1000 * 16 / 1000;
  168. if (fe->ops.i2c_gate_ctrl)
  169. fe->ops.i2c_gate_ctrl(fe, 1);
  170. i2c_transfer(&dev->i2c_adap, &msg, 1);
  171. saa_call_all(dev, tuner, s_frequency, &f);
  172. msg.buf = on;
  173. if (fe->ops.i2c_gate_ctrl)
  174. fe->ops.i2c_gate_ctrl(fe, 1);
  175. i2c_transfer(&dev->i2c_adap, &msg, 1);
  176. pinnacle_antenna_pwr(dev, antenna_pwr);
  177. /* mt352 setup */
  178. return mt352_pinnacle_init(fe);
  179. }
  180. static struct mt352_config pinnacle_300i = {
  181. .demod_address = 0x3c >> 1,
  182. .adc_clock = 20333,
  183. .if2 = 36150,
  184. .no_tuner = 1,
  185. .demod_init = mt352_pinnacle_init,
  186. };
  187. static struct mt352_config avermedia_777 = {
  188. .demod_address = 0xf,
  189. .demod_init = mt352_aver777_init,
  190. };
  191. static struct mt352_config avermedia_xc3028_mt352_dev = {
  192. .demod_address = (0x1e >> 1),
  193. .no_tuner = 1,
  194. .demod_init = mt352_avermedia_xc3028_init,
  195. };
  196. static struct tda18271_std_map mb86a20s_tda18271_std_map = {
  197. .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4,
  198. .if_lvl = 7, .rfagc_top = 0x37, },
  199. };
  200. static struct tda18271_config kworld_tda18271_config = {
  201. .std_map = &mb86a20s_tda18271_std_map,
  202. .gate = TDA18271_GATE_DIGITAL,
  203. .config = 3, /* Use tuner callback for AGC */
  204. };
  205. static const struct mb86a20s_config kworld_mb86a20s_config = {
  206. .demod_address = 0x10,
  207. };
  208. static int kworld_sbtvd_gate_ctrl(struct dvb_frontend* fe, int enable)
  209. {
  210. struct saa7134_dev *dev = fe->dvb->priv;
  211. unsigned char initmsg[] = {0x45, 0x97};
  212. unsigned char msg_enable[] = {0x45, 0xc1};
  213. unsigned char msg_disable[] = {0x45, 0x81};
  214. struct i2c_msg msg = {.addr = 0x4b, .flags = 0, .buf = initmsg, .len = 2};
  215. if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
  216. wprintk("could not access the I2C gate\n");
  217. return -EIO;
  218. }
  219. if (enable)
  220. msg.buf = msg_enable;
  221. else
  222. msg.buf = msg_disable;
  223. if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
  224. wprintk("could not access the I2C gate\n");
  225. return -EIO;
  226. }
  227. msleep(20);
  228. return 0;
  229. }
  230. /* ==================================================================
  231. * tda1004x based DVB-T cards, helper functions
  232. */
  233. static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
  234. const struct firmware **fw, char *name)
  235. {
  236. struct saa7134_dev *dev = fe->dvb->priv;
  237. return request_firmware(fw, name, &dev->pci->dev);
  238. }
  239. /* ------------------------------------------------------------------
  240. * these tuners are tu1216, td1316(a)
  241. */
  242. static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  243. {
  244. struct dtv_frontend_properties *c = &fe->dtv_property_cache;
  245. struct saa7134_dev *dev = fe->dvb->priv;
  246. struct tda1004x_state *state = fe->demodulator_priv;
  247. u8 addr = state->config->tuner_address;
  248. u8 tuner_buf[4];
  249. struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
  250. sizeof(tuner_buf) };
  251. int tuner_frequency = 0;
  252. u8 band, cp, filter;
  253. /* determine charge pump */
  254. tuner_frequency = c->frequency + 36166000;
  255. if (tuner_frequency < 87000000)
  256. return -EINVAL;
  257. else if (tuner_frequency < 130000000)
  258. cp = 3;
  259. else if (tuner_frequency < 160000000)
  260. cp = 5;
  261. else if (tuner_frequency < 200000000)
  262. cp = 6;
  263. else if (tuner_frequency < 290000000)
  264. cp = 3;
  265. else if (tuner_frequency < 420000000)
  266. cp = 5;
  267. else if (tuner_frequency < 480000000)
  268. cp = 6;
  269. else if (tuner_frequency < 620000000)
  270. cp = 3;
  271. else if (tuner_frequency < 830000000)
  272. cp = 5;
  273. else if (tuner_frequency < 895000000)
  274. cp = 7;
  275. else
  276. return -EINVAL;
  277. /* determine band */
  278. if (c->frequency < 49000000)
  279. return -EINVAL;
  280. else if (c->frequency < 161000000)
  281. band = 1;
  282. else if (c->frequency < 444000000)
  283. band = 2;
  284. else if (c->frequency < 861000000)
  285. band = 4;
  286. else
  287. return -EINVAL;
  288. /* setup PLL filter */
  289. switch (c->bandwidth_hz) {
  290. case 6000000:
  291. filter = 0;
  292. break;
  293. case 7000000:
  294. filter = 0;
  295. break;
  296. case 8000000:
  297. filter = 1;
  298. break;
  299. default:
  300. return -EINVAL;
  301. }
  302. /* calculate divisor
  303. * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
  304. */
  305. tuner_frequency = (((c->frequency / 1000) * 6) + 217496) / 1000;
  306. /* setup tuner buffer */
  307. tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
  308. tuner_buf[1] = tuner_frequency & 0xff;
  309. tuner_buf[2] = 0xca;
  310. tuner_buf[3] = (cp << 5) | (filter << 3) | band;
  311. if (fe->ops.i2c_gate_ctrl)
  312. fe->ops.i2c_gate_ctrl(fe, 1);
  313. if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
  314. wprintk("could not write to tuner at addr: 0x%02x\n",
  315. addr << 1);
  316. return -EIO;
  317. }
  318. msleep(1);
  319. return 0;
  320. }
  321. static int philips_tu1216_init(struct dvb_frontend *fe)
  322. {
  323. struct saa7134_dev *dev = fe->dvb->priv;
  324. struct tda1004x_state *state = fe->demodulator_priv;
  325. u8 addr = state->config->tuner_address;
  326. static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
  327. struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
  328. /* setup PLL configuration */
  329. if (fe->ops.i2c_gate_ctrl)
  330. fe->ops.i2c_gate_ctrl(fe, 1);
  331. if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
  332. return -EIO;
  333. msleep(1);
  334. return 0;
  335. }
  336. /* ------------------------------------------------------------------ */
  337. static struct tda1004x_config philips_tu1216_60_config = {
  338. .demod_address = 0x8,
  339. .invert = 1,
  340. .invert_oclk = 0,
  341. .xtal_freq = TDA10046_XTAL_4M,
  342. .agc_config = TDA10046_AGC_DEFAULT,
  343. .if_freq = TDA10046_FREQ_3617,
  344. .tuner_address = 0x60,
  345. .request_firmware = philips_tda1004x_request_firmware
  346. };
  347. static struct tda1004x_config philips_tu1216_61_config = {
  348. .demod_address = 0x8,
  349. .invert = 1,
  350. .invert_oclk = 0,
  351. .xtal_freq = TDA10046_XTAL_4M,
  352. .agc_config = TDA10046_AGC_DEFAULT,
  353. .if_freq = TDA10046_FREQ_3617,
  354. .tuner_address = 0x61,
  355. .request_firmware = philips_tda1004x_request_firmware
  356. };
  357. /* ------------------------------------------------------------------ */
  358. static int philips_td1316_tuner_init(struct dvb_frontend *fe)
  359. {
  360. struct saa7134_dev *dev = fe->dvb->priv;
  361. struct tda1004x_state *state = fe->demodulator_priv;
  362. u8 addr = state->config->tuner_address;
  363. static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
  364. struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
  365. /* setup PLL configuration */
  366. if (fe->ops.i2c_gate_ctrl)
  367. fe->ops.i2c_gate_ctrl(fe, 1);
  368. if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
  369. return -EIO;
  370. return 0;
  371. }
  372. static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  373. {
  374. return philips_tda6651_pll_set(fe, params);
  375. }
  376. static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
  377. {
  378. struct saa7134_dev *dev = fe->dvb->priv;
  379. struct tda1004x_state *state = fe->demodulator_priv;
  380. u8 addr = state->config->tuner_address;
  381. static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
  382. struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
  383. /* switch the tuner to analog mode */
  384. if (fe->ops.i2c_gate_ctrl)
  385. fe->ops.i2c_gate_ctrl(fe, 1);
  386. if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
  387. return -EIO;
  388. return 0;
  389. }
  390. /* ------------------------------------------------------------------ */
  391. static int philips_europa_tuner_init(struct dvb_frontend *fe)
  392. {
  393. struct saa7134_dev *dev = fe->dvb->priv;
  394. static u8 msg[] = { 0x00, 0x40};
  395. struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
  396. if (philips_td1316_tuner_init(fe))
  397. return -EIO;
  398. msleep(1);
  399. if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
  400. return -EIO;
  401. return 0;
  402. }
  403. static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
  404. {
  405. struct saa7134_dev *dev = fe->dvb->priv;
  406. static u8 msg[] = { 0x00, 0x14 };
  407. struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
  408. if (philips_td1316_tuner_sleep(fe))
  409. return -EIO;
  410. /* switch the board to analog mode */
  411. if (fe->ops.i2c_gate_ctrl)
  412. fe->ops.i2c_gate_ctrl(fe, 1);
  413. i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
  414. return 0;
  415. }
  416. static int philips_europa_demod_sleep(struct dvb_frontend *fe)
  417. {
  418. struct saa7134_dev *dev = fe->dvb->priv;
  419. if (dev->original_demod_sleep)
  420. dev->original_demod_sleep(fe);
  421. fe->ops.i2c_gate_ctrl(fe, 1);
  422. return 0;
  423. }
  424. static struct tda1004x_config philips_europa_config = {
  425. .demod_address = 0x8,
  426. .invert = 0,
  427. .invert_oclk = 0,
  428. .xtal_freq = TDA10046_XTAL_4M,
  429. .agc_config = TDA10046_AGC_IFO_AUTO_POS,
  430. .if_freq = TDA10046_FREQ_052,
  431. .tuner_address = 0x61,
  432. .request_firmware = philips_tda1004x_request_firmware
  433. };
  434. static struct tda1004x_config medion_cardbus = {
  435. .demod_address = 0x08,
  436. .invert = 1,
  437. .invert_oclk = 0,
  438. .xtal_freq = TDA10046_XTAL_16M,
  439. .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
  440. .if_freq = TDA10046_FREQ_3613,
  441. .tuner_address = 0x61,
  442. .request_firmware = philips_tda1004x_request_firmware
  443. };
  444. static struct tda1004x_config technotrend_budget_t3000_config = {
  445. .demod_address = 0x8,
  446. .invert = 1,
  447. .invert_oclk = 0,
  448. .xtal_freq = TDA10046_XTAL_4M,
  449. .agc_config = TDA10046_AGC_DEFAULT,
  450. .if_freq = TDA10046_FREQ_3617,
  451. .tuner_address = 0x63,
  452. .request_firmware = philips_tda1004x_request_firmware
  453. };
  454. /* ------------------------------------------------------------------
  455. * tda 1004x based cards with philips silicon tuner
  456. */
  457. static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
  458. {
  459. struct tda1004x_state *state = fe->demodulator_priv;
  460. u8 addr = state->config->i2c_gate;
  461. static u8 tda8290_close[] = { 0x21, 0xc0};
  462. static u8 tda8290_open[] = { 0x21, 0x80};
  463. struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
  464. if (enable) {
  465. tda8290_msg.buf = tda8290_close;
  466. } else {
  467. tda8290_msg.buf = tda8290_open;
  468. }
  469. if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
  470. struct saa7134_dev *dev = fe->dvb->priv;
  471. wprintk("could not access tda8290 I2C gate\n");
  472. return -EIO;
  473. }
  474. msleep(20);
  475. return 0;
  476. }
  477. static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
  478. {
  479. struct saa7134_dev *dev = fe->dvb->priv;
  480. struct tda1004x_state *state = fe->demodulator_priv;
  481. switch (state->config->antenna_switch) {
  482. case 0: break;
  483. case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
  484. saa7134_set_gpio(dev, 21, 0);
  485. break;
  486. case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
  487. saa7134_set_gpio(dev, 21, 1);
  488. break;
  489. }
  490. return 0;
  491. }
  492. static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
  493. {
  494. struct saa7134_dev *dev = fe->dvb->priv;
  495. struct tda1004x_state *state = fe->demodulator_priv;
  496. switch (state->config->antenna_switch) {
  497. case 0: break;
  498. case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
  499. saa7134_set_gpio(dev, 21, 1);
  500. break;
  501. case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
  502. saa7134_set_gpio(dev, 21, 0);
  503. break;
  504. }
  505. return 0;
  506. }
  507. static int configure_tda827x_fe(struct saa7134_dev *dev,
  508. struct tda1004x_config *cdec_conf,
  509. struct tda827x_config *tuner_conf)
  510. {
  511. struct videobuf_dvb_frontend *fe0;
  512. /* Get the first frontend */
  513. fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
  514. fe0->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap);
  515. if (fe0->dvb.frontend) {
  516. if (cdec_conf->i2c_gate)
  517. fe0->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
  518. if (dvb_attach(tda827x_attach, fe0->dvb.frontend,
  519. cdec_conf->tuner_address,
  520. &dev->i2c_adap, tuner_conf))
  521. return 0;
  522. wprintk("no tda827x tuner found at addr: %02x\n",
  523. cdec_conf->tuner_address);
  524. }
  525. return -EINVAL;
  526. }
  527. /* ------------------------------------------------------------------ */
  528. static struct tda827x_config tda827x_cfg_0 = {
  529. .init = philips_tda827x_tuner_init,
  530. .sleep = philips_tda827x_tuner_sleep,
  531. .config = 0,
  532. .switch_addr = 0
  533. };
  534. static struct tda827x_config tda827x_cfg_1 = {
  535. .init = philips_tda827x_tuner_init,
  536. .sleep = philips_tda827x_tuner_sleep,
  537. .config = 1,
  538. .switch_addr = 0x4b
  539. };
  540. static struct tda827x_config tda827x_cfg_2 = {
  541. .init = philips_tda827x_tuner_init,
  542. .sleep = philips_tda827x_tuner_sleep,
  543. .config = 2,
  544. .switch_addr = 0x4b
  545. };
  546. static struct tda827x_config tda827x_cfg_2_sw42 = {
  547. .init = philips_tda827x_tuner_init,
  548. .sleep = philips_tda827x_tuner_sleep,
  549. .config = 2,
  550. .switch_addr = 0x42
  551. };
  552. /* ------------------------------------------------------------------ */
  553. static struct tda1004x_config tda827x_lifeview_config = {
  554. .demod_address = 0x08,
  555. .invert = 1,
  556. .invert_oclk = 0,
  557. .xtal_freq = TDA10046_XTAL_16M,
  558. .agc_config = TDA10046_AGC_TDA827X,
  559. .gpio_config = TDA10046_GP11_I,
  560. .if_freq = TDA10046_FREQ_045,
  561. .tuner_address = 0x60,
  562. .request_firmware = philips_tda1004x_request_firmware
  563. };
  564. static struct tda1004x_config philips_tiger_config = {
  565. .demod_address = 0x08,
  566. .invert = 1,
  567. .invert_oclk = 0,
  568. .xtal_freq = TDA10046_XTAL_16M,
  569. .agc_config = TDA10046_AGC_TDA827X,
  570. .gpio_config = TDA10046_GP11_I,
  571. .if_freq = TDA10046_FREQ_045,
  572. .i2c_gate = 0x4b,
  573. .tuner_address = 0x61,
  574. .antenna_switch= 1,
  575. .request_firmware = philips_tda1004x_request_firmware
  576. };
  577. static struct tda1004x_config cinergy_ht_config = {
  578. .demod_address = 0x08,
  579. .invert = 1,
  580. .invert_oclk = 0,
  581. .xtal_freq = TDA10046_XTAL_16M,
  582. .agc_config = TDA10046_AGC_TDA827X,
  583. .gpio_config = TDA10046_GP01_I,
  584. .if_freq = TDA10046_FREQ_045,
  585. .i2c_gate = 0x4b,
  586. .tuner_address = 0x61,
  587. .request_firmware = philips_tda1004x_request_firmware
  588. };
  589. static struct tda1004x_config cinergy_ht_pci_config = {
  590. .demod_address = 0x08,
  591. .invert = 1,
  592. .invert_oclk = 0,
  593. .xtal_freq = TDA10046_XTAL_16M,
  594. .agc_config = TDA10046_AGC_TDA827X,
  595. .gpio_config = TDA10046_GP01_I,
  596. .if_freq = TDA10046_FREQ_045,
  597. .i2c_gate = 0x4b,
  598. .tuner_address = 0x60,
  599. .request_firmware = philips_tda1004x_request_firmware
  600. };
  601. static struct tda1004x_config philips_tiger_s_config = {
  602. .demod_address = 0x08,
  603. .invert = 1,
  604. .invert_oclk = 0,
  605. .xtal_freq = TDA10046_XTAL_16M,
  606. .agc_config = TDA10046_AGC_TDA827X,
  607. .gpio_config = TDA10046_GP01_I,
  608. .if_freq = TDA10046_FREQ_045,
  609. .i2c_gate = 0x4b,
  610. .tuner_address = 0x61,
  611. .antenna_switch= 1,
  612. .request_firmware = philips_tda1004x_request_firmware
  613. };
  614. static struct tda1004x_config pinnacle_pctv_310i_config = {
  615. .demod_address = 0x08,
  616. .invert = 1,
  617. .invert_oclk = 0,
  618. .xtal_freq = TDA10046_XTAL_16M,
  619. .agc_config = TDA10046_AGC_TDA827X,
  620. .gpio_config = TDA10046_GP11_I,
  621. .if_freq = TDA10046_FREQ_045,
  622. .i2c_gate = 0x4b,
  623. .tuner_address = 0x61,
  624. .request_firmware = philips_tda1004x_request_firmware
  625. };
  626. static struct tda1004x_config hauppauge_hvr_1110_config = {
  627. .demod_address = 0x08,
  628. .invert = 1,
  629. .invert_oclk = 0,
  630. .xtal_freq = TDA10046_XTAL_16M,
  631. .agc_config = TDA10046_AGC_TDA827X,
  632. .gpio_config = TDA10046_GP11_I,
  633. .if_freq = TDA10046_FREQ_045,
  634. .i2c_gate = 0x4b,
  635. .tuner_address = 0x61,
  636. .request_firmware = philips_tda1004x_request_firmware
  637. };
  638. static struct tda1004x_config asus_p7131_dual_config = {
  639. .demod_address = 0x08,
  640. .invert = 1,
  641. .invert_oclk = 0,
  642. .xtal_freq = TDA10046_XTAL_16M,
  643. .agc_config = TDA10046_AGC_TDA827X,
  644. .gpio_config = TDA10046_GP11_I,
  645. .if_freq = TDA10046_FREQ_045,
  646. .i2c_gate = 0x4b,
  647. .tuner_address = 0x61,
  648. .antenna_switch= 2,
  649. .request_firmware = philips_tda1004x_request_firmware
  650. };
  651. static struct tda1004x_config lifeview_trio_config = {
  652. .demod_address = 0x09,
  653. .invert = 1,
  654. .invert_oclk = 0,
  655. .xtal_freq = TDA10046_XTAL_16M,
  656. .agc_config = TDA10046_AGC_TDA827X,
  657. .gpio_config = TDA10046_GP00_I,
  658. .if_freq = TDA10046_FREQ_045,
  659. .tuner_address = 0x60,
  660. .request_firmware = philips_tda1004x_request_firmware
  661. };
  662. static struct tda1004x_config tevion_dvbt220rf_config = {
  663. .demod_address = 0x08,
  664. .invert = 1,
  665. .invert_oclk = 0,
  666. .xtal_freq = TDA10046_XTAL_16M,
  667. .agc_config = TDA10046_AGC_TDA827X,
  668. .gpio_config = TDA10046_GP11_I,
  669. .if_freq = TDA10046_FREQ_045,
  670. .tuner_address = 0x60,
  671. .request_firmware = philips_tda1004x_request_firmware
  672. };
  673. static struct tda1004x_config md8800_dvbt_config = {
  674. .demod_address = 0x08,
  675. .invert = 1,
  676. .invert_oclk = 0,
  677. .xtal_freq = TDA10046_XTAL_16M,
  678. .agc_config = TDA10046_AGC_TDA827X,
  679. .gpio_config = TDA10046_GP01_I,
  680. .if_freq = TDA10046_FREQ_045,
  681. .i2c_gate = 0x4b,
  682. .tuner_address = 0x60,
  683. .request_firmware = philips_tda1004x_request_firmware
  684. };
  685. static struct tda1004x_config asus_p7131_4871_config = {
  686. .demod_address = 0x08,
  687. .invert = 1,
  688. .invert_oclk = 0,
  689. .xtal_freq = TDA10046_XTAL_16M,
  690. .agc_config = TDA10046_AGC_TDA827X,
  691. .gpio_config = TDA10046_GP01_I,
  692. .if_freq = TDA10046_FREQ_045,
  693. .i2c_gate = 0x4b,
  694. .tuner_address = 0x61,
  695. .antenna_switch= 2,
  696. .request_firmware = philips_tda1004x_request_firmware
  697. };
  698. static struct tda1004x_config asus_p7131_hybrid_lna_config = {
  699. .demod_address = 0x08,
  700. .invert = 1,
  701. .invert_oclk = 0,
  702. .xtal_freq = TDA10046_XTAL_16M,
  703. .agc_config = TDA10046_AGC_TDA827X,
  704. .gpio_config = TDA10046_GP11_I,
  705. .if_freq = TDA10046_FREQ_045,
  706. .i2c_gate = 0x4b,
  707. .tuner_address = 0x61,
  708. .antenna_switch= 2,
  709. .request_firmware = philips_tda1004x_request_firmware
  710. };
  711. static struct tda1004x_config kworld_dvb_t_210_config = {
  712. .demod_address = 0x08,
  713. .invert = 1,
  714. .invert_oclk = 0,
  715. .xtal_freq = TDA10046_XTAL_16M,
  716. .agc_config = TDA10046_AGC_TDA827X,
  717. .gpio_config = TDA10046_GP11_I,
  718. .if_freq = TDA10046_FREQ_045,
  719. .i2c_gate = 0x4b,
  720. .tuner_address = 0x61,
  721. .antenna_switch= 1,
  722. .request_firmware = philips_tda1004x_request_firmware
  723. };
  724. static struct tda1004x_config avermedia_super_007_config = {
  725. .demod_address = 0x08,
  726. .invert = 1,
  727. .invert_oclk = 0,
  728. .xtal_freq = TDA10046_XTAL_16M,
  729. .agc_config = TDA10046_AGC_TDA827X,
  730. .gpio_config = TDA10046_GP01_I,
  731. .if_freq = TDA10046_FREQ_045,
  732. .i2c_gate = 0x4b,
  733. .tuner_address = 0x60,
  734. .antenna_switch= 1,
  735. .request_firmware = philips_tda1004x_request_firmware
  736. };
  737. static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
  738. .demod_address = 0x08,
  739. .invert = 1,
  740. .invert_oclk = 0,
  741. .xtal_freq = TDA10046_XTAL_16M,
  742. .agc_config = TDA10046_AGC_TDA827X,
  743. .gpio_config = TDA10046_GP01_I,
  744. .if_freq = TDA10046_FREQ_045,
  745. .i2c_gate = 0x42,
  746. .tuner_address = 0x61,
  747. .antenna_switch = 1,
  748. .request_firmware = philips_tda1004x_request_firmware
  749. };
  750. static struct tda1004x_config asus_tiger_3in1_config = {
  751. .demod_address = 0x0b,
  752. .invert = 1,
  753. .invert_oclk = 0,
  754. .xtal_freq = TDA10046_XTAL_16M,
  755. .agc_config = TDA10046_AGC_TDA827X,
  756. .gpio_config = TDA10046_GP11_I,
  757. .if_freq = TDA10046_FREQ_045,
  758. .i2c_gate = 0x4b,
  759. .tuner_address = 0x61,
  760. .antenna_switch = 1,
  761. .request_firmware = philips_tda1004x_request_firmware
  762. };
  763. /* ------------------------------------------------------------------
  764. * special case: this card uses saa713x GPIO22 for the mode switch
  765. */
  766. static int ads_duo_tuner_init(struct dvb_frontend *fe)
  767. {
  768. struct saa7134_dev *dev = fe->dvb->priv;
  769. philips_tda827x_tuner_init(fe);
  770. /* route TDA8275a AGC input to the channel decoder */
  771. saa7134_set_gpio(dev, 22, 1);
  772. return 0;
  773. }
  774. static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
  775. {
  776. struct saa7134_dev *dev = fe->dvb->priv;
  777. /* route TDA8275a AGC input to the analog IF chip*/
  778. saa7134_set_gpio(dev, 22, 0);
  779. philips_tda827x_tuner_sleep(fe);
  780. return 0;
  781. }
  782. static struct tda827x_config ads_duo_cfg = {
  783. .init = ads_duo_tuner_init,
  784. .sleep = ads_duo_tuner_sleep,
  785. .config = 0
  786. };
  787. static struct tda1004x_config ads_tech_duo_config = {
  788. .demod_address = 0x08,
  789. .invert = 1,
  790. .invert_oclk = 0,
  791. .xtal_freq = TDA10046_XTAL_16M,
  792. .agc_config = TDA10046_AGC_TDA827X,
  793. .gpio_config = TDA10046_GP00_I,
  794. .if_freq = TDA10046_FREQ_045,
  795. .tuner_address = 0x61,
  796. .request_firmware = philips_tda1004x_request_firmware
  797. };
  798. static struct zl10353_config behold_h6_config = {
  799. .demod_address = 0x1e>>1,
  800. .no_tuner = 1,
  801. .parallel_ts = 1,
  802. .disable_i2c_gate_ctrl = 1,
  803. };
  804. static struct xc5000_config behold_x7_tunerconfig = {
  805. .i2c_address = 0xc2>>1,
  806. .if_khz = 4560,
  807. .radio_input = XC5000_RADIO_FM1,
  808. };
  809. static struct zl10353_config behold_x7_config = {
  810. .demod_address = 0x1e>>1,
  811. .if2 = 45600,
  812. .no_tuner = 1,
  813. .parallel_ts = 1,
  814. .disable_i2c_gate_ctrl = 1,
  815. };
  816. static struct zl10353_config videomate_t750_zl10353_config = {
  817. .demod_address = 0x0f,
  818. .no_tuner = 1,
  819. .parallel_ts = 1,
  820. .disable_i2c_gate_ctrl = 1,
  821. };
  822. static struct qt1010_config videomate_t750_qt1010_config = {
  823. .i2c_address = 0x62
  824. };
  825. /* ==================================================================
  826. * tda10086 based DVB-S cards, helper functions
  827. */
  828. static struct tda10086_config flydvbs = {
  829. .demod_address = 0x0e,
  830. .invert = 0,
  831. .diseqc_tone = 0,
  832. .xtal_freq = TDA10086_XTAL_16M,
  833. };
  834. static struct tda10086_config sd1878_4m = {
  835. .demod_address = 0x0e,
  836. .invert = 0,
  837. .diseqc_tone = 0,
  838. .xtal_freq = TDA10086_XTAL_4M,
  839. };
  840. /* ------------------------------------------------------------------
  841. * special case: lnb supply is connected to the gated i2c
  842. */
  843. static int md8800_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
  844. {
  845. int res = -EIO;
  846. struct saa7134_dev *dev = fe->dvb->priv;
  847. if (fe->ops.i2c_gate_ctrl) {
  848. fe->ops.i2c_gate_ctrl(fe, 1);
  849. if (dev->original_set_voltage)
  850. res = dev->original_set_voltage(fe, voltage);
  851. fe->ops.i2c_gate_ctrl(fe, 0);
  852. }
  853. return res;
  854. };
  855. static int md8800_set_high_voltage(struct dvb_frontend *fe, long arg)
  856. {
  857. int res = -EIO;
  858. struct saa7134_dev *dev = fe->dvb->priv;
  859. if (fe->ops.i2c_gate_ctrl) {
  860. fe->ops.i2c_gate_ctrl(fe, 1);
  861. if (dev->original_set_high_voltage)
  862. res = dev->original_set_high_voltage(fe, arg);
  863. fe->ops.i2c_gate_ctrl(fe, 0);
  864. }
  865. return res;
  866. };
  867. static int md8800_set_voltage2(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
  868. {
  869. struct saa7134_dev *dev = fe->dvb->priv;
  870. u8 wbuf[2] = { 0x1f, 00 };
  871. u8 rbuf;
  872. struct i2c_msg msg[] = { { .addr = 0x08, .flags = 0, .buf = wbuf, .len = 1 },
  873. { .addr = 0x08, .flags = I2C_M_RD, .buf = &rbuf, .len = 1 } };
  874. if (i2c_transfer(&dev->i2c_adap, msg, 2) != 2)
  875. return -EIO;
  876. /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
  877. if (voltage == SEC_VOLTAGE_18)
  878. wbuf[1] = rbuf | 0x10;
  879. else
  880. wbuf[1] = rbuf & 0xef;
  881. msg[0].len = 2;
  882. i2c_transfer(&dev->i2c_adap, msg, 1);
  883. return 0;
  884. }
  885. static int md8800_set_high_voltage2(struct dvb_frontend *fe, long arg)
  886. {
  887. struct saa7134_dev *dev = fe->dvb->priv;
  888. wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__);
  889. return -EIO;
  890. }
  891. /* ==================================================================
  892. * nxt200x based ATSC cards, helper functions
  893. */
  894. static struct nxt200x_config avertvhda180 = {
  895. .demod_address = 0x0a,
  896. };
  897. static struct nxt200x_config kworldatsc110 = {
  898. .demod_address = 0x0a,
  899. };
  900. /* ------------------------------------------------------------------ */
  901. static struct mt312_config avertv_a700_mt312 = {
  902. .demod_address = 0x0e,
  903. .voltage_inverted = 1,
  904. };
  905. static struct zl10036_config avertv_a700_tuner = {
  906. .tuner_address = 0x60,
  907. };
  908. static struct mt312_config zl10313_compro_s350_config = {
  909. .demod_address = 0x0e,
  910. };
  911. static struct lgdt3305_config hcw_lgdt3305_config = {
  912. .i2c_addr = 0x0e,
  913. .mpeg_mode = LGDT3305_MPEG_SERIAL,
  914. .tpclk_edge = LGDT3305_TPCLK_RISING_EDGE,
  915. .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
  916. .deny_i2c_rptr = 1,
  917. .spectral_inversion = 1,
  918. .qam_if_khz = 4000,
  919. .vsb_if_khz = 3250,
  920. };
  921. static struct tda10048_config hcw_tda10048_config = {
  922. .demod_address = 0x10 >> 1,
  923. .output_mode = TDA10048_SERIAL_OUTPUT,
  924. .fwbulkwritelen = TDA10048_BULKWRITE_200,
  925. .inversion = TDA10048_INVERSION_ON,
  926. .dtv6_if_freq_khz = TDA10048_IF_3300,
  927. .dtv7_if_freq_khz = TDA10048_IF_3500,
  928. .dtv8_if_freq_khz = TDA10048_IF_4000,
  929. .clk_freq_khz = TDA10048_CLK_16000,
  930. .disable_gate_access = 1,
  931. };
  932. static struct tda18271_std_map hauppauge_tda18271_std_map = {
  933. .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4,
  934. .if_lvl = 1, .rfagc_top = 0x58, },
  935. .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5,
  936. .if_lvl = 1, .rfagc_top = 0x58, },
  937. };
  938. static struct tda18271_config hcw_tda18271_config = {
  939. .std_map = &hauppauge_tda18271_std_map,
  940. .gate = TDA18271_GATE_ANALOG,
  941. .config = 3,
  942. .output_opt = TDA18271_OUTPUT_LT_OFF,
  943. };
  944. static struct tda829x_config tda829x_no_probe = {
  945. .probe_tuner = TDA829X_DONT_PROBE,
  946. };
  947. static struct tda10048_config zolid_tda10048_config = {
  948. .demod_address = 0x10 >> 1,
  949. .output_mode = TDA10048_PARALLEL_OUTPUT,
  950. .fwbulkwritelen = TDA10048_BULKWRITE_200,
  951. .inversion = TDA10048_INVERSION_ON,
  952. .dtv6_if_freq_khz = TDA10048_IF_3300,
  953. .dtv7_if_freq_khz = TDA10048_IF_3500,
  954. .dtv8_if_freq_khz = TDA10048_IF_4000,
  955. .clk_freq_khz = TDA10048_CLK_16000,
  956. .disable_gate_access = 1,
  957. };
  958. static struct tda18271_config zolid_tda18271_config = {
  959. .gate = TDA18271_GATE_ANALOG,
  960. };
  961. static struct tda10048_config dtv1000s_tda10048_config = {
  962. .demod_address = 0x10 >> 1,
  963. .output_mode = TDA10048_PARALLEL_OUTPUT,
  964. .fwbulkwritelen = TDA10048_BULKWRITE_200,
  965. .inversion = TDA10048_INVERSION_ON,
  966. .dtv6_if_freq_khz = TDA10048_IF_3300,
  967. .dtv7_if_freq_khz = TDA10048_IF_3800,
  968. .dtv8_if_freq_khz = TDA10048_IF_4300,
  969. .clk_freq_khz = TDA10048_CLK_16000,
  970. .disable_gate_access = 1,
  971. };
  972. static struct tda18271_std_map dtv1000s_tda18271_std_map = {
  973. .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4,
  974. .if_lvl = 1, .rfagc_top = 0x37, },
  975. .dvbt_7 = { .if_freq = 3800, .agc_mode = 3, .std = 5,
  976. .if_lvl = 1, .rfagc_top = 0x37, },
  977. .dvbt_8 = { .if_freq = 4300, .agc_mode = 3, .std = 6,
  978. .if_lvl = 1, .rfagc_top = 0x37, },
  979. };
  980. static struct tda18271_config dtv1000s_tda18271_config = {
  981. .std_map = &dtv1000s_tda18271_std_map,
  982. .gate = TDA18271_GATE_ANALOG,
  983. };
  984. static struct lgs8gxx_config prohdtv_pro2_lgs8g75_config = {
  985. .prod = LGS8GXX_PROD_LGS8G75,
  986. .demod_address = 0x1d,
  987. .serial_ts = 0,
  988. .ts_clk_pol = 1,
  989. .ts_clk_gated = 0,
  990. .if_clk_freq = 30400, /* 30.4 MHz */
  991. .if_freq = 4000, /* 4.00 MHz */
  992. .if_neg_center = 0,
  993. .ext_adc = 0,
  994. .adc_signed = 1,
  995. .adc_vpp = 3, /* 2.0 Vpp */
  996. .if_neg_edge = 1,
  997. };
  998. static struct tda18271_config prohdtv_pro2_tda18271_config = {
  999. .gate = TDA18271_GATE_ANALOG,
  1000. .output_opt = TDA18271_OUTPUT_LT_OFF,
  1001. };
  1002. /* ==================================================================
  1003. * Core code
  1004. */
  1005. static int dvb_init(struct saa7134_dev *dev)
  1006. {
  1007. int ret;
  1008. int attach_xc3028 = 0;
  1009. struct videobuf_dvb_frontend *fe0;
  1010. /* FIXME: add support for multi-frontend */
  1011. mutex_init(&dev->frontends.lock);
  1012. INIT_LIST_HEAD(&dev->frontends.felist);
  1013. printk(KERN_INFO "%s() allocating 1 frontend\n", __func__);
  1014. fe0 = videobuf_dvb_alloc_frontend(&dev->frontends, 1);
  1015. if (!fe0) {
  1016. printk(KERN_ERR "%s() failed to alloc\n", __func__);
  1017. return -ENOMEM;
  1018. }
  1019. /* init struct videobuf_dvb */
  1020. dev->ts.nr_bufs = 32;
  1021. dev->ts.nr_packets = 32*4;
  1022. fe0->dvb.name = dev->name;
  1023. videobuf_queue_sg_init(&fe0->dvb.dvbq, &saa7134_ts_qops,
  1024. &dev->pci->dev, &dev->slock,
  1025. V4L2_BUF_TYPE_VIDEO_CAPTURE,
  1026. V4L2_FIELD_ALTERNATE,
  1027. sizeof(struct saa7134_buf),
  1028. dev, NULL);
  1029. switch (dev->board) {
  1030. case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
  1031. dprintk("pinnacle 300i dvb setup\n");
  1032. fe0->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
  1033. &dev->i2c_adap);
  1034. if (fe0->dvb.frontend) {
  1035. fe0->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
  1036. }
  1037. break;
  1038. case SAA7134_BOARD_AVERMEDIA_777:
  1039. case SAA7134_BOARD_AVERMEDIA_A16AR:
  1040. dprintk("avertv 777 dvb setup\n");
  1041. fe0->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
  1042. &dev->i2c_adap);
  1043. if (fe0->dvb.frontend) {
  1044. dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
  1045. &dev->i2c_adap, 0x61,
  1046. TUNER_PHILIPS_TD1316);
  1047. }
  1048. break;
  1049. case SAA7134_BOARD_AVERMEDIA_A16D:
  1050. dprintk("AverMedia A16D dvb setup\n");
  1051. fe0->dvb.frontend = dvb_attach(mt352_attach,
  1052. &avermedia_xc3028_mt352_dev,
  1053. &dev->i2c_adap);
  1054. attach_xc3028 = 1;
  1055. break;
  1056. case SAA7134_BOARD_MD7134:
  1057. fe0->dvb.frontend = dvb_attach(tda10046_attach,
  1058. &medion_cardbus,
  1059. &dev->i2c_adap);
  1060. if (fe0->dvb.frontend) {
  1061. dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
  1062. &dev->i2c_adap, medion_cardbus.tuner_address,
  1063. TUNER_PHILIPS_FMD1216ME_MK3);
  1064. }
  1065. break;
  1066. case SAA7134_BOARD_PHILIPS_TOUGH:
  1067. fe0->dvb.frontend = dvb_attach(tda10046_attach,
  1068. &philips_tu1216_60_config,
  1069. &dev->i2c_adap);
  1070. if (fe0->dvb.frontend) {
  1071. fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
  1072. fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
  1073. }
  1074. break;
  1075. case SAA7134_BOARD_FLYDVBTDUO:
  1076. case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
  1077. if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
  1078. &tda827x_cfg_0) < 0)
  1079. goto dettach_frontend;
  1080. break;
  1081. case SAA7134_BOARD_PHILIPS_EUROPA:
  1082. case SAA7134_BOARD_VIDEOMATE_DVBT_300:
  1083. case SAA7134_BOARD_ASUS_EUROPA_HYBRID:
  1084. fe0->dvb.frontend = dvb_attach(tda10046_attach,
  1085. &philips_europa_config,
  1086. &dev->i2c_adap);
  1087. if (fe0->dvb.frontend) {
  1088. dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
  1089. fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
  1090. fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
  1091. fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
  1092. fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
  1093. }
  1094. break;
  1095. case SAA7134_BOARD_TECHNOTREND_BUDGET_T3000:
  1096. fe0->dvb.frontend = dvb_attach(tda10046_attach,
  1097. &technotrend_budget_t3000_config,
  1098. &dev->i2c_adap);
  1099. if (fe0->dvb.frontend) {
  1100. dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
  1101. fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
  1102. fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
  1103. fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
  1104. fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
  1105. }
  1106. break;
  1107. case SAA7134_BOARD_VIDEOMATE_DVBT_200:
  1108. fe0->dvb.frontend = dvb_attach(tda10046_attach,
  1109. &philips_tu1216_61_config,
  1110. &dev->i2c_adap);
  1111. if (fe0->dvb.frontend) {
  1112. fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
  1113. fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
  1114. }
  1115. break;
  1116. case SAA7134_BOARD_KWORLD_DVBT_210:
  1117. if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config,
  1118. &tda827x_cfg_2) < 0)
  1119. goto dettach_frontend;
  1120. break;
  1121. case SAA7134_BOARD_HAUPPAUGE_HVR1120:
  1122. fe0->dvb.frontend = dvb_attach(tda10048_attach,
  1123. &hcw_tda10048_config,
  1124. &dev->i2c_adap);
  1125. if (fe0->dvb.frontend != NULL) {
  1126. dvb_attach(tda829x_attach, fe0->dvb.frontend,
  1127. &dev->i2c_adap, 0x4b,
  1128. &tda829x_no_probe);
  1129. dvb_attach(tda18271_attach, fe0->dvb.frontend,
  1130. 0x60, &dev->i2c_adap,
  1131. &hcw_tda18271_config);
  1132. }
  1133. break;
  1134. case SAA7134_BOARD_PHILIPS_TIGER:
  1135. if (configure_tda827x_fe(dev, &philips_tiger_config,
  1136. &tda827x_cfg_0) < 0)
  1137. goto dettach_frontend;
  1138. break;
  1139. case SAA7134_BOARD_PINNACLE_PCTV_310i:
  1140. if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config,
  1141. &tda827x_cfg_1) < 0)
  1142. goto dettach_frontend;
  1143. break;
  1144. case SAA7134_BOARD_HAUPPAUGE_HVR1110:
  1145. if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config,
  1146. &tda827x_cfg_1) < 0)
  1147. goto dettach_frontend;
  1148. break;
  1149. case SAA7134_BOARD_HAUPPAUGE_HVR1150:
  1150. fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
  1151. &hcw_lgdt3305_config,
  1152. &dev->i2c_adap);
  1153. if (fe0->dvb.frontend) {
  1154. dvb_attach(tda829x_attach, fe0->dvb.frontend,
  1155. &dev->i2c_adap, 0x4b,
  1156. &tda829x_no_probe);
  1157. dvb_attach(tda18271_attach, fe0->dvb.frontend,
  1158. 0x60, &dev->i2c_adap,
  1159. &hcw_tda18271_config);
  1160. }
  1161. break;
  1162. case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
  1163. if (configure_tda827x_fe(dev, &asus_p7131_dual_config,
  1164. &tda827x_cfg_0) < 0)
  1165. goto dettach_frontend;
  1166. break;
  1167. case SAA7134_BOARD_FLYDVBT_LR301:
  1168. if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
  1169. &tda827x_cfg_0) < 0)
  1170. goto dettach_frontend;
  1171. break;
  1172. case SAA7134_BOARD_FLYDVB_TRIO:
  1173. if (!use_frontend) { /* terrestrial */
  1174. if (configure_tda827x_fe(dev, &lifeview_trio_config,
  1175. &tda827x_cfg_0) < 0)
  1176. goto dettach_frontend;
  1177. } else { /* satellite */
  1178. fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
  1179. if (fe0->dvb.frontend) {
  1180. if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x63,
  1181. &dev->i2c_adap, 0) == NULL) {
  1182. wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__);
  1183. goto dettach_frontend;
  1184. }
  1185. if (dvb_attach(isl6421_attach, fe0->dvb.frontend, &dev->i2c_adap,
  1186. 0x08, 0, 0) == NULL) {
  1187. wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__);
  1188. goto dettach_frontend;
  1189. }
  1190. }
  1191. }
  1192. break;
  1193. case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
  1194. case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
  1195. fe0->dvb.frontend = dvb_attach(tda10046_attach,
  1196. &ads_tech_duo_config,
  1197. &dev->i2c_adap);
  1198. if (fe0->dvb.frontend) {
  1199. if (dvb_attach(tda827x_attach,fe0->dvb.frontend,
  1200. ads_tech_duo_config.tuner_address, &dev->i2c_adap,
  1201. &ads_duo_cfg) == NULL) {
  1202. wprintk("no tda827x tuner found at addr: %02x\n",
  1203. ads_tech_duo_config.tuner_address);
  1204. goto dettach_frontend;
  1205. }
  1206. } else
  1207. wprintk("failed to attach tda10046\n");
  1208. break;
  1209. case SAA7134_BOARD_TEVION_DVBT_220RF:
  1210. if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config,
  1211. &tda827x_cfg_0) < 0)
  1212. goto dettach_frontend;
  1213. break;
  1214. case SAA7134_BOARD_MEDION_MD8800_QUADRO:
  1215. if (!use_frontend) { /* terrestrial */
  1216. if (configure_tda827x_fe(dev, &md8800_dvbt_config,
  1217. &tda827x_cfg_0) < 0)
  1218. goto dettach_frontend;
  1219. } else { /* satellite */
  1220. fe0->dvb.frontend = dvb_attach(tda10086_attach,
  1221. &flydvbs, &dev->i2c_adap);
  1222. if (fe0->dvb.frontend) {
  1223. struct dvb_frontend *fe = fe0->dvb.frontend;
  1224. u8 dev_id = dev->eedata[2];
  1225. u8 data = 0xc4;
  1226. struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};
  1227. if (dvb_attach(tda826x_attach, fe0->dvb.frontend,
  1228. 0x60, &dev->i2c_adap, 0) == NULL) {
  1229. wprintk("%s: Medion Quadro, no tda826x "
  1230. "found !\n", __func__);
  1231. goto dettach_frontend;
  1232. }
  1233. if (dev_id != 0x08) {
  1234. /* we need to open the i2c gate (we know it exists) */
  1235. fe->ops.i2c_gate_ctrl(fe, 1);
  1236. if (dvb_attach(isl6405_attach, fe,
  1237. &dev->i2c_adap, 0x08, 0, 0) == NULL) {
  1238. wprintk("%s: Medion Quadro, no ISL6405 "
  1239. "found !\n", __func__);
  1240. goto dettach_frontend;
  1241. }
  1242. if (dev_id == 0x07) {
  1243. /* fire up the 2nd section of the LNB supply since
  1244. we can't do this from the other section */
  1245. msg.buf = &data;
  1246. i2c_transfer(&dev->i2c_adap, &msg, 1);
  1247. }
  1248. fe->ops.i2c_gate_ctrl(fe, 0);
  1249. dev->original_set_voltage = fe->ops.set_voltage;
  1250. fe->ops.set_voltage = md8800_set_voltage;
  1251. dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
  1252. fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
  1253. } else {
  1254. fe->ops.set_voltage = md8800_set_voltage2;
  1255. fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage2;
  1256. }
  1257. }
  1258. }
  1259. break;
  1260. case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
  1261. fe0->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
  1262. &dev->i2c_adap);
  1263. if (fe0->dvb.frontend)
  1264. dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x61,
  1265. NULL, DVB_PLL_TDHU2);
  1266. break;
  1267. case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI:
  1268. case SAA7134_BOARD_KWORLD_ATSC110:
  1269. fe0->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
  1270. &dev->i2c_adap);
  1271. if (fe0->dvb.frontend)
  1272. dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
  1273. &dev->i2c_adap, 0x61,
  1274. TUNER_PHILIPS_TUV1236D);
  1275. break;
  1276. case SAA7134_BOARD_FLYDVBS_LR300:
  1277. fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
  1278. &dev->i2c_adap);
  1279. if (fe0->dvb.frontend) {
  1280. if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
  1281. &dev->i2c_adap, 0) == NULL) {
  1282. wprintk("%s: No tda826x found!\n", __func__);
  1283. goto dettach_frontend;
  1284. }
  1285. if (dvb_attach(isl6421_attach, fe0->dvb.frontend,
  1286. &dev->i2c_adap, 0x08, 0, 0) == NULL) {
  1287. wprintk("%s: No ISL6421 found!\n", __func__);
  1288. goto dettach_frontend;
  1289. }
  1290. }
  1291. break;
  1292. case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
  1293. fe0->dvb.frontend = dvb_attach(tda10046_attach,
  1294. &medion_cardbus,
  1295. &dev->i2c_adap);
  1296. if (fe0->dvb.frontend) {
  1297. dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
  1298. fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
  1299. dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
  1300. &dev->i2c_adap, medion_cardbus.tuner_address,
  1301. TUNER_PHILIPS_FMD1216ME_MK3);
  1302. }
  1303. break;
  1304. case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
  1305. fe0->dvb.frontend = dvb_attach(tda10046_attach,
  1306. &philips_europa_config,
  1307. &dev->i2c_adap);
  1308. if (fe0->dvb.frontend) {
  1309. fe0->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
  1310. fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
  1311. }
  1312. break;
  1313. case SAA7134_BOARD_CINERGY_HT_PCMCIA:
  1314. if (configure_tda827x_fe(dev, &cinergy_ht_config,
  1315. &tda827x_cfg_0) < 0)
  1316. goto dettach_frontend;
  1317. break;
  1318. case SAA7134_BOARD_CINERGY_HT_PCI:
  1319. if (configure_tda827x_fe(dev, &cinergy_ht_pci_config,
  1320. &tda827x_cfg_0) < 0)
  1321. goto dettach_frontend;
  1322. break;
  1323. case SAA7134_BOARD_PHILIPS_TIGER_S:
  1324. if (configure_tda827x_fe(dev, &philips_tiger_s_config,
  1325. &tda827x_cfg_2) < 0)
  1326. goto dettach_frontend;
  1327. break;
  1328. case SAA7134_BOARD_ASUS_P7131_4871:
  1329. if (configure_tda827x_fe(dev, &asus_p7131_4871_config,
  1330. &tda827x_cfg_2) < 0)
  1331. goto dettach_frontend;
  1332. break;
  1333. case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
  1334. if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config,
  1335. &tda827x_cfg_2) < 0)
  1336. goto dettach_frontend;
  1337. break;
  1338. case SAA7134_BOARD_AVERMEDIA_SUPER_007:
  1339. if (configure_tda827x_fe(dev, &avermedia_super_007_config,
  1340. &tda827x_cfg_0) < 0)
  1341. goto dettach_frontend;
  1342. break;
  1343. case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
  1344. if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config,
  1345. &tda827x_cfg_2_sw42) < 0)
  1346. goto dettach_frontend;
  1347. break;
  1348. case SAA7134_BOARD_PHILIPS_SNAKE:
  1349. fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
  1350. &dev->i2c_adap);
  1351. if (fe0->dvb.frontend) {
  1352. if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
  1353. &dev->i2c_adap, 0) == NULL) {
  1354. wprintk("%s: No tda826x found!\n", __func__);
  1355. goto dettach_frontend;
  1356. }
  1357. if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
  1358. &dev->i2c_adap, 0, 0) == NULL) {
  1359. wprintk("%s: No lnbp21 found!\n", __func__);
  1360. goto dettach_frontend;
  1361. }
  1362. }
  1363. break;
  1364. case SAA7134_BOARD_CREATIX_CTX953:
  1365. if (configure_tda827x_fe(dev, &md8800_dvbt_config,
  1366. &tda827x_cfg_0) < 0)
  1367. goto dettach_frontend;
  1368. break;
  1369. case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
  1370. if (configure_tda827x_fe(dev, &philips_tiger_s_config,
  1371. &tda827x_cfg_2) < 0)
  1372. goto dettach_frontend;
  1373. break;
  1374. case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
  1375. dprintk("AverMedia E506R dvb setup\n");
  1376. saa7134_set_gpio(dev, 25, 0);
  1377. msleep(10);
  1378. saa7134_set_gpio(dev, 25, 1);
  1379. fe0->dvb.frontend = dvb_attach(mt352_attach,
  1380. &avermedia_xc3028_mt352_dev,
  1381. &dev->i2c_adap);
  1382. attach_xc3028 = 1;
  1383. break;
  1384. case SAA7134_BOARD_MD7134_BRIDGE_2:
  1385. fe0->dvb.frontend = dvb_attach(tda10086_attach,
  1386. &sd1878_4m, &dev->i2c_adap);
  1387. if (fe0->dvb.frontend) {
  1388. struct dvb_frontend *fe;
  1389. if (dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
  1390. &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) {
  1391. wprintk("%s: MD7134 DVB-S, no SD1878 "
  1392. "found !\n", __func__);
  1393. goto dettach_frontend;
  1394. }
  1395. /* we need to open the i2c gate (we know it exists) */
  1396. fe = fe0->dvb.frontend;
  1397. fe->ops.i2c_gate_ctrl(fe, 1);
  1398. if (dvb_attach(isl6405_attach, fe,
  1399. &dev->i2c_adap, 0x08, 0, 0) == NULL) {
  1400. wprintk("%s: MD7134 DVB-S, no ISL6405 "
  1401. "found !\n", __func__);
  1402. goto dettach_frontend;
  1403. }
  1404. fe->ops.i2c_gate_ctrl(fe, 0);
  1405. dev->original_set_voltage = fe->ops.set_voltage;
  1406. fe->ops.set_voltage = md8800_set_voltage;
  1407. dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
  1408. fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
  1409. }
  1410. break;
  1411. case SAA7134_BOARD_AVERMEDIA_M103:
  1412. saa7134_set_gpio(dev, 25, 0);
  1413. msleep(10);
  1414. saa7134_set_gpio(dev, 25, 1);
  1415. fe0->dvb.frontend = dvb_attach(mt352_attach,
  1416. &avermedia_xc3028_mt352_dev,
  1417. &dev->i2c_adap);
  1418. attach_xc3028 = 1;
  1419. break;
  1420. case SAA7134_BOARD_ASUSTeK_TIGER_3IN1:
  1421. if (!use_frontend) { /* terrestrial */
  1422. if (configure_tda827x_fe(dev, &asus_tiger_3in1_config,
  1423. &tda827x_cfg_2) < 0)
  1424. goto dettach_frontend;
  1425. } else { /* satellite */
  1426. fe0->dvb.frontend = dvb_attach(tda10086_attach,
  1427. &flydvbs, &dev->i2c_adap);
  1428. if (fe0->dvb.frontend) {
  1429. if (dvb_attach(tda826x_attach,
  1430. fe0->dvb.frontend, 0x60,
  1431. &dev->i2c_adap, 0) == NULL) {
  1432. wprintk("%s: Asus Tiger 3in1, no "
  1433. "tda826x found!\n", __func__);
  1434. goto dettach_frontend;
  1435. }
  1436. if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
  1437. &dev->i2c_adap, 0, 0) == NULL) {
  1438. wprintk("%s: Asus Tiger 3in1, no lnbp21"
  1439. " found!\n", __func__);
  1440. goto dettach_frontend;
  1441. }
  1442. }
  1443. }
  1444. break;
  1445. case SAA7134_BOARD_ASUSTeK_TIGER:
  1446. if (configure_tda827x_fe(dev, &philips_tiger_config,
  1447. &tda827x_cfg_0) < 0)
  1448. goto dettach_frontend;
  1449. break;
  1450. case SAA7134_BOARD_BEHOLD_H6:
  1451. fe0->dvb.frontend = dvb_attach(zl10353_attach,
  1452. &behold_h6_config,
  1453. &dev->i2c_adap);
  1454. if (fe0->dvb.frontend) {
  1455. dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
  1456. &dev->i2c_adap, 0x61,
  1457. TUNER_PHILIPS_FMD1216MEX_MK3);
  1458. }
  1459. break;
  1460. case SAA7134_BOARD_BEHOLD_X7:
  1461. fe0->dvb.frontend = dvb_attach(zl10353_attach,
  1462. &behold_x7_config,
  1463. &dev->i2c_adap);
  1464. if (fe0->dvb.frontend) {
  1465. dvb_attach(xc5000_attach, fe0->dvb.frontend,
  1466. &dev->i2c_adap, &behold_x7_tunerconfig);
  1467. }
  1468. break;
  1469. case SAA7134_BOARD_BEHOLD_H7:
  1470. fe0->dvb.frontend = dvb_attach(zl10353_attach,
  1471. &behold_x7_config,
  1472. &dev->i2c_adap);
  1473. if (fe0->dvb.frontend) {
  1474. dvb_attach(xc5000_attach, fe0->dvb.frontend,
  1475. &dev->i2c_adap, &behold_x7_tunerconfig);
  1476. }
  1477. break;
  1478. case SAA7134_BOARD_AVERMEDIA_A700_PRO:
  1479. case SAA7134_BOARD_AVERMEDIA_A700_HYBRID:
  1480. /* Zarlink ZL10313 */
  1481. fe0->dvb.frontend = dvb_attach(mt312_attach,
  1482. &avertv_a700_mt312, &dev->i2c_adap);
  1483. if (fe0->dvb.frontend) {
  1484. if (dvb_attach(zl10036_attach, fe0->dvb.frontend,
  1485. &avertv_a700_tuner, &dev->i2c_adap) == NULL) {
  1486. wprintk("%s: No zl10036 found!\n",
  1487. __func__);
  1488. }
  1489. }
  1490. break;
  1491. case SAA7134_BOARD_VIDEOMATE_S350:
  1492. fe0->dvb.frontend = dvb_attach(mt312_attach,
  1493. &zl10313_compro_s350_config, &dev->i2c_adap);
  1494. if (fe0->dvb.frontend)
  1495. if (dvb_attach(zl10039_attach, fe0->dvb.frontend,
  1496. 0x60, &dev->i2c_adap) == NULL)
  1497. wprintk("%s: No zl10039 found!\n",
  1498. __func__);
  1499. break;
  1500. case SAA7134_BOARD_VIDEOMATE_T750:
  1501. fe0->dvb.frontend = dvb_attach(zl10353_attach,
  1502. &videomate_t750_zl10353_config,
  1503. &dev->i2c_adap);
  1504. if (fe0->dvb.frontend != NULL) {
  1505. if (dvb_attach(qt1010_attach,
  1506. fe0->dvb.frontend,
  1507. &dev->i2c_adap,
  1508. &videomate_t750_qt1010_config) == NULL)
  1509. wprintk("error attaching QT1010\n");
  1510. }
  1511. break;
  1512. case SAA7134_BOARD_ZOLID_HYBRID_PCI:
  1513. fe0->dvb.frontend = dvb_attach(tda10048_attach,
  1514. &zolid_tda10048_config,
  1515. &dev->i2c_adap);
  1516. if (fe0->dvb.frontend != NULL) {
  1517. dvb_attach(tda829x_attach, fe0->dvb.frontend,
  1518. &dev->i2c_adap, 0x4b,
  1519. &tda829x_no_probe);
  1520. dvb_attach(tda18271_attach, fe0->dvb.frontend,
  1521. 0x60, &dev->i2c_adap,
  1522. &zolid_tda18271_config);
  1523. }
  1524. break;
  1525. case SAA7134_BOARD_LEADTEK_WINFAST_DTV1000S:
  1526. fe0->dvb.frontend = dvb_attach(tda10048_attach,
  1527. &dtv1000s_tda10048_config,
  1528. &dev->i2c_adap);
  1529. if (fe0->dvb.frontend != NULL) {
  1530. dvb_attach(tda829x_attach, fe0->dvb.frontend,
  1531. &dev->i2c_adap, 0x4b,
  1532. &tda829x_no_probe);
  1533. dvb_attach(tda18271_attach, fe0->dvb.frontend,
  1534. 0x60, &dev->i2c_adap,
  1535. &dtv1000s_tda18271_config);
  1536. }
  1537. break;
  1538. case SAA7134_BOARD_KWORLD_PCI_SBTVD_FULLSEG:
  1539. /* Switch to digital mode */
  1540. saa7134_tuner_callback(dev, 0,
  1541. TDA18271_CALLBACK_CMD_AGC_ENABLE, 1);
  1542. fe0->dvb.frontend = dvb_attach(mb86a20s_attach,
  1543. &kworld_mb86a20s_config,
  1544. &dev->i2c_adap);
  1545. if (fe0->dvb.frontend != NULL) {
  1546. dvb_attach(tda829x_attach, fe0->dvb.frontend,
  1547. &dev->i2c_adap, 0x4b,
  1548. &tda829x_no_probe);
  1549. dvb_attach(tda18271_attach, fe0->dvb.frontend,
  1550. 0x60, &dev->i2c_adap,
  1551. &kworld_tda18271_config);
  1552. fe0->dvb.frontend->ops.i2c_gate_ctrl = kworld_sbtvd_gate_ctrl;
  1553. }
  1554. /* mb86a20s need to use the I2C gateway */
  1555. break;
  1556. case SAA7134_BOARD_MAGICPRO_PROHDTV_PRO2:
  1557. fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
  1558. &prohdtv_pro2_lgs8g75_config,
  1559. &dev->i2c_adap);
  1560. if (fe0->dvb.frontend != NULL) {
  1561. dvb_attach(tda829x_attach, fe0->dvb.frontend,
  1562. &dev->i2c_adap, 0x4b,
  1563. &tda829x_no_probe);
  1564. dvb_attach(tda18271_attach, fe0->dvb.frontend,
  1565. 0x60, &dev->i2c_adap,
  1566. &prohdtv_pro2_tda18271_config);
  1567. }
  1568. break;
  1569. default:
  1570. wprintk("Huh? unknown DVB card?\n");
  1571. break;
  1572. }
  1573. if (attach_xc3028) {
  1574. struct dvb_frontend *fe;
  1575. struct xc2028_config cfg = {
  1576. .i2c_adap = &dev->i2c_adap,
  1577. .i2c_addr = 0x61,
  1578. };
  1579. if (!fe0->dvb.frontend)
  1580. goto dettach_frontend;
  1581. fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
  1582. if (!fe) {
  1583. printk(KERN_ERR "%s/2: xc3028 attach failed\n",
  1584. dev->name);
  1585. goto dettach_frontend;
  1586. }
  1587. }
  1588. if (NULL == fe0->dvb.frontend) {
  1589. printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
  1590. goto dettach_frontend;
  1591. }
  1592. /* define general-purpose callback pointer */
  1593. fe0->dvb.frontend->callback = saa7134_tuner_callback;
  1594. /* register everything else */
  1595. ret = videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
  1596. &dev->pci->dev, adapter_nr, 0, NULL);
  1597. /* this sequence is necessary to make the tda1004x load its firmware
  1598. * and to enter analog mode of hybrid boards
  1599. */
  1600. if (!ret) {
  1601. if (fe0->dvb.frontend->ops.init)
  1602. fe0->dvb.frontend->ops.init(fe0->dvb.frontend);
  1603. if (fe0->dvb.frontend->ops.sleep)
  1604. fe0->dvb.frontend->ops.sleep(fe0->dvb.frontend);
  1605. if (fe0->dvb.frontend->ops.tuner_ops.sleep)
  1606. fe0->dvb.frontend->ops.tuner_ops.sleep(fe0->dvb.frontend);
  1607. }
  1608. return ret;
  1609. dettach_frontend:
  1610. videobuf_dvb_dealloc_frontends(&dev->frontends);
  1611. return -EINVAL;
  1612. }
  1613. static int dvb_fini(struct saa7134_dev *dev)
  1614. {
  1615. struct videobuf_dvb_frontend *fe0;
  1616. /* Get the first frontend */
  1617. fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
  1618. if (!fe0)
  1619. return -EINVAL;
  1620. /* FIXME: I suspect that this code is bogus, since the entry for
  1621. Pinnacle 300I DVB-T PAL already defines the proper init to allow
  1622. the detection of mt2032 (TDA9887_PORT2_INACTIVE)
  1623. */
  1624. if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
  1625. struct v4l2_priv_tun_config tda9887_cfg;
  1626. static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
  1627. tda9887_cfg.tuner = TUNER_TDA9887;
  1628. tda9887_cfg.priv = &on;
  1629. /* otherwise we don't detect the tuner on next insmod */
  1630. saa_call_all(dev, tuner, s_config, &tda9887_cfg);
  1631. } else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) {
  1632. if ((dev->eedata[2] == 0x07) && use_frontend) {
  1633. /* turn off the 2nd lnb supply */
  1634. u8 data = 0x80;
  1635. struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1};
  1636. struct dvb_frontend *fe;
  1637. fe = fe0->dvb.frontend;
  1638. if (fe->ops.i2c_gate_ctrl) {
  1639. fe->ops.i2c_gate_ctrl(fe, 1);
  1640. i2c_transfer(&dev->i2c_adap, &msg, 1);
  1641. fe->ops.i2c_gate_ctrl(fe, 0);
  1642. }
  1643. }
  1644. }
  1645. videobuf_dvb_unregister_bus(&dev->frontends);
  1646. return 0;
  1647. }
  1648. static struct saa7134_mpeg_ops dvb_ops = {
  1649. .type = SAA7134_MPEG_DVB,
  1650. .init = dvb_init,
  1651. .fini = dvb_fini,
  1652. };
  1653. static int __init dvb_register(void)
  1654. {
  1655. return saa7134_ts_register(&dvb_ops);
  1656. }
  1657. static void __exit dvb_unregister(void)
  1658. {
  1659. saa7134_ts_unregister(&dvb_ops);
  1660. }
  1661. module_init(dvb_register);
  1662. module_exit(dvb_unregister);
  1663. /* ------------------------------------------------------------------ */
  1664. /*
  1665. * Local variables:
  1666. * c-basic-offset: 8
  1667. * End:
  1668. */