saa7134-dvb.c 52 KB

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