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

Commit ee733608 authored by Mingming Yin's avatar Mingming Yin Committed by Gerrit - the friendly Code Review server
Browse files

hal: add missing flags for extended features.

- add missing feature flags to compile hal
  without extended features enabled.

Change-Id: Idd43dfac20cb14798b20f4aa2bee5ff11a8da491
parent 868fa085
Loading
Loading
Loading
Loading
+27 −7
Original line number Diff line number Diff line
@@ -184,9 +184,11 @@ static int check_and_set_gapless_mode(struct audio_device *adev) {
static bool is_supported_format(audio_format_t format)
{
    if (format == AUDIO_FORMAT_MP3 ||
        format == AUDIO_FORMAT_AAC ||
#ifdef EXTN_OFFLOAD_ENABLED
        format == AUDIO_FORMAT_PCM_16_BIT_OFFLOAD ||
        format == AUDIO_FORMAT_PCM_24_BIT_OFFLOAD)
        format == AUDIO_FORMAT_PCM_24_BIT_OFFLOAD ||
#endif
        format == AUDIO_FORMAT_AAC)
           return true;

    return false;
@@ -203,10 +205,12 @@ static int get_snd_codec_id(audio_format_t format)
    case AUDIO_FORMAT_AAC:
        id = SND_AUDIOCODEC_AAC;
        break;
#ifdef EXTN_OFFLOAD_ENABLED
    case AUDIO_FORMAT_PCM_16_BIT_OFFLOAD:
    case AUDIO_FORMAT_PCM_24_BIT_OFFLOAD:
        id = SND_AUDIOCODEC_PCM;
        break;
#endif
    default:
        ALOGE("%s: Unsupported audio format :%x", __func__, format);
    }
@@ -1326,6 +1330,7 @@ static int parse_compress_metadata(struct stream_out *out, struct str_parms *par
        return -EINVAL;
    }

#ifdef EXTN_OFFLOAD_ENABLED
    ret = str_parms_get_str(parms, AUDIO_OFFLOAD_CODEC_FORMAT, value, sizeof(value));
    if (ret >= 0) {
        if (atoi(value) == SND_AUDIOSTREAMFORMAT_MP4ADTS) {
@@ -1334,6 +1339,7 @@ static int parse_compress_metadata(struct stream_out *out, struct str_parms *par
        }
        out->send_new_metadata = 1;
    }
#endif

    ret = str_parms_get_str(parms, AUDIO_OFFLOAD_CODEC_SAMPLE_RATE, value, sizeof(value));
    if(ret >= 0)
@@ -2076,15 +2082,21 @@ static int adev_open_output_stream(struct audio_hw_device *dev,

    /* Init use case and pcm_config */
    if ((out->flags == AUDIO_OUTPUT_FLAG_DIRECT) &&
        (out->devices & AUDIO_DEVICE_OUT_AUX_DIGITAL ||
        out->devices & AUDIO_DEVICE_OUT_PROXY)) {
        (
#ifdef AFE_PROXY_ENABLED
        out->devices & AUDIO_DEVICE_OUT_PROXY ||
#endif
        out->devices & AUDIO_DEVICE_OUT_AUX_DIGITAL)) {

        pthread_mutex_lock(&adev->lock);
        if (out->devices & AUDIO_DEVICE_OUT_AUX_DIGITAL)
            ret = read_hdmi_channel_masks(out);

#ifdef AFE_PROXY_ENABLED
        if (out->devices & AUDIO_DEVICE_OUT_PROXY)
            ret = audio_extn_read_afe_proxy_channel_masks(out);
#endif

        pthread_mutex_unlock(&adev->lock);
        if (ret != 0)
            goto error_open;
@@ -2101,6 +2113,7 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
        out->config.rate = config->sample_rate;
        out->config.channels = popcount(out->channel_mask);
        out->config.period_size = HDMI_MULTI_PERIOD_BYTES / (out->config.channels * 2);
#ifdef COMPRESS_VOIP_ENABLED
    } else if ((out->dev->mode == AUDIO_MODE_IN_COMMUNICATION) &&
               (out->flags == (AUDIO_OUTPUT_FLAG_DIRECT | AUDIO_OUTPUT_FLAG_VOIP_RX)) &&
               (voice_extn_compress_voip_is_config_supported(config))) {
@@ -2110,6 +2123,7 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
                  __func__, ret);
            goto error_open;
        }
#endif
    } else if (out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) {
        if (config->offload_info.version != AUDIO_INFO_INITIALIZER.version ||
            config->offload_info.size != AUDIO_INFO_INITIALIZER.size) {
@@ -2150,11 +2164,13 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
        else
            out->compr_config.codec->id =
                get_snd_codec_id(config->offload_info.format);

#ifdef EXTN_OFFLOAD_ENABLED
        if (audio_is_offload_pcm(config->offload_info.format)) {
            out->compr_config.fragment_size =
                       platform_get_pcm_offload_buffer_size(&config->offload_info);
        } else {
        } else
#endif
        {
            out->compr_config.fragment_size =
                       platform_get_compress_offload_buffer_size(&config->offload_info);
        }
@@ -2168,10 +2184,12 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
        out->compr_config.codec->ch_out = out->compr_config.codec->ch_in;
        out->compr_config.codec->format = SND_AUDIOSTREAMFORMAT_RAW;

#ifdef EXTN_OFFLOAD_ENABLED
        if (config->offload_info.format == AUDIO_FORMAT_PCM_16_BIT_OFFLOAD)
            out->compr_config.codec->format = SNDRV_PCM_FORMAT_S16_LE;
        else if(config->offload_info.format == AUDIO_FORMAT_PCM_24_BIT_OFFLOAD)
            out->compr_config.codec->format = SNDRV_PCM_FORMAT_S24_LE;
#endif

        if (flags & AUDIO_OUTPUT_FLAG_NON_BLOCKING)
            out->non_blocking = 1;
@@ -2187,6 +2205,7 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
        //Decide if we need to use gapless mode by default
        check_and_set_gapless_mode(adev);

#ifdef INCALL_MUSIC_ENABLED
    } else if (out->flags & AUDIO_OUTPUT_FLAG_INCALL_MUSIC) {
        ret = voice_check_and_set_incall_music_usecase(adev, out);
        if (ret != 0) {
@@ -2194,6 +2213,7 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
                  __func__, ret);
            goto error_open;
        }
#endif
    } else if (out->flags & AUDIO_OUTPUT_FLAG_FAST) {
        out->usecase = USECASE_AUDIO_PLAYBACK_LOW_LATENCY;
        out->config = pcm_config_low_latency;
+34 −15
Original line number Diff line number Diff line
@@ -687,6 +687,23 @@ int platform_get_pcm_device_id(audio_usecase_t usecase, int device_type)
    return device_id;
}

int platform_set_snd_device_acdb_id(snd_device_t snd_device, unsigned int acdb_id)
{
    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;
    }

    acdb_device_table[snd_device] = acdb_id;
done:
    return ret;
}

#ifdef FLUENCE_ENABLED
int platform_set_fluence_type(void *platform, char *value)
{
    int ret = 0;
@@ -727,21 +744,6 @@ done:
    return ret;
}

int platform_set_snd_device_acdb_id(snd_device_t snd_device, unsigned int acdb_id)
{
    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;
    }

    acdb_device_table[snd_device] = acdb_id;
done:
    return ret;
}

int platform_get_fluence_type(void *platform, char *value, uint32_t len)
{
@@ -759,6 +761,7 @@ int platform_get_fluence_type(void *platform, char *value, uint32_t len)

    return ret;
}
#endif

int platform_send_audio_calibration(void *platform, snd_device_t snd_device)
{
@@ -1068,8 +1071,10 @@ snd_device_t platform_get_output_snd_device(void *platform, audio_devices_t devi
        } else if (devices & AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET ||
                   devices & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET) {
            snd_device = SND_DEVICE_OUT_USB_HEADSET;
#ifdef FM_ENABLED
        } else if (devices & AUDIO_DEVICE_OUT_FM_TX) {
            snd_device = SND_DEVICE_OUT_TRANSMISSION_FM;
#endif
        } else if (devices & AUDIO_DEVICE_OUT_EARPIECE) {
            if (audio_extn_should_use_handset_anc(channel_count))
                snd_device = SND_DEVICE_OUT_ANC_HANDSET;
@@ -1109,15 +1114,19 @@ snd_device_t platform_get_output_snd_device(void *platform, audio_devices_t devi
        ALOGD("%s: setting USB hadset channel capability(2) for Proxy", __func__);
        audio_extn_set_afe_proxy_channel_mixer(adev, 2);
        snd_device = SND_DEVICE_OUT_USB_HEADSET;
#ifdef FM_ENABLED
    } else if (devices & AUDIO_DEVICE_OUT_FM_TX) {
        snd_device = SND_DEVICE_OUT_TRANSMISSION_FM;
#endif
    } else if (devices & AUDIO_DEVICE_OUT_EARPIECE) {
        snd_device = SND_DEVICE_OUT_HANDSET;
#ifdef AFE_PROXY_ENABLED
    } else if (devices & AUDIO_DEVICE_OUT_PROXY) {
        channel_count = audio_extn_get_afe_proxy_channel_count();
        ALOGD("%s: setting sink capability(%d) for Proxy", __func__, channel_count);
        audio_extn_set_afe_proxy_channel_mixer(adev, channel_count);
        snd_device = SND_DEVICE_OUT_AFE_PROXY;
#endif
    } else {
        ALOGE("%s: Unknown device(s) %#x", __func__, devices);
    }
@@ -1293,9 +1302,11 @@ snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_d
                set_echo_reference(adev, true);
            }
        }
#ifdef FM_ENABLED
    } else if (source == AUDIO_SOURCE_FM_RX ||
               source == AUDIO_SOURCE_FM_RX_A2DP) {
        snd_device = SND_DEVICE_IN_CAPTURE_FM;
#endif
    } else if (source == AUDIO_SOURCE_DEFAULT) {
        goto exit;
    }
@@ -1330,8 +1341,10 @@ snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_d
        } else if (in_device & AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET ||
                   in_device & AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET) {
            snd_device = SND_DEVICE_IN_USB_HEADSET_MIC;
#ifdef FM_ENABLED
        } else if (in_device & AUDIO_DEVICE_IN_FM_RX) {
            snd_device = SND_DEVICE_IN_CAPTURE_FM;
#endif
        } else {
            ALOGE("%s: Unknown input device(s) %#x", __func__, in_device);
            ALOGW("%s: Using default handset-mic", __func__);
@@ -1684,8 +1697,10 @@ int64_t platform_render_latency(audio_usecase_t usecase)
int platform_update_usecase_from_source(int source, int usecase)
{
    ALOGV("%s: input source :%d", __func__, source);
#ifdef FM_ENABLED
    if(source == AUDIO_SOURCE_FM_RX_A2DP)
        usecase = USECASE_AUDIO_RECORD_FM_VIRTUAL;
#endif
    return usecase;
}

@@ -1693,7 +1708,9 @@ bool platform_listen_update_status(snd_device_t snd_device)
{
    if ((snd_device >= SND_DEVICE_IN_BEGIN) &&
        (snd_device < SND_DEVICE_IN_END) &&
#ifdef FM_ENABLED
        (snd_device != SND_DEVICE_IN_CAPTURE_FM) &&
#endif
        (snd_device != SND_DEVICE_IN_CAPTURE_VI_FEEDBACK))
        return true;
    else
@@ -1734,9 +1751,11 @@ uint32_t platform_get_pcm_offload_buffer_size(audio_offload_info_t* info)
    uint32_t fragment_size = MIN_PCM_OFFLOAD_FRAGMENT_SIZE;
    uint32_t bits_per_sample = 16;

#ifdef EXTN_OFFLOAD_ENABLED
    if (info->format == AUDIO_FORMAT_PCM_24_BIT_OFFLOAD) {
        bits_per_sample = 32;
    }
#endif

    if (!info->has_video) {
        fragment_size = MAX_PCM_OFFLOAD_FRAGMENT_SIZE;
+8 −0
Original line number Diff line number Diff line
@@ -186,11 +186,13 @@ static int update_calls(struct audio_device *adev)
            case CALL_LOCAL_HOLD:
                ALOGD("%s: LOCAL_HOLD -> ACTIVE vsid:%x", __func__, session->vsid);
                lch_mode = VOICE_LCH_STOP;
#ifdef PCM_IOCTL_ENABLED
                if (pcm_ioctl(session->pcm_tx, SNDRV_VOICE_IOCTL_LCH, &lch_mode) < 0) {
                    ALOGE("LOCAL_HOLD -> ACTIVE failed");
                } else {
                    session->state.current = session->state.new;
                }
#endif
                break;

            default:
@@ -238,11 +240,13 @@ static int update_calls(struct audio_device *adev)
            case CALL_LOCAL_HOLD:
                ALOGD("%s: CALL_LOCAL_HOLD -> HOLD vsid:%x", __func__, session->vsid);
                lch_mode = VOICE_LCH_STOP;
#ifdef PCM_IOCTL_ENABLED
                if (pcm_ioctl(session->pcm_tx, SNDRV_VOICE_IOCTL_LCH, &lch_mode) < 0) {
                    ALOGE("LOCAL_HOLD -> HOLD failed");
                } else {
                    session->state.current = session->state.new;
                }
#endif
                break;

            default:
@@ -260,11 +264,13 @@ static int update_calls(struct audio_device *adev)
                ALOGD("%s: ACTIVE/CALL_HOLD -> LOCAL_HOLD vsid:%x", __func__,
                      session->vsid);
                lch_mode = VOICE_LCH_START;
#ifdef PCM_IOCTL_ENABLED
                if (pcm_ioctl(session->pcm_tx, SNDRV_VOICE_IOCTL_LCH, &lch_mode) < 0) {
                    ALOGE("LOCAL_HOLD -> HOLD failed");
                } else {
                    session->state.current = session->state.new;
                }
#endif
                break;

            default:
@@ -583,6 +589,7 @@ void voice_extn_in_get_parameters(struct stream_in *in,
    voice_extn_compress_voip_in_get_parameters(in, query, reply);
}

#ifdef INCALL_MUSIC_ENABLED
int voice_extn_check_and_set_incall_music_usecase(struct audio_device *adev,
                                                  struct stream_out *out)
{
@@ -604,4 +611,5 @@ int voice_extn_check_and_set_incall_music_usecase(struct audio_device *adev,

    return 0;
}
#endif
+2 −0
Original line number Diff line number Diff line
ifneq ($(strip $(AUDIO_FEATURE_DISABLED_EXTN_MM_AUDIO)),true)
include $(call all-subdir-makefiles)
endif
+2 −0
Original line number Diff line number Diff line
ifneq ($(strip $(AUDIO_FEATURE_DISABLED_EXTN_APM)),true)
ifeq ($(strip $(BOARD_USES_ALSA_AUDIO)),true)

LOCAL_PATH := $(call my-dir)
@@ -33,3 +34,4 @@ endif
include $(BUILD_SHARED_LIBRARY)

endif
endif#endif for AUDIO_FEATURE_DISABLED_EXTN_APM
Loading