diff options
Diffstat (limited to 'drivers/media/dvb/frontends/dib8000.c')
-rw-r--r-- | drivers/media/dvb/frontends/dib8000.c | 64 |
1 files changed, 52 insertions, 12 deletions
diff --git a/drivers/media/dvb/frontends/dib8000.c b/drivers/media/dvb/frontends/dib8000.c index 898400d331a3..b924e7eec5ac 100644 --- a/drivers/media/dvb/frontends/dib8000.c +++ b/drivers/media/dvb/frontends/dib8000.c | |||
@@ -28,18 +28,6 @@ MODULE_PARM_DESC(debug, "turn on debugging (default: 0)"); | |||
28 | 28 | ||
29 | #define dprintk(args...) do { if (debug) { printk(KERN_DEBUG "DiB8000: "); printk(args); printk("\n"); } } while (0) | 29 | #define dprintk(args...) do { if (debug) { printk(KERN_DEBUG "DiB8000: "); printk(args); printk("\n"); } } while (0) |
30 | 30 | ||
31 | enum frontend_tune_state { | ||
32 | CT_AGC_START = 20, | ||
33 | CT_AGC_STEP_0, | ||
34 | CT_AGC_STEP_1, | ||
35 | CT_AGC_STEP_2, | ||
36 | CT_AGC_STEP_3, | ||
37 | CT_AGC_STEP_4, | ||
38 | CT_AGC_STOP, | ||
39 | |||
40 | CT_DEMOD_START = 30, | ||
41 | }; | ||
42 | |||
43 | #define FE_STATUS_TUNE_FAILED 0 | 31 | #define FE_STATUS_TUNE_FAILED 0 |
44 | 32 | ||
45 | struct i2c_device { | 33 | struct i2c_device { |
@@ -852,6 +840,14 @@ static int dib8000_set_agc_config(struct dib8000_state *state, u8 band) | |||
852 | return 0; | 840 | return 0; |
853 | } | 841 | } |
854 | 842 | ||
843 | void dib8000_pwm_agc_reset(struct dvb_frontend *fe) | ||
844 | { | ||
845 | struct dib8000_state *state = fe->demodulator_priv; | ||
846 | dib8000_set_adc_state(state, DIBX000_ADC_ON); | ||
847 | dib8000_set_agc_config(state, (unsigned char)(BAND_OF_FREQUENCY(fe->dtv_property_cache.frequency / 1000))); | ||
848 | } | ||
849 | EXPORT_SYMBOL(dib8000_pwm_agc_reset); | ||
850 | |||
855 | static int dib8000_agc_soft_split(struct dib8000_state *state) | 851 | static int dib8000_agc_soft_split(struct dib8000_state *state) |
856 | { | 852 | { |
857 | u16 agc, split_offset; | 853 | u16 agc, split_offset; |
@@ -939,6 +935,32 @@ static int dib8000_agc_startup(struct dvb_frontend *fe) | |||
939 | 935 | ||
940 | } | 936 | } |
941 | 937 | ||
938 | static const int32_t lut_1000ln_mant[] = | ||
939 | { | ||
940 | 908,7003,7090,7170,7244,7313,7377,7438,7495,7549,7600 | ||
941 | }; | ||
942 | |||
943 | int32_t dib8000_get_adc_power(struct dvb_frontend *fe, uint8_t mode) | ||
944 | { | ||
945 | struct dib8000_state *state = fe->demodulator_priv; | ||
946 | uint32_t ix =0, tmp_val =0, exp = 0, mant = 0; | ||
947 | int32_t val; | ||
948 | |||
949 | val = dib8000_read32(state, 384); | ||
950 | /* mode = 1 : ln_agcpower calc using mant-exp conversion and mantis look up table */ | ||
951 | if(mode) { | ||
952 | tmp_val = val; | ||
953 | while(tmp_val>>=1) | ||
954 | exp++; | ||
955 | mant = (val * 1000 / (1<<exp)); | ||
956 | ix = (uint8_t)((mant-1000)/100); /* index of the LUT */ | ||
957 | val = (lut_1000ln_mant[ix] + 693*(exp-20) - 6908); /* 1000 * ln(adcpower_real) ; 693 = 1000ln(2) ; 6908 = 1000*ln(1000) ; 20 comes from adc_real = adc_pow_int / 2**20 */ | ||
958 | val = (val*256)/1000; | ||
959 | } | ||
960 | return val; | ||
961 | } | ||
962 | EXPORT_SYMBOL(dib8000_get_adc_power); | ||
963 | |||
942 | static void dib8000_update_timf(struct dib8000_state *state) | 964 | static void dib8000_update_timf(struct dib8000_state *state) |
943 | { | 965 | { |
944 | u32 timf = state->timf = dib8000_read32(state, 435); | 966 | u32 timf = state->timf = dib8000_read32(state, 435); |
@@ -1854,6 +1876,24 @@ static int dib8000_sleep(struct dvb_frontend *fe) | |||
1854 | } | 1876 | } |
1855 | } | 1877 | } |
1856 | 1878 | ||
1879 | enum frontend_tune_state dib8000_get_tune_state(struct dvb_frontend* fe) | ||
1880 | { | ||
1881 | struct dib8000_state *state = fe->demodulator_priv; | ||
1882 | return state->tune_state; | ||
1883 | } | ||
1884 | EXPORT_SYMBOL(dib8000_get_tune_state); | ||
1885 | |||
1886 | int dib8000_set_tune_state(struct dvb_frontend* fe, enum frontend_tune_state tune_state) | ||
1887 | { | ||
1888 | struct dib8000_state *state = fe->demodulator_priv; | ||
1889 | state->tune_state = tune_state; | ||
1890 | return 0; | ||
1891 | } | ||
1892 | EXPORT_SYMBOL(dib8000_set_tune_state); | ||
1893 | |||
1894 | |||
1895 | |||
1896 | |||
1857 | static int dib8000_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep) | 1897 | static int dib8000_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep) |
1858 | { | 1898 | { |
1859 | struct dib8000_state *state = fe->demodulator_priv; | 1899 | struct dib8000_state *state = fe->demodulator_priv; |