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

Commit 5a39c91d authored by Amit Shekhar's avatar Amit Shekhar
Browse files

hal: Support config selection for playback on speaker

Support bit width selection for playback on speakers based on
platform info.

Change-Id: I8dd2cc7049186e7468615a43db550d7d580a81d1
parent 1d89604d
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -436,6 +436,9 @@ void audio_extn_utils_update_stream_app_type_cfg(void *platform,

    if ((24 == bit_width) &&
        (devices & AUDIO_DEVICE_OUT_SPEAKER)) {
        int32_t bw = platform_get_snd_device_bit_width(SND_DEVICE_OUT_SPEAKER);
        if (-ENOSYS != bw)
            bit_width = (uint32_t)bw;
        sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE;
        ALOGI("%s Allowing 24-bit playback on speaker ONLY at default sampling rate", __func__);
    }
+12 −0
Original line number Diff line number Diff line
@@ -1035,6 +1035,18 @@ int platform_get_snd_device_acdb_id(snd_device_t snd_device)
    return acdb_device_table[snd_device];
}

int platform_set_snd_device_bit_width(snd_device_t snd_device, unsigned int bit_width)
{
    ALOGE("%s: Not implemented", __func__);
    return -ENOSYS;
}

int platform_get_snd_device_bit_width(snd_device_t snd_device)
{
    ALOGE("%s: Not implemented", __func__);
    return -ENOSYS;
}

int platform_send_audio_calibration(void *platform, snd_device_t snd_device,
                                    int app_type, int sample_rate)
{
+12 −0
Original line number Diff line number Diff line
@@ -421,6 +421,18 @@ int platform_get_snd_device_acdb_id(snd_device_t snd_device __unused)
    return -ENOSYS;
}

int platform_set_snd_device_bit_width(snd_device_t snd_device, unsigned int bit_width)
{
    ALOGE("%s: Not implemented", __func__);
    return -ENOSYS;
}

int platform_get_snd_device_bit_width(snd_device_t snd_device)
{
    ALOGE("%s: Not implemented", __func__);
    return -ENOSYS;
}

int platform_switch_voice_call_enable_device_config(void *platform __unused,
                                                    snd_device_t out_snd_device __unused,
                                                    snd_device_t in_snd_device __unused)
+40 −5
Original line number Diff line number Diff line
@@ -298,6 +298,9 @@ static const char * const device_table[SND_DEVICE_MAX] = {
    [SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS_BROADSIDE] = "speaker-dmic-broadside",
};

// Platform specific backend bit width table
static int backend_bit_width_table[SND_DEVICE_MAX] = {0};

/* ACDB IDs (audio DSP path configuration IDs) for each sound device */
static int acdb_device_table[SND_DEVICE_MAX] = {
    [SND_DEVICE_NONE] = -1,
@@ -693,6 +696,9 @@ static void set_platform_defaults()
    for (dev = 0; dev < SND_DEVICE_MAX; dev++) {
        backend_table[dev] = NULL;
    }
    for (dev = 0; dev < SND_DEVICE_MAX; dev++) {
        backend_bit_width_table[dev] = 16;
    }

    // TBD - do these go to the platform-info.xml file.
    // will help in avoiding strdups here
@@ -1164,6 +1170,31 @@ int platform_get_snd_device_acdb_id(snd_device_t snd_device)
    return acdb_device_table[snd_device];
}

int platform_set_snd_device_bit_width(snd_device_t snd_device, unsigned int bit_width)
{
    int ret = 0;

    if ((snd_device < SND_DEVICE_MIN) || (snd_device >= SND_DEVICE_MAX)) {
        ALOGE("%s: Invalid snd_device = %d",
            __func__, snd_device);
        ret = -EINVAL;
        goto done;
    }

    backend_bit_width_table[snd_device] = bit_width;
done:
    return ret;
}

int platform_get_snd_device_bit_width(snd_device_t snd_device)
{
    if ((snd_device < SND_DEVICE_MIN) || (snd_device >= SND_DEVICE_MAX)) {
        ALOGE("%s: Invalid snd_device = %d", __func__, snd_device);
        return DEFAULT_OUTPUT_SAMPLING_RATE;
    }
    return backend_bit_width_table[snd_device];
}

int platform_send_audio_calibration(void *platform, snd_device_t snd_device,
                                    int app_type, int sample_rate)
{
@@ -2559,11 +2590,15 @@ bool platform_check_codec_backend_cfg(struct audio_device* adev,
        }
    }

    // 24 bit playback on speakers and all 16 bit playbacks is allowed through
    // 16 bit/48 khz backend only
    if ((16 == bit_width) ||
        ((24 == bit_width) &&
         (usecase->stream.out->devices & AUDIO_DEVICE_OUT_SPEAKER))) {
    // 16 bit playback on speakers is allowed through 48 khz backend only
    if (16 == bit_width) {
        sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
    }
    // 24 bit playback on speakers is allowed through 48 khz backend only
    // bit width re-configured based on platform info
    if ((24 == bit_width) &&
        (usecase->stream.out->devices & AUDIO_DEVICE_OUT_SPEAKER)) {
        bit_width = (uint32_t)platform_get_snd_device_bit_width(SND_DEVICE_OUT_SPEAKER);
        sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
    }
    // Force routing if the expected bitwdith or samplerate
+2 −0
Original line number Diff line number Diff line
@@ -36,6 +36,8 @@ int platform_set_fluence_type(void *platform, char *value);
int platform_get_fluence_type(void *platform, char *value, uint32_t len);
int platform_set_snd_device_acdb_id(snd_device_t snd_device, unsigned int acdb_id);
int platform_get_snd_device_acdb_id(snd_device_t snd_device);
int platform_set_snd_device_bit_width(snd_device_t snd_device, unsigned int bit_width);
int platform_get_snd_device_bit_width(snd_device_t snd_device);
int platform_send_audio_calibration(void *platform, snd_device_t snd_device,
                                    int app_type, int sample_rate);
int platform_get_default_app_type(void *platform);
Loading