saa7134-dvb.c 34 KB

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