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

Commit 8d6edc60 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "audio-hal: soft step volume params controls"

parents b8ab916b 10ad39f2
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -144,6 +144,12 @@
        <usecase name="USECASE_AUDIO_RECORD3" type="in" id="62" />
    </pcm_ids>

    <soft_volume_params>
        <vol_params name="USECASE_AUDIO_PLAYBACK_MEDIA" period="70" step="10000" curve="0"/>
        <vol_params name="USECASE_AUDIO_PLAYBACK_SYS_NOTIFICATION" period="25" step="1000" curve="0"/>
        <vol_params name="USECASE_AUDIO_PLAYBACK_REAR_SEAT" period="40" step="1000" curve="0"/>
    </soft_volume_params>

    <config_params>
        <param key="spkr_1_tz_name" value="wsatz.13"/>
        <param key="spkr_2_tz_name" value="wsatz.14"/>
+2 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ AUDIO_FEATURE_ENABLED_3D_AUDIO := false
AUDIO_FEATURE_ENABLED_AHAL_EXT := false
DOLBY_ENABLE := false
AUDIO_FEATURE_ENABLED_EXTENDED_COMPRESS_FORMAT := true
AUDIO_FEATURE_ENABLED_SOFT_VOLUME:= true
endif

USE_XML_AUDIO_POLICY_CONF := 1
@@ -89,6 +90,7 @@ AUDIO_FEATURE_ENABLED_DLKM := true
AUDIO_FEATURE_ENABLED_USB_BURST_MODE := false
AUDIO_FEATURE_ENABLED_SVA_MULTI_STAGE := true
AUDIO_FEATURE_ENABLED_BATTERY_LISTENER := false
AUDIO_FEATURE_ENABLED_SOFT_VOLUME:= true
##AUDIO_FEATURE_FLAGS

AUDIO_HARDWARE += audio.a2dp.default

hal/Android.mk

100644 → 100755
+5 −0
Original line number Diff line number Diff line
@@ -258,6 +258,11 @@ ifeq ($(strip $(AUDIO_FEATURE_ENABLED_CONCURRENT_CAPTURE)),true)
    LOCAL_CFLAGS += -DCONCURRENT_CAPTURE_ENABLED
endif

# soft step volume params control
ifeq ($(strip $(AUDIO_FEATURE_ENABLED_SOFT_VOLUME)),true)
    LOCAL_CFLAGS += -DSOFT_VOLUME
endif

# Hardware specific feature
ifeq ($(strip $(AUDIO_FEATURE_ENABLED_QAP)),true)
LOCAL_CFLAGS += -DQAP_EXTN_ENABLED -Wno-tautological-pointer-compare

hal/audio_hw.c

100644 → 100755
+45 −1
Original line number Diff line number Diff line
@@ -543,7 +543,9 @@ static int out_set_compr_volume(struct audio_stream_out *stream, float left, flo
static int out_set_mmap_volume(struct audio_stream_out *stream, float left, float right);
static int out_set_voip_volume(struct audio_stream_out *stream, float left, float right);
static int out_set_pcm_volume(struct audio_stream_out *stream, float left, float right);

#ifdef SOFT_VOLUME
static int out_set_soft_volume_params(struct audio_stream_out *stream);
#endif
static void adev_snd_mon_cb(void *cookie, struct str_parms *parms);
static void in_snd_mon_cb(void * stream, struct str_parms * parms);
static void out_snd_mon_cb(void * stream, struct str_parms * parms);
@@ -4283,6 +4285,9 @@ int start_output_stream(struct stream_out *out)
                 out->apply_volume = false;
        } else if (audio_extn_auto_hal_is_bus_device_usecase(out->usecase)) {
            out_set_pcm_volume(&out->stream, out->volume_l, out->volume_r);
#ifdef SOFT_VOLUME
            out_set_soft_volume_params(&out->stream);
#endif
        }
    } else {
        /*
@@ -5647,6 +5652,45 @@ static float AmpToDb(float amplification)
    return db;
}

#ifdef SOFT_VOLUME
static int out_set_soft_volume_params(struct audio_stream_out *stream)
{
    struct stream_out *out = (struct stream_out *)stream;
    int ret = 0;
    char mixer_ctl_name[128];
    struct audio_device *adev = out->dev;
    struct mixer_ctl *ctl = NULL;
    struct soft_step_volume_params *volume_params = NULL;

    int pcm_device_id = platform_get_pcm_device_id(out->usecase, PCM_PLAYBACK);
    snprintf(mixer_ctl_name, sizeof(mixer_ctl_name), "Playback  %d Soft Vol Params", pcm_device_id);
    ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
    if (!ctl) {
        ALOGE("%s : Could not get ctl for mixer cmd - %s", __func__, mixer_ctl_name);
        return -EINVAL;
    }

    volume_params =(struct soft_step_volume_params * ) malloc(sizeof(struct soft_step_volume_params));
    if (volume_params == NULL){
        ALOGE("%s : malloc is failed for volume params", __func__);
        return -EINVAL;
    } else {
        ret = platform_get_soft_step_volume_params(volume_params,out->usecase);
        if (ret < 0) {
            ALOGE("%s : platform_get_soft_step_volume_params is fialed", __func__);
            return -EINVAL;
        }

    }
    ret = mixer_ctl_set_array(ctl, volume_params, sizeof(struct soft_step_volume_params)/sizeof(int));
    if (ret < 0) {
        ALOGE("%s: Could not set ctl, error:%d ", __func__, ret);
        return -EINVAL;
    }
    return 0;
}
#endif

static int out_set_mmap_volume(struct audio_stream_out *stream, float left,
                          float right)
{
+43 −0
Original line number Diff line number Diff line
@@ -33,6 +33,40 @@
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.

 *  Changes from Qualcomm Innovation Center are provided under the following license:

 * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.

 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted (subject to the limitations in the
 * disclaimer below) provided that the following conditions are met:

 *  * Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.

 *   * Redistributions in binary form must reproduce the above
 *     copyright notice, this list of conditions and the following
 *     disclaimer in the documentation and/or other materials provided
 *     with the distribution.

 *   * Neither the name of Qualcomm Innovation Center, Inc. nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.

 * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
 * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
 * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef QCOM_AUDIO_HW_H
@@ -803,6 +837,15 @@ struct audio_patch_record {
    struct audio_patch patch;
};

#ifdef SOFT_VOLUME
/* this struct is used for set/get values from AHAL*/
struct soft_step_volume_params {
    int period;
    int step;
    int curve;
};
#endif

int select_devices(struct audio_device *adev,
                          audio_usecase_t uc_id);
int disable_audio_route(struct audio_device *adev,
Loading