• Home
  • Raw
  • Download

Lines Matching +full:max +full:- +full:burst +full:- +full:len

2     Conexant cx24116/cx24118 - DVBS/S2 Satellite demod/tuner driver
4 Copyright (C) 2006-2008 Steven Toth <stoth@hauppauge.com>
5 Copyright (C) 2006-2007 Georg Acher
6 Copyright (C) 2007-2008 Darron Broad
57 #define CX24116_DEFAULT_FIRMWARE "dvb-fe-cx24116.fw"
86 /* Select DVB-S demodulator, else DVB-S2 */
127 /* DiSEqC burst */
131 /* DiSEqC tone burst */
140 MODULE_PARM_DESC(esno_snr, "SNR return units, 0=PERCENTAGE 0-100, "\
181 u8 len; member
195 u8 burst; member
202 struct i2c_msg msg = { .addr = state->config->demod_address, in cx24116_writereg()
203 .flags = 0, .buf = buf, .len = 2 }; in cx24116_writereg()
210 err = i2c_transfer(state->i2c, &msg, 1); in cx24116_writereg()
214 return -EREMOTEIO; in cx24116_writereg()
222 const u8 *data, u16 len) in cx24116_writeregN() argument
228 buf = kmalloc(len + 1, GFP_KERNEL); in cx24116_writeregN()
230 return -ENOMEM; in cx24116_writeregN()
233 memcpy(buf + 1, data, len); in cx24116_writeregN()
235 msg.addr = state->config->demod_address; in cx24116_writeregN()
238 msg.len = len + 1; in cx24116_writeregN()
241 printk(KERN_INFO "cx24116: %s: write regN 0x%02x, len = %d\n", in cx24116_writeregN()
242 __func__, reg, len); in cx24116_writeregN()
244 ret = i2c_transfer(state->i2c, &msg, 1); in cx24116_writeregN()
248 ret = -EREMOTEIO; in cx24116_writeregN()
262 { .addr = state->config->demod_address, .flags = 0, in cx24116_readreg()
263 .buf = b0, .len = 1 }, in cx24116_readreg()
264 { .addr = state->config->demod_address, .flags = I2C_M_RD, in cx24116_readreg()
265 .buf = b1, .len = 1 } in cx24116_readreg()
268 ret = i2c_transfer(state->i2c, msg, 2); in cx24116_readreg()
290 state->dnxt.inversion_val = 0x00; in cx24116_set_inversion()
293 state->dnxt.inversion_val = 0x04; in cx24116_set_inversion()
296 state->dnxt.inversion_val = 0x0C; in cx24116_set_inversion()
299 return -EINVAL; in cx24116_set_inversion()
302 state->dnxt.inversion = inversion; in cx24116_set_inversion()
312 * ---- -------- ----------- --------
313 * QPSK FEC_1_2 0x02 0x02+X DVB-S
314 * QPSK FEC_2_3 0x04 0x02+X DVB-S
315 * QPSK FEC_3_4 0x08 0x02+X DVB-S
316 * QPSK FEC_4_5 0x10 0x02+X DVB-S (?)
317 * QPSK FEC_5_6 0x20 0x02+X DVB-S
318 * QPSK FEC_6_7 0x40 0x02+X DVB-S
319 * QPSK FEC_7_8 0x80 0x02+X DVB-S
320 * QPSK FEC_8_9 0x01 0x02+X DVB-S (?) (NOT SUPPORTED?)
321 * QPSK AUTO 0xff 0x02+X DVB-S
323 * For DVB-S high byte probably represents FEC
326 * on DVB-S and remaining bits represent some
340 * NBC=NOT/NON BACKWARD COMPATIBLE WITH DVB-S (DVB-S2 only)
342 * NBC-QPSK FEC_1_2 0x00, 0x04 DVB-S2
343 * NBC-QPSK FEC_3_5 0x00, 0x05 DVB-S2
344 * NBC-QPSK FEC_2_3 0x00, 0x06 DVB-S2
345 * NBC-QPSK FEC_3_4 0x00, 0x07 DVB-S2
346 * NBC-QPSK FEC_4_5 0x00, 0x08 DVB-S2
347 * NBC-QPSK FEC_5_6 0x00, 0x09 DVB-S2
348 * NBC-QPSK FEC_8_9 0x00, 0x0a DVB-S2
349 * NBC-QPSK FEC_9_10 0x00, 0x0b DVB-S2
351 * NBC-8PSK FEC_3_5 0x00, 0x0c DVB-S2
352 * NBC-8PSK FEC_2_3 0x00, 0x0d DVB-S2
353 * NBC-8PSK FEC_3_4 0x00, 0x0e DVB-S2
354 * NBC-8PSK FEC_5_6 0x00, 0x0f DVB-S2
355 * NBC-8PSK FEC_8_9 0x00, 0x10 DVB-S2
356 * NBC-8PSK FEC_9_10 0x00, 0x11 DVB-S2
358 * For DVB-S2 low bytes selects both modulator
391 /* NBC-QPSK */
416 int i, ret = -EOPNOTSUPP; in cx24116_lookup_fecmod()
446 state->dnxt.fec = fec; in cx24116_set_fec()
447 state->dnxt.fec_val = CX24116_MODFEC_MODES[ret].val; in cx24116_set_fec()
448 state->dnxt.fec_mask = CX24116_MODFEC_MODES[ret].mask; in cx24116_set_fec()
450 state->dnxt.fec_mask, state->dnxt.fec_val); in cx24116_set_fec()
460 if ((rate > state->frontend.ops.info.symbol_rate_max) || in cx24116_set_symbolrate()
461 (rate < state->frontend.ops.info.symbol_rate_min)) { in cx24116_set_symbolrate()
463 return -EOPNOTSUPP; in cx24116_set_symbolrate()
466 state->dnxt.symbol_rate = rate; in cx24116_set_symbolrate()
477 struct cx24116_state *state = fe->demodulator_priv; in cx24116_firmware_ondemand()
485 if (state->skip_fw_load) in cx24116_firmware_ondemand()
493 state->i2c->dev.parent); in cx24116_firmware_ondemand()
504 state->skip_fw_load = 1; in cx24116_firmware_ondemand()
517 state->skip_fw_load = 0; in cx24116_firmware_ondemand()
528 struct cx24116_state *state = fe->demodulator_priv; in cx24116_cmd_execute()
542 for (i = 0; i < cmd->len ; i++) { in cx24116_cmd_execute()
543 dprintk("%s: 0x%02x == 0x%02x\n", __func__, i, cmd->args[i]); in cx24116_cmd_execute()
544 cx24116_writereg(state, i, cmd->args[i]); in cx24116_cmd_execute()
556 return -EREMOTEIO; in cx24116_cmd_execute()
565 struct cx24116_state *state = fe->demodulator_priv; in cx24116_load_firmware()
567 int i, ret, len, max, remaining; in cx24116_load_firmware() local
572 fw->size, in cx24116_load_firmware()
573 fw->data[0], in cx24116_load_firmware()
574 fw->data[1], in cx24116_load_firmware()
575 fw->data[fw->size-2], in cx24116_load_firmware()
576 fw->data[fw->size-1]); in cx24116_load_firmware()
579 if (state->config->reset_device) in cx24116_load_firmware()
580 state->config->reset_device(fe); in cx24116_load_firmware()
604 /* Split firmware to the max I2C write len and write. in cx24116_load_firmware()
606 if (state->config->i2c_wr_max) in cx24116_load_firmware()
607 max = state->config->i2c_wr_max; in cx24116_load_firmware()
609 max = INT_MAX; /* enough for 32k firmware */ in cx24116_load_firmware()
611 for (remaining = fw->size; remaining > 0; remaining -= max - 1) { in cx24116_load_firmware()
612 len = remaining; in cx24116_load_firmware()
613 if (len > max - 1) in cx24116_load_firmware()
614 len = max - 1; in cx24116_load_firmware()
616 cx24116_writeregN(state, 0xF7, &fw->data[fw->size - remaining], in cx24116_load_firmware()
617 len); in cx24116_load_firmware()
635 cmd.len = 0x0a; in cx24116_load_firmware()
646 cmd.len = 0x03; in cx24116_load_firmware()
658 if (state->config->mpg_clk_pos_pol) in cx24116_load_firmware()
659 cmd.args[0x04] = state->config->mpg_clk_pos_pol; in cx24116_load_firmware()
663 cmd.len = 0x06; in cx24116_load_firmware()
670 cmd.len = 0x02; in cx24116_load_firmware()
686 struct cx24116_state *state = fe->demodulator_priv; in cx24116_read_status()
709 struct cx24116_state *state = fe->demodulator_priv; in cx24116_read_ber()
725 struct cx24116_state *state = fe->demodulator_priv; in cx24116_read_signal_strength()
734 cmd.len = 0x01; in cx24116_read_signal_strength()
743 *signal_strength = 0 - sig_reading; in cx24116_read_signal_strength()
754 struct cx24116_state *state = fe->demodulator_priv; in cx24116_read_snr_pct()
779 * ESNO, from 0->30db (values 0->300). We provide this value by
784 struct cx24116_state *state = fe->demodulator_priv; in cx24116_read_snr_esno()
806 struct cx24116_state *state = fe->demodulator_priv; in cx24116_read_ucblocks()
819 struct cx24116_state *state = fe->demodulator_priv; in cx24116_clone_params()
820 state->dcur = state->dnxt; in cx24116_clone_params()
826 struct cx24116_state *state = fe->demodulator_priv; in cx24116_wait_for_lnb()
841 return -ETIMEDOUT; /* -EBUSY ? */ in cx24116_wait_for_lnb()
864 cmd.len = 0x02; in cx24116_set_voltage()
881 return -EINVAL; in cx24116_set_tone()
890 msleep(15); /* XXX determine is FW does this, see send_diseqc/burst */ in cx24116_set_tone()
907 cmd.len = 0x04; in cx24116_set_tone()
910 msleep(15); /* XXX determine is FW does this, see send_diseqc/burst */ in cx24116_set_tone()
918 struct cx24116_state *state = fe->demodulator_priv; in cx24116_diseqc_init()
931 cmd.len = 0x08; in cx24116_diseqc_init()
937 state->dsec_cmd.args[0x00] = CMD_LNBSEND; in cx24116_diseqc_init()
939 /* DiSEqC burst */ in cx24116_diseqc_init()
940 state->dsec_cmd.args[CX24116_DISEQC_BURST] = CX24116_DISEQC_MINI_A; in cx24116_diseqc_init()
943 state->dsec_cmd.args[CX24116_DISEQC_ARG2_2] = 0x02; in cx24116_diseqc_init()
944 state->dsec_cmd.args[CX24116_DISEQC_ARG3_0] = 0x00; in cx24116_diseqc_init()
946 state->dsec_cmd.args[CX24116_DISEQC_ARG4_0] = 0x00; in cx24116_diseqc_init()
949 state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] = 0x00; in cx24116_diseqc_init()
952 state->dsec_cmd.len = CX24116_DISEQC_MSGOFS; in cx24116_diseqc_init()
957 /* Send DiSEqC message with derived burst (hack) || previous burst */
961 struct cx24116_state *state = fe->demodulator_priv; in cx24116_send_diseqc_msg()
965 if (d->msg_len > sizeof(d->msg)) in cx24116_send_diseqc_msg()
966 return -EINVAL; in cx24116_send_diseqc_msg()
971 for (i = 0 ; i < d->msg_len ;) { in cx24116_send_diseqc_msg()
972 printk(KERN_INFO "0x%02x", d->msg[i]); in cx24116_send_diseqc_msg()
973 if (++i < d->msg_len) in cx24116_send_diseqc_msg()
980 for (i = 0; i < d->msg_len; i++) in cx24116_send_diseqc_msg()
981 state->dsec_cmd.args[CX24116_DISEQC_MSGOFS + i] = d->msg[i]; in cx24116_send_diseqc_msg()
984 state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] = d->msg_len; in cx24116_send_diseqc_msg()
987 state->dsec_cmd.len = CX24116_DISEQC_MSGOFS + in cx24116_send_diseqc_msg()
988 state->dsec_cmd.args[CX24116_DISEQC_MSGLEN]; in cx24116_send_diseqc_msg()
996 /* Message is sent without burst */ in cx24116_send_diseqc_msg()
997 state->dsec_cmd.args[CX24116_DISEQC_BURST] = 0; in cx24116_send_diseqc_msg()
1001 * Message is sent with derived else cached burst in cx24116_send_diseqc_msg()
1018 if (d->msg_len >= 4 && d->msg[2] == 0x38) in cx24116_send_diseqc_msg()
1019 state->dsec_cmd.args[CX24116_DISEQC_BURST] = in cx24116_send_diseqc_msg()
1020 ((d->msg[3] & 4) >> 2); in cx24116_send_diseqc_msg()
1022 dprintk("%s burst=%d\n", __func__, in cx24116_send_diseqc_msg()
1023 state->dsec_cmd.args[CX24116_DISEQC_BURST]); in cx24116_send_diseqc_msg()
1035 ret = cx24116_cmd_execute(fe, &state->dsec_cmd); in cx24116_send_diseqc_msg()
1045 * 12.5ms burst + in cx24116_send_diseqc_msg()
1048 msleep((state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] << 4) + in cx24116_send_diseqc_msg()
1054 /* Send DiSEqC burst */
1056 enum fe_sec_mini_cmd burst) in cx24116_diseqc_send_burst() argument
1058 struct cx24116_state *state = fe->demodulator_priv; in cx24116_diseqc_send_burst()
1061 dprintk("%s(%d) toneburst=%d\n", __func__, burst, toneburst); in cx24116_diseqc_send_burst()
1063 /* DiSEqC burst */ in cx24116_diseqc_send_burst()
1064 if (burst == SEC_MINI_A) in cx24116_diseqc_send_burst()
1065 state->dsec_cmd.args[CX24116_DISEQC_BURST] = in cx24116_diseqc_send_burst()
1067 else if (burst == SEC_MINI_B) in cx24116_diseqc_send_burst()
1068 state->dsec_cmd.args[CX24116_DISEQC_BURST] = in cx24116_diseqc_send_burst()
1071 return -EINVAL; in cx24116_diseqc_send_burst()
1075 /* Burst is cached */ in cx24116_diseqc_send_burst()
1078 /* Burst is to be sent with cached message */ in cx24116_diseqc_send_burst()
1089 ret = cx24116_cmd_execute(fe, &state->dsec_cmd); in cx24116_diseqc_send_burst()
1100 * 12.5ms burst + in cx24116_diseqc_send_burst()
1103 msleep((state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] << 4) + 60); in cx24116_diseqc_send_burst()
1110 struct cx24116_state *state = fe->demodulator_priv; in cx24116_release()
1130 state->config = config; in cx24116_attach()
1131 state->i2c = i2c; in cx24116_attach()
1143 memcpy(&state->frontend.ops, &cx24116_ops, in cx24116_attach()
1145 state->frontend.demodulator_priv = state; in cx24116_attach()
1146 return &state->frontend; in cx24116_attach()
1157 struct cx24116_state *state = fe->demodulator_priv; in cx24116_initfe()
1171 cmd.len = 0x02; in cx24116_initfe()
1180 /* HVR-4000 needs this */ in cx24116_initfe()
1189 struct cx24116_state *state = fe->demodulator_priv; in cx24116_sleep()
1198 cmd.len = 0x02; in cx24116_sleep()
1211 /* dvb-core told us to tune, the tv property cache will be complete,
1216 struct cx24116_state *state = fe->demodulator_priv; in cx24116_set_frontend()
1217 struct dtv_frontend_properties *c = &fe->dtv_property_cache; in cx24116_set_frontend()
1224 switch (c->delivery_system) { in cx24116_set_frontend()
1226 dprintk("%s: DVB-S delivery system selected\n", __func__); in cx24116_set_frontend()
1228 /* Only QPSK is supported for DVB-S */ in cx24116_set_frontend()
1229 if (c->modulation != QPSK) { in cx24116_set_frontend()
1231 __func__, c->modulation); in cx24116_set_frontend()
1232 return -EOPNOTSUPP; in cx24116_set_frontend()
1235 /* Pilot doesn't exist in DVB-S, turn bit off */ in cx24116_set_frontend()
1236 state->dnxt.pilot_val = CX24116_PILOT_OFF; in cx24116_set_frontend()
1238 /* DVB-S only supports 0.35 */ in cx24116_set_frontend()
1239 if (c->rolloff != ROLLOFF_35) { in cx24116_set_frontend()
1241 __func__, c->rolloff); in cx24116_set_frontend()
1242 return -EOPNOTSUPP; in cx24116_set_frontend()
1244 state->dnxt.rolloff_val = CX24116_ROLLOFF_035; in cx24116_set_frontend()
1248 dprintk("%s: DVB-S2 delivery system selected\n", __func__); in cx24116_set_frontend()
1251 * NBC 8PSK/QPSK with DVB-S is supported for DVB-S2, in cx24116_set_frontend()
1254 if (c->modulation != PSK_8 && c->modulation != QPSK) { in cx24116_set_frontend()
1256 __func__, c->modulation); in cx24116_set_frontend()
1257 return -EOPNOTSUPP; in cx24116_set_frontend()
1260 switch (c->pilot) { in cx24116_set_frontend()
1262 state->dnxt.pilot_val = (c->modulation == QPSK) in cx24116_set_frontend()
1267 state->dnxt.pilot_val = CX24116_PILOT_OFF; in cx24116_set_frontend()
1270 state->dnxt.pilot_val = CX24116_PILOT_ON; in cx24116_set_frontend()
1274 __func__, c->pilot); in cx24116_set_frontend()
1275 return -EOPNOTSUPP; in cx24116_set_frontend()
1278 switch (c->rolloff) { in cx24116_set_frontend()
1280 state->dnxt.rolloff_val = CX24116_ROLLOFF_020; in cx24116_set_frontend()
1283 state->dnxt.rolloff_val = CX24116_ROLLOFF_025; in cx24116_set_frontend()
1286 state->dnxt.rolloff_val = CX24116_ROLLOFF_035; in cx24116_set_frontend()
1291 __func__, c->rolloff); in cx24116_set_frontend()
1292 return -EOPNOTSUPP; in cx24116_set_frontend()
1298 __func__, c->delivery_system); in cx24116_set_frontend()
1299 return -EOPNOTSUPP; in cx24116_set_frontend()
1301 state->dnxt.delsys = c->delivery_system; in cx24116_set_frontend()
1302 state->dnxt.modulation = c->modulation; in cx24116_set_frontend()
1303 state->dnxt.frequency = c->frequency; in cx24116_set_frontend()
1304 state->dnxt.pilot = c->pilot; in cx24116_set_frontend()
1305 state->dnxt.rolloff = c->rolloff; in cx24116_set_frontend()
1307 ret = cx24116_set_inversion(state, c->inversion); in cx24116_set_frontend()
1311 /* FEC_NONE/AUTO for DVB-S2 is not supported and detected here */ in cx24116_set_frontend()
1312 ret = cx24116_set_fec(state, c->delivery_system, c->modulation, c->fec_inner); in cx24116_set_frontend()
1316 ret = cx24116_set_symbolrate(state, c->symbol_rate); in cx24116_set_frontend()
1323 dprintk("%s: delsys = %d\n", __func__, state->dcur.delsys); in cx24116_set_frontend()
1324 dprintk("%s: modulation = %d\n", __func__, state->dcur.modulation); in cx24116_set_frontend()
1325 dprintk("%s: frequency = %d\n", __func__, state->dcur.frequency); in cx24116_set_frontend()
1327 state->dcur.pilot, state->dcur.pilot_val); in cx24116_set_frontend()
1330 state->dcur.rolloff, state->dcur.rolloff_val); in cx24116_set_frontend()
1331 dprintk("%s: symbol_rate = %d\n", __func__, state->dcur.symbol_rate); in cx24116_set_frontend()
1333 state->dcur.fec, state->dcur.fec_mask, state->dcur.fec_val); in cx24116_set_frontend()
1335 state->dcur.inversion, state->dcur.inversion_val); in cx24116_set_frontend()
1338 if (state->config->set_ts_params) in cx24116_set_frontend()
1339 state->config->set_ts_params(fe, 0); in cx24116_set_frontend()
1344 cmd.len = 0x02; in cx24116_set_frontend()
1353 cmd.args[0x01] = (state->dcur.frequency & 0xff0000) >> 16; in cx24116_set_frontend()
1354 cmd.args[0x02] = (state->dcur.frequency & 0x00ff00) >> 8; in cx24116_set_frontend()
1355 cmd.args[0x03] = (state->dcur.frequency & 0x0000ff); in cx24116_set_frontend()
1358 cmd.args[0x04] = ((state->dcur.symbol_rate / 1000) & 0xff00) >> 8; in cx24116_set_frontend()
1359 cmd.args[0x05] = ((state->dcur.symbol_rate / 1000) & 0x00ff); in cx24116_set_frontend()
1362 cmd.args[0x06] = state->dcur.inversion_val; in cx24116_set_frontend()
1365 cmd.args[0x07] = state->dcur.fec_val | state->dcur.pilot_val; in cx24116_set_frontend()
1371 cmd.args[0x0c] = state->dcur.rolloff_val; in cx24116_set_frontend()
1372 cmd.args[0x0d] = state->dcur.fec_mask; in cx24116_set_frontend()
1374 if (state->dcur.symbol_rate > 30000000) { in cx24116_set_frontend()
1392 cmd.len = 0x13; in cx24116_set_frontend()
1394 /* We need to support pilot and non-pilot tuning in the in cx24116_set_frontend()
1427 /* Toggle pilot bit when in auto-pilot */ in cx24116_set_frontend()
1428 if (state->dcur.pilot == PILOT_AUTO) in cx24116_set_frontend()
1430 } while (--retune); in cx24116_set_frontend()
1435 cmd.len = 0x02; in cx24116_set_frontend()
1444 * fe->dtv_property_cache with fepriv->parameters_in, where the in cx24116_tune()
1446 * that re-tuning is needed, e. g. (fepriv->state & FESTATE_RETUNE) is in cx24116_tune()