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

Commit aeb60e81 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "hal: fm: add parameter to set mute options" into av-userspace.lnx.1.0-dev.1.0

parents acf1070b eeb6b31f
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
/*
 * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
 * Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
 * Not a Contribution.
 *
 * Copyright (C) 2013 The Android Open Source Project
@@ -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"
#define FM_LOOPBACK_DRAIN_TIME_MS 2

static struct pcm_config pcm_config_fm = {
@@ -52,6 +53,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;
@@ -62,6 +64,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,
};
@@ -86,6 +89,12 @@ static int32_t fm_set_volume(struct audio_device *adev, float value, bool persis
    if (persist)
        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;
@@ -286,6 +295,17 @@ void audio_extn_fm_set_parameters(struct audio_device *adev,
        fm_set_volume(adev, vol, true);
    }

    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, false);
    }

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