saa7134-dvb.c 35 KB

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