saa7134-dvb.c 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139
  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 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. * tda1004x based DVB-T cards, helper functions
  160. */
  161. static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
  162. const struct firmware **fw, char *name)
  163. {
  164. struct saa7134_dev *dev = fe->dvb->priv;
  165. return request_firmware(fw, name, &dev->pci->dev);
  166. }
  167. /* ------------------------------------------------------------------
  168. * these tuners are tu1216, td1316(a)
  169. */
  170. static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  171. {
  172. struct saa7134_dev *dev = fe->dvb->priv;
  173. struct tda1004x_state *state = fe->demodulator_priv;
  174. u8 addr = state->config->tuner_address;
  175. u8 tuner_buf[4];
  176. struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
  177. sizeof(tuner_buf) };
  178. int tuner_frequency = 0;
  179. u8 band, cp, filter;
  180. /* determine charge pump */
  181. tuner_frequency = params->frequency + 36166000;
  182. if (tuner_frequency < 87000000)
  183. return -EINVAL;
  184. else if (tuner_frequency < 130000000)
  185. cp = 3;
  186. else if (tuner_frequency < 160000000)
  187. cp = 5;
  188. else if (tuner_frequency < 200000000)
  189. cp = 6;
  190. else if (tuner_frequency < 290000000)
  191. cp = 3;
  192. else if (tuner_frequency < 420000000)
  193. cp = 5;
  194. else if (tuner_frequency < 480000000)
  195. cp = 6;
  196. else if (tuner_frequency < 620000000)
  197. cp = 3;
  198. else if (tuner_frequency < 830000000)
  199. cp = 5;
  200. else if (tuner_frequency < 895000000)
  201. cp = 7;
  202. else
  203. return -EINVAL;
  204. /* determine band */
  205. if (params->frequency < 49000000)
  206. return -EINVAL;
  207. else if (params->frequency < 161000000)
  208. band = 1;
  209. else if (params->frequency < 444000000)
  210. band = 2;
  211. else if (params->frequency < 861000000)
  212. band = 4;
  213. else
  214. return -EINVAL;
  215. /* setup PLL filter */
  216. switch (params->u.ofdm.bandwidth) {
  217. case BANDWIDTH_6_MHZ:
  218. filter = 0;
  219. break;
  220. case BANDWIDTH_7_MHZ:
  221. filter = 0;
  222. break;
  223. case BANDWIDTH_8_MHZ:
  224. filter = 1;
  225. break;
  226. default:
  227. return -EINVAL;
  228. }
  229. /* calculate divisor
  230. * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
  231. */
  232. tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
  233. /* setup tuner buffer */
  234. tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
  235. tuner_buf[1] = tuner_frequency & 0xff;
  236. tuner_buf[2] = 0xca;
  237. tuner_buf[3] = (cp << 5) | (filter << 3) | band;
  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. wprintk("could not write to tuner at addr: 0x%02x\n",
  242. addr << 1);
  243. return -EIO;
  244. }
  245. msleep(1);
  246. return 0;
  247. }
  248. static int philips_tu1216_init(struct dvb_frontend *fe)
  249. {
  250. struct saa7134_dev *dev = fe->dvb->priv;
  251. struct tda1004x_state *state = fe->demodulator_priv;
  252. u8 addr = state->config->tuner_address;
  253. static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
  254. struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
  255. /* setup PLL configuration */
  256. if (fe->ops.i2c_gate_ctrl)
  257. fe->ops.i2c_gate_ctrl(fe, 1);
  258. if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
  259. return -EIO;
  260. msleep(1);
  261. return 0;
  262. }
  263. /* ------------------------------------------------------------------ */
  264. static struct tda1004x_config philips_tu1216_60_config = {
  265. .demod_address = 0x8,
  266. .invert = 1,
  267. .invert_oclk = 0,
  268. .xtal_freq = TDA10046_XTAL_4M,
  269. .agc_config = TDA10046_AGC_DEFAULT,
  270. .if_freq = TDA10046_FREQ_3617,
  271. .tuner_address = 0x60,
  272. .request_firmware = philips_tda1004x_request_firmware
  273. };
  274. static struct tda1004x_config philips_tu1216_61_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 = 0x61,
  282. .request_firmware = philips_tda1004x_request_firmware
  283. };
  284. /* ------------------------------------------------------------------ */
  285. static int philips_td1316_tuner_init(struct dvb_frontend *fe)
  286. {
  287. struct saa7134_dev *dev = fe->dvb->priv;
  288. struct tda1004x_state *state = fe->demodulator_priv;
  289. u8 addr = state->config->tuner_address;
  290. static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
  291. struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
  292. /* setup PLL configuration */
  293. if (fe->ops.i2c_gate_ctrl)
  294. fe->ops.i2c_gate_ctrl(fe, 1);
  295. if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
  296. return -EIO;
  297. return 0;
  298. }
  299. static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  300. {
  301. return philips_tda6651_pll_set(fe, params);
  302. }
  303. static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
  304. {
  305. struct saa7134_dev *dev = fe->dvb->priv;
  306. struct tda1004x_state *state = fe->demodulator_priv;
  307. u8 addr = state->config->tuner_address;
  308. static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
  309. struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
  310. /* switch the tuner to analog mode */
  311. if (fe->ops.i2c_gate_ctrl)
  312. fe->ops.i2c_gate_ctrl(fe, 1);
  313. if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
  314. return -EIO;
  315. return 0;
  316. }
  317. /* ------------------------------------------------------------------ */
  318. static int philips_europa_tuner_init(struct dvb_frontend *fe)
  319. {
  320. struct saa7134_dev *dev = fe->dvb->priv;
  321. static u8 msg[] = { 0x00, 0x40};
  322. struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
  323. if (philips_td1316_tuner_init(fe))
  324. return -EIO;
  325. msleep(1);
  326. if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
  327. return -EIO;
  328. return 0;
  329. }
  330. static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
  331. {
  332. struct saa7134_dev *dev = fe->dvb->priv;
  333. static u8 msg[] = { 0x00, 0x14 };
  334. struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
  335. if (philips_td1316_tuner_sleep(fe))
  336. return -EIO;
  337. /* switch the board to analog mode */
  338. if (fe->ops.i2c_gate_ctrl)
  339. fe->ops.i2c_gate_ctrl(fe, 1);
  340. i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
  341. return 0;
  342. }
  343. static int philips_europa_demod_sleep(struct dvb_frontend *fe)
  344. {
  345. struct saa7134_dev *dev = fe->dvb->priv;
  346. if (dev->original_demod_sleep)
  347. dev->original_demod_sleep(fe);
  348. fe->ops.i2c_gate_ctrl(fe, 1);
  349. return 0;
  350. }
  351. static struct tda1004x_config philips_europa_config = {
  352. .demod_address = 0x8,
  353. .invert = 0,
  354. .invert_oclk = 0,
  355. .xtal_freq = TDA10046_XTAL_4M,
  356. .agc_config = TDA10046_AGC_IFO_AUTO_POS,
  357. .if_freq = TDA10046_FREQ_052,
  358. .tuner_address = 0x61,
  359. .request_firmware = philips_tda1004x_request_firmware
  360. };
  361. /* ------------------------------------------------------------------ */
  362. static struct tda1004x_config medion_cardbus = {
  363. .demod_address = 0x08,
  364. .invert = 1,
  365. .invert_oclk = 0,
  366. .xtal_freq = TDA10046_XTAL_16M,
  367. .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
  368. .if_freq = TDA10046_FREQ_3613,
  369. .tuner_address = 0x61,
  370. .request_firmware = philips_tda1004x_request_firmware
  371. };
  372. /* ------------------------------------------------------------------
  373. * tda 1004x based cards with philips silicon tuner
  374. */
  375. static void philips_tda827x_lna_gain(struct dvb_frontend *fe, int high)
  376. {
  377. struct saa7134_dev *dev = fe->dvb->priv;
  378. struct tda1004x_state *state = fe->demodulator_priv;
  379. u8 addr = state->config->i2c_gate;
  380. u8 config = state->config->tuner_config;
  381. u8 GP00_CF[] = {0x20, 0x01};
  382. u8 GP00_LEV[] = {0x22, 0x00};
  383. struct i2c_msg msg = {.addr = addr,.flags = 0,.buf = GP00_CF, .len = 2};
  384. if (config) {
  385. if (high) {
  386. dprintk("setting LNA to high gain\n");
  387. } else {
  388. dprintk("setting LNA to low gain\n");
  389. }
  390. }
  391. switch (config) {
  392. case 0: /* no LNA */
  393. break;
  394. case 1: /* switch is GPIO 0 of tda8290 */
  395. case 2:
  396. /* turn Vsync off */
  397. saa7134_set_gpio(dev, 22, 0);
  398. GP00_LEV[1] = high ? 0 : 1;
  399. if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
  400. wprintk("could not access tda8290 at addr: 0x%02x\n",
  401. addr << 1);
  402. return;
  403. }
  404. msg.buf = GP00_LEV;
  405. if (config == 2)
  406. GP00_LEV[1] = high ? 1 : 0;
  407. i2c_transfer(&dev->i2c_adap, &msg, 1);
  408. break;
  409. case 3: /* switch with GPIO of saa713x */
  410. saa7134_set_gpio(dev, 22, high);
  411. break;
  412. }
  413. }
  414. static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
  415. {
  416. struct tda1004x_state *state = fe->demodulator_priv;
  417. u8 addr = state->config->i2c_gate;
  418. static u8 tda8290_close[] = { 0x21, 0xc0};
  419. static u8 tda8290_open[] = { 0x21, 0x80};
  420. struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
  421. if (enable) {
  422. tda8290_msg.buf = tda8290_close;
  423. } else {
  424. tda8290_msg.buf = tda8290_open;
  425. }
  426. if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
  427. struct saa7134_dev *dev = fe->dvb->priv;
  428. wprintk("could not access tda8290 I2C gate\n");
  429. return -EIO;
  430. }
  431. msleep(20);
  432. return 0;
  433. }
  434. /* ------------------------------------------------------------------ */
  435. static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
  436. {
  437. struct saa7134_dev *dev = fe->dvb->priv;
  438. struct tda1004x_state *state = fe->demodulator_priv;
  439. switch (state->config->antenna_switch) {
  440. case 0: break;
  441. case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
  442. saa7134_set_gpio(dev, 21, 0);
  443. break;
  444. case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
  445. saa7134_set_gpio(dev, 21, 1);
  446. break;
  447. }
  448. return 0;
  449. }
  450. static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
  451. {
  452. struct saa7134_dev *dev = fe->dvb->priv;
  453. struct tda1004x_state *state = fe->demodulator_priv;
  454. switch (state->config->antenna_switch) {
  455. case 0: break;
  456. case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
  457. saa7134_set_gpio(dev, 21, 1);
  458. break;
  459. case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
  460. saa7134_set_gpio(dev, 21, 0);
  461. break;
  462. }
  463. return 0;
  464. }
  465. static struct tda827x_config tda827x_cfg = {
  466. .lna_gain = philips_tda827x_lna_gain,
  467. .init = philips_tda827x_tuner_init,
  468. .sleep = philips_tda827x_tuner_sleep
  469. };
  470. static void configure_tda827x_fe(struct saa7134_dev *dev, struct tda1004x_config *tda_conf)
  471. {
  472. dev->dvb.frontend = dvb_attach(tda10046_attach, tda_conf, &dev->i2c_adap);
  473. if (dev->dvb.frontend) {
  474. if (tda_conf->i2c_gate)
  475. dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
  476. if (dvb_attach(tda827x_attach, dev->dvb.frontend, tda_conf->tuner_address,
  477. &dev->i2c_adap,&tda827x_cfg) == NULL) {
  478. wprintk("no tda827x tuner found at addr: %02x\n",
  479. tda_conf->tuner_address);
  480. }
  481. }
  482. }
  483. /* ------------------------------------------------------------------ */
  484. static struct tda1004x_config tda827x_lifeview_config = {
  485. .demod_address = 0x08,
  486. .invert = 1,
  487. .invert_oclk = 0,
  488. .xtal_freq = TDA10046_XTAL_16M,
  489. .agc_config = TDA10046_AGC_TDA827X,
  490. .gpio_config = TDA10046_GP11_I,
  491. .if_freq = TDA10046_FREQ_045,
  492. .tuner_address = 0x60,
  493. .request_firmware = philips_tda1004x_request_firmware
  494. };
  495. static struct tda1004x_config philips_tiger_config = {
  496. .demod_address = 0x08,
  497. .invert = 1,
  498. .invert_oclk = 0,
  499. .xtal_freq = TDA10046_XTAL_16M,
  500. .agc_config = TDA10046_AGC_TDA827X,
  501. .gpio_config = TDA10046_GP11_I,
  502. .if_freq = TDA10046_FREQ_045,
  503. .i2c_gate = 0x4b,
  504. .tuner_address = 0x61,
  505. .tuner_config = 0,
  506. .antenna_switch= 1,
  507. .request_firmware = philips_tda1004x_request_firmware
  508. };
  509. static struct tda1004x_config cinergy_ht_config = {
  510. .demod_address = 0x08,
  511. .invert = 1,
  512. .invert_oclk = 0,
  513. .xtal_freq = TDA10046_XTAL_16M,
  514. .agc_config = TDA10046_AGC_TDA827X,
  515. .gpio_config = TDA10046_GP01_I,
  516. .if_freq = TDA10046_FREQ_045,
  517. .i2c_gate = 0x4b,
  518. .tuner_address = 0x61,
  519. .tuner_config = 0,
  520. .request_firmware = philips_tda1004x_request_firmware
  521. };
  522. static struct tda1004x_config cinergy_ht_pci_config = {
  523. .demod_address = 0x08,
  524. .invert = 1,
  525. .invert_oclk = 0,
  526. .xtal_freq = TDA10046_XTAL_16M,
  527. .agc_config = TDA10046_AGC_TDA827X,
  528. .gpio_config = TDA10046_GP01_I,
  529. .if_freq = TDA10046_FREQ_045,
  530. .i2c_gate = 0x4b,
  531. .tuner_address = 0x60,
  532. .tuner_config = 0,
  533. .request_firmware = philips_tda1004x_request_firmware
  534. };
  535. static struct tda1004x_config philips_tiger_s_config = {
  536. .demod_address = 0x08,
  537. .invert = 1,
  538. .invert_oclk = 0,
  539. .xtal_freq = TDA10046_XTAL_16M,
  540. .agc_config = TDA10046_AGC_TDA827X,
  541. .gpio_config = TDA10046_GP01_I,
  542. .if_freq = TDA10046_FREQ_045,
  543. .i2c_gate = 0x4b,
  544. .tuner_address = 0x61,
  545. .tuner_config = 2,
  546. .antenna_switch= 1,
  547. .request_firmware = philips_tda1004x_request_firmware
  548. };
  549. static struct tda1004x_config pinnacle_pctv_310i_config = {
  550. .demod_address = 0x08,
  551. .invert = 1,
  552. .invert_oclk = 0,
  553. .xtal_freq = TDA10046_XTAL_16M,
  554. .agc_config = TDA10046_AGC_TDA827X,
  555. .gpio_config = TDA10046_GP11_I,
  556. .if_freq = TDA10046_FREQ_045,
  557. .i2c_gate = 0x4b,
  558. .tuner_address = 0x61,
  559. .tuner_config = 1,
  560. .request_firmware = philips_tda1004x_request_firmware
  561. };
  562. static struct tda1004x_config hauppauge_hvr_1110_config = {
  563. .demod_address = 0x08,
  564. .invert = 1,
  565. .invert_oclk = 0,
  566. .xtal_freq = TDA10046_XTAL_16M,
  567. .agc_config = TDA10046_AGC_TDA827X,
  568. .gpio_config = TDA10046_GP11_I,
  569. .if_freq = TDA10046_FREQ_045,
  570. .i2c_gate = 0x4b,
  571. .tuner_address = 0x61,
  572. .tuner_config = 1,
  573. .request_firmware = philips_tda1004x_request_firmware
  574. };
  575. static struct tda1004x_config asus_p7131_dual_config = {
  576. .demod_address = 0x08,
  577. .invert = 1,
  578. .invert_oclk = 0,
  579. .xtal_freq = TDA10046_XTAL_16M,
  580. .agc_config = TDA10046_AGC_TDA827X,
  581. .gpio_config = TDA10046_GP11_I,
  582. .if_freq = TDA10046_FREQ_045,
  583. .i2c_gate = 0x4b,
  584. .tuner_address = 0x61,
  585. .tuner_config = 0,
  586. .antenna_switch= 2,
  587. .request_firmware = philips_tda1004x_request_firmware
  588. };
  589. static struct tda1004x_config lifeview_trio_config = {
  590. .demod_address = 0x09,
  591. .invert = 1,
  592. .invert_oclk = 0,
  593. .xtal_freq = TDA10046_XTAL_16M,
  594. .agc_config = TDA10046_AGC_TDA827X,
  595. .gpio_config = TDA10046_GP00_I,
  596. .if_freq = TDA10046_FREQ_045,
  597. .tuner_address = 0x60,
  598. .request_firmware = philips_tda1004x_request_firmware
  599. };
  600. static struct tda1004x_config tevion_dvbt220rf_config = {
  601. .demod_address = 0x08,
  602. .invert = 1,
  603. .invert_oclk = 0,
  604. .xtal_freq = TDA10046_XTAL_16M,
  605. .agc_config = TDA10046_AGC_TDA827X,
  606. .gpio_config = TDA10046_GP11_I,
  607. .if_freq = TDA10046_FREQ_045,
  608. .tuner_address = 0x60,
  609. .request_firmware = philips_tda1004x_request_firmware
  610. };
  611. static struct tda1004x_config md8800_dvbt_config = {
  612. .demod_address = 0x08,
  613. .invert = 1,
  614. .invert_oclk = 0,
  615. .xtal_freq = TDA10046_XTAL_16M,
  616. .agc_config = TDA10046_AGC_TDA827X,
  617. .gpio_config = TDA10046_GP01_I,
  618. .if_freq = TDA10046_FREQ_045,
  619. .i2c_gate = 0x4b,
  620. .tuner_address = 0x60,
  621. .tuner_config = 0,
  622. .request_firmware = philips_tda1004x_request_firmware
  623. };
  624. static struct tda1004x_config asus_p7131_4871_config = {
  625. .demod_address = 0x08,
  626. .invert = 1,
  627. .invert_oclk = 0,
  628. .xtal_freq = TDA10046_XTAL_16M,
  629. .agc_config = TDA10046_AGC_TDA827X,
  630. .gpio_config = TDA10046_GP01_I,
  631. .if_freq = TDA10046_FREQ_045,
  632. .i2c_gate = 0x4b,
  633. .tuner_address = 0x61,
  634. .tuner_config = 2,
  635. .antenna_switch= 2,
  636. .request_firmware = philips_tda1004x_request_firmware
  637. };
  638. static struct tda1004x_config asus_p7131_hybrid_lna_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_GP11_I,
  645. .if_freq = TDA10046_FREQ_045,
  646. .i2c_gate = 0x4b,
  647. .tuner_address = 0x61,
  648. .tuner_config = 2,
  649. .antenna_switch= 2,
  650. .request_firmware = philips_tda1004x_request_firmware
  651. };
  652. static struct tda1004x_config kworld_dvb_t_210_config = {
  653. .demod_address = 0x08,
  654. .invert = 1,
  655. .invert_oclk = 0,
  656. .xtal_freq = TDA10046_XTAL_16M,
  657. .agc_config = TDA10046_AGC_TDA827X,
  658. .gpio_config = TDA10046_GP11_I,
  659. .if_freq = TDA10046_FREQ_045,
  660. .i2c_gate = 0x4b,
  661. .tuner_address = 0x61,
  662. .tuner_config = 2,
  663. .antenna_switch= 1,
  664. .request_firmware = philips_tda1004x_request_firmware
  665. };
  666. static struct tda1004x_config avermedia_super_007_config = {
  667. .demod_address = 0x08,
  668. .invert = 1,
  669. .invert_oclk = 0,
  670. .xtal_freq = TDA10046_XTAL_16M,
  671. .agc_config = TDA10046_AGC_TDA827X,
  672. .gpio_config = TDA10046_GP01_I,
  673. .if_freq = TDA10046_FREQ_045,
  674. .i2c_gate = 0x4b,
  675. .tuner_address = 0x60,
  676. .tuner_config = 0,
  677. .antenna_switch= 1,
  678. .request_firmware = philips_tda1004x_request_firmware
  679. };
  680. static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
  681. .demod_address = 0x08,
  682. .invert = 1,
  683. .invert_oclk = 0,
  684. .xtal_freq = TDA10046_XTAL_16M,
  685. .agc_config = TDA10046_AGC_TDA827X,
  686. .gpio_config = TDA10046_GP01_I,
  687. .if_freq = TDA10046_FREQ_045,
  688. .i2c_gate = 0x42,
  689. .tuner_address = 0x61,
  690. .tuner_config = 2,
  691. .antenna_switch = 1,
  692. .request_firmware = philips_tda1004x_request_firmware
  693. };
  694. /* ------------------------------------------------------------------
  695. * special case: this card uses saa713x GPIO22 for the mode switch
  696. */
  697. static int ads_duo_tuner_init(struct dvb_frontend *fe)
  698. {
  699. struct saa7134_dev *dev = fe->dvb->priv;
  700. philips_tda827x_tuner_init(fe);
  701. /* route TDA8275a AGC input to the channel decoder */
  702. saa7134_set_gpio(dev, 22, 1);
  703. return 0;
  704. }
  705. static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
  706. {
  707. struct saa7134_dev *dev = fe->dvb->priv;
  708. /* route TDA8275a AGC input to the analog IF chip*/
  709. saa7134_set_gpio(dev, 22, 0);
  710. philips_tda827x_tuner_sleep(fe);
  711. return 0;
  712. }
  713. static struct tda827x_config ads_duo_cfg = {
  714. .lna_gain = philips_tda827x_lna_gain,
  715. .init = ads_duo_tuner_init,
  716. .sleep = ads_duo_tuner_sleep
  717. };
  718. static struct tda1004x_config ads_tech_duo_config = {
  719. .demod_address = 0x08,
  720. .invert = 1,
  721. .invert_oclk = 0,
  722. .xtal_freq = TDA10046_XTAL_16M,
  723. .agc_config = TDA10046_AGC_TDA827X,
  724. .gpio_config = TDA10046_GP00_I,
  725. .if_freq = TDA10046_FREQ_045,
  726. .tuner_address = 0x61,
  727. .request_firmware = philips_tda1004x_request_firmware
  728. };
  729. /* ==================================================================
  730. * tda10086 based DVB-S cards, helper functions
  731. */
  732. static struct tda10086_config flydvbs = {
  733. .demod_address = 0x0e,
  734. .invert = 0,
  735. .diseqc_tone = 0,
  736. };
  737. /* ==================================================================
  738. * nxt200x based ATSC cards, helper functions
  739. */
  740. static struct nxt200x_config avertvhda180 = {
  741. .demod_address = 0x0a,
  742. };
  743. static struct nxt200x_config kworldatsc110 = {
  744. .demod_address = 0x0a,
  745. };
  746. /* ==================================================================
  747. * Core code
  748. */
  749. static int dvb_init(struct saa7134_dev *dev)
  750. {
  751. int ret;
  752. /* init struct videobuf_dvb */
  753. dev->ts.nr_bufs = 32;
  754. dev->ts.nr_packets = 32*4;
  755. dev->dvb.name = dev->name;
  756. videobuf_queue_pci_init(&dev->dvb.dvbq, &saa7134_ts_qops,
  757. dev->pci, &dev->slock,
  758. V4L2_BUF_TYPE_VIDEO_CAPTURE,
  759. V4L2_FIELD_ALTERNATE,
  760. sizeof(struct saa7134_buf),
  761. dev);
  762. switch (dev->board) {
  763. case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
  764. dprintk("pinnacle 300i dvb setup\n");
  765. dev->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
  766. &dev->i2c_adap);
  767. if (dev->dvb.frontend) {
  768. dev->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
  769. }
  770. break;
  771. case SAA7134_BOARD_AVERMEDIA_777:
  772. case SAA7134_BOARD_AVERMEDIA_A16AR:
  773. dprintk("avertv 777 dvb setup\n");
  774. dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
  775. &dev->i2c_adap);
  776. if (dev->dvb.frontend) {
  777. dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
  778. NULL, DVB_PLL_PHILIPS_TD1316);
  779. }
  780. break;
  781. case SAA7134_BOARD_MD7134:
  782. dev->dvb.frontend = dvb_attach(tda10046_attach,
  783. &medion_cardbus,
  784. &dev->i2c_adap);
  785. if (dev->dvb.frontend) {
  786. dvb_attach(dvb_pll_attach, dev->dvb.frontend, medion_cardbus.tuner_address,
  787. &dev->i2c_adap, DVB_PLL_FMD1216ME);
  788. }
  789. break;
  790. case SAA7134_BOARD_PHILIPS_TOUGH:
  791. dev->dvb.frontend = dvb_attach(tda10046_attach,
  792. &philips_tu1216_60_config,
  793. &dev->i2c_adap);
  794. if (dev->dvb.frontend) {
  795. dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
  796. dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
  797. }
  798. break;
  799. case SAA7134_BOARD_FLYDVBTDUO:
  800. case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
  801. configure_tda827x_fe(dev, &tda827x_lifeview_config);
  802. break;
  803. case SAA7134_BOARD_PHILIPS_EUROPA:
  804. case SAA7134_BOARD_VIDEOMATE_DVBT_300:
  805. dev->dvb.frontend = dvb_attach(tda10046_attach,
  806. &philips_europa_config,
  807. &dev->i2c_adap);
  808. if (dev->dvb.frontend) {
  809. dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
  810. dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
  811. dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
  812. dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
  813. dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
  814. }
  815. break;
  816. case SAA7134_BOARD_VIDEOMATE_DVBT_200:
  817. dev->dvb.frontend = dvb_attach(tda10046_attach,
  818. &philips_tu1216_61_config,
  819. &dev->i2c_adap);
  820. if (dev->dvb.frontend) {
  821. dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
  822. dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
  823. }
  824. break;
  825. case SAA7134_BOARD_KWORLD_DVBT_210:
  826. configure_tda827x_fe(dev, &kworld_dvb_t_210_config);
  827. break;
  828. case SAA7134_BOARD_PHILIPS_TIGER:
  829. configure_tda827x_fe(dev, &philips_tiger_config);
  830. break;
  831. case SAA7134_BOARD_PINNACLE_PCTV_310i:
  832. configure_tda827x_fe(dev, &pinnacle_pctv_310i_config);
  833. break;
  834. case SAA7134_BOARD_HAUPPAUGE_HVR1110:
  835. configure_tda827x_fe(dev, &hauppauge_hvr_1110_config);
  836. break;
  837. case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
  838. configure_tda827x_fe(dev, &asus_p7131_dual_config);
  839. break;
  840. case SAA7134_BOARD_FLYDVBT_LR301:
  841. configure_tda827x_fe(dev, &tda827x_lifeview_config);
  842. break;
  843. case SAA7134_BOARD_FLYDVB_TRIO:
  844. if(! use_frontend) { /* terrestrial */
  845. configure_tda827x_fe(dev, &lifeview_trio_config);
  846. } else { /* satellite */
  847. dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
  848. if (dev->dvb.frontend) {
  849. if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63,
  850. &dev->i2c_adap, 0) == NULL) {
  851. wprintk("%s: Lifeview Trio, No tda826x found!\n", __FUNCTION__);
  852. }
  853. if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap,
  854. 0x08, 0, 0) == NULL) {
  855. wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __FUNCTION__);
  856. }
  857. }
  858. }
  859. break;
  860. case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
  861. case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
  862. dev->dvb.frontend = dvb_attach(tda10046_attach,
  863. &ads_tech_duo_config,
  864. &dev->i2c_adap);
  865. if (dev->dvb.frontend) {
  866. if (dvb_attach(tda827x_attach,dev->dvb.frontend,
  867. ads_tech_duo_config.tuner_address,
  868. &dev->i2c_adap,&ads_duo_cfg) == NULL) {
  869. wprintk("no tda827x tuner found at addr: %02x\n",
  870. ads_tech_duo_config.tuner_address);
  871. }
  872. }
  873. break;
  874. case SAA7134_BOARD_TEVION_DVBT_220RF:
  875. configure_tda827x_fe(dev, &tevion_dvbt220rf_config);
  876. break;
  877. case SAA7134_BOARD_MEDION_MD8800_QUADRO:
  878. configure_tda827x_fe(dev, &md8800_dvbt_config);
  879. break;
  880. case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
  881. dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
  882. &dev->i2c_adap);
  883. if (dev->dvb.frontend) {
  884. dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
  885. NULL, DVB_PLL_TDHU2);
  886. }
  887. break;
  888. case SAA7134_BOARD_KWORLD_ATSC110:
  889. dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
  890. &dev->i2c_adap);
  891. if (dev->dvb.frontend) {
  892. dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
  893. NULL, DVB_PLL_TUV1236D);
  894. }
  895. break;
  896. case SAA7134_BOARD_FLYDVBS_LR300:
  897. dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
  898. &dev->i2c_adap);
  899. if (dev->dvb.frontend) {
  900. if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
  901. &dev->i2c_adap, 0) == NULL) {
  902. wprintk("%s: No tda826x found!\n", __FUNCTION__);
  903. }
  904. if (dvb_attach(isl6421_attach, dev->dvb.frontend,
  905. &dev->i2c_adap, 0x08, 0, 0) == NULL) {
  906. wprintk("%s: No ISL6421 found!\n", __FUNCTION__);
  907. }
  908. }
  909. break;
  910. case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
  911. dev->dvb.frontend = dvb_attach(tda10046_attach,
  912. &medion_cardbus,
  913. &dev->i2c_adap);
  914. if (dev->dvb.frontend) {
  915. dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
  916. dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
  917. dvb_attach(dvb_pll_attach, dev->dvb.frontend, medion_cardbus.tuner_address,
  918. &dev->i2c_adap, DVB_PLL_FMD1216ME);
  919. }
  920. break;
  921. case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
  922. dev->dvb.frontend = dvb_attach(tda10046_attach,
  923. &philips_europa_config,
  924. &dev->i2c_adap);
  925. if (dev->dvb.frontend) {
  926. dev->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
  927. dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
  928. }
  929. break;
  930. case SAA7134_BOARD_CINERGY_HT_PCMCIA:
  931. configure_tda827x_fe(dev, &cinergy_ht_config);
  932. break;
  933. case SAA7134_BOARD_CINERGY_HT_PCI:
  934. configure_tda827x_fe(dev, &cinergy_ht_pci_config);
  935. break;
  936. case SAA7134_BOARD_PHILIPS_TIGER_S:
  937. configure_tda827x_fe(dev, &philips_tiger_s_config);
  938. break;
  939. case SAA7134_BOARD_ASUS_P7131_4871:
  940. configure_tda827x_fe(dev, &asus_p7131_4871_config);
  941. break;
  942. case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
  943. configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config);
  944. break;
  945. case SAA7134_BOARD_AVERMEDIA_SUPER_007:
  946. configure_tda827x_fe(dev, &avermedia_super_007_config);
  947. break;
  948. case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
  949. configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config);
  950. break;
  951. default:
  952. wprintk("Huh? unknown DVB card?\n");
  953. break;
  954. }
  955. if (NULL == dev->dvb.frontend) {
  956. printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
  957. return -1;
  958. }
  959. /* register everything else */
  960. ret = videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev);
  961. /* this sequence is necessary to make the tda1004x load its firmware
  962. * and to enter analog mode of hybrid boards
  963. */
  964. if (!ret) {
  965. if (dev->dvb.frontend->ops.init)
  966. dev->dvb.frontend->ops.init(dev->dvb.frontend);
  967. if (dev->dvb.frontend->ops.sleep)
  968. dev->dvb.frontend->ops.sleep(dev->dvb.frontend);
  969. if (dev->dvb.frontend->ops.tuner_ops.sleep)
  970. dev->dvb.frontend->ops.tuner_ops.sleep(dev->dvb.frontend);
  971. }
  972. return ret;
  973. }
  974. static int dvb_fini(struct saa7134_dev *dev)
  975. {
  976. /* FIXME: I suspect that this code is bogus, since the entry for
  977. Pinnacle 300I DVB-T PAL already defines the proper init to allow
  978. the detection of mt2032 (TDA9887_PORT2_INACTIVE)
  979. */
  980. if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
  981. struct v4l2_priv_tun_config tda9887_cfg;
  982. static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
  983. tda9887_cfg.tuner = TUNER_TDA9887;
  984. tda9887_cfg.priv = &on;
  985. /* otherwise we don't detect the tuner on next insmod */
  986. saa7134_i2c_call_clients(dev, TUNER_SET_CONFIG, &tda9887_cfg);
  987. }
  988. videobuf_dvb_unregister(&dev->dvb);
  989. return 0;
  990. }
  991. static struct saa7134_mpeg_ops dvb_ops = {
  992. .type = SAA7134_MPEG_DVB,
  993. .init = dvb_init,
  994. .fini = dvb_fini,
  995. };
  996. static int __init dvb_register(void)
  997. {
  998. return saa7134_ts_register(&dvb_ops);
  999. }
  1000. static void __exit dvb_unregister(void)
  1001. {
  1002. saa7134_ts_unregister(&dvb_ops);
  1003. }
  1004. module_init(dvb_register);
  1005. module_exit(dvb_unregister);
  1006. /* ------------------------------------------------------------------ */
  1007. /*
  1008. * Local variables:
  1009. * c-basic-offset: 8
  1010. * End:
  1011. */