saa7134-dvb.c 55 KB

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