Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit e603ac77 authored by bengris32's avatar bengris32 Committed by Giovanni Ricca
Browse files

jni: Always build noise floor detect code and make it conditional



* Some FM chips need this, others don't. Always compile the
  code for it but make it configurable at runtime.

Change-Id: I0e313c7db1f6469d7da210364f53f14e4d0c24dc
Signed-off-by: default avatarbengris32 <bengris32@protonmail.ch>
parent 7f5188d5
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -125,6 +125,9 @@ enum {
// seek threshold
#define FM_SEEKTH_LEVEL_DEFAULT 4

#define RSSI_TH -296
#define FM_NOISE_FLOOR_OFFSET 10

struct fm_tune_parm {
    uint8_t err;
    uint8_t band;
+1 −0
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@ struct CUST_cfg_ds
    int32_t scan_sort;
    int32_t short_ana_sup;
    int32_t rssi_th_l2;
    bool noise_floor_detect;
    struct fm_fake_channel_t *fake_chan;
};

+36 −39
Original line number Diff line number Diff line
@@ -291,7 +291,7 @@ fm_bool FMR_SevereDensense(fm_u16 ChannelNo, fm_s32 RSSI)
    }
    return fm_false;
}
#if (FMR_NOISE_FLOORT_DETECT==1)

/*return TRUE:get noise floor freq*/
fm_bool FMR_NoiseFloorDetect(fm_bool *rF, fm_s32 rssi, fm_s32 *F_rssi)
{
@@ -310,7 +310,6 @@ fm_bool FMR_NoiseFloorDetect(fm_bool *rF, fm_s32 rssi, fm_s32 *F_rssi)
    }
    return fm_false;
}
#endif

/*check the cur_freq->freq is valid or not
return fm_true : need check cur_freq->valid
@@ -579,13 +578,11 @@ int FMR_scan_Channels(int idx, uint16_t *scan_tbl, int *max_cnt, fm_s32 band_cha
    static struct fm_cqi SortData[CQI_CH_NUM_MAX];
    fm_bool LastExist = fm_false;
    struct fm_cqi swap;
#if (FMR_NOISE_FLOORT_DETECT==1)
    fm_s32 Pacc = 0, Nacc = 0;
    fm_s32 NF = 0;
    fm_bool F[3] = {fm_false, fm_false, fm_false};
    fm_s32 F_Rssi[3] = {0};
    fm_u8 NF_Idx = 0;
#endif

    memset(SortData, 0, CQI_CH_NUM_MAX*sizeof(struct fm_cqi));
    LOGI("band_channel_no=[%d], seek_space=%d, start freq=%d\n", band_channel_no,seek_space,Start_Freq);
@@ -604,9 +601,9 @@ int FMR_scan_Channels(int idx, uint16_t *scan_tbl, int *max_cnt, fm_s32 band_cha
            continue;
        }
        if (cur_freq.valid == fm_true)/*get valid channel*/ {
#if (FMR_NOISE_FLOORT_DETECT==1)
            if (fmr_data.cfg_data.noise_floor_detect)
                memset(F, fm_false, sizeof(F));
#endif

            if (FMR_DensenseDetect(idx, cur_freq.freq, cur_freq.rssi) == fm_true) {
                LOGI("desense channel detected:[%d] \n", cur_freq.freq);
                LastExist = fm_false;
@@ -639,7 +636,7 @@ int FMR_scan_Channels(int idx, uint16_t *scan_tbl, int *max_cnt, fm_s32 band_cha
                LOGI("Num++:[%d] \n", Num);
            }
        } else {
#if (FMR_NOISE_FLOORT_DETECT==1)
            if (fmr_data.cfg_data.noise_floor_detect) {
                if (FMR_DensenseDetect(idx, cur_freq.freq, cur_freq.rssi) == fm_false) {
                    if (FMR_NoiseFloorDetect(F, cur_freq.rssi, F_Rssi) == fm_true) {
                        Pacc += F_Rssi[1];
@@ -656,10 +653,10 @@ int FMR_scan_Channels(int idx, uint16_t *scan_tbl, int *max_cnt, fm_s32 band_cha
                } else {
                    memset(F, fm_false, sizeof(F));
                }
#endif
            }
            LastExist = fm_false;
        }
#if (FMR_NOISE_FLOORT_DETECT==1)
        if (fmr_data.cfg_data.noise_floor_detect) {
            if (((i%NF_Space) == 0) && (i != 0)) {
                if (Nacc > 0) {
                    NF = Pacc/Nacc;
@@ -677,7 +674,7 @@ int FMR_scan_Channels(int idx, uint16_t *scan_tbl, int *max_cnt, fm_s32 band_cha
                NF_Idx = j;
                LOGI("FM Noise FLoor NF_Idx[%d] \n", NF_Idx);
            }
#endif
        }
    }
    LOGI("get channel no.[%d] \n", Num);
    if (Num == 0)/*get nothing*/ {