saa7134-dvb.c 38 KB

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