saa7134-dvb.c 49 KB

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