Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1 | /* |
| 2 | Conexant cx24116/cx24118 - DVBS/S2 Satellite demod/tuner driver |
| 3 | |
| 4 | Copyright (C) 2006-2008 Steven Toth <stoth@hauppauge.com> |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 5 | Copyright (C) 2006-2007 Georg Acher |
| 6 | Copyright (C) 2007-2008 Darron Broad |
| 7 | March 2007 |
| 8 | Fixed some bugs. |
| 9 | Added diseqc support. |
| 10 | Added corrected signal strength support. |
| 11 | August 2007 |
| 12 | Sync with legacy version. |
| 13 | Some clean ups. |
| 14 | Copyright (C) 2008 Igor Liplianin |
| 15 | September, 9th 2008 |
Igor M. Liplianin | c063a48 | 2008-09-14 07:43:53 -0300 | [diff] [blame] | 16 | Fixed locking on high symbol rates (>30000). |
| 17 | Implement MPEG initialization parameter. |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 18 | |
| 19 | This program is free software; you can redistribute it and/or modify |
| 20 | it under the terms of the GNU General Public License as published by |
| 21 | the Free Software Foundation; either version 2 of the License, or |
| 22 | (at your option) any later version. |
| 23 | |
| 24 | This program is distributed in the hope that it will be useful, |
| 25 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 26 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 27 | GNU General Public License for more details. |
| 28 | |
| 29 | You should have received a copy of the GNU General Public License |
| 30 | along with this program; if not, write to the Free Software |
| 31 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 32 | */ |
| 33 | |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 34 | #include <linux/slab.h> |
| 35 | #include <linux/kernel.h> |
| 36 | #include <linux/module.h> |
| 37 | #include <linux/moduleparam.h> |
| 38 | #include <linux/init.h> |
| 39 | #include <linux/firmware.h> |
| 40 | |
| 41 | #include "dvb_frontend.h" |
| 42 | #include "cx24116.h" |
| 43 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 44 | static int debug; |
| 45 | module_param(debug, int, 0644); |
| 46 | MODULE_PARM_DESC(debug, "Activates frontend debugging (default:0)"); |
| 47 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 48 | #define dprintk(args...) \ |
| 49 | do { \ |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 50 | if (debug) \ |
Steven Toth | 98c9482 | 2008-10-16 20:24:42 -0300 | [diff] [blame] | 51 | printk(KERN_INFO "cx24116: " args); \ |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 52 | } while (0) |
| 53 | |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 54 | #define CX24116_DEFAULT_FIRMWARE "dvb-fe-cx24116.fw" |
| 55 | #define CX24116_SEARCH_RANGE_KHZ 5000 |
| 56 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 57 | /* known registers */ |
| 58 | #define CX24116_REG_COMMAND (0x00) /* command args 0x00..0x1e */ |
| 59 | #define CX24116_REG_EXECUTE (0x1f) /* execute command */ |
| 60 | #define CX24116_REG_MAILBOX (0x96) /* FW or multipurpose mailbox? */ |
| 61 | #define CX24116_REG_RESET (0x20) /* reset status > 0 */ |
| 62 | #define CX24116_REG_SIGNAL (0x9e) /* signal low */ |
| 63 | #define CX24116_REG_SSTATUS (0x9d) /* signal high / status */ |
Steven Toth | 8953db7 | 2008-10-06 21:20:21 -0300 | [diff] [blame] | 64 | #define CX24116_REG_QUALITY8 (0xa3) |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 65 | #define CX24116_REG_QSTATUS (0xbc) |
Steven Toth | 8953db7 | 2008-10-06 21:20:21 -0300 | [diff] [blame] | 66 | #define CX24116_REG_QUALITY0 (0xd5) |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 67 | #define CX24116_REG_BER0 (0xc9) |
| 68 | #define CX24116_REG_BER8 (0xc8) |
| 69 | #define CX24116_REG_BER16 (0xc7) |
| 70 | #define CX24116_REG_BER24 (0xc6) |
| 71 | #define CX24116_REG_UCB0 (0xcb) |
| 72 | #define CX24116_REG_UCB8 (0xca) |
| 73 | #define CX24116_REG_CLKDIV (0xf3) |
| 74 | #define CX24116_REG_RATEDIV (0xf9) |
Steven Toth | 98c9482 | 2008-10-16 20:24:42 -0300 | [diff] [blame] | 75 | |
| 76 | /* configured fec (not tuned) or actual FEC (tuned) 1=1/2 2=2/3 etc */ |
| 77 | #define CX24116_REG_FECSTATUS (0x9c) |
Darron Broad | 681faa0 | 2008-09-22 00:47:20 -0300 | [diff] [blame] | 78 | |
| 79 | /* FECSTATUS bits */ |
Steven Toth | 98c9482 | 2008-10-16 20:24:42 -0300 | [diff] [blame] | 80 | /* mask to determine configured fec (not tuned) or actual fec (tuned) */ |
| 81 | #define CX24116_FEC_FECMASK (0x1f) |
| 82 | |
| 83 | /* Select DVB-S demodulator, else DVB-S2 */ |
| 84 | #define CX24116_FEC_DVBS (0x20) |
Darron Broad | 681faa0 | 2008-09-22 00:47:20 -0300 | [diff] [blame] | 85 | #define CX24116_FEC_UNKNOWN (0x40) /* Unknown/unused */ |
Steven Toth | 98c9482 | 2008-10-16 20:24:42 -0300 | [diff] [blame] | 86 | |
| 87 | /* Pilot mode requested when tuning else always reset when tuned */ |
| 88 | #define CX24116_FEC_PILOT (0x80) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 89 | |
| 90 | /* arg buffer size */ |
| 91 | #define CX24116_ARGLEN (0x1e) |
| 92 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 93 | /* rolloff */ |
| 94 | #define CX24116_ROLLOFF_020 (0x00) |
| 95 | #define CX24116_ROLLOFF_025 (0x01) |
| 96 | #define CX24116_ROLLOFF_035 (0x02) |
| 97 | |
| 98 | /* pilot bit */ |
Darron Broad | 01a8f03 | 2008-10-03 11:47:46 -0300 | [diff] [blame] | 99 | #define CX24116_PILOT_OFF (0x00) |
| 100 | #define CX24116_PILOT_ON (0x40) |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 101 | |
| 102 | /* signal status */ |
| 103 | #define CX24116_HAS_SIGNAL (0x01) |
| 104 | #define CX24116_HAS_CARRIER (0x02) |
| 105 | #define CX24116_HAS_VITERBI (0x04) |
| 106 | #define CX24116_HAS_SYNCLOCK (0x08) |
| 107 | #define CX24116_HAS_UNKNOWN1 (0x10) |
| 108 | #define CX24116_HAS_UNKNOWN2 (0x20) |
| 109 | #define CX24116_STATUS_MASK (0x3f) |
| 110 | #define CX24116_SIGNAL_MASK (0xc0) |
| 111 | |
| 112 | #define CX24116_DISEQC_TONEOFF (0) /* toneburst never sent */ |
| 113 | #define CX24116_DISEQC_TONECACHE (1) /* toneburst cached */ |
| 114 | #define CX24116_DISEQC_MESGCACHE (2) /* message cached */ |
| 115 | |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 116 | /* arg offset for DiSEqC */ |
| 117 | #define CX24116_DISEQC_BURST (1) |
| 118 | #define CX24116_DISEQC_ARG2_2 (2) /* unknown value=2 */ |
| 119 | #define CX24116_DISEQC_ARG3_0 (3) /* unknown value=0 */ |
| 120 | #define CX24116_DISEQC_ARG4_0 (4) /* unknown value=0 */ |
| 121 | #define CX24116_DISEQC_MSGLEN (5) |
| 122 | #define CX24116_DISEQC_MSGOFS (6) |
| 123 | |
| 124 | /* DiSEqC burst */ |
| 125 | #define CX24116_DISEQC_MINI_A (0) |
| 126 | #define CX24116_DISEQC_MINI_B (1) |
| 127 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 128 | /* DiSEqC tone burst */ |
| 129 | static int toneburst = 1; |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 130 | module_param(toneburst, int, 0644); |
Steven Toth | 98c9482 | 2008-10-16 20:24:42 -0300 | [diff] [blame] | 131 | MODULE_PARM_DESC(toneburst, "DiSEqC toneburst 0=OFF, 1=TONE CACHE, "\ |
| 132 | "2=MESSAGE CACHE (default:1)"); |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 133 | |
Steven Toth | 8953db7 | 2008-10-06 21:20:21 -0300 | [diff] [blame] | 134 | /* SNR measurements */ |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 135 | static int esno_snr; |
| 136 | module_param(esno_snr, int, 0644); |
Steven Toth | 98c9482 | 2008-10-16 20:24:42 -0300 | [diff] [blame] | 137 | MODULE_PARM_DESC(debug, "SNR return units, 0=PERCENTAGE 0-100, "\ |
| 138 | "1=ESNO(db * 10) (default:0)"); |
Steven Toth | 8953db7 | 2008-10-06 21:20:21 -0300 | [diff] [blame] | 139 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 140 | enum cmds { |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 141 | CMD_SET_VCO = 0x10, |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 142 | CMD_TUNEREQUEST = 0x11, |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 143 | CMD_MPEGCONFIG = 0x13, |
| 144 | CMD_TUNERINIT = 0x14, |
| 145 | CMD_BANDWIDTH = 0x15, |
| 146 | CMD_GETAGC = 0x19, |
| 147 | CMD_LNBCONFIG = 0x20, |
| 148 | CMD_LNBSEND = 0x21, /* Formerly CMD_SEND_DISEQC */ |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 149 | CMD_SET_TONEPRE = 0x22, |
| 150 | CMD_SET_TONE = 0x23, |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 151 | CMD_UPDFWVERS = 0x35, |
| 152 | CMD_TUNERSLEEP = 0x36, |
| 153 | CMD_AGCCONTROL = 0x3b, /* Unknown */ |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 154 | }; |
| 155 | |
| 156 | /* The Demod/Tuner can't easily provide these, we cache them */ |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 157 | struct cx24116_tuning { |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 158 | u32 frequency; |
| 159 | u32 symbol_rate; |
| 160 | fe_spectral_inversion_t inversion; |
| 161 | fe_code_rate_t fec; |
| 162 | |
Darron Broad | 3569476 | 2008-12-18 06:21:51 -0300 | [diff] [blame^] | 163 | fe_delivery_system_t delsys; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 164 | fe_modulation_t modulation; |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 165 | fe_pilot_t pilot; |
| 166 | fe_rolloff_t rolloff; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 167 | |
| 168 | /* Demod values */ |
| 169 | u8 fec_val; |
| 170 | u8 fec_mask; |
| 171 | u8 inversion_val; |
Darron Broad | 01a8f03 | 2008-10-03 11:47:46 -0300 | [diff] [blame] | 172 | u8 pilot_val; |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 173 | u8 rolloff_val; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 174 | }; |
| 175 | |
| 176 | /* Basic commands that are sent to the firmware */ |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 177 | struct cx24116_cmd { |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 178 | u8 len; |
| 179 | u8 args[CX24116_ARGLEN]; |
| 180 | }; |
| 181 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 182 | struct cx24116_state { |
| 183 | struct i2c_adapter *i2c; |
| 184 | const struct cx24116_config *config; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 185 | |
| 186 | struct dvb_frontend frontend; |
| 187 | |
| 188 | struct cx24116_tuning dcur; |
| 189 | struct cx24116_tuning dnxt; |
| 190 | |
| 191 | u8 skip_fw_load; |
| 192 | u8 burst; |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 193 | struct cx24116_cmd dsec_cmd; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 194 | }; |
| 195 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 196 | static int cx24116_writereg(struct cx24116_state *state, int reg, int data) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 197 | { |
| 198 | u8 buf[] = { reg, data }; |
| 199 | struct i2c_msg msg = { .addr = state->config->demod_address, |
| 200 | .flags = 0, .buf = buf, .len = 2 }; |
| 201 | int err; |
| 202 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 203 | if (debug > 1) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 204 | printk("cx24116: %s: write reg 0x%02x, value 0x%02x\n", |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 205 | __func__, reg, data); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 206 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 207 | err = i2c_transfer(state->i2c, &msg, 1); |
| 208 | if (err != 1) { |
Steven Toth | 98c9482 | 2008-10-16 20:24:42 -0300 | [diff] [blame] | 209 | printk(KERN_ERR "%s: writereg error(err == %i, reg == 0x%02x," |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 210 | " value == 0x%02x)\n", __func__, err, reg, data); |
| 211 | return -EREMOTEIO; |
| 212 | } |
| 213 | |
| 214 | return 0; |
| 215 | } |
| 216 | |
| 217 | /* Bulk byte writes to a single I2C address, for 32k firmware load */ |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 218 | static int cx24116_writeregN(struct cx24116_state *state, int reg, |
Geert Uytterhoeven | 64decbf | 2008-10-16 21:04:35 -0300 | [diff] [blame] | 219 | const u8 *data, u16 len) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 220 | { |
| 221 | int ret = -EREMOTEIO; |
| 222 | struct i2c_msg msg; |
| 223 | u8 *buf; |
| 224 | |
| 225 | buf = kmalloc(len + 1, GFP_KERNEL); |
| 226 | if (buf == NULL) { |
| 227 | printk("Unable to kmalloc\n"); |
| 228 | ret = -ENOMEM; |
| 229 | goto error; |
| 230 | } |
| 231 | |
| 232 | *(buf) = reg; |
| 233 | memcpy(buf + 1, data, len); |
| 234 | |
| 235 | msg.addr = state->config->demod_address; |
| 236 | msg.flags = 0; |
| 237 | msg.buf = buf; |
| 238 | msg.len = len + 1; |
| 239 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 240 | if (debug > 1) |
Steven Toth | 98c9482 | 2008-10-16 20:24:42 -0300 | [diff] [blame] | 241 | printk(KERN_INFO "cx24116: %s: write regN 0x%02x, len = %d\n", |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 242 | __func__, reg, len); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 243 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 244 | ret = i2c_transfer(state->i2c, &msg, 1); |
| 245 | if (ret != 1) { |
Steven Toth | 98c9482 | 2008-10-16 20:24:42 -0300 | [diff] [blame] | 246 | printk(KERN_ERR "%s: writereg error(err == %i, reg == 0x%02x\n", |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 247 | __func__, ret, reg); |
| 248 | ret = -EREMOTEIO; |
| 249 | } |
| 250 | |
| 251 | error: |
| 252 | kfree(buf); |
| 253 | |
| 254 | return ret; |
| 255 | } |
| 256 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 257 | static int cx24116_readreg(struct cx24116_state *state, u8 reg) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 258 | { |
| 259 | int ret; |
| 260 | u8 b0[] = { reg }; |
| 261 | u8 b1[] = { 0 }; |
| 262 | struct i2c_msg msg[] = { |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 263 | { .addr = state->config->demod_address, .flags = 0, |
| 264 | .buf = b0, .len = 1 }, |
| 265 | { .addr = state->config->demod_address, .flags = I2C_M_RD, |
| 266 | .buf = b1, .len = 1 } |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 267 | }; |
| 268 | |
| 269 | ret = i2c_transfer(state->i2c, msg, 2); |
| 270 | |
| 271 | if (ret != 2) { |
Steven Toth | 98c9482 | 2008-10-16 20:24:42 -0300 | [diff] [blame] | 272 | printk(KERN_ERR "%s: reg=0x%x (error=%d)\n", |
| 273 | __func__, reg, ret); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 274 | return ret; |
| 275 | } |
| 276 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 277 | if (debug > 1) |
Steven Toth | 98c9482 | 2008-10-16 20:24:42 -0300 | [diff] [blame] | 278 | printk(KERN_INFO "cx24116: read reg 0x%02x, value 0x%02x\n", |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 279 | reg, b1[0]); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 280 | |
| 281 | return b1[0]; |
| 282 | } |
| 283 | |
Steven Toth | 98c9482 | 2008-10-16 20:24:42 -0300 | [diff] [blame] | 284 | static int cx24116_set_inversion(struct cx24116_state *state, |
| 285 | fe_spectral_inversion_t inversion) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 286 | { |
| 287 | dprintk("%s(%d)\n", __func__, inversion); |
| 288 | |
| 289 | switch (inversion) { |
| 290 | case INVERSION_OFF: |
| 291 | state->dnxt.inversion_val = 0x00; |
| 292 | break; |
| 293 | case INVERSION_ON: |
| 294 | state->dnxt.inversion_val = 0x04; |
| 295 | break; |
| 296 | case INVERSION_AUTO: |
| 297 | state->dnxt.inversion_val = 0x0C; |
| 298 | break; |
| 299 | default: |
| 300 | return -EINVAL; |
| 301 | } |
| 302 | |
| 303 | state->dnxt.inversion = inversion; |
| 304 | |
| 305 | return 0; |
| 306 | } |
| 307 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 308 | /* |
| 309 | * modfec (modulation and FEC) |
| 310 | * =========================== |
| 311 | * |
| 312 | * MOD FEC mask/val standard |
| 313 | * ---- -------- ----------- -------- |
| 314 | * QPSK FEC_1_2 0x02 0x02+X DVB-S |
| 315 | * QPSK FEC_2_3 0x04 0x02+X DVB-S |
| 316 | * QPSK FEC_3_4 0x08 0x02+X DVB-S |
| 317 | * QPSK FEC_4_5 0x10 0x02+X DVB-S (?) |
| 318 | * QPSK FEC_5_6 0x20 0x02+X DVB-S |
| 319 | * QPSK FEC_6_7 0x40 0x02+X DVB-S |
| 320 | * QPSK FEC_7_8 0x80 0x02+X DVB-S |
| 321 | * QPSK FEC_8_9 0x01 0x02+X DVB-S (?) (NOT SUPPORTED?) |
| 322 | * QPSK AUTO 0xff 0x02+X DVB-S |
| 323 | * |
| 324 | * For DVB-S high byte probably represents FEC |
| 325 | * and low byte selects the modulator. The high |
| 326 | * byte is search range mask. Bit 5 may turn |
| 327 | * on DVB-S and remaining bits represent some |
| 328 | * kind of calibration (how/what i do not know). |
| 329 | * |
| 330 | * Eg.(2/3) szap "Zone Horror" |
| 331 | * |
| 332 | * mask/val = 0x04, 0x20 |
Steven Toth | 98c9482 | 2008-10-16 20:24:42 -0300 | [diff] [blame] | 333 | * status 1f | signal c3c0 | snr a333 | ber 00000098 | unc 0 | FE_HAS_LOCK |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 334 | * |
| 335 | * mask/val = 0x04, 0x30 |
Steven Toth | 98c9482 | 2008-10-16 20:24:42 -0300 | [diff] [blame] | 336 | * status 1f | signal c3c0 | snr a333 | ber 00000000 | unc 0 | FE_HAS_LOCK |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 337 | * |
| 338 | * After tuning FECSTATUS contains actual FEC |
| 339 | * in use numbered 1 through to 8 for 1/2 .. 2/3 etc |
| 340 | * |
| 341 | * NBC=NOT/NON BACKWARD COMPATIBLE WITH DVB-S (DVB-S2 only) |
| 342 | * |
| 343 | * NBC-QPSK FEC_1_2 0x00, 0x04 DVB-S2 |
| 344 | * NBC-QPSK FEC_3_5 0x00, 0x05 DVB-S2 |
| 345 | * NBC-QPSK FEC_2_3 0x00, 0x06 DVB-S2 |
| 346 | * NBC-QPSK FEC_3_4 0x00, 0x07 DVB-S2 |
| 347 | * NBC-QPSK FEC_4_5 0x00, 0x08 DVB-S2 |
| 348 | * NBC-QPSK FEC_5_6 0x00, 0x09 DVB-S2 |
| 349 | * NBC-QPSK FEC_8_9 0x00, 0x0a DVB-S2 |
| 350 | * NBC-QPSK FEC_9_10 0x00, 0x0b DVB-S2 |
| 351 | * |
| 352 | * NBC-8PSK FEC_3_5 0x00, 0x0c DVB-S2 |
| 353 | * NBC-8PSK FEC_2_3 0x00, 0x0d DVB-S2 |
| 354 | * NBC-8PSK FEC_3_4 0x00, 0x0e DVB-S2 |
| 355 | * NBC-8PSK FEC_5_6 0x00, 0x0f DVB-S2 |
| 356 | * NBC-8PSK FEC_8_9 0x00, 0x10 DVB-S2 |
| 357 | * NBC-8PSK FEC_9_10 0x00, 0x11 DVB-S2 |
| 358 | * |
| 359 | * For DVB-S2 low bytes selects both modulator |
| 360 | * and FEC. High byte is meaningless here. To |
| 361 | * set pilot, bit 6 (0x40) is set. When inspecting |
| 362 | * FECSTATUS bit 7 (0x80) represents the pilot |
| 363 | * selection whilst not tuned. When tuned, actual FEC |
| 364 | * in use is found in FECSTATUS as per above. Pilot |
| 365 | * value is reset. |
| 366 | */ |
| 367 | |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 368 | /* A table of modulation, fec and configuration bytes for the demod. |
| 369 | * Not all S2 mmodulation schemes are support and not all rates with |
| 370 | * a scheme are support. Especially, no auto detect when in S2 mode. |
| 371 | */ |
| 372 | struct cx24116_modfec { |
Steven Toth | 0a6393a | 2008-10-06 21:06:48 -0300 | [diff] [blame] | 373 | fe_delivery_system_t delivery_system; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 374 | fe_modulation_t modulation; |
| 375 | fe_code_rate_t fec; |
| 376 | u8 mask; /* In DVBS mode this is used to autodetect */ |
| 377 | u8 val; /* Passed to the firmware to indicate mode selection */ |
| 378 | } CX24116_MODFEC_MODES[] = { |
| 379 | /* QPSK. For unknown rates we set hardware to auto detect 0xfe 0x30 */ |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 380 | |
| 381 | /*mod fec mask val */ |
Steven Toth | 0a6393a | 2008-10-06 21:06:48 -0300 | [diff] [blame] | 382 | { SYS_DVBS, QPSK, FEC_NONE, 0xfe, 0x30 }, |
| 383 | { SYS_DVBS, QPSK, FEC_1_2, 0x02, 0x2e }, /* 00000010 00101110 */ |
| 384 | { SYS_DVBS, QPSK, FEC_2_3, 0x04, 0x2f }, /* 00000100 00101111 */ |
| 385 | { SYS_DVBS, QPSK, FEC_3_4, 0x08, 0x30 }, /* 00001000 00110000 */ |
| 386 | { SYS_DVBS, QPSK, FEC_4_5, 0xfe, 0x30 }, /* 000?0000 ? */ |
| 387 | { SYS_DVBS, QPSK, FEC_5_6, 0x20, 0x31 }, /* 00100000 00110001 */ |
| 388 | { SYS_DVBS, QPSK, FEC_6_7, 0xfe, 0x30 }, /* 0?000000 ? */ |
| 389 | { SYS_DVBS, QPSK, FEC_7_8, 0x80, 0x32 }, /* 10000000 00110010 */ |
| 390 | { SYS_DVBS, QPSK, FEC_8_9, 0xfe, 0x30 }, /* 0000000? ? */ |
| 391 | { SYS_DVBS, QPSK, FEC_AUTO, 0xfe, 0x30 }, |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 392 | /* NBC-QPSK */ |
Steven Toth | 0a6393a | 2008-10-06 21:06:48 -0300 | [diff] [blame] | 393 | { SYS_DVBS2, QPSK, FEC_1_2, 0x00, 0x04 }, |
| 394 | { SYS_DVBS2, QPSK, FEC_3_5, 0x00, 0x05 }, |
| 395 | { SYS_DVBS2, QPSK, FEC_2_3, 0x00, 0x06 }, |
| 396 | { SYS_DVBS2, QPSK, FEC_3_4, 0x00, 0x07 }, |
| 397 | { SYS_DVBS2, QPSK, FEC_4_5, 0x00, 0x08 }, |
| 398 | { SYS_DVBS2, QPSK, FEC_5_6, 0x00, 0x09 }, |
| 399 | { SYS_DVBS2, QPSK, FEC_8_9, 0x00, 0x0a }, |
| 400 | { SYS_DVBS2, QPSK, FEC_9_10, 0x00, 0x0b }, |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 401 | /* 8PSK */ |
Steven Toth | 0a6393a | 2008-10-06 21:06:48 -0300 | [diff] [blame] | 402 | { SYS_DVBS2, PSK_8, FEC_3_5, 0x00, 0x0c }, |
| 403 | { SYS_DVBS2, PSK_8, FEC_2_3, 0x00, 0x0d }, |
| 404 | { SYS_DVBS2, PSK_8, FEC_3_4, 0x00, 0x0e }, |
| 405 | { SYS_DVBS2, PSK_8, FEC_5_6, 0x00, 0x0f }, |
| 406 | { SYS_DVBS2, PSK_8, FEC_8_9, 0x00, 0x10 }, |
| 407 | { SYS_DVBS2, PSK_8, FEC_9_10, 0x00, 0x11 }, |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 408 | /* |
| 409 | * `val' can be found in the FECSTATUS register when tuning. |
| 410 | * FECSTATUS will give the actual FEC in use if tuning was successful. |
| 411 | */ |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 412 | }; |
| 413 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 414 | static int cx24116_lookup_fecmod(struct cx24116_state *state, |
Darron Broad | 3569476 | 2008-12-18 06:21:51 -0300 | [diff] [blame^] | 415 | fe_delivery_system_t d, fe_modulation_t m, fe_code_rate_t f) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 416 | { |
| 417 | int i, ret = -EOPNOTSUPP; |
| 418 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 419 | dprintk("%s(0x%02x,0x%02x)\n", __func__, m, f); |
| 420 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 421 | for (i = 0; i < ARRAY_SIZE(CX24116_MODFEC_MODES); i++) { |
Darron Broad | 3569476 | 2008-12-18 06:21:51 -0300 | [diff] [blame^] | 422 | if ((d == CX24116_MODFEC_MODES[i].delivery_system) && |
| 423 | (m == CX24116_MODFEC_MODES[i].modulation) && |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 424 | (f == CX24116_MODFEC_MODES[i].fec)) { |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 425 | ret = i; |
| 426 | break; |
| 427 | } |
| 428 | } |
| 429 | |
| 430 | return ret; |
| 431 | } |
| 432 | |
Steven Toth | 98c9482 | 2008-10-16 20:24:42 -0300 | [diff] [blame] | 433 | static int cx24116_set_fec(struct cx24116_state *state, |
Darron Broad | 3569476 | 2008-12-18 06:21:51 -0300 | [diff] [blame^] | 434 | fe_delivery_system_t delsys, fe_modulation_t mod, fe_code_rate_t fec) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 435 | { |
| 436 | int ret = 0; |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 437 | |
| 438 | dprintk("%s(0x%02x,0x%02x)\n", __func__, mod, fec); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 439 | |
Darron Broad | 3569476 | 2008-12-18 06:21:51 -0300 | [diff] [blame^] | 440 | ret = cx24116_lookup_fecmod(state, delsys, mod, fec); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 441 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 442 | if (ret < 0) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 443 | return ret; |
| 444 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 445 | state->dnxt.fec = fec; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 446 | state->dnxt.fec_val = CX24116_MODFEC_MODES[ret].val; |
| 447 | state->dnxt.fec_mask = CX24116_MODFEC_MODES[ret].mask; |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 448 | dprintk("%s() mask/val = 0x%02x/0x%02x\n", __func__, |
| 449 | state->dnxt.fec_mask, state->dnxt.fec_val); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 450 | |
| 451 | return 0; |
| 452 | } |
| 453 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 454 | static int cx24116_set_symbolrate(struct cx24116_state *state, u32 rate) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 455 | { |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 456 | dprintk("%s(%d)\n", __func__, rate); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 457 | |
| 458 | /* check if symbol rate is within limits */ |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 459 | if ((rate > state->frontend.ops.info.symbol_rate_max) || |
| 460 | (rate < state->frontend.ops.info.symbol_rate_min)) { |
| 461 | dprintk("%s() unsupported symbol_rate = %d\n", __func__, rate); |
| 462 | return -EOPNOTSUPP; |
| 463 | } |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 464 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 465 | state->dnxt.symbol_rate = rate; |
| 466 | dprintk("%s() symbol_rate = %d\n", __func__, rate); |
| 467 | |
| 468 | return 0; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 469 | } |
| 470 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 471 | static int cx24116_load_firmware(struct dvb_frontend *fe, |
| 472 | const struct firmware *fw); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 473 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 474 | static int cx24116_firmware_ondemand(struct dvb_frontend *fe) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 475 | { |
| 476 | struct cx24116_state *state = fe->demodulator_priv; |
| 477 | const struct firmware *fw; |
| 478 | int ret = 0; |
| 479 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 480 | dprintk("%s()\n", __func__); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 481 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 482 | if (cx24116_readreg(state, 0x20) > 0) { |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 483 | |
| 484 | if (state->skip_fw_load) |
| 485 | return 0; |
| 486 | |
| 487 | /* Load firmware */ |
Steven Toth | 98c9482 | 2008-10-16 20:24:42 -0300 | [diff] [blame] | 488 | /* request the firmware, this will block until loaded */ |
| 489 | printk(KERN_INFO "%s: Waiting for firmware upload (%s)...\n", |
| 490 | __func__, CX24116_DEFAULT_FIRMWARE); |
| 491 | ret = request_firmware(&fw, CX24116_DEFAULT_FIRMWARE, |
| 492 | &state->i2c->dev); |
| 493 | printk(KERN_INFO "%s: Waiting for firmware upload(2)...\n", |
| 494 | __func__); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 495 | if (ret) { |
Steven Toth | 98c9482 | 2008-10-16 20:24:42 -0300 | [diff] [blame] | 496 | printk(KERN_ERR "%s: No firmware uploaded " |
| 497 | "(timeout or file not found?)\n", __func__); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 498 | return ret; |
| 499 | } |
| 500 | |
Steven Toth | 98c9482 | 2008-10-16 20:24:42 -0300 | [diff] [blame] | 501 | /* Make sure we don't recurse back through here |
| 502 | * during loading */ |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 503 | state->skip_fw_load = 1; |
| 504 | |
| 505 | ret = cx24116_load_firmware(fe, fw); |
| 506 | if (ret) |
Steven Toth | 98c9482 | 2008-10-16 20:24:42 -0300 | [diff] [blame] | 507 | printk(KERN_ERR "%s: Writing firmware to device failed\n", |
| 508 | __func__); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 509 | |
| 510 | release_firmware(fw); |
| 511 | |
Steven Toth | 98c9482 | 2008-10-16 20:24:42 -0300 | [diff] [blame] | 512 | printk(KERN_INFO "%s: Firmware upload %s\n", __func__, |
| 513 | ret == 0 ? "complete" : "failed"); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 514 | |
| 515 | /* Ensure firmware is always loaded if required */ |
| 516 | state->skip_fw_load = 0; |
| 517 | } |
| 518 | |
| 519 | return ret; |
| 520 | } |
| 521 | |
Steven Toth | 98c9482 | 2008-10-16 20:24:42 -0300 | [diff] [blame] | 522 | /* Take a basic firmware command structure, format it |
| 523 | * and forward it for processing |
| 524 | */ |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 525 | static int cx24116_cmd_execute(struct dvb_frontend *fe, struct cx24116_cmd *cmd) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 526 | { |
| 527 | struct cx24116_state *state = fe->demodulator_priv; |
| 528 | int i, ret; |
| 529 | |
| 530 | dprintk("%s()\n", __func__); |
| 531 | |
| 532 | /* Load the firmware if required */ |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 533 | ret = cx24116_firmware_ondemand(fe); |
| 534 | if (ret != 0) { |
Steven Toth | 98c9482 | 2008-10-16 20:24:42 -0300 | [diff] [blame] | 535 | printk(KERN_ERR "%s(): Unable initialise the firmware\n", |
| 536 | __func__); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 537 | return ret; |
| 538 | } |
| 539 | |
| 540 | /* Write the command */ |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 541 | for (i = 0; i < cmd->len ; i++) { |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 542 | dprintk("%s: 0x%02x == 0x%02x\n", __func__, i, cmd->args[i]); |
| 543 | cx24116_writereg(state, i, cmd->args[i]); |
| 544 | } |
| 545 | |
| 546 | /* Start execution and wait for cmd to terminate */ |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 547 | cx24116_writereg(state, CX24116_REG_EXECUTE, 0x01); |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 548 | while (cx24116_readreg(state, CX24116_REG_EXECUTE)) { |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 549 | msleep(10); |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 550 | if (i++ > 64) { |
Steven Toth | 98c9482 | 2008-10-16 20:24:42 -0300 | [diff] [blame] | 551 | /* Avoid looping forever if the firmware does |
| 552 | not respond */ |
| 553 | printk(KERN_WARNING "%s() Firmware not responding\n", |
| 554 | __func__); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 555 | return -EREMOTEIO; |
| 556 | } |
| 557 | } |
| 558 | return 0; |
| 559 | } |
| 560 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 561 | static int cx24116_load_firmware(struct dvb_frontend *fe, |
| 562 | const struct firmware *fw) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 563 | { |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 564 | struct cx24116_state *state = fe->demodulator_priv; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 565 | struct cx24116_cmd cmd; |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 566 | int i, ret; |
| 567 | unsigned char vers[4]; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 568 | |
| 569 | dprintk("%s\n", __func__); |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 570 | dprintk("Firmware is %zu bytes (%02x %02x .. %02x %02x)\n", |
| 571 | fw->size, |
| 572 | fw->data[0], |
| 573 | fw->data[1], |
| 574 | fw->data[fw->size-2], |
| 575 | fw->data[fw->size-1]); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 576 | |
| 577 | /* Toggle 88x SRST pin to reset demod */ |
| 578 | if (state->config->reset_device) |
| 579 | state->config->reset_device(fe); |
| 580 | |
| 581 | /* Begin the firmware load process */ |
| 582 | /* Prepare the demod, load the firmware, cleanup after load */ |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 583 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 584 | /* Init PLL */ |
| 585 | cx24116_writereg(state, 0xE5, 0x00); |
| 586 | cx24116_writereg(state, 0xF1, 0x08); |
| 587 | cx24116_writereg(state, 0xF2, 0x13); |
| 588 | |
| 589 | /* Start PLL */ |
| 590 | cx24116_writereg(state, 0xe0, 0x03); |
| 591 | cx24116_writereg(state, 0xe0, 0x00); |
| 592 | |
| 593 | /* Unknown */ |
| 594 | cx24116_writereg(state, CX24116_REG_CLKDIV, 0x46); |
| 595 | cx24116_writereg(state, CX24116_REG_RATEDIV, 0x00); |
| 596 | |
| 597 | /* Unknown */ |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 598 | cx24116_writereg(state, 0xF0, 0x03); |
| 599 | cx24116_writereg(state, 0xF4, 0x81); |
| 600 | cx24116_writereg(state, 0xF5, 0x00); |
| 601 | cx24116_writereg(state, 0xF6, 0x00); |
| 602 | |
| 603 | /* write the entire firmware as one transaction */ |
| 604 | cx24116_writeregN(state, 0xF7, fw->data, fw->size); |
| 605 | |
| 606 | cx24116_writereg(state, 0xF4, 0x10); |
| 607 | cx24116_writereg(state, 0xF0, 0x00); |
| 608 | cx24116_writereg(state, 0xF8, 0x06); |
| 609 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 610 | /* Firmware CMD 10: VCO config */ |
| 611 | cmd.args[0x00] = CMD_SET_VCO; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 612 | cmd.args[0x01] = 0x05; |
| 613 | cmd.args[0x02] = 0xdc; |
| 614 | cmd.args[0x03] = 0xda; |
| 615 | cmd.args[0x04] = 0xae; |
| 616 | cmd.args[0x05] = 0xaa; |
| 617 | cmd.args[0x06] = 0x04; |
| 618 | cmd.args[0x07] = 0x9d; |
| 619 | cmd.args[0x08] = 0xfc; |
| 620 | cmd.args[0x09] = 0x06; |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 621 | cmd.len = 0x0a; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 622 | ret = cx24116_cmd_execute(fe, &cmd); |
| 623 | if (ret != 0) |
| 624 | return ret; |
| 625 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 626 | cx24116_writereg(state, CX24116_REG_SSTATUS, 0x00); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 627 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 628 | /* Firmware CMD 14: Tuner config */ |
| 629 | cmd.args[0x00] = CMD_TUNERINIT; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 630 | cmd.args[0x01] = 0x00; |
| 631 | cmd.args[0x02] = 0x00; |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 632 | cmd.len = 0x03; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 633 | ret = cx24116_cmd_execute(fe, &cmd); |
| 634 | if (ret != 0) |
| 635 | return ret; |
| 636 | |
| 637 | cx24116_writereg(state, 0xe5, 0x00); |
| 638 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 639 | /* Firmware CMD 13: MPEG config */ |
| 640 | cmd.args[0x00] = CMD_MPEGCONFIG; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 641 | cmd.args[0x01] = 0x01; |
| 642 | cmd.args[0x02] = 0x75; |
| 643 | cmd.args[0x03] = 0x00; |
Igor M. Liplianin | cc8c4f3 | 2008-09-09 13:57:47 -0300 | [diff] [blame] | 644 | if (state->config->mpg_clk_pos_pol) |
| 645 | cmd.args[0x04] = state->config->mpg_clk_pos_pol; |
| 646 | else |
| 647 | cmd.args[0x04] = 0x02; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 648 | cmd.args[0x05] = 0x00; |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 649 | cmd.len = 0x06; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 650 | ret = cx24116_cmd_execute(fe, &cmd); |
| 651 | if (ret != 0) |
| 652 | return ret; |
| 653 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 654 | /* Firmware CMD 35: Get firmware version */ |
| 655 | cmd.args[0x00] = CMD_UPDFWVERS; |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 656 | cmd.len = 0x02; |
| 657 | for (i = 0; i < 4; i++) { |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 658 | cmd.args[0x01] = i; |
| 659 | ret = cx24116_cmd_execute(fe, &cmd); |
| 660 | if (ret != 0) |
| 661 | return ret; |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 662 | vers[i] = cx24116_readreg(state, CX24116_REG_MAILBOX); |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 663 | } |
Steven Toth | 98c9482 | 2008-10-16 20:24:42 -0300 | [diff] [blame] | 664 | printk(KERN_INFO "%s: FW version %i.%i.%i.%i\n", __func__, |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 665 | vers[0], vers[1], vers[2], vers[3]); |
| 666 | |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 667 | return 0; |
| 668 | } |
| 669 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 670 | static int cx24116_set_voltage(struct dvb_frontend *fe, |
| 671 | fe_sec_voltage_t voltage) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 672 | { |
| 673 | /* The isl6421 module will override this function in the fops. */ |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 674 | dprintk("%s() This should never appear if the isl6421 module " |
| 675 | "is loaded correctly\n", __func__); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 676 | |
| 677 | return -EOPNOTSUPP; |
| 678 | } |
| 679 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 680 | static int cx24116_read_status(struct dvb_frontend *fe, fe_status_t *status) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 681 | { |
| 682 | struct cx24116_state *state = fe->demodulator_priv; |
| 683 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 684 | int lock = cx24116_readreg(state, CX24116_REG_SSTATUS); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 685 | |
| 686 | dprintk("%s: status = 0x%02x\n", __func__, lock); |
| 687 | |
| 688 | *status = 0; |
| 689 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 690 | if (lock & CX24116_HAS_SIGNAL) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 691 | *status |= FE_HAS_SIGNAL; |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 692 | if (lock & CX24116_HAS_CARRIER) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 693 | *status |= FE_HAS_CARRIER; |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 694 | if (lock & CX24116_HAS_VITERBI) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 695 | *status |= FE_HAS_VITERBI; |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 696 | if (lock & CX24116_HAS_SYNCLOCK) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 697 | *status |= FE_HAS_SYNC | FE_HAS_LOCK; |
| 698 | |
| 699 | return 0; |
| 700 | } |
| 701 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 702 | static int cx24116_read_ber(struct dvb_frontend *fe, u32 *ber) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 703 | { |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 704 | struct cx24116_state *state = fe->demodulator_priv; |
| 705 | |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 706 | dprintk("%s()\n", __func__); |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 707 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 708 | *ber = (cx24116_readreg(state, CX24116_REG_BER24) << 24) | |
| 709 | (cx24116_readreg(state, CX24116_REG_BER16) << 16) | |
| 710 | (cx24116_readreg(state, CX24116_REG_BER8) << 8) | |
| 711 | cx24116_readreg(state, CX24116_REG_BER0); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 712 | |
| 713 | return 0; |
| 714 | } |
| 715 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 716 | /* TODO Determine function and scale appropriately */ |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 717 | static int cx24116_read_signal_strength(struct dvb_frontend *fe, |
| 718 | u16 *signal_strength) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 719 | { |
| 720 | struct cx24116_state *state = fe->demodulator_priv; |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 721 | struct cx24116_cmd cmd; |
| 722 | int ret; |
| 723 | u16 sig_reading; |
| 724 | |
| 725 | dprintk("%s()\n", __func__); |
| 726 | |
| 727 | /* Firmware CMD 19: Get AGC */ |
| 728 | cmd.args[0x00] = CMD_GETAGC; |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 729 | cmd.len = 0x01; |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 730 | ret = cx24116_cmd_execute(fe, &cmd); |
| 731 | if (ret != 0) |
| 732 | return ret; |
| 733 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 734 | sig_reading = |
| 735 | (cx24116_readreg(state, |
| 736 | CX24116_REG_SSTATUS) & CX24116_SIGNAL_MASK) | |
| 737 | (cx24116_readreg(state, CX24116_REG_SIGNAL) << 6); |
| 738 | *signal_strength = 0 - sig_reading; |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 739 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 740 | dprintk("%s: raw / cooked = 0x%04x / 0x%04x\n", |
| 741 | __func__, sig_reading, *signal_strength); |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 742 | |
| 743 | return 0; |
| 744 | } |
| 745 | |
| 746 | /* SNR (0..100)% = (sig & 0xf0) * 10 + (sig & 0x0f) * 10 / 16 */ |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 747 | static int cx24116_read_snr_pct(struct dvb_frontend *fe, u16 *snr) |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 748 | { |
| 749 | struct cx24116_state *state = fe->demodulator_priv; |
| 750 | u8 snr_reading; |
| 751 | static const u32 snr_tab[] = { /* 10 x Table (rounded up) */ |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 752 | 0x00000, 0x0199A, 0x03333, 0x04ccD, 0x06667, |
| 753 | 0x08000, 0x0999A, 0x0b333, 0x0cccD, 0x0e667, |
| 754 | 0x10000, 0x1199A, 0x13333, 0x14ccD, 0x16667, |
| 755 | 0x18000 }; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 756 | |
| 757 | dprintk("%s()\n", __func__); |
| 758 | |
Steven Toth | 8953db7 | 2008-10-06 21:20:21 -0300 | [diff] [blame] | 759 | snr_reading = cx24116_readreg(state, CX24116_REG_QUALITY0); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 760 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 761 | if (snr_reading >= 0xa0 /* 100% */) |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 762 | *snr = 0xffff; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 763 | else |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 764 | *snr = snr_tab[(snr_reading & 0xf0) >> 4] + |
| 765 | (snr_tab[(snr_reading & 0x0f)] >> 4); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 766 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 767 | dprintk("%s: raw / cooked = 0x%02x / 0x%04x\n", __func__, |
| 768 | snr_reading, *snr); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 769 | |
| 770 | return 0; |
| 771 | } |
| 772 | |
Steven Toth | 8953db7 | 2008-10-06 21:20:21 -0300 | [diff] [blame] | 773 | /* The reelbox patches show the value in the registers represents |
| 774 | * ESNO, from 0->30db (values 0->300). We provide this value by |
| 775 | * default. |
| 776 | */ |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 777 | static int cx24116_read_snr_esno(struct dvb_frontend *fe, u16 *snr) |
Steven Toth | 8953db7 | 2008-10-06 21:20:21 -0300 | [diff] [blame] | 778 | { |
| 779 | struct cx24116_state *state = fe->demodulator_priv; |
| 780 | |
| 781 | dprintk("%s()\n", __func__); |
| 782 | |
| 783 | *snr = cx24116_readreg(state, CX24116_REG_QUALITY8) << 8 | |
| 784 | cx24116_readreg(state, CX24116_REG_QUALITY0); |
| 785 | |
| 786 | dprintk("%s: raw 0x%04x\n", __func__, *snr); |
| 787 | |
| 788 | return 0; |
| 789 | } |
| 790 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 791 | static int cx24116_read_snr(struct dvb_frontend *fe, u16 *snr) |
Steven Toth | 8953db7 | 2008-10-06 21:20:21 -0300 | [diff] [blame] | 792 | { |
| 793 | if (esno_snr == 1) |
| 794 | return cx24116_read_snr_esno(fe, snr); |
| 795 | else |
| 796 | return cx24116_read_snr_pct(fe, snr); |
| 797 | } |
| 798 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 799 | static int cx24116_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 800 | { |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 801 | struct cx24116_state *state = fe->demodulator_priv; |
| 802 | |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 803 | dprintk("%s()\n", __func__); |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 804 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 805 | *ucblocks = (cx24116_readreg(state, CX24116_REG_UCB8) << 8) | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 806 | cx24116_readreg(state, CX24116_REG_UCB0); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 807 | |
| 808 | return 0; |
| 809 | } |
| 810 | |
| 811 | /* Overwrite the current tuning params, we are about to tune */ |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 812 | static void cx24116_clone_params(struct dvb_frontend *fe) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 813 | { |
| 814 | struct cx24116_state *state = fe->demodulator_priv; |
| 815 | memcpy(&state->dcur, &state->dnxt, sizeof(state->dcur)); |
| 816 | } |
| 817 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 818 | /* Wait for LNB */ |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 819 | static int cx24116_wait_for_lnb(struct dvb_frontend *fe) |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 820 | { |
| 821 | struct cx24116_state *state = fe->demodulator_priv; |
| 822 | int i; |
| 823 | |
| 824 | dprintk("%s() qstatus = 0x%02x\n", __func__, |
| 825 | cx24116_readreg(state, CX24116_REG_QSTATUS)); |
| 826 | |
| 827 | /* Wait for up to 300 ms */ |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 828 | for (i = 0; i < 30 ; i++) { |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 829 | if (cx24116_readreg(state, CX24116_REG_QSTATUS) & 0x20) |
| 830 | return 0; |
| 831 | msleep(10); |
| 832 | } |
| 833 | |
| 834 | dprintk("%s(): LNB not ready\n", __func__); |
| 835 | |
| 836 | return -ETIMEDOUT; /* -EBUSY ? */ |
| 837 | } |
| 838 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 839 | static int cx24116_set_tone(struct dvb_frontend *fe, |
| 840 | fe_sec_tone_mode_t tone) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 841 | { |
| 842 | struct cx24116_cmd cmd; |
| 843 | int ret; |
| 844 | |
| 845 | dprintk("%s(%d)\n", __func__, tone); |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 846 | if ((tone != SEC_TONE_ON) && (tone != SEC_TONE_OFF)) { |
Steven Toth | 98c9482 | 2008-10-16 20:24:42 -0300 | [diff] [blame] | 847 | printk(KERN_ERR "%s: Invalid, tone=%d\n", __func__, tone); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 848 | return -EINVAL; |
| 849 | } |
| 850 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 851 | /* Wait for LNB ready */ |
| 852 | ret = cx24116_wait_for_lnb(fe); |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 853 | if (ret != 0) |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 854 | return ret; |
| 855 | |
| 856 | /* Min delay time after DiSEqC send */ |
| 857 | msleep(15); /* XXX determine is FW does this, see send_diseqc/burst */ |
| 858 | |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 859 | /* This is always done before the tone is set */ |
| 860 | cmd.args[0x00] = CMD_SET_TONEPRE; |
| 861 | cmd.args[0x01] = 0x00; |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 862 | cmd.len = 0x02; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 863 | ret = cx24116_cmd_execute(fe, &cmd); |
| 864 | if (ret != 0) |
| 865 | return ret; |
| 866 | |
| 867 | /* Now we set the tone */ |
| 868 | cmd.args[0x00] = CMD_SET_TONE; |
| 869 | cmd.args[0x01] = 0x00; |
| 870 | cmd.args[0x02] = 0x00; |
| 871 | |
| 872 | switch (tone) { |
| 873 | case SEC_TONE_ON: |
| 874 | dprintk("%s: setting tone on\n", __func__); |
| 875 | cmd.args[0x03] = 0x01; |
| 876 | break; |
| 877 | case SEC_TONE_OFF: |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 878 | dprintk("%s: setting tone off\n", __func__); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 879 | cmd.args[0x03] = 0x00; |
| 880 | break; |
| 881 | } |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 882 | cmd.len = 0x04; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 883 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 884 | /* Min delay time before DiSEqC send */ |
| 885 | msleep(15); /* XXX determine is FW does this, see send_diseqc/burst */ |
| 886 | |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 887 | return cx24116_cmd_execute(fe, &cmd); |
| 888 | } |
| 889 | |
| 890 | /* Initialise DiSEqC */ |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 891 | static int cx24116_diseqc_init(struct dvb_frontend *fe) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 892 | { |
| 893 | struct cx24116_state *state = fe->demodulator_priv; |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 894 | struct cx24116_cmd cmd; |
| 895 | int ret; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 896 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 897 | /* Firmware CMD 20: LNB/DiSEqC config */ |
| 898 | cmd.args[0x00] = CMD_LNBCONFIG; |
| 899 | cmd.args[0x01] = 0x00; |
| 900 | cmd.args[0x02] = 0x10; |
| 901 | cmd.args[0x03] = 0x00; |
| 902 | cmd.args[0x04] = 0x8f; |
| 903 | cmd.args[0x05] = 0x28; |
| 904 | cmd.args[0x06] = (toneburst == CX24116_DISEQC_TONEOFF) ? 0x00 : 0x01; |
| 905 | cmd.args[0x07] = 0x01; |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 906 | cmd.len = 0x08; |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 907 | ret = cx24116_cmd_execute(fe, &cmd); |
| 908 | if (ret != 0) |
| 909 | return ret; |
| 910 | |
| 911 | /* Prepare a DiSEqC command */ |
| 912 | state->dsec_cmd.args[0x00] = CMD_LNBSEND; |
| 913 | |
| 914 | /* DiSEqC burst */ |
| 915 | state->dsec_cmd.args[CX24116_DISEQC_BURST] = CX24116_DISEQC_MINI_A; |
| 916 | |
| 917 | /* Unknown */ |
| 918 | state->dsec_cmd.args[CX24116_DISEQC_ARG2_2] = 0x02; |
| 919 | state->dsec_cmd.args[CX24116_DISEQC_ARG3_0] = 0x00; |
Steven Toth | 98c9482 | 2008-10-16 20:24:42 -0300 | [diff] [blame] | 920 | /* Continuation flag? */ |
| 921 | state->dsec_cmd.args[CX24116_DISEQC_ARG4_0] = 0x00; |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 922 | |
| 923 | /* DiSEqC message length */ |
| 924 | state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] = 0x00; |
| 925 | |
| 926 | /* Command length */ |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 927 | state->dsec_cmd.len = CX24116_DISEQC_MSGOFS; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 928 | |
| 929 | return 0; |
| 930 | } |
| 931 | |
| 932 | /* Send DiSEqC message with derived burst (hack) || previous burst */ |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 933 | static int cx24116_send_diseqc_msg(struct dvb_frontend *fe, |
| 934 | struct dvb_diseqc_master_cmd *d) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 935 | { |
| 936 | struct cx24116_state *state = fe->demodulator_priv; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 937 | int i, ret; |
| 938 | |
| 939 | /* Dump DiSEqC message */ |
| 940 | if (debug) { |
Steven Toth | 98c9482 | 2008-10-16 20:24:42 -0300 | [diff] [blame] | 941 | printk(KERN_INFO "cx24116: %s(", __func__); |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 942 | for (i = 0 ; i < d->msg_len ;) { |
Steven Toth | 98c9482 | 2008-10-16 20:24:42 -0300 | [diff] [blame] | 943 | printk(KERN_INFO "0x%02x", d->msg[i]); |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 944 | if (++i < d->msg_len) |
Steven Toth | 98c9482 | 2008-10-16 20:24:42 -0300 | [diff] [blame] | 945 | printk(KERN_INFO ", "); |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 946 | } |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 947 | printk(") toneburst=%d\n", toneburst); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 948 | } |
| 949 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 950 | /* Validate length */ |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 951 | if (d->msg_len > (CX24116_ARGLEN - CX24116_DISEQC_MSGOFS)) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 952 | return -EINVAL; |
| 953 | |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 954 | /* DiSEqC message */ |
| 955 | for (i = 0; i < d->msg_len; i++) |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 956 | state->dsec_cmd.args[CX24116_DISEQC_MSGOFS + i] = d->msg[i]; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 957 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 958 | /* DiSEqC message length */ |
| 959 | state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] = d->msg_len; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 960 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 961 | /* Command length */ |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 962 | state->dsec_cmd.len = CX24116_DISEQC_MSGOFS + |
| 963 | state->dsec_cmd.args[CX24116_DISEQC_MSGLEN]; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 964 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 965 | /* DiSEqC toneburst */ |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 966 | if (toneburst == CX24116_DISEQC_MESGCACHE) |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 967 | /* Message is cached */ |
| 968 | return 0; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 969 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 970 | else if (toneburst == CX24116_DISEQC_TONEOFF) |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 971 | /* Message is sent without burst */ |
| 972 | state->dsec_cmd.args[CX24116_DISEQC_BURST] = 0; |
| 973 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 974 | else if (toneburst == CX24116_DISEQC_TONECACHE) { |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 975 | /* |
| 976 | * Message is sent with derived else cached burst |
| 977 | * |
| 978 | * WRITE PORT GROUP COMMAND 38 |
| 979 | * |
| 980 | * 0/A/A: E0 10 38 F0..F3 |
| 981 | * 1/B/B: E0 10 38 F4..F7 |
| 982 | * 2/C/A: E0 10 38 F8..FB |
| 983 | * 3/D/B: E0 10 38 FC..FF |
| 984 | * |
Darron Broad | 7396d3e | 2008-09-14 10:45:58 -0300 | [diff] [blame] | 985 | * databyte[3]= 8421:8421 |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 986 | * ABCD:WXYZ |
| 987 | * CLR :SET |
| 988 | * |
| 989 | * WX= PORT SELECT 0..3 (X=TONEBURST) |
| 990 | * Y = VOLTAGE (0=13V, 1=18V) |
| 991 | * Z = BAND (0=LOW, 1=HIGH(22K)) |
| 992 | */ |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 993 | if (d->msg_len >= 4 && d->msg[2] == 0x38) |
| 994 | state->dsec_cmd.args[CX24116_DISEQC_BURST] = |
| 995 | ((d->msg[3] & 4) >> 2); |
| 996 | if (debug) |
| 997 | dprintk("%s burst=%d\n", __func__, |
| 998 | state->dsec_cmd.args[CX24116_DISEQC_BURST]); |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 999 | } |
| 1000 | |
| 1001 | /* Wait for LNB ready */ |
| 1002 | ret = cx24116_wait_for_lnb(fe); |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1003 | if (ret != 0) |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1004 | return ret; |
| 1005 | |
| 1006 | /* Wait for voltage/min repeat delay */ |
| 1007 | msleep(100); |
| 1008 | |
| 1009 | /* Command */ |
| 1010 | ret = cx24116_cmd_execute(fe, &state->dsec_cmd); |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1011 | if (ret != 0) |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1012 | return ret; |
| 1013 | /* |
| 1014 | * Wait for send |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1015 | * |
| 1016 | * Eutelsat spec: |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1017 | * >15ms delay + (XXX determine if FW does this, see set_tone) |
| 1018 | * 13.5ms per byte + |
| 1019 | * >15ms delay + |
| 1020 | * 12.5ms burst + |
| 1021 | * >15ms delay (XXX determine if FW does this, see set_tone) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1022 | */ |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1023 | msleep((state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] << 4) + |
| 1024 | ((toneburst == CX24116_DISEQC_TONEOFF) ? 30 : 60)); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1025 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1026 | return 0; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1027 | } |
| 1028 | |
| 1029 | /* Send DiSEqC burst */ |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1030 | static int cx24116_diseqc_send_burst(struct dvb_frontend *fe, |
| 1031 | fe_sec_mini_cmd_t burst) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1032 | { |
| 1033 | struct cx24116_state *state = fe->demodulator_priv; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1034 | int ret; |
| 1035 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1036 | dprintk("%s(%d) toneburst=%d\n", __func__, burst, toneburst); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1037 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1038 | /* DiSEqC burst */ |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1039 | if (burst == SEC_MINI_A) |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1040 | state->dsec_cmd.args[CX24116_DISEQC_BURST] = |
| 1041 | CX24116_DISEQC_MINI_A; |
| 1042 | else if (burst == SEC_MINI_B) |
| 1043 | state->dsec_cmd.args[CX24116_DISEQC_BURST] = |
| 1044 | CX24116_DISEQC_MINI_B; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1045 | else |
| 1046 | return -EINVAL; |
| 1047 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1048 | /* DiSEqC toneburst */ |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1049 | if (toneburst != CX24116_DISEQC_MESGCACHE) |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1050 | /* Burst is cached */ |
| 1051 | return 0; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1052 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1053 | /* Burst is to be sent with cached message */ |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1054 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1055 | /* Wait for LNB ready */ |
| 1056 | ret = cx24116_wait_for_lnb(fe); |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1057 | if (ret != 0) |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1058 | return ret; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1059 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1060 | /* Wait for voltage/min repeat delay */ |
| 1061 | msleep(100); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1062 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1063 | /* Command */ |
| 1064 | ret = cx24116_cmd_execute(fe, &state->dsec_cmd); |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1065 | if (ret != 0) |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1066 | return ret; |
| 1067 | |
| 1068 | /* |
| 1069 | * Wait for send |
| 1070 | * |
| 1071 | * Eutelsat spec: |
| 1072 | * >15ms delay + (XXX determine if FW does this, see set_tone) |
| 1073 | * 13.5ms per byte + |
| 1074 | * >15ms delay + |
| 1075 | * 12.5ms burst + |
| 1076 | * >15ms delay (XXX determine if FW does this, see set_tone) |
| 1077 | */ |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1078 | msleep((state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] << 4) + 60); |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1079 | |
| 1080 | return 0; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1081 | } |
| 1082 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1083 | static void cx24116_release(struct dvb_frontend *fe) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1084 | { |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1085 | struct cx24116_state *state = fe->demodulator_priv; |
| 1086 | dprintk("%s\n", __func__); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1087 | kfree(state); |
| 1088 | } |
| 1089 | |
| 1090 | static struct dvb_frontend_ops cx24116_ops; |
| 1091 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1092 | struct dvb_frontend *cx24116_attach(const struct cx24116_config *config, |
| 1093 | struct i2c_adapter *i2c) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1094 | { |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1095 | struct cx24116_state *state = NULL; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1096 | int ret; |
| 1097 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1098 | dprintk("%s\n", __func__); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1099 | |
| 1100 | /* allocate memory for the internal state */ |
| 1101 | state = kmalloc(sizeof(struct cx24116_state), GFP_KERNEL); |
Steven Toth | 98c9482 | 2008-10-16 20:24:42 -0300 | [diff] [blame] | 1102 | if (state == NULL) |
Darron Broad | 7396d3e | 2008-09-14 10:45:58 -0300 | [diff] [blame] | 1103 | goto error1; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1104 | |
| 1105 | /* setup the state */ |
| 1106 | memset(state, 0, sizeof(struct cx24116_state)); |
| 1107 | |
| 1108 | state->config = config; |
| 1109 | state->i2c = i2c; |
| 1110 | |
| 1111 | /* check if the demod is present */ |
Steven Toth | 98c9482 | 2008-10-16 20:24:42 -0300 | [diff] [blame] | 1112 | ret = (cx24116_readreg(state, 0xFF) << 8) | |
| 1113 | cx24116_readreg(state, 0xFE); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1114 | if (ret != 0x0501) { |
Steven Toth | 98c9482 | 2008-10-16 20:24:42 -0300 | [diff] [blame] | 1115 | printk(KERN_INFO "Invalid probe, probably not a CX24116 device\n"); |
Darron Broad | 7396d3e | 2008-09-14 10:45:58 -0300 | [diff] [blame] | 1116 | goto error2; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1117 | } |
| 1118 | |
| 1119 | /* create dvb_frontend */ |
Steven Toth | 98c9482 | 2008-10-16 20:24:42 -0300 | [diff] [blame] | 1120 | memcpy(&state->frontend.ops, &cx24116_ops, |
| 1121 | sizeof(struct dvb_frontend_ops)); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1122 | state->frontend.demodulator_priv = state; |
| 1123 | return &state->frontend; |
| 1124 | |
Darron Broad | 7396d3e | 2008-09-14 10:45:58 -0300 | [diff] [blame] | 1125 | error2: kfree(state); |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1126 | error1: return NULL; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1127 | } |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1128 | EXPORT_SYMBOL(cx24116_attach); |
| 1129 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1130 | /* |
| 1131 | * Initialise or wake up device |
| 1132 | * |
| 1133 | * Power config will reset and load initial firmware if required |
| 1134 | */ |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1135 | static int cx24116_initfe(struct dvb_frontend *fe) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1136 | { |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1137 | struct cx24116_state *state = fe->demodulator_priv; |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1138 | struct cx24116_cmd cmd; |
| 1139 | int ret; |
| 1140 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1141 | dprintk("%s()\n", __func__); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1142 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1143 | /* Power on */ |
| 1144 | cx24116_writereg(state, 0xe0, 0); |
| 1145 | cx24116_writereg(state, 0xe1, 0); |
| 1146 | cx24116_writereg(state, 0xea, 0); |
| 1147 | |
| 1148 | /* Firmware CMD 36: Power config */ |
| 1149 | cmd.args[0x00] = CMD_TUNERSLEEP; |
| 1150 | cmd.args[0x01] = 0; |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1151 | cmd.len = 0x02; |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1152 | ret = cx24116_cmd_execute(fe, &cmd); |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1153 | if (ret != 0) |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1154 | return ret; |
| 1155 | |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1156 | return cx24116_diseqc_init(fe); |
| 1157 | } |
| 1158 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1159 | /* |
| 1160 | * Put device to sleep |
| 1161 | */ |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1162 | static int cx24116_sleep(struct dvb_frontend *fe) |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1163 | { |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1164 | struct cx24116_state *state = fe->demodulator_priv; |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1165 | struct cx24116_cmd cmd; |
| 1166 | int ret; |
| 1167 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1168 | dprintk("%s()\n", __func__); |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1169 | |
| 1170 | /* Firmware CMD 36: Power config */ |
| 1171 | cmd.args[0x00] = CMD_TUNERSLEEP; |
| 1172 | cmd.args[0x01] = 1; |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1173 | cmd.len = 0x02; |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1174 | ret = cx24116_cmd_execute(fe, &cmd); |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1175 | if (ret != 0) |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1176 | return ret; |
| 1177 | |
| 1178 | /* Power off (Shutdown clocks) */ |
| 1179 | cx24116_writereg(state, 0xea, 0xff); |
| 1180 | cx24116_writereg(state, 0xe1, 1); |
| 1181 | cx24116_writereg(state, 0xe0, 1); |
| 1182 | |
| 1183 | return 0; |
| 1184 | } |
| 1185 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1186 | static int cx24116_set_property(struct dvb_frontend *fe, |
| 1187 | struct dtv_property *tvp) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1188 | { |
| 1189 | dprintk("%s(..)\n", __func__); |
| 1190 | return 0; |
| 1191 | } |
| 1192 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1193 | static int cx24116_get_property(struct dvb_frontend *fe, |
| 1194 | struct dtv_property *tvp) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1195 | { |
Steven Toth | bfbf2da | 2008-09-12 01:37:37 -0300 | [diff] [blame] | 1196 | dprintk("%s(..)\n", __func__); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1197 | return 0; |
| 1198 | } |
| 1199 | |
| 1200 | /* dvb-core told us to tune, the tv property cache will be complete, |
| 1201 | * it's safe for is to pull values and use them for tuning purposes. |
| 1202 | */ |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1203 | static int cx24116_set_frontend(struct dvb_frontend *fe, |
| 1204 | struct dvb_frontend_parameters *p) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1205 | { |
| 1206 | struct cx24116_state *state = fe->demodulator_priv; |
Steven Toth | 56f0680 | 2008-09-11 10:19:27 -0300 | [diff] [blame] | 1207 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1208 | struct cx24116_cmd cmd; |
| 1209 | fe_status_t tunerstat; |
Darron Broad | 01a8f03 | 2008-10-03 11:47:46 -0300 | [diff] [blame] | 1210 | int i, status, ret, retune; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1211 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1212 | dprintk("%s()\n", __func__); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1213 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1214 | switch (c->delivery_system) { |
| 1215 | case SYS_DVBS: |
| 1216 | dprintk("%s: DVB-S delivery system selected\n", __func__); |
Darron Broad | 01a8f03 | 2008-10-03 11:47:46 -0300 | [diff] [blame] | 1217 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1218 | /* Only QPSK is supported for DVB-S */ |
| 1219 | if (c->modulation != QPSK) { |
| 1220 | dprintk("%s: unsupported modulation selected (%d)\n", |
| 1221 | __func__, c->modulation); |
| 1222 | return -EOPNOTSUPP; |
| 1223 | } |
Darron Broad | 01a8f03 | 2008-10-03 11:47:46 -0300 | [diff] [blame] | 1224 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1225 | /* Pilot doesn't exist in DVB-S, turn bit off */ |
| 1226 | state->dnxt.pilot_val = CX24116_PILOT_OFF; |
| 1227 | retune = 1; |
| 1228 | |
| 1229 | /* DVB-S only supports 0.35 */ |
| 1230 | if (c->rolloff != ROLLOFF_35) { |
| 1231 | dprintk("%s: unsupported rolloff selected (%d)\n", |
| 1232 | __func__, c->rolloff); |
| 1233 | return -EOPNOTSUPP; |
| 1234 | } |
| 1235 | state->dnxt.rolloff_val = CX24116_ROLLOFF_035; |
| 1236 | break; |
| 1237 | |
| 1238 | case SYS_DVBS2: |
| 1239 | dprintk("%s: DVB-S2 delivery system selected\n", __func__); |
| 1240 | |
| 1241 | /* |
| 1242 | * NBC 8PSK/QPSK with DVB-S is supported for DVB-S2, |
| 1243 | * but not hardware auto detection |
| 1244 | */ |
| 1245 | if (c->modulation != PSK_8 && c->modulation != QPSK) { |
| 1246 | dprintk("%s: unsupported modulation selected (%d)\n", |
| 1247 | __func__, c->modulation); |
| 1248 | return -EOPNOTSUPP; |
| 1249 | } |
| 1250 | |
| 1251 | switch (c->pilot) { |
| 1252 | case PILOT_AUTO: /* Not supported but emulated */ |
Christophe Thommeret | 7456321 | 2008-10-15 20:01:32 -0300 | [diff] [blame] | 1253 | state->dnxt.pilot_val = (c->modulation == QPSK) |
| 1254 | ? CX24116_PILOT_OFF : CX24116_PILOT_ON; |
| 1255 | retune = 2; |
| 1256 | break; |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1257 | case PILOT_OFF: |
Darron Broad | 01a8f03 | 2008-10-03 11:47:46 -0300 | [diff] [blame] | 1258 | state->dnxt.pilot_val = CX24116_PILOT_OFF; |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1259 | break; |
| 1260 | case PILOT_ON: |
| 1261 | state->dnxt.pilot_val = CX24116_PILOT_ON; |
| 1262 | break; |
| 1263 | default: |
| 1264 | dprintk("%s: unsupported pilot mode selected (%d)\n", |
| 1265 | __func__, c->pilot); |
| 1266 | return -EOPNOTSUPP; |
| 1267 | } |
Darron Broad | 01a8f03 | 2008-10-03 11:47:46 -0300 | [diff] [blame] | 1268 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1269 | switch (c->rolloff) { |
| 1270 | case ROLLOFF_20: |
| 1271 | state->dnxt.rolloff_val = CX24116_ROLLOFF_020; |
| 1272 | break; |
| 1273 | case ROLLOFF_25: |
| 1274 | state->dnxt.rolloff_val = CX24116_ROLLOFF_025; |
| 1275 | break; |
| 1276 | case ROLLOFF_35: |
Darron Broad | 7396d3e | 2008-09-14 10:45:58 -0300 | [diff] [blame] | 1277 | state->dnxt.rolloff_val = CX24116_ROLLOFF_035; |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1278 | break; |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1279 | case ROLLOFF_AUTO: /* Rolloff must be explicit */ |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1280 | default: |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1281 | dprintk("%s: unsupported rolloff selected (%d)\n", |
| 1282 | __func__, c->rolloff); |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1283 | return -EOPNOTSUPP; |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1284 | } |
| 1285 | break; |
| 1286 | |
| 1287 | default: |
| 1288 | dprintk("%s: unsupported delivery system selected (%d)\n", |
| 1289 | __func__, c->delivery_system); |
| 1290 | return -EOPNOTSUPP; |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1291 | } |
Darron Broad | 3569476 | 2008-12-18 06:21:51 -0300 | [diff] [blame^] | 1292 | state->dnxt.delsys = c->delivery_system; |
Darron Broad | 01a8f03 | 2008-10-03 11:47:46 -0300 | [diff] [blame] | 1293 | state->dnxt.modulation = c->modulation; |
| 1294 | state->dnxt.frequency = c->frequency; |
| 1295 | state->dnxt.pilot = c->pilot; |
| 1296 | state->dnxt.rolloff = c->rolloff; |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1297 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1298 | ret = cx24116_set_inversion(state, c->inversion); |
| 1299 | if (ret != 0) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1300 | return ret; |
| 1301 | |
Darron Broad | 01a8f03 | 2008-10-03 11:47:46 -0300 | [diff] [blame] | 1302 | /* FEC_NONE/AUTO for DVB-S2 is not supported and detected here */ |
Darron Broad | 3569476 | 2008-12-18 06:21:51 -0300 | [diff] [blame^] | 1303 | ret = cx24116_set_fec(state, c->delivery_system, c->modulation, c->fec_inner); |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1304 | if (ret != 0) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1305 | return ret; |
| 1306 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1307 | ret = cx24116_set_symbolrate(state, c->symbol_rate); |
| 1308 | if (ret != 0) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1309 | return ret; |
| 1310 | |
| 1311 | /* discard the 'current' tuning parameters and prepare to tune */ |
| 1312 | cx24116_clone_params(fe); |
| 1313 | |
Darron Broad | 3569476 | 2008-12-18 06:21:51 -0300 | [diff] [blame^] | 1314 | dprintk("%s: delsys = %d\n", __func__, state->dcur.delsys); |
Darron Broad | 01a8f03 | 2008-10-03 11:47:46 -0300 | [diff] [blame] | 1315 | dprintk("%s: modulation = %d\n", __func__, state->dcur.modulation); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1316 | dprintk("%s: frequency = %d\n", __func__, state->dcur.frequency); |
Darron Broad | 01a8f03 | 2008-10-03 11:47:46 -0300 | [diff] [blame] | 1317 | dprintk("%s: pilot = %d (val = 0x%02x)\n", __func__, |
| 1318 | state->dcur.pilot, state->dcur.pilot_val); |
| 1319 | dprintk("%s: retune = %d\n", __func__, retune); |
| 1320 | dprintk("%s: rolloff = %d (val = 0x%02x)\n", __func__, |
| 1321 | state->dcur.rolloff, state->dcur.rolloff_val); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1322 | dprintk("%s: symbol_rate = %d\n", __func__, state->dcur.symbol_rate); |
| 1323 | dprintk("%s: FEC = %d (mask/val = 0x%02x/0x%02x)\n", __func__, |
| 1324 | state->dcur.fec, state->dcur.fec_mask, state->dcur.fec_val); |
| 1325 | dprintk("%s: Inversion = %d (val = 0x%02x)\n", __func__, |
| 1326 | state->dcur.inversion, state->dcur.inversion_val); |
| 1327 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1328 | /* This is also done in advise/acquire on HVR4000 but not on LITE */ |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1329 | if (state->config->set_ts_params) |
| 1330 | state->config->set_ts_params(fe, 0); |
| 1331 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1332 | /* Set/Reset B/W */ |
| 1333 | cmd.args[0x00] = CMD_BANDWIDTH; |
| 1334 | cmd.args[0x01] = 0x01; |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1335 | cmd.len = 0x02; |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1336 | ret = cx24116_cmd_execute(fe, &cmd); |
| 1337 | if (ret != 0) |
| 1338 | return ret; |
Igor M. Liplianin | 3f8e51a | 2008-09-09 13:22:29 -0300 | [diff] [blame] | 1339 | |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1340 | /* Prepare a tune request */ |
| 1341 | cmd.args[0x00] = CMD_TUNEREQUEST; |
| 1342 | |
| 1343 | /* Frequency */ |
| 1344 | cmd.args[0x01] = (state->dcur.frequency & 0xff0000) >> 16; |
| 1345 | cmd.args[0x02] = (state->dcur.frequency & 0x00ff00) >> 8; |
| 1346 | cmd.args[0x03] = (state->dcur.frequency & 0x0000ff); |
| 1347 | |
| 1348 | /* Symbol Rate */ |
| 1349 | cmd.args[0x04] = ((state->dcur.symbol_rate / 1000) & 0xff00) >> 8; |
| 1350 | cmd.args[0x05] = ((state->dcur.symbol_rate / 1000) & 0x00ff); |
| 1351 | |
| 1352 | /* Automatic Inversion */ |
| 1353 | cmd.args[0x06] = state->dcur.inversion_val; |
| 1354 | |
Darron Broad | 01a8f03 | 2008-10-03 11:47:46 -0300 | [diff] [blame] | 1355 | /* Modulation / FEC / Pilot */ |
| 1356 | cmd.args[0x07] = state->dcur.fec_val | state->dcur.pilot_val; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1357 | |
| 1358 | cmd.args[0x08] = CX24116_SEARCH_RANGE_KHZ >> 8; |
| 1359 | cmd.args[0x09] = CX24116_SEARCH_RANGE_KHZ & 0xff; |
| 1360 | cmd.args[0x0a] = 0x00; |
| 1361 | cmd.args[0x0b] = 0x00; |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1362 | cmd.args[0x0c] = state->dcur.rolloff_val; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1363 | cmd.args[0x0d] = state->dcur.fec_mask; |
Igor M. Liplianin | 3f8e51a | 2008-09-09 13:22:29 -0300 | [diff] [blame] | 1364 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1365 | if (state->dcur.symbol_rate > 30000000) { |
Igor M. Liplianin | 3f8e51a | 2008-09-09 13:22:29 -0300 | [diff] [blame] | 1366 | cmd.args[0x0e] = 0x04; |
| 1367 | cmd.args[0x0f] = 0x00; |
| 1368 | cmd.args[0x10] = 0x01; |
| 1369 | cmd.args[0x11] = 0x77; |
| 1370 | cmd.args[0x12] = 0x36; |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1371 | cx24116_writereg(state, CX24116_REG_CLKDIV, 0x44); |
| 1372 | cx24116_writereg(state, CX24116_REG_RATEDIV, 0x01); |
Igor M. Liplianin | 3f8e51a | 2008-09-09 13:22:29 -0300 | [diff] [blame] | 1373 | } else { |
| 1374 | cmd.args[0x0e] = 0x06; |
| 1375 | cmd.args[0x0f] = 0x00; |
| 1376 | cmd.args[0x10] = 0x00; |
| 1377 | cmd.args[0x11] = 0xFA; |
| 1378 | cmd.args[0x12] = 0x24; |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1379 | cx24116_writereg(state, CX24116_REG_CLKDIV, 0x46); |
| 1380 | cx24116_writereg(state, CX24116_REG_RATEDIV, 0x00); |
Igor M. Liplianin | 3f8e51a | 2008-09-09 13:22:29 -0300 | [diff] [blame] | 1381 | } |
| 1382 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1383 | cmd.len = 0x13; |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1384 | |
| 1385 | /* We need to support pilot and non-pilot tuning in the |
| 1386 | * driver automatically. This is a workaround for because |
| 1387 | * the demod does not support autodetect. |
| 1388 | */ |
| 1389 | do { |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1390 | /* Reset status register */ |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1391 | status = cx24116_readreg(state, CX24116_REG_SSTATUS) |
| 1392 | & CX24116_SIGNAL_MASK; |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1393 | cx24116_writereg(state, CX24116_REG_SSTATUS, status); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1394 | |
| 1395 | /* Tune */ |
| 1396 | ret = cx24116_cmd_execute(fe, &cmd); |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1397 | if (ret != 0) |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1398 | break; |
| 1399 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1400 | /* |
| 1401 | * Wait for up to 500 ms before retrying |
| 1402 | * |
| 1403 | * If we are able to tune then generally it occurs within 100ms. |
| 1404 | * If it takes longer, try a different toneburst setting. |
| 1405 | */ |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1406 | for (i = 0; i < 50 ; i++) { |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1407 | cx24116_read_status(fe, &tunerstat); |
| 1408 | status = tunerstat & (FE_HAS_SIGNAL | FE_HAS_SYNC); |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1409 | if (status == (FE_HAS_SIGNAL | FE_HAS_SYNC)) { |
| 1410 | dprintk("%s: Tuned\n", __func__); |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1411 | goto tuned; |
| 1412 | } |
| 1413 | msleep(10); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1414 | } |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1415 | |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1416 | dprintk("%s: Not tuned\n", __func__); |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1417 | |
| 1418 | /* Toggle pilot bit when in auto-pilot */ |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1419 | if (state->dcur.pilot == PILOT_AUTO) |
Darron Broad | 01a8f03 | 2008-10-03 11:47:46 -0300 | [diff] [blame] | 1420 | cmd.args[0x07] ^= CX24116_PILOT_ON; |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1421 | } while (--retune); |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1422 | |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1423 | tuned: /* Set/Reset B/W */ |
| 1424 | cmd.args[0x00] = CMD_BANDWIDTH; |
| 1425 | cmd.args[0x01] = 0x00; |
Steven Toth | f11ec7d | 2008-10-16 20:22:01 -0300 | [diff] [blame] | 1426 | cmd.len = 0x02; |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1427 | ret = cx24116_cmd_execute(fe, &cmd); |
| 1428 | if (ret != 0) |
| 1429 | return ret; |
| 1430 | |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1431 | return ret; |
| 1432 | } |
| 1433 | |
| 1434 | static struct dvb_frontend_ops cx24116_ops = { |
| 1435 | |
| 1436 | .info = { |
| 1437 | .name = "Conexant CX24116/CX24118", |
| 1438 | .type = FE_QPSK, |
| 1439 | .frequency_min = 950000, |
| 1440 | .frequency_max = 2150000, |
| 1441 | .frequency_stepsize = 1011, /* kHz for QPSK frontends */ |
| 1442 | .frequency_tolerance = 5000, |
| 1443 | .symbol_rate_min = 1000000, |
| 1444 | .symbol_rate_max = 45000000, |
| 1445 | .caps = FE_CAN_INVERSION_AUTO | |
| 1446 | FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | |
| 1447 | FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 | |
| 1448 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO | |
| 1449 | FE_CAN_QPSK | FE_CAN_RECOVER |
| 1450 | }, |
| 1451 | |
| 1452 | .release = cx24116_release, |
| 1453 | |
| 1454 | .init = cx24116_initfe, |
Darron Broad | 490c868 | 2008-09-13 19:42:16 -0300 | [diff] [blame] | 1455 | .sleep = cx24116_sleep, |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1456 | .read_status = cx24116_read_status, |
| 1457 | .read_ber = cx24116_read_ber, |
| 1458 | .read_signal_strength = cx24116_read_signal_strength, |
| 1459 | .read_snr = cx24116_read_snr, |
| 1460 | .read_ucblocks = cx24116_read_ucblocks, |
| 1461 | .set_tone = cx24116_set_tone, |
| 1462 | .set_voltage = cx24116_set_voltage, |
| 1463 | .diseqc_send_master_cmd = cx24116_send_diseqc_msg, |
| 1464 | .diseqc_send_burst = cx24116_diseqc_send_burst, |
| 1465 | |
| 1466 | .set_property = cx24116_set_property, |
Steven Toth | bfbf2da | 2008-09-12 01:37:37 -0300 | [diff] [blame] | 1467 | .get_property = cx24116_get_property, |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1468 | .set_frontend = cx24116_set_frontend, |
| 1469 | }; |
| 1470 | |
Steven Toth | 0d46748 | 2008-09-04 01:14:43 -0300 | [diff] [blame] | 1471 | MODULE_DESCRIPTION("DVB Frontend module for Conexant cx24116/cx24118 hardware"); |
| 1472 | MODULE_AUTHOR("Steven Toth"); |
| 1473 | MODULE_LICENSE("GPL"); |
| 1474 | |