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

Commit d40c6c12 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "hal: Add change to fix speaker and headphone concurrency."

parents a586b71d c1411665
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -133,6 +133,10 @@
        <param key="true_32_bit" value="true"/>
        <!-- In the below value string, the value indicates sidetone gain in dB -->
        <param key="usb_sidetone_gain" value="35"/>
        <!-- In the below value string, the value indicates whether the -->
        <!-- target does not supports speaker and headphone working on  -->
        <!-- different fractional and integer sampling rate             -->
        <param key="spkr_hph_single_be_native_concurrency" value="true"/>
    </config_params>
    <gain_db_to_level_mapping>
        <gain_level_map db="-59" level="5"/>
+4 −0
Original line number Diff line number Diff line
@@ -110,6 +110,10 @@
        <param key="native_audio_mode" value="multiple_mix_dsp"/>
        <param key="hfp_pcm_dev_id" value="39"/>
        <param key="input_mic_max_count" value="4"/>
        <!-- In the below value string, the value indicates whether the -->
        <!-- target does not supports speaker and headphone working on  -->
        <!-- different fractional and integer sampling rate             -->
        <param key="spkr_hph_single_be_native_concurrency" value="true"/>
    </config_params>
    <gain_db_to_level_mapping>
        <gain_level_map db="-59" level="5"/>
+4 −0
Original line number Diff line number Diff line
@@ -110,6 +110,10 @@
        <param key="native_audio_mode" value="multiple_mix_dsp"/>
        <param key="hfp_pcm_dev_id" value="39"/>
        <param key="input_mic_max_count" value="2"/>
        <!-- In the below value string, the value indicates whether the -->
        <!-- target does not supports speaker and headphone working on  -->
        <!-- different fractional and integer sampling rate             -->
        <param key="spkr_hph_single_be_native_concurrency" value="true"/>
    </config_params>
    <gain_db_to_level_mapping>
        <gain_level_map db="-59" level="5"/>
+31 −0
Original line number Diff line number Diff line
@@ -935,6 +935,36 @@ static void disable_asrc_mode(struct audio_device *adev)
    adev->asrc_mode_enabled = false;
}

static void check_and_configure_headphone(struct audio_device *adev,
                                          struct audio_usecase *uc_info,
                                              snd_device_t snd_device)
{
    struct listnode *node;
    struct audio_usecase *usecase;
    int new_backend_idx, usecase_backend_idx;
    bool spkr_hph_single_be_native_concurrency;

    new_backend_idx = platform_get_backend_index(snd_device);
    spkr_hph_single_be_native_concurrency = platform_get_spkr_hph_single_be_native_concurrency_flag();
    if ( spkr_hph_single_be_native_concurrency && (new_backend_idx == DEFAULT_CODEC_BACKEND)) {
        list_for_each(node, &adev->usecase_list) {
            usecase = node_to_item(node, struct audio_usecase, list);
            if ((usecase->type != PCM_CAPTURE) && (usecase != uc_info)) {
                usecase_backend_idx = platform_get_backend_index(usecase->out_snd_device);
                if (((usecase_backend_idx == HEADPHONE_BACKEND) ||
                    (usecase_backend_idx == HEADPHONE_44_1_BACKEND)) &&
                    ((usecase->stream.out->sample_rate % OUTPUT_SAMPLING_RATE_44100) == 0)) {
                    disable_audio_route(adev, usecase);
                    disable_snd_device(adev, usecase->out_snd_device);
                    usecase->stream.out->sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE;
                    enable_audio_route(adev, usecase);
                    enable_snd_device(adev, usecase->out_snd_device);
                }
            }
        }
    }
}

/*
 * - Enable ASRC mode for incoming mix path use case(Headphone backend)if Headphone
 *   44.1 or Native DSD backends are enabled for any of current use case.
@@ -2968,6 +2998,7 @@ int select_devices(struct audio_device *adev, audio_usecase_t uc_id)
    /* Enable new sound devices */
    if (out_snd_device != SND_DEVICE_NONE) {
        check_usecases_codec_backend(adev, usecase, out_snd_device);
        check_and_configure_headphone(adev, usecase, out_snd_device);
        if (platform_check_codec_asrc_support(adev->platform))
            check_and_set_asrc_mode(adev, usecase, out_snd_device);
        enable_snd_device(adev, out_snd_device);
+23 −0
Original line number Diff line number Diff line
@@ -282,6 +282,7 @@ typedef struct codec_backend_cfg {
static native_audio_prop na_props = {0, 0, NATIVE_AUDIO_MODE_INVALID};
static bool supports_true_32_bit = false;
static bool spkr_hph_single_be_native_concurrency = false;
static int max_be_dai_names = 0;
static const struct be_dai_name_struct *be_dai_name_table;
@@ -5161,6 +5162,27 @@ int platform_get_native_support()
    return ret;
}
bool platform_get_spkr_hph_single_be_native_concurrency_flag()
{
    return spkr_hph_single_be_native_concurrency;
}
void spkr_hph_single_be_native_concurrency_params(struct str_parms *parms,
                                    char *value, int len)
{
    int ret = 0;
    ret = str_parms_get_str(parms, AUDIO_PARAMETER_SPKR_HPH_SINGLE_BE_NATIVE_CONCURRENCY,
                           value, len);
    if (ret >= 0) {
        if (value && !strncmp(value, "true", sizeof("true")))
            spkr_hph_single_be_native_concurrency = true;
        else
            spkr_hph_single_be_native_concurrency = false;
        str_parms_del(parms, AUDIO_PARAMETER_SPKR_HPH_SINGLE_BE_NATIVE_CONCURRENCY);
    }
}
void native_audio_get_params(struct str_parms *query,
                             struct str_parms *reply,
                             char *value, int len)
@@ -8447,6 +8469,7 @@ int platform_set_parameters(void *platform, struct str_parms *parms)
    /* handle audio calibration parameters */
    set_audiocal(platform, parms, value, len);
    spkr_hph_single_be_native_concurrency_params(parms, value, len);
    native_audio_set_params(platform, parms, value, len);
    audio_extn_spkr_prot_set_parameters(parms, value, len);
    audio_extn_usb_set_sidetone_gain(parms, value, len);
Loading