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

Commit de4849ce authored by vivek mehta's avatar vivek mehta Committed by Eric Laurent
Browse files

hal: enable form factor based configuration

- for 8996 enable form factor based mixer path configuration

Change-Id: Ib3cc1bdb2b0427c9d98cfaa9cbae21b91dc38bd2
parent 46183ded
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -39,8 +39,8 @@ ifneq ($(filter msm8996,$(TARGET_BOARD_PLATFORM)),)
  LOCAL_CFLAGS := -DPLATFORM_MSM8996
  LOCAL_CFLAGS += -DMAX_TARGET_SPECIFIC_CHANNEL_CNT="4"
  LOCAL_CFLAGS += -DKPI_OPTIMIZE_ENABLED
  MULTIPLE_HW_VARIANTS_ENABLED := true
endif

endif

LOCAL_SRC_FILES := \
@@ -51,6 +51,11 @@ LOCAL_SRC_FILES := \
	audio_extn/audio_extn.c \
	$(AUDIO_PLATFORM)/platform.c

ifdef MULTIPLE_HW_VARIANTS_ENABLED
  LOCAL_CFLAGS += -DHW_VARIANTS_ENABLED
  LOCAL_SRC_FILES +=  $(AUDIO_PLATFORM)/hw_info.c
endif

LOCAL_SHARED_LIBRARIES := \
	liblog \
	libcutils \
+55 −0
Original line number Diff line number Diff line
@@ -29,7 +29,62 @@
#include "platform.h"
#include "platform_api.h"

struct snd_card_split cur_snd_card_split = {
    .device = {0},
    .snd_card = {0},
    .form_factor = {0},
};

struct snd_card_split *audio_extn_get_snd_card_split()
{
    return &cur_snd_card_split;
}

void audio_extn_set_snd_card_split(const char* in_snd_card_name)
{
    /* sound card name follows below mentioned convention
       <target name>-<sound card name>-<form factor>-snd-card
       parse target name, sound card name and form factor
    */
    char *snd_card_name = strdup(in_snd_card_name);
    char *tmp = NULL;
    char *device = NULL;
    char *snd_card = NULL;
    char *form_factor = NULL;

    if (in_snd_card_name == NULL) {
        ALOGE("%s: snd_card_name passed is NULL", __func__);
        goto on_error;
    }

    device = strtok_r(snd_card_name, "-", &tmp);
    if (device == NULL) {
        ALOGE("%s: called on invalid snd card name", __func__);
        goto on_error;
    }
    strlcpy(cur_snd_card_split.device, device, HW_INFO_ARRAY_MAX_SIZE);

    snd_card = strtok_r(NULL, "-", &tmp);
    if (snd_card == NULL) {
        ALOGE("%s: called on invalid snd card name", __func__);
        goto on_error;
    }
    strlcpy(cur_snd_card_split.snd_card, snd_card, HW_INFO_ARRAY_MAX_SIZE);

    form_factor = strtok_r(NULL, "-", &tmp);
    if (form_factor == NULL) {
        ALOGE("%s: called on invalid snd card name", __func__);
        goto on_error;
    }
    strlcpy(cur_snd_card_split.form_factor, form_factor, HW_INFO_ARRAY_MAX_SIZE);

    ALOGI("%s: snd_card_name(%s) device(%s) snd_card(%s) form_factor(%s)",
               __func__, in_snd_card_name, device, snd_card, form_factor);

on_error:
    if (snd_card_name)
        free(snd_card_name);
}

#ifdef KPI_OPTIMIZE_ENABLED
typedef int (*perf_lock_acquire_t)(int, int, int*, int);
+22 −0
Original line number Diff line number Diff line
@@ -19,11 +19,21 @@

#include <cutils/str_parms.h>

#define HW_INFO_ARRAY_MAX_SIZE 32

struct snd_card_split {
    char device[HW_INFO_ARRAY_MAX_SIZE];
    char snd_card[HW_INFO_ARRAY_MAX_SIZE];
    char form_factor[HW_INFO_ARRAY_MAX_SIZE];
};

void *audio_extn_extspk_init(struct audio_device *adev);
void audio_extn_extspk_deinit(void *extn);
void audio_extn_extspk_update(void* extn);
void audio_extn_extspk_set_mode(void* extn, audio_mode_t mode);
void audio_extn_extspk_set_voice_vol(void* extn, float vol);
struct snd_card_split *audio_extn_get_snd_card_split();
void audio_extn_set_snd_card_split(const char* in_snd_card_name);

#ifndef SPKR_PROT_ENABLED
#define audio_extn_spkr_prot_init(adev)       (0)
@@ -110,4 +120,16 @@ int audio_extn_perf_lock_init(void);
void audio_extn_perf_lock_acquire(void);
void audio_extn_perf_lock_release(void);
#endif /* KPI_OPTIMIZE_ENABLED */

#ifndef HW_VARIANTS_ENABLED
#define hw_info_init(snd_card_name)                  (0)
#define hw_info_deinit(hw_info)                      (0)
#define hw_info_append_hw_type(hw_info,\
        snd_device, device_name)                     (0)
#else
void *hw_info_init(const char *snd_card_name);
void hw_info_deinit(void *hw_info);
void hw_info_append_hw_type(void *hw_info, snd_device_t snd_device,
                             char *device_name);
#endif /* HW_VARIANTS_ENABLED */
#endif /* AUDIO_EXTN_H */
+27 −17
Original line number Diff line number Diff line
@@ -307,20 +307,19 @@ int enable_snd_device(struct audio_device *adev,
{
    int i, num_devices = 0;
    snd_device_t new_snd_devices[2];

    int ret_val = -EINVAL;
    if (snd_device < SND_DEVICE_MIN ||
        snd_device >= SND_DEVICE_MAX) {
        ALOGE("%s: Invalid sound device %d", __func__, snd_device);
        return -EINVAL;
        goto on_error;
    }

    platform_send_audio_calibration(adev->platform, snd_device);

    adev->snd_dev_ref_cnt[snd_device]++;
    if (adev->snd_dev_ref_cnt[snd_device] > 1) {
    if (adev->snd_dev_ref_cnt[snd_device] >= 1) {
        ALOGV("%s: snd_device(%d: %s) is already active",
              __func__, snd_device, platform_get_snd_device_name(snd_device));
        return 0;
        goto on_success;
    }

    /* due to the possibility of calibration overwrite between listen
@@ -337,12 +336,11 @@ int enable_snd_device(struct audio_device *adev,
        snd_device == SND_DEVICE_OUT_VOICE_SPEAKER) &&
        audio_extn_spkr_prot_is_enabled()) {
        if (audio_extn_spkr_prot_get_acdb_id(snd_device) < 0) {
            adev->snd_dev_ref_cnt[snd_device]--;
            return -EINVAL;
            goto on_error;
        }
        if (audio_extn_spkr_prot_start_processing(snd_device)) {
            ALOGE("%s: spkr_start_processing failed", __func__);
            return -EINVAL;
            goto on_error;
        }
    } else if (platform_can_split_snd_device(snd_device, &num_devices, new_snd_devices)) {
        for (i = 0; i < num_devices; i++) {
@@ -350,12 +348,20 @@ int enable_snd_device(struct audio_device *adev,
        }
        platform_set_speaker_gain_in_combo(adev, snd_device, true);
    } else {
        const char * dev_path = platform_get_snd_device_name(snd_device);
        ALOGV("%s: snd_device(%d: %s)", __func__, snd_device, dev_path);
        audio_route_apply_and_update_path(adev->audio_route, dev_path);
        char device_name[DEVICE_NAME_MAX_SIZE] = {0};
        if (platform_get_snd_device_name_extn(adev->platform, snd_device, device_name) < 0 ) {
            ALOGE(" %s: Invalid sound device returned", __func__);
            goto on_error;
        }

    return 0;
        ALOGV("%s: snd_device(%d: %s)", __func__, snd_device, device_name);
        audio_route_apply_and_update_path(adev->audio_route, device_name);
    }
on_success:
    adev->snd_dev_ref_cnt[snd_device]++;
    ret_val = 0;
on_error:
    return ret_val;
}

int disable_snd_device(struct audio_device *adev,
@@ -375,9 +381,6 @@ int disable_snd_device(struct audio_device *adev,
    }
    adev->snd_dev_ref_cnt[snd_device]--;
    if (adev->snd_dev_ref_cnt[snd_device] == 0) {
        const char * dev_path = platform_get_snd_device_name(snd_device);
        ALOGV("%s: snd_device(%d: %s)", __func__, snd_device, dev_path);

        audio_extn_dsm_feedback_enable(adev, snd_device, false);
        if ((snd_device == SND_DEVICE_OUT_SPEAKER ||
            snd_device == SND_DEVICE_OUT_VOICE_SPEAKER) &&
@@ -389,7 +392,14 @@ int disable_snd_device(struct audio_device *adev,
            }
            platform_set_speaker_gain_in_combo(adev, snd_device, false);
        } else {
            audio_route_reset_and_update_path(adev->audio_route, dev_path);
            char device_name[DEVICE_NAME_MAX_SIZE] = {0};
            if (platform_get_snd_device_name_extn(adev->platform, snd_device, device_name) < 0 ) {
                ALOGE(" %s: Invalid sound device returned", __func__);
                return -EINVAL;
            }

            ALOGV("%s: snd_device(%d: %s)", __func__, snd_device, device_name);
            audio_route_reset_and_update_path(adev->audio_route, device_name);
        }
        audio_extn_sound_trigger_update_device_status(snd_device,
                                        ST_EVENT_SND_DEVICE_FREE);
+0 −2
Original line number Diff line number Diff line
@@ -45,8 +45,6 @@
#define MAX_SUPPORTED_CHANNEL_MASKS 2
#define DEFAULT_HDMI_OUT_CHANNELS   2

typedef int snd_device_t;

/* These are the supported use cases by the hardware.
 * Each usecase is mapped to a specific PCM device.
 * Refer to pcm_device_table[].
Loading