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

Commit 31d944cd authored by Xiaojun Sang's avatar Xiaojun Sang
Browse files

hal: set backend channel number to one for mono speaker

Channel number is wrong for mono device. It causes channel
mismatch in ADSP. Set backend channel number to one for mono device.
Update backend info in case of channel mismatch.

Change-Id: I76d7e77c2e3cee11e38d7b1d4033d2227f8c97ce
parent 82debc53
Loading
Loading
Loading
Loading
+11 −7
Original line number Diff line number Diff line
@@ -3244,7 +3244,12 @@ static bool check_snd_device_is_speaker(snd_device_t snd_device)
        snd_device == SND_DEVICE_OUT_SPEAKER_PROTECTED ||
        snd_device == SND_DEVICE_OUT_SPEAKER_PROTECTED_VBAT ||
        snd_device == SND_DEVICE_OUT_SPEAKER_PROTECTED_RAS ||
        snd_device == SND_DEVICE_OUT_SPEAKER_PROTECTED_VBAT_RAS) {
        snd_device == SND_DEVICE_OUT_SPEAKER_PROTECTED_VBAT_RAS ||
        snd_device == SND_DEVICE_OUT_VOICE_SPEAKER ||
        snd_device == SND_DEVICE_OUT_VOICE_SPEAKER_WSA ||
        snd_device == SND_DEVICE_OUT_VOICE_SPEAKER_VBAT ||
        snd_device == SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED ||
        snd_device == SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED_VBAT ) {
        ret = true;
    }
    return ret;
@@ -6234,6 +6239,9 @@ static bool platform_check_codec_backend_cfg(struct audio_device* adev,
        }
    }

    if (!(hw_info_is_stereo_spkr(my_data->hw_info)) && check_snd_device_is_speaker(snd_device))
        channels = 1;

    /* Native playback is preferred for Headphone/HS device over 192Khz */
    if (!voice_call_active && codec_device_supports_native_playback(usecase->devices)) {
        if (audio_is_true_native_stream_active(adev)) {
@@ -6373,6 +6381,7 @@ static bool platform_check_codec_backend_cfg(struct audio_device* adev,
    // Force routing if the expected bitwdith or samplerate
    // is not same as current backend comfiguration
    if ((bit_width != my_data->current_backend_cfg[backend_idx].bit_width) ||
        (channels != my_data->current_backend_cfg[backend_idx].channels) ||
        (sample_rate != my_data->current_backend_cfg[backend_idx].sample_rate) ||
         passthrough_enabled || channels_updated || service_interval_update ) {
        backend_cfg->bit_width = bit_width;
@@ -6430,12 +6439,7 @@ bool platform_check_and_set_codec_backend_cfg(struct audio_device* adev,
        backend_cfg.bit_width = usecase->stream.out->bit_width;
        backend_cfg.sample_rate = usecase->stream.out->sample_rate;
        backend_cfg.format = usecase->stream.out->format;
        if (!(hw_info_is_stereo_spkr(my_data->hw_info)) &&
             check_snd_device_is_speaker(snd_device))
            backend_cfg.channels = 1;
        else
            backend_cfg.channels =
                audio_channel_count_from_out_mask(usecase->stream.out->channel_mask);
        backend_cfg.channels = audio_channel_count_from_out_mask(usecase->stream.out->channel_mask);
    }
    if (audio_extn_is_dsp_bit_width_enforce_mode_supported(usecase->stream.out->flags) &&
                (adev->dsp_bit_width_enforce_mode > backend_cfg.bit_width))