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

Commit 1b966ad9 authored by Dhananjay Kumar's avatar Dhananjay Kumar Committed by Divya Narayanan Poojary
Browse files

hal: fm: add parameter to set mute options

Add parameter to handle mute options, this is required to
control fm mute in device loopback mode without affecting
other music streams.

CRs-Fixed: 963849
Change-Id: I1729d0bd3cff40670444a8806a05c7304d4ca6aa
parent 99b10759
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@
#define AUDIO_PARAMETER_KEY_HANDLE_FM "handle_fm"
#define AUDIO_PARAMETER_KEY_FM_VOLUME "fm_volume"
#define AUDIO_PARAMETER_KEY_REC_PLAY_CONC "rec_play_conc_on"
#define AUDIO_PARAMETER_KEY_FM_MUTE "fm_mute"

static struct pcm_config pcm_config_fm = {
    .channels = 2,
@@ -51,6 +52,7 @@ struct fm_module {
    struct pcm *fm_pcm_rx;
    struct pcm *fm_pcm_tx;
    bool is_fm_running;
    bool is_fm_muted;
    float fm_volume;
    bool restart_fm;
    int scard_state;
@@ -61,6 +63,7 @@ static struct fm_module fmmod = {
  .fm_pcm_tx = NULL,
  .fm_volume = 0,
  .is_fm_running = 0,
  .is_fm_muted = 0,
  .restart_fm = 0,
  .scard_state = SND_CARD_STATE_ONLINE,
};
@@ -84,6 +87,12 @@ static int32_t fm_set_volume(struct audio_device *adev, float value)
    vol  = lrint((value * 0x2000) + 0.5);
    fmmod.fm_volume = value;

    if (fmmod.is_fm_muted == true && vol > 0) {
        ALOGD("%s: fm is muted, applying '0' volume instead of '%d'.",
                                                        __func__, vol);
        vol = 0;
    }

    if (!fmmod.is_fm_running) {
        ALOGV("%s: FM not active, ignoring set_fm_volume call", __func__);
        return -EIO;
@@ -281,6 +290,17 @@ void audio_extn_fm_set_parameters(struct audio_device *adev,
        fm_set_volume(adev, vol);
    }

    ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_FM_MUTE,
                            value, sizeof(value));
    if (ret >= 0) {
        if (value[0] == '1')
            fmmod.is_fm_muted = true;
        else
            fmmod.is_fm_muted = false;
        ALOGV("%s: set_fm_volume from param mute", __func__);
        fm_set_volume(adev, fmmod.fm_volume);
    }

#ifdef RECORD_PLAY_CONCURRENCY
    ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_REC_PLAY_CONC,
                               value, sizeof(value));