saa7134-dvb.c 46 KB

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