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

Commit 0e6e1e5e authored by Aniket Kumar Lata's avatar Aniket Kumar Lata
Browse files

hal: Remove storage of audio device on bitfields

Audio devices were stored in HAL on variables with
type audio_devices_t. This change removes the storage
of multiple devices on a bitfield. Device comparisons,
assigments, removal have been updated. Helper functions
have been introduced for device operations.

Change-Id: I9ce8b0f9bdc542c386cbfe45b685158cc51d47b6
parent 4c32fb4f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -131,6 +131,7 @@ LOCAL_SRC_FILES += audio_extn/audio_extn.c \
                   audio_extn/source_track.c \
                   audio_extn/usb.c \
                   audio_extn/utils.c \
                   audio_extn/device_utils.c \
                   voice_extn/compress_voip.c \
                   voice_extn/voice_extn.c

+14 −7
Original line number Diff line number Diff line
@@ -136,7 +136,8 @@ ifneq ($(filter sdm845 sdm710 sdmshrike msmnile kona lito bengal atoll sdm660 ms
  MULTIPLE_HW_VARIANTS_ENABLED := true
endif

LOCAL_SRC_FILES:= ssr.c
LOCAL_SRC_FILES:= ssr.c \
                  device_utils.c

LOCAL_CFLAGS += \
    -Wall \
@@ -383,7 +384,8 @@ ifneq ($(filter sdm845 sdm710 sdmshrike msmnile kona lito bengal atoll sdm660 ms
endif

LOCAL_SRC_FILES:= \
        a2dp.c
        a2dp.c \
        device_utils.c

LOCAL_CFLAGS += \
    -Wall \
@@ -514,7 +516,8 @@ ifeq ($(TARGET_BOARD_AUTO),true)
endif

LOCAL_SRC_FILES:= \
        hfp.c
        hfp.c \
        device_utils.c

LOCAL_CFLAGS += \
    -Wall \
@@ -577,7 +580,8 @@ ifneq ($(filter sdm845 sdm710 sdmshrike msmnile kona lito bengal atoll sdm660 ms
endif

LOCAL_SRC_FILES:= \
        passthru.c
        passthru.c \
        device_utils.c

LOCAL_CFLAGS += \
    -Wall \
@@ -779,7 +783,8 @@ ifneq ($(filter sdm845 sdm710 sdmshrike msmnile kona sdm660 msm8937 $(MSMSTEPPE)
endif

LOCAL_SRC_FILES:= \
        maxxaudio.c
        maxxaudio.c \
        device_utils.c

LOCAL_CFLAGS += \
    -Wall \
@@ -840,7 +845,8 @@ ifneq ($(filter sdm845 sdm710 sdmshrike msmnile kona sdm660 msm8937 $(MSMSTEPPE)
endif

LOCAL_SRC_FILES:= \
        audiozoom.c
        audiozoom.c \
        device_utils.c

LOCAL_CFLAGS += \
    -Wall \
@@ -904,7 +910,8 @@ ifneq ($(filter sdm845 sdm710 sdmshrike msmnile kona lito atoll sdm660 msm8937 m
endif

LOCAL_SRC_FILES:= \
        auto_hal.c
        auto_hal.c \
        device_utils.c

LOCAL_CFLAGS += \
    -Wall \
+3 −3
Original line number Diff line number Diff line
/*
* Copyright (c) 2015-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2015-2020, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -2786,7 +2786,7 @@ int a2dp_set_parameters(struct str_parms *parms, bool *reconfig)
                list_for_each(node, &a2dp.adev->usecase_list) {
                    uc_info = node_to_item(node, struct audio_usecase, list);
                    if (uc_info->stream.out && uc_info->type == PCM_PLAYBACK &&
                         (uc_info->stream.out->devices & AUDIO_DEVICE_OUT_ALL_A2DP)) {
                        is_a2dp_out_device_type(&uc_info->stream.out->device_list)) {
                        pthread_mutex_unlock(&a2dp.adev->lock);
                        fp_check_a2dp_restore(a2dp.adev, uc_info->stream.out, false);
                        pthread_mutex_lock(&a2dp.adev->lock);
@@ -2827,7 +2827,7 @@ int a2dp_set_parameters(struct str_parms *parms, bool *reconfig)
                list_for_each(node, &a2dp.adev->usecase_list) {
                    uc_info = node_to_item(node, struct audio_usecase, list);
                    if (uc_info->stream.out && uc_info->type == PCM_PLAYBACK &&
                         (uc_info->stream.out->devices & AUDIO_DEVICE_OUT_ALL_A2DP)) {
                        is_a2dp_out_device_type(&uc_info->stream.out->device_list)) {
                        pthread_mutex_unlock(&a2dp.adev->lock);
                        fp_check_a2dp_restore(a2dp.adev, uc_info->stream.out, true);
                        pthread_mutex_lock(&a2dp.adev->lock);
+9 −9
Original line number Diff line number Diff line
@@ -1247,12 +1247,12 @@ void audio_extn_set_anc_parameters(struct audio_device *adev,
        list_for_each(node, &adev->usecase_list) {
            usecase = node_to_item(node, struct audio_usecase, list);
            if (usecase->stream.out && usecase->type != PCM_CAPTURE) {
                if (usecase->stream.out->devices == \
                    AUDIO_DEVICE_OUT_WIRED_HEADPHONE ||
                    usecase->stream.out->devices ==  \
                    AUDIO_DEVICE_OUT_WIRED_HEADSET ||
                    usecase->stream.out->devices ==  \
                    AUDIO_DEVICE_OUT_EARPIECE) {
                if (is_single_device_type_equal(&usecase->stream.out->device_list,
                                AUDIO_DEVICE_OUT_WIRED_HEADPHONE) ||
                    is_single_device_type_equal(&usecase->stream.out->device_list,
                                AUDIO_DEVICE_OUT_WIRED_HEADSET) ||
                    is_single_device_type_equal(&usecase->stream.out->device_list,
                                AUDIO_DEVICE_OUT_EARPIECE)) {
                        select_devices(adev, usecase->id);
                        ALOGV("%s: switching device completed", __func__);
                        break;
@@ -3387,7 +3387,7 @@ static int audio_extn_set_multichannel_mask(struct audio_device *adev,
    /* validate input params. Avoid updated channel mask if loopback device */
    if ((channel_count == 6) &&
        (in->format == AUDIO_FORMAT_PCM_16_BIT) &&
        (!is_loopback_input_device(in->device))) {
        (!is_loopback_input_device(get_device_types(&in->device_list)))) {
        switch (max_mic_count) {
            case 4:
                config->channel_mask = AUDIO_CHANNEL_INDEX_MASK_4;
@@ -3662,13 +3662,13 @@ int audio_extn_set_device_cfg_params(struct audio_device *adev,

    adev_device_cfg_ptr = adev->device_cfg_params;
    /* Create an out stream to get snd device from audio device */
    out.devices = device_cfg_params->device;
    reassign_device_list(&out.device_list, device_cfg_params->device, "");
    out.sample_rate = device_cfg_params->sample_rate;
    snd_device = platform_get_output_snd_device(adev->platform, &out);
    backend_idx = platform_get_backend_index(snd_device);

    ALOGV("%s:: device %d sample_rate %d snd_device %d backend_idx %d",
                __func__, out.devices, out.sample_rate, snd_device, backend_idx);
                __func__, get_device_types(&out.device_list), out.sample_rate, snd_device, backend_idx);

    ALOGV("%s:: Device Config Params from Client samplerate %d  channels %d"
          " bit_width %d  format %d  device %d  channel_map[0] %d channel_map[1] %d"
+6 −5
Original line number Diff line number Diff line
@@ -680,7 +680,7 @@ int audio_extn_hfp_set_mic_mute2(struct audio_device *adev, bool state);
typedef int (*fp_platform_set_mic_mute_t)(void *, bool);
//typedef int (*fp_platform_get_pcm_device_id_t)(audio_usecase_t, int);
typedef void (*fp_platform_set_echo_reference_t)(struct audio_device *, bool,
                                                            audio_devices_t);
                                                     struct listnode *);
typedef int (*fp_select_devices_t)(struct audio_device *, audio_usecase_t);
typedef int (*fp_audio_extn_ext_hw_plugin_usecase_start_t)(void *,
                                                      struct audio_usecase *);
@@ -795,7 +795,7 @@ void audio_extn_utils_release_streams_cfg_lists(
                                  struct listnode *streams_input_cfg_list);
void audio_extn_utils_update_stream_output_app_type_cfg(void *platform,
                                  struct listnode *streams_output_cfg_list,
                                  audio_devices_t devices,
                                  struct listnode *devices,
                                  audio_output_flags_t flags,
                                  audio_format_t format,
                                  uint32_t sample_rate,
@@ -805,7 +805,7 @@ void audio_extn_utils_update_stream_output_app_type_cfg(void *platform,
                                  struct stream_app_type_cfg *app_type_cfg);
void audio_extn_utils_update_stream_input_app_type_cfg(void *platform,
                                  struct listnode *streams_input_cfg_list,
                                  audio_devices_t devices,
                                  struct listnode *devices,
                                  audio_input_flags_t flags,
                                  audio_format_t format,
                                  uint32_t sample_rate,
@@ -1063,7 +1063,7 @@ int audio_extn_keep_alive_set_parameters(struct audio_device *adev,
void audio_extn_gef_init(struct audio_device *adev);
void audio_extn_gef_deinit(struct audio_device *adev);

void audio_extn_gef_notify_device_config(audio_devices_t audio_device,
void audio_extn_gef_notify_device_config(struct listnode *audio_devices,
    audio_channel_mask_t channel_mask, int sample_rate, int acdb_id, int app_type);
#ifndef INSTANCE_ID_ENABLED
int audio_extn_gef_send_audio_cal(void* adev, int acdb_dev_id, int acdb_device_type,
@@ -1126,7 +1126,8 @@ void audio_extn_source_track_get_parameters(const struct audio_device *adev,
void audio_extn_fm_set_parameters(struct audio_device *adev,
                                   struct str_parms *parms);
void audio_extn_fm_get_parameters(struct str_parms *query, struct str_parms *reply);
void audio_extn_fm_route_on_selected_device(struct audio_device *adev, audio_devices_t device);
void audio_extn_fm_route_on_selected_device(struct audio_device *adev,
                                            struct listnode *devices);

#ifndef APTX_DECODER_ENABLED
#define audio_extn_aptx_dec_set_license(adev); (0)
Loading