Skip to content

Commit

Permalink
Merge "configs: sdm845: Add support for suspend mixer ctls"
Browse files Browse the repository at this point in the history
  • Loading branch information
lnxbuild authored and Gerrit - the friendly Code Review server committed Aug 11, 2017
2 parents 84c562c + 45a58f7 commit 032ed25
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 0 deletions.
8 changes: 8 additions & 0 deletions configs/sdm845/mixer_paths_i2s.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@
<ctl name="RT_PROXY_1_TX SetCalMode" value="CAL_MODE_NONE" />
<!-- RT Proxy Cal end -->

<!-- mixer control to disable lowlatency qos voting -->
<ctl name="MultiMedia5_RX QOS Vote" value="Disable" />
<!-- mixer control to disable lowlatency qos voting end -->

<!-- These are audio route (FE to BE) specific mixer settings -->
<path name="deep-buffer-playback">
<ctl name="AUX_PCM_RX Audio Mixer MultiMedia1" value="1" />
Expand All @@ -82,6 +86,10 @@
<ctl name="AUX_PCM_RX Audio Mixer MultiMedia5" value="1" />
</path>

<path name="low-latency-playback resume">
<ctl name="MultiMedia5_RX QOS Vote" value="Enable" />
</path>

<path name="compress-offload-playback">
<ctl name="AUX_PCM_RX Audio Mixer MultiMedia4" value="1" />
</path>
Expand Down
8 changes: 8 additions & 0 deletions configs/sdm845/mixer_paths_skuk.xml
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,10 @@

<!-- Codec controls end -->

<!-- mixer control to disable lowlatency qos voting -->
<ctl name="MultiMedia5_RX QOS Vote" value="Disable" />
<!-- mixer control to disable lowlatency qos voting end -->

<!-- These are audio route (FE to BE) specific mixer settings -->
<path name="gsm-mode">
<ctl name="GSM mode Enable" value="ON" />
Expand Down Expand Up @@ -627,6 +631,10 @@
<path name="low-latency-playback" />
</path>

<path name="low-latency-playback resume">
<ctl name="MultiMedia5_RX QOS Vote" value="Enable" />
</path>

<path name="audio-ull-playback">
<ctl name="SLIMBUS_0_RX Audio Mixer MultiMedia8" value="1" />
</path>
Expand Down
8 changes: 8 additions & 0 deletions configs/sdm845/mixer_paths_tavil.xml
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,10 @@

<!-- Codec controls end -->

<!-- mixer control to disable lowlatency qos voting -->
<ctl name="MultiMedia5_RX QOS Vote" value="Disable" />
<!-- mixer control to disable lowlatency qos voting end -->

<!-- These are audio route (FE to BE) specific mixer settings -->
<path name="gsm-mode">
<ctl name="GSM mode Enable" value="ON" />
Expand Down Expand Up @@ -636,6 +640,10 @@
<path name="low-latency-playback" />
</path>

<path name="low-latency-playback resume">
<ctl name="MultiMedia5_RX QOS Vote" value="Enable" />
</path>

<path name="audio-ull-playback">
<ctl name="SLIMBUS_0_RX Audio Mixer MultiMedia8" value="1" />
</path>
Expand Down
54 changes: 54 additions & 0 deletions hal/audio_hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -3158,6 +3158,37 @@ static int out_set_parameters(struct audio_stream *stream, const char *kvpairs)
pthread_mutex_unlock(&out->lock);
}

//suspend, resume handling block
if (out->dynamic_pm_qos_enabled) {
//check suspend parameter only for low latency and if the property
//is enabled
if (str_parms_get_str(parms, "suspend_playback", value, sizeof(value)) >= 0) {
ALOGI("%s: got suspend_playback %s", __func__, value);
lock_output_stream(out);
if (!strncmp(value, "false", 5)) {
//suspend_playback=false is supposed to set QOS value back to 75%
//the mixer control sent with value Enable will achieve that
ret = audio_route_apply_and_update_path(adev->audio_route, out->pm_qos_mixer_path);
} else if (!strncmp (value, "true", 4)) {
//suspend_playback=true is supposed to remove QOS value
//resetting the mixer control will set the default value
//for the mixer control which is Disable and this removes the QOS vote
ret = audio_route_reset_and_update_path(adev->audio_route, out->pm_qos_mixer_path);
} else {
ALOGE("%s: Wrong value sent for suspend_playback, expected true/false,"
" got %s", __func__, value);
ret = -1;
}

if (ret != 0) {
ALOGE("%s: %s mixer ctl failed with %d, ignore suspend/resume setparams",
__func__, out->pm_qos_mixer_path, ret);
}

pthread_mutex_unlock(&out->lock);
}
}
//end suspend, resume handling block
str_parms_destroy(parms);
error:
ALOGV("%s: exit: code(%d)", __func__, ret);
Expand Down Expand Up @@ -3277,6 +3308,16 @@ static char* out_get_parameters(const struct audio_stream *stream, const char *k
str = str_parms_to_str(reply);
}

if (str_parms_get_str(query, "supports_hw_suspend", value, sizeof(value)) >= 0) {
//only low latency track supports suspend_resume
str_parms_add_int(reply, "supports_hw_suspend",
(out->dynamic_pm_qos_enabled));
if (str)
free(str);
str = str_parms_to_str(reply);
}


str_parms_destroy(query);
str_parms_destroy(reply);
ALOGV("%s: exit: returns - %s", __func__, str);
Expand Down Expand Up @@ -4394,6 +4435,7 @@ int adev_open_output_stream(struct audio_hw_device *dev,
out->convert_buffer = NULL;
out->started = 0;
out->a2dp_compress_mute = false;
out->dynamic_pm_qos_enabled = 0;

if (out->devices & AUDIO_DEVICE_OUT_AUX_DIGITAL &&
(flags & AUDIO_OUTPUT_FLAG_DIRECT)) {
Expand Down Expand Up @@ -4737,6 +4779,18 @@ int adev_open_output_stream(struct audio_hw_device *dev,
out->config = out->realtime ? pcm_config_rt : pcm_config_low_latency;
} else if (out->flags & AUDIO_OUTPUT_FLAG_FAST) {
out->usecase = USECASE_AUDIO_PLAYBACK_LOW_LATENCY;
out->dynamic_pm_qos_enabled = property_get_bool("vendor.audio.dynamic.qos.enable", false);
if (!out->dynamic_pm_qos_enabled) {
ALOGI("%s: dynamic qos voting not enabled for platform", __func__);
} else {
ALOGI("%s: dynamic qos voting enabled for platform", __func__);
//the mixer path will be a string similar to "low-latency-playback resume"
strlcpy(out->pm_qos_mixer_path, use_case_table[out->usecase], MAX_MIXER_PATH_LEN);
strlcat(out->pm_qos_mixer_path,
" resume", MAX_MIXER_PATH_LEN);
ALOGI("%s: created %s pm_qos_mixer_path" , __func__,
out->pm_qos_mixer_path);
}
out->config = pcm_config_low_latency;
} else if (out->flags & AUDIO_OUTPUT_FLAG_DEEP_BUFFER) {
out->usecase = USECASE_AUDIO_PLAYBACK_DEEP_BUFFER;
Expand Down
5 changes: 5 additions & 0 deletions hal/audio_hw.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@

#define MAX_STREAM_PROFILE_STR_LEN 32

#define MAX_MIXER_PATH_LEN 64

typedef enum card_status_t {
CARD_STATUS_OFFLINE,
CARD_STATUS_ONLINE
Expand Down Expand Up @@ -305,6 +307,9 @@ struct stream_out {
bool a2dp_compress_mute;
float volume_l;
float volume_r;

char pm_qos_mixer_path[MAX_MIXER_PATH_LEN];
int dynamic_pm_qos_enabled;
};

struct stream_in {
Expand Down

0 comments on commit 032ed25

Please sign in to comment.