/* Demodulator private data */
enum fe_modulation current_modulation;
- u32 snr; /* Result of last SNR calculation */
+ u32 snr; /* Result of last SNR calculation */
/* Tuner private data */
u32 current_frequency;
static int lgdt330x_init(struct dvb_frontend *fe)
{
struct lgdt330x_state *state = fe->demodulator_priv;
+ struct dtv_frontend_properties *p = &fe->dtv_property_cache;
char *chip_name;
int err;
/*
dprintk(state, "Initialized the %s chip\n", chip_name);
if (err < 0)
return err;
+
+ p->cnr.len = 1;
+ p->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
+
return lgdt330x_sw_reset(state);
}
return 10 * (c - mse);
}
-static int lgdt3302_read_snr(struct dvb_frontend *fe, u16 *snr)
+static int lgdt3302_read_snr(struct dvb_frontend *fe)
{
struct lgdt330x_state *state = fe->demodulator_priv;
u8 buf[5]; /* read data buffer */
dev_err(&state->client->dev,
"%s: Modulation set to unsupported value\n",
__func__);
+
+ state->snr = 0;
+
return -EREMOTEIO; /* return -EDRIVER_IS_GIBBERED; */
}
state->snr = calculate_snr(noise, c);
- *snr = (state->snr) >> 16; /* Convert from 8.24 fixed-point to 8.8 */
dprintk(state, "noise = 0x%08x, snr = %d.%02d dB\n", noise,
state->snr >> 24, (((state->snr >> 8) & 0xffff) * 100) >> 16);
return 0;
}
-static int lgdt3303_read_snr(struct dvb_frontend *fe, u16 *snr)
+static int lgdt3303_read_snr(struct dvb_frontend *fe)
{
struct lgdt330x_state *state = fe->demodulator_priv;
u8 buf[5]; /* read data buffer */
dev_err(&state->client->dev,
"%s: Modulation set to unsupported value\n",
__func__);
+ state->snr = 0;
return -EREMOTEIO; /* return -EDRIVER_IS_GIBBERED; */
}
state->snr = calculate_snr(noise, c);
- *snr = (state->snr) >> 16; /* Convert from 8.24 fixed-point to 8.8 */
dprintk(state, "noise = 0x%08x, snr = %d.%02d dB\n", noise,
state->snr >> 24, (((state->snr >> 8) & 0xffff) * 100) >> 16);
return 0;
}
+static int lgdt330x_read_snr(struct dvb_frontend *fe, u16 *snr)
+{
+ struct lgdt330x_state *state = fe->demodulator_priv;
+
+ *snr = (state->snr) >> 16; /* Convert from 8.24 fixed-point to 8.8 */
+
+ return 0;
+}
+
static int lgdt330x_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
{
/* Calculate Strength from SNR up to 35dB */
enum fe_status *status)
{
struct lgdt330x_state *state = fe->demodulator_priv;
+ struct dtv_frontend_properties *p = &fe->dtv_property_cache;
u8 buf[3];
*status = 0; /* Reset status result */
__func__);
}
+ if (*status & FE_HAS_LOCK && lgdt3302_read_snr(fe) >= 0) {
+ p->cnr.stat[0].scale = FE_SCALE_DECIBEL;
+ p->cnr.stat[0].svalue = (((u64)state->snr) * 1000) >> 24;
+ } else {
+ p->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
+ }
+
return 0;
}
enum fe_status *status)
{
struct lgdt330x_state *state = fe->demodulator_priv;
+ struct dtv_frontend_properties *p = &fe->dtv_property_cache;
int err;
u8 buf[3];
"%s: Modulation set to unsupported value\n",
__func__);
}
+
+ if (*status & FE_HAS_LOCK && lgdt3303_read_snr(fe) >= 0) {
+ p->cnr.stat[0].scale = FE_SCALE_DECIBEL;
+ p->cnr.stat[0].svalue = (((u64)state->snr) * 1000) >> 24;
+ } else {
+ p->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
+ }
+
return 0;
}
.read_status = lgdt3302_read_status,
.read_ber = lgdt330x_read_ber,
.read_signal_strength = lgdt330x_read_signal_strength,
- .read_snr = lgdt3302_read_snr,
+ .read_snr = lgdt330x_read_snr,
.read_ucblocks = lgdt330x_read_ucblocks,
.release = lgdt330x_release,
};
.read_status = lgdt3303_read_status,
.read_ber = lgdt330x_read_ber,
.read_signal_strength = lgdt330x_read_signal_strength,
- .read_snr = lgdt3303_read_snr,
+ .read_snr = lgdt330x_read_snr,
.read_ucblocks = lgdt330x_read_ucblocks,
.release = lgdt330x_release,
};