saa7134-dvb.c 38 KB

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