diff options
author | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-07-04 13:15:29 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-07-07 08:55:31 -0400 |
commit | 7fa676c6f4d758271dfe6ff5b4bfece3eacb9aeb (patch) | |
tree | a4f5ca66ec830c9b3f7e618d67547b0364acb1ce /drivers/media/dvb-frontends/dib8000.c | |
parent | c063c7c6a355cc7214ed8fb31d5e989b3baa0b87 (diff) |
[media] dib8000: Fix alignments at dib8000_tune()
There are two tabs instead of one aligning this struct.
Worse than that, on some places, the alignment is wrong.
Fix it.
No functional changes.
Acked-By: Patrick Boettcher <pboettcher@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media/dvb-frontends/dib8000.c')
-rw-r--r-- | drivers/media/dvb-frontends/dib8000.c | 486 |
1 files changed, 243 insertions, 243 deletions
diff --git a/drivers/media/dvb-frontends/dib8000.c b/drivers/media/dvb-frontends/dib8000.c index 8dd34e0194fe..43d1261afba0 100644 --- a/drivers/media/dvb-frontends/dib8000.c +++ b/drivers/media/dvb-frontends/dib8000.c | |||
@@ -3018,313 +3018,313 @@ static int dib8000_tune(struct dvb_frontend *fe) | |||
3018 | 3018 | ||
3019 | switch (*tune_state) { | 3019 | switch (*tune_state) { |
3020 | case CT_DEMOD_START: /* 30 */ | 3020 | case CT_DEMOD_START: /* 30 */ |
3021 | dib8000_reset_stats(fe); | 3021 | dib8000_reset_stats(fe); |
3022 | 3022 | ||
3023 | if (state->revision == 0x8090) | 3023 | if (state->revision == 0x8090) |
3024 | dib8090p_init_sdram(state); | 3024 | dib8090p_init_sdram(state); |
3025 | state->status = FE_STATUS_TUNE_PENDING; | 3025 | state->status = FE_STATUS_TUNE_PENDING; |
3026 | state->channel_parameters_set = is_manual_mode(c); | 3026 | state->channel_parameters_set = is_manual_mode(c); |
3027 | 3027 | ||
3028 | dprintk("Tuning channel on %s search mode", | 3028 | dprintk("Tuning channel on %s search mode", |
3029 | state->channel_parameters_set ? "manual" : "auto"); | 3029 | state->channel_parameters_set ? "manual" : "auto"); |
3030 | 3030 | ||
3031 | dib8000_viterbi_state(state, 0); /* force chan dec in restart */ | 3031 | dib8000_viterbi_state(state, 0); /* force chan dec in restart */ |
3032 | 3032 | ||
3033 | /* Layer monitor */ | 3033 | /* Layer monitor */ |
3034 | dib8000_write_word(state, 285, dib8000_read_word(state, 285) & 0x60); | 3034 | dib8000_write_word(state, 285, dib8000_read_word(state, 285) & 0x60); |
3035 | 3035 | ||
3036 | dib8000_set_frequency_offset(state); | 3036 | dib8000_set_frequency_offset(state); |
3037 | dib8000_set_bandwidth(fe, c->bandwidth_hz / 1000); | 3037 | dib8000_set_bandwidth(fe, c->bandwidth_hz / 1000); |
3038 | 3038 | ||
3039 | if (state->channel_parameters_set == 0) { /* The channel struct is unknown, search it ! */ | 3039 | if (state->channel_parameters_set == 0) { /* The channel struct is unknown, search it ! */ |
3040 | #ifdef DIB8000_AGC_FREEZE | 3040 | #ifdef DIB8000_AGC_FREEZE |
3041 | if (state->revision != 0x8090) { | 3041 | if (state->revision != 0x8090) { |
3042 | state->agc1_max = dib8000_read_word(state, 108); | 3042 | state->agc1_max = dib8000_read_word(state, 108); |
3043 | state->agc1_min = dib8000_read_word(state, 109); | 3043 | state->agc1_min = dib8000_read_word(state, 109); |
3044 | state->agc2_max = dib8000_read_word(state, 110); | 3044 | state->agc2_max = dib8000_read_word(state, 110); |
3045 | state->agc2_min = dib8000_read_word(state, 111); | 3045 | state->agc2_min = dib8000_read_word(state, 111); |
3046 | agc1 = dib8000_read_word(state, 388); | 3046 | agc1 = dib8000_read_word(state, 388); |
3047 | agc2 = dib8000_read_word(state, 389); | 3047 | agc2 = dib8000_read_word(state, 389); |
3048 | dib8000_write_word(state, 108, agc1); | 3048 | dib8000_write_word(state, 108, agc1); |
3049 | dib8000_write_word(state, 109, agc1); | 3049 | dib8000_write_word(state, 109, agc1); |
3050 | dib8000_write_word(state, 110, agc2); | 3050 | dib8000_write_word(state, 110, agc2); |
3051 | dib8000_write_word(state, 111, agc2); | 3051 | dib8000_write_word(state, 111, agc2); |
3052 | } | ||
3053 | #endif | ||
3054 | state->autosearch_state = AS_SEARCHING_FFT; | ||
3055 | state->found_nfft = TRANSMISSION_MODE_AUTO; | ||
3056 | state->found_guard = GUARD_INTERVAL_AUTO; | ||
3057 | *tune_state = CT_DEMOD_SEARCH_NEXT; | ||
3058 | } else { /* we already know the channel struct so TUNE only ! */ | ||
3059 | state->autosearch_state = AS_DONE; | ||
3060 | *tune_state = CT_DEMOD_STEP_3; | ||
3061 | } | 3052 | } |
3062 | state->symbol_duration = dib8000_get_symbol_duration(state); | 3053 | #endif |
3063 | break; | 3054 | state->autosearch_state = AS_SEARCHING_FFT; |
3055 | state->found_nfft = TRANSMISSION_MODE_AUTO; | ||
3056 | state->found_guard = GUARD_INTERVAL_AUTO; | ||
3057 | *tune_state = CT_DEMOD_SEARCH_NEXT; | ||
3058 | } else { /* we already know the channel struct so TUNE only ! */ | ||
3059 | state->autosearch_state = AS_DONE; | ||
3060 | *tune_state = CT_DEMOD_STEP_3; | ||
3061 | } | ||
3062 | state->symbol_duration = dib8000_get_symbol_duration(state); | ||
3063 | break; | ||
3064 | 3064 | ||
3065 | case CT_DEMOD_SEARCH_NEXT: /* 51 */ | 3065 | case CT_DEMOD_SEARCH_NEXT: /* 51 */ |
3066 | dib8000_autosearch_start(fe); | 3066 | dib8000_autosearch_start(fe); |
3067 | if (state->revision == 0x8090) | 3067 | if (state->revision == 0x8090) |
3068 | ret = 50; | 3068 | ret = 50; |
3069 | else | 3069 | else |
3070 | ret = 15; | 3070 | ret = 15; |
3071 | *tune_state = CT_DEMOD_STEP_1; | 3071 | *tune_state = CT_DEMOD_STEP_1; |
3072 | break; | 3072 | break; |
3073 | 3073 | ||
3074 | case CT_DEMOD_STEP_1: /* 31 */ | 3074 | case CT_DEMOD_STEP_1: /* 31 */ |
3075 | switch (dib8000_autosearch_irq(fe)) { | 3075 | switch (dib8000_autosearch_irq(fe)) { |
3076 | case 1: /* fail */ | 3076 | case 1: /* fail */ |
3077 | state->status = FE_STATUS_TUNE_FAILED; | 3077 | state->status = FE_STATUS_TUNE_FAILED; |
3078 | state->autosearch_state = AS_DONE; | 3078 | state->autosearch_state = AS_DONE; |
3079 | *tune_state = CT_DEMOD_STOP; /* else we are done here */ | 3079 | *tune_state = CT_DEMOD_STOP; /* else we are done here */ |
3080 | break; | 3080 | break; |
3081 | case 2: /* Succes */ | 3081 | case 2: /* Succes */ |
3082 | state->status = FE_STATUS_FFT_SUCCESS; /* signal to the upper layer, that there was a channel found and the parameters can be read */ | 3082 | state->status = FE_STATUS_FFT_SUCCESS; /* signal to the upper layer, that there was a channel found and the parameters can be read */ |
3083 | *tune_state = CT_DEMOD_STEP_3; | 3083 | *tune_state = CT_DEMOD_STEP_3; |
3084 | if (state->autosearch_state == AS_SEARCHING_GUARD) | 3084 | if (state->autosearch_state == AS_SEARCHING_GUARD) |
3085 | *tune_state = CT_DEMOD_STEP_2; | 3085 | *tune_state = CT_DEMOD_STEP_2; |
3086 | else | 3086 | else |
3087 | state->autosearch_state = AS_DONE; | 3087 | state->autosearch_state = AS_DONE; |
3088 | break; | 3088 | break; |
3089 | case 3: /* Autosearch FFT max correlation endded */ | 3089 | case 3: /* Autosearch FFT max correlation endded */ |
3090 | *tune_state = CT_DEMOD_STEP_2; | 3090 | *tune_state = CT_DEMOD_STEP_2; |
3091 | break; | ||
3092 | } | ||
3093 | break; | 3091 | break; |
3092 | } | ||
3093 | break; | ||
3094 | 3094 | ||
3095 | case CT_DEMOD_STEP_2: | 3095 | case CT_DEMOD_STEP_2: |
3096 | switch (state->autosearch_state) { | 3096 | switch (state->autosearch_state) { |
3097 | case AS_SEARCHING_FFT: | 3097 | case AS_SEARCHING_FFT: |
3098 | /* searching for the correct FFT */ | 3098 | /* searching for the correct FFT */ |
3099 | if (state->revision == 0x8090) { | 3099 | if (state->revision == 0x8090) { |
3100 | corm[2] = (dib8000_read_word(state, 596) << 16) | (dib8000_read_word(state, 597)); | 3100 | corm[2] = (dib8000_read_word(state, 596) << 16) | (dib8000_read_word(state, 597)); |
3101 | corm[1] = (dib8000_read_word(state, 598) << 16) | (dib8000_read_word(state, 599)); | 3101 | corm[1] = (dib8000_read_word(state, 598) << 16) | (dib8000_read_word(state, 599)); |
3102 | corm[0] = (dib8000_read_word(state, 600) << 16) | (dib8000_read_word(state, 601)); | 3102 | corm[0] = (dib8000_read_word(state, 600) << 16) | (dib8000_read_word(state, 601)); |
3103 | } else { | 3103 | } else { |
3104 | corm[2] = (dib8000_read_word(state, 594) << 16) | (dib8000_read_word(state, 595)); | 3104 | corm[2] = (dib8000_read_word(state, 594) << 16) | (dib8000_read_word(state, 595)); |
3105 | corm[1] = (dib8000_read_word(state, 596) << 16) | (dib8000_read_word(state, 597)); | 3105 | corm[1] = (dib8000_read_word(state, 596) << 16) | (dib8000_read_word(state, 597)); |
3106 | corm[0] = (dib8000_read_word(state, 598) << 16) | (dib8000_read_word(state, 599)); | 3106 | corm[0] = (dib8000_read_word(state, 598) << 16) | (dib8000_read_word(state, 599)); |
3107 | } | 3107 | } |
3108 | /* dprintk("corm fft: %u %u %u", corm[0], corm[1], corm[2]); */ | 3108 | /* dprintk("corm fft: %u %u %u", corm[0], corm[1], corm[2]); */ |
3109 | 3109 | ||
3110 | max_value = 0; | 3110 | max_value = 0; |
3111 | for (find_index = 1 ; find_index < 3 ; find_index++) { | 3111 | for (find_index = 1 ; find_index < 3 ; find_index++) { |
3112 | if (corm[max_value] < corm[find_index]) | 3112 | if (corm[max_value] < corm[find_index]) |
3113 | max_value = find_index ; | 3113 | max_value = find_index ; |
3114 | } | 3114 | } |
3115 | 3115 | ||
3116 | switch (max_value) { | 3116 | switch (max_value) { |
3117 | case 0: | 3117 | case 0: |
3118 | state->found_nfft = TRANSMISSION_MODE_2K; | 3118 | state->found_nfft = TRANSMISSION_MODE_2K; |
3119 | break; | 3119 | break; |
3120 | case 1: | 3120 | case 1: |
3121 | state->found_nfft = TRANSMISSION_MODE_4K; | 3121 | state->found_nfft = TRANSMISSION_MODE_4K; |
3122 | break; | 3122 | break; |
3123 | case 2: | 3123 | case 2: |
3124 | default: | ||
3125 | state->found_nfft = TRANSMISSION_MODE_8K; | ||
3126 | break; | ||
3127 | } | ||
3128 | /* dprintk("Autosearch FFT has found Mode %d", max_value + 1); */ | ||
3129 | |||
3130 | *tune_state = CT_DEMOD_SEARCH_NEXT; | ||
3131 | state->autosearch_state = AS_SEARCHING_GUARD; | ||
3132 | if (state->revision == 0x8090) | ||
3133 | ret = 50; | ||
3134 | else | ||
3135 | ret = 10; | ||
3136 | break; | ||
3137 | case AS_SEARCHING_GUARD: | ||
3138 | /* searching for the correct guard interval */ | ||
3139 | if (state->revision == 0x8090) | ||
3140 | state->found_guard = dib8000_read_word(state, 572) & 0x3; | ||
3141 | else | ||
3142 | state->found_guard = dib8000_read_word(state, 570) & 0x3; | ||
3143 | /* dprintk("guard interval found=%i", state->found_guard); */ | ||
3144 | |||
3145 | *tune_state = CT_DEMOD_STEP_3; | ||
3146 | break; | ||
3147 | default: | 3124 | default: |
3148 | /* the demod should never be in this state */ | 3125 | state->found_nfft = TRANSMISSION_MODE_8K; |
3149 | state->status = FE_STATUS_TUNE_FAILED; | 3126 | break; |
3150 | state->autosearch_state = AS_DONE; | ||
3151 | *tune_state = CT_DEMOD_STOP; /* else we are done here */ | ||
3152 | break; | ||
3153 | } | 3127 | } |
3128 | /* dprintk("Autosearch FFT has found Mode %d", max_value + 1); */ | ||
3129 | |||
3130 | *tune_state = CT_DEMOD_SEARCH_NEXT; | ||
3131 | state->autosearch_state = AS_SEARCHING_GUARD; | ||
3132 | if (state->revision == 0x8090) | ||
3133 | ret = 50; | ||
3134 | else | ||
3135 | ret = 10; | ||
3154 | break; | 3136 | break; |
3137 | case AS_SEARCHING_GUARD: | ||
3138 | /* searching for the correct guard interval */ | ||
3139 | if (state->revision == 0x8090) | ||
3140 | state->found_guard = dib8000_read_word(state, 572) & 0x3; | ||
3141 | else | ||
3142 | state->found_guard = dib8000_read_word(state, 570) & 0x3; | ||
3143 | /* dprintk("guard interval found=%i", state->found_guard); */ | ||
3155 | 3144 | ||
3156 | case CT_DEMOD_STEP_3: /* 33 */ | 3145 | *tune_state = CT_DEMOD_STEP_3; |
3157 | state->symbol_duration = dib8000_get_symbol_duration(state); | ||
3158 | dib8000_set_isdbt_loop_params(state, LOOP_TUNE_1); | ||
3159 | dib8000_set_isdbt_common_channel(state, 0, 0);/* setting the known channel parameters here */ | ||
3160 | *tune_state = CT_DEMOD_STEP_4; | ||
3161 | break; | 3146 | break; |
3147 | default: | ||
3148 | /* the demod should never be in this state */ | ||
3149 | state->status = FE_STATUS_TUNE_FAILED; | ||
3150 | state->autosearch_state = AS_DONE; | ||
3151 | *tune_state = CT_DEMOD_STOP; /* else we are done here */ | ||
3152 | break; | ||
3153 | } | ||
3154 | break; | ||
3155 | |||
3156 | case CT_DEMOD_STEP_3: /* 33 */ | ||
3157 | state->symbol_duration = dib8000_get_symbol_duration(state); | ||
3158 | dib8000_set_isdbt_loop_params(state, LOOP_TUNE_1); | ||
3159 | dib8000_set_isdbt_common_channel(state, 0, 0);/* setting the known channel parameters here */ | ||
3160 | *tune_state = CT_DEMOD_STEP_4; | ||
3161 | break; | ||
3162 | 3162 | ||
3163 | case CT_DEMOD_STEP_4: /* (34) */ | 3163 | case CT_DEMOD_STEP_4: /* (34) */ |
3164 | dib8000_demod_restart(state); | 3164 | dib8000_demod_restart(state); |
3165 | 3165 | ||
3166 | dib8000_set_sync_wait(state); | 3166 | dib8000_set_sync_wait(state); |
3167 | dib8000_set_diversity_in(state->fe[0], state->diversity_onoff); | 3167 | dib8000_set_diversity_in(state->fe[0], state->diversity_onoff); |
3168 | 3168 | ||
3169 | locks = (dib8000_read_word(state, 180) >> 6) & 0x3f; /* P_coff_winlen ? */ | 3169 | locks = (dib8000_read_word(state, 180) >> 6) & 0x3f; /* P_coff_winlen ? */ |
3170 | /* coff should lock over P_coff_winlen ofdm symbols : give 3 times this length to lock */ | 3170 | /* coff should lock over P_coff_winlen ofdm symbols : give 3 times this length to lock */ |
3171 | *timeout = dib8000_get_timeout(state, 2 * locks, SYMBOL_DEPENDENT_ON); | 3171 | *timeout = dib8000_get_timeout(state, 2 * locks, SYMBOL_DEPENDENT_ON); |
3172 | *tune_state = CT_DEMOD_STEP_5; | 3172 | *tune_state = CT_DEMOD_STEP_5; |
3173 | break; | 3173 | break; |
3174 | 3174 | ||
3175 | case CT_DEMOD_STEP_5: /* (35) */ | 3175 | case CT_DEMOD_STEP_5: /* (35) */ |
3176 | locks = dib8000_read_lock(fe); | 3176 | locks = dib8000_read_lock(fe); |
3177 | if (locks & (0x3 << 11)) { /* coff-lock and off_cpil_lock achieved */ | 3177 | if (locks & (0x3 << 11)) { /* coff-lock and off_cpil_lock achieved */ |
3178 | dib8000_update_timf(state); /* we achieved a coff_cpil_lock - it's time to update the timf */ | 3178 | dib8000_update_timf(state); /* we achieved a coff_cpil_lock - it's time to update the timf */ |
3179 | if (!state->differential_constellation) { | 3179 | if (!state->differential_constellation) { |
3180 | /* 2 times lmod4_win_len + 10 symbols (pipe delay after coff + nb to compute a 1st correlation) */ | 3180 | /* 2 times lmod4_win_len + 10 symbols (pipe delay after coff + nb to compute a 1st correlation) */ |
3181 | *timeout = dib8000_get_timeout(state, (20 * ((dib8000_read_word(state, 188)>>5)&0x1f)), SYMBOL_DEPENDENT_ON); | 3181 | *timeout = dib8000_get_timeout(state, (20 * ((dib8000_read_word(state, 188)>>5)&0x1f)), SYMBOL_DEPENDENT_ON); |
3182 | *tune_state = CT_DEMOD_STEP_7; | 3182 | *tune_state = CT_DEMOD_STEP_7; |
3183 | } else { | 3183 | } else { |
3184 | *tune_state = CT_DEMOD_STEP_8; | 3184 | *tune_state = CT_DEMOD_STEP_8; |
3185 | } | ||
3186 | } else if (now > *timeout) { | ||
3187 | *tune_state = CT_DEMOD_STEP_6; /* goto check for diversity input connection */ | ||
3188 | } | 3185 | } |
3189 | break; | 3186 | } else if (now > *timeout) { |
3187 | *tune_state = CT_DEMOD_STEP_6; /* goto check for diversity input connection */ | ||
3188 | } | ||
3189 | break; | ||
3190 | 3190 | ||
3191 | case CT_DEMOD_STEP_6: /* (36) if there is an input (diversity) */ | 3191 | case CT_DEMOD_STEP_6: /* (36) if there is an input (diversity) */ |
3192 | if ((state->fe[1] != NULL) && (state->output_mode != OUTMODE_DIVERSITY)) { | 3192 | if ((state->fe[1] != NULL) && (state->output_mode != OUTMODE_DIVERSITY)) { |
3193 | /* if there is a diversity fe in input and this fe is has not already failled : wait here until this this fe has succedeed or failled */ | 3193 | /* if there is a diversity fe in input and this fe is has not already failled : wait here until this this fe has succedeed or failled */ |
3194 | if (dib8000_get_status(state->fe[1]) <= FE_STATUS_STD_SUCCESS) /* Something is locked on the input fe */ | 3194 | if (dib8000_get_status(state->fe[1]) <= FE_STATUS_STD_SUCCESS) /* Something is locked on the input fe */ |
3195 | *tune_state = CT_DEMOD_STEP_8; /* go for mpeg */ | 3195 | *tune_state = CT_DEMOD_STEP_8; /* go for mpeg */ |
3196 | else if (dib8000_get_status(state->fe[1]) >= FE_STATUS_TUNE_TIME_TOO_SHORT) { /* fe in input failled also, break the current one */ | 3196 | else if (dib8000_get_status(state->fe[1]) >= FE_STATUS_TUNE_TIME_TOO_SHORT) { /* fe in input failled also, break the current one */ |
3197 | *tune_state = CT_DEMOD_STOP; /* else we are done here ; step 8 will close the loops and exit */ | 3197 | *tune_state = CT_DEMOD_STOP; /* else we are done here ; step 8 will close the loops and exit */ |
3198 | dib8000_viterbi_state(state, 1); /* start viterbi chandec */ | ||
3199 | dib8000_set_isdbt_loop_params(state, LOOP_TUNE_2); | ||
3200 | state->status = FE_STATUS_TUNE_FAILED; | ||
3201 | } | ||
3202 | } else { | ||
3203 | dib8000_viterbi_state(state, 1); /* start viterbi chandec */ | 3198 | dib8000_viterbi_state(state, 1); /* start viterbi chandec */ |
3204 | dib8000_set_isdbt_loop_params(state, LOOP_TUNE_2); | 3199 | dib8000_set_isdbt_loop_params(state, LOOP_TUNE_2); |
3205 | *tune_state = CT_DEMOD_STOP; /* else we are done here ; step 8 will close the loops and exit */ | ||
3206 | state->status = FE_STATUS_TUNE_FAILED; | 3200 | state->status = FE_STATUS_TUNE_FAILED; |
3207 | } | 3201 | } |
3208 | break; | 3202 | } else { |
3203 | dib8000_viterbi_state(state, 1); /* start viterbi chandec */ | ||
3204 | dib8000_set_isdbt_loop_params(state, LOOP_TUNE_2); | ||
3205 | *tune_state = CT_DEMOD_STOP; /* else we are done here ; step 8 will close the loops and exit */ | ||
3206 | state->status = FE_STATUS_TUNE_FAILED; | ||
3207 | } | ||
3208 | break; | ||
3209 | 3209 | ||
3210 | case CT_DEMOD_STEP_7: /* 37 */ | 3210 | case CT_DEMOD_STEP_7: /* 37 */ |
3211 | locks = dib8000_read_lock(fe); | 3211 | locks = dib8000_read_lock(fe); |
3212 | if (locks & (1<<10)) { /* lmod4_lock */ | 3212 | if (locks & (1<<10)) { /* lmod4_lock */ |
3213 | ret = 14; /* wait for 14 symbols */ | 3213 | ret = 14; /* wait for 14 symbols */ |
3214 | *tune_state = CT_DEMOD_STEP_8; | 3214 | *tune_state = CT_DEMOD_STEP_8; |
3215 | } else if (now > *timeout) | 3215 | } else if (now > *timeout) |
3216 | *tune_state = CT_DEMOD_STEP_6; /* goto check for diversity input connection */ | 3216 | *tune_state = CT_DEMOD_STEP_6; /* goto check for diversity input connection */ |
3217 | break; | 3217 | break; |
3218 | 3218 | ||
3219 | case CT_DEMOD_STEP_8: /* 38 */ | 3219 | case CT_DEMOD_STEP_8: /* 38 */ |
3220 | dib8000_viterbi_state(state, 1); /* start viterbi chandec */ | 3220 | dib8000_viterbi_state(state, 1); /* start viterbi chandec */ |
3221 | dib8000_set_isdbt_loop_params(state, LOOP_TUNE_2); | 3221 | dib8000_set_isdbt_loop_params(state, LOOP_TUNE_2); |
3222 | 3222 | ||
3223 | /* mpeg will never lock on this condition because init_prbs is not set : search for it !*/ | 3223 | /* mpeg will never lock on this condition because init_prbs is not set : search for it !*/ |
3224 | if (c->isdbt_sb_mode | 3224 | if (c->isdbt_sb_mode |
3225 | && c->isdbt_sb_subchannel < 14 | 3225 | && c->isdbt_sb_subchannel < 14 |
3226 | && !state->differential_constellation) { | 3226 | && !state->differential_constellation) { |
3227 | state->subchannel = 0; | 3227 | state->subchannel = 0; |
3228 | *tune_state = CT_DEMOD_STEP_11; | 3228 | *tune_state = CT_DEMOD_STEP_11; |
3229 | } else { | 3229 | } else { |
3230 | *tune_state = CT_DEMOD_STEP_9; | 3230 | *tune_state = CT_DEMOD_STEP_9; |
3231 | state->status = FE_STATUS_LOCKED; | 3231 | state->status = FE_STATUS_LOCKED; |
3232 | } | 3232 | } |
3233 | break; | 3233 | break; |
3234 | 3234 | ||
3235 | case CT_DEMOD_STEP_9: /* 39 */ | 3235 | case CT_DEMOD_STEP_9: /* 39 */ |
3236 | if ((state->revision == 0x8090) || ((dib8000_read_word(state, 1291) >> 9) & 0x1)) { /* fe capable of deinterleaving : esram */ | 3236 | if ((state->revision == 0x8090) || ((dib8000_read_word(state, 1291) >> 9) & 0x1)) { /* fe capable of deinterleaving : esram */ |
3237 | /* defines timeout for mpeg lock depending on interleaver length of longest layer */ | 3237 | /* defines timeout for mpeg lock depending on interleaver length of longest layer */ |
3238 | for (i = 0; i < 3; i++) { | 3238 | for (i = 0; i < 3; i++) { |
3239 | if (c->layer[i].interleaving >= deeper_interleaver) { | 3239 | if (c->layer[i].interleaving >= deeper_interleaver) { |
3240 | dprintk("layer%i: time interleaver = %d ", i, c->layer[i].interleaving); | 3240 | dprintk("layer%i: time interleaver = %d ", i, c->layer[i].interleaving); |
3241 | if (c->layer[i].segment_count > 0) { /* valid layer */ | 3241 | if (c->layer[i].segment_count > 0) { /* valid layer */ |
3242 | deeper_interleaver = c->layer[0].interleaving; | 3242 | deeper_interleaver = c->layer[0].interleaving; |
3243 | state->longest_intlv_layer = i; | 3243 | state->longest_intlv_layer = i; |
3244 | } | ||
3245 | } | 3244 | } |
3246 | } | 3245 | } |
3246 | } | ||
3247 | 3247 | ||
3248 | if (deeper_interleaver == 0) | 3248 | if (deeper_interleaver == 0) |
3249 | locks = 2; /* locks is the tmp local variable name */ | 3249 | locks = 2; /* locks is the tmp local variable name */ |
3250 | else if (deeper_interleaver == 3) | 3250 | else if (deeper_interleaver == 3) |
3251 | locks = 8; | 3251 | locks = 8; |
3252 | else | 3252 | else |
3253 | locks = 2 * deeper_interleaver; | 3253 | locks = 2 * deeper_interleaver; |
3254 | 3254 | ||
3255 | if (state->diversity_onoff != 0) /* because of diversity sync */ | 3255 | if (state->diversity_onoff != 0) /* because of diversity sync */ |
3256 | locks *= 2; | 3256 | locks *= 2; |
3257 | 3257 | ||
3258 | *timeout = now + (2000 * locks); /* give the mpeg lock 800ms if sram is present */ | 3258 | *timeout = now + (2000 * locks); /* give the mpeg lock 800ms if sram is present */ |
3259 | dprintk("Deeper interleaver mode = %d on layer %d : timeout mult factor = %d => will use timeout = %d", deeper_interleaver, state->longest_intlv_layer, locks, *timeout); | 3259 | dprintk("Deeper interleaver mode = %d on layer %d : timeout mult factor = %d => will use timeout = %d", deeper_interleaver, state->longest_intlv_layer, locks, *timeout); |
3260 | 3260 | ||
3261 | *tune_state = CT_DEMOD_STEP_10; | 3261 | *tune_state = CT_DEMOD_STEP_10; |
3262 | } else | 3262 | } else |
3263 | *tune_state = CT_DEMOD_STOP; | 3263 | *tune_state = CT_DEMOD_STOP; |
3264 | break; | 3264 | break; |
3265 | 3265 | ||
3266 | case CT_DEMOD_STEP_10: /* 40 */ | 3266 | case CT_DEMOD_STEP_10: /* 40 */ |
3267 | locks = dib8000_read_lock(fe); | 3267 | locks = dib8000_read_lock(fe); |
3268 | if (locks&(1<<(7-state->longest_intlv_layer))) { /* mpeg lock : check the longest one */ | 3268 | if (locks&(1<<(7-state->longest_intlv_layer))) { /* mpeg lock : check the longest one */ |
3269 | dprintk("Mpeg locks [ L0 : %d | L1 : %d | L2 : %d ]", (locks>>7)&0x1, (locks>>6)&0x1, (locks>>5)&0x1); | 3269 | dprintk("Mpeg locks [ L0 : %d | L1 : %d | L2 : %d ]", (locks>>7)&0x1, (locks>>6)&0x1, (locks>>5)&0x1); |
3270 | if (c->isdbt_sb_mode | 3270 | if (c->isdbt_sb_mode |
3271 | && c->isdbt_sb_subchannel < 14 | 3271 | && c->isdbt_sb_subchannel < 14 |
3272 | && !state->differential_constellation) | 3272 | && !state->differential_constellation) |
3273 | /* signal to the upper layer, that there was a channel found and the parameters can be read */ | 3273 | /* signal to the upper layer, that there was a channel found and the parameters can be read */ |
3274 | state->status = FE_STATUS_DEMOD_SUCCESS; | 3274 | state->status = FE_STATUS_DEMOD_SUCCESS; |
3275 | else | 3275 | else |
3276 | state->status = FE_STATUS_DATA_LOCKED; | ||
3277 | *tune_state = CT_DEMOD_STOP; | ||
3278 | } else if (now > *timeout) { | ||
3279 | if (c->isdbt_sb_mode | ||
3280 | && c->isdbt_sb_subchannel < 14 | ||
3281 | && !state->differential_constellation) { /* continue to try init prbs autosearch */ | ||
3282 | state->subchannel += 3; | ||
3283 | *tune_state = CT_DEMOD_STEP_11; | ||
3284 | } else { /* we are done mpeg of the longest interleaver xas not locking but let's try if an other layer has locked in the same time */ | ||
3285 | if (locks & (0x7<<5)) { | ||
3286 | dprintk("Mpeg locks [ L0 : %d | L1 : %d | L2 : %d ]", (locks>>7)&0x1, (locks>>6)&0x1, (locks>>5)&0x1); | ||
3276 | state->status = FE_STATUS_DATA_LOCKED; | 3287 | state->status = FE_STATUS_DATA_LOCKED; |
3288 | } else | ||
3289 | state->status = FE_STATUS_TUNE_FAILED; | ||
3277 | *tune_state = CT_DEMOD_STOP; | 3290 | *tune_state = CT_DEMOD_STOP; |
3278 | } else if (now > *timeout) { | ||
3279 | if (c->isdbt_sb_mode | ||
3280 | && c->isdbt_sb_subchannel < 14 | ||
3281 | && !state->differential_constellation) { /* continue to try init prbs autosearch */ | ||
3282 | state->subchannel += 3; | ||
3283 | *tune_state = CT_DEMOD_STEP_11; | ||
3284 | } else { /* we are done mpeg of the longest interleaver xas not locking but let's try if an other layer has locked in the same time */ | ||
3285 | if (locks & (0x7<<5)) { | ||
3286 | dprintk("Mpeg locks [ L0 : %d | L1 : %d | L2 : %d ]", (locks>>7)&0x1, (locks>>6)&0x1, (locks>>5)&0x1); | ||
3287 | state->status = FE_STATUS_DATA_LOCKED; | ||
3288 | } else | ||
3289 | state->status = FE_STATUS_TUNE_FAILED; | ||
3290 | *tune_state = CT_DEMOD_STOP; | ||
3291 | } | ||
3292 | } | 3291 | } |
3293 | break; | 3292 | } |
3293 | break; | ||
3294 | 3294 | ||
3295 | case CT_DEMOD_STEP_11: /* 41 : init prbs autosearch */ | 3295 | case CT_DEMOD_STEP_11: /* 41 : init prbs autosearch */ |
3296 | if (state->subchannel <= 41) { | 3296 | if (state->subchannel <= 41) { |
3297 | dib8000_set_subchannel_prbs(state, dib8000_get_init_prbs(state, state->subchannel)); | 3297 | dib8000_set_subchannel_prbs(state, dib8000_get_init_prbs(state, state->subchannel)); |
3298 | *tune_state = CT_DEMOD_STEP_9; | 3298 | *tune_state = CT_DEMOD_STEP_9; |
3299 | } else { | 3299 | } else { |
3300 | *tune_state = CT_DEMOD_STOP; | 3300 | *tune_state = CT_DEMOD_STOP; |
3301 | state->status = FE_STATUS_TUNE_FAILED; | 3301 | state->status = FE_STATUS_TUNE_FAILED; |
3302 | } | 3302 | } |
3303 | break; | 3303 | break; |
3304 | 3304 | ||
3305 | default: | 3305 | default: |
3306 | break; | 3306 | break; |
3307 | } | 3307 | } |
3308 | 3308 | ||
3309 | /* tuning is finished - cleanup the demod */ | 3309 | /* tuning is finished - cleanup the demod */ |
3310 | switch (*tune_state) { | 3310 | switch (*tune_state) { |
3311 | case CT_DEMOD_STOP: /* (42) */ | 3311 | case CT_DEMOD_STOP: /* (42) */ |
3312 | #ifdef DIB8000_AGC_FREEZE | 3312 | #ifdef DIB8000_AGC_FREEZE |
3313 | if ((state->revision != 0x8090) && (state->agc1_max != 0)) { | 3313 | if ((state->revision != 0x8090) && (state->agc1_max != 0)) { |
3314 | dib8000_write_word(state, 108, state->agc1_max); | 3314 | dib8000_write_word(state, 108, state->agc1_max); |
3315 | dib8000_write_word(state, 109, state->agc1_min); | 3315 | dib8000_write_word(state, 109, state->agc1_min); |
3316 | dib8000_write_word(state, 110, state->agc2_max); | 3316 | dib8000_write_word(state, 110, state->agc2_max); |
3317 | dib8000_write_word(state, 111, state->agc2_min); | 3317 | dib8000_write_word(state, 111, state->agc2_min); |
3318 | state->agc1_max = 0; | 3318 | state->agc1_max = 0; |
3319 | state->agc1_min = 0; | 3319 | state->agc1_min = 0; |
3320 | state->agc2_max = 0; | 3320 | state->agc2_max = 0; |
3321 | state->agc2_min = 0; | 3321 | state->agc2_min = 0; |
3322 | } | 3322 | } |
3323 | #endif | 3323 | #endif |
3324 | ret = FE_CALLBACK_TIME_NEVER; | 3324 | ret = FE_CALLBACK_TIME_NEVER; |
3325 | break; | 3325 | break; |
3326 | default: | 3326 | default: |
3327 | break; | 3327 | break; |
3328 | } | 3328 | } |
3329 | 3329 | ||
3330 | if ((ret > 0) && (*tune_state > CT_DEMOD_STEP_3)) | 3330 | if ((ret > 0) && (*tune_state > CT_DEMOD_STEP_3)) |