saa7134-dvb.c 53 KB

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