or51132.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  1. /*
  2. * Support for OR51132 (pcHDTV HD-3000) - VSB/QAM
  3. *
  4. * Copyright (C) 2005 Kirk Lapray <kirk_lapray@bigfoot.com>
  5. *
  6. * Based on code from Jack Kelliher (kelliher@xmission.com)
  7. * Copyright (C) 2002 & pcHDTV, inc.
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22. *
  23. */
  24. /*
  25. * This driver needs two external firmware files. Please copy
  26. * "dvb-fe-or51132-vsb.fw" and "dvb-fe-or51132-qam.fw" to
  27. * /usr/lib/hotplug/firmware/ or /lib/firmware/
  28. * (depending on configuration of firmware hotplug).
  29. */
  30. #define OR51132_VSB_FIRMWARE "dvb-fe-or51132-vsb.fw"
  31. #define OR51132_QAM_FIRMWARE "dvb-fe-or51132-qam.fw"
  32. #include <linux/kernel.h>
  33. #include <linux/module.h>
  34. #include <linux/moduleparam.h>
  35. #include <linux/init.h>
  36. #include <linux/delay.h>
  37. #include <asm/byteorder.h>
  38. #include "dvb_frontend.h"
  39. #include "dvb-pll.h"
  40. #include "or51132.h"
  41. static int debug;
  42. #define dprintk(args...) \
  43. do { \
  44. if (debug) printk(KERN_DEBUG "or51132: " args); \
  45. } while (0)
  46. struct or51132_state
  47. {
  48. struct i2c_adapter* i2c;
  49. struct dvb_frontend_ops ops;
  50. /* Configuration settings */
  51. const struct or51132_config* config;
  52. struct dvb_frontend frontend;
  53. /* Demodulator private data */
  54. fe_modulation_t current_modulation;
  55. /* Tuner private data */
  56. u32 current_frequency;
  57. };
  58. static int i2c_writebytes (struct or51132_state* state, u8 reg, u8 *buf, int len)
  59. {
  60. int err;
  61. struct i2c_msg msg;
  62. msg.addr = reg;
  63. msg.flags = 0;
  64. msg.len = len;
  65. msg.buf = buf;
  66. if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) {
  67. printk(KERN_WARNING "or51132: i2c_writebytes error (addr %02x, err == %i)\n", reg, err);
  68. return -EREMOTEIO;
  69. }
  70. return 0;
  71. }
  72. static u8 i2c_readbytes (struct or51132_state* state, u8 reg, u8* buf, int len)
  73. {
  74. int err;
  75. struct i2c_msg msg;
  76. msg.addr = reg;
  77. msg.flags = I2C_M_RD;
  78. msg.len = len;
  79. msg.buf = buf;
  80. if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) {
  81. printk(KERN_WARNING "or51132: i2c_readbytes error (addr %02x, err == %i)\n", reg, err);
  82. return -EREMOTEIO;
  83. }
  84. return 0;
  85. }
  86. static int or51132_load_firmware (struct dvb_frontend* fe, const struct firmware *fw)
  87. {
  88. struct or51132_state* state = fe->demodulator_priv;
  89. static u8 run_buf[] = {0x7F,0x01};
  90. static u8 get_ver_buf[] = {0x04,0x00,0x30,0x00,0x00};
  91. u8 rec_buf[14];
  92. u8 cmd_buf[14];
  93. u32 firmwareAsize, firmwareBsize;
  94. int i,ret;
  95. dprintk("Firmware is %Zd bytes\n",fw->size);
  96. /* Get size of firmware A and B */
  97. firmwareAsize = le32_to_cpu(*((u32*)fw->data));
  98. dprintk("FirmwareA is %i bytes\n",firmwareAsize);
  99. firmwareBsize = le32_to_cpu(*((u32*)(fw->data+4)));
  100. dprintk("FirmwareB is %i bytes\n",firmwareBsize);
  101. /* Upload firmware */
  102. if ((ret = i2c_writebytes(state,state->config->demod_address,
  103. &fw->data[8],firmwareAsize))) {
  104. printk(KERN_WARNING "or51132: load_firmware error 1\n");
  105. return ret;
  106. }
  107. msleep(1); /* 1ms */
  108. if ((ret = i2c_writebytes(state,state->config->demod_address,
  109. &fw->data[8+firmwareAsize],firmwareBsize))) {
  110. printk(KERN_WARNING "or51132: load_firmware error 2\n");
  111. return ret;
  112. }
  113. msleep(1); /* 1ms */
  114. if ((ret = i2c_writebytes(state,state->config->demod_address,
  115. run_buf,2))) {
  116. printk(KERN_WARNING "or51132: load_firmware error 3\n");
  117. return ret;
  118. }
  119. /* Wait at least 5 msec */
  120. msleep(20); /* 10ms */
  121. if ((ret = i2c_writebytes(state,state->config->demod_address,
  122. run_buf,2))) {
  123. printk(KERN_WARNING "or51132: load_firmware error 4\n");
  124. return ret;
  125. }
  126. /* 50ms for operation to begin */
  127. msleep(50);
  128. /* Read back ucode version to besure we loaded correctly and are really up and running */
  129. /* Get uCode version */
  130. cmd_buf[0] = 0x10;
  131. cmd_buf[1] = 0x10;
  132. cmd_buf[2] = 0x00;
  133. cmd_buf[3] = 0x00;
  134. msleep(20); /* 20ms */
  135. if ((ret = i2c_writebytes(state,state->config->demod_address,
  136. cmd_buf,3))) {
  137. printk(KERN_WARNING "or51132: load_firmware error a\n");
  138. return ret;
  139. }
  140. cmd_buf[0] = 0x04;
  141. cmd_buf[1] = 0x17;
  142. cmd_buf[2] = 0x00;
  143. cmd_buf[3] = 0x00;
  144. msleep(20); /* 20ms */
  145. if ((ret = i2c_writebytes(state,state->config->demod_address,
  146. cmd_buf,2))) {
  147. printk(KERN_WARNING "or51132: load_firmware error b\n");
  148. return ret;
  149. }
  150. cmd_buf[0] = 0x00;
  151. cmd_buf[1] = 0x00;
  152. cmd_buf[2] = 0x00;
  153. cmd_buf[3] = 0x00;
  154. msleep(20); /* 20ms */
  155. if ((ret = i2c_writebytes(state,state->config->demod_address,
  156. cmd_buf,2))) {
  157. printk(KERN_WARNING "or51132: load_firmware error c\n");
  158. return ret;
  159. }
  160. for(i=0;i<4;i++) {
  161. msleep(20); /* 20ms */
  162. get_ver_buf[4] = i+1;
  163. if ((ret = i2c_readbytes(state,state->config->demod_address,
  164. &rec_buf[i*2],2))) {
  165. printk(KERN_WARNING
  166. "or51132: load_firmware error d - %d\n",i);
  167. return ret;
  168. }
  169. }
  170. printk(KERN_WARNING
  171. "or51132: Version: %02X%02X%02X%02X-%02X%02X%02X%02X (%02X%01X-%01X-%02X%01X-%01X)\n",
  172. rec_buf[1],rec_buf[0],rec_buf[3],rec_buf[2],
  173. rec_buf[5],rec_buf[4],rec_buf[7],rec_buf[6],
  174. rec_buf[3],rec_buf[2]>>4,rec_buf[2]&0x0f,
  175. rec_buf[5],rec_buf[4]>>4,rec_buf[4]&0x0f);
  176. cmd_buf[0] = 0x10;
  177. cmd_buf[1] = 0x00;
  178. cmd_buf[2] = 0x00;
  179. cmd_buf[3] = 0x00;
  180. msleep(20); /* 20ms */
  181. if ((ret = i2c_writebytes(state,state->config->demod_address,
  182. cmd_buf,3))) {
  183. printk(KERN_WARNING "or51132: load_firmware error e\n");
  184. return ret;
  185. }
  186. return 0;
  187. };
  188. static int or51132_init(struct dvb_frontend* fe)
  189. {
  190. return 0;
  191. }
  192. static int or51132_read_ber(struct dvb_frontend* fe, u32* ber)
  193. {
  194. *ber = 0;
  195. return 0;
  196. }
  197. static int or51132_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
  198. {
  199. *ucblocks = 0;
  200. return 0;
  201. }
  202. static int or51132_sleep(struct dvb_frontend* fe)
  203. {
  204. return 0;
  205. }
  206. static int or51132_setmode(struct dvb_frontend* fe)
  207. {
  208. struct or51132_state* state = fe->demodulator_priv;
  209. unsigned char cmd_buf[4];
  210. dprintk("setmode %d\n",(int)state->current_modulation);
  211. /* set operation mode in Receiver 1 register; */
  212. cmd_buf[0] = 0x04;
  213. cmd_buf[1] = 0x01;
  214. switch (state->current_modulation) {
  215. case QAM_256:
  216. case QAM_64:
  217. case QAM_AUTO:
  218. /* Auto-deinterleave; MPEG ser, MPEG2tr, phase noise-high*/
  219. cmd_buf[2] = 0x5F;
  220. break;
  221. case VSB_8:
  222. /* Auto CH, Auto NTSC rej, MPEGser, MPEG2tr, phase noise-high*/
  223. cmd_buf[2] = 0x50;
  224. break;
  225. default:
  226. printk("setmode:Modulation set to unsupported value\n");
  227. };
  228. cmd_buf[3] = 0x00;
  229. if (i2c_writebytes(state,state->config->demod_address,
  230. cmd_buf,3)) {
  231. printk(KERN_WARNING "or51132: set_mode error 1\n");
  232. return -1;
  233. }
  234. dprintk("or51132: set #1 to %02x\n", cmd_buf[2]);
  235. /* Set operation mode in Receiver 6 register */
  236. cmd_buf[0] = 0x1C;
  237. switch (state->current_modulation) {
  238. case QAM_AUTO:
  239. /* REC MODE Normal Carrier Lock */
  240. cmd_buf[1] = 0x00;
  241. /* Channel MODE Auto QAM64/256 */
  242. cmd_buf[2] = 0x4f;
  243. break;
  244. case QAM_256:
  245. /* REC MODE Normal Carrier Lock */
  246. cmd_buf[1] = 0x00;
  247. /* Channel MODE QAM256 */
  248. cmd_buf[2] = 0x45;
  249. break;
  250. case QAM_64:
  251. /* REC MODE Normal Carrier Lock */
  252. cmd_buf[1] = 0x00;
  253. /* Channel MODE QAM64 */
  254. cmd_buf[2] = 0x43;
  255. break;
  256. case VSB_8:
  257. /* REC MODE inv IF spectrum, Normal */
  258. cmd_buf[1] = 0x03;
  259. /* Channel MODE ATSC/VSB8 */
  260. cmd_buf[2] = 0x06;
  261. break;
  262. default:
  263. printk("setmode: Modulation set to unsupported value\n");
  264. };
  265. cmd_buf[3] = 0x00;
  266. msleep(20); /* 20ms */
  267. if (i2c_writebytes(state,state->config->demod_address,
  268. cmd_buf,3)) {
  269. printk(KERN_WARNING "or51132: set_mode error 2\n");
  270. return -1;
  271. }
  272. dprintk("or51132: set #6 to 0x%02x%02x\n", cmd_buf[1], cmd_buf[2]);
  273. return 0;
  274. }
  275. static int or51132_set_parameters(struct dvb_frontend* fe,
  276. struct dvb_frontend_parameters *param)
  277. {
  278. int ret;
  279. u8 buf[4];
  280. struct or51132_state* state = fe->demodulator_priv;
  281. const struct firmware *fw;
  282. /* Change only if we are actually changing the modulation */
  283. if (state->current_modulation != param->u.vsb.modulation) {
  284. switch(param->u.vsb.modulation) {
  285. case VSB_8:
  286. dprintk("set_parameters VSB MODE\n");
  287. printk("or51132: Waiting for firmware upload(%s)...\n",
  288. OR51132_VSB_FIRMWARE);
  289. ret = request_firmware(&fw, OR51132_VSB_FIRMWARE,
  290. &state->i2c->dev);
  291. if (ret){
  292. printk(KERN_WARNING "or51132: No firmware up"
  293. "loaded(timeout or file not found?)\n");
  294. return ret;
  295. }
  296. /* Set non-punctured clock for VSB */
  297. state->config->set_ts_params(fe, 0);
  298. break;
  299. case QAM_AUTO:
  300. case QAM_64:
  301. case QAM_256:
  302. dprintk("set_parameters QAM MODE\n");
  303. printk("or51132: Waiting for firmware upload(%s)...\n",
  304. OR51132_QAM_FIRMWARE);
  305. ret = request_firmware(&fw, OR51132_QAM_FIRMWARE,
  306. &state->i2c->dev);
  307. if (ret){
  308. printk(KERN_WARNING "or51132: No firmware up"
  309. "loaded(timeout or file not found?)\n");
  310. return ret;
  311. }
  312. /* Set punctured clock for QAM */
  313. state->config->set_ts_params(fe, 1);
  314. break;
  315. default:
  316. printk("or51132:Modulation type(%d) UNSUPPORTED\n",
  317. param->u.vsb.modulation);
  318. return -1;
  319. };
  320. ret = or51132_load_firmware(fe, fw);
  321. release_firmware(fw);
  322. if (ret) {
  323. printk(KERN_WARNING "or51132: Writing firmware to "
  324. "device failed!\n");
  325. return ret;
  326. }
  327. printk("or51132: Firmware upload complete.\n");
  328. state->current_modulation = param->u.vsb.modulation;
  329. or51132_setmode(fe);
  330. }
  331. dvb_pll_configure(state->config->pll_desc, buf,
  332. param->frequency, 0);
  333. dprintk("set_parameters tuner bytes: 0x%02x 0x%02x "
  334. "0x%02x 0x%02x\n",buf[0],buf[1],buf[2],buf[3]);
  335. if (i2c_writebytes(state, state->config->pll_address ,buf, 4))
  336. printk(KERN_WARNING "or51132: set_parameters error "
  337. "writing to tuner\n");
  338. /* Set to current mode */
  339. or51132_setmode(fe);
  340. /* Update current frequency */
  341. state->current_frequency = param->frequency;
  342. return 0;
  343. }
  344. static int or51132_read_status(struct dvb_frontend* fe, fe_status_t* status)
  345. {
  346. struct or51132_state* state = fe->demodulator_priv;
  347. unsigned char rec_buf[2];
  348. unsigned char snd_buf[2];
  349. *status = 0;
  350. /* Receiver Status */
  351. snd_buf[0]=0x04;
  352. snd_buf[1]=0x00;
  353. msleep(30); /* 30ms */
  354. if (i2c_writebytes(state,state->config->demod_address,snd_buf,2)) {
  355. printk(KERN_WARNING "or51132: read_status write error\n");
  356. return -1;
  357. }
  358. msleep(30); /* 30ms */
  359. if (i2c_readbytes(state,state->config->demod_address,rec_buf,2)) {
  360. printk(KERN_WARNING "or51132: read_status read error\n");
  361. return -1;
  362. }
  363. dprintk("read_status %x %x\n",rec_buf[0],rec_buf[1]);
  364. if (rec_buf[1] & 0x01) { /* Receiver Lock */
  365. *status |= FE_HAS_SIGNAL;
  366. *status |= FE_HAS_CARRIER;
  367. *status |= FE_HAS_VITERBI;
  368. *status |= FE_HAS_SYNC;
  369. *status |= FE_HAS_LOCK;
  370. }
  371. return 0;
  372. }
  373. /* log10-1 table at .5 increments from 1 to 100.5 */
  374. static unsigned int i100x20log10[] = {
  375. 0, 352, 602, 795, 954, 1088, 1204, 1306, 1397, 1480,
  376. 1556, 1625, 1690, 1750, 1806, 1858, 1908, 1955, 2000, 2042,
  377. 2082, 2121, 2158, 2193, 2227, 2260, 2292, 2322, 2352, 2380,
  378. 2408, 2434, 2460, 2486, 2510, 2534, 2557, 2580, 2602, 2623,
  379. 2644, 2664, 2684, 2704, 2723, 2742, 2760, 2778, 2795, 2813,
  380. 2829, 2846, 2862, 2878, 2894, 2909, 2924, 2939, 2954, 2968,
  381. 2982, 2996, 3010, 3023, 3037, 3050, 3062, 3075, 3088, 3100,
  382. 3112, 3124, 3136, 3148, 3159, 3170, 3182, 3193, 3204, 3214,
  383. 3225, 3236, 3246, 3256, 3266, 3276, 3286, 3296, 3306, 3316,
  384. 3325, 3334, 3344, 3353, 3362, 3371, 3380, 3389, 3397, 3406,
  385. 3415, 3423, 3432, 3440, 3448, 3456, 3464, 3472, 3480, 3488,
  386. 3496, 3504, 3511, 3519, 3526, 3534, 3541, 3549, 3556, 3563,
  387. 3570, 3577, 3584, 3591, 3598, 3605, 3612, 3619, 3625, 3632,
  388. 3639, 3645, 3652, 3658, 3665, 3671, 3677, 3683, 3690, 3696,
  389. 3702, 3708, 3714, 3720, 3726, 3732, 3738, 3744, 3750, 3755,
  390. 3761, 3767, 3772, 3778, 3784, 3789, 3795, 3800, 3806, 3811,
  391. 3816, 3822, 3827, 3832, 3838, 3843, 3848, 3853, 3858, 3863,
  392. 3868, 3874, 3879, 3884, 3888, 3893, 3898, 3903, 3908, 3913,
  393. 3918, 3922, 3927, 3932, 3936, 3941, 3946, 3950, 3955, 3960,
  394. 3964, 3969, 3973, 3978, 3982, 3986, 3991, 3995, 4000, 4004,
  395. };
  396. static unsigned int denom[] = {1,1,100,1000,10000,100000,1000000,10000000,100000000};
  397. static unsigned int i20Log10(unsigned short val)
  398. {
  399. unsigned int rntval = 100;
  400. unsigned int tmp = val;
  401. unsigned int exp = 1;
  402. while(tmp > 100) {tmp /= 100; exp++;}
  403. val = (2 * val)/denom[exp];
  404. if (exp > 1) rntval = 2000*exp;
  405. rntval += i100x20log10[val];
  406. return rntval;
  407. }
  408. static int or51132_read_signal_strength(struct dvb_frontend* fe, u16* strength)
  409. {
  410. struct or51132_state* state = fe->demodulator_priv;
  411. unsigned char rec_buf[2];
  412. unsigned char snd_buf[2];
  413. u8 rcvr_stat;
  414. u16 snr_equ;
  415. int usK;
  416. snd_buf[0]=0x04;
  417. snd_buf[1]=0x02; /* SNR after Equalizer */
  418. msleep(30); /* 30ms */
  419. if (i2c_writebytes(state,state->config->demod_address,snd_buf,2)) {
  420. printk(KERN_WARNING "or51132: read_status write error\n");
  421. return -1;
  422. }
  423. msleep(30); /* 30ms */
  424. if (i2c_readbytes(state,state->config->demod_address,rec_buf,2)) {
  425. printk(KERN_WARNING "or51132: read_status read error\n");
  426. return -1;
  427. }
  428. snr_equ = rec_buf[0] | (rec_buf[1] << 8);
  429. dprintk("read_signal_strength snr_equ %x %x (%i)\n",rec_buf[0],rec_buf[1],snr_equ);
  430. /* Receiver Status */
  431. snd_buf[0]=0x04;
  432. snd_buf[1]=0x00;
  433. msleep(30); /* 30ms */
  434. if (i2c_writebytes(state,state->config->demod_address,snd_buf,2)) {
  435. printk(KERN_WARNING "or51132: read_signal_strength read_status write error\n");
  436. return -1;
  437. }
  438. msleep(30); /* 30ms */
  439. if (i2c_readbytes(state,state->config->demod_address,rec_buf,2)) {
  440. printk(KERN_WARNING "or51132: read_signal_strength read_status read error\n");
  441. return -1;
  442. }
  443. dprintk("read_signal_strength read_status %x %x\n",rec_buf[0],rec_buf[1]);
  444. rcvr_stat = rec_buf[1];
  445. usK = (rcvr_stat & 0x10) ? 3 : 0;
  446. /* The value reported back from the frontend will be FFFF=100% 0000=0% */
  447. *strength = (((8952 - i20Log10(snr_equ) - usK*100)/3+5)*65535)/1000;
  448. dprintk("read_signal_strength %i\n",*strength);
  449. return 0;
  450. }
  451. static int or51132_read_snr(struct dvb_frontend* fe, u16* snr)
  452. {
  453. struct or51132_state* state = fe->demodulator_priv;
  454. unsigned char rec_buf[2];
  455. unsigned char snd_buf[2];
  456. u16 snr_equ;
  457. snd_buf[0]=0x04;
  458. snd_buf[1]=0x02; /* SNR after Equalizer */
  459. msleep(30); /* 30ms */
  460. if (i2c_writebytes(state,state->config->demod_address,snd_buf,2)) {
  461. printk(KERN_WARNING "or51132: read_snr write error\n");
  462. return -1;
  463. }
  464. msleep(30); /* 30ms */
  465. if (i2c_readbytes(state,state->config->demod_address,rec_buf,2)) {
  466. printk(KERN_WARNING "or51132: read_snr dvr read error\n");
  467. return -1;
  468. }
  469. snr_equ = rec_buf[0] | (rec_buf[1] << 8);
  470. dprintk("read_snr snr_equ %x %x (%i)\n",rec_buf[0],rec_buf[1],snr_equ);
  471. *snr = 0xFFFF - snr_equ;
  472. dprintk("read_snr %i\n",*snr);
  473. return 0;
  474. }
  475. static int or51132_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fe_tune_settings)
  476. {
  477. fe_tune_settings->min_delay_ms = 500;
  478. fe_tune_settings->step_size = 0;
  479. fe_tune_settings->max_drift = 0;
  480. return 0;
  481. }
  482. static void or51132_release(struct dvb_frontend* fe)
  483. {
  484. struct or51132_state* state = fe->demodulator_priv;
  485. kfree(state);
  486. }
  487. static struct dvb_frontend_ops or51132_ops;
  488. struct dvb_frontend* or51132_attach(const struct or51132_config* config,
  489. struct i2c_adapter* i2c)
  490. {
  491. struct or51132_state* state = NULL;
  492. /* Allocate memory for the internal state */
  493. state = kmalloc(sizeof(struct or51132_state), GFP_KERNEL);
  494. if (state == NULL)
  495. goto error;
  496. /* Setup the state */
  497. state->config = config;
  498. state->i2c = i2c;
  499. memcpy(&state->ops, &or51132_ops, sizeof(struct dvb_frontend_ops));
  500. state->current_frequency = -1;
  501. state->current_modulation = -1;
  502. /* Create dvb_frontend */
  503. state->frontend.ops = &state->ops;
  504. state->frontend.demodulator_priv = state;
  505. return &state->frontend;
  506. error:
  507. if (state)
  508. kfree(state);
  509. return NULL;
  510. }
  511. static struct dvb_frontend_ops or51132_ops = {
  512. .info = {
  513. .name = "Oren OR51132 VSB/QAM Frontend",
  514. .type = FE_ATSC,
  515. .frequency_min = 44000000,
  516. .frequency_max = 958000000,
  517. .frequency_stepsize = 166666,
  518. .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
  519. FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
  520. FE_CAN_QAM_64 | FE_CAN_QAM_256 | FE_CAN_QAM_AUTO |
  521. FE_CAN_8VSB
  522. },
  523. .release = or51132_release,
  524. .init = or51132_init,
  525. .sleep = or51132_sleep,
  526. .set_frontend = or51132_set_parameters,
  527. .get_tune_settings = or51132_get_tune_settings,
  528. .read_status = or51132_read_status,
  529. .read_ber = or51132_read_ber,
  530. .read_signal_strength = or51132_read_signal_strength,
  531. .read_snr = or51132_read_snr,
  532. .read_ucblocks = or51132_read_ucblocks,
  533. };
  534. module_param(debug, int, 0644);
  535. MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
  536. MODULE_DESCRIPTION("OR51132 ATSC [pcHDTV HD-3000] (8VSB & ITU J83 AnnexB FEC QAM64/256) Demodulator Driver");
  537. MODULE_AUTHOR("Kirk Lapray");
  538. MODULE_LICENSE("GPL");
  539. EXPORT_SYMBOL(or51132_attach);
  540. /*
  541. * Local variables:
  542. * c-basic-offset: 8
  543. * End:
  544. */