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

Commit 52f9b6db authored by Linux Build Service Account's avatar Linux Build Service Account
Browse files

Promotion of audio-userspace.lnx.3.0-00020.

CRs      Change ID                                   Subject
--------------------------------------------------------------------------------------------------------------
2040989   I1b37bc3d7c9e8e30cc344f2feffdd37fa4a0379b   hal: Fix MBDRC volume difference issue for combo use cas
2040989   I18726af9d30c966fd04666305529a46cebee18c7   volume_listener: Fix MBDRC volume difference issue for c
2009985   Ibaf5b7454dfeeb3b3d985a6108ca839b19e8f2b3   audio: hal: Add support to query delay from dsp
2043993   I5745a432155e858b4a680aca9363b8d76306f784   hal: avoid dereferencing null pointer
2044358   Ia6ede71a8702fd04f06d701602473bc0146843f3   policy_hal: adjust bitrate restriction for wma
2009985   I38ef63bf89eaf7a8664ff33cd00455b9643a4cdc   audio: hal: Add support to configure render mode

Change-Id: I2b990537f3fd01f505d3623f539a031f920e3bbb
CRs-Fixed: 2040989, 2044358, 2009985, 2043993
parents a219e64d d99547d5
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -93,6 +93,10 @@
                                      AUDIO_FORMAT_AAC_SUB_HE_V2)
#endif

#ifndef AUDIO_OUTPUT_FLAG_TIMESTAMP
#define AUDIO_OUTPUT_FLAG_TIMESTAMP 0x10000
#endif

#ifndef COMPRESS_METADATA_NEEDED
#define audio_extn_parse_compress_metadata(out, parms) (0)
#else
@@ -108,6 +112,11 @@ int audio_extn_parse_compress_metadata(struct stream_out *out,
#define compress_set_next_track_param(compress, codec_options) (0)
#endif

#ifndef AUDIO_HW_EXTN_API_ENABLED
#define compress_set_metadata(compress, metadata) (0)
#define compress_get_metadata(compress, metadata) (0)
#endif

#define MAX_LENGTH_MIXER_CONTROL_IN_INT                  (128)

void audio_extn_set_parameters(struct audio_device *adev,
@@ -823,4 +832,6 @@ int audio_extn_set_aptx_dec_params(struct aptx_dec_param *payload);
int audio_extn_utils_get_avt_device_drift(
                struct audio_usecase *usecase,
                struct audio_avt_device_drift_param *drift_param);
int audio_extn_utils_compress_get_dsp_latency(struct stream_out *out);
int audio_extn_utils_compress_set_render_mode(struct stream_out *out);
#endif /* AUDIO_EXTN_H */
+93 −2
Original line number Diff line number Diff line
@@ -29,13 +29,15 @@
#include <cutils/log.h>
#include <cutils/misc.h>


#include "audio_hw.h"
#include "platform.h"
#include "platform_api.h"
#include "audio_extn.h"
#include "voice.h"
#include "sound/compress_params.h"

#include <sound/compress_params.h>
#include <sound/compress_offload.h>
#include <tinycompress/tinycompress.h>
#ifdef AUDIO_EXTERNAL_HDMI_ENABLED
#ifdef HDMI_PASSTHROUGH_ENABLED
#include "audio_parsers.h"
@@ -82,6 +84,10 @@
#define SR_192000           (14<<0)     /* 192kHz */

#endif

/* ToDo: Check and update a proper value in msec */
#define COMPRESS_OFFLOAD_PLAYBACK_LATENCY 50

struct string_to_enum {
    const char *name;
    uint32_t value;
@@ -1650,3 +1656,88 @@ int audio_extn_utils_get_avt_device_drift(
done:
    return ret;
}

#ifdef SNDRV_COMPRESS_PATH_DELAY
int audio_extn_utils_compress_get_dsp_latency(struct stream_out *out)
{
    int ret = -EINVAL;
    struct snd_compr_metadata metadata;
    int delay_ms = COMPRESS_OFFLOAD_PLAYBACK_LATENCY;

    if (property_get_bool("audio.playback.dsp.pathdelay", false)) {
        ALOGD("%s:: Quering DSP delay %d",__func__, __LINE__);
        if (!(is_offload_usecase(out->usecase))) {
            ALOGE("%s:: not supported for non offload session", __func__);
            goto exit;
        }

        if (!out->compr) {
            ALOGD("%s:: Invalid compress handle,returning default dsp latency",
                    __func__);
            goto exit;
        }

        metadata.key = SNDRV_COMPRESS_PATH_DELAY;
        ret = compress_get_metadata(out->compr, &metadata);
        if(ret) {
            ALOGE("%s::error %s", __func__, compress_get_error(out->compr));
            goto exit;
        }
        delay_ms = metadata.value[0] / 1000; /*convert to ms*/
    } else {
        ALOGD("%s:: Using Fix DSP delay",__func__);
    }

exit:
    ALOGD("%s:: delay in ms is %d",__func__, delay_ms);
    return delay_ms;
}
#else
int audio_extn_utils_compress_get_dsp_latency(struct stream_out *out __unused)
{
    return COMPRESS_OFFLOAD_PLAYBACK_LATENCY;
}
#endif

#ifdef SNDRV_COMPRESS_RENDER_MODE
int audio_extn_utils_compress_set_render_mode(struct stream_out *out)
{
    struct snd_compr_metadata metadata;
    int ret = -EINVAL;

    if (!(is_offload_usecase(out->usecase))) {
        ALOGE("%s:: not supported for non offload session", __func__);
        goto exit;
    }

    if (!out->compr) {
        ALOGD("%s:: Invalid compress handle",
                __func__);
        goto exit;
    }

    ALOGD("%s:: render mode %d", __func__, out->render_mode);

    metadata.key = SNDRV_COMPRESS_RENDER_MODE;
    if (out->render_mode == RENDER_MODE_AUDIO_MASTER) {
        metadata.value[0] = SNDRV_COMPRESS_RENDER_MODE_AUDIO_MASTER;
    } else if (out->render_mode == RENDER_MODE_AUDIO_STC_MASTER) {
        metadata.value[0] = SNDRV_COMPRESS_RENDER_MODE_STC_MASTER;
    } else {
        ret = 0;
        goto exit;
    }
    ret = compress_set_metadata(out->compr, &metadata);
    if(ret) {
        ALOGE("%s::error %s", __func__, compress_get_error(out->compr));
    }
exit:
    return ret;
}
#else
int audio_extn_utils_compress_set_render_mode(struct stream_out *out __unused)
{
    ALOGD("%s:: configuring render mode not supported", __func__);
    return 0;
}
#endif
+14 −4
Original line number Diff line number Diff line
@@ -79,8 +79,6 @@
#define COMPRESS_OFFLOAD_NUM_FRAGMENTS 4
/*DIRECT PCM has same buffer sizes as DEEP Buffer*/
#define DIRECT_PCM_NUM_FRAGMENTS 2
/* ToDo: Check and update a proper value in msec */
#define COMPRESS_OFFLOAD_PLAYBACK_LATENCY 50
#define COMPRESS_PLAYBACK_VOLUME_MAX 0x2000
#define DSD_VOLUME_MIN_DB (-110)

@@ -1522,6 +1520,7 @@ int select_devices(struct audio_device *adev, audio_usecase_t uc_id)
            }
        } else if (voice_extn_compress_voip_is_active(adev)) {
            bool out_snd_device_backend_match = true;
            voip_usecase = get_usecase_from_list(adev, USECASE_COMPRESS_VOIP_CALL);
            if (usecase->stream.out != NULL) {
                out_snd_device_backend_match = platform_check_backends_match(
                                                   voip_usecase->out_snd_device,
@@ -1529,7 +1528,6 @@ int select_devices(struct audio_device *adev, audio_usecase_t uc_id)
                                                       adev->platform,
                                                       usecase->stream.out));
            }
            voip_usecase = get_usecase_from_list(adev, USECASE_COMPRESS_VOIP_CALL);
            if ((voip_usecase) && ((voip_usecase->devices & AUDIO_DEVICE_OUT_ALL_CODEC_BACKEND) &&
                ((usecase->devices & AUDIO_DEVICE_OUT_ALL_CODEC_BACKEND) ||
                  ((usecase->devices & ~AUDIO_DEVICE_BIT_IN) & AUDIO_DEVICE_IN_ALL_CODEC_BACKEND)) &&
@@ -2365,6 +2363,8 @@ int start_output_stream(struct stream_out *out)
            compress_set_max_poll_wait(out->compr, 1000);
        }

        audio_extn_utils_compress_set_render_mode(out);

        audio_extn_dts_create_state_notifier_node(out->usecase);
        audio_extn_dts_notify_playback_state(out->usecase, 0, out->sample_rate,
                                             popcount(out->channel_mask),
@@ -2961,7 +2961,9 @@ static uint32_t out_get_latency(const struct audio_stream_out *stream)
    uint32_t latency = 0;

    if (is_offload_usecase(out->usecase)) {
        latency = COMPRESS_OFFLOAD_PLAYBACK_LATENCY;
        lock_output_stream(out);
        latency = audio_extn_utils_compress_get_dsp_latency(out);
        pthread_mutex_unlock(&out->lock);
    } else if (out->realtime) {
        // since the buffer won't be filled up faster than realtime,
        // return a smaller number
@@ -4133,6 +4135,14 @@ int adev_open_output_stream(struct audio_hw_device *dev,
        if (flags & AUDIO_OUTPUT_FLAG_NON_BLOCKING)
            out->non_blocking = 1;

        if ((flags & AUDIO_OUTPUT_FLAG_TIMESTAMP) &&
            (flags & AUDIO_OUTPUT_FLAG_HW_AV_SYNC)) {
            out->render_mode = RENDER_MODE_AUDIO_STC_MASTER;
        } else if(flags & AUDIO_OUTPUT_FLAG_TIMESTAMP) {
            out->render_mode = RENDER_MODE_AUDIO_MASTER;
        } else {
            out->render_mode = RENDER_MODE_AUDIO_NO_TIMESTAMP;
        }

        out->send_new_metadata = 1;
        out->send_next_track_params = false;
+9 −0
Original line number Diff line number Diff line
@@ -196,6 +196,12 @@ struct offload_cmd {
    int data[];
};

typedef enum render_mode {
    RENDER_MODE_AUDIO_NO_TIMESTAMP = 0,
    RENDER_MODE_AUDIO_MASTER,
    RENDER_MODE_AUDIO_STC_MASTER,
} render_mode_t;

struct stream_app_type_cfg {
    int sample_rate;
    uint32_t bit_width;
@@ -252,11 +258,14 @@ struct stream_out {
    bool realtime;
    int af_period_multiplier;
    struct audio_device *dev;

    void* qaf_stream_handle;
    pthread_cond_t qaf_offload_cond;
    pthread_t qaf_offload_thread;
    struct listnode qaf_offload_cmd_list;
    uint32_t platform_latency;
    render_mode_t render_mode;

    audio_offload_info_t info;
};

+32 −6
Original line number Diff line number Diff line
@@ -6606,6 +6606,24 @@ int platform_spkr_prot_is_wsa_analog_mode(void *adev)
        return 0;
}

static bool can_enable_mbdrc_on_device(snd_device_t snd_device)
{
    bool ret = false;

    if (snd_device == SND_DEVICE_OUT_SPEAKER ||
        snd_device == SND_DEVICE_OUT_SPEAKER_WSA ||
        snd_device == SND_DEVICE_OUT_SPEAKER_VBAT ||
        snd_device == SND_DEVICE_OUT_VOICE_SPEAKER_VBAT ||
        snd_device == SND_DEVICE_OUT_VOICE_SPEAKER_2_VBAT ||
        snd_device == SND_DEVICE_OUT_VOICE_SPEAKER ||
        snd_device == SND_DEVICE_OUT_VOICE_SPEAKER_2 ||
        snd_device == SND_DEVICE_OUT_VOICE_SPEAKER_WSA ||
        snd_device == SND_DEVICE_OUT_VOICE_SPEAKER_2_WSA) {
        ret = true;
    }
    return ret;
}

bool platform_send_gain_dep_cal(void *platform,
                                int level )
{
@@ -6633,15 +6651,23 @@ bool platform_send_gain_dep_cal(void *platform,

            if (usecase != NULL &&
                usecase->type == PCM_PLAYBACK &&
                usecase->stream.out->devices == AUDIO_DEVICE_OUT_SPEAKER) {
                usecase->stream.out->devices & AUDIO_DEVICE_OUT_SPEAKER) {
                int new_snd_device[2] = {0};
                int i, num_devices = 1;

                ALOGV("%s: out device is %d", __func__,  usecase->out_snd_device);
                app_type = usecase->stream.out->app_type_cfg.app_type;

                if (audio_extn_spkr_prot_is_enabled()) {
                    acdb_dev_id = platform_get_spkr_prot_acdb_id(usecase->out_snd_device);
                } else {
                    acdb_dev_id = acdb_device_table[usecase->out_snd_device];
                if (platform_split_snd_device(my_data, usecase->out_snd_device,
                                              &num_devices, new_snd_device) < 0)
                    new_snd_device[0] = usecase->out_snd_device;

                for (i = 0; i < num_devices; i++)
                    if (can_enable_mbdrc_on_device(new_snd_device[i])) {
                        if (audio_extn_spkr_prot_is_enabled())
                            acdb_dev_id = platform_get_spkr_prot_acdb_id(new_snd_device[i]);
                        else
                            acdb_dev_id = acdb_device_table[new_snd_device[i]];
                    }

                if (!my_data->acdb_send_gain_dep_cal(acdb_dev_id, app_type,
Loading