All pastes #780993 Raw Edit

Unbenannt

public text v1 · immutable
·published 2007-11-18 18:56 UTC
rendered paste body
static int tda10021_read_signal_strength(struct dvb_frontend* fe, u16* strength)
{
        struct tda10021_state* state = fe->demodulator_priv;

        u8 gain = tda10021_readreg(state, 0x17);
        *strength = (gain << 8) | gain;

        return 0;
}


static int tda10023_read_signal_strength(struct dvb_frontend* fe, u16* strength)
{
        struct tda10023_state* state = fe->demodulator_priv;
        u8 ifgain=tda10023_readreg(state, 0x2f);

        u16 gain = ((255-tda10023_readreg(state, 0x17))) + (255-ifgain)/16;
        // Max raw value is about 0xb0 -> Normalize to >0xf0 after 0x90
        if (gain>0x90)
                gain=gain+2*(gain-0x90);
        if (gain>255)
                gain=255;

        *strength = (gain<<8)|gain;
        return 0;
}

static int cu1216_read_strength(struct dvb_frontend *fe, u16 *strength)
{
        struct cu1216_state *state = fe->demodulator_priv;

        u8      tempagc;

        tempagc = cu1216_readreg(state, AC_VAGC1_IND);

        if (tempagc > 0xF0)
                *strength = 2;
        else if (tempagc > 0xE5)
                *strength = 4;
        else if (tempagc < 0x6E)
                *strength = 98;
        else if (tempagc < 0x96)
                *strength = 70 + (0x96 - tempagc) / 2 * 7 / 5;
        else if (tempagc < 0xCD)
                *strength = 14 + (0xCD - tempagc);
        else
                *strength = 2 + (0xE5 - tempagc) / 2;

        return  0;