saa7134-dvb.c 52 KB

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