saa7134-dvb.c 47 KB

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