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

Commit 9828fdc5 authored by wjiang's avatar wjiang Committed by Steve Kondik
Browse files

post_proc: Squash upstream changes

post_proc: disable effect immediately when routed to invalid devices

Offload effect is still perceived when invalid output device is
connected. We should send disable command immediately once phone is
routed to unexpected device and forbid effect enablement during
temporary disabled state.

Change-Id: I26d4ccfd77037a879622b0437ae3916ff0071a69
CRs-Fixed: 630408

post_proc: disable Bassboost and Virtualizer for USB_ACCESSORY

USB_ACCESSORY is not intended to be applied with SA+ bassboost
and virtualizer, so add into invalid devices list.

CRs-Fixed: 659191
Change-Id: If1f3421f9935ce624dc21895d9244d36d195b2bd

post_proc: fix post and pre process KW issues

KW issue fix includes:
- handle memory allocation failure
- array index boundary check

Change-Id: I083952ba58d348a5b650601a83e6f492b0d686bb

post_proc: Fix improper datatype of EQ preset band level value

unsigned int causes negative band level turn out to be extreme large
value, which results in EQ works abnormally due to unexpected parameter
sent.

Change-Id: I81120c604f4e9f23b25d5a45a7b0294fea63d207
CRs-Fixed: 696825

post_proc: add support for virtualizer capability query

Add extra virtualizer interfaces to keep align with aosp design.
Extended capabilities include:
- Stub interface to allow querying speaker angles.
- Force set output device as specific virtualize mode.
- Query virtualize mode

Stub function remains to be refined in sync with upcoming aosp
changes.

Change-Id: I3316f6d944db1c9954eda7643a5ce433defa1a6c
CRs-Fixed: 810294

post_proc: remove unnecessary command size check

Up bound check for command size of EFFECT_CMD_SET_PARAM is not
applicable for DSP effect bundle. Remove the check to avoid parameter
not taking effect.

Change-Id: I7e8f73377699f11bdc1f62a05f6bea03c9c24151
CRs-Fixed: 816053

post_proc: explicitly disable virtualizer module if strength is 0

0 stength in DSP virtualizer is not equivalent to disable state as down
mix is still happening for multichannel inputs.

For better user experience, explicitly disable virtualizer module when
strength is 0.

Change-Id: Ic2884ac7010e4f835df871719d546c0c05173f4b
CRs-Fixed: 872772

post_proc: fix reverb processing issue when preset is set to NONE

Reverb effects are getting applied even after setting reverb preset
to REVERB_PRESET_NONE.
Preset NONE is used by client and is supposed to be equivalent to
disabled state, even though this preset is not supported in DSP.
Fix this issue by avoiding enable command from post processing HAL
to DSP when preset NONE is in use.

CRs-Fixed: 868041
Change-Id: Iad626a7400246e80a97a926234cfb7756ec6083e

post_proc: fix crash in offload effect bundle during stop output

Effect bundle stop() frees mixer contol before doing module stop(),
whereas module's stop() still needs this control to send disable
command down the layer.
Crash is observed if memory associated with effect control is reused
and gets altered by the time mixer control is completed.
Move mixer control's deletion after module's stop() to fix this issue.

CRs-Fixed: 860604
Change-Id: Ia8b6d5f847b69392afbda1ba77fc740a47aba25d
parent 3e55a862
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -152,6 +152,7 @@ int bassboost_set_device(effect_context_t *context, uint32_t device)
       (device == AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT) ||
       (device == AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER) ||
       (device == AUDIO_DEVICE_OUT_AUX_DIGITAL) ||
       (device == AUDIO_DEVICE_OUT_USB_ACCESSORY) ||
       (device == AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET)) {
        if (!bass_ctxt->temp_disabled) {
            if (effect_is_active(&bass_ctxt->common)) {
@@ -162,6 +163,10 @@ int bassboost_set_device(effect_context_t *context, uint32_t device)
                                                  OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG);
            }
            bass_ctxt->temp_disabled = true;
            if (bass_ctxt->ctl)
                offload_bassboost_send_params(bass_ctxt->ctl,
                                              &bass_ctxt->offload_bass,
                                              OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG);
        }
    } else {
        if (bass_ctxt->temp_disabled) {
@@ -173,6 +178,10 @@ int bassboost_set_device(effect_context_t *context, uint32_t device)
                                                  OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG);
            }
            bass_ctxt->temp_disabled = false;
            if (bass_ctxt->ctl)
                offload_bassboost_send_params(bass_ctxt->ctl,
                                              &bass_ctxt->offload_bass,
                                              OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG);
        }
    }
    offload_bassboost_set_device(&(bass_ctxt->offload_bass), device);
+22 −3
Original line number Diff line number Diff line
/*
 * Copyright (C) 2014 The Android Open Source Project
 * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
 * Not a Contribution.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -198,6 +200,11 @@ int offload_effects_bundle_hal_start_output(audio_io_handle_t output, int pcm_id

    out_ctxt = (output_context_t *)
                                 malloc(sizeof(output_context_t));
    if (!out_ctxt) {
        ALOGE("%s fail to allocate for output context", __func__);
        ret = -ENOMEM;
        goto exit;
    }
    out_ctxt->handle = output;
    out_ctxt->pcm_device_id = pcm_id;

@@ -263,9 +270,6 @@ int offload_effects_bundle_hal_stop_output(audio_io_handle_t output, int pcm_id)
        goto exit;
    }

    if (out_ctxt->mixer)
        mixer_close(out_ctxt->mixer);

    list_for_each(fx_node, &out_ctxt->effects_list) {
        effect_context_t *fx_ctxt = node_to_item(fx_node,
                                                 effect_context_t,
@@ -274,6 +278,9 @@ int offload_effects_bundle_hal_stop_output(audio_io_handle_t output, int pcm_id)
            fx_ctxt->ops.stop(fx_ctxt, out_ctxt);
    }

    if (out_ctxt->mixer)
        mixer_close(out_ctxt->mixer);

    list_remove(&out_ctxt->outputs_list_node);

    free(out_ctxt);
@@ -333,6 +340,9 @@ int effect_lib_create(const effect_uuid_t *uuid,
        sizeof(effect_uuid_t)) == 0) {
        equalizer_context_t *eq_ctxt = (equalizer_context_t *)
                                       calloc(1, sizeof(equalizer_context_t));
        if (eq_ctxt == NULL) {
            return -ENOMEM;
        }
        context = (effect_context_t *)eq_ctxt;
        context->ops.init = equalizer_init;
        context->ops.reset = equalizer_reset;
@@ -350,6 +360,9 @@ int effect_lib_create(const effect_uuid_t *uuid,
               sizeof(effect_uuid_t)) == 0) {
        bassboost_context_t *bass_ctxt = (bassboost_context_t *)
                                         calloc(1, sizeof(bassboost_context_t));
        if (bass_ctxt == NULL) {
            return -ENOMEM;
        }
        context = (effect_context_t *)bass_ctxt;
        context->ops.init = bassboost_init;
        context->ops.reset = bassboost_reset;
@@ -367,6 +380,9 @@ int effect_lib_create(const effect_uuid_t *uuid,
               sizeof(effect_uuid_t)) == 0) {
        virtualizer_context_t *virt_ctxt = (virtualizer_context_t *)
                                           calloc(1, sizeof(virtualizer_context_t));
        if (virt_ctxt == NULL) {
            return -ENOMEM;
        }
        context = (effect_context_t *)virt_ctxt;
        context->ops.init = virtualizer_init;
        context->ops.reset = virtualizer_reset;
@@ -390,6 +406,9 @@ int effect_lib_create(const effect_uuid_t *uuid,
                sizeof(effect_uuid_t)) == 0)) {
        reverb_context_t *reverb_ctxt = (reverb_context_t *)
                                        calloc(1, sizeof(reverb_context_t));
        if (reverb_ctxt == NULL) {
            return -ENOMEM;
        }
        context = (effect_context_t *)reverb_ctxt;
        context->ops.init = reverb_init;
        context->ops.reset = reverb_reset;
+3 −2
Original line number Diff line number Diff line
@@ -299,8 +299,9 @@ int offload_eq_send_params(struct mixer_ctl *ctl, struct eq_params *eq,
    int *p_param_values = param_values;
    uint32_t i;

    ALOGV("%s", __func__);
    if (eq->config.preset_id < -1 ) {
    ALOGV("%s: flags 0x%x", __func__, param_send_flags);
    if ((eq->config.preset_id < -1) ||
            ((param_send_flags & OFFLOAD_SEND_EQ_PRESET) && (eq->config.preset_id == -1))) {
        ALOGV("No Valid preset to set");
        return 0;
    }
+18 −4
Original line number Diff line number Diff line
@@ -246,6 +246,7 @@ void reverb_set_preset(reverb_context_t *context, int16_t preset)
    context->next_preset = preset;
    offload_reverb_set_preset(&(context->offload_reverb), preset);

    if (context->enabled_by_client) {
        enable = (preset == REVERB_PRESET_NONE) ? false: true;
        offload_reverb_set_enable_flag(&(context->offload_reverb), enable);

@@ -254,6 +255,7 @@ void reverb_set_preset(reverb_context_t *context, int16_t preset)
                                   OFFLOAD_SEND_REVERB_ENABLE_FLAG |
                                   OFFLOAD_SEND_REVERB_PRESET);
    }
}

void reverb_set_all_properties(reverb_context_t *context,
                               reverb_settings_t *reverb_settings)
@@ -568,6 +570,7 @@ int reverb_init(effect_context_t *context)

    set_config(context, &context->config);

    reverb_ctxt->enabled_by_client = false;
    memset(&(reverb_ctxt->reverb_settings), 0, sizeof(reverb_settings_t));
    memset(&(reverb_ctxt->offload_reverb), 0, sizeof(struct reverb_params));

@@ -583,6 +586,16 @@ int reverb_enable(effect_context_t *context)
    reverb_context_t *reverb_ctxt = (reverb_context_t *)context;

    ALOGV("%s", __func__);
    reverb_ctxt->enabled_by_client = true;

    /* REVERB_PRESET_NONE is equivalent to disabled state,
     * But support for this state is not provided in DSP.
     * Hence, do not set enable flag, if in peset mode with preset "NONE".
     * Effect would be enabled when valid preset is set.
     */
    if ((reverb_ctxt->preset == true) &&
        (reverb_ctxt->next_preset == REVERB_PRESET_NONE))
        return 0;

    if (!offload_reverb_get_enable_flag(&(reverb_ctxt->offload_reverb)))
        offload_reverb_set_enable_flag(&(reverb_ctxt->offload_reverb), true);
@@ -594,6 +607,7 @@ int reverb_disable(effect_context_t *context)
    reverb_context_t *reverb_ctxt = (reverb_context_t *)context;

    ALOGV("%s", __func__);
    reverb_ctxt->enabled_by_client = false;
    if (offload_reverb_get_enable_flag(&(reverb_ctxt->offload_reverb))) {
        offload_reverb_set_enable_flag(&(reverb_ctxt->offload_reverb), false);
        if (reverb_ctxt->ctl)
+1 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ typedef struct reverb_context_s {

    // Offload vars
    struct mixer_ctl *ctl;
    bool enabled_by_client;
    bool auxiliary;
    bool preset;
    uint16_t cur_preset;
Loading