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

Commit 9b7e6903 authored by Shruthi Krishna's avatar Shruthi Krishna
Browse files

Merge tag 'AU_LINUX_ANDROID_LA.BF64.1.05.00.00.021.095' into merge_branch

AU_LINUX_ANDROID_LA.BF64.1.05.00.00.021.095 based on quic/aosp/LA.BF64.1

* tag 'AU_LINUX_ANDROID_LA.BF64.1.05.00.00.021.095': (30 commits)
  audio: Reject incall record request when mode is not IN_CALL
  mm-audio: aenc-aac: fix integer overflow for encoded buffer timestamp calculation
  hal: Add support for parsing hdmi edid information for msm8992
  hal: Fix glitch in audio playback during device switch
  hal: add support to query hpx state using getparameter
  hal: add all compressed formats for app type selection
  hal: Performance mode during recording usecase
  hal: fix null pointer de-reference
  hal : add 8992 for msm8992 audio
  post_proc: Support Headphone:X in offload and non tunnel modes
  post_proc: Add support for non-tunnel DSP audio effects
  audio: Avoid mute during AFE PROXY Usecase
  hal: Fix DTS HPX Get parameters
  hal: bug fixes for PCM offload
  hal: Fix progress bar issue during compress offload playback
  hal: Fix setting stream channel map properly
  hardware/qcom/audio: Integrate Eagle framework for HeadphoneX
  hal: Remove setting DAP bypass /DAP on from HAL
  hal: Avoid resetting device to speaker for HDMI passthrough case
  hal: Audio HAL / APM changes for HDMI passthrough
  ...

Conflicts:
	Android.mk
	hal/Android.mk
	hal/audio_extn/audio_extn.h
	hal/audio_extn/utils.c
	hal/audio_hw.c
	hal/voice.c

Change-Id: Ia92b2002486894e8711a48480324479fe114aeb6
parents ca4688b3 ae9ad12d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
ifneq ($(filter mpq8092 msm8960 msm8226 msm8x26 msm8610 msm8974 msm8x74 apq8084 msm8916 msm8994 msm8909 thulium,$(TARGET_BOARD_PLATFORM)),)
ifneq ($(filter mpq8092 msm8960 msm8226 msm8x26 msm8610 msm8974 msm8x74 apq8084 msm8916 msm8994 msm8909 msm8909 thulium,$(TARGET_BOARD_PLATFORM)),)

MY_LOCAL_PATH := $(call my-dir)

+25 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ LOCAL_ARM_MODE := arm

AUDIO_PLATFORM := $(TARGET_BOARD_PLATFORM)

ifneq ($(filter msm8974 msm8226 msm8610 apq8084 msm8994 thulium,$(TARGET_BOARD_PLATFORM)),)
ifneq ($(filter msm8974 msm8226 msm8610 apq8084 msm8994 msm8992 thulium,$(TARGET_BOARD_PLATFORM)),)
  # B-family platform uses msm8974 code base
  AUDIO_PLATFORM = msm8974
  MULTIPLE_HW_VARIANTS_ENABLED := true
@@ -24,6 +24,9 @@ endif
ifneq ($(filter msm8994,$(TARGET_BOARD_PLATFORM)),)
  LOCAL_CFLAGS := -DPLATFORM_MSM8994
endif
ifneq ($(filter msm8992,$(TARGET_BOARD_PLATFORM)),)
  LOCAL_CFLAGS := -DPLATFORM_MSM8994
endif
ifneq ($(filter thulium,$(TARGET_BOARD_PLATFORM)),)
  LOCAL_CFLAGS := -DPLATFORM_THULIUM
endif
@@ -49,6 +52,10 @@ LOCAL_SRC_FILES += audio_extn/audio_extn.c \
LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr

ifneq ($(filter msm8994 msm8992,$(TARGET_BOARD_PLATFORM)),)
    LOCAL_SRC_FILES += edid.c
endif

ifeq ($(strip $(AUDIO_FEATURE_ENABLED_PCM_OFFLOAD)),true)
    LOCAL_CFLAGS += -DPCM_OFFLOAD_ENABLED
endif
@@ -65,6 +72,10 @@ ifeq ($(strip $(AUDIO_FEATURE_ENABLED_PROXY_DEVICE)),true)
    LOCAL_CFLAGS += -DAFE_PROXY_ENABLED
endif

ifeq ($(strip $(AUDIO_FEATURE_ENABLED_KPI_OPTIMIZE)),true)
    LOCAL_CFLAGS += -DKPI_OPTIMIZE_ENABLED
endif

ifeq ($(strip $(AUDIO_FEATURE_ENABLED_FM)),true)
    LOCAL_CFLAGS += -DFM_ENABLED
    LOCAL_SRC_FILES += audio_extn/fm.c
@@ -124,6 +135,11 @@ ifeq ($(strip $(AUDIO_FEATURE_ENABLED_COMPRESS_CAPTURE)),true)
    LOCAL_SRC_FILES += audio_extn/compress_capture.c
endif

ifeq ($(strip $(AUDIO_FEATURE_ENABLED_DTS_EAGLE)),true)
    LOCAL_CFLAGS += -DDTS_EAGLE
    LOCAL_SRC_FILES += audio_extn/dts_eagle.c
endif

ifeq ($(strip $(DOLBY_DDP)),true)
    LOCAL_CFLAGS += -DDS1_DOLBY_DDP_ENABLED
    LOCAL_SRC_FILES += audio_extn/dolby.c
@@ -153,6 +169,10 @@ ifeq ($(strip $(AUDIO_FEATURE_ENABLED_RECORD_PLAY_CONCURRENCY)),true)
    LOCAL_CFLAGS += -DRECORD_PLAY_CONCURRENCY
endif

ifeq ($(strip $(AUDIO_FEATURE_ENABLED_ACDB_LICENSE)), true)
    LOCAL_CFLAGS += -DDOLBY_ACDB_LICENSE
endif

ifeq ($(strip $(AUDIO_FEATURE_ENABLED_DS2_DOLBY_DAP)),true)
    LOCAL_CFLAGS += -DDS2_DOLBY_DAP_ENABLED
ifneq ($(strip $(DOLBY_DDP)),true)
@@ -162,6 +182,10 @@ ifneq ($(strip $(DOLBY_DDP)),true)
endif
endif

ifeq ($(strip $(AUDIO_FEATURE_ENABLED_HDMI_PASSTHROUGH)),true)
    LOCAL_CFLAGS += -DHDMI_PASSTHROUGH_ENABLED
endif

LOCAL_SHARED_LIBRARIES := \
	liblog \
	libcutils \
+130 −0
Original line number Diff line number Diff line
/*Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*      http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* 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.
* This file was modified by DTS, Inc. The portions of the
* code modified by DTS, Inc are copyrighted and
* licensed separately, as follows:
*
*  (C) 2014 DTS, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*    http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* 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.
*/

#define LOG_TAG "AudioUtil"
//#define LOG_NDEBUG 0
#include <utils/Log.h>
#include <stdlib.h>

#include <cutils/properties.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sound/devdep_params.h>
#include <sound/asound.h>
#include "AudioUtil.h"

#define ROUTE_PATH    "/data/data/dts/route"
#define DEVICE_NODE   "/dev/snd/hwC0D3"

static int32_t mDevices = 0;
static int32_t mCurrDevice = 0;

void create_route_node(void)
{
    char prop[PROPERTY_VALUE_MAX] = "true";
    int fd;
    property_get("use.dts_eagle", prop, "0");
    if (!strncmp("true", prop, sizeof("true")) || atoi(prop)) {
        ALOGV("create_route_node");
        if ((fd=open(ROUTE_PATH, O_RDONLY)) < 0) {
            ALOGV("No File exisit");
        } else {
            ALOGV("A file with the same name exist. Remove it before creating it");
            close(fd);
            remove(ROUTE_PATH);
        }
        if ((fd=creat(ROUTE_PATH, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) < 0) {
            ALOGE("opening route node failed returned");
            return;
        }
        chmod(ROUTE_PATH, S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH);
        ALOGV("opening route  node successful");
        close(fd);
    }
}

void notify_route_node(int active_device, int devices)
{
    char prop[PROPERTY_VALUE_MAX] = "true";
    char buf[1024];
    int fd;
    if ((mCurrDevice == active_device) &&
        (mDevices == devices)) {
        ALOGV("nothing to update to route node");
        return;
    }
    mDevices = devices;
    mCurrDevice = active_device;
    property_get("use.dts_eagle", prop, "0");
    if (!strncmp("true", prop, sizeof("true")) || atoi(prop)) {
        ALOGV("notify active device : %d all_devices : %d", active_device, devices);
        if ((fd=open(ROUTE_PATH, O_TRUNC|O_WRONLY)) < 0) {
            ALOGV("Write device to route node failed");
        } else {
            ALOGV("Write device to route node successful");
            snprintf(buf, sizeof(buf), "device=%d;all_devices=%d", active_device, devices);
            int n = write(fd, buf, strlen(buf));
            ALOGV("number of bytes written: %d", n);
            close(fd);
        }
        int eaglefd = open(DEVICE_NODE, O_RDWR);
        int32_t params[2] = {active_device, 1 /*is primary device*/};
        if (eaglefd > 0) {
            if(ioctl(eaglefd, DTS_EAGLE_IOCTL_SET_ACTIVE_DEVICE, &params) < 0) {
                ALOGE("DTS_EAGLE (%s): error sending primary device\n", __func__);
            }
            ALOGD("DTS_EAGLE (%s): sent primary device\n", __func__);
            close(eaglefd);
        } else {
            ALOGE("DTS_EAGLE (%s): error opening eagle\n", __func__);
        }
    }
}

void remove_route_node(void)
{
    char prop[PROPERTY_VALUE_MAX] = "true";
    int fd;
    property_get("use.dts_eagle", prop, "0");
    if (!strncmp("true", prop, sizeof("true")) || atoi(prop)) {
        ALOGV("remove_route_node");
        if ((fd=open(ROUTE_PATH, O_RDONLY)) < 0) {
            ALOGV("open route  node failed");
        } else {
            ALOGV("open route node successful");
            ALOGV("Remove the file");
            close(fd);
            remove(ROUTE_PATH);
        }
    }
}
+46 −0
Original line number Diff line number Diff line
/*Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*      http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* 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.
* This file was modified by DTS, Inc. The portions of the
* code modified by DTS, Inc are copyrighted and
* licensed separately, as follows:
*
*  (C) 2014 DTS, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*    http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* 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.
*/

#ifndef AUDIO_UTIL_H_
#define AUDIO_UTIL_H_

#ifndef DTS_EAGLE
#define create_route_node() (0)
#define notify_route_node(active_device, devices) (0)
#define remove_route_node() (0)
#else
void create_route_node(void);
void notify_route_node(int active_device, int devices);
void remove_route_node(void);
#endif

#endif  //AUDIO_UTIL_H_
+163 −24
Original line number Diff line number Diff line
@@ -15,6 +15,24 @@
 * 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.
 *
 * This file was modified by DTS, Inc. The portions of the
 * code modified by DTS, Inc are copyrighted and
 * licensed separately, as follows:
 *
 * (C) 2014 DTS, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * 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.
 */

#define LOG_TAG "audio_hw_extn"
@@ -23,6 +41,7 @@

#include <stdlib.h>
#include <errno.h>
#include <dlfcn.h>
#include <cutils/properties.h>
#include <cutils/log.h>

@@ -30,6 +49,7 @@
#include "audio_extn.h"
#include "platform.h"
#include "platform_api.h"
#include "edid.h"

#define MAX_SLEEP_RETRY 100
#define WIFI_INIT_WAIT_SLEEP 50
@@ -39,6 +59,7 @@ struct audio_extn_module {
    bool aanc_enabled;
    bool custom_stereo_enabled;
    uint32_t proxy_channel_num;
    bool hpx_enabled;
};

static struct audio_extn_module aextnmod = {
@@ -46,6 +67,7 @@ static struct audio_extn_module aextnmod = {
    .aanc_enabled = 0,
    .custom_stereo_enabled = 0,
    .proxy_channel_num = 2,
    .hpx_enabled = 0,
};

#define AUDIO_PARAMETER_KEY_ANC        "anc_enabled"
@@ -54,6 +76,7 @@ static struct audio_extn_module aextnmod = {
#define AUDIO_PARAMETER_CUSTOM_STEREO  "stereo_as_dual_mono"
/* Query offload playback instances count */
#define AUDIO_PARAMETER_OFFLOAD_NUM_ACTIVE "offload_num_active"
#define AUDIO_PARAMETER_HPX            "HPX"

#ifndef FM_ENABLED
#define audio_extn_fm_set_parameters(adev, parms) (0)
@@ -107,6 +130,76 @@ void audio_extn_customstereo_set_parameters(struct audio_device *adev,
}
#endif /* CUSTOM_STEREO_ENABLED */

#ifndef DTS_EAGLE
#define audio_extn_hpx_set_parameters(adev, parms)         (0)
#define audio_extn_hpx_get_parameters(query, reply)  (0)
#define audio_extn_check_and_set_dts_hpx_state(adev)       (0)
#else
void audio_extn_hpx_set_parameters(struct audio_device *adev,
                                   struct str_parms *parms)
{
    int ret = 0;
    char value[32]={0};
    char prop[PROPERTY_VALUE_MAX] = "false";
    bool hpx_state = false;
    const char *mixer_ctl_name = "Set HPX OnOff";
    struct mixer_ctl *ctl = NULL;
    ALOGV("%s", __func__);

    property_get("use.dts_eagle", prop, "0");
    if (strncmp("true", prop, sizeof("true")))
        return;

    ret = str_parms_get_str(parms, AUDIO_PARAMETER_HPX, value,
                            sizeof(value));
    if (ret >= 0) {
        if (!strncmp("ON", value, sizeof("ON")))
            hpx_state = true;

        if (hpx_state == aextnmod.hpx_enabled)
            return;

        aextnmod.hpx_enabled = hpx_state;
        /* set HPX state on stream pp */
        if (adev->offload_effects_set_hpx_state != NULL)
            adev->offload_effects_set_hpx_state(hpx_state);

        /* set HPX state on device pp */
        ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
        if (ctl)
            mixer_ctl_set_value(ctl, 0, aextnmod.hpx_enabled);
    }
}

static int audio_extn_hpx_get_parameters(struct str_parms *query,
                                       struct str_parms *reply)
{
    int ret;
    char value[32]={0};

    ALOGV("%s: hpx %d", __func__, aextnmod.hpx_enabled);
    ret = str_parms_get_str(query, AUDIO_PARAMETER_HPX, value,
                            sizeof(value));
    if (ret >= 0) {
        if (aextnmod.hpx_enabled)
            str_parms_add_str(reply, AUDIO_PARAMETER_HPX, "ON");
        else
            str_parms_add_str(reply, AUDIO_PARAMETER_HPX, "OFF");
    }
    return ret;
}

void audio_extn_check_and_set_dts_hpx_state(const struct audio_device *adev)
{
    char prop[PROPERTY_VALUE_MAX];
    property_get("use.dts_eagle", prop, "0");
    if (strncmp("true", prop, sizeof("true")))
        return;
    if (adev->offload_effects_set_hpx_state)
        adev->offload_effects_set_hpx_state(aextnmod.hpx_enabled);
}
#endif

#ifndef ANC_HEADSET_ENABLED
#define audio_extn_set_anc_parameters(adev, parms)       (0)
#else
@@ -235,30 +328,6 @@ done:
#define audio_extn_set_afe_proxy_parameters(adev, parms)  (0)
#define audio_extn_get_afe_proxy_parameters(query, reply) (0)
#else
/* Front left channel. */
#define PCM_CHANNEL_FL    1

/* Front right channel. */
#define PCM_CHANNEL_FR    2

/* Front center channel. */
#define PCM_CHANNEL_FC    3

/* Left surround channel.*/
#define PCM_CHANNEL_LS   4

/* Right surround channel.*/
#define PCM_CHANNEL_RS   5

/* Low frequency effect channel. */
#define PCM_CHANNEL_LFE  6

/* Left back channel; Rear left channel. */
#define PCM_CHANNEL_LB   8

/* Right back channel; Rear right channel. */
#define PCM_CHANNEL_RB   9

static int32_t afe_proxy_set_channel_mapping(struct audio_device *adev,
                                                     int channel_count)
{
@@ -460,8 +529,11 @@ void audio_extn_set_parameters(struct audio_device *adev,
   audio_extn_sound_trigger_set_parameters(adev, parms);
   audio_extn_listen_set_parameters(adev, parms);
   audio_extn_hfp_set_parameters(adev, parms);
   audio_extn_dts_eagle_set_parameters(adev, parms);
   audio_extn_ddp_set_parameters(adev, parms);
   audio_extn_ds2_set_parameters(adev, parms);
   audio_extn_customstereo_set_parameters(adev, parms);
   audio_extn_hpx_set_parameters(adev, parms);
}

void audio_extn_get_parameters(const struct audio_device *adev,
@@ -472,6 +544,8 @@ void audio_extn_get_parameters(const struct audio_device *adev,
    audio_extn_get_afe_proxy_parameters(query, reply);
    audio_extn_get_fluence_parameters(adev, query, reply);
    get_active_offload_usecases(adev, query, reply);
    audio_extn_dts_eagle_get_parameters(adev, query, reply);
    audio_extn_hpx_get_parameters(query, reply);

    kv_pairs = str_parms_to_str(reply);
    ALOGD_IF(kv_pairs != NULL, "%s: returns %s", __func__, kv_pairs);
@@ -505,3 +579,68 @@ int32_t audio_extn_read_xml(struct audio_device *adev, uint32_t mixer_card,
    return 0;
}
#endif /* AUXPCM_BT_ENABLED */

#ifdef KPI_OPTIMIZE_ENABLED
typedef int (*perf_lock_acquire_t)(int, int, int*, int);
typedef int (*perf_lock_release_t)(int);

static void *qcopt_handle;
static perf_lock_acquire_t perf_lock_acq;
static perf_lock_release_t perf_lock_rel;

static int perf_lock_handle;
char opt_lib_path[512] = {0};
int perf_lock_opts[1] = {0x20E};

int audio_extn_perf_lock_init(void)
{
    int ret = 0;
    if (qcopt_handle == NULL) {
        if (property_get("ro.vendor.extension_library",
                         opt_lib_path, NULL) <= 0) {
            ALOGE("%s: Failed getting perf property \n", __func__);
            ret = -EINVAL;
            goto err;
        }
        if ((qcopt_handle = dlopen(opt_lib_path, RTLD_NOW)) == NULL) {
            ALOGE("%s: Failed to open perf handle \n", __func__);
            ret = -EINVAL;
            goto err;
        } else {
            perf_lock_acq = (perf_lock_acquire_t)dlsym(qcopt_handle,
                                                       "perf_lock_acq");
            if (perf_lock_acq == NULL) {
                ALOGE("%s: Perf lock Acquire NULL \n", __func__);
                ret = -EINVAL;
                goto err;
            }
            perf_lock_rel = (perf_lock_release_t)dlsym(qcopt_handle,
                                                       "perf_lock_rel");
            if (perf_lock_rel == NULL) {
                ALOGE("%s: Perf lock Release NULL \n", __func__);
                ret = -EINVAL;
                goto err;
            }
            ALOGE("%s: Perf lock handles Success \n", __func__);
        }
    }
err:
    return ret;
}

void audio_extn_perf_lock_acquire(void)
{
    if (perf_lock_acq)
        perf_lock_handle = perf_lock_acq(perf_lock_handle, 0, perf_lock_opts, 1);
    else
        ALOGE("%s: Perf lock acquire error \n", __func__);
}

void audio_extn_perf_lock_release(void)
{
    if (perf_lock_rel && perf_lock_handle)
        perf_lock_rel(perf_lock_handle);
    else
        ALOGE("%s: Perf lock release error \n", __func__);
}
#endif /* KPI_OPTIMIZE_ENABLED */
Loading