summaryrefslogtreecommitdiff
path: root/linux/drivers/media/dvb/frontends/stb0899_drv.c
diff options
context:
space:
mode:
authorManu Abraham <manu@linuxtv.org>2008-10-27 01:28:52 +0400
committerManu Abraham <manu@linuxtv.org>2008-10-27 01:28:52 +0400
commitc553edd5135a293a84f9fd98ed49c51e33bf3787 (patch)
tree868e4956704211ae016603431cc6ea00ddab4437 /linux/drivers/media/dvb/frontends/stb0899_drv.c
parent84ff5e0bcaa2989c3fb8c2f75f39aaa3858dd767 (diff)
downloadmediapointer-dvb-s2-c553edd5135a293a84f9fd98ed49c51e33bf3787.tar.gz
mediapointer-dvb-s2-c553edd5135a293a84f9fd98ed49c51e33bf3787.tar.bz2
Port STB0899 and STB6100
From: Manu Abraham <abraham.manu@gmail.com> Signed-off-by: Manu Abraham <manu@linuxtv.org>
Diffstat (limited to 'linux/drivers/media/dvb/frontends/stb0899_drv.c')
-rw-r--r--linux/drivers/media/dvb/frontends/stb0899_drv.c250
1 files changed, 63 insertions, 187 deletions
diff --git a/linux/drivers/media/dvb/frontends/stb0899_drv.c b/linux/drivers/media/dvb/frontends/stb0899_drv.c
index 4d00cc848..02edf1760 100644
--- a/linux/drivers/media/dvb/frontends/stb0899_drv.c
+++ b/linux/drivers/media/dvb/frontends/stb0899_drv.c
@@ -823,16 +823,17 @@ static int stb0899_send_diseqc_burst(struct dvb_frontend *fe, fe_sec_mini_cmd_t
static int stb0899_diseqc_init(struct stb0899_state *state)
{
struct dvb_diseqc_master_cmd tx_data;
+/*
struct dvb_diseqc_slave_reply rx_data;
-
+*/
u8 f22_tx, f22_rx, reg;
- u32 mclk, tx_freq = 22000, count = 0, i;
-
+ u32 mclk, tx_freq = 22000;/* count = 0, i; */
+#if 0
u32 trial = 0; /* try max = 2 (try 20khz and 17.5 khz) */
u32 ret_1 = 0; /* 20 Khz status */
u32 ret_2 = 0; /* 17.5 Khz status */
-
+#endif
tx_data.msg[0] = 0xe2;
tx_data.msg_len = 3;
reg = stb0899_read_reg(state, STB0899_DISCNTRL2);
@@ -896,8 +897,9 @@ static int stb0899_diseqc_init(struct stb0899_state *state)
static int stb0899_sleep(struct dvb_frontend *fe)
{
struct stb0899_state *state = fe->demodulator_priv;
+/*
u8 reg;
-
+*/
dprintk(state->verbose, FE_DEBUG, 1, "Going to Sleep .. (Really tired .. :-))");
#if 0
reg = stb0899_read_reg(state, STB0899_SYNTCTRL);
@@ -936,7 +938,6 @@ static int stb0899_init(struct dvb_frontend *fe)
struct stb0899_config *config = state->config;
dprintk(state->verbose, FE_DEBUG, 1, "Initializing STB0899 ... ");
-// mutex_init(&state->search_lock);
/* init device */
dprintk(state->verbose, FE_DEBUG, 1, "init device");
@@ -1009,8 +1010,8 @@ static int stb0899_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
int val;
u32 reg;
switch (state->delsys) {
- case DVBFE_DELSYS_DVBS:
- case DVBFE_DELSYS_DSS:
+ case SYS_DVBS:
+ case SYS_DSS:
if (internal->lock) {
reg = stb0899_read_reg(state, STB0899_VSTATUS);
if (STB0899_GETFIELD(VSTATUS_LOCKEDVIT, reg)) {
@@ -1025,7 +1026,7 @@ static int stb0899_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
}
}
break;
- case DVBFE_DELSYS_DVBS2:
+ case SYS_DVBS2:
if (internal->lock) {
reg = STB0899_READ_S2REG(STB0899_DEMOD, IF_AGC_GAIN);
val = STB0899_GETFIELD(IF_AGC_GAIN, reg);
@@ -1055,8 +1056,8 @@ static int stb0899_read_snr(struct dvb_frontend *fe, u16 *snr)
reg = stb0899_read_reg(state, STB0899_VSTATUS);
switch (state->delsys) {
- case DVBFE_DELSYS_DVBS:
- case DVBFE_DELSYS_DSS:
+ case SYS_DVBS:
+ case SYS_DSS:
if (internal->lock) {
if (STB0899_GETFIELD(VSTATUS_LOCKEDVIT, reg)) {
@@ -1069,7 +1070,7 @@ static int stb0899_read_snr(struct dvb_frontend *fe, u16 *snr)
}
}
break;
- case DVBFE_DELSYS_DVBS2:
+ case SYS_DVBS2:
if (internal->lock) {
reg = STB0899_READ_S2REG(STB0899_S2DEMOD, UWP_CNTRL1);
quant = STB0899_GETFIELD(UWP_ESN0_QUANT, reg);
@@ -1108,8 +1109,8 @@ static int stb0899_read_status(struct dvb_frontend *fe, enum fe_status *status)
*status = 0;
switch (state->delsys) {
- case DVBFE_DELSYS_DVBS:
- case DVBFE_DELSYS_DSS:
+ case SYS_DVBS:
+ case SYS_DSS:
dprintk(state->verbose, FE_DEBUG, 1, "Delivery system DVB-S/DSS");
if (internal->lock) {
reg = stb0899_read_reg(state, STB0899_VSTATUS);
@@ -1127,7 +1128,7 @@ static int stb0899_read_status(struct dvb_frontend *fe, enum fe_status *status)
}
}
break;
- case DVBFE_DELSYS_DVBS2:
+ case SYS_DVBS2:
dprintk(state->verbose, FE_DEBUG, 1, "Delivery system DVB-S2");
if (internal->lock) {
reg = STB0899_READ_S2REG(STB0899_S2DEMOD, DMD_STAT2);
@@ -1182,8 +1183,8 @@ static int stb0899_read_ber(struct dvb_frontend *fe, u32 *ber)
*ber = 0;
switch (state->delsys) {
- case DVBFE_DELSYS_DVBS:
- case DVBFE_DELSYS_DSS:
+ case SYS_DVBS:
+ case SYS_DSS:
if (internal->lock) {
/* average 5 BER values */
for (i = 0; i < 5; i++) {
@@ -1203,7 +1204,7 @@ static int stb0899_read_ber(struct dvb_frontend *fe, u32 *ber)
}
}
break;
- case DVBFE_DELSYS_DVBS2:
+ case SYS_DVBS2:
if (internal->lock) {
/* Average 5 PER values */
for (i = 0; i < 5; i++) {
@@ -1350,97 +1351,6 @@ int stb0899_get_dev_id(struct stb0899_state *state)
return 0;
}
-static const struct dvbfe_info dvbs_info = {
- .name = "STB0899 DVB-S",
- .delsys = {
- .dvbs.modulation = DVBFE_MOD_QPSK,
- .dvbs.fec = DVBFE_FEC_1_2 | DVBFE_FEC_2_3 |
- DVBFE_FEC_3_4 | DVBFE_FEC_5_6 |
- DVBFE_FEC_6_7
- },
-
- .frequency_min = 950000,
- .frequency_max = 2150000,
- .frequency_step = 0,
- .symbol_rate_min = 1000000,
- .symbol_rate_max = 45000000,
- .symbol_rate_tolerance = 0
-};
-
-static const struct dvbfe_info dss_info = {
- .name = "STB0899 DSS",
- .delsys = {
- .dss.modulation = DVBFE_MOD_BPSK | DVBFE_MOD_QPSK,
- .dss.fec = DVBFE_FEC_1_2 | DVBFE_FEC_2_3 |
- DVBFE_FEC_3_4 | DVBFE_FEC_5_6 |
- DVBFE_FEC_6_7
- },
-
- .frequency_min = 950000,
- .frequency_max = 2150000,
- .frequency_step = 0,
- .symbol_rate_min = 1000000,
- .symbol_rate_max = 45000000,
- .symbol_rate_tolerance = 0
-};
-
-static const struct dvbfe_info dvbs2_info = {
- .name = "STB0899 DVB-S2",
- .delsys = {
- .dvbs2.modulation = DVBFE_MOD_QPSK | DVBFE_MOD_8PSK |
- DVBFE_MOD_16APSK | DVBFE_MOD_32APSK,
-
- .dvbs2.fec = DVBFE_FEC_1_4 | DVBFE_FEC_1_3 |
- DVBFE_FEC_2_5 | DVBFE_FEC_1_2 |
- DVBFE_FEC_3_5 | DVBFE_FEC_2_3 |
- DVBFE_FEC_3_4 | DVBFE_FEC_4_5 |
- DVBFE_FEC_5_6 | DVBFE_FEC_8_9 |
- DVBFE_FEC_9_10,
- },
-
- .frequency_min = 950000,
- .frequency_max = 2150000,
- .frequency_step = 0,
- .symbol_rate_min = 1000000,
- .symbol_rate_max = 45000000,
- .symbol_rate_tolerance = 0
-};
-
-static int stb0899_get_info(struct dvb_frontend *fe, struct dvbfe_info *fe_info)
-{
- struct stb0899_state *state = fe->demodulator_priv;
-
- dprintk(state->verbose, FE_DEBUG, 1, "Get Info");
-
- switch (state->delsys) {
- case DVBFE_DELSYS_DVBS:
- dprintk(state->verbose, FE_ERROR, 1, "Querying DVB-S info");
- memcpy(fe_info, &dvbs_info, sizeof (struct dvbfe_info));
- break;
- case DVBFE_DELSYS_DSS:
- dprintk(state->verbose, FE_ERROR, 1, "Querying DSS info");
- memcpy(fe_info, &dss_info, sizeof (struct dvbfe_info));
- break;
- case DVBFE_DELSYS_DVBS2:
- dprintk(state->verbose, FE_ERROR, 1, "Querying DVB-S2 info");
- memcpy(fe_info, &dvbs2_info, sizeof (struct dvbfe_info));
- break;
- default:
- dprintk(state->verbose, FE_ERROR, 1, "Unsupported delivery system");
- return -EINVAL;
- }
- dprintk(state->verbose, FE_DEBUG, 1, "delivery system=%d", state->delsys);
-
- return 0;
-}
-
-static int stb0899_get_delsys(struct dvb_frontend *fe, enum dvbfe_delsys *fe_delsys)
-{
- *fe_delsys = DVBFE_DELSYS_DVBS | DVBFE_DELSYS_DSS | DVBFE_DELSYS_DVBS2;
-
- return 0;
-}
-
static void stb0899_set_delivery(struct stb0899_state *state)
{
u8 reg;
@@ -1450,7 +1360,7 @@ static void stb0899_set_delivery(struct stb0899_state *state)
stop_clk[1] = stb0899_read_reg(state, STB0899_STOPCLK2);
switch (state->delsys) {
- case DVBFE_DELSYS_DVBS:
+ case SYS_DVBS:
dprintk(state->verbose, FE_DEBUG, 1, "Delivery System -- DVB-S");
/* FECM/Viterbi ON */
reg = stb0899_read_reg(state, STB0899_FECM);
@@ -1479,7 +1389,7 @@ static void stb0899_set_delivery(struct stb0899_state *state)
STB0899_SETFIELD_VAL(STOP_CKS2DMD108, stop_clk[1], 1);
break;
- case DVBFE_DELSYS_DVBS2:
+ case SYS_DVBS2:
/* FECM/Viterbi OFF */
reg = stb0899_read_reg(state, STB0899_FECM);
STB0899_SETFIELD_VAL(FECM_RSVD0, reg, 0);
@@ -1507,7 +1417,7 @@ static void stb0899_set_delivery(struct stb0899_state *state)
STB0899_SETFIELD_VAL(STOP_CKS2DMD108, stop_clk[1], 0);
break;
- case DVBFE_DELSYS_DSS:
+ case SYS_DSS:
/* FECM/Viterbi ON */
reg = stb0899_read_reg(state, STB0899_FECM);
STB0899_SETFIELD_VAL(FECM_RSVD0, reg, 1);
@@ -1566,33 +1476,19 @@ static void stb0899_set_iterations(struct stb0899_state *state)
stb0899_write_s2reg(state, STB0899_S2DEMOD, STB0899_BASE_MAX_ITER, STB0899_OFF0_MAX_ITER, reg);
}
-static enum dvbfe_search stb0899_search(struct dvb_frontend *fe, struct dvbfe_params *params)
+static enum dvbfe_search stb0899_search(struct dvb_frontend *fe, struct dvb_frontend_parameters *p)
{
struct stb0899_state *state = fe->demodulator_priv;
struct stb0899_params *i_params = &state->params;
struct stb0899_internal *internal = &state->internal;
struct stb0899_config *config = state->config;
+ struct dtv_frontend_properties *props = &fe->dtv_property_cache;
u32 SearchRange, gain;
- i_params->freq = params->frequency;
- switch (state->delsys) {
- case DVBFE_DELSYS_DVBS:
- dprintk(state->verbose, FE_ERROR, 1, "set DVB-S params");
- i_params->srate = params->delsys.dvbs.symbol_rate;
- break;
- case DVBFE_DELSYS_DSS:
- dprintk(state->verbose, FE_ERROR, 1, "set DSS params");
- i_params->srate = params->delsys.dss.symbol_rate;
- break;
- case DVBFE_DELSYS_DVBS2:
- dprintk(state->verbose, FE_ERROR, 1, "set DVB-S2 params");
- i_params->srate = params->delsys.dvbs2.symbol_rate;
- break;
- default:
- dprintk(state->verbose, FE_ERROR, 1, "Unsupported delivery system");
- return -EINVAL;
- }
+ i_params->freq = p->frequency;
+ i_params->srate = p->u.qpsk.symbol_rate;
+ state->delsys = props->delivery_system;
dprintk(state->verbose, FE_DEBUG, 1, "delivery system=%d", state->delsys);
SearchRange = 10000000;
@@ -1604,11 +1500,11 @@ static enum dvbfe_search stb0899_search(struct dvb_frontend *fe, struct dvbfe_pa
if (state->config->tuner_set_rfsiggain) {
if (internal->srate > 15000000)
- gain = 8; /* 15Mb < srate < 45Mb, gain = 8dB */
+ gain = 8; /* 15Mb < srate < 45Mb, gain = 8dB */
else if (internal->srate > 5000000)
- gain = 12; /* 5Mb < srate < 15Mb, gain = 12dB */
+ gain = 12; /* 5Mb < srate < 15Mb, gain = 12dB */
else
- gain = 14; /* 1Mb < srate < 5Mb, gain = 14db */
+ gain = 14; /* 1Mb < srate < 5Mb, gain = 14db */
state->config->tuner_set_rfsiggain(fe, gain);
}
@@ -1618,8 +1514,8 @@ static enum dvbfe_search stb0899_search(struct dvb_frontend *fe, struct dvbfe_pa
stb0899_set_mclk(state, config->hi_clk);
switch (state->delsys) {
- case DVBFE_DELSYS_DVBS:
- case DVBFE_DELSYS_DSS:
+ case SYS_DVBS:
+ case SYS_DSS:
dprintk(state->verbose, FE_DEBUG, 1, "DVB-S delivery system");
internal->freq = i_params->freq;
internal->srate = i_params->srate;
@@ -1667,7 +1563,7 @@ static enum dvbfe_search stb0899_search(struct dvb_frontend *fe, struct dvbfe_pa
return DVBFE_ALGO_SEARCH_FAILED;
}
break;
- case DVBFE_DELSYS_DVBS2:
+ case SYS_DVBS2:
internal->freq = i_params->freq;
internal->srate = i_params->srate;
internal->srch_range = SearchRange;
@@ -1717,7 +1613,7 @@ static enum dvbfe_search stb0899_search(struct dvb_frontend *fe, struct dvbfe_pa
return DVBFE_ALGO_SEARCH_ERROR;
}
-
+#if 0
static enum stb0899_status stb0899_track_carrier(struct stb0899_state *state)
{
u8 reg;
@@ -1752,26 +1648,26 @@ static enum stb0899_status stb0899_get_ifagc(struct stb0899_state *state)
return NOAGC1;
}
-static int stb0899_get_s1fec(struct stb0899_internal *internal, enum dvbfe_fec *fec)
+static int stb0899_get_s1fec(struct stb0899_internal *internal, enum fe_code_rate *fec)
{
switch (internal->fecrate) {
case STB0899_FEC_1_2:
- *fec = DVBFE_FEC_1_2;
+ *fec = FEC_1_2;
break;
case STB0899_FEC_2_3:
- *fec = DVBFE_FEC_2_3;
+ *fec = FEC_2_3;
break;
case STB0899_FEC_3_4:
- *fec = DVBFE_FEC_3_4;
+ *fec = FEC_3_4;
break;
case STB0899_FEC_5_6:
- *fec = DVBFE_FEC_5_6;
+ *fec = FEC_5_6;
break;
case STB0899_FEC_6_7:
- *fec = DVBFE_FEC_6_7;
+ *fec = FEC_6_7;
break;
case STB0899_FEC_7_8:
- *fec = DVBFE_FEC_7_8;
+ *fec = FEC_7_8;
break;
default:
return -EINVAL;
@@ -1905,7 +1801,7 @@ static int stb0899_get_modcod(struct stb0899_internal *internal, struct dvbs2_pa
return 0;
}
-
+#endif
/*
* stb0899_track
* periodically check the signal level against a specified
@@ -1922,14 +1818,14 @@ static int stb0899_get_modcod(struct stb0899_internal *internal, struct dvbs2_pa
* Once a new lock has established, the internal state
* frequency (internal->freq) is updated
*/
-static int stb0899_track(struct dvb_frontend *fe, struct dvbfe_params *params, int *delay)
+static int stb0899_track(struct dvb_frontend *fe, struct dvb_frontend_parameters *p)
{
+#if 0
u32 lock_lost;
struct stb0899_state *state = fe->demodulator_priv;
struct stb0899_internal *internal = &state->internal;
-#if 0
switch (state->delsys) {
case DVBFE_DELSYS_DVBS:
dprintk(state->verbose, FE_DEBUG, 1, "Tracking DVB-S state");
@@ -1981,40 +1877,19 @@ static int stb0899_track(struct dvb_frontend *fe, struct dvbfe_params *params, i
dprintk(state->verbose, FE_ERROR, 1, "Unsupported delivery system");
return -EINVAL;
}
-#endif
-
- *delay = HZ/10;
+// *delay = HZ/10;
+#endif
return 0;
}
-static int stb0899_get_params(struct dvb_frontend *fe, struct dvbfe_params *params)
+static int stb0899_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p)
{
struct stb0899_state *state = fe->demodulator_priv;
struct stb0899_internal *internal = &state->internal;
- params->frequency = internal->freq;
- params->inversion = internal->inversion;
- params->delivery = state->delsys;
- switch (state->delsys) {
- case DVBFE_DELSYS_DVBS:
- dprintk(state->verbose, FE_DEBUG, 1, "Get DVB-S params");
- params->delsys.dvbs.symbol_rate = internal->srate;
- params->delsys.dvbs.modulation = DVBFE_MOD_QPSK;
- break;
- case DVBFE_DELSYS_DSS:
- dprintk(state->verbose, FE_DEBUG, 1, "Get DSS params");
- params->delsys.dss.symbol_rate = internal->srate;
- params->delsys.dss.modulation = DVBFE_MOD_QPSK;
- break;
- case DVBFE_DELSYS_DVBS2:
- dprintk(state->verbose, FE_DEBUG, 1, "Get DVB-S2 params");
- params->delsys.dvbs2.symbol_rate = internal->srate;
- break;
- default:
- dprintk(state->verbose, FE_ERROR, 1, "Unsupported delivery system");
- return -EINVAL;
- }
+ dprintk(state->verbose, FE_DEBUG, 1, "Get params");
+ p->u.qpsk.symbol_rate = internal->srate;
return 0;
}
@@ -2024,18 +1899,21 @@ static enum dvbfe_algo stb0899_frontend_algo(struct dvb_frontend *fe)
return DVBFE_ALGO_CUSTOM;
}
-static int stb0899_set_delsys(struct dvb_frontend *fe, enum dvbfe_delsys delsys)
-{
- struct stb0899_state *state = fe->demodulator_priv;
-
- state->delsys = delsys;
- return 0;
-}
-
static struct dvb_frontend_ops stb0899_ops = {
.info = {
- .name = "STB0899 Multistandard",
+ .name = "STB0899 Multistandard",
+ .type = FE_QPSK,
+ .frequency_min = 950000,
+ .frequency_max = 2150000,
+ .frequency_stepsize = 0,
+ .frequency_tolerance = 0,
+ .symbol_rate_min = 5000000,
+ .symbol_rate_max = 45000000,
+
+ .caps = FE_CAN_INVERSION_AUTO |
+ FE_CAN_FEC_AUTO |
+ FE_CAN_QPSK
},
.release = stb0899_release,
@@ -2044,14 +1922,12 @@ static struct dvb_frontend_ops stb0899_ops = {
// .wakeup = stb0899_wakeup,
.i2c_gate_ctrl = stb0899_i2c_gate_ctrl,
- .get_info = stb0899_get_info,
- .get_delsys = stb0899_get_delsys,
- .set_delsys = stb0899_set_delsys,
.get_frontend_algo = stb0899_frontend_algo,
.search = stb0899_search,
.track = stb0899_track,
- .get_params = stb0899_get_params,
+ .get_frontend = stb0899_get_frontend,
+
.read_status = stb0899_read_status,
.read_snr = stb0899_read_snr,