saa7134-dvb.c 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187
  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 "tda827x.h"
  41. #include "isl6421.h"
  42. MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
  43. MODULE_LICENSE("GPL");
  44. static unsigned int antenna_pwr = 0;
  45. module_param(antenna_pwr, int, 0444);
  46. MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
  47. static int use_frontend = 0;
  48. module_param(use_frontend, int, 0644);
  49. MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
  50. static int debug = 0;
  51. module_param(debug, int, 0644);
  52. MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off).");
  53. #define dprintk(fmt, arg...) do { if (debug) \
  54. printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
  55. /* Print a warning */
  56. #define wprintk(fmt, arg...) \
  57. printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
  58. /* ------------------------------------------------------------------
  59. * mt352 based DVB-T cards
  60. */
  61. static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
  62. {
  63. u32 ok;
  64. if (!on) {
  65. saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
  66. saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
  67. return 0;
  68. }
  69. saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
  70. saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
  71. udelay(10);
  72. saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28));
  73. saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
  74. udelay(10);
  75. saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
  76. udelay(10);
  77. ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
  78. dprintk("%s %s\n", __FUNCTION__, ok ? "on" : "off");
  79. if (!ok)
  80. saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
  81. return ok;
  82. }
  83. static int mt352_pinnacle_init(struct dvb_frontend* fe)
  84. {
  85. static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 };
  86. static u8 reset [] = { RESET, 0x80 };
  87. static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
  88. static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
  89. static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
  90. static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 };
  91. static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f };
  92. static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d };
  93. static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
  94. struct saa7134_dev *dev= fe->dvb->priv;
  95. dprintk("%s called\n", __FUNCTION__);
  96. mt352_write(fe, clock_config, sizeof(clock_config));
  97. udelay(200);
  98. mt352_write(fe, reset, sizeof(reset));
  99. mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
  100. mt352_write(fe, agc_cfg, sizeof(agc_cfg));
  101. mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
  102. mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
  103. mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
  104. mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
  105. mt352_write(fe, irq_cfg, sizeof(irq_cfg));
  106. return 0;
  107. }
  108. static int mt352_aver777_init(struct dvb_frontend* fe)
  109. {
  110. static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
  111. static u8 reset [] = { RESET, 0x80 };
  112. static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
  113. static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
  114. static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
  115. mt352_write(fe, clock_config, sizeof(clock_config));
  116. udelay(200);
  117. mt352_write(fe, reset, sizeof(reset));
  118. mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
  119. mt352_write(fe, agc_cfg, sizeof(agc_cfg));
  120. mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
  121. return 0;
  122. }
  123. static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
  124. struct dvb_frontend_parameters* params)
  125. {
  126. u8 off[] = { 0x00, 0xf1};
  127. u8 on[] = { 0x00, 0x71};
  128. struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
  129. struct saa7134_dev *dev = fe->dvb->priv;
  130. struct v4l2_frequency f;
  131. /* set frequency (mt2050) */
  132. f.tuner = 0;
  133. f.type = V4L2_TUNER_DIGITAL_TV;
  134. f.frequency = params->frequency / 1000 * 16 / 1000;
  135. if (fe->ops.i2c_gate_ctrl)
  136. fe->ops.i2c_gate_ctrl(fe, 1);
  137. i2c_transfer(&dev->i2c_adap, &msg, 1);
  138. saa7134_i2c_call_clients(dev,VIDIOC_S_FREQUENCY,&f);
  139. msg.buf = on;
  140. if (fe->ops.i2c_gate_ctrl)
  141. fe->ops.i2c_gate_ctrl(fe, 1);
  142. i2c_transfer(&dev->i2c_adap, &msg, 1);
  143. pinnacle_antenna_pwr(dev, antenna_pwr);
  144. /* mt352 setup */
  145. return mt352_pinnacle_init(fe);
  146. }
  147. static int mt352_aver777_tuner_calc_regs(struct dvb_frontend *fe, struct dvb_frontend_parameters *params, u8* pllbuf, int buf_len)
  148. {
  149. if (buf_len < 5)
  150. return -EINVAL;
  151. pllbuf[0] = 0x61;
  152. dvb_pll_configure(&dvb_pll_philips_td1316, pllbuf+1,
  153. params->frequency,
  154. params->u.ofdm.bandwidth);
  155. return 5;
  156. }
  157. static struct mt352_config pinnacle_300i = {
  158. .demod_address = 0x3c >> 1,
  159. .adc_clock = 20333,
  160. .if2 = 36150,
  161. .no_tuner = 1,
  162. .demod_init = mt352_pinnacle_init,
  163. };
  164. static struct mt352_config avermedia_777 = {
  165. .demod_address = 0xf,
  166. .demod_init = mt352_aver777_init,
  167. };
  168. /* ==================================================================
  169. * tda1004x based DVB-T cards, helper functions
  170. */
  171. static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
  172. const struct firmware **fw, char *name)
  173. {
  174. struct saa7134_dev *dev = fe->dvb->priv;
  175. return request_firmware(fw, name, &dev->pci->dev);
  176. }
  177. /* ------------------------------------------------------------------
  178. * these tuners are tu1216, td1316(a)
  179. */
  180. static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  181. {
  182. struct saa7134_dev *dev = fe->dvb->priv;
  183. struct tda1004x_state *state = fe->demodulator_priv;
  184. u8 addr = state->config->tuner_address;
  185. u8 tuner_buf[4];
  186. struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
  187. sizeof(tuner_buf) };
  188. int tuner_frequency = 0;
  189. u8 band, cp, filter;
  190. /* determine charge pump */
  191. tuner_frequency = params->frequency + 36166000;
  192. if (tuner_frequency < 87000000)
  193. return -EINVAL;
  194. else if (tuner_frequency < 130000000)
  195. cp = 3;
  196. else if (tuner_frequency < 160000000)
  197. cp = 5;
  198. else if (tuner_frequency < 200000000)
  199. cp = 6;
  200. else if (tuner_frequency < 290000000)
  201. cp = 3;
  202. else if (tuner_frequency < 420000000)
  203. cp = 5;
  204. else if (tuner_frequency < 480000000)
  205. cp = 6;
  206. else if (tuner_frequency < 620000000)
  207. cp = 3;
  208. else if (tuner_frequency < 830000000)
  209. cp = 5;
  210. else if (tuner_frequency < 895000000)
  211. cp = 7;
  212. else
  213. return -EINVAL;
  214. /* determine band */
  215. if (params->frequency < 49000000)
  216. return -EINVAL;
  217. else if (params->frequency < 161000000)
  218. band = 1;
  219. else if (params->frequency < 444000000)
  220. band = 2;
  221. else if (params->frequency < 861000000)
  222. band = 4;
  223. else
  224. return -EINVAL;
  225. /* setup PLL filter */
  226. switch (params->u.ofdm.bandwidth) {
  227. case BANDWIDTH_6_MHZ:
  228. filter = 0;
  229. break;
  230. case BANDWIDTH_7_MHZ:
  231. filter = 0;
  232. break;
  233. case BANDWIDTH_8_MHZ:
  234. filter = 1;
  235. break;
  236. default:
  237. return -EINVAL;
  238. }
  239. /* calculate divisor
  240. * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
  241. */
  242. tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
  243. /* setup tuner buffer */
  244. tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
  245. tuner_buf[1] = tuner_frequency & 0xff;
  246. tuner_buf[2] = 0xca;
  247. tuner_buf[3] = (cp << 5) | (filter << 3) | band;
  248. if (fe->ops.i2c_gate_ctrl)
  249. fe->ops.i2c_gate_ctrl(fe, 1);
  250. if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
  251. wprintk("could not write to tuner at addr: 0x%02x\n",
  252. addr << 1);
  253. return -EIO;
  254. }
  255. msleep(1);
  256. return 0;
  257. }
  258. static int philips_tu1216_init(struct dvb_frontend *fe)
  259. {
  260. struct saa7134_dev *dev = fe->dvb->priv;
  261. struct tda1004x_state *state = fe->demodulator_priv;
  262. u8 addr = state->config->tuner_address;
  263. static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
  264. struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
  265. /* setup PLL configuration */
  266. if (fe->ops.i2c_gate_ctrl)
  267. fe->ops.i2c_gate_ctrl(fe, 1);
  268. if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
  269. return -EIO;
  270. msleep(1);
  271. return 0;
  272. }
  273. /* ------------------------------------------------------------------ */
  274. static struct tda1004x_config philips_tu1216_60_config = {
  275. .demod_address = 0x8,
  276. .invert = 1,
  277. .invert_oclk = 0,
  278. .xtal_freq = TDA10046_XTAL_4M,
  279. .agc_config = TDA10046_AGC_DEFAULT,
  280. .if_freq = TDA10046_FREQ_3617,
  281. .tuner_address = 0x60,
  282. .request_firmware = philips_tda1004x_request_firmware
  283. };
  284. static struct tda1004x_config philips_tu1216_61_config = {
  285. .demod_address = 0x8,
  286. .invert = 1,
  287. .invert_oclk = 0,
  288. .xtal_freq = TDA10046_XTAL_4M,
  289. .agc_config = TDA10046_AGC_DEFAULT,
  290. .if_freq = TDA10046_FREQ_3617,
  291. .tuner_address = 0x61,
  292. .request_firmware = philips_tda1004x_request_firmware
  293. };
  294. /* ------------------------------------------------------------------ */
  295. static int philips_td1316_tuner_init(struct dvb_frontend *fe)
  296. {
  297. struct saa7134_dev *dev = fe->dvb->priv;
  298. struct tda1004x_state *state = fe->demodulator_priv;
  299. u8 addr = state->config->tuner_address;
  300. static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
  301. struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
  302. /* setup PLL configuration */
  303. if (fe->ops.i2c_gate_ctrl)
  304. fe->ops.i2c_gate_ctrl(fe, 1);
  305. if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
  306. return -EIO;
  307. return 0;
  308. }
  309. static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  310. {
  311. return philips_tda6651_pll_set(fe, params);
  312. }
  313. static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
  314. {
  315. struct saa7134_dev *dev = fe->dvb->priv;
  316. struct tda1004x_state *state = fe->demodulator_priv;
  317. u8 addr = state->config->tuner_address;
  318. static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
  319. struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
  320. /* switch the tuner to analog mode */
  321. if (fe->ops.i2c_gate_ctrl)
  322. fe->ops.i2c_gate_ctrl(fe, 1);
  323. if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
  324. return -EIO;
  325. return 0;
  326. }
  327. /* ------------------------------------------------------------------ */
  328. static int philips_europa_tuner_init(struct dvb_frontend *fe)
  329. {
  330. struct saa7134_dev *dev = fe->dvb->priv;
  331. static u8 msg[] = { 0x00, 0x40};
  332. struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
  333. if (philips_td1316_tuner_init(fe))
  334. return -EIO;
  335. msleep(1);
  336. if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
  337. return -EIO;
  338. return 0;
  339. }
  340. static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
  341. {
  342. struct saa7134_dev *dev = fe->dvb->priv;
  343. static u8 msg[] = { 0x00, 0x14 };
  344. struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
  345. if (philips_td1316_tuner_sleep(fe))
  346. return -EIO;
  347. /* switch the board to analog mode */
  348. if (fe->ops.i2c_gate_ctrl)
  349. fe->ops.i2c_gate_ctrl(fe, 1);
  350. i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
  351. return 0;
  352. }
  353. static int philips_europa_demod_sleep(struct dvb_frontend *fe)
  354. {
  355. struct saa7134_dev *dev = fe->dvb->priv;
  356. if (dev->original_demod_sleep)
  357. dev->original_demod_sleep(fe);
  358. fe->ops.i2c_gate_ctrl(fe, 1);
  359. return 0;
  360. }
  361. static struct tda1004x_config philips_europa_config = {
  362. .demod_address = 0x8,
  363. .invert = 0,
  364. .invert_oclk = 0,
  365. .xtal_freq = TDA10046_XTAL_4M,
  366. .agc_config = TDA10046_AGC_IFO_AUTO_POS,
  367. .if_freq = TDA10046_FREQ_052,
  368. .tuner_address = 0x61,
  369. .request_firmware = philips_tda1004x_request_firmware
  370. };
  371. /* ------------------------------------------------------------------ */
  372. static int philips_fmd1216_tuner_init(struct dvb_frontend *fe)
  373. {
  374. struct saa7134_dev *dev = fe->dvb->priv;
  375. struct tda1004x_state *state = fe->demodulator_priv;
  376. u8 addr = state->config->tuner_address;
  377. /* this message is to set up ATC and ALC */
  378. static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0xa0 };
  379. struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) };
  380. if (fe->ops.i2c_gate_ctrl)
  381. fe->ops.i2c_gate_ctrl(fe, 1);
  382. if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
  383. return -EIO;
  384. msleep(1);
  385. return 0;
  386. }
  387. static int philips_fmd1216_tuner_sleep(struct dvb_frontend *fe)
  388. {
  389. struct saa7134_dev *dev = fe->dvb->priv;
  390. struct tda1004x_state *state = fe->demodulator_priv;
  391. u8 addr = state->config->tuner_address;
  392. /* this message actually turns the tuner back to analog mode */
  393. u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0x60 };
  394. struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) };
  395. if (fe->ops.i2c_gate_ctrl)
  396. fe->ops.i2c_gate_ctrl(fe, 1);
  397. i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
  398. msleep(1);
  399. fmd1216_init[2] = 0x86;
  400. fmd1216_init[3] = 0x54;
  401. if (fe->ops.i2c_gate_ctrl)
  402. fe->ops.i2c_gate_ctrl(fe, 1);
  403. i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
  404. msleep(1);
  405. return 0;
  406. }
  407. static int philips_fmd1216_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  408. {
  409. struct saa7134_dev *dev = fe->dvb->priv;
  410. struct tda1004x_state *state = fe->demodulator_priv;
  411. u8 addr = state->config->tuner_address;
  412. u8 tuner_buf[4];
  413. struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
  414. sizeof(tuner_buf) };
  415. int tuner_frequency = 0;
  416. int divider = 0;
  417. u8 band, mode, cp;
  418. /* determine charge pump */
  419. tuner_frequency = params->frequency + 36130000;
  420. if (tuner_frequency < 87000000)
  421. return -EINVAL;
  422. /* low band */
  423. else if (tuner_frequency < 180000000) {
  424. band = 1;
  425. mode = 7;
  426. cp = 0;
  427. } else if (tuner_frequency < 195000000) {
  428. band = 1;
  429. mode = 6;
  430. cp = 1;
  431. /* mid band */
  432. } else if (tuner_frequency < 366000000) {
  433. if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
  434. band = 10;
  435. } else {
  436. band = 2;
  437. }
  438. mode = 7;
  439. cp = 0;
  440. } else if (tuner_frequency < 478000000) {
  441. if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
  442. band = 10;
  443. } else {
  444. band = 2;
  445. }
  446. mode = 6;
  447. cp = 1;
  448. /* high band */
  449. } else if (tuner_frequency < 662000000) {
  450. if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
  451. band = 12;
  452. } else {
  453. band = 4;
  454. }
  455. mode = 7;
  456. cp = 0;
  457. } else if (tuner_frequency < 840000000) {
  458. if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
  459. band = 12;
  460. } else {
  461. band = 4;
  462. }
  463. mode = 6;
  464. cp = 1;
  465. } else {
  466. if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
  467. band = 12;
  468. } else {
  469. band = 4;
  470. }
  471. mode = 7;
  472. cp = 1;
  473. }
  474. /* calculate divisor */
  475. /* ((36166000 + Finput) / 166666) rounded! */
  476. divider = (tuner_frequency + 83333) / 166667;
  477. /* setup tuner buffer */
  478. tuner_buf[0] = (divider >> 8) & 0x7f;
  479. tuner_buf[1] = divider & 0xff;
  480. tuner_buf[2] = 0x80 | (cp << 6) | (mode << 3) | 4;
  481. tuner_buf[3] = 0x40 | band;
  482. if (fe->ops.i2c_gate_ctrl)
  483. fe->ops.i2c_gate_ctrl(fe, 1);
  484. if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
  485. wprintk("could not write to tuner at addr: 0x%02x\n",
  486. addr << 1);
  487. return -EIO;
  488. }
  489. return 0;
  490. }
  491. static struct tda1004x_config medion_cardbus = {
  492. .demod_address = 0x08,
  493. .invert = 1,
  494. .invert_oclk = 0,
  495. .xtal_freq = TDA10046_XTAL_16M,
  496. .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
  497. .if_freq = TDA10046_FREQ_3613,
  498. .tuner_address = 0x61,
  499. .request_firmware = philips_tda1004x_request_firmware
  500. };
  501. /* ------------------------------------------------------------------
  502. * tda 1004x based cards with philips silicon tuner
  503. */
  504. static void philips_tda827x_lna_gain(struct dvb_frontend *fe, int high)
  505. {
  506. struct saa7134_dev *dev = fe->dvb->priv;
  507. struct tda1004x_state *state = fe->demodulator_priv;
  508. u8 addr = state->config->i2c_gate;
  509. u8 config = state->config->tuner_config;
  510. u8 GP00_CF[] = {0x20, 0x01};
  511. u8 GP00_LEV[] = {0x22, 0x00};
  512. struct i2c_msg msg = {.addr = addr,.flags = 0,.buf = GP00_CF, .len = 2};
  513. if (config) {
  514. if (high) {
  515. dprintk("setting LNA to high gain\n");
  516. } else {
  517. dprintk("setting LNA to low gain\n");
  518. }
  519. }
  520. switch (config) {
  521. case 0: /* no LNA */
  522. break;
  523. case 1: /* switch is GPIO 0 of tda8290 */
  524. case 2:
  525. /* turn Vsync off */
  526. saa7134_set_gpio(dev, 22, 0);
  527. GP00_LEV[1] = high ? 0 : 1;
  528. if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
  529. wprintk("could not access tda8290 at addr: 0x%02x\n",
  530. addr << 1);
  531. return;
  532. }
  533. msg.buf = GP00_LEV;
  534. if (config == 2)
  535. GP00_LEV[1] = high ? 1 : 0;
  536. i2c_transfer(&dev->i2c_adap, &msg, 1);
  537. break;
  538. case 3: /* switch with GPIO of saa713x */
  539. saa7134_set_gpio(dev, 22, high);
  540. break;
  541. }
  542. }
  543. static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
  544. {
  545. struct tda1004x_state *state = fe->demodulator_priv;
  546. u8 addr = state->config->i2c_gate;
  547. static u8 tda8290_close[] = { 0x21, 0xc0};
  548. static u8 tda8290_open[] = { 0x21, 0x80};
  549. struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
  550. if (enable) {
  551. tda8290_msg.buf = tda8290_close;
  552. } else {
  553. tda8290_msg.buf = tda8290_open;
  554. }
  555. if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
  556. struct saa7134_dev *dev = fe->dvb->priv;
  557. wprintk("could not access tda8290 I2C gate\n");
  558. return -EIO;
  559. }
  560. msleep(20);
  561. return 0;
  562. }
  563. /* ------------------------------------------------------------------ */
  564. static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
  565. {
  566. struct saa7134_dev *dev = fe->dvb->priv;
  567. struct tda1004x_state *state = fe->demodulator_priv;
  568. switch (state->config->antenna_switch) {
  569. case 0: break;
  570. case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
  571. saa7134_set_gpio(dev, 21, 0);
  572. break;
  573. case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
  574. saa7134_set_gpio(dev, 21, 1);
  575. break;
  576. }
  577. return 0;
  578. }
  579. static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
  580. {
  581. struct saa7134_dev *dev = fe->dvb->priv;
  582. struct tda1004x_state *state = fe->demodulator_priv;
  583. switch (state->config->antenna_switch) {
  584. case 0: break;
  585. case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
  586. saa7134_set_gpio(dev, 21, 1);
  587. break;
  588. case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
  589. saa7134_set_gpio(dev, 21, 0);
  590. break;
  591. }
  592. return 0;
  593. }
  594. static struct tda827x_config tda827x_cfg = {
  595. .lna_gain = philips_tda827x_lna_gain,
  596. .init = philips_tda827x_tuner_init,
  597. .sleep = philips_tda827x_tuner_sleep
  598. };
  599. static void configure_tda827x_fe(struct saa7134_dev *dev, struct tda1004x_config *tda_conf)
  600. {
  601. dev->dvb.frontend = dvb_attach(tda10046_attach, tda_conf, &dev->i2c_adap);
  602. if (dev->dvb.frontend) {
  603. if (tda_conf->i2c_gate)
  604. dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
  605. if (dvb_attach(tda827x_attach, dev->dvb.frontend, tda_conf->tuner_address,
  606. &dev->i2c_adap,&tda827x_cfg) == NULL) {
  607. wprintk("no tda827x tuner found at addr: %02x\n",
  608. tda_conf->tuner_address);
  609. }
  610. }
  611. }
  612. /* ------------------------------------------------------------------ */
  613. static struct tda1004x_config tda827x_lifeview_config = {
  614. .demod_address = 0x08,
  615. .invert = 1,
  616. .invert_oclk = 0,
  617. .xtal_freq = TDA10046_XTAL_16M,
  618. .agc_config = TDA10046_AGC_TDA827X,
  619. .gpio_config = TDA10046_GP11_I,
  620. .if_freq = TDA10046_FREQ_045,
  621. .tuner_address = 0x60,
  622. .request_firmware = philips_tda1004x_request_firmware
  623. };
  624. static struct tda1004x_config philips_tiger_config = {
  625. .demod_address = 0x08,
  626. .invert = 1,
  627. .invert_oclk = 0,
  628. .xtal_freq = TDA10046_XTAL_16M,
  629. .agc_config = TDA10046_AGC_TDA827X,
  630. .gpio_config = TDA10046_GP11_I,
  631. .if_freq = TDA10046_FREQ_045,
  632. .i2c_gate = 0x4b,
  633. .tuner_address = 0x61,
  634. .tuner_config = 0,
  635. .antenna_switch= 1,
  636. .request_firmware = philips_tda1004x_request_firmware
  637. };
  638. static struct tda1004x_config cinergy_ht_config = {
  639. .demod_address = 0x08,
  640. .invert = 1,
  641. .invert_oclk = 0,
  642. .xtal_freq = TDA10046_XTAL_16M,
  643. .agc_config = TDA10046_AGC_TDA827X,
  644. .gpio_config = TDA10046_GP01_I,
  645. .if_freq = TDA10046_FREQ_045,
  646. .i2c_gate = 0x4b,
  647. .tuner_address = 0x61,
  648. .tuner_config = 0,
  649. .request_firmware = philips_tda1004x_request_firmware
  650. };
  651. static struct tda1004x_config cinergy_ht_pci_config = {
  652. .demod_address = 0x08,
  653. .invert = 1,
  654. .invert_oclk = 0,
  655. .xtal_freq = TDA10046_XTAL_16M,
  656. .agc_config = TDA10046_AGC_TDA827X,
  657. .gpio_config = TDA10046_GP01_I,
  658. .if_freq = TDA10046_FREQ_045,
  659. .i2c_gate = 0x4b,
  660. .tuner_address = 0x60,
  661. .tuner_config = 0,
  662. .request_firmware = philips_tda1004x_request_firmware
  663. };
  664. static struct tda1004x_config philips_tiger_s_config = {
  665. .demod_address = 0x08,
  666. .invert = 1,
  667. .invert_oclk = 0,
  668. .xtal_freq = TDA10046_XTAL_16M,
  669. .agc_config = TDA10046_AGC_TDA827X,
  670. .gpio_config = TDA10046_GP01_I,
  671. .if_freq = TDA10046_FREQ_045,
  672. .i2c_gate = 0x4b,
  673. .tuner_address = 0x61,
  674. .tuner_config = 2,
  675. .antenna_switch= 1,
  676. .request_firmware = philips_tda1004x_request_firmware
  677. };
  678. static struct tda1004x_config pinnacle_pctv_310i_config = {
  679. .demod_address = 0x08,
  680. .invert = 1,
  681. .invert_oclk = 0,
  682. .xtal_freq = TDA10046_XTAL_16M,
  683. .agc_config = TDA10046_AGC_TDA827X,
  684. .gpio_config = TDA10046_GP11_I,
  685. .if_freq = TDA10046_FREQ_045,
  686. .i2c_gate = 0x4b,
  687. .tuner_address = 0x61,
  688. .tuner_config = 1,
  689. .request_firmware = philips_tda1004x_request_firmware
  690. };
  691. static struct tda1004x_config hauppauge_hvr_1110_config = {
  692. .demod_address = 0x08,
  693. .invert = 1,
  694. .invert_oclk = 0,
  695. .xtal_freq = TDA10046_XTAL_16M,
  696. .agc_config = TDA10046_AGC_TDA827X,
  697. .gpio_config = TDA10046_GP11_I,
  698. .if_freq = TDA10046_FREQ_045,
  699. .i2c_gate = 0x4b,
  700. .tuner_address = 0x61,
  701. .request_firmware = philips_tda1004x_request_firmware
  702. };
  703. static struct tda1004x_config asus_p7131_dual_config = {
  704. .demod_address = 0x08,
  705. .invert = 1,
  706. .invert_oclk = 0,
  707. .xtal_freq = TDA10046_XTAL_16M,
  708. .agc_config = TDA10046_AGC_TDA827X,
  709. .gpio_config = TDA10046_GP11_I,
  710. .if_freq = TDA10046_FREQ_045,
  711. .i2c_gate = 0x4b,
  712. .tuner_address = 0x61,
  713. .tuner_config = 0,
  714. .antenna_switch= 2,
  715. .request_firmware = philips_tda1004x_request_firmware
  716. };
  717. static struct tda1004x_config lifeview_trio_config = {
  718. .demod_address = 0x09,
  719. .invert = 1,
  720. .invert_oclk = 0,
  721. .xtal_freq = TDA10046_XTAL_16M,
  722. .agc_config = TDA10046_AGC_TDA827X,
  723. .gpio_config = TDA10046_GP00_I,
  724. .if_freq = TDA10046_FREQ_045,
  725. .tuner_address = 0x60,
  726. .request_firmware = philips_tda1004x_request_firmware
  727. };
  728. static struct tda1004x_config tevion_dvbt220rf_config = {
  729. .demod_address = 0x08,
  730. .invert = 1,
  731. .invert_oclk = 0,
  732. .xtal_freq = TDA10046_XTAL_16M,
  733. .agc_config = TDA10046_AGC_TDA827X,
  734. .gpio_config = TDA10046_GP11_I,
  735. .if_freq = TDA10046_FREQ_045,
  736. .tuner_address = 0x60,
  737. .request_firmware = philips_tda1004x_request_firmware
  738. };
  739. static struct tda1004x_config md8800_dvbt_config = {
  740. .demod_address = 0x08,
  741. .invert = 1,
  742. .invert_oclk = 0,
  743. .xtal_freq = TDA10046_XTAL_16M,
  744. .agc_config = TDA10046_AGC_TDA827X,
  745. .gpio_config = TDA10046_GP01_I,
  746. .if_freq = TDA10046_FREQ_045,
  747. .i2c_gate = 0x4b,
  748. .tuner_address = 0x60,
  749. .tuner_config = 0,
  750. .request_firmware = philips_tda1004x_request_firmware
  751. };
  752. /* ------------------------------------------------------------------
  753. * special case: this card uses saa713x GPIO22 for the mode switch
  754. */
  755. static int ads_duo_tuner_init(struct dvb_frontend *fe)
  756. {
  757. struct saa7134_dev *dev = fe->dvb->priv;
  758. philips_tda827x_tuner_init(fe);
  759. /* route TDA8275a AGC input to the channel decoder */
  760. saa7134_set_gpio(dev, 22, 1);
  761. return 0;
  762. }
  763. static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
  764. {
  765. struct saa7134_dev *dev = fe->dvb->priv;
  766. /* route TDA8275a AGC input to the analog IF chip*/
  767. saa7134_set_gpio(dev, 22, 0);
  768. philips_tda827x_tuner_sleep(fe);
  769. return 0;
  770. }
  771. static struct tda827x_config ads_duo_cfg = {
  772. .lna_gain = philips_tda827x_lna_gain,
  773. .init = ads_duo_tuner_init,
  774. .sleep = ads_duo_tuner_sleep
  775. };
  776. static struct tda1004x_config ads_tech_duo_config = {
  777. .demod_address = 0x08,
  778. .invert = 1,
  779. .invert_oclk = 0,
  780. .xtal_freq = TDA10046_XTAL_16M,
  781. .agc_config = TDA10046_AGC_TDA827X,
  782. .gpio_config = TDA10046_GP00_I,
  783. .if_freq = TDA10046_FREQ_045,
  784. .tuner_address = 0x61,
  785. .request_firmware = philips_tda1004x_request_firmware
  786. };
  787. /* ==================================================================
  788. * tda10086 based DVB-S cards, helper functions
  789. */
  790. static struct tda10086_config flydvbs = {
  791. .demod_address = 0x0e,
  792. .invert = 0,
  793. };
  794. /* ==================================================================
  795. * nxt200x based ATSC cards, helper functions
  796. */
  797. static struct nxt200x_config avertvhda180 = {
  798. .demod_address = 0x0a,
  799. };
  800. static int nxt200x_set_pll_input(u8 *buf, int input)
  801. {
  802. if (input)
  803. buf[3] |= 0x08;
  804. else
  805. buf[3] &= ~0x08;
  806. return 0;
  807. }
  808. static struct nxt200x_config kworldatsc110 = {
  809. .demod_address = 0x0a,
  810. .set_pll_input = nxt200x_set_pll_input,
  811. };
  812. /* ==================================================================
  813. * Core code
  814. */
  815. static int dvb_init(struct saa7134_dev *dev)
  816. {
  817. int ret;
  818. /* init struct videobuf_dvb */
  819. dev->ts.nr_bufs = 32;
  820. dev->ts.nr_packets = 32*4;
  821. dev->dvb.name = dev->name;
  822. videobuf_queue_init(&dev->dvb.dvbq, &saa7134_ts_qops,
  823. dev->pci, &dev->slock,
  824. V4L2_BUF_TYPE_VIDEO_CAPTURE,
  825. V4L2_FIELD_ALTERNATE,
  826. sizeof(struct saa7134_buf),
  827. dev);
  828. switch (dev->board) {
  829. case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
  830. dprintk("pinnacle 300i dvb setup\n");
  831. dev->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
  832. &dev->i2c_adap);
  833. if (dev->dvb.frontend) {
  834. dev->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
  835. }
  836. break;
  837. case SAA7134_BOARD_AVERMEDIA_777:
  838. case SAA7134_BOARD_AVERMEDIA_A16AR:
  839. dprintk("avertv 777 dvb setup\n");
  840. dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
  841. &dev->i2c_adap);
  842. if (dev->dvb.frontend) {
  843. dev->dvb.frontend->ops.tuner_ops.calc_regs = mt352_aver777_tuner_calc_regs;
  844. }
  845. break;
  846. case SAA7134_BOARD_MD7134:
  847. dev->dvb.frontend = dvb_attach(tda10046_attach,
  848. &medion_cardbus,
  849. &dev->i2c_adap);
  850. if (dev->dvb.frontend) {
  851. dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init;
  852. dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep;
  853. dev->dvb.frontend->ops.tuner_ops.set_params = philips_fmd1216_tuner_set_params;
  854. }
  855. break;
  856. case SAA7134_BOARD_PHILIPS_TOUGH:
  857. dev->dvb.frontend = dvb_attach(tda10046_attach,
  858. &philips_tu1216_60_config,
  859. &dev->i2c_adap);
  860. if (dev->dvb.frontend) {
  861. dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
  862. dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
  863. }
  864. break;
  865. case SAA7134_BOARD_FLYDVBTDUO:
  866. case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
  867. configure_tda827x_fe(dev, &tda827x_lifeview_config);
  868. break;
  869. case SAA7134_BOARD_PHILIPS_EUROPA:
  870. case SAA7134_BOARD_VIDEOMATE_DVBT_300:
  871. dev->dvb.frontend = dvb_attach(tda10046_attach,
  872. &philips_europa_config,
  873. &dev->i2c_adap);
  874. if (dev->dvb.frontend) {
  875. dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
  876. dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
  877. dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
  878. dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
  879. dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
  880. }
  881. break;
  882. case SAA7134_BOARD_VIDEOMATE_DVBT_200:
  883. dev->dvb.frontend = dvb_attach(tda10046_attach,
  884. &philips_tu1216_61_config,
  885. &dev->i2c_adap);
  886. if (dev->dvb.frontend) {
  887. dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
  888. dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
  889. }
  890. break;
  891. case SAA7134_BOARD_PHILIPS_TIGER:
  892. configure_tda827x_fe(dev, &philips_tiger_config);
  893. break;
  894. case SAA7134_BOARD_PINNACLE_PCTV_310i:
  895. configure_tda827x_fe(dev, &pinnacle_pctv_310i_config);
  896. break;
  897. case SAA7134_BOARD_HAUPPAUGE_HVR1110:
  898. configure_tda827x_fe(dev, &hauppauge_hvr_1110_config);
  899. break;
  900. case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
  901. configure_tda827x_fe(dev, &asus_p7131_dual_config);
  902. break;
  903. case SAA7134_BOARD_FLYDVBT_LR301:
  904. configure_tda827x_fe(dev, &tda827x_lifeview_config);
  905. break;
  906. case SAA7134_BOARD_FLYDVB_TRIO:
  907. if(! use_frontend) { //terrestrial
  908. configure_tda827x_fe(dev, &lifeview_trio_config);
  909. } else { //satellite
  910. dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
  911. if (dev->dvb.frontend) {
  912. if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63,
  913. &dev->i2c_adap, 0) == NULL) {
  914. wprintk("%s: Lifeview Trio, No tda826x found!\n", __FUNCTION__);
  915. }
  916. if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap,
  917. 0x08, 0, 0) == NULL) {
  918. wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __FUNCTION__);
  919. }
  920. }
  921. }
  922. break;
  923. case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
  924. case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
  925. dev->dvb.frontend = dvb_attach(tda10046_attach,
  926. &ads_tech_duo_config,
  927. &dev->i2c_adap);
  928. if (dev->dvb.frontend) {
  929. if (dvb_attach(tda827x_attach,dev->dvb.frontend,
  930. ads_tech_duo_config.tuner_address,
  931. &dev->i2c_adap,&ads_duo_cfg) == NULL) {
  932. wprintk("no tda827x tuner found at addr: %02x\n",
  933. ads_tech_duo_config.tuner_address);
  934. }
  935. }
  936. break;
  937. case SAA7134_BOARD_TEVION_DVBT_220RF:
  938. configure_tda827x_fe(dev, &tevion_dvbt220rf_config);
  939. break;
  940. case SAA7134_BOARD_MEDION_MD8800_QUADRO:
  941. configure_tda827x_fe(dev, &md8800_dvbt_config);
  942. break;
  943. case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
  944. dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
  945. &dev->i2c_adap);
  946. if (dev->dvb.frontend) {
  947. dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
  948. NULL, &dvb_pll_tdhu2);
  949. }
  950. break;
  951. case SAA7134_BOARD_KWORLD_ATSC110:
  952. dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
  953. &dev->i2c_adap);
  954. if (dev->dvb.frontend) {
  955. dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
  956. NULL, &dvb_pll_tuv1236d);
  957. }
  958. break;
  959. case SAA7134_BOARD_FLYDVBS_LR300:
  960. dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
  961. &dev->i2c_adap);
  962. if (dev->dvb.frontend) {
  963. if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
  964. &dev->i2c_adap, 0) == NULL) {
  965. wprintk("%s: No tda826x found!\n", __FUNCTION__);
  966. }
  967. if (dvb_attach(isl6421_attach, dev->dvb.frontend,
  968. &dev->i2c_adap, 0x08, 0, 0) == NULL) {
  969. wprintk("%s: No ISL6421 found!\n", __FUNCTION__);
  970. }
  971. }
  972. break;
  973. case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
  974. dev->dvb.frontend = tda10046_attach(&medion_cardbus,
  975. &dev->i2c_adap);
  976. if (dev->dvb.frontend) {
  977. dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
  978. dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
  979. dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init;
  980. dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep;
  981. dev->dvb.frontend->ops.tuner_ops.set_params = philips_fmd1216_tuner_set_params;
  982. }
  983. break;
  984. case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
  985. dev->dvb.frontend = dvb_attach(tda10046_attach,
  986. &philips_europa_config,
  987. &dev->i2c_adap);
  988. if (dev->dvb.frontend) {
  989. dev->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
  990. dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
  991. }
  992. break;
  993. case SAA7134_BOARD_CINERGY_HT_PCMCIA:
  994. configure_tda827x_fe(dev, &cinergy_ht_config);
  995. break;
  996. case SAA7134_BOARD_CINERGY_HT_PCI:
  997. configure_tda827x_fe(dev, &cinergy_ht_pci_config);
  998. break;
  999. case SAA7134_BOARD_PHILIPS_TIGER_S:
  1000. configure_tda827x_fe(dev, &philips_tiger_s_config);
  1001. break;
  1002. default:
  1003. wprintk("Huh? unknown DVB card?\n");
  1004. break;
  1005. }
  1006. if (NULL == dev->dvb.frontend) {
  1007. printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
  1008. return -1;
  1009. }
  1010. /* register everything else */
  1011. ret = videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev);
  1012. /* this sequence is necessary to make the tda1004x load its firmware
  1013. * and to enter analog mode of hybrid boards
  1014. */
  1015. if (!ret) {
  1016. if (dev->dvb.frontend->ops.init)
  1017. dev->dvb.frontend->ops.init(dev->dvb.frontend);
  1018. if (dev->dvb.frontend->ops.sleep)
  1019. dev->dvb.frontend->ops.sleep(dev->dvb.frontend);
  1020. }
  1021. return ret;
  1022. }
  1023. static int dvb_fini(struct saa7134_dev *dev)
  1024. {
  1025. static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
  1026. switch (dev->board) {
  1027. case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
  1028. /* otherwise we don't detect the tuner on next insmod */
  1029. saa7134_i2c_call_clients(dev,TDA9887_SET_CONFIG,&on);
  1030. break;
  1031. };
  1032. videobuf_dvb_unregister(&dev->dvb);
  1033. return 0;
  1034. }
  1035. static struct saa7134_mpeg_ops dvb_ops = {
  1036. .type = SAA7134_MPEG_DVB,
  1037. .init = dvb_init,
  1038. .fini = dvb_fini,
  1039. };
  1040. static int __init dvb_register(void)
  1041. {
  1042. return saa7134_ts_register(&dvb_ops);
  1043. }
  1044. static void __exit dvb_unregister(void)
  1045. {
  1046. saa7134_ts_unregister(&dvb_ops);
  1047. }
  1048. module_init(dvb_register);
  1049. module_exit(dvb_unregister);
  1050. /* ------------------------------------------------------------------ */
  1051. /*
  1052. * Local variables:
  1053. * c-basic-offset: 8
  1054. * End:
  1055. */