lgdt3305.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216
  1. /*
  2. * Support for LG Electronics LGDT3304 and LGDT3305 - VSB/QAM
  3. *
  4. * Copyright (C) 2008, 2009, 2010 Michael Krufky <mkrufky@linuxtv.org>
  5. *
  6. * LGDT3304 support by Jarod Wilson <jarod@redhat.com>
  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. */
  23. #include <asm/div64.h>
  24. #include <linux/dvb/frontend.h>
  25. #include <linux/slab.h>
  26. #include "dvb_math.h"
  27. #include "lgdt3305.h"
  28. static int debug;
  29. module_param(debug, int, 0644);
  30. MODULE_PARM_DESC(debug, "set debug level (info=1, reg=2 (or-able))");
  31. #define DBG_INFO 1
  32. #define DBG_REG 2
  33. #define lg_printk(kern, fmt, arg...) \
  34. printk(kern "%s: " fmt, __func__, ##arg)
  35. #define lg_info(fmt, arg...) printk(KERN_INFO "lgdt3305: " fmt, ##arg)
  36. #define lg_warn(fmt, arg...) lg_printk(KERN_WARNING, fmt, ##arg)
  37. #define lg_err(fmt, arg...) lg_printk(KERN_ERR, fmt, ##arg)
  38. #define lg_dbg(fmt, arg...) if (debug & DBG_INFO) \
  39. lg_printk(KERN_DEBUG, fmt, ##arg)
  40. #define lg_reg(fmt, arg...) if (debug & DBG_REG) \
  41. lg_printk(KERN_DEBUG, fmt, ##arg)
  42. #define lg_fail(ret) \
  43. ({ \
  44. int __ret; \
  45. __ret = (ret < 0); \
  46. if (__ret) \
  47. lg_err("error %d on line %d\n", ret, __LINE__); \
  48. __ret; \
  49. })
  50. struct lgdt3305_state {
  51. struct i2c_adapter *i2c_adap;
  52. const struct lgdt3305_config *cfg;
  53. struct dvb_frontend frontend;
  54. enum fe_modulation current_modulation;
  55. u32 current_frequency;
  56. u32 snr;
  57. };
  58. /* ------------------------------------------------------------------------ */
  59. /* FIXME: verify & document the LGDT3304 registers */
  60. #define LGDT3305_GEN_CTRL_1 0x0000
  61. #define LGDT3305_GEN_CTRL_2 0x0001
  62. #define LGDT3305_GEN_CTRL_3 0x0002
  63. #define LGDT3305_GEN_STATUS 0x0003
  64. #define LGDT3305_GEN_CONTROL 0x0007
  65. #define LGDT3305_GEN_CTRL_4 0x000a
  66. #define LGDT3305_DGTL_AGC_REF_1 0x0012
  67. #define LGDT3305_DGTL_AGC_REF_2 0x0013
  68. #define LGDT3305_CR_CTR_FREQ_1 0x0106
  69. #define LGDT3305_CR_CTR_FREQ_2 0x0107
  70. #define LGDT3305_CR_CTR_FREQ_3 0x0108
  71. #define LGDT3305_CR_CTR_FREQ_4 0x0109
  72. #define LGDT3305_CR_MSE_1 0x011b
  73. #define LGDT3305_CR_MSE_2 0x011c
  74. #define LGDT3305_CR_LOCK_STATUS 0x011d
  75. #define LGDT3305_CR_CTRL_7 0x0126
  76. #define LGDT3305_AGC_POWER_REF_1 0x0300
  77. #define LGDT3305_AGC_POWER_REF_2 0x0301
  78. #define LGDT3305_AGC_DELAY_PT_1 0x0302
  79. #define LGDT3305_AGC_DELAY_PT_2 0x0303
  80. #define LGDT3305_RFAGC_LOOP_FLTR_BW_1 0x0306
  81. #define LGDT3305_RFAGC_LOOP_FLTR_BW_2 0x0307
  82. #define LGDT3305_IFBW_1 0x0308
  83. #define LGDT3305_IFBW_2 0x0309
  84. #define LGDT3305_AGC_CTRL_1 0x030c
  85. #define LGDT3305_AGC_CTRL_4 0x0314
  86. #define LGDT3305_EQ_MSE_1 0x0413
  87. #define LGDT3305_EQ_MSE_2 0x0414
  88. #define LGDT3305_EQ_MSE_3 0x0415
  89. #define LGDT3305_PT_MSE_1 0x0417
  90. #define LGDT3305_PT_MSE_2 0x0418
  91. #define LGDT3305_PT_MSE_3 0x0419
  92. #define LGDT3305_FEC_BLOCK_CTRL 0x0504
  93. #define LGDT3305_FEC_LOCK_STATUS 0x050a
  94. #define LGDT3305_FEC_PKT_ERR_1 0x050c
  95. #define LGDT3305_FEC_PKT_ERR_2 0x050d
  96. #define LGDT3305_TP_CTRL_1 0x050e
  97. #define LGDT3305_BERT_PERIOD 0x0801
  98. #define LGDT3305_BERT_ERROR_COUNT_1 0x080a
  99. #define LGDT3305_BERT_ERROR_COUNT_2 0x080b
  100. #define LGDT3305_BERT_ERROR_COUNT_3 0x080c
  101. #define LGDT3305_BERT_ERROR_COUNT_4 0x080d
  102. static int lgdt3305_write_reg(struct lgdt3305_state *state, u16 reg, u8 val)
  103. {
  104. int ret;
  105. u8 buf[] = { reg >> 8, reg & 0xff, val };
  106. struct i2c_msg msg = {
  107. .addr = state->cfg->i2c_addr, .flags = 0,
  108. .buf = buf, .len = 3,
  109. };
  110. lg_reg("reg: 0x%04x, val: 0x%02x\n", reg, val);
  111. ret = i2c_transfer(state->i2c_adap, &msg, 1);
  112. if (ret != 1) {
  113. lg_err("error (addr %02x %02x <- %02x, err = %i)\n",
  114. msg.buf[0], msg.buf[1], msg.buf[2], ret);
  115. if (ret < 0)
  116. return ret;
  117. else
  118. return -EREMOTEIO;
  119. }
  120. return 0;
  121. }
  122. static int lgdt3305_read_reg(struct lgdt3305_state *state, u16 reg, u8 *val)
  123. {
  124. int ret;
  125. u8 reg_buf[] = { reg >> 8, reg & 0xff };
  126. struct i2c_msg msg[] = {
  127. { .addr = state->cfg->i2c_addr,
  128. .flags = 0, .buf = reg_buf, .len = 2 },
  129. { .addr = state->cfg->i2c_addr,
  130. .flags = I2C_M_RD, .buf = val, .len = 1 },
  131. };
  132. lg_reg("reg: 0x%04x\n", reg);
  133. ret = i2c_transfer(state->i2c_adap, msg, 2);
  134. if (ret != 2) {
  135. lg_err("error (addr %02x reg %04x error (ret == %i)\n",
  136. state->cfg->i2c_addr, reg, ret);
  137. if (ret < 0)
  138. return ret;
  139. else
  140. return -EREMOTEIO;
  141. }
  142. return 0;
  143. }
  144. #define read_reg(state, reg) \
  145. ({ \
  146. u8 __val; \
  147. int ret = lgdt3305_read_reg(state, reg, &__val); \
  148. if (lg_fail(ret)) \
  149. __val = 0; \
  150. __val; \
  151. })
  152. static int lgdt3305_set_reg_bit(struct lgdt3305_state *state,
  153. u16 reg, int bit, int onoff)
  154. {
  155. u8 val;
  156. int ret;
  157. lg_reg("reg: 0x%04x, bit: %d, level: %d\n", reg, bit, onoff);
  158. ret = lgdt3305_read_reg(state, reg, &val);
  159. if (lg_fail(ret))
  160. goto fail;
  161. val &= ~(1 << bit);
  162. val |= (onoff & 1) << bit;
  163. ret = lgdt3305_write_reg(state, reg, val);
  164. fail:
  165. return ret;
  166. }
  167. struct lgdt3305_reg {
  168. u16 reg;
  169. u8 val;
  170. };
  171. static int lgdt3305_write_regs(struct lgdt3305_state *state,
  172. struct lgdt3305_reg *regs, int len)
  173. {
  174. int i, ret;
  175. lg_reg("writing %d registers...\n", len);
  176. for (i = 0; i < len - 1; i++) {
  177. ret = lgdt3305_write_reg(state, regs[i].reg, regs[i].val);
  178. if (lg_fail(ret))
  179. return ret;
  180. }
  181. return 0;
  182. }
  183. /* ------------------------------------------------------------------------ */
  184. static int lgdt3305_soft_reset(struct lgdt3305_state *state)
  185. {
  186. int ret;
  187. lg_dbg("\n");
  188. ret = lgdt3305_set_reg_bit(state, LGDT3305_GEN_CTRL_3, 0, 0);
  189. if (lg_fail(ret))
  190. goto fail;
  191. msleep(20);
  192. ret = lgdt3305_set_reg_bit(state, LGDT3305_GEN_CTRL_3, 0, 1);
  193. fail:
  194. return ret;
  195. }
  196. static inline int lgdt3305_mpeg_mode(struct lgdt3305_state *state,
  197. enum lgdt3305_mpeg_mode mode)
  198. {
  199. lg_dbg("(%d)\n", mode);
  200. return lgdt3305_set_reg_bit(state, LGDT3305_TP_CTRL_1, 5, mode);
  201. }
  202. static int lgdt3305_mpeg_mode_polarity(struct lgdt3305_state *state)
  203. {
  204. u8 val;
  205. int ret;
  206. enum lgdt3305_tp_clock_edge edge = state->cfg->tpclk_edge;
  207. enum lgdt3305_tp_clock_mode mode = state->cfg->tpclk_mode;
  208. enum lgdt3305_tp_valid_polarity valid = state->cfg->tpvalid_polarity;
  209. lg_dbg("edge = %d, valid = %d\n", edge, valid);
  210. ret = lgdt3305_read_reg(state, LGDT3305_TP_CTRL_1, &val);
  211. if (lg_fail(ret))
  212. goto fail;
  213. val &= ~0x09;
  214. if (edge)
  215. val |= 0x08;
  216. if (mode)
  217. val |= 0x40;
  218. if (valid)
  219. val |= 0x01;
  220. ret = lgdt3305_write_reg(state, LGDT3305_TP_CTRL_1, val);
  221. if (lg_fail(ret))
  222. goto fail;
  223. ret = lgdt3305_soft_reset(state);
  224. fail:
  225. return ret;
  226. }
  227. static int lgdt3305_set_modulation(struct lgdt3305_state *state,
  228. struct dtv_frontend_properties *p)
  229. {
  230. u8 opermode;
  231. int ret;
  232. lg_dbg("\n");
  233. ret = lgdt3305_read_reg(state, LGDT3305_GEN_CTRL_1, &opermode);
  234. if (lg_fail(ret))
  235. goto fail;
  236. opermode &= ~0x03;
  237. switch (p->modulation) {
  238. case VSB_8:
  239. opermode |= 0x03;
  240. break;
  241. case QAM_64:
  242. opermode |= 0x00;
  243. break;
  244. case QAM_256:
  245. opermode |= 0x01;
  246. break;
  247. default:
  248. return -EINVAL;
  249. }
  250. ret = lgdt3305_write_reg(state, LGDT3305_GEN_CTRL_1, opermode);
  251. fail:
  252. return ret;
  253. }
  254. static int lgdt3305_set_filter_extension(struct lgdt3305_state *state,
  255. struct dtv_frontend_properties *p)
  256. {
  257. int val;
  258. switch (p->modulation) {
  259. case VSB_8:
  260. val = 0;
  261. break;
  262. case QAM_64:
  263. case QAM_256:
  264. val = 1;
  265. break;
  266. default:
  267. return -EINVAL;
  268. }
  269. lg_dbg("val = %d\n", val);
  270. return lgdt3305_set_reg_bit(state, 0x043f, 2, val);
  271. }
  272. /* ------------------------------------------------------------------------ */
  273. static int lgdt3305_passband_digital_agc(struct lgdt3305_state *state,
  274. struct dtv_frontend_properties *p)
  275. {
  276. u16 agc_ref;
  277. switch (p->modulation) {
  278. case VSB_8:
  279. agc_ref = 0x32c4;
  280. break;
  281. case QAM_64:
  282. agc_ref = 0x2a00;
  283. break;
  284. case QAM_256:
  285. agc_ref = 0x2a80;
  286. break;
  287. default:
  288. return -EINVAL;
  289. }
  290. lg_dbg("agc ref: 0x%04x\n", agc_ref);
  291. lgdt3305_write_reg(state, LGDT3305_DGTL_AGC_REF_1, agc_ref >> 8);
  292. lgdt3305_write_reg(state, LGDT3305_DGTL_AGC_REF_2, agc_ref & 0xff);
  293. return 0;
  294. }
  295. static int lgdt3305_rfagc_loop(struct lgdt3305_state *state,
  296. struct dtv_frontend_properties *p)
  297. {
  298. u16 ifbw, rfbw, agcdelay;
  299. switch (p->modulation) {
  300. case VSB_8:
  301. agcdelay = 0x04c0;
  302. rfbw = 0x8000;
  303. ifbw = 0x8000;
  304. break;
  305. case QAM_64:
  306. case QAM_256:
  307. agcdelay = 0x046b;
  308. rfbw = 0x8889;
  309. /* FIXME: investigate optimal ifbw & rfbw values for the
  310. * DT3304 and re-write this switch..case block */
  311. if (state->cfg->demod_chip == LGDT3304)
  312. ifbw = 0x6666;
  313. else /* (state->cfg->demod_chip == LGDT3305) */
  314. ifbw = 0x8888;
  315. break;
  316. default:
  317. return -EINVAL;
  318. }
  319. if (state->cfg->rf_agc_loop) {
  320. lg_dbg("agcdelay: 0x%04x, rfbw: 0x%04x\n", agcdelay, rfbw);
  321. /* rf agc loop filter bandwidth */
  322. lgdt3305_write_reg(state, LGDT3305_AGC_DELAY_PT_1,
  323. agcdelay >> 8);
  324. lgdt3305_write_reg(state, LGDT3305_AGC_DELAY_PT_2,
  325. agcdelay & 0xff);
  326. lgdt3305_write_reg(state, LGDT3305_RFAGC_LOOP_FLTR_BW_1,
  327. rfbw >> 8);
  328. lgdt3305_write_reg(state, LGDT3305_RFAGC_LOOP_FLTR_BW_2,
  329. rfbw & 0xff);
  330. } else {
  331. lg_dbg("ifbw: 0x%04x\n", ifbw);
  332. /* if agc loop filter bandwidth */
  333. lgdt3305_write_reg(state, LGDT3305_IFBW_1, ifbw >> 8);
  334. lgdt3305_write_reg(state, LGDT3305_IFBW_2, ifbw & 0xff);
  335. }
  336. return 0;
  337. }
  338. static int lgdt3305_agc_setup(struct lgdt3305_state *state,
  339. struct dtv_frontend_properties *p)
  340. {
  341. int lockdten, acqen;
  342. switch (p->modulation) {
  343. case VSB_8:
  344. lockdten = 0;
  345. acqen = 0;
  346. break;
  347. case QAM_64:
  348. case QAM_256:
  349. lockdten = 1;
  350. acqen = 1;
  351. break;
  352. default:
  353. return -EINVAL;
  354. }
  355. lg_dbg("lockdten = %d, acqen = %d\n", lockdten, acqen);
  356. /* control agc function */
  357. switch (state->cfg->demod_chip) {
  358. case LGDT3304:
  359. lgdt3305_write_reg(state, 0x0314, 0xe1 | lockdten << 1);
  360. lgdt3305_set_reg_bit(state, 0x030e, 2, acqen);
  361. break;
  362. case LGDT3305:
  363. lgdt3305_write_reg(state, LGDT3305_AGC_CTRL_4, 0xe1 | lockdten << 1);
  364. lgdt3305_set_reg_bit(state, LGDT3305_AGC_CTRL_1, 2, acqen);
  365. break;
  366. default:
  367. return -EINVAL;
  368. }
  369. return lgdt3305_rfagc_loop(state, p);
  370. }
  371. static int lgdt3305_set_agc_power_ref(struct lgdt3305_state *state,
  372. struct dtv_frontend_properties *p)
  373. {
  374. u16 usref = 0;
  375. switch (p->modulation) {
  376. case VSB_8:
  377. if (state->cfg->usref_8vsb)
  378. usref = state->cfg->usref_8vsb;
  379. break;
  380. case QAM_64:
  381. if (state->cfg->usref_qam64)
  382. usref = state->cfg->usref_qam64;
  383. break;
  384. case QAM_256:
  385. if (state->cfg->usref_qam256)
  386. usref = state->cfg->usref_qam256;
  387. break;
  388. default:
  389. return -EINVAL;
  390. }
  391. if (usref) {
  392. lg_dbg("set manual mode: 0x%04x\n", usref);
  393. lgdt3305_set_reg_bit(state, LGDT3305_AGC_CTRL_1, 3, 1);
  394. lgdt3305_write_reg(state, LGDT3305_AGC_POWER_REF_1,
  395. 0xff & (usref >> 8));
  396. lgdt3305_write_reg(state, LGDT3305_AGC_POWER_REF_2,
  397. 0xff & (usref >> 0));
  398. }
  399. return 0;
  400. }
  401. /* ------------------------------------------------------------------------ */
  402. static int lgdt3305_spectral_inversion(struct lgdt3305_state *state,
  403. struct dtv_frontend_properties *p,
  404. int inversion)
  405. {
  406. int ret;
  407. lg_dbg("(%d)\n", inversion);
  408. switch (p->modulation) {
  409. case VSB_8:
  410. ret = lgdt3305_write_reg(state, LGDT3305_CR_CTRL_7,
  411. inversion ? 0xf9 : 0x79);
  412. break;
  413. case QAM_64:
  414. case QAM_256:
  415. ret = lgdt3305_write_reg(state, LGDT3305_FEC_BLOCK_CTRL,
  416. inversion ? 0xfd : 0xff);
  417. break;
  418. default:
  419. ret = -EINVAL;
  420. }
  421. return ret;
  422. }
  423. static int lgdt3305_set_if(struct lgdt3305_state *state,
  424. struct dtv_frontend_properties *p)
  425. {
  426. u16 if_freq_khz;
  427. u8 nco1, nco2, nco3, nco4;
  428. u64 nco;
  429. switch (p->modulation) {
  430. case VSB_8:
  431. if_freq_khz = state->cfg->vsb_if_khz;
  432. break;
  433. case QAM_64:
  434. case QAM_256:
  435. if_freq_khz = state->cfg->qam_if_khz;
  436. break;
  437. default:
  438. return -EINVAL;
  439. }
  440. nco = if_freq_khz / 10;
  441. switch (p->modulation) {
  442. case VSB_8:
  443. nco <<= 24;
  444. do_div(nco, 625);
  445. break;
  446. case QAM_64:
  447. case QAM_256:
  448. nco <<= 28;
  449. do_div(nco, 625);
  450. break;
  451. default:
  452. return -EINVAL;
  453. }
  454. nco1 = (nco >> 24) & 0x3f;
  455. nco1 |= 0x40;
  456. nco2 = (nco >> 16) & 0xff;
  457. nco3 = (nco >> 8) & 0xff;
  458. nco4 = nco & 0xff;
  459. lgdt3305_write_reg(state, LGDT3305_CR_CTR_FREQ_1, nco1);
  460. lgdt3305_write_reg(state, LGDT3305_CR_CTR_FREQ_2, nco2);
  461. lgdt3305_write_reg(state, LGDT3305_CR_CTR_FREQ_3, nco3);
  462. lgdt3305_write_reg(state, LGDT3305_CR_CTR_FREQ_4, nco4);
  463. lg_dbg("%d KHz -> [%02x%02x%02x%02x]\n",
  464. if_freq_khz, nco1, nco2, nco3, nco4);
  465. return 0;
  466. }
  467. /* ------------------------------------------------------------------------ */
  468. static int lgdt3305_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
  469. {
  470. struct lgdt3305_state *state = fe->demodulator_priv;
  471. if (state->cfg->deny_i2c_rptr)
  472. return 0;
  473. lg_dbg("(%d)\n", enable);
  474. return lgdt3305_set_reg_bit(state, LGDT3305_GEN_CTRL_2, 5,
  475. enable ? 0 : 1);
  476. }
  477. static int lgdt3305_sleep(struct dvb_frontend *fe)
  478. {
  479. struct lgdt3305_state *state = fe->demodulator_priv;
  480. u8 gen_ctrl_3, gen_ctrl_4;
  481. lg_dbg("\n");
  482. gen_ctrl_3 = read_reg(state, LGDT3305_GEN_CTRL_3);
  483. gen_ctrl_4 = read_reg(state, LGDT3305_GEN_CTRL_4);
  484. /* hold in software reset while sleeping */
  485. gen_ctrl_3 &= ~0x01;
  486. /* tristate the IF-AGC pin */
  487. gen_ctrl_3 |= 0x02;
  488. /* tristate the RF-AGC pin */
  489. gen_ctrl_3 |= 0x04;
  490. /* disable vsb/qam module */
  491. gen_ctrl_4 &= ~0x01;
  492. /* disable adc module */
  493. gen_ctrl_4 &= ~0x02;
  494. lgdt3305_write_reg(state, LGDT3305_GEN_CTRL_3, gen_ctrl_3);
  495. lgdt3305_write_reg(state, LGDT3305_GEN_CTRL_4, gen_ctrl_4);
  496. return 0;
  497. }
  498. static int lgdt3305_init(struct dvb_frontend *fe)
  499. {
  500. struct lgdt3305_state *state = fe->demodulator_priv;
  501. int ret;
  502. static struct lgdt3305_reg lgdt3304_init_data[] = {
  503. { .reg = LGDT3305_GEN_CTRL_1, .val = 0x03, },
  504. { .reg = 0x000d, .val = 0x02, },
  505. { .reg = 0x000e, .val = 0x02, },
  506. { .reg = LGDT3305_DGTL_AGC_REF_1, .val = 0x32, },
  507. { .reg = LGDT3305_DGTL_AGC_REF_2, .val = 0xc4, },
  508. { .reg = LGDT3305_CR_CTR_FREQ_1, .val = 0x00, },
  509. { .reg = LGDT3305_CR_CTR_FREQ_2, .val = 0x00, },
  510. { .reg = LGDT3305_CR_CTR_FREQ_3, .val = 0x00, },
  511. { .reg = LGDT3305_CR_CTR_FREQ_4, .val = 0x00, },
  512. { .reg = LGDT3305_CR_CTRL_7, .val = 0xf9, },
  513. { .reg = 0x0112, .val = 0x17, },
  514. { .reg = 0x0113, .val = 0x15, },
  515. { .reg = 0x0114, .val = 0x18, },
  516. { .reg = 0x0115, .val = 0xff, },
  517. { .reg = 0x0116, .val = 0x3c, },
  518. { .reg = 0x0214, .val = 0x67, },
  519. { .reg = 0x0424, .val = 0x8d, },
  520. { .reg = 0x0427, .val = 0x12, },
  521. { .reg = 0x0428, .val = 0x4f, },
  522. { .reg = LGDT3305_IFBW_1, .val = 0x80, },
  523. { .reg = LGDT3305_IFBW_2, .val = 0x00, },
  524. { .reg = 0x030a, .val = 0x08, },
  525. { .reg = 0x030b, .val = 0x9b, },
  526. { .reg = 0x030d, .val = 0x00, },
  527. { .reg = 0x030e, .val = 0x1c, },
  528. { .reg = 0x0314, .val = 0xe1, },
  529. { .reg = 0x000d, .val = 0x82, },
  530. { .reg = LGDT3305_TP_CTRL_1, .val = 0x5b, },
  531. { .reg = LGDT3305_TP_CTRL_1, .val = 0x5b, },
  532. };
  533. static struct lgdt3305_reg lgdt3305_init_data[] = {
  534. { .reg = LGDT3305_GEN_CTRL_1, .val = 0x03, },
  535. { .reg = LGDT3305_GEN_CTRL_2, .val = 0xb0, },
  536. { .reg = LGDT3305_GEN_CTRL_3, .val = 0x01, },
  537. { .reg = LGDT3305_GEN_CONTROL, .val = 0x6f, },
  538. { .reg = LGDT3305_GEN_CTRL_4, .val = 0x03, },
  539. { .reg = LGDT3305_DGTL_AGC_REF_1, .val = 0x32, },
  540. { .reg = LGDT3305_DGTL_AGC_REF_2, .val = 0xc4, },
  541. { .reg = LGDT3305_CR_CTR_FREQ_1, .val = 0x00, },
  542. { .reg = LGDT3305_CR_CTR_FREQ_2, .val = 0x00, },
  543. { .reg = LGDT3305_CR_CTR_FREQ_3, .val = 0x00, },
  544. { .reg = LGDT3305_CR_CTR_FREQ_4, .val = 0x00, },
  545. { .reg = LGDT3305_CR_CTRL_7, .val = 0x79, },
  546. { .reg = LGDT3305_AGC_POWER_REF_1, .val = 0x32, },
  547. { .reg = LGDT3305_AGC_POWER_REF_2, .val = 0xc4, },
  548. { .reg = LGDT3305_AGC_DELAY_PT_1, .val = 0x0d, },
  549. { .reg = LGDT3305_AGC_DELAY_PT_2, .val = 0x30, },
  550. { .reg = LGDT3305_RFAGC_LOOP_FLTR_BW_1, .val = 0x80, },
  551. { .reg = LGDT3305_RFAGC_LOOP_FLTR_BW_2, .val = 0x00, },
  552. { .reg = LGDT3305_IFBW_1, .val = 0x80, },
  553. { .reg = LGDT3305_IFBW_2, .val = 0x00, },
  554. { .reg = LGDT3305_AGC_CTRL_1, .val = 0x30, },
  555. { .reg = LGDT3305_AGC_CTRL_4, .val = 0x61, },
  556. { .reg = LGDT3305_FEC_BLOCK_CTRL, .val = 0xff, },
  557. { .reg = LGDT3305_TP_CTRL_1, .val = 0x1b, },
  558. };
  559. lg_dbg("\n");
  560. switch (state->cfg->demod_chip) {
  561. case LGDT3304:
  562. ret = lgdt3305_write_regs(state, lgdt3304_init_data,
  563. ARRAY_SIZE(lgdt3304_init_data));
  564. break;
  565. case LGDT3305:
  566. ret = lgdt3305_write_regs(state, lgdt3305_init_data,
  567. ARRAY_SIZE(lgdt3305_init_data));
  568. break;
  569. default:
  570. ret = -EINVAL;
  571. }
  572. if (lg_fail(ret))
  573. goto fail;
  574. ret = lgdt3305_soft_reset(state);
  575. fail:
  576. return ret;
  577. }
  578. static int lgdt3304_set_parameters(struct dvb_frontend *fe)
  579. {
  580. struct dtv_frontend_properties *p = &fe->dtv_property_cache;
  581. struct lgdt3305_state *state = fe->demodulator_priv;
  582. int ret;
  583. lg_dbg("(%d, %d)\n", p->frequency, p->modulation);
  584. if (fe->ops.tuner_ops.set_params) {
  585. ret = fe->ops.tuner_ops.set_params(fe);
  586. if (fe->ops.i2c_gate_ctrl)
  587. fe->ops.i2c_gate_ctrl(fe, 0);
  588. if (lg_fail(ret))
  589. goto fail;
  590. state->current_frequency = p->frequency;
  591. }
  592. ret = lgdt3305_set_modulation(state, p);
  593. if (lg_fail(ret))
  594. goto fail;
  595. ret = lgdt3305_passband_digital_agc(state, p);
  596. if (lg_fail(ret))
  597. goto fail;
  598. ret = lgdt3305_agc_setup(state, p);
  599. if (lg_fail(ret))
  600. goto fail;
  601. /* reg 0x030d is 3304-only... seen in vsb and qam usbsnoops... */
  602. switch (p->modulation) {
  603. case VSB_8:
  604. lgdt3305_write_reg(state, 0x030d, 0x00);
  605. lgdt3305_write_reg(state, LGDT3305_CR_CTR_FREQ_1, 0x4f);
  606. lgdt3305_write_reg(state, LGDT3305_CR_CTR_FREQ_2, 0x0c);
  607. lgdt3305_write_reg(state, LGDT3305_CR_CTR_FREQ_3, 0xac);
  608. lgdt3305_write_reg(state, LGDT3305_CR_CTR_FREQ_4, 0xba);
  609. break;
  610. case QAM_64:
  611. case QAM_256:
  612. lgdt3305_write_reg(state, 0x030d, 0x14);
  613. ret = lgdt3305_set_if(state, p);
  614. if (lg_fail(ret))
  615. goto fail;
  616. break;
  617. default:
  618. return -EINVAL;
  619. }
  620. ret = lgdt3305_spectral_inversion(state, p,
  621. state->cfg->spectral_inversion
  622. ? 1 : 0);
  623. if (lg_fail(ret))
  624. goto fail;
  625. state->current_modulation = p->modulation;
  626. ret = lgdt3305_mpeg_mode(state, state->cfg->mpeg_mode);
  627. if (lg_fail(ret))
  628. goto fail;
  629. /* lgdt3305_mpeg_mode_polarity calls lgdt3305_soft_reset */
  630. ret = lgdt3305_mpeg_mode_polarity(state);
  631. fail:
  632. return ret;
  633. }
  634. static int lgdt3305_set_parameters(struct dvb_frontend *fe)
  635. {
  636. struct dtv_frontend_properties *p = &fe->dtv_property_cache;
  637. struct lgdt3305_state *state = fe->demodulator_priv;
  638. int ret;
  639. lg_dbg("(%d, %d)\n", p->frequency, p->modulation);
  640. if (fe->ops.tuner_ops.set_params) {
  641. ret = fe->ops.tuner_ops.set_params(fe);
  642. if (fe->ops.i2c_gate_ctrl)
  643. fe->ops.i2c_gate_ctrl(fe, 0);
  644. if (lg_fail(ret))
  645. goto fail;
  646. state->current_frequency = p->frequency;
  647. }
  648. ret = lgdt3305_set_modulation(state, p);
  649. if (lg_fail(ret))
  650. goto fail;
  651. ret = lgdt3305_passband_digital_agc(state, p);
  652. if (lg_fail(ret))
  653. goto fail;
  654. ret = lgdt3305_set_agc_power_ref(state, p);
  655. if (lg_fail(ret))
  656. goto fail;
  657. ret = lgdt3305_agc_setup(state, p);
  658. if (lg_fail(ret))
  659. goto fail;
  660. /* low if */
  661. ret = lgdt3305_write_reg(state, LGDT3305_GEN_CONTROL, 0x2f);
  662. if (lg_fail(ret))
  663. goto fail;
  664. ret = lgdt3305_set_reg_bit(state, LGDT3305_CR_CTR_FREQ_1, 6, 1);
  665. if (lg_fail(ret))
  666. goto fail;
  667. ret = lgdt3305_set_if(state, p);
  668. if (lg_fail(ret))
  669. goto fail;
  670. ret = lgdt3305_spectral_inversion(state, p,
  671. state->cfg->spectral_inversion
  672. ? 1 : 0);
  673. if (lg_fail(ret))
  674. goto fail;
  675. ret = lgdt3305_set_filter_extension(state, p);
  676. if (lg_fail(ret))
  677. goto fail;
  678. state->current_modulation = p->modulation;
  679. ret = lgdt3305_mpeg_mode(state, state->cfg->mpeg_mode);
  680. if (lg_fail(ret))
  681. goto fail;
  682. /* lgdt3305_mpeg_mode_polarity calls lgdt3305_soft_reset */
  683. ret = lgdt3305_mpeg_mode_polarity(state);
  684. fail:
  685. return ret;
  686. }
  687. static int lgdt3305_get_frontend(struct dvb_frontend *fe)
  688. {
  689. struct dtv_frontend_properties *p = &fe->dtv_property_cache;
  690. struct lgdt3305_state *state = fe->demodulator_priv;
  691. lg_dbg("\n");
  692. p->modulation = state->current_modulation;
  693. p->frequency = state->current_frequency;
  694. return 0;
  695. }
  696. /* ------------------------------------------------------------------------ */
  697. static int lgdt3305_read_cr_lock_status(struct lgdt3305_state *state,
  698. int *locked)
  699. {
  700. u8 val;
  701. int ret;
  702. char *cr_lock_state = "";
  703. *locked = 0;
  704. ret = lgdt3305_read_reg(state, LGDT3305_CR_LOCK_STATUS, &val);
  705. if (lg_fail(ret))
  706. goto fail;
  707. switch (state->current_modulation) {
  708. case QAM_256:
  709. case QAM_64:
  710. if (val & (1 << 1))
  711. *locked = 1;
  712. switch (val & 0x07) {
  713. case 0:
  714. cr_lock_state = "QAM UNLOCK";
  715. break;
  716. case 4:
  717. cr_lock_state = "QAM 1stLock";
  718. break;
  719. case 6:
  720. cr_lock_state = "QAM 2ndLock";
  721. break;
  722. case 7:
  723. cr_lock_state = "QAM FinalLock";
  724. break;
  725. default:
  726. cr_lock_state = "CLOCKQAM-INVALID!";
  727. break;
  728. }
  729. break;
  730. case VSB_8:
  731. if (val & (1 << 7)) {
  732. *locked = 1;
  733. cr_lock_state = "CLOCKVSB";
  734. }
  735. break;
  736. default:
  737. ret = -EINVAL;
  738. }
  739. lg_dbg("(%d) %s\n", *locked, cr_lock_state);
  740. fail:
  741. return ret;
  742. }
  743. static int lgdt3305_read_fec_lock_status(struct lgdt3305_state *state,
  744. int *locked)
  745. {
  746. u8 val;
  747. int ret, mpeg_lock, fec_lock, viterbi_lock;
  748. *locked = 0;
  749. switch (state->current_modulation) {
  750. case QAM_256:
  751. case QAM_64:
  752. ret = lgdt3305_read_reg(state,
  753. LGDT3305_FEC_LOCK_STATUS, &val);
  754. if (lg_fail(ret))
  755. goto fail;
  756. mpeg_lock = (val & (1 << 0)) ? 1 : 0;
  757. fec_lock = (val & (1 << 2)) ? 1 : 0;
  758. viterbi_lock = (val & (1 << 3)) ? 1 : 0;
  759. *locked = mpeg_lock && fec_lock && viterbi_lock;
  760. lg_dbg("(%d) %s%s%s\n", *locked,
  761. mpeg_lock ? "mpeg lock " : "",
  762. fec_lock ? "fec lock " : "",
  763. viterbi_lock ? "viterbi lock" : "");
  764. break;
  765. case VSB_8:
  766. default:
  767. ret = -EINVAL;
  768. }
  769. fail:
  770. return ret;
  771. }
  772. static int lgdt3305_read_status(struct dvb_frontend *fe, enum fe_status *status)
  773. {
  774. struct lgdt3305_state *state = fe->demodulator_priv;
  775. u8 val;
  776. int ret, signal, inlock, nofecerr, snrgood,
  777. cr_lock, fec_lock, sync_lock;
  778. *status = 0;
  779. ret = lgdt3305_read_reg(state, LGDT3305_GEN_STATUS, &val);
  780. if (lg_fail(ret))
  781. goto fail;
  782. signal = (val & (1 << 4)) ? 1 : 0;
  783. inlock = (val & (1 << 3)) ? 0 : 1;
  784. sync_lock = (val & (1 << 2)) ? 1 : 0;
  785. nofecerr = (val & (1 << 1)) ? 1 : 0;
  786. snrgood = (val & (1 << 0)) ? 1 : 0;
  787. lg_dbg("%s%s%s%s%s\n",
  788. signal ? "SIGNALEXIST " : "",
  789. inlock ? "INLOCK " : "",
  790. sync_lock ? "SYNCLOCK " : "",
  791. nofecerr ? "NOFECERR " : "",
  792. snrgood ? "SNRGOOD " : "");
  793. ret = lgdt3305_read_cr_lock_status(state, &cr_lock);
  794. if (lg_fail(ret))
  795. goto fail;
  796. if (signal)
  797. *status |= FE_HAS_SIGNAL;
  798. if (cr_lock)
  799. *status |= FE_HAS_CARRIER;
  800. if (nofecerr)
  801. *status |= FE_HAS_VITERBI;
  802. if (sync_lock)
  803. *status |= FE_HAS_SYNC;
  804. switch (state->current_modulation) {
  805. case QAM_256:
  806. case QAM_64:
  807. /* signal bit is unreliable on the DT3304 in QAM mode */
  808. if (((LGDT3304 == state->cfg->demod_chip)) && (cr_lock))
  809. *status |= FE_HAS_SIGNAL;
  810. ret = lgdt3305_read_fec_lock_status(state, &fec_lock);
  811. if (lg_fail(ret))
  812. goto fail;
  813. if (fec_lock)
  814. *status |= FE_HAS_LOCK;
  815. break;
  816. case VSB_8:
  817. if (inlock)
  818. *status |= FE_HAS_LOCK;
  819. break;
  820. default:
  821. ret = -EINVAL;
  822. }
  823. fail:
  824. return ret;
  825. }
  826. /* ------------------------------------------------------------------------ */
  827. /* borrowed from lgdt330x.c */
  828. static u32 calculate_snr(u32 mse, u32 c)
  829. {
  830. if (mse == 0) /* no signal */
  831. return 0;
  832. mse = intlog10(mse);
  833. if (mse > c) {
  834. /* Negative SNR, which is possible, but realisticly the
  835. demod will lose lock before the signal gets this bad. The
  836. API only allows for unsigned values, so just return 0 */
  837. return 0;
  838. }
  839. return 10*(c - mse);
  840. }
  841. static int lgdt3305_read_snr(struct dvb_frontend *fe, u16 *snr)
  842. {
  843. struct lgdt3305_state *state = fe->demodulator_priv;
  844. u32 noise; /* noise value */
  845. u32 c; /* per-modulation SNR calculation constant */
  846. switch (state->current_modulation) {
  847. case VSB_8:
  848. #ifdef USE_PTMSE
  849. /* Use Phase Tracker Mean-Square Error Register */
  850. /* SNR for ranges from -13.11 to +44.08 */
  851. noise = ((read_reg(state, LGDT3305_PT_MSE_1) & 0x07) << 16) |
  852. (read_reg(state, LGDT3305_PT_MSE_2) << 8) |
  853. (read_reg(state, LGDT3305_PT_MSE_3) & 0xff);
  854. c = 73957994; /* log10(25*32^2)*2^24 */
  855. #else
  856. /* Use Equalizer Mean-Square Error Register */
  857. /* SNR for ranges from -16.12 to +44.08 */
  858. noise = ((read_reg(state, LGDT3305_EQ_MSE_1) & 0x0f) << 16) |
  859. (read_reg(state, LGDT3305_EQ_MSE_2) << 8) |
  860. (read_reg(state, LGDT3305_EQ_MSE_3) & 0xff);
  861. c = 73957994; /* log10(25*32^2)*2^24 */
  862. #endif
  863. break;
  864. case QAM_64:
  865. case QAM_256:
  866. noise = (read_reg(state, LGDT3305_CR_MSE_1) << 8) |
  867. (read_reg(state, LGDT3305_CR_MSE_2) & 0xff);
  868. c = (state->current_modulation == QAM_64) ?
  869. 97939837 : 98026066;
  870. /* log10(688128)*2^24 and log10(696320)*2^24 */
  871. break;
  872. default:
  873. return -EINVAL;
  874. }
  875. state->snr = calculate_snr(noise, c);
  876. /* report SNR in dB * 10 */
  877. *snr = (state->snr / ((1 << 24) / 10));
  878. lg_dbg("noise = 0x%08x, snr = %d.%02d dB\n", noise,
  879. state->snr >> 24, (((state->snr >> 8) & 0xffff) * 100) >> 16);
  880. return 0;
  881. }
  882. static int lgdt3305_read_signal_strength(struct dvb_frontend *fe,
  883. u16 *strength)
  884. {
  885. /* borrowed from lgdt330x.c
  886. *
  887. * Calculate strength from SNR up to 35dB
  888. * Even though the SNR can go higher than 35dB,
  889. * there is some comfort factor in having a range of
  890. * strong signals that can show at 100%
  891. */
  892. struct lgdt3305_state *state = fe->demodulator_priv;
  893. u16 snr;
  894. int ret;
  895. *strength = 0;
  896. ret = fe->ops.read_snr(fe, &snr);
  897. if (lg_fail(ret))
  898. goto fail;
  899. /* Rather than use the 8.8 value snr, use state->snr which is 8.24 */
  900. /* scale the range 0 - 35*2^24 into 0 - 65535 */
  901. if (state->snr >= 8960 * 0x10000)
  902. *strength = 0xffff;
  903. else
  904. *strength = state->snr / 8960;
  905. fail:
  906. return ret;
  907. }
  908. /* ------------------------------------------------------------------------ */
  909. static int lgdt3305_read_ber(struct dvb_frontend *fe, u32 *ber)
  910. {
  911. *ber = 0;
  912. return 0;
  913. }
  914. static int lgdt3305_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
  915. {
  916. struct lgdt3305_state *state = fe->demodulator_priv;
  917. *ucblocks =
  918. (read_reg(state, LGDT3305_FEC_PKT_ERR_1) << 8) |
  919. (read_reg(state, LGDT3305_FEC_PKT_ERR_2) & 0xff);
  920. return 0;
  921. }
  922. static int lgdt3305_get_tune_settings(struct dvb_frontend *fe,
  923. struct dvb_frontend_tune_settings
  924. *fe_tune_settings)
  925. {
  926. fe_tune_settings->min_delay_ms = 500;
  927. lg_dbg("\n");
  928. return 0;
  929. }
  930. static void lgdt3305_release(struct dvb_frontend *fe)
  931. {
  932. struct lgdt3305_state *state = fe->demodulator_priv;
  933. lg_dbg("\n");
  934. kfree(state);
  935. }
  936. static struct dvb_frontend_ops lgdt3304_ops;
  937. static struct dvb_frontend_ops lgdt3305_ops;
  938. struct dvb_frontend *lgdt3305_attach(const struct lgdt3305_config *config,
  939. struct i2c_adapter *i2c_adap)
  940. {
  941. struct lgdt3305_state *state = NULL;
  942. int ret;
  943. u8 val;
  944. lg_dbg("(%d-%04x)\n",
  945. i2c_adap ? i2c_adapter_id(i2c_adap) : 0,
  946. config ? config->i2c_addr : 0);
  947. state = kzalloc(sizeof(struct lgdt3305_state), GFP_KERNEL);
  948. if (state == NULL)
  949. goto fail;
  950. state->cfg = config;
  951. state->i2c_adap = i2c_adap;
  952. switch (config->demod_chip) {
  953. case LGDT3304:
  954. memcpy(&state->frontend.ops, &lgdt3304_ops,
  955. sizeof(struct dvb_frontend_ops));
  956. break;
  957. case LGDT3305:
  958. memcpy(&state->frontend.ops, &lgdt3305_ops,
  959. sizeof(struct dvb_frontend_ops));
  960. break;
  961. default:
  962. goto fail;
  963. }
  964. state->frontend.demodulator_priv = state;
  965. /* verify that we're talking to a lg dt3304/5 */
  966. ret = lgdt3305_read_reg(state, LGDT3305_GEN_CTRL_2, &val);
  967. if ((lg_fail(ret)) | (val == 0))
  968. goto fail;
  969. ret = lgdt3305_write_reg(state, 0x0808, 0x80);
  970. if (lg_fail(ret))
  971. goto fail;
  972. ret = lgdt3305_read_reg(state, 0x0808, &val);
  973. if ((lg_fail(ret)) | (val != 0x80))
  974. goto fail;
  975. ret = lgdt3305_write_reg(state, 0x0808, 0x00);
  976. if (lg_fail(ret))
  977. goto fail;
  978. state->current_frequency = -1;
  979. state->current_modulation = -1;
  980. return &state->frontend;
  981. fail:
  982. lg_warn("unable to detect %s hardware\n",
  983. config->demod_chip ? "LGDT3304" : "LGDT3305");
  984. kfree(state);
  985. return NULL;
  986. }
  987. EXPORT_SYMBOL(lgdt3305_attach);
  988. static struct dvb_frontend_ops lgdt3304_ops = {
  989. .delsys = { SYS_ATSC, SYS_DVBC_ANNEX_B },
  990. .info = {
  991. .name = "LG Electronics LGDT3304 VSB/QAM Frontend",
  992. .frequency_min = 54000000,
  993. .frequency_max = 858000000,
  994. .frequency_stepsize = 62500,
  995. .caps = FE_CAN_QAM_64 | FE_CAN_QAM_256 | FE_CAN_8VSB
  996. },
  997. .i2c_gate_ctrl = lgdt3305_i2c_gate_ctrl,
  998. .init = lgdt3305_init,
  999. .sleep = lgdt3305_sleep,
  1000. .set_frontend = lgdt3304_set_parameters,
  1001. .get_frontend = lgdt3305_get_frontend,
  1002. .get_tune_settings = lgdt3305_get_tune_settings,
  1003. .read_status = lgdt3305_read_status,
  1004. .read_ber = lgdt3305_read_ber,
  1005. .read_signal_strength = lgdt3305_read_signal_strength,
  1006. .read_snr = lgdt3305_read_snr,
  1007. .read_ucblocks = lgdt3305_read_ucblocks,
  1008. .release = lgdt3305_release,
  1009. };
  1010. static struct dvb_frontend_ops lgdt3305_ops = {
  1011. .delsys = { SYS_ATSC, SYS_DVBC_ANNEX_B },
  1012. .info = {
  1013. .name = "LG Electronics LGDT3305 VSB/QAM Frontend",
  1014. .frequency_min = 54000000,
  1015. .frequency_max = 858000000,
  1016. .frequency_stepsize = 62500,
  1017. .caps = FE_CAN_QAM_64 | FE_CAN_QAM_256 | FE_CAN_8VSB
  1018. },
  1019. .i2c_gate_ctrl = lgdt3305_i2c_gate_ctrl,
  1020. .init = lgdt3305_init,
  1021. .sleep = lgdt3305_sleep,
  1022. .set_frontend = lgdt3305_set_parameters,
  1023. .get_frontend = lgdt3305_get_frontend,
  1024. .get_tune_settings = lgdt3305_get_tune_settings,
  1025. .read_status = lgdt3305_read_status,
  1026. .read_ber = lgdt3305_read_ber,
  1027. .read_signal_strength = lgdt3305_read_signal_strength,
  1028. .read_snr = lgdt3305_read_snr,
  1029. .read_ucblocks = lgdt3305_read_ucblocks,
  1030. .release = lgdt3305_release,
  1031. };
  1032. MODULE_DESCRIPTION("LG Electronics LGDT3304/5 ATSC/QAM-B Demodulator Driver");
  1033. MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>");
  1034. MODULE_LICENSE("GPL");
  1035. MODULE_VERSION("0.2");