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

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

Merge "hal: Fix backend for 24 bit playback on speaker"

parents 93dd4e03 a4a37d8c
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -472,6 +472,7 @@ int audio_extn_utils_send_app_type_cfg(struct audio_usecase *usecase)
    struct audio_device *adev;
    struct mixer_ctl *ctl;
    int pcm_device_id, acdb_dev_id, snd_device = usecase->out_snd_device;
    int32_t sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE;

    ALOGV("%s", __func__);

@@ -513,13 +514,21 @@ int audio_extn_utils_send_app_type_cfg(struct audio_usecase *usecase)
        rc = -EINVAL;
        goto exit_send_app_type_cfg;
    }

    if ((24 == usecase->stream.out->bit_width) &&
            (AUDIO_DEVICE_OUT_SPEAKER == snd_device)) {
        sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE;
    } else {
        sample_rate = out->app_type_cfg.sample_rate;
    }

    app_type_cfg[len++] = out->app_type_cfg.app_type;
    app_type_cfg[len++] = acdb_dev_id;
    app_type_cfg[len++] = out->app_type_cfg.sample_rate;
    app_type_cfg[len++] = sample_rate;

    mixer_ctl_set_array(ctl, app_type_cfg, len);
    ALOGI("%s app_type %d, acdb_dev_id %d, sample_rate %d",
           __func__, out->app_type_cfg.app_type, acdb_dev_id, out->app_type_cfg.sample_rate);
           __func__, out->app_type_cfg.app_type, acdb_dev_id, sample_rate);
    rc = 0;
exit_send_app_type_cfg:
    return rc;
+34 −3
Original line number Diff line number Diff line
@@ -797,6 +797,27 @@ int select_devices(struct audio_device *adev, audio_usecase_t uc_id)
    usecase->in_snd_device = in_snd_device;
    usecase->out_snd_device = out_snd_device;

    if (usecase->type == PCM_PLAYBACK) {
        if ((24 == usecase->stream.out->bit_width) &&
            (AUDIO_DEVICE_OUT_SPEAKER == usecase->stream.out->devices)) {
            audio_extn_utils_update_stream_app_type_cfg(adev->platform,
                                                &adev->streams_output_cfg_list,
                                                usecase->stream.out->flags,
                                                usecase->stream.out->format,
                                                DEFAULT_OUTPUT_SAMPLING_RATE,
                                                usecase->stream.out->bit_width,
                                                &usecase->stream.out->app_type_cfg);
        } else {
            audio_extn_utils_update_stream_app_type_cfg(adev->platform,
                                                &adev->streams_output_cfg_list,
                                                usecase->stream.out->flags,
                                                usecase->stream.out->format,
                                                usecase->stream.out->sample_rate,
                                                usecase->stream.out->bit_width,
                                                &usecase->stream.out->app_type_cfg);
        }
    ALOGI("%s Selected apptype: %d", __func__, usecase->stream.out->app_type_cfg.app_type);
    }
    enable_audio_route(adev, usecase);

    /* Applicable only on the targets that has external modem.
@@ -2382,6 +2403,7 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
    struct stream_out *out;
    int i, ret = 0;
    audio_format_t format;
    int32_t sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE;

    *stream_out = NULL;

@@ -2567,11 +2589,20 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
        out->sample_rate = out->config.rate;
    }

    ALOGV("%s flags %x, format %x, out->sample_rate %d, out->bit_width %d",
           __func__, flags, format, out->sample_rate, out->bit_width);
    if ((24 == out->bit_width) &&
        (devices == AUDIO_DEVICE_OUT_SPEAKER)) {
        sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE;
        ALOGI("%s 24-bit playback on Speaker is allowed ONLY at 48khz. Hence changing sample rate to: %d",
               __func__, sample_rate);
    } else {
        sample_rate = out->sample_rate;
    }

    ALOGV("%s flags %x, format %x, sample_rate %d, out->bit_width %d",
           __func__, flags, format, sample_rate, out->bit_width);
    audio_extn_utils_update_stream_app_type_cfg(adev->platform,
                                                &adev->streams_output_cfg_list,
                                                flags, format, out->sample_rate,
                                                flags, format, sample_rate,
                                                out->bit_width, &out->app_type_cfg);
    if ((out->usecase == USECASE_AUDIO_PLAYBACK_PRIMARY) ||
        (flags & AUDIO_OUTPUT_FLAG_PRIMARY)) {
+3 −1
Original line number Diff line number Diff line
@@ -2560,8 +2560,10 @@ bool platform_check_codec_backend_cfg(struct audio_device* adev,
    }

    // 16 bit playbacks is allowed through 16 bit/48 khz backend only
    if (16 == bit_width)
    if ((16 == bit_width) ||
        ((24 == bit_width) && (SND_DEVICE_OUT_SPEAKER == usecase->devices))) {
        sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
    }
    // Force routing if the expected bitwdith or samplerate
    // is not same as current backend comfiguration
    if ((bit_width != adev->cur_codec_backend_bit_width) ||