s5h1409.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  1. /*
  2. Samsung S5H1409 VSB/QAM demodulator driver
  3. Copyright (C) 2006 Steven Toth <stoth@hauppauge.com>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. */
  16. #include <linux/kernel.h>
  17. #include <linux/init.h>
  18. #include <linux/module.h>
  19. #include <linux/string.h>
  20. #include <linux/slab.h>
  21. #include <linux/delay.h>
  22. #include "dvb_frontend.h"
  23. #include "dvb-pll.h"
  24. #include "s5h1409.h"
  25. struct s5h1409_state {
  26. struct i2c_adapter* i2c;
  27. /* configuration settings */
  28. const struct s5h1409_config* config;
  29. struct dvb_frontend frontend;
  30. /* previous uncorrected block counter */
  31. fe_modulation_t current_modulation;
  32. u32 current_frequency;
  33. };
  34. static int debug = 0;
  35. #define dprintk if (debug) printk
  36. /* Register values to initialise the demod, this will set VSB by default */
  37. static struct init_tab {
  38. u8 reg;
  39. u16 data;
  40. } init_tab[] = {
  41. { 0x00, 0x0071, },
  42. { 0x01, 0x3213, },
  43. { 0x09, 0x0025, },
  44. { 0x1c, 0x001d, },
  45. { 0x1f, 0x002d, },
  46. { 0x20, 0x001d, },
  47. { 0x22, 0x0022, },
  48. { 0x23, 0x0020, },
  49. { 0x29, 0x110f, },
  50. { 0x2a, 0x10b4, },
  51. { 0x2b, 0x10ae, },
  52. { 0x2c, 0x0031, },
  53. { 0x31, 0x010d, },
  54. { 0x32, 0x0100, },
  55. { 0x44, 0x0510, },
  56. { 0x54, 0x0104, },
  57. { 0x58, 0x2222, },
  58. { 0x59, 0x1162, },
  59. { 0x5a, 0x3211, },
  60. { 0x5d, 0x0370, },
  61. { 0x5e, 0x0296, },
  62. { 0x61, 0x0010, },
  63. { 0x63, 0x4a00, },
  64. { 0x65, 0x0800, },
  65. { 0x71, 0x0003, },
  66. { 0x72, 0x0470, },
  67. { 0x81, 0x0002, },
  68. { 0x82, 0x0600, },
  69. { 0x86, 0x0002, },
  70. { 0x8a, 0x2c38, },
  71. { 0x8b, 0x2a37, },
  72. { 0x92, 0x302f, },
  73. { 0x93, 0x3332, },
  74. { 0x96, 0x000c, },
  75. { 0x99, 0x0101, },
  76. { 0x9c, 0x2e37, },
  77. { 0x9d, 0x2c37, },
  78. { 0x9e, 0x2c37, },
  79. { 0xab, 0x0100, },
  80. { 0xac, 0x1003, },
  81. { 0xad, 0x103f, },
  82. { 0xe2, 0x0100, },
  83. { 0x28, 0x1010, },
  84. { 0xb1, 0x000e, },
  85. };
  86. /* VSB SNR lookup table */
  87. static struct vsb_snr_tab {
  88. u16 val;
  89. u16 data;
  90. } vsb_snr_tab[] = {
  91. { 1023, 770, },
  92. { 923, 300, },
  93. { 918, 295, },
  94. { 915, 290, },
  95. { 911, 285, },
  96. { 906, 280, },
  97. { 901, 275, },
  98. { 896, 270, },
  99. { 891, 265, },
  100. { 885, 260, },
  101. { 879, 255, },
  102. { 873, 250, },
  103. { 864, 245, },
  104. { 858, 240, },
  105. { 850, 235, },
  106. { 841, 230, },
  107. { 832, 225, },
  108. { 823, 220, },
  109. { 812, 215, },
  110. { 802, 210, },
  111. { 788, 205, },
  112. { 778, 200, },
  113. { 767, 195, },
  114. { 753, 190, },
  115. { 740, 185, },
  116. { 725, 180, },
  117. { 707, 175, },
  118. { 689, 170, },
  119. { 671, 165, },
  120. { 656, 160, },
  121. { 637, 155, },
  122. { 616, 150, },
  123. { 542, 145, },
  124. { 519, 140, },
  125. { 507, 135, },
  126. { 497, 130, },
  127. { 492, 125, },
  128. { 474, 120, },
  129. { 300, 111, },
  130. { 0, 0, },
  131. };
  132. /* QAM64 SNR lookup table */
  133. static struct qam64_snr_tab {
  134. u16 val;
  135. u16 data;
  136. } qam64_snr_tab[] = {
  137. { 12, 300, },
  138. { 15, 290, },
  139. { 18, 280, },
  140. { 22, 270, },
  141. { 23, 268, },
  142. { 24, 266, },
  143. { 25, 264, },
  144. { 27, 262, },
  145. { 28, 260, },
  146. { 29, 258, },
  147. { 30, 256, },
  148. { 32, 254, },
  149. { 33, 252, },
  150. { 34, 250, },
  151. { 35, 249, },
  152. { 36, 248, },
  153. { 37, 247, },
  154. { 38, 246, },
  155. { 39, 245, },
  156. { 40, 244, },
  157. { 41, 243, },
  158. { 42, 241, },
  159. { 43, 240, },
  160. { 44, 239, },
  161. { 45, 238, },
  162. { 46, 237, },
  163. { 47, 236, },
  164. { 48, 235, },
  165. { 49, 234, },
  166. { 50, 233, },
  167. { 51, 232, },
  168. { 52, 231, },
  169. { 53, 230, },
  170. { 55, 229, },
  171. { 56, 228, },
  172. { 57, 227, },
  173. { 58, 226, },
  174. { 59, 225, },
  175. { 60, 224, },
  176. { 62, 223, },
  177. { 63, 222, },
  178. { 65, 221, },
  179. { 66, 220, },
  180. { 68, 219, },
  181. { 69, 218, },
  182. { 70, 217, },
  183. { 72, 216, },
  184. { 73, 215, },
  185. { 75, 214, },
  186. { 76, 213, },
  187. { 78, 212, },
  188. { 80, 211, },
  189. { 81, 210, },
  190. { 83, 209, },
  191. { 84, 208, },
  192. { 85, 207, },
  193. { 87, 206, },
  194. { 89, 205, },
  195. { 91, 204, },
  196. { 93, 203, },
  197. { 95, 202, },
  198. { 96, 201, },
  199. { 104, 200, },
  200. };
  201. /* QAM256 SNR lookup table */
  202. static struct qam256_snr_tab {
  203. u16 val;
  204. u16 data;
  205. } qam256_snr_tab[] = {
  206. { 12, 400, },
  207. { 13, 390, },
  208. { 15, 380, },
  209. { 17, 360, },
  210. { 19, 350, },
  211. { 22, 348, },
  212. { 23, 346, },
  213. { 24, 344, },
  214. { 25, 342, },
  215. { 26, 340, },
  216. { 27, 336, },
  217. { 28, 334, },
  218. { 29, 332, },
  219. { 30, 330, },
  220. { 31, 328, },
  221. { 32, 326, },
  222. { 33, 325, },
  223. { 34, 322, },
  224. { 35, 320, },
  225. { 37, 318, },
  226. { 39, 316, },
  227. { 40, 314, },
  228. { 41, 312, },
  229. { 42, 310, },
  230. { 43, 308, },
  231. { 46, 306, },
  232. { 47, 304, },
  233. { 49, 302, },
  234. { 51, 300, },
  235. { 53, 298, },
  236. { 54, 297, },
  237. { 55, 296, },
  238. { 56, 295, },
  239. { 57, 294, },
  240. { 59, 293, },
  241. { 60, 292, },
  242. { 61, 291, },
  243. { 63, 290, },
  244. { 64, 289, },
  245. { 65, 288, },
  246. { 66, 287, },
  247. { 68, 286, },
  248. { 69, 285, },
  249. { 71, 284, },
  250. { 72, 283, },
  251. { 74, 282, },
  252. { 75, 281, },
  253. { 76, 280, },
  254. { 77, 279, },
  255. { 78, 278, },
  256. { 81, 277, },
  257. { 83, 276, },
  258. { 84, 275, },
  259. { 86, 274, },
  260. { 87, 273, },
  261. { 89, 272, },
  262. { 90, 271, },
  263. { 92, 270, },
  264. { 93, 269, },
  265. { 95, 268, },
  266. { 96, 267, },
  267. { 98, 266, },
  268. { 100, 265, },
  269. { 102, 264, },
  270. { 104, 263, },
  271. { 105, 262, },
  272. { 106, 261, },
  273. { 110, 260, },
  274. };
  275. /* 8 bit registers, 16 bit values */
  276. static int s5h1409_writereg(struct s5h1409_state* state, u8 reg, u16 data)
  277. {
  278. int ret;
  279. u8 buf [] = { reg, data >> 8, data & 0xff };
  280. struct i2c_msg msg = { .addr = state->config->demod_address,
  281. .flags = 0, .buf = buf, .len = 3 };
  282. ret = i2c_transfer(state->i2c, &msg, 1);
  283. if (ret != 1)
  284. printk("%s: writereg error (reg == 0x%02x, val == 0x%04x, "
  285. "ret == %i)\n", __FUNCTION__, reg, data, ret);
  286. return (ret != 1) ? -1 : 0;
  287. }
  288. static u16 s5h1409_readreg(struct s5h1409_state* state, u8 reg)
  289. {
  290. int ret;
  291. u8 b0 [] = { reg };
  292. u8 b1 [] = { 0, 0 };
  293. struct i2c_msg msg [] = {
  294. { .addr = state->config->demod_address, .flags = 0,
  295. .buf = b0, .len = 1 },
  296. { .addr = state->config->demod_address, .flags = I2C_M_RD,
  297. .buf = b1, .len = 2 } };
  298. ret = i2c_transfer(state->i2c, msg, 2);
  299. if (ret != 2)
  300. printk("%s: readreg error (ret == %i)\n", __FUNCTION__, ret);
  301. return (b1[0] << 8) | b1[1];
  302. }
  303. static int s5h1409_softreset(struct dvb_frontend* fe)
  304. {
  305. struct s5h1409_state* state = fe->demodulator_priv;
  306. dprintk("%s()\n", __FUNCTION__);
  307. s5h1409_writereg(state, 0xf5, 0);
  308. s5h1409_writereg(state, 0xf5, 1);
  309. return 0;
  310. }
  311. static int s5h1409_set_if_freq(struct dvb_frontend* fe, int KHz)
  312. {
  313. struct s5h1409_state* state = fe->demodulator_priv;
  314. int ret = 0;
  315. dprintk("%s(%d KHz)\n", __FUNCTION__, KHz);
  316. if( (KHz == 44000) || (KHz == 5380) ) {
  317. s5h1409_writereg(state, 0x87, 0x01be);
  318. s5h1409_writereg(state, 0x88, 0x0436);
  319. s5h1409_writereg(state, 0x89, 0x054d);
  320. } else {
  321. printk("%s() Invalid arg = %d KHz\n", __FUNCTION__, KHz);
  322. ret = -1;
  323. }
  324. return ret;
  325. }
  326. static int s5h1409_set_spectralinversion(struct dvb_frontend* fe, int inverted)
  327. {
  328. struct s5h1409_state* state = fe->demodulator_priv;
  329. dprintk("%s()\n", __FUNCTION__);
  330. if(inverted == 1)
  331. return s5h1409_writereg(state, 0x1b, 0x1101); /* Inverted */
  332. else
  333. return s5h1409_writereg(state, 0x1b, 0x0110); /* Normal */
  334. }
  335. static int s5h1409_enable_modulation(struct dvb_frontend* fe,
  336. fe_modulation_t m)
  337. {
  338. struct s5h1409_state* state = fe->demodulator_priv;
  339. dprintk("%s(0x%08x)\n", __FUNCTION__, m);
  340. switch(m) {
  341. case VSB_8:
  342. dprintk("%s() VSB_8\n", __FUNCTION__);
  343. s5h1409_writereg(state, 0xf4, 0);
  344. break;
  345. case QAM_64:
  346. dprintk("%s() QAM_64\n", __FUNCTION__);
  347. s5h1409_writereg(state, 0xf4, 1);
  348. s5h1409_writereg(state, 0x85, 0x100);
  349. break;
  350. case QAM_256:
  351. dprintk("%s() QAM_256\n", __FUNCTION__);
  352. s5h1409_writereg(state, 0xf4, 1);
  353. s5h1409_writereg(state, 0x85, 0x101);
  354. break;
  355. default:
  356. dprintk("%s() Invalid modulation\n", __FUNCTION__);
  357. return -EINVAL;
  358. }
  359. state->current_modulation = m;
  360. s5h1409_softreset(fe);
  361. return 0;
  362. }
  363. static int s5h1409_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)
  364. {
  365. struct s5h1409_state* state = fe->demodulator_priv;
  366. dprintk("%s(%d)\n", __FUNCTION__, enable);
  367. if (enable)
  368. return s5h1409_writereg(state, 0xf3, 1);
  369. else
  370. return s5h1409_writereg(state, 0xf3, 0);
  371. }
  372. static int s5h1409_set_gpio(struct dvb_frontend* fe, int enable)
  373. {
  374. struct s5h1409_state* state = fe->demodulator_priv;
  375. dprintk("%s(%d)\n", __FUNCTION__, enable);
  376. if (enable)
  377. return s5h1409_writereg(state, 0xe3, 0x1100);
  378. else
  379. return s5h1409_writereg(state, 0xe3, 0);
  380. }
  381. static int s5h1409_sleep(struct dvb_frontend* fe, int enable)
  382. {
  383. struct s5h1409_state* state = fe->demodulator_priv;
  384. dprintk("%s(%d)\n", __FUNCTION__, enable);
  385. return s5h1409_writereg(state, 0xf2, enable);
  386. }
  387. static int s5h1409_register_reset(struct dvb_frontend* fe)
  388. {
  389. struct s5h1409_state* state = fe->demodulator_priv;
  390. dprintk("%s()\n", __FUNCTION__);
  391. return s5h1409_writereg(state, 0xfa, 0);
  392. }
  393. /* Talk to the demod, set the FEC, GUARD, QAM settings etc */
  394. static int s5h1409_set_frontend (struct dvb_frontend* fe,
  395. struct dvb_frontend_parameters *p)
  396. {
  397. struct s5h1409_state* state = fe->demodulator_priv;
  398. dprintk("%s(frequency=%d)\n", __FUNCTION__, p->frequency);
  399. s5h1409_softreset(fe);
  400. state->current_frequency = p->frequency;
  401. s5h1409_enable_modulation(fe, p->u.vsb.modulation);
  402. if (fe->ops.tuner_ops.set_params) {
  403. if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 1);
  404. fe->ops.tuner_ops.set_params(fe, p);
  405. if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
  406. }
  407. return 0;
  408. }
  409. /* Reset the demod hardware and reset all of the configuration registers
  410. to a default state. */
  411. static int s5h1409_init (struct dvb_frontend* fe)
  412. {
  413. int i;
  414. struct s5h1409_state* state = fe->demodulator_priv;
  415. dprintk("%s()\n", __FUNCTION__);
  416. s5h1409_sleep(fe, 0);
  417. s5h1409_register_reset(fe);
  418. for (i=0; i < ARRAY_SIZE(init_tab); i++)
  419. s5h1409_writereg(state, init_tab[i].reg, init_tab[i].data);
  420. /* The datasheet says that after initialisation, VSB is default */
  421. state->current_modulation = VSB_8;
  422. if (state->config->output_mode == S5H1409_SERIAL_OUTPUT)
  423. s5h1409_writereg(state, 0xab, 0x100); /* Serial */
  424. else
  425. s5h1409_writereg(state, 0xab, 0x0); /* Parallel */
  426. s5h1409_set_spectralinversion(fe, state->config->inversion);
  427. s5h1409_set_if_freq(fe, state->config->if_freq);
  428. s5h1409_set_gpio(fe, state->config->gpio);
  429. s5h1409_softreset(fe);
  430. /* Note: Leaving the I2C gate open here. */
  431. s5h1409_i2c_gate_ctrl(fe, 1);
  432. return 0;
  433. }
  434. static int s5h1409_read_status(struct dvb_frontend* fe, fe_status_t* status)
  435. {
  436. struct s5h1409_state* state = fe->demodulator_priv;
  437. u16 reg;
  438. u32 tuner_status = 0;
  439. *status = 0;
  440. /* Get the demodulator status */
  441. reg = s5h1409_readreg(state, 0xf1);
  442. if(reg & 0x1000)
  443. *status |= FE_HAS_VITERBI;
  444. if(reg & 0x8000)
  445. *status |= FE_HAS_LOCK | FE_HAS_SYNC;
  446. switch(state->config->status_mode) {
  447. case S5H1409_DEMODLOCKING:
  448. if (*status & FE_HAS_VITERBI)
  449. *status |= FE_HAS_CARRIER | FE_HAS_SIGNAL;
  450. break;
  451. case S5H1409_TUNERLOCKING:
  452. /* Get the tuner status */
  453. if (fe->ops.tuner_ops.get_status) {
  454. if (fe->ops.i2c_gate_ctrl)
  455. fe->ops.i2c_gate_ctrl(fe, 1);
  456. fe->ops.tuner_ops.get_status(fe, &tuner_status);
  457. if (fe->ops.i2c_gate_ctrl)
  458. fe->ops.i2c_gate_ctrl(fe, 0);
  459. }
  460. if (tuner_status)
  461. *status |= FE_HAS_CARRIER | FE_HAS_SIGNAL;
  462. break;
  463. }
  464. dprintk("%s() status 0x%08x\n", __FUNCTION__, *status);
  465. return 0;
  466. }
  467. static int s5h1409_qam256_lookup_snr(struct dvb_frontend* fe, u16* snr, u16 v)
  468. {
  469. int i, ret = -EINVAL;
  470. dprintk("%s()\n", __FUNCTION__);
  471. for (i=0; i < ARRAY_SIZE(qam256_snr_tab); i++) {
  472. if (v < qam256_snr_tab[i].val) {
  473. *snr = qam256_snr_tab[i].data;
  474. ret = 0;
  475. break;
  476. }
  477. }
  478. return ret;
  479. }
  480. static int s5h1409_qam64_lookup_snr(struct dvb_frontend* fe, u16* snr, u16 v)
  481. {
  482. int i, ret = -EINVAL;
  483. dprintk("%s()\n", __FUNCTION__);
  484. for (i=0; i < ARRAY_SIZE(qam64_snr_tab); i++) {
  485. if (v < qam64_snr_tab[i].val) {
  486. *snr = qam64_snr_tab[i].data;
  487. ret = 0;
  488. break;
  489. }
  490. }
  491. return ret;
  492. }
  493. static int s5h1409_vsb_lookup_snr(struct dvb_frontend* fe, u16* snr, u16 v)
  494. {
  495. int i, ret = -EINVAL;
  496. dprintk("%s()\n", __FUNCTION__);
  497. for (i=0; i < ARRAY_SIZE(vsb_snr_tab); i++) {
  498. if (v > vsb_snr_tab[i].val) {
  499. *snr = vsb_snr_tab[i].data;
  500. ret = 0;
  501. break;
  502. }
  503. }
  504. dprintk("%s() snr=%d\n", __FUNCTION__, *snr);
  505. return ret;
  506. }
  507. static int s5h1409_read_snr(struct dvb_frontend* fe, u16* snr)
  508. {
  509. struct s5h1409_state* state = fe->demodulator_priv;
  510. u16 reg;
  511. dprintk("%s()\n", __FUNCTION__);
  512. reg = s5h1409_readreg(state, 0xf1) & 0x1ff;
  513. switch(state->current_modulation) {
  514. case QAM_64:
  515. return s5h1409_qam64_lookup_snr(fe, snr, reg);
  516. case QAM_256:
  517. return s5h1409_qam256_lookup_snr(fe, snr, reg);
  518. case VSB_8:
  519. return s5h1409_vsb_lookup_snr(fe, snr, reg);
  520. default:
  521. break;
  522. }
  523. return -EINVAL;
  524. }
  525. static int s5h1409_read_signal_strength(struct dvb_frontend* fe,
  526. u16* signal_strength)
  527. {
  528. return s5h1409_read_snr(fe, signal_strength);
  529. }
  530. static int s5h1409_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
  531. {
  532. struct s5h1409_state* state = fe->demodulator_priv;
  533. *ucblocks = s5h1409_readreg(state, 0xb5);
  534. return 0;
  535. }
  536. static int s5h1409_read_ber(struct dvb_frontend* fe, u32* ber)
  537. {
  538. return s5h1409_read_ucblocks(fe, ber);
  539. }
  540. static int s5h1409_get_frontend(struct dvb_frontend* fe,
  541. struct dvb_frontend_parameters *p)
  542. {
  543. struct s5h1409_state* state = fe->demodulator_priv;
  544. p->frequency = state->current_frequency;
  545. p->u.vsb.modulation = state->current_modulation;
  546. return 0;
  547. }
  548. static int s5h1409_get_tune_settings(struct dvb_frontend* fe,
  549. struct dvb_frontend_tune_settings *tune)
  550. {
  551. tune->min_delay_ms = 1000;
  552. return 0;
  553. }
  554. static void s5h1409_release(struct dvb_frontend* fe)
  555. {
  556. struct s5h1409_state* state = fe->demodulator_priv;
  557. kfree(state);
  558. }
  559. static struct dvb_frontend_ops s5h1409_ops;
  560. struct dvb_frontend* s5h1409_attach(const struct s5h1409_config* config,
  561. struct i2c_adapter* i2c)
  562. {
  563. struct s5h1409_state* state = NULL;
  564. /* allocate memory for the internal state */
  565. state = kmalloc(sizeof(struct s5h1409_state), GFP_KERNEL);
  566. if (state == NULL)
  567. goto error;
  568. /* setup the state */
  569. state->config = config;
  570. state->i2c = i2c;
  571. state->current_modulation = 0;
  572. /* check if the demod exists */
  573. if (s5h1409_readreg(state, 0x04) != 0x0066)
  574. goto error;
  575. /* create dvb_frontend */
  576. memcpy(&state->frontend.ops, &s5h1409_ops,
  577. sizeof(struct dvb_frontend_ops));
  578. state->frontend.demodulator_priv = state;
  579. /* Note: Leaving the I2C gate open here. */
  580. s5h1409_writereg(state, 0xf3, 1);
  581. return &state->frontend;
  582. error:
  583. kfree(state);
  584. return NULL;
  585. }
  586. static struct dvb_frontend_ops s5h1409_ops = {
  587. .info = {
  588. .name = "Samsung S5H1409 QAM/8VSB Frontend",
  589. .type = FE_ATSC,
  590. .frequency_min = 54000000,
  591. .frequency_max = 858000000,
  592. .frequency_stepsize = 62500,
  593. .caps = FE_CAN_QAM_64 | FE_CAN_QAM_256 | FE_CAN_8VSB
  594. },
  595. .init = s5h1409_init,
  596. .i2c_gate_ctrl = s5h1409_i2c_gate_ctrl,
  597. .set_frontend = s5h1409_set_frontend,
  598. .get_frontend = s5h1409_get_frontend,
  599. .get_tune_settings = s5h1409_get_tune_settings,
  600. .read_status = s5h1409_read_status,
  601. .read_ber = s5h1409_read_ber,
  602. .read_signal_strength = s5h1409_read_signal_strength,
  603. .read_snr = s5h1409_read_snr,
  604. .read_ucblocks = s5h1409_read_ucblocks,
  605. .release = s5h1409_release,
  606. };
  607. module_param(debug, int, 0644);
  608. MODULE_PARM_DESC(debug, "Enable verbose debug messages");
  609. MODULE_DESCRIPTION("Samsung S5H1409 QAM-B/ATSC Demodulator driver");
  610. MODULE_AUTHOR("Steven Toth");
  611. MODULE_LICENSE("GPL");
  612. EXPORT_SYMBOL(s5h1409_attach);
  613. /*
  614. * Local variables:
  615. * c-basic-offset: 8
  616. */