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

Commit c1088ea9 authored by Zhou Song's avatar Zhou Song Committed by Gerrit - the friendly Code Review server
Browse files

hal: report battery status to sound trigger hal

Report battery status to sound trigger hal which is used to
determine performance mode or low power mode for SVA.
Also report active rx device to STHAL to select equivalent
echo reference.

Change-Id: If9633fefd3319cc5121e96c238c9de04d67efe35
parent 01156f90
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -379,6 +379,7 @@ void audio_extn_listen_set_parameters(struct audio_device *adev,
#define audio_extn_sound_trigger_deinit(adev)                          (0)
#define audio_extn_sound_trigger_update_device_status(snd_dev, event)  (0)
#define audio_extn_sound_trigger_update_stream_status(uc_info, event)  (0)
#define audio_extn_sound_trigger_update_battery_status(charging)       (0)
#define audio_extn_sound_trigger_set_parameters(adev, parms)           (0)
#define audio_extn_sound_trigger_get_parameters(adev, query, reply)    (0)
#define audio_extn_sound_trigger_check_and_get_session(in)             (0)
@@ -400,6 +401,7 @@ void audio_extn_sound_trigger_update_device_status(snd_device_t snd_device,
                                     st_event_type_t event);
void audio_extn_sound_trigger_update_stream_status(struct audio_usecase *uc_info,
                                     st_event_type_t event);
void audio_extn_sound_trigger_update_battery_status(bool charging);
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);
+19 −2
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ typedef enum {
    AUDIO_EVENT_SVA_EXEC_MODE_STATUS,
    AUDIO_EVENT_CAPTURE_STREAM_INACTIVE,
    AUDIO_EVENT_CAPTURE_STREAM_ACTIVE,
    AUDIO_EVENT_BATTERY_STATUS_CHANGED,
} audio_event_type_t;

typedef enum {
@@ -500,12 +501,16 @@ void audio_extn_sound_trigger_update_stream_status(struct audio_usecase *uc_info
        __func__, uc_info->id, uc_info->type, event, raise_event);
    if (raise_event) {
        if (uc_info->type == PCM_PLAYBACK) {
            if (uc_info->stream.out)
                ev_info.device_info.device = uc_info->stream.out->devices;
            else
                ev_info.device_info.device = AUDIO_DEVICE_OUT_SPEAKER;
            switch(event) {
            case ST_EVENT_STREAM_FREE:
                st_dev->st_callback(AUDIO_EVENT_PLAYBACK_STREAM_INACTIVE, NULL);
                st_dev->st_callback(AUDIO_EVENT_PLAYBACK_STREAM_INACTIVE, &ev_info);
                break;
            case ST_EVENT_STREAM_BUSY:
                st_dev->st_callback(AUDIO_EVENT_PLAYBACK_STREAM_ACTIVE, NULL);
                st_dev->st_callback(AUDIO_EVENT_PLAYBACK_STREAM_ACTIVE, &ev_info);
                break;
            default:
                ALOGW("%s:invalid event %d, for usecase %d",
@@ -525,6 +530,18 @@ void audio_extn_sound_trigger_update_stream_status(struct audio_usecase *uc_info
    }
}

void audio_extn_sound_trigger_update_battery_status(bool charging)
{
    struct audio_event_info ev_info;

    if (!st_dev || st_dev->sthal_prop_api_version < STHAL_PROP_API_VERSION_1_0)
        return;

    ev_info.u.value = charging;
    st_dev->st_callback(AUDIO_EVENT_BATTERY_STATUS_CHANGED, &ev_info);
}


void audio_extn_sound_trigger_set_parameters(struct audio_device *adev __unused,
                               struct str_parms *params)
{
+3 −1
Original line number Diff line number Diff line
@@ -7394,6 +7394,7 @@ void adev_on_battery_status_changed(bool charging)
    pthread_mutex_lock(&adev->lock);
    ALOGI("%s: battery status changed to %scharging", __func__, charging ? "" : "not ");
    adev->is_charging = charging;
    audio_extn_sound_trigger_update_battery_status(charging);
    pthread_mutex_unlock(&adev->lock);
}

@@ -7649,8 +7650,9 @@ static int adev_open(const hw_module_t *module, const char *name,
     * the callback value will reflect the latest state
     */
    adev->is_charging = audio_extn_battery_properties_is_charging();
    pthread_mutex_unlock(&adev->lock);
    audio_extn_sound_trigger_init(adev); /* dependent on snd_mon_init() */
    audio_extn_sound_trigger_update_battery_status(adev->is_charging);
    pthread_mutex_unlock(&adev->lock);
    /* Allocate memory for Device config params */
    adev->device_cfg_params = (struct audio_device_config_param*)
                                  calloc(platform_get_max_codec_backend(),