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

Commit ab3238b1 authored by Scott Mertz's avatar Scott Mertz
Browse files

Merge remote-tracking branch 'github/cm-12.1-caf-8994' into stable/cm-12.1-caf-8994-YOG4P

CYNGNOS-809

Change-Id: If6cf8c6cbf1171792aed9102f160f8be67ff5e14
parents 7932795f a31c0c79
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -139,7 +139,7 @@ ifeq ($(strip $(DOLBY_DDP)),true)
    LOCAL_SRC_FILES += audio_extn/dolby.c
endif

ifeq ($(strip $(DOLBY_DAP)),true)
ifeq ($(strip $(DS1_DOLBY_DAP)),true)
    LOCAL_CFLAGS += -DDS1_DOLBY_DAP_ENABLED
ifneq ($(strip $(DOLBY_DDP)),true)
    LOCAL_SRC_FILES += audio_extn/dolby.c
@@ -173,8 +173,9 @@ endif

ifeq ($(strip $(AUDIO_FEATURE_ENABLED_DS2_DOLBY_DAP)),true)
    LOCAL_CFLAGS += -DDS2_DOLBY_DAP_ENABLED
    LOCAL_CFLAGS += -DDS1_DOLBY_DDP_ENABLED
ifneq ($(strip $(DOLBY_DDP)),true)
    ifneq ($(strip $(DOLBY_DAP)),true)
    ifneq ($(strip $(DS1_DOLBY_DAP)),true)
        LOCAL_SRC_FILES += audio_extn/dolby.c
    endif
endif
+39 −24
Original line number Diff line number Diff line
@@ -250,36 +250,30 @@ static unsigned int audio_device_ref_count;
static int set_voice_volume_l(struct audio_device *adev, float volume);

static amplifier_device_t * get_amplifier_device(void)
{
    if (adev)
        return adev->amp;

    return NULL;
}

static int amplifier_open(void)
{
    int rc;
    amplifier_module_t *module;

    if (adev->amp)
        return adev->amp;

    rc = hw_get_module(AMPLIFIER_HARDWARE_MODULE_ID,
            (const hw_module_t **) &module);
    if (rc) {
        ALOGV("%s: Failed to obtain reference to amplifier module: %s\n",
                __func__, strerror(-rc));
        return NULL;
        return -ENODEV;
    }

    rc = amplifier_device_open((const hw_module_t *) module, &adev->amp);
    if (rc) {
        ALOGV("%s: Failed to open amplifier hardware device: %s\n",
                __func__, strerror(-rc));
        return NULL;
    }

    return adev->amp;
}

static int amplifier_open(void)
{
    amplifier_device_t *amp = get_amplifier_device();

    if (!amp) {
        return -ENODEV;
    }

@@ -998,6 +992,9 @@ int select_devices(struct audio_device *adev, audio_usecase_t uc_id)
        (usecase->in_snd_device != SND_DEVICE_NONE) &&
        (usecase->out_snd_device != SND_DEVICE_NONE)) {
        status = platform_switch_voice_call_device_pre(adev->platform);
        /* Disable sidetone only if voice call already exists */
        if (voice_is_call_state_active(adev))
            voice_set_sidetone(adev, usecase->out_snd_device, false);
    }

    /* Disable current sound devices */
@@ -1040,6 +1037,9 @@ int select_devices(struct audio_device *adev, audio_usecase_t uc_id)
                                                        out_snd_device,
                                                        in_snd_device);
        enable_audio_route_for_voice_usecases(adev, usecase);
        /* Enable sidetone only if voice call already exists */
        if (voice_is_call_state_active(adev))
            voice_set_sidetone(adev, out_snd_device, true);
    }

    usecase->in_snd_device = in_snd_device;
@@ -2315,9 +2315,13 @@ static int out_get_render_position(const struct audio_stream_out *stream,
                                   uint32_t *dsp_frames)
{
    struct stream_out *out = (struct stream_out *)stream;
    if (is_offload_usecase(out->usecase) && (dsp_frames != NULL)) {
        ssize_t ret = 0;

    if (dsp_frames == NULL)
        return -EINVAL;

    *dsp_frames = 0;
    if (is_offload_usecase(out->usecase)) {
        ssize_t ret = 0;
        pthread_mutex_lock(&out->lock);
        if (out->compr != NULL) {
            ret = compress_get_tstamp(out->compr, (unsigned long *)dsp_frames,
@@ -2338,6 +2342,9 @@ static int out_get_render_position(const struct audio_stream_out *stream,
        } else {
            return 0;
        }
    } else if (audio_is_linear_pcm(out->format)) {
        *dsp_frames = out->written;
        return 0;
    } else
        return -EINVAL;
}
@@ -3494,7 +3501,7 @@ static int adev_open_input_stream(struct audio_hw_device *dev,
                                  struct audio_stream_in **stream_in,
                                  audio_input_flags_t flags __unused,
                                  const char *address __unused,
                                  audio_source_t source __unused)
                                  audio_source_t source)
{
    struct audio_device *adev = (struct audio_device *)dev;
    struct stream_in *in;
@@ -3514,8 +3521,8 @@ static int adev_open_input_stream(struct audio_hw_device *dev,
    }

    ALOGD("%s: enter: sample_rate(%d) channel_mask(%#x) devices(%#x)\
        stream_handle(%p) io_handle(%d)",__func__, config->sample_rate, config->channel_mask,
        devices, &in->stream, handle);
        stream_handle(%p) io_handle(%d) source(%d)",__func__, config->sample_rate, config->channel_mask,
        devices, &in->stream, handle, source);

    pthread_mutex_init(&in->lock, (const pthread_mutexattr_t *) NULL);

@@ -3536,7 +3543,7 @@ static int adev_open_input_stream(struct audio_hw_device *dev,
    in->stream.get_input_frames_lost = in_get_input_frames_lost;

    in->device = devices;
    in->source = AUDIO_SOURCE_DEFAULT;
    in->source = source;
    in->dev = adev;
    in->standby = 1;
    in->channel_mask = config->channel_mask;
@@ -3602,6 +3609,13 @@ static int adev_open_input_stream(struct audio_hw_device *dev,
                                            channel_count,
                                            is_low_latency);
        in->config.period_size = buffer_size / frame_size;
        if ((in->source == AUDIO_SOURCE_VOICE_COMMUNICATION) &&
               (in->dev->mode == AUDIO_MODE_IN_COMMUNICATION) &&
               (voice_extn_compress_voip_is_format_supported(in->format)) &&
               (in->config.rate == 8000 || in->config.rate == 16000) &&
               (audio_channel_count_from_in_mask(in->channel_mask) == 1)) {
            voice_extn_compress_voip_open_input_stream(in);
        }
    }

    /* This stream could be for sound trigger lab,
@@ -3823,14 +3837,15 @@ static int adev_open(const hw_module_t *module, const char *name,
    adev->bt_wb_speech_enabled = false;

    audio_extn_ds2_enable(adev);

    if (amplifier_open() != 0)
        ALOGE("Amplifier initialization failed");

    *device = &adev->device.common;

    audio_extn_utils_update_streams_output_cfg_list(adev->platform, adev->mixer,
                                                    &adev->streams_output_cfg_list);

    if (amplifier_open() != 0)
        ALOGE("Amplifier initialization failed");

    audio_device_ref_count++;

    char value[PROPERTY_VALUE_MAX];
+6 −0
Original line number Diff line number Diff line
@@ -1145,3 +1145,9 @@ int platform_set_device_params(struct stream_out *out __unused,
{
    return 0;
}

int platform_set_snd_device_name(snd_device_t snd_device __unused,
                                 const char * name __unused)
{
    return -ENOSYS;
}
+30 −2
Original line number Diff line number Diff line
@@ -183,6 +183,7 @@ struct platform_data {
    bool hd_voice;
    bool ec_ref_enabled;
    bool is_i2s_ext_modem;
    bool camcorder_stereo;
    /* Audio calibration related functions */
    void                       *acdb_handle;
    int                        voice_feature_set;
@@ -270,7 +271,7 @@ static int pcm_device_table[AUDIO_USECASE_MAX][2] = {
};

/* Array to store sound devices */
static const char * const device_table[SND_DEVICE_MAX] = {
static char * device_table[SND_DEVICE_MAX] = {
    [SND_DEVICE_NONE] = "none",
    /* Playback sound devices */
    [SND_DEVICE_OUT_HANDSET] = "handset",
@@ -337,6 +338,7 @@ static const char * const device_table[SND_DEVICE_MAX] = {
    [SND_DEVICE_IN_BT_SCO_MIC_WB] = "bt-sco-mic-wb",
    [SND_DEVICE_IN_BT_SCO_MIC_WB_NREC] = "bt-sco-mic-wb",
    [SND_DEVICE_IN_CAMCORDER_MIC] = "camcorder-mic",
    [SND_DEVICE_IN_CAMCORDER_STEREO_DMIC] = "camcorder-stereo-dmic",
    [SND_DEVICE_IN_VOICE_DMIC] = "voice-dmic-ef",
    [SND_DEVICE_IN_VOICE_SPEAKER_DMIC] = "voice-speaker-dmic-ef",
    [SND_DEVICE_IN_VOICE_SPEAKER_QMIC] = "voice-speaker-qmic",
@@ -436,6 +438,7 @@ static int acdb_device_table[SND_DEVICE_MAX] = {
    [SND_DEVICE_IN_BT_SCO_MIC_WB] = 38,
    [SND_DEVICE_IN_BT_SCO_MIC_WB_NREC] = 123,
    [SND_DEVICE_IN_CAMCORDER_MIC] = 4,
    [SND_DEVICE_IN_CAMCORDER_STEREO_DMIC] = 131,
    [SND_DEVICE_IN_VOICE_DMIC] = 41,
    [SND_DEVICE_IN_VOICE_SPEAKER_DMIC] = 43,
    [SND_DEVICE_IN_VOICE_SPEAKER_QMIC] = 19,
@@ -533,6 +536,7 @@ static struct name_to_index snd_device_name_index[SND_DEVICE_MAX] = {
    {TO_NAME_INDEX(SND_DEVICE_IN_BT_SCO_MIC_WB)},
    {TO_NAME_INDEX(SND_DEVICE_IN_BT_SCO_MIC_WB_NREC)},
    {TO_NAME_INDEX(SND_DEVICE_IN_CAMCORDER_MIC)},
    {TO_NAME_INDEX(SND_DEVICE_IN_CAMCORDER_STEREO_DMIC)},
    {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_DMIC)},
    {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_SPEAKER_DMIC)},
    {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_SPEAKER_QMIC)},
@@ -1072,6 +1076,7 @@ void *platform_init(struct audio_device *adev)
    my_data->slowtalk = false;
    my_data->hd_voice = false;
    my_data->edid_info = NULL;
    my_data->camcorder_stereo = false;

    property_get("ro.qc.sdk.audio.fluencetype", my_data->fluence_cap, "");
    if (!strncmp("fluencepro", my_data->fluence_cap, sizeof("fluencepro"))) {
@@ -1082,6 +1087,11 @@ void *platform_init(struct audio_device *adev)
        my_data->fluence_type = FLUENCE_NONE;
    }

    property_get("persist.audio.camcorder.stereo", value, "false");
    if (!strncmp("true", value, sizeof("true"))) {
        my_data->camcorder_stereo = true;
    }

    if (my_data->fluence_type != FLUENCE_NONE) {
        property_get("persist.audio.fluence.voicecall",value,"");
        if (!strncmp("true", value, sizeof("true"))) {
@@ -2032,6 +2042,9 @@ snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_d
    } else if (source == AUDIO_SOURCE_CAMCORDER) {
        if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC ||
            in_device & AUDIO_DEVICE_IN_BACK_MIC) {
            if (my_data->camcorder_stereo)
                snd_device = SND_DEVICE_IN_CAMCORDER_STEREO_DMIC;
            else
                snd_device = SND_DEVICE_IN_CAMCORDER_MIC;
        }
    } else if (source == AUDIO_SOURCE_VOICE_RECOGNITION) {
@@ -3695,3 +3708,18 @@ int platform_set_device_params(struct stream_out *out, int param, int value)
end:
    return ret;
}

int platform_set_snd_device_name(snd_device_t device, const char *name)
{
    int ret = 0;

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

    device_table[device] = strdup(name);
done:
    return ret;
}
+1 −0
Original line number Diff line number Diff line
@@ -121,6 +121,7 @@ enum {
    SND_DEVICE_IN_BT_SCO_MIC_WB,
    SND_DEVICE_IN_BT_SCO_MIC_WB_NREC,
    SND_DEVICE_IN_CAMCORDER_MIC,
    SND_DEVICE_IN_CAMCORDER_STEREO_DMIC,
    SND_DEVICE_IN_VOICE_DMIC,
    SND_DEVICE_IN_VOICE_SPEAKER_DMIC,
    SND_DEVICE_IN_VOICE_SPEAKER_QMIC,
Loading