saa7134-dvb.c 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481
  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 "mt352.h"
  35. #include "mt352_priv.h" /* FIXME */
  36. #include "tda1004x.h"
  37. #include "nxt200x.h"
  38. #include "tda10086.h"
  39. #include "tda826x.h"
  40. #include "isl6421.h"
  41. MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
  42. MODULE_LICENSE("GPL");
  43. static unsigned int antenna_pwr = 0;
  44. module_param(antenna_pwr, int, 0444);
  45. MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
  46. static int use_frontend = 0;
  47. module_param(use_frontend, int, 0644);
  48. MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
  49. /* ------------------------------------------------------------------ */
  50. static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
  51. {
  52. u32 ok;
  53. if (!on) {
  54. saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
  55. saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
  56. return 0;
  57. }
  58. saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
  59. saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
  60. udelay(10);
  61. saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28));
  62. saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
  63. udelay(10);
  64. saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
  65. udelay(10);
  66. ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
  67. printk("%s: %s %s\n", dev->name, __FUNCTION__,
  68. ok ? "on" : "off");
  69. if (!ok)
  70. saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
  71. return ok;
  72. }
  73. static int mt352_pinnacle_init(struct dvb_frontend* fe)
  74. {
  75. static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 };
  76. static u8 reset [] = { RESET, 0x80 };
  77. static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
  78. static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
  79. static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
  80. static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 };
  81. static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f };
  82. static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d };
  83. static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
  84. struct saa7134_dev *dev= fe->dvb->priv;
  85. printk("%s: %s called\n",dev->name,__FUNCTION__);
  86. mt352_write(fe, clock_config, sizeof(clock_config));
  87. udelay(200);
  88. mt352_write(fe, reset, sizeof(reset));
  89. mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
  90. mt352_write(fe, agc_cfg, sizeof(agc_cfg));
  91. mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
  92. mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
  93. mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
  94. mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
  95. mt352_write(fe, irq_cfg, sizeof(irq_cfg));
  96. return 0;
  97. }
  98. static int mt352_aver777_init(struct dvb_frontend* fe)
  99. {
  100. static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
  101. static u8 reset [] = { RESET, 0x80 };
  102. static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
  103. static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
  104. static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
  105. mt352_write(fe, clock_config, sizeof(clock_config));
  106. udelay(200);
  107. mt352_write(fe, reset, sizeof(reset));
  108. mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
  109. mt352_write(fe, agc_cfg, sizeof(agc_cfg));
  110. mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
  111. return 0;
  112. }
  113. static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
  114. struct dvb_frontend_parameters* params)
  115. {
  116. u8 off[] = { 0x00, 0xf1};
  117. u8 on[] = { 0x00, 0x71};
  118. struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
  119. struct saa7134_dev *dev = fe->dvb->priv;
  120. struct v4l2_frequency f;
  121. /* set frequency (mt2050) */
  122. f.tuner = 0;
  123. f.type = V4L2_TUNER_DIGITAL_TV;
  124. f.frequency = params->frequency / 1000 * 16 / 1000;
  125. if (fe->ops.i2c_gate_ctrl)
  126. fe->ops.i2c_gate_ctrl(fe, 1);
  127. i2c_transfer(&dev->i2c_adap, &msg, 1);
  128. saa7134_i2c_call_clients(dev,VIDIOC_S_FREQUENCY,&f);
  129. msg.buf = on;
  130. if (fe->ops.i2c_gate_ctrl)
  131. fe->ops.i2c_gate_ctrl(fe, 1);
  132. i2c_transfer(&dev->i2c_adap, &msg, 1);
  133. pinnacle_antenna_pwr(dev, antenna_pwr);
  134. /* mt352 setup */
  135. return mt352_pinnacle_init(fe);
  136. }
  137. static int mt352_aver777_tuner_calc_regs(struct dvb_frontend *fe, struct dvb_frontend_parameters *params, u8* pllbuf, int buf_len)
  138. {
  139. if (buf_len < 5)
  140. return -EINVAL;
  141. pllbuf[0] = 0x61;
  142. dvb_pll_configure(&dvb_pll_philips_td1316, pllbuf+1,
  143. params->frequency,
  144. params->u.ofdm.bandwidth);
  145. return 5;
  146. }
  147. static struct mt352_config pinnacle_300i = {
  148. .demod_address = 0x3c >> 1,
  149. .adc_clock = 20333,
  150. .if2 = 36150,
  151. .no_tuner = 1,
  152. .demod_init = mt352_pinnacle_init,
  153. };
  154. static struct mt352_config avermedia_777 = {
  155. .demod_address = 0xf,
  156. .demod_init = mt352_aver777_init,
  157. };
  158. /* ------------------------------------------------------------------ */
  159. static int philips_tda6651_pll_set(u8 addr, struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  160. {
  161. struct saa7134_dev *dev = fe->dvb->priv;
  162. u8 tuner_buf[4];
  163. struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
  164. sizeof(tuner_buf) };
  165. int tuner_frequency = 0;
  166. u8 band, cp, filter;
  167. /* determine charge pump */
  168. tuner_frequency = params->frequency + 36166000;
  169. if (tuner_frequency < 87000000)
  170. return -EINVAL;
  171. else if (tuner_frequency < 130000000)
  172. cp = 3;
  173. else if (tuner_frequency < 160000000)
  174. cp = 5;
  175. else if (tuner_frequency < 200000000)
  176. cp = 6;
  177. else if (tuner_frequency < 290000000)
  178. cp = 3;
  179. else if (tuner_frequency < 420000000)
  180. cp = 5;
  181. else if (tuner_frequency < 480000000)
  182. cp = 6;
  183. else if (tuner_frequency < 620000000)
  184. cp = 3;
  185. else if (tuner_frequency < 830000000)
  186. cp = 5;
  187. else if (tuner_frequency < 895000000)
  188. cp = 7;
  189. else
  190. return -EINVAL;
  191. /* determine band */
  192. if (params->frequency < 49000000)
  193. return -EINVAL;
  194. else if (params->frequency < 161000000)
  195. band = 1;
  196. else if (params->frequency < 444000000)
  197. band = 2;
  198. else if (params->frequency < 861000000)
  199. band = 4;
  200. else
  201. return -EINVAL;
  202. /* setup PLL filter */
  203. switch (params->u.ofdm.bandwidth) {
  204. case BANDWIDTH_6_MHZ:
  205. filter = 0;
  206. break;
  207. case BANDWIDTH_7_MHZ:
  208. filter = 0;
  209. break;
  210. case BANDWIDTH_8_MHZ:
  211. filter = 1;
  212. break;
  213. default:
  214. return -EINVAL;
  215. }
  216. /* calculate divisor
  217. * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
  218. */
  219. tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
  220. /* setup tuner buffer */
  221. tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
  222. tuner_buf[1] = tuner_frequency & 0xff;
  223. tuner_buf[2] = 0xca;
  224. tuner_buf[3] = (cp << 5) | (filter << 3) | band;
  225. if (fe->ops.i2c_gate_ctrl)
  226. fe->ops.i2c_gate_ctrl(fe, 1);
  227. if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
  228. return -EIO;
  229. msleep(1);
  230. return 0;
  231. }
  232. static int philips_tda6651_pll_init(u8 addr, struct dvb_frontend *fe)
  233. {
  234. struct saa7134_dev *dev = fe->dvb->priv;
  235. static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
  236. struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
  237. /* setup PLL configuration */
  238. if (fe->ops.i2c_gate_ctrl)
  239. fe->ops.i2c_gate_ctrl(fe, 1);
  240. if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
  241. return -EIO;
  242. msleep(1);
  243. return 0;
  244. }
  245. /* ------------------------------------------------------------------ */
  246. static int philips_tu1216_tuner_60_init(struct dvb_frontend *fe)
  247. {
  248. return philips_tda6651_pll_init(0x60, fe);
  249. }
  250. static int philips_tu1216_tuner_60_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  251. {
  252. return philips_tda6651_pll_set(0x60, fe, params);
  253. }
  254. static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
  255. const struct firmware **fw, char *name)
  256. {
  257. struct saa7134_dev *dev = fe->dvb->priv;
  258. return request_firmware(fw, name, &dev->pci->dev);
  259. }
  260. static struct tda1004x_config philips_tu1216_60_config = {
  261. .demod_address = 0x8,
  262. .invert = 1,
  263. .invert_oclk = 0,
  264. .xtal_freq = TDA10046_XTAL_4M,
  265. .agc_config = TDA10046_AGC_DEFAULT,
  266. .if_freq = TDA10046_FREQ_3617,
  267. .request_firmware = philips_tda1004x_request_firmware,
  268. };
  269. /* ------------------------------------------------------------------ */
  270. static int philips_tu1216_tuner_61_init(struct dvb_frontend *fe)
  271. {
  272. return philips_tda6651_pll_init(0x61, fe);
  273. }
  274. static int philips_tu1216_tuner_61_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  275. {
  276. return philips_tda6651_pll_set(0x61, fe, params);
  277. }
  278. static struct tda1004x_config philips_tu1216_61_config = {
  279. .demod_address = 0x8,
  280. .invert = 1,
  281. .invert_oclk = 0,
  282. .xtal_freq = TDA10046_XTAL_4M,
  283. .agc_config = TDA10046_AGC_DEFAULT,
  284. .if_freq = TDA10046_FREQ_3617,
  285. .request_firmware = philips_tda1004x_request_firmware,
  286. };
  287. /* ------------------------------------------------------------------ */
  288. static int philips_td1316_tuner_init(struct dvb_frontend *fe)
  289. {
  290. struct saa7134_dev *dev = fe->dvb->priv;
  291. static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
  292. struct i2c_msg init_msg = {.addr = 0x61,.flags = 0,.buf = msg,.len = sizeof(msg) };
  293. /* setup PLL configuration */
  294. if (fe->ops.i2c_gate_ctrl)
  295. fe->ops.i2c_gate_ctrl(fe, 1);
  296. if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
  297. return -EIO;
  298. if (fe->ops.i2c_gate_ctrl)
  299. fe->ops.i2c_gate_ctrl(fe, 0);
  300. return 0;
  301. }
  302. static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  303. {
  304. return philips_tda6651_pll_set(0x61, fe, params);
  305. }
  306. static int philips_europa_tuner_init(struct dvb_frontend *fe)
  307. {
  308. struct saa7134_dev *dev = fe->dvb->priv;
  309. static u8 msg[] = { 0x00, 0x40};
  310. struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
  311. if (philips_td1316_tuner_init(fe))
  312. return -EIO;
  313. msleep(1);
  314. if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
  315. return -EIO;
  316. return 0;
  317. }
  318. static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
  319. {
  320. struct saa7134_dev *dev = fe->dvb->priv;
  321. /* this message actually turns the tuner back to analog mode */
  322. static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
  323. struct i2c_msg analog_msg = {.addr = 0x61,.flags = 0,.buf = msg,.len = sizeof(msg) };
  324. i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
  325. msleep(1);
  326. /* switch the board to analog mode */
  327. analog_msg.addr = 0x43;
  328. analog_msg.len = 0x02;
  329. msg[0] = 0x00;
  330. msg[1] = 0x14;
  331. if (fe->ops.i2c_gate_ctrl)
  332. fe->ops.i2c_gate_ctrl(fe, 1);
  333. i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
  334. return 0;
  335. }
  336. static int philips_europa_demod_sleep(struct dvb_frontend *fe)
  337. {
  338. struct saa7134_dev *dev = fe->dvb->priv;
  339. if (dev->original_demod_sleep)
  340. dev->original_demod_sleep(fe);
  341. fe->ops.i2c_gate_ctrl(fe, 1);
  342. return 0;
  343. }
  344. static struct tda1004x_config philips_europa_config = {
  345. .demod_address = 0x8,
  346. .invert = 0,
  347. .invert_oclk = 0,
  348. .xtal_freq = TDA10046_XTAL_4M,
  349. .agc_config = TDA10046_AGC_IFO_AUTO_POS,
  350. .if_freq = TDA10046_FREQ_052,
  351. .request_firmware = NULL,
  352. };
  353. /* ------------------------------------------------------------------ */
  354. static int philips_fmd1216_tuner_init(struct dvb_frontend *fe)
  355. {
  356. struct saa7134_dev *dev = fe->dvb->priv;
  357. /* this message is to set up ATC and ALC */
  358. static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0xa0 };
  359. struct i2c_msg tuner_msg = {.addr = 0x61,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) };
  360. if (fe->ops.i2c_gate_ctrl)
  361. fe->ops.i2c_gate_ctrl(fe, 1);
  362. if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
  363. return -EIO;
  364. msleep(1);
  365. return 0;
  366. }
  367. static int philips_fmd1216_tuner_sleep(struct dvb_frontend *fe)
  368. {
  369. struct saa7134_dev *dev = fe->dvb->priv;
  370. /* this message actually turns the tuner back to analog mode */
  371. static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0x60 };
  372. struct i2c_msg tuner_msg = {.addr = 0x61,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) };
  373. if (fe->ops.i2c_gate_ctrl)
  374. fe->ops.i2c_gate_ctrl(fe, 1);
  375. i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
  376. msleep(1);
  377. fmd1216_init[2] = 0x86;
  378. fmd1216_init[3] = 0x54;
  379. if (fe->ops.i2c_gate_ctrl)
  380. fe->ops.i2c_gate_ctrl(fe, 1);
  381. i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
  382. msleep(1);
  383. return 0;
  384. }
  385. static int philips_fmd1216_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  386. {
  387. struct saa7134_dev *dev = fe->dvb->priv;
  388. u8 tuner_buf[4];
  389. struct i2c_msg tuner_msg = {.addr = 0x61,.flags = 0,.buf = tuner_buf,.len =
  390. sizeof(tuner_buf) };
  391. int tuner_frequency = 0;
  392. int divider = 0;
  393. u8 band, mode, cp;
  394. /* determine charge pump */
  395. tuner_frequency = params->frequency + 36130000;
  396. if (tuner_frequency < 87000000)
  397. return -EINVAL;
  398. /* low band */
  399. else if (tuner_frequency < 180000000) {
  400. band = 1;
  401. mode = 7;
  402. cp = 0;
  403. } else if (tuner_frequency < 195000000) {
  404. band = 1;
  405. mode = 6;
  406. cp = 1;
  407. /* mid band */
  408. } else if (tuner_frequency < 366000000) {
  409. if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
  410. band = 10;
  411. } else {
  412. band = 2;
  413. }
  414. mode = 7;
  415. cp = 0;
  416. } else if (tuner_frequency < 478000000) {
  417. if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
  418. band = 10;
  419. } else {
  420. band = 2;
  421. }
  422. mode = 6;
  423. cp = 1;
  424. /* high band */
  425. } else if (tuner_frequency < 662000000) {
  426. if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
  427. band = 12;
  428. } else {
  429. band = 4;
  430. }
  431. mode = 7;
  432. cp = 0;
  433. } else if (tuner_frequency < 840000000) {
  434. if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
  435. band = 12;
  436. } else {
  437. band = 4;
  438. }
  439. mode = 6;
  440. cp = 1;
  441. } else {
  442. if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
  443. band = 12;
  444. } else {
  445. band = 4;
  446. }
  447. mode = 7;
  448. cp = 1;
  449. }
  450. /* calculate divisor */
  451. /* ((36166000 + Finput) / 166666) rounded! */
  452. divider = (tuner_frequency + 83333) / 166667;
  453. /* setup tuner buffer */
  454. tuner_buf[0] = (divider >> 8) & 0x7f;
  455. tuner_buf[1] = divider & 0xff;
  456. tuner_buf[2] = 0x80 | (cp << 6) | (mode << 3) | 4;
  457. tuner_buf[3] = 0x40 | band;
  458. if (fe->ops.i2c_gate_ctrl)
  459. fe->ops.i2c_gate_ctrl(fe, 1);
  460. if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
  461. return -EIO;
  462. return 0;
  463. }
  464. static struct tda1004x_config medion_cardbus = {
  465. .demod_address = 0x08,
  466. .invert = 1,
  467. .invert_oclk = 0,
  468. .xtal_freq = TDA10046_XTAL_16M,
  469. .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
  470. .if_freq = TDA10046_FREQ_3613,
  471. .request_firmware = NULL,
  472. };
  473. /* ------------------------------------------------------------------ */
  474. struct tda827x_data {
  475. u32 lomax;
  476. u8 spd;
  477. u8 bs;
  478. u8 bp;
  479. u8 cp;
  480. u8 gc3;
  481. u8 div1p5;
  482. };
  483. static struct tda827x_data tda827x_dvbt[] = {
  484. { .lomax = 62000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 1},
  485. { .lomax = 66000000, .spd = 3, .bs = 3, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 1},
  486. { .lomax = 76000000, .spd = 3, .bs = 1, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 0},
  487. { .lomax = 84000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 0},
  488. { .lomax = 93000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 1, .div1p5 = 0},
  489. { .lomax = 98000000, .spd = 3, .bs = 3, .bp = 0, .cp = 0, .gc3 = 1, .div1p5 = 0},
  490. { .lomax = 109000000, .spd = 3, .bs = 3, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0},
  491. { .lomax = 123000000, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 1},
  492. { .lomax = 133000000, .spd = 2, .bs = 3, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 1},
  493. { .lomax = 151000000, .spd = 2, .bs = 1, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0},
  494. { .lomax = 154000000, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0},
  495. { .lomax = 181000000, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 0, .div1p5 = 0},
  496. { .lomax = 185000000, .spd = 2, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
  497. { .lomax = 217000000, .spd = 2, .bs = 3, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
  498. { .lomax = 244000000, .spd = 1, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 1},
  499. { .lomax = 265000000, .spd = 1, .bs = 3, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 1},
  500. { .lomax = 302000000, .spd = 1, .bs = 1, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
  501. { .lomax = 324000000, .spd = 1, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
  502. { .lomax = 370000000, .spd = 1, .bs = 2, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0},
  503. { .lomax = 454000000, .spd = 1, .bs = 3, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0},
  504. { .lomax = 493000000, .spd = 0, .bs = 2, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 1},
  505. { .lomax = 530000000, .spd = 0, .bs = 3, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 1},
  506. { .lomax = 554000000, .spd = 0, .bs = 1, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0},
  507. { .lomax = 604000000, .spd = 0, .bs = 1, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0},
  508. { .lomax = 696000000, .spd = 0, .bs = 2, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0},
  509. { .lomax = 740000000, .spd = 0, .bs = 2, .bp = 4, .cp = 1, .gc3 = 0, .div1p5 = 0},
  510. { .lomax = 820000000, .spd = 0, .bs = 3, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0},
  511. { .lomax = 865000000, .spd = 0, .bs = 3, .bp = 4, .cp = 1, .gc3 = 0, .div1p5 = 0},
  512. { .lomax = 0, .spd = 0, .bs = 0, .bp = 0, .cp = 0, .gc3 = 0, .div1p5 = 0}
  513. };
  514. static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
  515. {
  516. return 0;
  517. }
  518. static int philips_tda827x_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  519. {
  520. struct saa7134_dev *dev = fe->dvb->priv;
  521. u8 tuner_buf[14];
  522. struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tuner_buf,
  523. .len = sizeof(tuner_buf) };
  524. int i, tuner_freq, if_freq;
  525. u32 N;
  526. switch (params->u.ofdm.bandwidth) {
  527. case BANDWIDTH_6_MHZ:
  528. if_freq = 4000000;
  529. break;
  530. case BANDWIDTH_7_MHZ:
  531. if_freq = 4500000;
  532. break;
  533. default: /* 8 MHz or Auto */
  534. if_freq = 5000000;
  535. break;
  536. }
  537. tuner_freq = params->frequency + if_freq;
  538. i = 0;
  539. while (tda827x_dvbt[i].lomax < tuner_freq) {
  540. if(tda827x_dvbt[i + 1].lomax == 0)
  541. break;
  542. i++;
  543. }
  544. N = ((tuner_freq + 125000) / 250000) << (tda827x_dvbt[i].spd + 2);
  545. tuner_buf[0] = 0;
  546. tuner_buf[1] = (N>>8) | 0x40;
  547. tuner_buf[2] = N & 0xff;
  548. tuner_buf[3] = 0;
  549. tuner_buf[4] = 0x52;
  550. tuner_buf[5] = (tda827x_dvbt[i].spd << 6) + (tda827x_dvbt[i].div1p5 << 5) +
  551. (tda827x_dvbt[i].bs << 3) + tda827x_dvbt[i].bp;
  552. tuner_buf[6] = (tda827x_dvbt[i].gc3 << 4) + 0x8f;
  553. tuner_buf[7] = 0xbf;
  554. tuner_buf[8] = 0x2a;
  555. tuner_buf[9] = 0x05;
  556. tuner_buf[10] = 0xff;
  557. tuner_buf[11] = 0x00;
  558. tuner_buf[12] = 0x00;
  559. tuner_buf[13] = 0x40;
  560. tuner_msg.len = 14;
  561. if (fe->ops.i2c_gate_ctrl)
  562. fe->ops.i2c_gate_ctrl(fe, 1);
  563. if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
  564. return -EIO;
  565. msleep(500);
  566. /* correct CP value */
  567. tuner_buf[0] = 0x30;
  568. tuner_buf[1] = 0x50 + tda827x_dvbt[i].cp;
  569. tuner_msg.len = 2;
  570. if (fe->ops.i2c_gate_ctrl)
  571. fe->ops.i2c_gate_ctrl(fe, 1);
  572. i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
  573. return 0;
  574. }
  575. static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
  576. {
  577. struct saa7134_dev *dev = fe->dvb->priv;
  578. static u8 tda827x_sleep[] = { 0x30, 0xd0};
  579. struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tda827x_sleep,
  580. .len = sizeof(tda827x_sleep) };
  581. if (fe->ops.i2c_gate_ctrl)
  582. fe->ops.i2c_gate_ctrl(fe, 1);
  583. i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
  584. return 0;
  585. }
  586. static struct tda1004x_config tda827x_lifeview_config = {
  587. .demod_address = 0x08,
  588. .invert = 1,
  589. .invert_oclk = 0,
  590. .xtal_freq = TDA10046_XTAL_16M,
  591. .agc_config = TDA10046_AGC_TDA827X_GP11,
  592. .if_freq = TDA10046_FREQ_045,
  593. .request_firmware = NULL,
  594. };
  595. /* ------------------------------------------------------------------ */
  596. struct tda827xa_data {
  597. u32 lomax;
  598. u8 svco;
  599. u8 spd;
  600. u8 scr;
  601. u8 sbs;
  602. u8 gc3;
  603. };
  604. static struct tda827xa_data tda827xa_dvbt[] = {
  605. { .lomax = 56875000, .svco = 3, .spd = 4, .scr = 0, .sbs = 0, .gc3 = 1},
  606. { .lomax = 67250000, .svco = 0, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 1},
  607. { .lomax = 81250000, .svco = 1, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 1},
  608. { .lomax = 97500000, .svco = 2, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 1},
  609. { .lomax = 113750000, .svco = 3, .spd = 3, .scr = 0, .sbs = 1, .gc3 = 1},
  610. { .lomax = 134500000, .svco = 0, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
  611. { .lomax = 154000000, .svco = 1, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
  612. { .lomax = 162500000, .svco = 1, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
  613. { .lomax = 183000000, .svco = 2, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
  614. { .lomax = 195000000, .svco = 2, .spd = 2, .scr = 0, .sbs = 2, .gc3 = 1},
  615. { .lomax = 227500000, .svco = 3, .spd = 2, .scr = 0, .sbs = 2, .gc3 = 1},
  616. { .lomax = 269000000, .svco = 0, .spd = 1, .scr = 0, .sbs = 2, .gc3 = 1},
  617. { .lomax = 290000000, .svco = 1, .spd = 1, .scr = 0, .sbs = 2, .gc3 = 1},
  618. { .lomax = 325000000, .svco = 1, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 1},
  619. { .lomax = 390000000, .svco = 2, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 1},
  620. { .lomax = 455000000, .svco = 3, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 1},
  621. { .lomax = 520000000, .svco = 0, .spd = 0, .scr = 0, .sbs = 3, .gc3 = 1},
  622. { .lomax = 538000000, .svco = 0, .spd = 0, .scr = 1, .sbs = 3, .gc3 = 1},
  623. { .lomax = 550000000, .svco = 1, .spd = 0, .scr = 0, .sbs = 3, .gc3 = 1},
  624. { .lomax = 620000000, .svco = 1, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0},
  625. { .lomax = 650000000, .svco = 1, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0},
  626. { .lomax = 700000000, .svco = 2, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0},
  627. { .lomax = 780000000, .svco = 2, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0},
  628. { .lomax = 820000000, .svco = 3, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0},
  629. { .lomax = 870000000, .svco = 3, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0},
  630. { .lomax = 911000000, .svco = 3, .spd = 0, .scr = 2, .sbs = 4, .gc3 = 0},
  631. { .lomax = 0, .svco = 0, .spd = 0, .scr = 0, .sbs = 0, .gc3 = 0}};
  632. static int philips_tda827xa_pll_set(u8 addr, struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  633. {
  634. struct saa7134_dev *dev = fe->dvb->priv;
  635. u8 tuner_buf[14];
  636. unsigned char reg2[2];
  637. struct i2c_msg msg = {.addr = addr,.flags = 0,.buf = tuner_buf};
  638. int i, tuner_freq, if_freq;
  639. u32 N;
  640. switch (params->u.ofdm.bandwidth) {
  641. case BANDWIDTH_6_MHZ:
  642. if_freq = 4000000;
  643. break;
  644. case BANDWIDTH_7_MHZ:
  645. if_freq = 4500000;
  646. break;
  647. default: /* 8 MHz or Auto */
  648. if_freq = 5000000;
  649. break;
  650. }
  651. tuner_freq = params->frequency + if_freq;
  652. i = 0;
  653. while (tda827xa_dvbt[i].lomax < tuner_freq) {
  654. if(tda827xa_dvbt[i + 1].lomax == 0)
  655. break;
  656. i++;
  657. }
  658. N = ((tuner_freq + 31250) / 62500) << tda827xa_dvbt[i].spd;
  659. tuner_buf[0] = 0; // subaddress
  660. tuner_buf[1] = N >> 8;
  661. tuner_buf[2] = N & 0xff;
  662. tuner_buf[3] = 0;
  663. tuner_buf[4] = 0x16;
  664. tuner_buf[5] = (tda827xa_dvbt[i].spd << 5) + (tda827xa_dvbt[i].svco << 3) +
  665. tda827xa_dvbt[i].sbs;
  666. tuner_buf[6] = 0x4b + (tda827xa_dvbt[i].gc3 << 4);
  667. tuner_buf[7] = 0x0c;
  668. tuner_buf[8] = 0x06;
  669. tuner_buf[9] = 0x24;
  670. tuner_buf[10] = 0xff;
  671. tuner_buf[11] = 0x60;
  672. tuner_buf[12] = 0x00;
  673. tuner_buf[13] = 0x39; // lpsel
  674. msg.len = 14;
  675. if (fe->ops.i2c_gate_ctrl)
  676. fe->ops.i2c_gate_ctrl(fe, 1);
  677. if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1)
  678. return -EIO;
  679. msg.buf= reg2;
  680. msg.len = 2;
  681. reg2[0] = 0x60;
  682. reg2[1] = 0x3c;
  683. if (fe->ops.i2c_gate_ctrl)
  684. fe->ops.i2c_gate_ctrl(fe, 1);
  685. i2c_transfer(&dev->i2c_adap, &msg, 1);
  686. reg2[0] = 0xa0;
  687. reg2[1] = 0x40;
  688. if (fe->ops.i2c_gate_ctrl)
  689. fe->ops.i2c_gate_ctrl(fe, 1);
  690. i2c_transfer(&dev->i2c_adap, &msg, 1);
  691. msleep(2);
  692. /* correct CP value */
  693. reg2[0] = 0x30;
  694. reg2[1] = 0x10 + tda827xa_dvbt[i].scr;
  695. msg.len = 2;
  696. if (fe->ops.i2c_gate_ctrl)
  697. fe->ops.i2c_gate_ctrl(fe, 1);
  698. i2c_transfer(&dev->i2c_adap, &msg, 1);
  699. msleep(550);
  700. reg2[0] = 0x50;
  701. reg2[1] = 0x4f + (tda827xa_dvbt[i].gc3 << 4);
  702. if (fe->ops.i2c_gate_ctrl)
  703. fe->ops.i2c_gate_ctrl(fe, 1);
  704. i2c_transfer(&dev->i2c_adap, &msg, 1);
  705. return 0;
  706. }
  707. static int philips_tda827xa_tuner_sleep(u8 addr, struct dvb_frontend *fe)
  708. {
  709. struct saa7134_dev *dev = fe->dvb->priv;
  710. static u8 tda827xa_sleep[] = { 0x30, 0x90};
  711. struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tda827xa_sleep,
  712. .len = sizeof(tda827xa_sleep) };
  713. if (fe->ops.i2c_gate_ctrl)
  714. fe->ops.i2c_gate_ctrl(fe, 1);
  715. i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
  716. if (fe->ops.i2c_gate_ctrl)
  717. fe->ops.i2c_gate_ctrl(fe, 0);
  718. return 0;
  719. }
  720. /* ------------------------------------------------------------------ */
  721. static int tda8290_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)
  722. {
  723. struct saa7134_dev *dev = fe->dvb->priv;
  724. static u8 tda8290_close[] = { 0x21, 0xc0};
  725. static u8 tda8290_open[] = { 0x21, 0x80};
  726. struct i2c_msg tda8290_msg = {.addr = 0x4b,.flags = 0, .len = 2};
  727. if (enable) {
  728. tda8290_msg.buf = tda8290_close;
  729. } else {
  730. tda8290_msg.buf = tda8290_open;
  731. }
  732. if (i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1) != 1)
  733. return -EIO;
  734. msleep(20);
  735. return 0;
  736. }
  737. /* ------------------------------------------------------------------ */
  738. static int philips_tiger_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  739. {
  740. int ret;
  741. ret = philips_tda827xa_pll_set(0x61, fe, params);
  742. if (ret != 0)
  743. return ret;
  744. return 0;
  745. }
  746. static int philips_tiger_tuner_init(struct dvb_frontend *fe)
  747. {
  748. struct saa7134_dev *dev = fe->dvb->priv;
  749. static u8 data[] = { 0x3c, 0x33, 0x6a};
  750. struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
  751. if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1)
  752. return -EIO;
  753. return 0;
  754. }
  755. static int philips_tiger_tuner_sleep(struct dvb_frontend *fe)
  756. {
  757. struct saa7134_dev *dev = fe->dvb->priv;
  758. static u8 data[] = { 0x3c, 0x33, 0x68};
  759. struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
  760. i2c_transfer(&dev->i2c_adap, &msg, 1);
  761. philips_tda827xa_tuner_sleep( 0x61, fe);
  762. return 0;
  763. }
  764. static struct tda1004x_config philips_tiger_config = {
  765. .demod_address = 0x08,
  766. .invert = 1,
  767. .invert_oclk = 0,
  768. .xtal_freq = TDA10046_XTAL_16M,
  769. .agc_config = TDA10046_AGC_TDA827X_GP11,
  770. .if_freq = TDA10046_FREQ_045,
  771. .request_firmware = NULL,
  772. };
  773. /* ------------------------------------------------------------------ */
  774. static int cinergy_ht_tuner_init(struct dvb_frontend *fe)
  775. {
  776. struct saa7134_dev *dev = fe->dvb->priv;
  777. static u8 data[] = { 0x3c, 0x33, 0x62};
  778. struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
  779. if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1)
  780. return -EIO;
  781. return 0;
  782. }
  783. static int cinergy_ht_tuner_sleep(struct dvb_frontend *fe)
  784. {
  785. struct saa7134_dev *dev = fe->dvb->priv;
  786. static u8 data[] = { 0x3c, 0x33, 0x60};
  787. struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
  788. i2c_transfer(&dev->i2c_adap, &msg, 1);
  789. philips_tda827xa_tuner_sleep( 0x61, fe);
  790. return 0;
  791. }
  792. static struct tda1004x_config cinergy_ht_config = {
  793. .demod_address = 0x08,
  794. .invert = 1,
  795. .invert_oclk = 0,
  796. .xtal_freq = TDA10046_XTAL_16M,
  797. .agc_config = TDA10046_AGC_TDA827X_GP01,
  798. .if_freq = TDA10046_FREQ_045,
  799. .request_firmware = NULL,
  800. };
  801. /* ------------------------------------------------------------------ */
  802. static struct tda1004x_config pinnacle_pctv_310i_config = {
  803. .demod_address = 0x08,
  804. .invert = 1,
  805. .invert_oclk = 0,
  806. .xtal_freq = TDA10046_XTAL_16M,
  807. .agc_config = TDA10046_AGC_TDA827X_GP11,
  808. .if_freq = TDA10046_FREQ_045,
  809. .request_firmware = philips_tda1004x_request_firmware,
  810. };
  811. /* ------------------------------------------------------------------ */
  812. static struct tda1004x_config hauppauge_hvr_1110_config = {
  813. .demod_address = 0x08,
  814. .invert = 1,
  815. .invert_oclk = 0,
  816. .xtal_freq = TDA10046_XTAL_16M,
  817. .agc_config = TDA10046_AGC_TDA827X_GP11,
  818. .if_freq = TDA10046_FREQ_045,
  819. .request_firmware = philips_tda1004x_request_firmware,
  820. };
  821. /* ------------------------------------------------------------------ */
  822. static struct tda1004x_config asus_p7131_dual_config = {
  823. .demod_address = 0x08,
  824. .invert = 1,
  825. .invert_oclk = 0,
  826. .xtal_freq = TDA10046_XTAL_16M,
  827. .agc_config = TDA10046_AGC_TDA827X_GP11,
  828. .if_freq = TDA10046_FREQ_045,
  829. .request_firmware = philips_tda1004x_request_firmware,
  830. };
  831. static int asus_p7131_dual_tuner_init(struct dvb_frontend *fe)
  832. {
  833. struct saa7134_dev *dev = fe->dvb->priv;
  834. static u8 data[] = { 0x3c, 0x33, 0x6a};
  835. struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
  836. if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1)
  837. return -EIO;
  838. /* make sure the DVB-T antenna input is set */
  839. saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x0200000);
  840. return 0;
  841. }
  842. static int asus_p7131_dual_tuner_sleep(struct dvb_frontend *fe)
  843. {
  844. struct saa7134_dev *dev = fe->dvb->priv;
  845. static u8 data[] = { 0x3c, 0x33, 0x68};
  846. struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
  847. i2c_transfer(&dev->i2c_adap, &msg, 1);
  848. philips_tda827xa_tuner_sleep( 0x61, fe);
  849. /* reset antenna inputs for analog usage */
  850. saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x0200000);
  851. return 0;
  852. }
  853. /* ------------------------------------------------------------------ */
  854. static int lifeview_trio_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  855. {
  856. int ret;
  857. ret = philips_tda827xa_pll_set(0x60, fe, params);
  858. return ret;
  859. }
  860. static int lifeview_trio_tuner_sleep(struct dvb_frontend *fe)
  861. {
  862. philips_tda827xa_tuner_sleep(0x60, fe);
  863. return 0;
  864. }
  865. static struct tda1004x_config lifeview_trio_config = {
  866. .demod_address = 0x09,
  867. .invert = 1,
  868. .invert_oclk = 0,
  869. .xtal_freq = TDA10046_XTAL_16M,
  870. .agc_config = TDA10046_AGC_TDA827X_GP00,
  871. .if_freq = TDA10046_FREQ_045,
  872. .request_firmware = NULL,
  873. };
  874. /* ------------------------------------------------------------------ */
  875. static int ads_duo_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  876. {
  877. int ret;
  878. ret = philips_tda827xa_pll_set(0x61, fe, params);
  879. return ret;
  880. }
  881. static int ads_duo_tuner_init(struct dvb_frontend *fe)
  882. {
  883. struct saa7134_dev *dev = fe->dvb->priv;
  884. /* route TDA8275a AGC input to the channel decoder */
  885. saa_writeb(SAA7134_GPIO_GPSTATUS2, 0x60);
  886. return 0;
  887. }
  888. static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
  889. {
  890. struct saa7134_dev *dev = fe->dvb->priv;
  891. /* route TDA8275a AGC input to the analog IF chip*/
  892. saa_writeb(SAA7134_GPIO_GPSTATUS2, 0x20);
  893. philips_tda827xa_tuner_sleep( 0x61, fe);
  894. return 0;
  895. }
  896. static struct tda1004x_config ads_tech_duo_config = {
  897. .demod_address = 0x08,
  898. .invert = 1,
  899. .invert_oclk = 0,
  900. .xtal_freq = TDA10046_XTAL_16M,
  901. .agc_config = TDA10046_AGC_TDA827X_GP00,
  902. .if_freq = TDA10046_FREQ_045,
  903. .request_firmware = NULL,
  904. };
  905. /* ------------------------------------------------------------------ */
  906. static int tevion_dvb220rf_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  907. {
  908. int ret;
  909. ret = philips_tda827xa_pll_set(0x60, fe, params);
  910. return ret;
  911. }
  912. static int tevion_dvb220rf_tuner_sleep(struct dvb_frontend *fe)
  913. {
  914. philips_tda827xa_tuner_sleep( 0x61, fe);
  915. return 0;
  916. }
  917. static struct tda1004x_config tevion_dvbt220rf_config = {
  918. .demod_address = 0x08,
  919. .invert = 1,
  920. .invert_oclk = 0,
  921. .xtal_freq = TDA10046_XTAL_16M,
  922. .agc_config = TDA10046_AGC_TDA827X_GP11,
  923. .if_freq = TDA10046_FREQ_045,
  924. .request_firmware = NULL,
  925. };
  926. /* ------------------------------------------------------------------ */
  927. static int md8800_dvbt_analog_mode(struct dvb_frontend *fe)
  928. {
  929. struct saa7134_dev *dev = fe->dvb->priv;
  930. static u8 data[] = { 0x3c, 0x33, 0x68};
  931. struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
  932. i2c_transfer(&dev->i2c_adap, &msg, 1);
  933. philips_tda827xa_tuner_sleep( 0x61, fe);
  934. return 0;
  935. }
  936. static int md8800_dvbt_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  937. {
  938. int ret;
  939. struct saa7134_dev *dev = fe->dvb->priv;
  940. static u8 tda8290_close[] = { 0x21, 0xc0};
  941. static u8 tda8290_open[] = { 0x21, 0x80};
  942. struct i2c_msg tda8290_msg = {.addr = 0x4b,.flags = 0, .len = 2};
  943. /* close tda8290 i2c bridge */
  944. tda8290_msg.buf = tda8290_close;
  945. ret = i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1);
  946. if (ret != 1)
  947. return -EIO;
  948. msleep(20);
  949. ret = philips_tda827xa_pll_set(0x60, fe, params);
  950. if (ret != 0)
  951. return ret;
  952. /* open tda8290 i2c bridge */
  953. tda8290_msg.buf = tda8290_open;
  954. i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1);
  955. return ret;
  956. }
  957. static struct tda1004x_config md8800_dvbt_config = {
  958. .demod_address = 0x08,
  959. .invert = 1,
  960. .invert_oclk = 0,
  961. .xtal_freq = TDA10046_XTAL_16M,
  962. .agc_config = TDA10046_AGC_TDA827X_GP11,
  963. .if_freq = TDA10046_FREQ_045,
  964. .request_firmware = NULL,
  965. };
  966. static struct tda10086_config flydvbs = {
  967. .demod_address = 0x0e,
  968. .invert = 0,
  969. };
  970. /* ------------------------------------------------------------------ */
  971. static struct nxt200x_config avertvhda180 = {
  972. .demod_address = 0x0a,
  973. };
  974. static int nxt200x_set_pll_input(u8 *buf, int input)
  975. {
  976. if (input)
  977. buf[3] |= 0x08;
  978. else
  979. buf[3] &= ~0x08;
  980. return 0;
  981. }
  982. static struct nxt200x_config kworldatsc110 = {
  983. .demod_address = 0x0a,
  984. .set_pll_input = nxt200x_set_pll_input,
  985. };
  986. /* ------------------------------------------------------------------ */
  987. static int dvb_init(struct saa7134_dev *dev)
  988. {
  989. /* init struct videobuf_dvb */
  990. dev->ts.nr_bufs = 32;
  991. dev->ts.nr_packets = 32*4;
  992. dev->dvb.name = dev->name;
  993. videobuf_queue_init(&dev->dvb.dvbq, &saa7134_ts_qops,
  994. dev->pci, &dev->slock,
  995. V4L2_BUF_TYPE_VIDEO_CAPTURE,
  996. V4L2_FIELD_ALTERNATE,
  997. sizeof(struct saa7134_buf),
  998. dev);
  999. switch (dev->board) {
  1000. case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
  1001. printk("%s: pinnacle 300i dvb setup\n",dev->name);
  1002. dev->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
  1003. &dev->i2c_adap);
  1004. if (dev->dvb.frontend) {
  1005. dev->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
  1006. }
  1007. break;
  1008. case SAA7134_BOARD_AVERMEDIA_777:
  1009. case SAA7134_BOARD_AVERMEDIA_A16AR:
  1010. printk("%s: avertv 777 dvb setup\n",dev->name);
  1011. dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
  1012. &dev->i2c_adap);
  1013. if (dev->dvb.frontend) {
  1014. dev->dvb.frontend->ops.tuner_ops.calc_regs = mt352_aver777_tuner_calc_regs;
  1015. }
  1016. break;
  1017. case SAA7134_BOARD_MD7134:
  1018. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1019. &medion_cardbus,
  1020. &dev->i2c_adap);
  1021. if (dev->dvb.frontend) {
  1022. dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init;
  1023. dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep;
  1024. dev->dvb.frontend->ops.tuner_ops.set_params = philips_fmd1216_tuner_set_params;
  1025. }
  1026. break;
  1027. case SAA7134_BOARD_PHILIPS_TOUGH:
  1028. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1029. &philips_tu1216_60_config,
  1030. &dev->i2c_adap);
  1031. if (dev->dvb.frontend) {
  1032. dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_tuner_60_init;
  1033. dev->dvb.frontend->ops.tuner_ops.set_params = philips_tu1216_tuner_60_set_params;
  1034. }
  1035. break;
  1036. case SAA7134_BOARD_FLYDVBTDUO:
  1037. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1038. &tda827x_lifeview_config,
  1039. &dev->i2c_adap);
  1040. if (dev->dvb.frontend) {
  1041. dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init;
  1042. dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep;
  1043. dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda827x_tuner_set_params;
  1044. }
  1045. break;
  1046. case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
  1047. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1048. &tda827x_lifeview_config,
  1049. &dev->i2c_adap);
  1050. if (dev->dvb.frontend) {
  1051. dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init;
  1052. dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep;
  1053. dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda827x_tuner_set_params;
  1054. }
  1055. break;
  1056. case SAA7134_BOARD_PHILIPS_EUROPA:
  1057. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1058. &philips_europa_config,
  1059. &dev->i2c_adap);
  1060. if (dev->dvb.frontend) {
  1061. dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
  1062. dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
  1063. dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
  1064. dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
  1065. dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
  1066. }
  1067. break;
  1068. case SAA7134_BOARD_VIDEOMATE_DVBT_300:
  1069. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1070. &philips_europa_config,
  1071. &dev->i2c_adap);
  1072. if (dev->dvb.frontend) {
  1073. dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
  1074. dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
  1075. dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
  1076. dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
  1077. dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
  1078. }
  1079. break;
  1080. case SAA7134_BOARD_VIDEOMATE_DVBT_200:
  1081. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1082. &philips_tu1216_61_config,
  1083. &dev->i2c_adap);
  1084. if (dev->dvb.frontend) {
  1085. dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_tuner_61_init;
  1086. dev->dvb.frontend->ops.tuner_ops.set_params = philips_tu1216_tuner_61_set_params;
  1087. }
  1088. break;
  1089. case SAA7134_BOARD_PHILIPS_TIGER:
  1090. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1091. &philips_tiger_config,
  1092. &dev->i2c_adap);
  1093. if (dev->dvb.frontend) {
  1094. dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
  1095. dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
  1096. dev->dvb.frontend->ops.tuner_ops.sleep = philips_tiger_tuner_sleep;
  1097. dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
  1098. }
  1099. break;
  1100. case SAA7134_BOARD_PINNACLE_PCTV_310i:
  1101. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1102. &pinnacle_pctv_310i_config,
  1103. &dev->i2c_adap);
  1104. if (dev->dvb.frontend) {
  1105. dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
  1106. dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
  1107. dev->dvb.frontend->ops.tuner_ops.sleep = philips_tiger_tuner_sleep;
  1108. dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
  1109. }
  1110. break;
  1111. case SAA7134_BOARD_HAUPPAUGE_HVR1110:
  1112. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1113. &hauppauge_hvr_1110_config,
  1114. &dev->i2c_adap);
  1115. if (dev->dvb.frontend) {
  1116. dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
  1117. dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
  1118. dev->dvb.frontend->ops.tuner_ops.sleep = philips_tiger_tuner_sleep;
  1119. dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
  1120. }
  1121. break;
  1122. case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
  1123. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1124. &asus_p7131_dual_config,
  1125. &dev->i2c_adap);
  1126. if (dev->dvb.frontend) {
  1127. dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
  1128. dev->dvb.frontend->ops.tuner_ops.init = asus_p7131_dual_tuner_init;
  1129. dev->dvb.frontend->ops.tuner_ops.sleep = asus_p7131_dual_tuner_sleep;
  1130. dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
  1131. }
  1132. break;
  1133. case SAA7134_BOARD_FLYDVBT_LR301:
  1134. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1135. &tda827x_lifeview_config,
  1136. &dev->i2c_adap);
  1137. if (dev->dvb.frontend) {
  1138. dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init;
  1139. dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep;
  1140. dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda827x_tuner_set_params;
  1141. }
  1142. break;
  1143. case SAA7134_BOARD_FLYDVB_TRIO:
  1144. if(! use_frontend) { //terrestrial
  1145. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1146. &lifeview_trio_config,
  1147. &dev->i2c_adap);
  1148. if (dev->dvb.frontend) {
  1149. dev->dvb.frontend->ops.tuner_ops.sleep = lifeview_trio_tuner_sleep;
  1150. dev->dvb.frontend->ops.tuner_ops.set_params =
  1151. lifeview_trio_tuner_set_params;
  1152. }
  1153. } else { //satellite
  1154. dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
  1155. if (dev->dvb.frontend) {
  1156. if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63,
  1157. &dev->i2c_adap, 0) == NULL) {
  1158. printk("%s: Lifeview Trio, No tda826x found!\n", __FUNCTION__);
  1159. }
  1160. if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap,
  1161. 0x08, 0, 0) == NULL) {
  1162. printk("%s: Lifeview Trio, No ISL6421 found!\n", __FUNCTION__);
  1163. }
  1164. }
  1165. }
  1166. break;
  1167. case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
  1168. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1169. &ads_tech_duo_config,
  1170. &dev->i2c_adap);
  1171. if (dev->dvb.frontend) {
  1172. dev->dvb.frontend->ops.tuner_ops.init = ads_duo_tuner_init;
  1173. dev->dvb.frontend->ops.tuner_ops.sleep = ads_duo_tuner_sleep;
  1174. dev->dvb.frontend->ops.tuner_ops.set_params = ads_duo_tuner_set_params;
  1175. }
  1176. break;
  1177. case SAA7134_BOARD_TEVION_DVBT_220RF:
  1178. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1179. &tevion_dvbt220rf_config,
  1180. &dev->i2c_adap);
  1181. if (dev->dvb.frontend) {
  1182. dev->dvb.frontend->ops.tuner_ops.sleep = tevion_dvb220rf_tuner_sleep;
  1183. dev->dvb.frontend->ops.tuner_ops.set_params = tevion_dvb220rf_tuner_set_params;
  1184. }
  1185. break;
  1186. case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
  1187. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1188. &ads_tech_duo_config,
  1189. &dev->i2c_adap);
  1190. if (dev->dvb.frontend) {
  1191. dev->dvb.frontend->ops.tuner_ops.init = ads_duo_tuner_init;
  1192. dev->dvb.frontend->ops.tuner_ops.sleep = ads_duo_tuner_sleep;
  1193. dev->dvb.frontend->ops.tuner_ops.set_params = ads_duo_tuner_set_params;
  1194. }
  1195. break;
  1196. case SAA7134_BOARD_MEDION_MD8800_QUADRO:
  1197. dev->dvb.frontend = tda10046_attach(&md8800_dvbt_config,
  1198. &dev->i2c_adap);
  1199. if (dev->dvb.frontend) {
  1200. dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
  1201. dev->dvb.frontend->ops.tuner_ops.sleep = md8800_dvbt_analog_mode;
  1202. dev->dvb.frontend->ops.tuner_ops.set_params = md8800_dvbt_pll_set;
  1203. }
  1204. break;
  1205. case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
  1206. dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
  1207. &dev->i2c_adap);
  1208. if (dev->dvb.frontend) {
  1209. dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
  1210. NULL, &dvb_pll_tdhu2);
  1211. }
  1212. break;
  1213. case SAA7134_BOARD_KWORLD_ATSC110:
  1214. dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
  1215. &dev->i2c_adap);
  1216. if (dev->dvb.frontend) {
  1217. dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
  1218. NULL, &dvb_pll_tuv1236d);
  1219. }
  1220. break;
  1221. case SAA7134_BOARD_FLYDVBS_LR300:
  1222. dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
  1223. &dev->i2c_adap);
  1224. if (dev->dvb.frontend) {
  1225. if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
  1226. &dev->i2c_adap, 0) == NULL) {
  1227. printk("%s: No tda826x found!\n", __FUNCTION__);
  1228. }
  1229. if (dvb_attach(isl6421_attach, dev->dvb.frontend,
  1230. &dev->i2c_adap, 0x08, 0, 0) == NULL) {
  1231. printk("%s: No ISL6421 found!\n", __FUNCTION__);
  1232. }
  1233. }
  1234. break;
  1235. case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
  1236. dev->dvb.frontend = tda10046_attach(&medion_cardbus,
  1237. &dev->i2c_adap);
  1238. if (dev->dvb.frontend) {
  1239. dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
  1240. dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
  1241. dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init;
  1242. dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep;
  1243. dev->dvb.frontend->ops.tuner_ops.set_params = philips_fmd1216_tuner_set_params;
  1244. }
  1245. break;
  1246. case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
  1247. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1248. &philips_europa_config,
  1249. &dev->i2c_adap);
  1250. if (dev->dvb.frontend) {
  1251. dev->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
  1252. dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
  1253. }
  1254. break;
  1255. case SAA7134_BOARD_CINERGY_HT_PCMCIA:
  1256. dev->dvb.frontend = dvb_attach(tda10046_attach,
  1257. &cinergy_ht_config,
  1258. &dev->i2c_adap);
  1259. if (dev->dvb.frontend) {
  1260. dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
  1261. dev->dvb.frontend->ops.tuner_ops.init = cinergy_ht_tuner_init;
  1262. dev->dvb.frontend->ops.tuner_ops.sleep = cinergy_ht_tuner_sleep;
  1263. dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
  1264. }
  1265. break;
  1266. default:
  1267. printk("%s: Huh? unknown DVB card?\n",dev->name);
  1268. break;
  1269. }
  1270. if (NULL == dev->dvb.frontend) {
  1271. printk("%s: frontend initialization failed\n",dev->name);
  1272. return -1;
  1273. }
  1274. /* register everything else */
  1275. return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev);
  1276. }
  1277. static int dvb_fini(struct saa7134_dev *dev)
  1278. {
  1279. static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
  1280. switch (dev->board) {
  1281. case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
  1282. /* otherwise we don't detect the tuner on next insmod */
  1283. saa7134_i2c_call_clients(dev,TDA9887_SET_CONFIG,&on);
  1284. break;
  1285. };
  1286. videobuf_dvb_unregister(&dev->dvb);
  1287. return 0;
  1288. }
  1289. static struct saa7134_mpeg_ops dvb_ops = {
  1290. .type = SAA7134_MPEG_DVB,
  1291. .init = dvb_init,
  1292. .fini = dvb_fini,
  1293. };
  1294. static int __init dvb_register(void)
  1295. {
  1296. return saa7134_ts_register(&dvb_ops);
  1297. }
  1298. static void __exit dvb_unregister(void)
  1299. {
  1300. saa7134_ts_unregister(&dvb_ops);
  1301. }
  1302. module_init(dvb_register);
  1303. module_exit(dvb_unregister);
  1304. /* ------------------------------------------------------------------ */
  1305. /*
  1306. * Local variables:
  1307. * c-basic-offset: 8
  1308. * End:
  1309. */