saa7134-dvb.c 51 KB

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