saa7134-dvb.c 50 KB

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