saa7134-dvb.c 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137
  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. };
  736. /* ==================================================================
  737. * nxt200x based ATSC cards, helper functions
  738. */
  739. static struct nxt200x_config avertvhda180 = {
  740. .demod_address = 0x0a,
  741. };
  742. static struct nxt200x_config kworldatsc110 = {
  743. .demod_address = 0x0a,
  744. };
  745. /* ==================================================================
  746. * Core code
  747. */
  748. static int dvb_init(struct saa7134_dev *dev)
  749. {
  750. int ret;
  751. /* init struct videobuf_dvb */
  752. dev->ts.nr_bufs = 32;
  753. dev->ts.nr_packets = 32*4;
  754. dev->dvb.name = dev->name;
  755. videobuf_queue_pci_init(&dev->dvb.dvbq, &saa7134_ts_qops,
  756. dev->pci, &dev->slock,
  757. V4L2_BUF_TYPE_VIDEO_CAPTURE,
  758. V4L2_FIELD_ALTERNATE,
  759. sizeof(struct saa7134_buf),
  760. dev);
  761. switch (dev->board) {
  762. case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
  763. dprintk("pinnacle 300i dvb setup\n");
  764. dev->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
  765. &dev->i2c_adap);
  766. if (dev->dvb.frontend) {
  767. dev->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
  768. }
  769. break;
  770. case SAA7134_BOARD_AVERMEDIA_777:
  771. case SAA7134_BOARD_AVERMEDIA_A16AR:
  772. dprintk("avertv 777 dvb setup\n");
  773. dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
  774. &dev->i2c_adap);
  775. if (dev->dvb.frontend) {
  776. dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
  777. NULL, DVB_PLL_PHILIPS_TD1316);
  778. }
  779. break;
  780. case SAA7134_BOARD_MD7134:
  781. dev->dvb.frontend = dvb_attach(tda10046_attach,
  782. &medion_cardbus,
  783. &dev->i2c_adap);
  784. if (dev->dvb.frontend) {
  785. dvb_attach(dvb_pll_attach, dev->dvb.frontend, medion_cardbus.tuner_address,
  786. &dev->i2c_adap, DVB_PLL_FMD1216ME);
  787. }
  788. break;
  789. case SAA7134_BOARD_PHILIPS_TOUGH:
  790. dev->dvb.frontend = dvb_attach(tda10046_attach,
  791. &philips_tu1216_60_config,
  792. &dev->i2c_adap);
  793. if (dev->dvb.frontend) {
  794. dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
  795. dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
  796. }
  797. break;
  798. case SAA7134_BOARD_FLYDVBTDUO:
  799. case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
  800. configure_tda827x_fe(dev, &tda827x_lifeview_config);
  801. break;
  802. case SAA7134_BOARD_PHILIPS_EUROPA:
  803. case SAA7134_BOARD_VIDEOMATE_DVBT_300:
  804. dev->dvb.frontend = dvb_attach(tda10046_attach,
  805. &philips_europa_config,
  806. &dev->i2c_adap);
  807. if (dev->dvb.frontend) {
  808. dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
  809. dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
  810. dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
  811. dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
  812. dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
  813. }
  814. break;
  815. case SAA7134_BOARD_VIDEOMATE_DVBT_200:
  816. dev->dvb.frontend = dvb_attach(tda10046_attach,
  817. &philips_tu1216_61_config,
  818. &dev->i2c_adap);
  819. if (dev->dvb.frontend) {
  820. dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
  821. dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
  822. }
  823. break;
  824. case SAA7134_BOARD_KWORLD_DVBT_210:
  825. configure_tda827x_fe(dev, &kworld_dvb_t_210_config);
  826. break;
  827. case SAA7134_BOARD_PHILIPS_TIGER:
  828. configure_tda827x_fe(dev, &philips_tiger_config);
  829. break;
  830. case SAA7134_BOARD_PINNACLE_PCTV_310i:
  831. configure_tda827x_fe(dev, &pinnacle_pctv_310i_config);
  832. break;
  833. case SAA7134_BOARD_HAUPPAUGE_HVR1110:
  834. configure_tda827x_fe(dev, &hauppauge_hvr_1110_config);
  835. break;
  836. case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
  837. configure_tda827x_fe(dev, &asus_p7131_dual_config);
  838. break;
  839. case SAA7134_BOARD_FLYDVBT_LR301:
  840. configure_tda827x_fe(dev, &tda827x_lifeview_config);
  841. break;
  842. case SAA7134_BOARD_FLYDVB_TRIO:
  843. if(! use_frontend) { //terrestrial
  844. configure_tda827x_fe(dev, &lifeview_trio_config);
  845. } else { //satellite
  846. dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
  847. if (dev->dvb.frontend) {
  848. if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63,
  849. &dev->i2c_adap, 0) == NULL) {
  850. wprintk("%s: Lifeview Trio, No tda826x found!\n", __FUNCTION__);
  851. }
  852. if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap,
  853. 0x08, 0, 0) == NULL) {
  854. wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __FUNCTION__);
  855. }
  856. }
  857. }
  858. break;
  859. case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
  860. case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
  861. dev->dvb.frontend = dvb_attach(tda10046_attach,
  862. &ads_tech_duo_config,
  863. &dev->i2c_adap);
  864. if (dev->dvb.frontend) {
  865. if (dvb_attach(tda827x_attach,dev->dvb.frontend,
  866. ads_tech_duo_config.tuner_address,
  867. &dev->i2c_adap,&ads_duo_cfg) == NULL) {
  868. wprintk("no tda827x tuner found at addr: %02x\n",
  869. ads_tech_duo_config.tuner_address);
  870. }
  871. }
  872. break;
  873. case SAA7134_BOARD_TEVION_DVBT_220RF:
  874. configure_tda827x_fe(dev, &tevion_dvbt220rf_config);
  875. break;
  876. case SAA7134_BOARD_MEDION_MD8800_QUADRO:
  877. configure_tda827x_fe(dev, &md8800_dvbt_config);
  878. break;
  879. case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
  880. dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
  881. &dev->i2c_adap);
  882. if (dev->dvb.frontend) {
  883. dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
  884. NULL, DVB_PLL_TDHU2);
  885. }
  886. break;
  887. case SAA7134_BOARD_KWORLD_ATSC110:
  888. dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
  889. &dev->i2c_adap);
  890. if (dev->dvb.frontend) {
  891. dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
  892. NULL, DVB_PLL_TUV1236D);
  893. }
  894. break;
  895. case SAA7134_BOARD_FLYDVBS_LR300:
  896. dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
  897. &dev->i2c_adap);
  898. if (dev->dvb.frontend) {
  899. if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
  900. &dev->i2c_adap, 0) == NULL) {
  901. wprintk("%s: No tda826x found!\n", __FUNCTION__);
  902. }
  903. if (dvb_attach(isl6421_attach, dev->dvb.frontend,
  904. &dev->i2c_adap, 0x08, 0, 0) == NULL) {
  905. wprintk("%s: No ISL6421 found!\n", __FUNCTION__);
  906. }
  907. }
  908. break;
  909. case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
  910. dev->dvb.frontend = tda10046_attach(&medion_cardbus,
  911. &dev->i2c_adap);
  912. if (dev->dvb.frontend) {
  913. dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
  914. dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
  915. dvb_attach(dvb_pll_attach, dev->dvb.frontend, medion_cardbus.tuner_address,
  916. &dev->i2c_adap, DVB_PLL_FMD1216ME);
  917. }
  918. break;
  919. case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
  920. dev->dvb.frontend = dvb_attach(tda10046_attach,
  921. &philips_europa_config,
  922. &dev->i2c_adap);
  923. if (dev->dvb.frontend) {
  924. dev->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
  925. dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
  926. }
  927. break;
  928. case SAA7134_BOARD_CINERGY_HT_PCMCIA:
  929. configure_tda827x_fe(dev, &cinergy_ht_config);
  930. break;
  931. case SAA7134_BOARD_CINERGY_HT_PCI:
  932. configure_tda827x_fe(dev, &cinergy_ht_pci_config);
  933. break;
  934. case SAA7134_BOARD_PHILIPS_TIGER_S:
  935. configure_tda827x_fe(dev, &philips_tiger_s_config);
  936. break;
  937. case SAA7134_BOARD_ASUS_P7131_4871:
  938. configure_tda827x_fe(dev, &asus_p7131_4871_config);
  939. break;
  940. case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
  941. configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config);
  942. break;
  943. case SAA7134_BOARD_AVERMEDIA_SUPER_007:
  944. configure_tda827x_fe(dev, &avermedia_super_007_config);
  945. break;
  946. case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
  947. configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config);
  948. break;
  949. default:
  950. wprintk("Huh? unknown DVB card?\n");
  951. break;
  952. }
  953. if (NULL == dev->dvb.frontend) {
  954. printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
  955. return -1;
  956. }
  957. /* register everything else */
  958. ret = videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev);
  959. /* this sequence is necessary to make the tda1004x load its firmware
  960. * and to enter analog mode of hybrid boards
  961. */
  962. if (!ret) {
  963. if (dev->dvb.frontend->ops.init)
  964. dev->dvb.frontend->ops.init(dev->dvb.frontend);
  965. if (dev->dvb.frontend->ops.sleep)
  966. dev->dvb.frontend->ops.sleep(dev->dvb.frontend);
  967. if (dev->dvb.frontend->ops.tuner_ops.sleep)
  968. dev->dvb.frontend->ops.tuner_ops.sleep(dev->dvb.frontend);
  969. }
  970. return ret;
  971. }
  972. static int dvb_fini(struct saa7134_dev *dev)
  973. {
  974. /* FIXME: I suspect that this code is bogus, since the entry for
  975. Pinnacle 300I DVB-T PAL already defines the proper init to allow
  976. the detection of mt2032 (TDA9887_PORT2_INACTIVE)
  977. */
  978. if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
  979. struct v4l2_priv_tun_config tda9887_cfg;
  980. static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
  981. tda9887_cfg.tuner = TUNER_TDA9887;
  982. tda9887_cfg.priv = &on;
  983. /* otherwise we don't detect the tuner on next insmod */
  984. saa7134_i2c_call_clients(dev, TUNER_SET_CONFIG, &tda9887_cfg);
  985. }
  986. videobuf_dvb_unregister(&dev->dvb);
  987. return 0;
  988. }
  989. static struct saa7134_mpeg_ops dvb_ops = {
  990. .type = SAA7134_MPEG_DVB,
  991. .init = dvb_init,
  992. .fini = dvb_fini,
  993. };
  994. static int __init dvb_register(void)
  995. {
  996. return saa7134_ts_register(&dvb_ops);
  997. }
  998. static void __exit dvb_unregister(void)
  999. {
  1000. saa7134_ts_unregister(&dvb_ops);
  1001. }
  1002. module_init(dvb_register);
  1003. module_exit(dvb_unregister);
  1004. /* ------------------------------------------------------------------ */
  1005. /*
  1006. * Local variables:
  1007. * c-basic-offset: 8
  1008. * End:
  1009. */