saa7134-dvb.c 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939
  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. if (!fe0)
  515. return -EINVAL;
  516. fe0->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap);
  517. if (fe0->dvb.frontend) {
  518. if (cdec_conf->i2c_gate)
  519. fe0->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
  520. if (dvb_attach(tda827x_attach, fe0->dvb.frontend,
  521. cdec_conf->tuner_address,
  522. &dev->i2c_adap, tuner_conf))
  523. return 0;
  524. wprintk("no tda827x tuner found at addr: %02x\n",
  525. cdec_conf->tuner_address);
  526. }
  527. return -EINVAL;
  528. }
  529. /* ------------------------------------------------------------------ */
  530. static struct tda827x_config tda827x_cfg_0 = {
  531. .init = philips_tda827x_tuner_init,
  532. .sleep = philips_tda827x_tuner_sleep,
  533. .config = 0,
  534. .switch_addr = 0
  535. };
  536. static struct tda827x_config tda827x_cfg_1 = {
  537. .init = philips_tda827x_tuner_init,
  538. .sleep = philips_tda827x_tuner_sleep,
  539. .config = 1,
  540. .switch_addr = 0x4b
  541. };
  542. static struct tda827x_config tda827x_cfg_2 = {
  543. .init = philips_tda827x_tuner_init,
  544. .sleep = philips_tda827x_tuner_sleep,
  545. .config = 2,
  546. .switch_addr = 0x4b
  547. };
  548. static struct tda827x_config tda827x_cfg_2_sw42 = {
  549. .init = philips_tda827x_tuner_init,
  550. .sleep = philips_tda827x_tuner_sleep,
  551. .config = 2,
  552. .switch_addr = 0x42
  553. };
  554. /* ------------------------------------------------------------------ */
  555. static struct tda1004x_config tda827x_lifeview_config = {
  556. .demod_address = 0x08,
  557. .invert = 1,
  558. .invert_oclk = 0,
  559. .xtal_freq = TDA10046_XTAL_16M,
  560. .agc_config = TDA10046_AGC_TDA827X,
  561. .gpio_config = TDA10046_GP11_I,
  562. .if_freq = TDA10046_FREQ_045,
  563. .tuner_address = 0x60,
  564. .request_firmware = philips_tda1004x_request_firmware
  565. };
  566. static struct tda1004x_config philips_tiger_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. .antenna_switch= 1,
  577. .request_firmware = philips_tda1004x_request_firmware
  578. };
  579. static struct tda1004x_config cinergy_ht_config = {
  580. .demod_address = 0x08,
  581. .invert = 1,
  582. .invert_oclk = 0,
  583. .xtal_freq = TDA10046_XTAL_16M,
  584. .agc_config = TDA10046_AGC_TDA827X,
  585. .gpio_config = TDA10046_GP01_I,
  586. .if_freq = TDA10046_FREQ_045,
  587. .i2c_gate = 0x4b,
  588. .tuner_address = 0x61,
  589. .request_firmware = philips_tda1004x_request_firmware
  590. };
  591. static struct tda1004x_config cinergy_ht_pci_config = {
  592. .demod_address = 0x08,
  593. .invert = 1,
  594. .invert_oclk = 0,
  595. .xtal_freq = TDA10046_XTAL_16M,
  596. .agc_config = TDA10046_AGC_TDA827X,
  597. .gpio_config = TDA10046_GP01_I,
  598. .if_freq = TDA10046_FREQ_045,
  599. .i2c_gate = 0x4b,
  600. .tuner_address = 0x60,
  601. .request_firmware = philips_tda1004x_request_firmware
  602. };
  603. static struct tda1004x_config philips_tiger_s_config = {
  604. .demod_address = 0x08,
  605. .invert = 1,
  606. .invert_oclk = 0,
  607. .xtal_freq = TDA10046_XTAL_16M,
  608. .agc_config = TDA10046_AGC_TDA827X,
  609. .gpio_config = TDA10046_GP01_I,
  610. .if_freq = TDA10046_FREQ_045,
  611. .i2c_gate = 0x4b,
  612. .tuner_address = 0x61,
  613. .antenna_switch= 1,
  614. .request_firmware = philips_tda1004x_request_firmware
  615. };
  616. static struct tda1004x_config pinnacle_pctv_310i_config = {
  617. .demod_address = 0x08,
  618. .invert = 1,
  619. .invert_oclk = 0,
  620. .xtal_freq = TDA10046_XTAL_16M,
  621. .agc_config = TDA10046_AGC_TDA827X,
  622. .gpio_config = TDA10046_GP11_I,
  623. .if_freq = TDA10046_FREQ_045,
  624. .i2c_gate = 0x4b,
  625. .tuner_address = 0x61,
  626. .request_firmware = philips_tda1004x_request_firmware
  627. };
  628. static struct tda1004x_config hauppauge_hvr_1110_config = {
  629. .demod_address = 0x08,
  630. .invert = 1,
  631. .invert_oclk = 0,
  632. .xtal_freq = TDA10046_XTAL_16M,
  633. .agc_config = TDA10046_AGC_TDA827X,
  634. .gpio_config = TDA10046_GP11_I,
  635. .if_freq = TDA10046_FREQ_045,
  636. .i2c_gate = 0x4b,
  637. .tuner_address = 0x61,
  638. .request_firmware = philips_tda1004x_request_firmware
  639. };
  640. static struct tda1004x_config asus_p7131_dual_config = {
  641. .demod_address = 0x08,
  642. .invert = 1,
  643. .invert_oclk = 0,
  644. .xtal_freq = TDA10046_XTAL_16M,
  645. .agc_config = TDA10046_AGC_TDA827X,
  646. .gpio_config = TDA10046_GP11_I,
  647. .if_freq = TDA10046_FREQ_045,
  648. .i2c_gate = 0x4b,
  649. .tuner_address = 0x61,
  650. .antenna_switch= 2,
  651. .request_firmware = philips_tda1004x_request_firmware
  652. };
  653. static struct tda1004x_config lifeview_trio_config = {
  654. .demod_address = 0x09,
  655. .invert = 1,
  656. .invert_oclk = 0,
  657. .xtal_freq = TDA10046_XTAL_16M,
  658. .agc_config = TDA10046_AGC_TDA827X,
  659. .gpio_config = TDA10046_GP00_I,
  660. .if_freq = TDA10046_FREQ_045,
  661. .tuner_address = 0x60,
  662. .request_firmware = philips_tda1004x_request_firmware
  663. };
  664. static struct tda1004x_config tevion_dvbt220rf_config = {
  665. .demod_address = 0x08,
  666. .invert = 1,
  667. .invert_oclk = 0,
  668. .xtal_freq = TDA10046_XTAL_16M,
  669. .agc_config = TDA10046_AGC_TDA827X,
  670. .gpio_config = TDA10046_GP11_I,
  671. .if_freq = TDA10046_FREQ_045,
  672. .tuner_address = 0x60,
  673. .request_firmware = philips_tda1004x_request_firmware
  674. };
  675. static struct tda1004x_config md8800_dvbt_config = {
  676. .demod_address = 0x08,
  677. .invert = 1,
  678. .invert_oclk = 0,
  679. .xtal_freq = TDA10046_XTAL_16M,
  680. .agc_config = TDA10046_AGC_TDA827X,
  681. .gpio_config = TDA10046_GP01_I,
  682. .if_freq = TDA10046_FREQ_045,
  683. .i2c_gate = 0x4b,
  684. .tuner_address = 0x60,
  685. .request_firmware = philips_tda1004x_request_firmware
  686. };
  687. static struct tda1004x_config asus_p7131_4871_config = {
  688. .demod_address = 0x08,
  689. .invert = 1,
  690. .invert_oclk = 0,
  691. .xtal_freq = TDA10046_XTAL_16M,
  692. .agc_config = TDA10046_AGC_TDA827X,
  693. .gpio_config = TDA10046_GP01_I,
  694. .if_freq = TDA10046_FREQ_045,
  695. .i2c_gate = 0x4b,
  696. .tuner_address = 0x61,
  697. .antenna_switch= 2,
  698. .request_firmware = philips_tda1004x_request_firmware
  699. };
  700. static struct tda1004x_config asus_p7131_hybrid_lna_config = {
  701. .demod_address = 0x08,
  702. .invert = 1,
  703. .invert_oclk = 0,
  704. .xtal_freq = TDA10046_XTAL_16M,
  705. .agc_config = TDA10046_AGC_TDA827X,
  706. .gpio_config = TDA10046_GP11_I,
  707. .if_freq = TDA10046_FREQ_045,
  708. .i2c_gate = 0x4b,
  709. .tuner_address = 0x61,
  710. .antenna_switch= 2,
  711. .request_firmware = philips_tda1004x_request_firmware
  712. };
  713. static struct tda1004x_config kworld_dvb_t_210_config = {
  714. .demod_address = 0x08,
  715. .invert = 1,
  716. .invert_oclk = 0,
  717. .xtal_freq = TDA10046_XTAL_16M,
  718. .agc_config = TDA10046_AGC_TDA827X,
  719. .gpio_config = TDA10046_GP11_I,
  720. .if_freq = TDA10046_FREQ_045,
  721. .i2c_gate = 0x4b,
  722. .tuner_address = 0x61,
  723. .antenna_switch= 1,
  724. .request_firmware = philips_tda1004x_request_firmware
  725. };
  726. static struct tda1004x_config avermedia_super_007_config = {
  727. .demod_address = 0x08,
  728. .invert = 1,
  729. .invert_oclk = 0,
  730. .xtal_freq = TDA10046_XTAL_16M,
  731. .agc_config = TDA10046_AGC_TDA827X,
  732. .gpio_config = TDA10046_GP01_I,
  733. .if_freq = TDA10046_FREQ_045,
  734. .i2c_gate = 0x4b,
  735. .tuner_address = 0x60,
  736. .antenna_switch= 1,
  737. .request_firmware = philips_tda1004x_request_firmware
  738. };
  739. static struct tda1004x_config twinhan_dtv_dvb_3056_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_GP01_I,
  746. .if_freq = TDA10046_FREQ_045,
  747. .i2c_gate = 0x42,
  748. .tuner_address = 0x61,
  749. .antenna_switch = 1,
  750. .request_firmware = philips_tda1004x_request_firmware
  751. };
  752. static struct tda1004x_config asus_tiger_3in1_config = {
  753. .demod_address = 0x0b,
  754. .invert = 1,
  755. .invert_oclk = 0,
  756. .xtal_freq = TDA10046_XTAL_16M,
  757. .agc_config = TDA10046_AGC_TDA827X,
  758. .gpio_config = TDA10046_GP11_I,
  759. .if_freq = TDA10046_FREQ_045,
  760. .i2c_gate = 0x4b,
  761. .tuner_address = 0x61,
  762. .antenna_switch = 1,
  763. .request_firmware = philips_tda1004x_request_firmware
  764. };
  765. static struct tda1004x_config asus_ps3_100_config = {
  766. .demod_address = 0x0b,
  767. .invert = 1,
  768. .invert_oclk = 0,
  769. .xtal_freq = TDA10046_XTAL_16M,
  770. .agc_config = TDA10046_AGC_TDA827X,
  771. .gpio_config = TDA10046_GP11_I,
  772. .if_freq = TDA10046_FREQ_045,
  773. .i2c_gate = 0x4b,
  774. .tuner_address = 0x61,
  775. .antenna_switch = 1,
  776. .request_firmware = philips_tda1004x_request_firmware
  777. };
  778. /* ------------------------------------------------------------------
  779. * special case: this card uses saa713x GPIO22 for the mode switch
  780. */
  781. static int ads_duo_tuner_init(struct dvb_frontend *fe)
  782. {
  783. struct saa7134_dev *dev = fe->dvb->priv;
  784. philips_tda827x_tuner_init(fe);
  785. /* route TDA8275a AGC input to the channel decoder */
  786. saa7134_set_gpio(dev, 22, 1);
  787. return 0;
  788. }
  789. static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
  790. {
  791. struct saa7134_dev *dev = fe->dvb->priv;
  792. /* route TDA8275a AGC input to the analog IF chip*/
  793. saa7134_set_gpio(dev, 22, 0);
  794. philips_tda827x_tuner_sleep(fe);
  795. return 0;
  796. }
  797. static struct tda827x_config ads_duo_cfg = {
  798. .init = ads_duo_tuner_init,
  799. .sleep = ads_duo_tuner_sleep,
  800. .config = 0
  801. };
  802. static struct tda1004x_config ads_tech_duo_config = {
  803. .demod_address = 0x08,
  804. .invert = 1,
  805. .invert_oclk = 0,
  806. .xtal_freq = TDA10046_XTAL_16M,
  807. .agc_config = TDA10046_AGC_TDA827X,
  808. .gpio_config = TDA10046_GP00_I,
  809. .if_freq = TDA10046_FREQ_045,
  810. .tuner_address = 0x61,
  811. .request_firmware = philips_tda1004x_request_firmware
  812. };
  813. static struct zl10353_config behold_h6_config = {
  814. .demod_address = 0x1e>>1,
  815. .no_tuner = 1,
  816. .parallel_ts = 1,
  817. .disable_i2c_gate_ctrl = 1,
  818. };
  819. static struct xc5000_config behold_x7_tunerconfig = {
  820. .i2c_address = 0xc2>>1,
  821. .if_khz = 4560,
  822. .radio_input = XC5000_RADIO_FM1,
  823. };
  824. static struct zl10353_config behold_x7_config = {
  825. .demod_address = 0x1e>>1,
  826. .if2 = 45600,
  827. .no_tuner = 1,
  828. .parallel_ts = 1,
  829. .disable_i2c_gate_ctrl = 1,
  830. };
  831. static struct zl10353_config videomate_t750_zl10353_config = {
  832. .demod_address = 0x0f,
  833. .no_tuner = 1,
  834. .parallel_ts = 1,
  835. .disable_i2c_gate_ctrl = 1,
  836. };
  837. static struct qt1010_config videomate_t750_qt1010_config = {
  838. .i2c_address = 0x62
  839. };
  840. /* ==================================================================
  841. * tda10086 based DVB-S cards, helper functions
  842. */
  843. static struct tda10086_config flydvbs = {
  844. .demod_address = 0x0e,
  845. .invert = 0,
  846. .diseqc_tone = 0,
  847. .xtal_freq = TDA10086_XTAL_16M,
  848. };
  849. static struct tda10086_config sd1878_4m = {
  850. .demod_address = 0x0e,
  851. .invert = 0,
  852. .diseqc_tone = 0,
  853. .xtal_freq = TDA10086_XTAL_4M,
  854. };
  855. /* ------------------------------------------------------------------
  856. * special case: lnb supply is connected to the gated i2c
  857. */
  858. static int md8800_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
  859. {
  860. int res = -EIO;
  861. struct saa7134_dev *dev = fe->dvb->priv;
  862. if (fe->ops.i2c_gate_ctrl) {
  863. fe->ops.i2c_gate_ctrl(fe, 1);
  864. if (dev->original_set_voltage)
  865. res = dev->original_set_voltage(fe, voltage);
  866. fe->ops.i2c_gate_ctrl(fe, 0);
  867. }
  868. return res;
  869. };
  870. static int md8800_set_high_voltage(struct dvb_frontend *fe, long arg)
  871. {
  872. int res = -EIO;
  873. struct saa7134_dev *dev = fe->dvb->priv;
  874. if (fe->ops.i2c_gate_ctrl) {
  875. fe->ops.i2c_gate_ctrl(fe, 1);
  876. if (dev->original_set_high_voltage)
  877. res = dev->original_set_high_voltage(fe, arg);
  878. fe->ops.i2c_gate_ctrl(fe, 0);
  879. }
  880. return res;
  881. };
  882. static int md8800_set_voltage2(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
  883. {
  884. struct saa7134_dev *dev = fe->dvb->priv;
  885. u8 wbuf[2] = { 0x1f, 00 };
  886. u8 rbuf;
  887. struct i2c_msg msg[] = { { .addr = 0x08, .flags = 0, .buf = wbuf, .len = 1 },
  888. { .addr = 0x08, .flags = I2C_M_RD, .buf = &rbuf, .len = 1 } };
  889. if (i2c_transfer(&dev->i2c_adap, msg, 2) != 2)
  890. return -EIO;
  891. /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
  892. if (voltage == SEC_VOLTAGE_18)
  893. wbuf[1] = rbuf | 0x10;
  894. else
  895. wbuf[1] = rbuf & 0xef;
  896. msg[0].len = 2;
  897. i2c_transfer(&dev->i2c_adap, msg, 1);
  898. return 0;
  899. }
  900. static int md8800_set_high_voltage2(struct dvb_frontend *fe, long arg)
  901. {
  902. struct saa7134_dev *dev = fe->dvb->priv;
  903. wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__);
  904. return -EIO;
  905. }
  906. /* ==================================================================
  907. * nxt200x based ATSC cards, helper functions
  908. */
  909. static struct nxt200x_config avertvhda180 = {
  910. .demod_address = 0x0a,
  911. };
  912. static struct nxt200x_config kworldatsc110 = {
  913. .demod_address = 0x0a,
  914. };
  915. /* ------------------------------------------------------------------ */
  916. static struct mt312_config avertv_a700_mt312 = {
  917. .demod_address = 0x0e,
  918. .voltage_inverted = 1,
  919. };
  920. static struct zl10036_config avertv_a700_tuner = {
  921. .tuner_address = 0x60,
  922. };
  923. static struct mt312_config zl10313_compro_s350_config = {
  924. .demod_address = 0x0e,
  925. };
  926. static struct lgdt3305_config hcw_lgdt3305_config = {
  927. .i2c_addr = 0x0e,
  928. .mpeg_mode = LGDT3305_MPEG_SERIAL,
  929. .tpclk_edge = LGDT3305_TPCLK_RISING_EDGE,
  930. .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
  931. .deny_i2c_rptr = 1,
  932. .spectral_inversion = 1,
  933. .qam_if_khz = 4000,
  934. .vsb_if_khz = 3250,
  935. };
  936. static struct tda10048_config hcw_tda10048_config = {
  937. .demod_address = 0x10 >> 1,
  938. .output_mode = TDA10048_SERIAL_OUTPUT,
  939. .fwbulkwritelen = TDA10048_BULKWRITE_200,
  940. .inversion = TDA10048_INVERSION_ON,
  941. .dtv6_if_freq_khz = TDA10048_IF_3300,
  942. .dtv7_if_freq_khz = TDA10048_IF_3500,
  943. .dtv8_if_freq_khz = TDA10048_IF_4000,
  944. .clk_freq_khz = TDA10048_CLK_16000,
  945. .disable_gate_access = 1,
  946. };
  947. static struct tda18271_std_map hauppauge_tda18271_std_map = {
  948. .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4,
  949. .if_lvl = 1, .rfagc_top = 0x58, },
  950. .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5,
  951. .if_lvl = 1, .rfagc_top = 0x58, },
  952. };
  953. static struct tda18271_config hcw_tda18271_config = {
  954. .std_map = &hauppauge_tda18271_std_map,
  955. .gate = TDA18271_GATE_ANALOG,
  956. .config = 3,
  957. .output_opt = TDA18271_OUTPUT_LT_OFF,
  958. };
  959. static struct tda829x_config tda829x_no_probe = {
  960. .probe_tuner = TDA829X_DONT_PROBE,
  961. };
  962. static struct tda10048_config zolid_tda10048_config = {
  963. .demod_address = 0x10 >> 1,
  964. .output_mode = TDA10048_PARALLEL_OUTPUT,
  965. .fwbulkwritelen = TDA10048_BULKWRITE_200,
  966. .inversion = TDA10048_INVERSION_ON,
  967. .dtv6_if_freq_khz = TDA10048_IF_3300,
  968. .dtv7_if_freq_khz = TDA10048_IF_3500,
  969. .dtv8_if_freq_khz = TDA10048_IF_4000,
  970. .clk_freq_khz = TDA10048_CLK_16000,
  971. .disable_gate_access = 1,
  972. };
  973. static struct tda18271_config zolid_tda18271_config = {
  974. .gate = TDA18271_GATE_ANALOG,
  975. };
  976. static struct tda10048_config dtv1000s_tda10048_config = {
  977. .demod_address = 0x10 >> 1,
  978. .output_mode = TDA10048_PARALLEL_OUTPUT,
  979. .fwbulkwritelen = TDA10048_BULKWRITE_200,
  980. .inversion = TDA10048_INVERSION_ON,
  981. .dtv6_if_freq_khz = TDA10048_IF_3300,
  982. .dtv7_if_freq_khz = TDA10048_IF_3800,
  983. .dtv8_if_freq_khz = TDA10048_IF_4300,
  984. .clk_freq_khz = TDA10048_CLK_16000,
  985. .disable_gate_access = 1,
  986. };
  987. static struct tda18271_std_map dtv1000s_tda18271_std_map = {
  988. .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4,
  989. .if_lvl = 1, .rfagc_top = 0x37, },
  990. .dvbt_7 = { .if_freq = 3800, .agc_mode = 3, .std = 5,
  991. .if_lvl = 1, .rfagc_top = 0x37, },
  992. .dvbt_8 = { .if_freq = 4300, .agc_mode = 3, .std = 6,
  993. .if_lvl = 1, .rfagc_top = 0x37, },
  994. };
  995. static struct tda18271_config dtv1000s_tda18271_config = {
  996. .std_map = &dtv1000s_tda18271_std_map,
  997. .gate = TDA18271_GATE_ANALOG,
  998. };
  999. static struct lgs8gxx_config prohdtv_pro2_lgs8g75_config = {
  1000. .prod = LGS8GXX_PROD_LGS8G75,
  1001. .demod_address = 0x1d,
  1002. .serial_ts = 0,
  1003. .ts_clk_pol = 1,
  1004. .ts_clk_gated = 0,
  1005. .if_clk_freq = 30400, /* 30.4 MHz */
  1006. .if_freq = 4000, /* 4.00 MHz */
  1007. .if_neg_center = 0,
  1008. .ext_adc = 0,
  1009. .adc_signed = 1,
  1010. .adc_vpp = 3, /* 2.0 Vpp */
  1011. .if_neg_edge = 1,
  1012. };
  1013. static struct tda18271_config prohdtv_pro2_tda18271_config = {
  1014. .gate = TDA18271_GATE_ANALOG,
  1015. .output_opt = TDA18271_OUTPUT_LT_OFF,
  1016. };
  1017. static struct tda18271_std_map kworld_tda18271_std_map = {
  1018. .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 3,
  1019. .if_lvl = 6, .rfagc_top = 0x37 },
  1020. .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 0,
  1021. .if_lvl = 6, .rfagc_top = 0x37 },
  1022. };
  1023. static struct tda18271_config kworld_pc150u_tda18271_config = {
  1024. .std_map = &kworld_tda18271_std_map,
  1025. .gate = TDA18271_GATE_ANALOG,
  1026. .output_opt = TDA18271_OUTPUT_LT_OFF,
  1027. .config = 3, /* Use tuner callback for AGC */
  1028. .rf_cal_on_startup = 1
  1029. };
  1030. static struct s5h1411_config kworld_s5h1411_config = {
  1031. .output_mode = S5H1411_PARALLEL_OUTPUT,
  1032. .gpio = S5H1411_GPIO_OFF,
  1033. .qam_if = S5H1411_IF_4000,
  1034. .vsb_if = S5H1411_IF_3250,
  1035. .inversion = S5H1411_INVERSION_ON,
  1036. .status_mode = S5H1411_DEMODLOCKING,
  1037. .mpeg_timing =
  1038. S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
  1039. };
  1040. /* ==================================================================
  1041. * Core code
  1042. */
  1043. static int dvb_init(struct saa7134_dev *dev)
  1044. {
  1045. int ret;
  1046. int attach_xc3028 = 0;
  1047. struct videobuf_dvb_frontend *fe0;
  1048. /* FIXME: add support for multi-frontend */
  1049. mutex_init(&dev->frontends.lock);
  1050. INIT_LIST_HEAD(&dev->frontends.felist);
  1051. printk(KERN_INFO "%s() allocating 1 frontend\n", __func__);
  1052. fe0 = videobuf_dvb_alloc_frontend(&dev->frontends, 1);
  1053. if (!fe0) {
  1054. printk(KERN_ERR "%s() failed to alloc\n", __func__);
  1055. return -ENOMEM;
  1056. }
  1057. /* init struct videobuf_dvb */
  1058. dev->ts.nr_bufs = 32;
  1059. dev->ts.nr_packets = 32*4;
  1060. fe0->dvb.name = dev->name;
  1061. videobuf_queue_sg_init(&fe0->dvb.dvbq, &saa7134_ts_qops,
  1062. &dev->pci->dev, &dev->slock,
  1063. V4L2_BUF_TYPE_VIDEO_CAPTURE,
  1064. V4L2_FIELD_ALTERNATE,
  1065. sizeof(struct saa7134_buf),
  1066. dev, NULL);
  1067. switch (dev->board) {
  1068. case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
  1069. dprintk("pinnacle 300i dvb setup\n");
  1070. fe0->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
  1071. &dev->i2c_adap);
  1072. if (fe0->dvb.frontend) {
  1073. fe0->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
  1074. }
  1075. break;
  1076. case SAA7134_BOARD_AVERMEDIA_777:
  1077. case SAA7134_BOARD_AVERMEDIA_A16AR:
  1078. dprintk("avertv 777 dvb setup\n");
  1079. fe0->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
  1080. &dev->i2c_adap);
  1081. if (fe0->dvb.frontend) {
  1082. dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
  1083. &dev->i2c_adap, 0x61,
  1084. TUNER_PHILIPS_TD1316);
  1085. }
  1086. break;
  1087. case SAA7134_BOARD_AVERMEDIA_A16D:
  1088. dprintk("AverMedia A16D dvb setup\n");
  1089. fe0->dvb.frontend = dvb_attach(mt352_attach,
  1090. &avermedia_xc3028_mt352_dev,
  1091. &dev->i2c_adap);
  1092. attach_xc3028 = 1;
  1093. break;
  1094. case SAA7134_BOARD_MD7134:
  1095. fe0->dvb.frontend = dvb_attach(tda10046_attach,
  1096. &medion_cardbus,
  1097. &dev->i2c_adap);
  1098. if (fe0->dvb.frontend) {
  1099. dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
  1100. &dev->i2c_adap, medion_cardbus.tuner_address,
  1101. TUNER_PHILIPS_FMD1216ME_MK3);
  1102. }
  1103. break;
  1104. case SAA7134_BOARD_PHILIPS_TOUGH:
  1105. fe0->dvb.frontend = dvb_attach(tda10046_attach,
  1106. &philips_tu1216_60_config,
  1107. &dev->i2c_adap);
  1108. if (fe0->dvb.frontend) {
  1109. fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
  1110. fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
  1111. }
  1112. break;
  1113. case SAA7134_BOARD_FLYDVBTDUO:
  1114. case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
  1115. if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
  1116. &tda827x_cfg_0) < 0)
  1117. goto detach_frontend;
  1118. break;
  1119. case SAA7134_BOARD_PHILIPS_EUROPA:
  1120. case SAA7134_BOARD_VIDEOMATE_DVBT_300:
  1121. case SAA7134_BOARD_ASUS_EUROPA_HYBRID:
  1122. fe0->dvb.frontend = dvb_attach(tda10046_attach,
  1123. &philips_europa_config,
  1124. &dev->i2c_adap);
  1125. if (fe0->dvb.frontend) {
  1126. dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
  1127. fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
  1128. fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
  1129. fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
  1130. fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
  1131. }
  1132. break;
  1133. case SAA7134_BOARD_TECHNOTREND_BUDGET_T3000:
  1134. fe0->dvb.frontend = dvb_attach(tda10046_attach,
  1135. &technotrend_budget_t3000_config,
  1136. &dev->i2c_adap);
  1137. if (fe0->dvb.frontend) {
  1138. dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
  1139. fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
  1140. fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
  1141. fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
  1142. fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
  1143. }
  1144. break;
  1145. case SAA7134_BOARD_VIDEOMATE_DVBT_200:
  1146. fe0->dvb.frontend = dvb_attach(tda10046_attach,
  1147. &philips_tu1216_61_config,
  1148. &dev->i2c_adap);
  1149. if (fe0->dvb.frontend) {
  1150. fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
  1151. fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
  1152. }
  1153. break;
  1154. case SAA7134_BOARD_KWORLD_DVBT_210:
  1155. if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config,
  1156. &tda827x_cfg_2) < 0)
  1157. goto detach_frontend;
  1158. break;
  1159. case SAA7134_BOARD_HAUPPAUGE_HVR1120:
  1160. fe0->dvb.frontend = dvb_attach(tda10048_attach,
  1161. &hcw_tda10048_config,
  1162. &dev->i2c_adap);
  1163. if (fe0->dvb.frontend != NULL) {
  1164. dvb_attach(tda829x_attach, fe0->dvb.frontend,
  1165. &dev->i2c_adap, 0x4b,
  1166. &tda829x_no_probe);
  1167. dvb_attach(tda18271_attach, fe0->dvb.frontend,
  1168. 0x60, &dev->i2c_adap,
  1169. &hcw_tda18271_config);
  1170. }
  1171. break;
  1172. case SAA7134_BOARD_PHILIPS_TIGER:
  1173. if (configure_tda827x_fe(dev, &philips_tiger_config,
  1174. &tda827x_cfg_0) < 0)
  1175. goto detach_frontend;
  1176. break;
  1177. case SAA7134_BOARD_PINNACLE_PCTV_310i:
  1178. if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config,
  1179. &tda827x_cfg_1) < 0)
  1180. goto detach_frontend;
  1181. break;
  1182. case SAA7134_BOARD_HAUPPAUGE_HVR1110:
  1183. if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config,
  1184. &tda827x_cfg_1) < 0)
  1185. goto detach_frontend;
  1186. break;
  1187. case SAA7134_BOARD_HAUPPAUGE_HVR1150:
  1188. fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
  1189. &hcw_lgdt3305_config,
  1190. &dev->i2c_adap);
  1191. if (fe0->dvb.frontend) {
  1192. dvb_attach(tda829x_attach, fe0->dvb.frontend,
  1193. &dev->i2c_adap, 0x4b,
  1194. &tda829x_no_probe);
  1195. dvb_attach(tda18271_attach, fe0->dvb.frontend,
  1196. 0x60, &dev->i2c_adap,
  1197. &hcw_tda18271_config);
  1198. }
  1199. break;
  1200. case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
  1201. if (configure_tda827x_fe(dev, &asus_p7131_dual_config,
  1202. &tda827x_cfg_0) < 0)
  1203. goto detach_frontend;
  1204. break;
  1205. case SAA7134_BOARD_FLYDVBT_LR301:
  1206. if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
  1207. &tda827x_cfg_0) < 0)
  1208. goto detach_frontend;
  1209. break;
  1210. case SAA7134_BOARD_FLYDVB_TRIO:
  1211. if (!use_frontend) { /* terrestrial */
  1212. if (configure_tda827x_fe(dev, &lifeview_trio_config,
  1213. &tda827x_cfg_0) < 0)
  1214. goto detach_frontend;
  1215. } else { /* satellite */
  1216. fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
  1217. if (fe0->dvb.frontend) {
  1218. if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x63,
  1219. &dev->i2c_adap, 0) == NULL) {
  1220. wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__);
  1221. goto detach_frontend;
  1222. }
  1223. if (dvb_attach(isl6421_attach, fe0->dvb.frontend, &dev->i2c_adap,
  1224. 0x08, 0, 0) == NULL) {
  1225. wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__);
  1226. goto detach_frontend;
  1227. }
  1228. }
  1229. }
  1230. break;
  1231. case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
  1232. case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
  1233. fe0->dvb.frontend = dvb_attach(tda10046_attach,
  1234. &ads_tech_duo_config,
  1235. &dev->i2c_adap);
  1236. if (fe0->dvb.frontend) {
  1237. if (dvb_attach(tda827x_attach,fe0->dvb.frontend,
  1238. ads_tech_duo_config.tuner_address, &dev->i2c_adap,
  1239. &ads_duo_cfg) == NULL) {
  1240. wprintk("no tda827x tuner found at addr: %02x\n",
  1241. ads_tech_duo_config.tuner_address);
  1242. goto detach_frontend;
  1243. }
  1244. } else
  1245. wprintk("failed to attach tda10046\n");
  1246. break;
  1247. case SAA7134_BOARD_TEVION_DVBT_220RF:
  1248. if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config,
  1249. &tda827x_cfg_0) < 0)
  1250. goto detach_frontend;
  1251. break;
  1252. case SAA7134_BOARD_MEDION_MD8800_QUADRO:
  1253. if (!use_frontend) { /* terrestrial */
  1254. if (configure_tda827x_fe(dev, &md8800_dvbt_config,
  1255. &tda827x_cfg_0) < 0)
  1256. goto detach_frontend;
  1257. } else { /* satellite */
  1258. fe0->dvb.frontend = dvb_attach(tda10086_attach,
  1259. &flydvbs, &dev->i2c_adap);
  1260. if (fe0->dvb.frontend) {
  1261. struct dvb_frontend *fe = fe0->dvb.frontend;
  1262. u8 dev_id = dev->eedata[2];
  1263. u8 data = 0xc4;
  1264. struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};
  1265. if (dvb_attach(tda826x_attach, fe0->dvb.frontend,
  1266. 0x60, &dev->i2c_adap, 0) == NULL) {
  1267. wprintk("%s: Medion Quadro, no tda826x "
  1268. "found !\n", __func__);
  1269. goto detach_frontend;
  1270. }
  1271. if (dev_id != 0x08) {
  1272. /* we need to open the i2c gate (we know it exists) */
  1273. fe->ops.i2c_gate_ctrl(fe, 1);
  1274. if (dvb_attach(isl6405_attach, fe,
  1275. &dev->i2c_adap, 0x08, 0, 0) == NULL) {
  1276. wprintk("%s: Medion Quadro, no ISL6405 "
  1277. "found !\n", __func__);
  1278. goto detach_frontend;
  1279. }
  1280. if (dev_id == 0x07) {
  1281. /* fire up the 2nd section of the LNB supply since
  1282. we can't do this from the other section */
  1283. msg.buf = &data;
  1284. i2c_transfer(&dev->i2c_adap, &msg, 1);
  1285. }
  1286. fe->ops.i2c_gate_ctrl(fe, 0);
  1287. dev->original_set_voltage = fe->ops.set_voltage;
  1288. fe->ops.set_voltage = md8800_set_voltage;
  1289. dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
  1290. fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
  1291. } else {
  1292. fe->ops.set_voltage = md8800_set_voltage2;
  1293. fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage2;
  1294. }
  1295. }
  1296. }
  1297. break;
  1298. case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
  1299. fe0->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
  1300. &dev->i2c_adap);
  1301. if (fe0->dvb.frontend)
  1302. dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x61,
  1303. NULL, DVB_PLL_TDHU2);
  1304. break;
  1305. case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI:
  1306. case SAA7134_BOARD_KWORLD_ATSC110:
  1307. fe0->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
  1308. &dev->i2c_adap);
  1309. if (fe0->dvb.frontend)
  1310. dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
  1311. &dev->i2c_adap, 0x61,
  1312. TUNER_PHILIPS_TUV1236D);
  1313. break;
  1314. case SAA7134_BOARD_KWORLD_PC150U:
  1315. saa7134_set_gpio(dev, 18, 1); /* Switch to digital mode */
  1316. saa7134_tuner_callback(dev, 0,
  1317. TDA18271_CALLBACK_CMD_AGC_ENABLE, 1);
  1318. fe0->dvb.frontend = dvb_attach(s5h1411_attach,
  1319. &kworld_s5h1411_config,
  1320. &dev->i2c_adap);
  1321. if (fe0->dvb.frontend != NULL) {
  1322. dvb_attach(tda829x_attach, fe0->dvb.frontend,
  1323. &dev->i2c_adap, 0x4b,
  1324. &tda829x_no_probe);
  1325. dvb_attach(tda18271_attach, fe0->dvb.frontend,
  1326. 0x60, &dev->i2c_adap,
  1327. &kworld_pc150u_tda18271_config);
  1328. }
  1329. break;
  1330. case SAA7134_BOARD_FLYDVBS_LR300:
  1331. fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
  1332. &dev->i2c_adap);
  1333. if (fe0->dvb.frontend) {
  1334. if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
  1335. &dev->i2c_adap, 0) == NULL) {
  1336. wprintk("%s: No tda826x found!\n", __func__);
  1337. goto detach_frontend;
  1338. }
  1339. if (dvb_attach(isl6421_attach, fe0->dvb.frontend,
  1340. &dev->i2c_adap, 0x08, 0, 0) == NULL) {
  1341. wprintk("%s: No ISL6421 found!\n", __func__);
  1342. goto detach_frontend;
  1343. }
  1344. }
  1345. break;
  1346. case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
  1347. fe0->dvb.frontend = dvb_attach(tda10046_attach,
  1348. &medion_cardbus,
  1349. &dev->i2c_adap);
  1350. if (fe0->dvb.frontend) {
  1351. dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
  1352. fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
  1353. dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
  1354. &dev->i2c_adap, medion_cardbus.tuner_address,
  1355. TUNER_PHILIPS_FMD1216ME_MK3);
  1356. }
  1357. break;
  1358. case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
  1359. fe0->dvb.frontend = dvb_attach(tda10046_attach,
  1360. &philips_europa_config,
  1361. &dev->i2c_adap);
  1362. if (fe0->dvb.frontend) {
  1363. fe0->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
  1364. fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
  1365. }
  1366. break;
  1367. case SAA7134_BOARD_CINERGY_HT_PCMCIA:
  1368. if (configure_tda827x_fe(dev, &cinergy_ht_config,
  1369. &tda827x_cfg_0) < 0)
  1370. goto detach_frontend;
  1371. break;
  1372. case SAA7134_BOARD_CINERGY_HT_PCI:
  1373. if (configure_tda827x_fe(dev, &cinergy_ht_pci_config,
  1374. &tda827x_cfg_0) < 0)
  1375. goto detach_frontend;
  1376. break;
  1377. case SAA7134_BOARD_PHILIPS_TIGER_S:
  1378. if (configure_tda827x_fe(dev, &philips_tiger_s_config,
  1379. &tda827x_cfg_2) < 0)
  1380. goto detach_frontend;
  1381. break;
  1382. case SAA7134_BOARD_ASUS_P7131_4871:
  1383. if (configure_tda827x_fe(dev, &asus_p7131_4871_config,
  1384. &tda827x_cfg_2) < 0)
  1385. goto detach_frontend;
  1386. break;
  1387. case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
  1388. if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config,
  1389. &tda827x_cfg_2) < 0)
  1390. goto detach_frontend;
  1391. break;
  1392. case SAA7134_BOARD_AVERMEDIA_SUPER_007:
  1393. if (configure_tda827x_fe(dev, &avermedia_super_007_config,
  1394. &tda827x_cfg_0) < 0)
  1395. goto detach_frontend;
  1396. break;
  1397. case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
  1398. if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config,
  1399. &tda827x_cfg_2_sw42) < 0)
  1400. goto detach_frontend;
  1401. break;
  1402. case SAA7134_BOARD_PHILIPS_SNAKE:
  1403. fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
  1404. &dev->i2c_adap);
  1405. if (fe0->dvb.frontend) {
  1406. if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
  1407. &dev->i2c_adap, 0) == NULL) {
  1408. wprintk("%s: No tda826x found!\n", __func__);
  1409. goto detach_frontend;
  1410. }
  1411. if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
  1412. &dev->i2c_adap, 0, 0) == NULL) {
  1413. wprintk("%s: No lnbp21 found!\n", __func__);
  1414. goto detach_frontend;
  1415. }
  1416. }
  1417. break;
  1418. case SAA7134_BOARD_CREATIX_CTX953:
  1419. if (configure_tda827x_fe(dev, &md8800_dvbt_config,
  1420. &tda827x_cfg_0) < 0)
  1421. goto detach_frontend;
  1422. break;
  1423. case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
  1424. if (configure_tda827x_fe(dev, &philips_tiger_s_config,
  1425. &tda827x_cfg_2) < 0)
  1426. goto detach_frontend;
  1427. break;
  1428. case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
  1429. dprintk("AverMedia E506R dvb setup\n");
  1430. saa7134_set_gpio(dev, 25, 0);
  1431. msleep(10);
  1432. saa7134_set_gpio(dev, 25, 1);
  1433. fe0->dvb.frontend = dvb_attach(mt352_attach,
  1434. &avermedia_xc3028_mt352_dev,
  1435. &dev->i2c_adap);
  1436. attach_xc3028 = 1;
  1437. break;
  1438. case SAA7134_BOARD_MD7134_BRIDGE_2:
  1439. fe0->dvb.frontend = dvb_attach(tda10086_attach,
  1440. &sd1878_4m, &dev->i2c_adap);
  1441. if (fe0->dvb.frontend) {
  1442. struct dvb_frontend *fe;
  1443. if (dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
  1444. &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) {
  1445. wprintk("%s: MD7134 DVB-S, no SD1878 "
  1446. "found !\n", __func__);
  1447. goto detach_frontend;
  1448. }
  1449. /* we need to open the i2c gate (we know it exists) */
  1450. fe = fe0->dvb.frontend;
  1451. fe->ops.i2c_gate_ctrl(fe, 1);
  1452. if (dvb_attach(isl6405_attach, fe,
  1453. &dev->i2c_adap, 0x08, 0, 0) == NULL) {
  1454. wprintk("%s: MD7134 DVB-S, no ISL6405 "
  1455. "found !\n", __func__);
  1456. goto detach_frontend;
  1457. }
  1458. fe->ops.i2c_gate_ctrl(fe, 0);
  1459. dev->original_set_voltage = fe->ops.set_voltage;
  1460. fe->ops.set_voltage = md8800_set_voltage;
  1461. dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
  1462. fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
  1463. }
  1464. break;
  1465. case SAA7134_BOARD_AVERMEDIA_M103:
  1466. saa7134_set_gpio(dev, 25, 0);
  1467. msleep(10);
  1468. saa7134_set_gpio(dev, 25, 1);
  1469. fe0->dvb.frontend = dvb_attach(mt352_attach,
  1470. &avermedia_xc3028_mt352_dev,
  1471. &dev->i2c_adap);
  1472. attach_xc3028 = 1;
  1473. break;
  1474. case SAA7134_BOARD_ASUSTeK_TIGER_3IN1:
  1475. if (!use_frontend) { /* terrestrial */
  1476. if (configure_tda827x_fe(dev, &asus_tiger_3in1_config,
  1477. &tda827x_cfg_2) < 0)
  1478. goto detach_frontend;
  1479. } else { /* satellite */
  1480. fe0->dvb.frontend = dvb_attach(tda10086_attach,
  1481. &flydvbs, &dev->i2c_adap);
  1482. if (fe0->dvb.frontend) {
  1483. if (dvb_attach(tda826x_attach,
  1484. fe0->dvb.frontend, 0x60,
  1485. &dev->i2c_adap, 0) == NULL) {
  1486. wprintk("%s: Asus Tiger 3in1, no "
  1487. "tda826x found!\n", __func__);
  1488. goto detach_frontend;
  1489. }
  1490. if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
  1491. &dev->i2c_adap, 0, 0) == NULL) {
  1492. wprintk("%s: Asus Tiger 3in1, no lnbp21"
  1493. " found!\n", __func__);
  1494. goto detach_frontend;
  1495. }
  1496. }
  1497. }
  1498. break;
  1499. case SAA7134_BOARD_ASUSTeK_PS3_100:
  1500. if (!use_frontend) { /* terrestrial */
  1501. if (configure_tda827x_fe(dev, &asus_ps3_100_config,
  1502. &tda827x_cfg_2) < 0)
  1503. goto detach_frontend;
  1504. } else { /* satellite */
  1505. fe0->dvb.frontend = dvb_attach(tda10086_attach,
  1506. &flydvbs, &dev->i2c_adap);
  1507. if (fe0->dvb.frontend) {
  1508. if (dvb_attach(tda826x_attach,
  1509. fe0->dvb.frontend, 0x60,
  1510. &dev->i2c_adap, 0) == NULL) {
  1511. wprintk("%s: Asus My Cinema PS3-100, no "
  1512. "tda826x found!\n", __func__);
  1513. goto detach_frontend;
  1514. }
  1515. if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
  1516. &dev->i2c_adap, 0, 0) == NULL) {
  1517. wprintk("%s: Asus My Cinema PS3-100, no lnbp21"
  1518. " found!\n", __func__);
  1519. goto detach_frontend;
  1520. }
  1521. }
  1522. }
  1523. break;
  1524. case SAA7134_BOARD_ASUSTeK_TIGER:
  1525. if (configure_tda827x_fe(dev, &philips_tiger_config,
  1526. &tda827x_cfg_0) < 0)
  1527. goto detach_frontend;
  1528. break;
  1529. case SAA7134_BOARD_BEHOLD_H6:
  1530. fe0->dvb.frontend = dvb_attach(zl10353_attach,
  1531. &behold_h6_config,
  1532. &dev->i2c_adap);
  1533. if (fe0->dvb.frontend) {
  1534. dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
  1535. &dev->i2c_adap, 0x61,
  1536. TUNER_PHILIPS_FMD1216MEX_MK3);
  1537. }
  1538. break;
  1539. case SAA7134_BOARD_BEHOLD_X7:
  1540. fe0->dvb.frontend = dvb_attach(zl10353_attach,
  1541. &behold_x7_config,
  1542. &dev->i2c_adap);
  1543. if (fe0->dvb.frontend) {
  1544. dvb_attach(xc5000_attach, fe0->dvb.frontend,
  1545. &dev->i2c_adap, &behold_x7_tunerconfig);
  1546. }
  1547. break;
  1548. case SAA7134_BOARD_BEHOLD_H7:
  1549. fe0->dvb.frontend = dvb_attach(zl10353_attach,
  1550. &behold_x7_config,
  1551. &dev->i2c_adap);
  1552. if (fe0->dvb.frontend) {
  1553. dvb_attach(xc5000_attach, fe0->dvb.frontend,
  1554. &dev->i2c_adap, &behold_x7_tunerconfig);
  1555. }
  1556. break;
  1557. case SAA7134_BOARD_AVERMEDIA_A700_PRO:
  1558. case SAA7134_BOARD_AVERMEDIA_A700_HYBRID:
  1559. /* Zarlink ZL10313 */
  1560. fe0->dvb.frontend = dvb_attach(mt312_attach,
  1561. &avertv_a700_mt312, &dev->i2c_adap);
  1562. if (fe0->dvb.frontend) {
  1563. if (dvb_attach(zl10036_attach, fe0->dvb.frontend,
  1564. &avertv_a700_tuner, &dev->i2c_adap) == NULL) {
  1565. wprintk("%s: No zl10036 found!\n",
  1566. __func__);
  1567. }
  1568. }
  1569. break;
  1570. case SAA7134_BOARD_VIDEOMATE_S350:
  1571. fe0->dvb.frontend = dvb_attach(mt312_attach,
  1572. &zl10313_compro_s350_config, &dev->i2c_adap);
  1573. if (fe0->dvb.frontend)
  1574. if (dvb_attach(zl10039_attach, fe0->dvb.frontend,
  1575. 0x60, &dev->i2c_adap) == NULL)
  1576. wprintk("%s: No zl10039 found!\n",
  1577. __func__);
  1578. break;
  1579. case SAA7134_BOARD_VIDEOMATE_T750:
  1580. fe0->dvb.frontend = dvb_attach(zl10353_attach,
  1581. &videomate_t750_zl10353_config,
  1582. &dev->i2c_adap);
  1583. if (fe0->dvb.frontend != NULL) {
  1584. if (dvb_attach(qt1010_attach,
  1585. fe0->dvb.frontend,
  1586. &dev->i2c_adap,
  1587. &videomate_t750_qt1010_config) == NULL)
  1588. wprintk("error attaching QT1010\n");
  1589. }
  1590. break;
  1591. case SAA7134_BOARD_ZOLID_HYBRID_PCI:
  1592. fe0->dvb.frontend = dvb_attach(tda10048_attach,
  1593. &zolid_tda10048_config,
  1594. &dev->i2c_adap);
  1595. if (fe0->dvb.frontend != NULL) {
  1596. dvb_attach(tda829x_attach, fe0->dvb.frontend,
  1597. &dev->i2c_adap, 0x4b,
  1598. &tda829x_no_probe);
  1599. dvb_attach(tda18271_attach, fe0->dvb.frontend,
  1600. 0x60, &dev->i2c_adap,
  1601. &zolid_tda18271_config);
  1602. }
  1603. break;
  1604. case SAA7134_BOARD_LEADTEK_WINFAST_DTV1000S:
  1605. fe0->dvb.frontend = dvb_attach(tda10048_attach,
  1606. &dtv1000s_tda10048_config,
  1607. &dev->i2c_adap);
  1608. if (fe0->dvb.frontend != NULL) {
  1609. dvb_attach(tda829x_attach, fe0->dvb.frontend,
  1610. &dev->i2c_adap, 0x4b,
  1611. &tda829x_no_probe);
  1612. dvb_attach(tda18271_attach, fe0->dvb.frontend,
  1613. 0x60, &dev->i2c_adap,
  1614. &dtv1000s_tda18271_config);
  1615. }
  1616. break;
  1617. case SAA7134_BOARD_KWORLD_PCI_SBTVD_FULLSEG:
  1618. /* Switch to digital mode */
  1619. saa7134_tuner_callback(dev, 0,
  1620. TDA18271_CALLBACK_CMD_AGC_ENABLE, 1);
  1621. fe0->dvb.frontend = dvb_attach(mb86a20s_attach,
  1622. &kworld_mb86a20s_config,
  1623. &dev->i2c_adap);
  1624. if (fe0->dvb.frontend != NULL) {
  1625. dvb_attach(tda829x_attach, fe0->dvb.frontend,
  1626. &dev->i2c_adap, 0x4b,
  1627. &tda829x_no_probe);
  1628. fe0->dvb.frontend->ops.i2c_gate_ctrl = kworld_sbtvd_gate_ctrl;
  1629. dvb_attach(tda18271_attach, fe0->dvb.frontend,
  1630. 0x60, &dev->i2c_adap,
  1631. &kworld_tda18271_config);
  1632. }
  1633. /* mb86a20s need to use the I2C gateway */
  1634. break;
  1635. case SAA7134_BOARD_MAGICPRO_PROHDTV_PRO2:
  1636. fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
  1637. &prohdtv_pro2_lgs8g75_config,
  1638. &dev->i2c_adap);
  1639. if (fe0->dvb.frontend != NULL) {
  1640. dvb_attach(tda829x_attach, fe0->dvb.frontend,
  1641. &dev->i2c_adap, 0x4b,
  1642. &tda829x_no_probe);
  1643. dvb_attach(tda18271_attach, fe0->dvb.frontend,
  1644. 0x60, &dev->i2c_adap,
  1645. &prohdtv_pro2_tda18271_config);
  1646. }
  1647. break;
  1648. default:
  1649. wprintk("Huh? unknown DVB card?\n");
  1650. break;
  1651. }
  1652. if (attach_xc3028) {
  1653. struct dvb_frontend *fe;
  1654. struct xc2028_config cfg = {
  1655. .i2c_adap = &dev->i2c_adap,
  1656. .i2c_addr = 0x61,
  1657. };
  1658. if (!fe0->dvb.frontend)
  1659. goto detach_frontend;
  1660. fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
  1661. if (!fe) {
  1662. printk(KERN_ERR "%s/2: xc3028 attach failed\n",
  1663. dev->name);
  1664. goto detach_frontend;
  1665. }
  1666. }
  1667. if (NULL == fe0->dvb.frontend) {
  1668. printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
  1669. goto detach_frontend;
  1670. }
  1671. /* define general-purpose callback pointer */
  1672. fe0->dvb.frontend->callback = saa7134_tuner_callback;
  1673. /* register everything else */
  1674. ret = videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
  1675. &dev->pci->dev, adapter_nr, 0);
  1676. /* this sequence is necessary to make the tda1004x load its firmware
  1677. * and to enter analog mode of hybrid boards
  1678. */
  1679. if (!ret) {
  1680. if (fe0->dvb.frontend->ops.init)
  1681. fe0->dvb.frontend->ops.init(fe0->dvb.frontend);
  1682. if (fe0->dvb.frontend->ops.sleep)
  1683. fe0->dvb.frontend->ops.sleep(fe0->dvb.frontend);
  1684. if (fe0->dvb.frontend->ops.tuner_ops.sleep)
  1685. fe0->dvb.frontend->ops.tuner_ops.sleep(fe0->dvb.frontend);
  1686. }
  1687. return ret;
  1688. detach_frontend:
  1689. videobuf_dvb_dealloc_frontends(&dev->frontends);
  1690. return -EINVAL;
  1691. }
  1692. static int dvb_fini(struct saa7134_dev *dev)
  1693. {
  1694. struct videobuf_dvb_frontend *fe0;
  1695. /* Get the first frontend */
  1696. fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
  1697. if (!fe0)
  1698. return -EINVAL;
  1699. /* FIXME: I suspect that this code is bogus, since the entry for
  1700. Pinnacle 300I DVB-T PAL already defines the proper init to allow
  1701. the detection of mt2032 (TDA9887_PORT2_INACTIVE)
  1702. */
  1703. if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
  1704. struct v4l2_priv_tun_config tda9887_cfg;
  1705. static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
  1706. tda9887_cfg.tuner = TUNER_TDA9887;
  1707. tda9887_cfg.priv = &on;
  1708. /* otherwise we don't detect the tuner on next insmod */
  1709. saa_call_all(dev, tuner, s_config, &tda9887_cfg);
  1710. } else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) {
  1711. if ((dev->eedata[2] == 0x07) && use_frontend) {
  1712. /* turn off the 2nd lnb supply */
  1713. u8 data = 0x80;
  1714. struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1};
  1715. struct dvb_frontend *fe;
  1716. fe = fe0->dvb.frontend;
  1717. if (fe->ops.i2c_gate_ctrl) {
  1718. fe->ops.i2c_gate_ctrl(fe, 1);
  1719. i2c_transfer(&dev->i2c_adap, &msg, 1);
  1720. fe->ops.i2c_gate_ctrl(fe, 0);
  1721. }
  1722. }
  1723. }
  1724. videobuf_dvb_unregister_bus(&dev->frontends);
  1725. return 0;
  1726. }
  1727. static struct saa7134_mpeg_ops dvb_ops = {
  1728. .type = SAA7134_MPEG_DVB,
  1729. .init = dvb_init,
  1730. .fini = dvb_fini,
  1731. };
  1732. static int __init dvb_register(void)
  1733. {
  1734. return saa7134_ts_register(&dvb_ops);
  1735. }
  1736. static void __exit dvb_unregister(void)
  1737. {
  1738. saa7134_ts_unregister(&dvb_ops);
  1739. }
  1740. module_init(dvb_register);
  1741. module_exit(dvb_unregister);
  1742. /* ------------------------------------------------------------------ */
  1743. /*
  1744. * Local variables:
  1745. * c-basic-offset: 8
  1746. * End:
  1747. */