saa7134-dvb.c 35 KB

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