saa7134-dvb.c 56 KB

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