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

Commit 8875bde6 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "Merge 27d5ebe7 on remote branch"

parents 610b650e 85e38e35
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -221,6 +221,7 @@ void audio_extn_listen_set_parameters(struct audio_device *adev,
#define audio_extn_sound_trigger_set_parameters(adev, parms)           (0)
#define audio_extn_sound_trigger_check_and_get_session(in)             (0)
#define audio_extn_sound_trigger_stop_lab(in)                          (0)
#define audio_extn_sound_trigger_read(in, buffer, bytes)               (0)
#else

enum st_event_type {
@@ -241,6 +242,8 @@ void audio_extn_sound_trigger_set_parameters(struct audio_device *adev,
                                             struct str_parms *parms);
void audio_extn_sound_trigger_check_and_get_session(struct stream_in *in);
void audio_extn_sound_trigger_stop_lab(struct stream_in *in);
int audio_extn_sound_trigger_read(struct stream_in *in, void *buffer,
                                  size_t bytes);
#endif

#ifndef AUXPCM_BT_ENABLED
+41 −1
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@
/* #define LOG_NDEBUG 0 */
#define LOG_NDDEBUG 0

#include <errno.h>
#include <stdbool.h>
#include <stdlib.h>
#include <dlfcn.h>
@@ -64,7 +65,7 @@ get_sound_trigger_info(int capture_handle)
{
    struct sound_trigger_info  *st_ses_info = NULL;
    struct listnode *node;
    ALOGD("%s: list %d capture_handle %d", __func__,
    ALOGV("%s: list empty %d capture_handle %d", __func__,
           list_empty(&st_dev->st_ses_list), capture_handle);
    list_for_each(node, &st_dev->st_ses_list) {
        st_ses_info = node_to_item(node, struct sound_trigger_info , list);
@@ -128,6 +129,45 @@ int audio_hw_call_back(sound_trigger_event_type_t event,
    return status;
}

int audio_extn_sound_trigger_read(struct stream_in *in, void *buffer,
                       size_t bytes)
{
    int ret = -1;
    struct sound_trigger_info  *st_info = NULL;
    audio_event_info_t event;

    if (!st_dev)
       return ret;

    if (!in->is_st_session_active) {
        ALOGE(" %s: Sound trigger is not active", __func__);
        goto exit;
    }
    if(in->standby)
        in->standby = false;

    pthread_mutex_lock(&st_dev->lock);
    st_info = get_sound_trigger_info(in->capture_handle);
    pthread_mutex_unlock(&st_dev->lock);
    if (st_info) {
        event.u.aud_info.ses_info = &st_info->st_ses;
        event.u.aud_info.buf = buffer;
        event.u.aud_info.num_bytes = bytes;
        ret = st_dev->st_callback(AUDIO_EVENT_READ_SAMPLES, &event);
    }

exit:
    if (ret) {
        if (-ENETRESET == ret)
            in->is_st_session_active = false;
        memset(buffer, 0, bytes);
        ALOGV("%s: read failed status %d - sleep", __func__, ret);
        usleep((bytes * 1000000) / (audio_stream_in_frame_size((struct audio_stream_in *)in) *
                                   in->config.rate));
    }
    return ret;
}

void audio_extn_sound_trigger_stop_lab(struct stream_in *in)
{
    int status = 0;
+1 −1
Original line number Diff line number Diff line
@@ -214,7 +214,7 @@ int get_tzn(const char *sensor_name)
            snprintf(name, MAX_PATH, TZ_TYPE, tzn);
            ALOGD("Opening %s\n", name);
            read_line_from_file(name, buf, sizeof(buf));
            buf[strlen(sensor_name)] = '\0';
            buf[strlen(buf)] = '\0';
            if (!strcmp(buf, sensor_name)) {
                found = 1;
                break;
+24 −35
Original line number Diff line number Diff line
@@ -870,7 +870,6 @@ int select_devices(struct audio_device *adev, audio_usecase_t uc_id)
                                            usecase->stream.out);
                if (usecase->stream.out == adev->primary_output &&
                        adev->active_input &&
                        adev->active_input->source == AUDIO_SOURCE_VOICE_COMMUNICATION &&
                        out_snd_device != usecase->out_snd_device) {
                    select_devices(adev, adev->active_input->usecase);
                }
@@ -2610,22 +2609,21 @@ static ssize_t in_read(struct audio_stream_in *stream, void *buffer,

    pthread_mutex_lock(&in->lock);

    if (in->pcm) {
        if(SND_CARD_STATE_OFFLINE == snd_scard_state) {
    if (in->is_st_session) {
        ALOGVV(" %s: reading on st session bytes=%zu", __func__, bytes);
        /* Read from sound trigger HAL */
        audio_extn_sound_trigger_read(in, buffer, bytes);
        pthread_mutex_unlock(&in->lock);
        return bytes;
    }

    if (in->pcm && (SND_CARD_STATE_OFFLINE == snd_scard_state)) {
        ALOGD(" %s: sound card is not active/SSR state", __func__);
        ret= -EIO;;
        goto exit;
        } else {
            if (in->is_st_session &&  !in->is_st_session_active) {
                ALOGD(" %s: Sound trigger is not active/SSR", __func__);
                ret= -EIO;;
                goto exit;
            }
        }
    }

    if (in->standby) {
        if (!in->is_st_session) {
        pthread_mutex_lock(&adev->lock);
        if (in->usecase == USECASE_COMPRESS_VOIP_CALL)
            ret = voice_extn_compress_voip_start_input_stream(in);
@@ -2635,7 +2633,6 @@ static ssize_t in_read(struct audio_stream_in *stream, void *buffer,
        if (ret != 0) {
            goto exit;
        }
        }
        in->standby = 0;
    }

@@ -2664,17 +2661,9 @@ static ssize_t in_read(struct audio_stream_in *stream, void *buffer,
exit:
    /* ToDo: There may be a corner case when SSR happens back to back during
       start/stop. Need to post different error to handle that. */
    if (-ENETRESET == ret) {
        /* CPE SSR results in kernel returning ENETRESET for sound trigger
          session reading on LAB data. In this case do not set sound card state
          offline, instead mark this sound trigger session inactive to avoid
          further reading of LAB data from CPE driver. Marking the session
          inactive handles both CPE and ADSP SSR for sound trigger session */
        if (!in->is_st_session)
    if (-ENETRESET == ret)
        set_snd_card_state(adev,SND_CARD_STATE_OFFLINE);
        else
            in->is_st_session_active = false;
    }

    pthread_mutex_unlock(&in->lock);

    if (ret != 0) {
@@ -3394,7 +3383,7 @@ static size_t adev_get_input_buffer_size(const struct audio_hw_device *dev __unu
}

static int adev_open_input_stream(struct audio_hw_device *dev,
                                  audio_io_handle_t handle __unused,
                                  audio_io_handle_t handle,
                                  audio_devices_t devices,
                                  struct audio_config *config,
                                  struct audio_stream_in **stream_in,
+26 −3
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@
#include "sound/msmcal-hwdep.h"
#include <dirent.h>
#define SOUND_TRIGGER_DEVICE_HANDSET_MONO_LOW_POWER_ACDB_ID (100)

#define MAX_MIXER_XML_PATH  100
#define MIXER_XML_PATH "/system/etc/mixer_paths.xml"
#define MIXER_XML_PATH_MTP "/system/etc/mixer_paths_mtp.xml"
#define MIXER_XML_PATH_SBC "/system/etc/mixer_paths_sbc.xml"
@@ -58,6 +58,7 @@
#define MIXER_XML_PATH_WCD9306 "/system/etc/mixer_paths_wcd9306.xml"
#define MIXER_XML_PATH_WCD9330 "/system/etc/mixer_paths_wcd9330.xml"
#define MIXER_XML_PATH_WCD9335 "/system/etc/mixer_paths_wcd9335.xml"
#define MIXER_XML_PATH_WCD9326 "/system/etc/mixer_paths_wcd9326.xml"
#define MIXER_XML_PATH_SKUN "/system/etc/mixer_paths_qrd_skun.xml"
#define PLATFORM_INFO_XML_PATH      "/system/etc/audio_platform_info.xml"
#define PLATFORM_INFO_XML_PATH_EXTCODEC  "/system/etc/audio_platform_info_extcodec.xml"
@@ -745,6 +746,8 @@ static void update_codec_type(const char *snd_card_name) {
                  sizeof("msm8952-tomtom-snd-card")) ||
         !strncmp(snd_card_name, "msm8976-tasha-snd-card",
                  sizeof("msm8976-tasha-snd-card")) ||
         !strncmp(snd_card_name, "msm8976-tashalite-snd-card",
                  sizeof("msm8976-tashalite-snd-card")) ||
         !strncmp(snd_card_name, "msm8976-tasha-skun-snd-card",
                  sizeof("msm8976-tasha-skun-snd-card")))
     {
@@ -850,6 +853,14 @@ static void query_platform(const char *snd_card_name,
        msm_be_id_array_len  =
            sizeof(msm_device_to_be_id_external_codec) / sizeof(msm_device_to_be_id_external_codec[0]);

    } else if (!strncmp(snd_card_name, "msm8976-tashalite-snd-card",
                 sizeof("msm8976-tashalite-snd-card"))) {
        strlcpy(mixer_xml_path, MIXER_XML_PATH_WCD9326,
               MAX_MIXER_XML_PATH);
        msm_device_to_be_id = msm_device_to_be_id_external_codec;
        msm_be_id_array_len  =
            sizeof(msm_device_to_be_id_external_codec) / sizeof(msm_device_to_be_id_external_codec[0]);

    } else if (!strncmp(snd_card_name, "msm8976-tasha-skun-snd-card",
                sizeof("msm8976-tasha-skun-snd-card"))) {
        strlcpy(mixer_xml_path, MIXER_XML_PATH_SKUN,
@@ -1283,7 +1294,7 @@ void *platform_init(struct audio_device *adev)
    struct platform_data *my_data = NULL;
    int retry_num = 0, snd_card_num = 0, key = 0;
    const char *snd_card_name;
    char mixer_xml_path[100],ffspEnable[PROPERTY_VALUE_MAX];
    char mixer_xml_path[MAX_MIXER_XML_PATH],ffspEnable[PROPERTY_VALUE_MAX];
    char *cvd_version = NULL;
    const char *mixer_ctl_name = "Set HPX ActiveBe";
    struct mixer_ctl *ctl = NULL;
@@ -1799,7 +1810,7 @@ int platform_get_snd_device_bit_width(snd_device_t snd_device)
{
    if ((snd_device < SND_DEVICE_MIN) || (snd_device >= SND_DEVICE_MAX)) {
        ALOGE("%s: Invalid snd_device = %d", __func__, snd_device);
        return DEFAULT_OUTPUT_SAMPLING_RATE;
        return CODEC_BACKEND_DEFAULT_BIT_WIDTH;
    }
    return backend_bit_width_table[snd_device];
}
@@ -3566,6 +3577,8 @@ int platform_is_external_codec (char *snd_card_name)
        sizeof("msm8952-tomtom-snd-card")) ||
        !strncmp(snd_card_name, "msm8976-tasha-snd-card",
        sizeof("msm8976-tasha-snd-card")) ||
        !strncmp(snd_card_name, "msm8976-tashalite-snd-card",
        sizeof("msm8976-tashalite-snd-card")) ||
        !strncmp(snd_card_name, "msm8976-tasha-skun-snd-card",
        sizeof("msm8976-tasha-skun-snd-card")))
    {
@@ -3770,6 +3783,16 @@ bool platform_check_codec_backend_cfg(struct audio_device* adev,
            sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
        }
    }

    /*
     * Sample rate greater than 48K is only supported by external codecs on
     * specific devices e.g. Headphones, reset the sample rate to
     * default value if not external codec.
     */
    if (!is_external_codec)
        sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;


    ALOGI("%s Codec selected backend: %d updated bit width: %d and sample rate: %d",
               __func__, backend_idx, bit_width, sample_rate);
    // Force routing if the expected bitwdith or samplerate
Loading