aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb-frontends
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2013-01-24 09:48:44 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-01-24 11:26:55 -0500
commitad0abbf118519c14fee5256395f9c104e8023e9b (patch)
tree3b8165a66484c6d75210a9b8646da643202448ce /drivers/media/dvb-frontends
parent593ae89a3f2ea69b0cffb8d8ca63549c6c02ec19 (diff)
[media] mb86a20s: some fixes at preBER logic
The logic that resets the device is wrong. It should be resetting just the layer that got read. Also, stop is needed before updating the counters. While there, rename it, as we'll soon introduce a postBER logic there. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb-frontends')
-rw-r--r--drivers/media/dvb-frontends/mb86a20s.c51
1 files changed, 39 insertions, 12 deletions
diff --git a/drivers/media/dvb-frontends/mb86a20s.c b/drivers/media/dvb-frontends/mb86a20s.c
index c5c2c49ea99a..305ebc08cf43 100644
--- a/drivers/media/dvb-frontends/mb86a20s.c
+++ b/drivers/media/dvb-frontends/mb86a20s.c
@@ -785,12 +785,12 @@ ok:
785 return rc; 785 return rc;
786} 786}
787 787
788static int mb86a20s_get_ber_before_vterbi(struct dvb_frontend *fe, 788static int mb86a20s_get_pre_ber(struct dvb_frontend *fe,
789 unsigned layer, 789 unsigned layer,
790 u32 *error, u32 *count) 790 u32 *error, u32 *count)
791{ 791{
792 struct mb86a20s_state *state = fe->demodulator_priv; 792 struct mb86a20s_state *state = fe->demodulator_priv;
793 int rc; 793 int rc, val;
794 794
795 dev_dbg(&state->i2c->dev, "%s called.\n", __func__); 795 dev_dbg(&state->i2c->dev, "%s called.\n", __func__);
796 796
@@ -805,7 +805,7 @@ static int mb86a20s_get_ber_before_vterbi(struct dvb_frontend *fe,
805 /* Check if data is available for that layer */ 805 /* Check if data is available for that layer */
806 if (!(rc & (1 << layer))) { 806 if (!(rc & (1 << layer))) {
807 dev_dbg(&state->i2c->dev, 807 dev_dbg(&state->i2c->dev,
808 "%s: BER for layer %c is not available yet.\n", 808 "%s: preBER for layer %c is not available yet.\n",
809 __func__, 'A' + layer); 809 __func__, 'A' + layer);
810 return -EBUSY; 810 return -EBUSY;
811 } 811 }
@@ -866,8 +866,13 @@ static int mb86a20s_get_ber_before_vterbi(struct dvb_frontend *fe,
866 if (state->estimated_rate[layer] 866 if (state->estimated_rate[layer]
867 && state->estimated_rate[layer] != *count) { 867 && state->estimated_rate[layer] != *count) {
868 dev_dbg(&state->i2c->dev, 868 dev_dbg(&state->i2c->dev,
869 "%s: updating layer %c counter to %d.\n", 869 "%s: updating layer %c preBER counter to %d.\n",
870 __func__, 'A' + layer, state->estimated_rate[layer]); 870 __func__, 'A' + layer, state->estimated_rate[layer]);
871
872 /* Turn off BER before Viterbi */
873 rc = mb86a20s_writereg(state, 0x52, 0x00);
874
875 /* Update counter for this layer */
871 rc = mb86a20s_writereg(state, 0x50, 0xa7 + layer * 3); 876 rc = mb86a20s_writereg(state, 0x50, 0xa7 + layer * 3);
872 if (rc < 0) 877 if (rc < 0)
873 return rc; 878 return rc;
@@ -889,16 +894,39 @@ static int mb86a20s_get_ber_before_vterbi(struct dvb_frontend *fe,
889 state->estimated_rate[layer]); 894 state->estimated_rate[layer]);
890 if (rc < 0) 895 if (rc < 0)
891 return rc; 896 return rc;
897
898 /* Turn on BER before Viterbi */
899 rc = mb86a20s_writereg(state, 0x52, 0x01);
900
901 /* Reset all preBER counters */
902 rc = mb86a20s_writereg(state, 0x53, 0x00);
903 if (rc < 0)
904 return rc;
905 rc = mb86a20s_writereg(state, 0x53, 0x07);
906 } else {
907 /* Reset counter to collect new data */
908 rc = mb86a20s_readreg(state, 0x53);
909 if (rc < 0)
910 return rc;
911 val = rc;
912 rc = mb86a20s_writereg(state, 0x53, val & ~(1 << layer));
913 if (rc < 0)
914 return rc;
915 rc = mb86a20s_writereg(state, 0x53, val | (1 << layer));
892 } 916 }
893 917
894 918
895 /* Reset counter to collect new data */ 919 /* Reset counter to collect new data */
896 rc = mb86a20s_writereg(state, 0x53, 0x07 & ~(1 << layer)); 920 rc = mb86a20s_readreg(state, 0x5f);
897 if (rc < 0) 921 if (rc < 0)
898 return rc; 922 return rc;
899 rc = mb86a20s_writereg(state, 0x53, 0x07); 923 val = rc;
924 rc = mb86a20s_writereg(state, 0x5f, val & ~(1 << layer));
925 if (rc < 0)
926 return rc;
927 rc = mb86a20s_writereg(state, 0x5f, val);
900 928
901 return 0; 929 return rc;
902} 930}
903 931
904static int mb86a20s_get_blk_error(struct dvb_frontend *fe, 932static int mb86a20s_get_blk_error(struct dvb_frontend *fe,
@@ -1401,9 +1429,8 @@ static int mb86a20s_get_stats(struct dvb_frontend *fe)
1401 1429
1402 /* Read per-layer BER */ 1430 /* Read per-layer BER */
1403 /* Handle BER before vterbi */ 1431 /* Handle BER before vterbi */
1404 rc = mb86a20s_get_ber_before_vterbi(fe, i, 1432 rc = mb86a20s_get_pre_ber(fe, i,
1405 &bit_error, 1433 &bit_error, &bit_count);
1406 &bit_count);
1407 if (rc >= 0) { 1434 if (rc >= 0) {
1408 c->pre_bit_error.stat[1 + i].scale = FE_SCALE_COUNTER; 1435 c->pre_bit_error.stat[1 + i].scale = FE_SCALE_COUNTER;
1409 c->pre_bit_error.stat[1 + i].uvalue += bit_error; 1436 c->pre_bit_error.stat[1 + i].uvalue += bit_error;