Merge tag 'acpica-4.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael...
[firefly-linux-kernel-4.4.55.git] / drivers / media / dvb-frontends / cx24120.c
index d1c7ccb94c225fa8f5ef0e3f04658b3eaf51ca59..3b0ef52bb8342a049ea7cbd6a719b71ae548776a 100644 (file)
@@ -118,12 +118,12 @@ enum command_message_id {
 struct cx24120_tuning {
        u32 frequency;
        u32 symbol_rate;
-       fe_spectral_inversion_t inversion;
-       fe_code_rate_t fec;
+       enum fe_spectral_inversion inversion;
+       enum fe_code_rate fec;
 
-       fe_delivery_system_t delsys;
-       fe_modulation_t modulation;
-       fe_pilot_t pilot;
+       enum fe_delivery_system delsys;
+       enum fe_modulation modulation;
+       enum fe_pilot pilot;
 
        /* Demod values */
        u8 fec_val;
@@ -148,13 +148,13 @@ struct cx24120_state {
        struct cx24120_tuning dcur;
        struct cx24120_tuning dnxt;
 
-       fe_status_t fe_status;
+       enum fe_status fe_status;
 
        /* dvbv5 stats calculations */
        u32 bitrate;
        u32 berw_usecs;
        u32 ber_prev;
-       u32 per_prev;
+       u32 ucb_offset;
        unsigned long ber_jiffies_stats;
        unsigned long per_jiffies_stats;
 };
@@ -491,7 +491,7 @@ static int cx24120_msg_mpeg_output_config(struct cx24120_state *state, u8 seq)
 }
 
 static int cx24120_diseqc_send_burst(struct dvb_frontend *fe,
-                                    fe_sec_mini_cmd_t burst)
+                                    enum fe_sec_mini_cmd burst)
 {
        struct cx24120_state *state = fe->demodulator_priv;
        struct cx24120_cmd cmd;
@@ -513,7 +513,7 @@ static int cx24120_diseqc_send_burst(struct dvb_frontend *fe,
        return cx24120_message_send(state, &cmd);
 }
 
-static int cx24120_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone)
+static int cx24120_set_tone(struct dvb_frontend *fe, enum fe_sec_tone_mode tone)
 {
        struct cx24120_state *state = fe->demodulator_priv;
        struct cx24120_cmd cmd;
@@ -536,7 +536,7 @@ static int cx24120_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone)
 }
 
 static int cx24120_set_voltage(struct dvb_frontend *fe,
-                              fe_sec_voltage_t voltage)
+                              enum fe_sec_voltage voltage)
 {
        struct cx24120_state *state = fe->demodulator_priv;
        struct cx24120_cmd cmd;
@@ -698,8 +698,12 @@ static void cx24120_get_stats(struct cx24120_state *state)
                ucb |= cx24120_readreg(state, CX24120_REG_UCB_L);
                dev_dbg(&state->i2c->dev, "ucblocks = %d\n", ucb);
 
+               /* handle reset */
+               if (ucb < state->ucb_offset)
+                       state->ucb_offset = c->block_error.stat[0].uvalue;
+
                c->block_error.stat[0].scale = FE_SCALE_COUNTER;
-               c->block_error.stat[0].uvalue += ucb;
+               c->block_error.stat[0].uvalue = ucb + state->ucb_offset;
 
                c->block_count.stat[0].scale = FE_SCALE_COUNTER;
                c->block_count.stat[0].uvalue += state->bitrate / 8 / 208;
@@ -709,7 +713,7 @@ static void cx24120_get_stats(struct cx24120_state *state)
 static void cx24120_set_clock_ratios(struct dvb_frontend *fe);
 
 /* Read current tuning status */
-static int cx24120_read_status(struct dvb_frontend *fe, fe_status_t *status)
+static int cx24120_read_status(struct dvb_frontend *fe, enum fe_status *status)
 {
        struct cx24120_state *state = fe->demodulator_priv;
        int lock;
@@ -761,9 +765,9 @@ static int cx24120_read_status(struct dvb_frontend *fe, fe_status_t *status)
  * once tuned in.
  */
 struct cx24120_modfec {
-       fe_delivery_system_t delsys;
-       fe_modulation_t mod;
-       fe_code_rate_t fec;
+       enum fe_delivery_system delsys;
+       enum fe_modulation mod;
+       enum fe_code_rate fec;
        u8 val;
 };
 
@@ -834,7 +838,7 @@ static int cx24120_get_fec(struct dvb_frontend *fe)
 }
 
 /* Calculate ber window time */
-void cx24120_calculate_ber_window(struct cx24120_state *state, u32 rate)
+static void cx24120_calculate_ber_window(struct cx24120_state *state, u32 rate)
 {
        struct dvb_frontend *fe = &state->frontend;
        struct dtv_frontend_properties *c = &fe->dtv_property_cache;
@@ -867,10 +871,10 @@ void cx24120_calculate_ber_window(struct cx24120_state *state, u32 rate)
  * can't determine the pattern
  */
 struct cx24120_clock_ratios_table {
-       fe_delivery_system_t delsys;
-       fe_pilot_t pilot;
-       fe_modulation_t mod;
-       fe_code_rate_t fec;
+       enum fe_delivery_system delsys;
+       enum fe_pilot pilot;
+       enum fe_modulation mod;
+       enum fe_code_rate fec;
        u32 m_rat;
        u32 n_rat;
        u32 rate;
@@ -984,7 +988,7 @@ static void cx24120_set_clock_ratios(struct dvb_frontend *fe)
 
 /* Set inversion value */
 static int cx24120_set_inversion(struct cx24120_state *state,
-                                fe_spectral_inversion_t inversion)
+                                enum fe_spectral_inversion inversion)
 {
        dev_dbg(&state->i2c->dev, "(%d)\n", inversion);
 
@@ -1009,9 +1013,9 @@ static int cx24120_set_inversion(struct cx24120_state *state,
 
 /* FEC lookup table for tuning */
 struct cx24120_modfec_table {
-       fe_delivery_system_t delsys;
-       fe_modulation_t mod;
-       fe_code_rate_t fec;
+       enum fe_delivery_system delsys;
+       enum fe_modulation mod;
+       enum fe_code_rate fec;
        u8 val;
 };
 
@@ -1042,8 +1046,8 @@ static const struct cx24120_modfec_table modfec_table[] = {
 };
 
 /* Set fec_val & fec_mask values from delsys, modulation & fec */
-static int cx24120_set_fec(struct cx24120_state *state, fe_modulation_t mod,
-                          fe_code_rate_t fec)
+static int cx24120_set_fec(struct cx24120_state *state, enum fe_modulation mod,
+                          enum fe_code_rate fec)
 {
        int idx;
 
@@ -1080,7 +1084,7 @@ static int cx24120_set_fec(struct cx24120_state *state, fe_modulation_t mod,
 }
 
 /* Set pilot */
-static int cx24120_set_pilot(struct cx24120_state *state, fe_pilot_t pilot)
+static int cx24120_set_pilot(struct cx24120_state *state, enum fe_pilot pilot)
 {
        dev_dbg(&state->i2c->dev, "(%d)\n", pilot);
 
@@ -1463,14 +1467,14 @@ static int cx24120_init(struct dvb_frontend *fe)
        c->block_count.len = 1;
        c->block_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
 
-
        state->cold_init = 1;
+
        return 0;
 }
 
 static int cx24120_tune(struct dvb_frontend *fe, bool re_tune,
                        unsigned int mode_flags, unsigned int *delay,
-                       fe_status_t *status)
+                       enum fe_status *status)
 {
        struct cx24120_state *state = fe->demodulator_priv;
        int ret;
@@ -1541,8 +1545,7 @@ static int cx24120_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
                return 0;
        }
 
-       *ucblocks = c->block_error.stat[0].uvalue - state->per_prev;
-       state->per_prev = c->block_error.stat[0].uvalue;
+       *ucblocks = c->block_error.stat[0].uvalue - state->ucb_offset;
 
        return 0;
 }