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

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

Merge "policy_hal: hal: add support to enable Direct PCM"

parents 82cfb650 0ea887a9
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -59,6 +59,7 @@ struct string_to_enum {


const struct string_to_enum s_flag_name_to_enum_table[] = {
const struct string_to_enum s_flag_name_to_enum_table[] = {
    STRING_TO_ENUM(AUDIO_OUTPUT_FLAG_DIRECT),
    STRING_TO_ENUM(AUDIO_OUTPUT_FLAG_DIRECT),
    STRING_TO_ENUM(AUDIO_OUTPUT_FLAG_DIRECT_PCM),
    STRING_TO_ENUM(AUDIO_OUTPUT_FLAG_PRIMARY),
    STRING_TO_ENUM(AUDIO_OUTPUT_FLAG_PRIMARY),
    STRING_TO_ENUM(AUDIO_OUTPUT_FLAG_FAST),
    STRING_TO_ENUM(AUDIO_OUTPUT_FLAG_FAST),
    STRING_TO_ENUM(AUDIO_OUTPUT_FLAG_DEEP_BUFFER),
    STRING_TO_ENUM(AUDIO_OUTPUT_FLAG_DEEP_BUFFER),
+24 −7
Original line number Original line Diff line number Diff line
@@ -177,6 +177,8 @@ const char * const use_case_table[AUDIO_USECASE_MAX] = {
    [USECASE_AUDIO_PLAYBACK_OFFLOAD8] = "compress-offload-playback8",
    [USECASE_AUDIO_PLAYBACK_OFFLOAD8] = "compress-offload-playback8",
    [USECASE_AUDIO_PLAYBACK_OFFLOAD9] = "compress-offload-playback9",
    [USECASE_AUDIO_PLAYBACK_OFFLOAD9] = "compress-offload-playback9",
#endif
#endif
    [USECASE_AUDIO_DIRECT_PCM_OFFLOAD] = "compress-offload-playback2",

    [USECASE_AUDIO_RECORD] = "audio-record",
    [USECASE_AUDIO_RECORD] = "audio-record",
    [USECASE_AUDIO_RECORD_COMPRESS] = "audio-record-compress",
    [USECASE_AUDIO_RECORD_COMPRESS] = "audio-record-compress",
    [USECASE_AUDIO_RECORD_LOW_LATENCY] = "low-latency-record",
    [USECASE_AUDIO_RECORD_LOW_LATENCY] = "low-latency-record",
@@ -221,6 +223,7 @@ static const audio_usecase_t offload_usecases[] = {
    USECASE_AUDIO_PLAYBACK_OFFLOAD8,
    USECASE_AUDIO_PLAYBACK_OFFLOAD8,
    USECASE_AUDIO_PLAYBACK_OFFLOAD9,
    USECASE_AUDIO_PLAYBACK_OFFLOAD9,
#endif
#endif
    USECASE_AUDIO_DIRECT_PCM_OFFLOAD,
};
};


#define STRING_TO_ENUM(string) { #string, string }
#define STRING_TO_ENUM(string) { #string, string }
@@ -310,6 +313,7 @@ static bool is_supported_format(audio_format_t format)
        format == AUDIO_FORMAT_AAC_ADTS_HE_V2 ||
        format == AUDIO_FORMAT_AAC_ADTS_HE_V2 ||
        format == AUDIO_FORMAT_PCM_16_BIT_OFFLOAD ||
        format == AUDIO_FORMAT_PCM_16_BIT_OFFLOAD ||
        format == AUDIO_FORMAT_PCM_24_BIT_OFFLOAD ||
        format == AUDIO_FORMAT_PCM_24_BIT_OFFLOAD ||
        format == AUDIO_FORMAT_PCM_16_BIT ||
        format == AUDIO_FORMAT_FLAC ||
        format == AUDIO_FORMAT_FLAC ||
        format == AUDIO_FORMAT_ALAC ||
        format == AUDIO_FORMAT_ALAC ||
        format == AUDIO_FORMAT_APE ||
        format == AUDIO_FORMAT_APE ||
@@ -336,6 +340,7 @@ static int get_snd_codec_id(audio_format_t format)
        id = SND_AUDIOCODEC_AAC;
        id = SND_AUDIOCODEC_AAC;
        break;
        break;
    case AUDIO_FORMAT_PCM_OFFLOAD:
    case AUDIO_FORMAT_PCM_OFFLOAD:
    case AUDIO_FORMAT_PCM:
        id = SND_AUDIOCODEC_PCM;
        id = SND_AUDIOCODEC_PCM;
        break;
        break;
    case AUDIO_FORMAT_FLAC:
    case AUDIO_FORMAT_FLAC:
@@ -2848,7 +2853,9 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
                  __func__, ret);
                  __func__, ret);
            goto error_open;
            goto error_open;
        }
        }
    } else if (out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) {
    } else if ((out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) ||
               (out->flags & AUDIO_OUTPUT_FLAG_DIRECT_PCM)) {

        if (config->offload_info.version != AUDIO_INFO_INITIALIZER.version ||
        if (config->offload_info.version != AUDIO_INFO_INITIALIZER.version ||
            config->offload_info.size != AUDIO_INFO_INITIALIZER.size) {
            config->offload_info.size != AUDIO_INFO_INITIALIZER.size) {
            ALOGE("%s: Unsupported Offload information", __func__);
            ALOGE("%s: Unsupported Offload information", __func__);
@@ -2869,7 +2876,7 @@ static int adev_open_output_stream(struct audio_hw_device *dev,


        if (!is_supported_format(config->offload_info.format) &&
        if (!is_supported_format(config->offload_info.format) &&
                !audio_extn_is_dolby_format(config->offload_info.format)) {
                !audio_extn_is_dolby_format(config->offload_info.format)) {
            ALOGE("%s: Unsupported audio format", __func__);
            ALOGE("%s: Unsupported audio format %x " , __func__, config->offload_info.format);
            ret = -EINVAL;
            ret = -EINVAL;
            goto error_open;
            goto error_open;
        }
        }
@@ -2882,7 +2889,13 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
            goto error_open;
            goto error_open;
        }
        }


        if (out->flags & AUDIO_OUTPUT_FLAG_DIRECT_PCM) {
            ALOGV("%s:: inserting DIRECT_PCM _USECASE", __func__);
            out->usecase = USECASE_AUDIO_DIRECT_PCM_OFFLOAD;
        } else {
            ALOGV("%s:: inserting OFFLOAD_USECASE", __func__);
            out->usecase = get_offload_usecase(adev);
            out->usecase = get_offload_usecase(adev);
        }
        if (config->offload_info.channel_mask)
        if (config->offload_info.channel_mask)
            out->channel_mask = config->offload_info.channel_mask;
            out->channel_mask = config->offload_info.channel_mask;
        else if (config->channel_mask) {
        else if (config->channel_mask) {
@@ -2906,7 +2919,9 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
        else
        else
            out->compr_config.codec->id =
            out->compr_config.codec->id =
                get_snd_codec_id(config->offload_info.format);
                get_snd_codec_id(config->offload_info.format);
        if ((config->offload_info.format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_PCM_OFFLOAD) {

        if (((config->offload_info.format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_PCM_OFFLOAD)||
             ((config->offload_info.format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_PCM)) {
            out->compr_config.fragment_size =
            out->compr_config.fragment_size =
               platform_get_pcm_offload_buffer_size(&config->offload_info);
               platform_get_pcm_offload_buffer_size(&config->offload_info);
        } else if (audio_extn_dolby_is_passthrough_stream(out->flags)) {
        } else if (audio_extn_dolby_is_passthrough_stream(out->flags)) {
@@ -2936,6 +2951,8 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
            out->compr_config.codec->format = SNDRV_PCM_FORMAT_S16_LE;
            out->compr_config.codec->format = SNDRV_PCM_FORMAT_S16_LE;
        if (config->offload_info.format == AUDIO_FORMAT_PCM_24_BIT_OFFLOAD)
        if (config->offload_info.format == AUDIO_FORMAT_PCM_24_BIT_OFFLOAD)
            out->compr_config.codec->format = SNDRV_PCM_FORMAT_S24_LE;
            out->compr_config.codec->format = SNDRV_PCM_FORMAT_S24_LE;
        if (config->offload_info.format == AUDIO_FORMAT_PCM_16_BIT)
            out->compr_config.codec->format = SNDRV_PCM_FORMAT_S16_LE;


        if (out->bit_width == 24) {
        if (out->bit_width == 24) {
            out->compr_config.codec->format = SNDRV_PCM_FORMAT_S24_LE;
            out->compr_config.codec->format = SNDRV_PCM_FORMAT_S24_LE;
+2 −0
Original line number Original line Diff line number Diff line
@@ -95,6 +95,8 @@ enum {
    USECASE_AUDIO_PLAYBACK_OFFLOAD9,
    USECASE_AUDIO_PLAYBACK_OFFLOAD9,
#endif
#endif


    USECASE_AUDIO_DIRECT_PCM_OFFLOAD,

    /* FM usecase */
    /* FM usecase */
    USECASE_AUDIO_PLAYBACK_FM,
    USECASE_AUDIO_PLAYBACK_FM,


+5 −0
Original line number Original line Diff line number Diff line
@@ -259,6 +259,8 @@ int pcm_device_table[AUDIO_USECASE_MAX][2] = {
    [USECASE_AUDIO_PLAYBACK_OFFLOAD8] = {-1, -1},
    [USECASE_AUDIO_PLAYBACK_OFFLOAD8] = {-1, -1},
    [USECASE_AUDIO_PLAYBACK_OFFLOAD9] = {-1, -1},
    [USECASE_AUDIO_PLAYBACK_OFFLOAD9] = {-1, -1},
#endif
#endif
    [USECASE_AUDIO_DIRECT_PCM_OFFLOAD] =
                     {PLAYBACK_OFFLOAD_DEVICE, PLAYBACK_OFFLOAD_DEVICE},
    [USECASE_AUDIO_RECORD] = {AUDIO_RECORD_PCM_DEVICE, AUDIO_RECORD_PCM_DEVICE},
    [USECASE_AUDIO_RECORD] = {AUDIO_RECORD_PCM_DEVICE, AUDIO_RECORD_PCM_DEVICE},
    [USECASE_AUDIO_RECORD_COMPRESS] = {COMPRESS_CAPTURE_DEVICE, COMPRESS_CAPTURE_DEVICE},
    [USECASE_AUDIO_RECORD_COMPRESS] = {COMPRESS_CAPTURE_DEVICE, COMPRESS_CAPTURE_DEVICE},
    [USECASE_AUDIO_RECORD_LOW_LATENCY] = {LOWLATENCY_PCM_DEVICE,
    [USECASE_AUDIO_RECORD_LOW_LATENCY] = {LOWLATENCY_PCM_DEVICE,
@@ -628,6 +630,7 @@ static struct name_to_index usecase_name_index[AUDIO_USECASE_MAX] = {
    {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_OFFLOAD8)},
    {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_OFFLOAD8)},
    {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_OFFLOAD9)},
    {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_OFFLOAD9)},
#endif
#endif
    {TO_NAME_INDEX(USECASE_AUDIO_DIRECT_PCM_OFFLOAD)},
    {TO_NAME_INDEX(USECASE_AUDIO_RECORD)},
    {TO_NAME_INDEX(USECASE_AUDIO_RECORD)},
    {TO_NAME_INDEX(USECASE_AUDIO_RECORD_LOW_LATENCY)},
    {TO_NAME_INDEX(USECASE_AUDIO_RECORD_LOW_LATENCY)},
    {TO_NAME_INDEX(USECASE_VOICE_CALL)},
    {TO_NAME_INDEX(USECASE_VOICE_CALL)},
@@ -3365,6 +3368,7 @@ bool platform_listen_usecase_needs_event(audio_usecase_t uc_id)
    case USECASE_AUDIO_PLAYBACK_DEEP_BUFFER:
    case USECASE_AUDIO_PLAYBACK_DEEP_BUFFER:
    case USECASE_AUDIO_PLAYBACK_MULTI_CH:
    case USECASE_AUDIO_PLAYBACK_MULTI_CH:
    case USECASE_AUDIO_PLAYBACK_OFFLOAD:
    case USECASE_AUDIO_PLAYBACK_OFFLOAD:
    case USECASE_AUDIO_DIRECT_PCM_OFFLOAD:
        needs_event = true;
        needs_event = true;
        break;
        break;
    /* concurrent playback in low latency allowed */
    /* concurrent playback in low latency allowed */
@@ -3426,6 +3430,7 @@ bool platform_sound_trigger_usecase_needs_event(audio_usecase_t uc_id)
    case USECASE_AUDIO_PLAYBACK_DEEP_BUFFER:
    case USECASE_AUDIO_PLAYBACK_DEEP_BUFFER:
    case USECASE_AUDIO_PLAYBACK_MULTI_CH:
    case USECASE_AUDIO_PLAYBACK_MULTI_CH:
    case USECASE_AUDIO_PLAYBACK_OFFLOAD:
    case USECASE_AUDIO_PLAYBACK_OFFLOAD:
    case USECASE_AUDIO_DIRECT_PCM_OFFLOAD:
        needs_event = true;
        needs_event = true;
        break;
        break;
    /* concurrent playback in low latency allowed */
    /* concurrent playback in low latency allowed */
+5 −0
Original line number Original line Diff line number Diff line
@@ -255,6 +255,10 @@ static int pcm_device_table[AUDIO_USECASE_MAX][2] = {
    [USECASE_AUDIO_PLAYBACK_OFFLOAD9] =
    [USECASE_AUDIO_PLAYBACK_OFFLOAD9] =
                     {PLAYBACK_OFFLOAD_DEVICE9, PLAYBACK_OFFLOAD_DEVICE9},
                     {PLAYBACK_OFFLOAD_DEVICE9, PLAYBACK_OFFLOAD_DEVICE9},
#endif
#endif

    [USECASE_AUDIO_DIRECT_PCM_OFFLOAD] =
                     {PLAYBACK_OFFLOAD_DEVICE2, PLAYBACK_OFFLOAD_DEVICE2},

    [USECASE_AUDIO_RECORD] = {AUDIO_RECORD_PCM_DEVICE, AUDIO_RECORD_PCM_DEVICE},
    [USECASE_AUDIO_RECORD] = {AUDIO_RECORD_PCM_DEVICE, AUDIO_RECORD_PCM_DEVICE},
    [USECASE_AUDIO_RECORD_COMPRESS] = {COMPRESS_CAPTURE_DEVICE, COMPRESS_CAPTURE_DEVICE},
    [USECASE_AUDIO_RECORD_COMPRESS] = {COMPRESS_CAPTURE_DEVICE, COMPRESS_CAPTURE_DEVICE},
    [USECASE_AUDIO_RECORD_LOW_LATENCY] = {LOWLATENCY_PCM_DEVICE,
    [USECASE_AUDIO_RECORD_LOW_LATENCY] = {LOWLATENCY_PCM_DEVICE,
@@ -606,6 +610,7 @@ static struct name_to_index usecase_name_index[AUDIO_USECASE_MAX] = {
    {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_OFFLOAD8)},
    {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_OFFLOAD8)},
    {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_OFFLOAD9)},
    {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_OFFLOAD9)},
#endif
#endif
    {TO_NAME_INDEX(USECASE_AUDIO_DIRECT_PCM_OFFLOAD)},
    {TO_NAME_INDEX(USECASE_AUDIO_RECORD)},
    {TO_NAME_INDEX(USECASE_AUDIO_RECORD)},
    {TO_NAME_INDEX(USECASE_AUDIO_RECORD_LOW_LATENCY)},
    {TO_NAME_INDEX(USECASE_AUDIO_RECORD_LOW_LATENCY)},
    {TO_NAME_INDEX(USECASE_VOICE_CALL)},
    {TO_NAME_INDEX(USECASE_VOICE_CALL)},
Loading