saa7134-dvb.c 48 KB

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