summaryrefslogtreecommitdiffstats
path: root/hal
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2019-04-24 05:01:40 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2019-04-24 05:01:40 -0700
commitd5d099650aa7c73baee7cf8fcbfc6f43b3b50035 (patch)
treeeeebbecfff431e183fa52f71d56fee5f9da55672 /hal
parentb3a38e0e560b4ce6fc51de01009627676bf8c90d (diff)
parent988a66d841b6c712bbe0c6e3e1f5cca6d2635dce (diff)
downloadhardware_qcom_audio-d5d099650aa7c73baee7cf8fcbfc6f43b3b50035.tar.gz
hardware_qcom_audio-d5d099650aa7c73baee7cf8fcbfc6f43b3b50035.tar.bz2
hardware_qcom_audio-d5d099650aa7c73baee7cf8fcbfc6f43b3b50035.zip
Merge "hal: Add changes to send pspd coefficients during out_write"
Diffstat (limited to 'hal')
-rw-r--r--hal/audio_extn/audio_extn.c61
-rw-r--r--hal/audio_hw.c37
-rw-r--r--[-rwxr-xr-x]hal/audio_hw.h2
-rw-r--r--hal/msm8974/platform.c2
4 files changed, 86 insertions, 16 deletions
diff --git a/hal/audio_extn/audio_extn.c b/hal/audio_extn/audio_extn.c
index 9ecbd68a..def3b503 100644
--- a/hal/audio_extn/audio_extn.c
+++ b/hal/audio_extn/audio_extn.c
@@ -393,27 +393,56 @@ static int update_custom_mtmx_coefficients(struct audio_device *adev,
char mixer_ctl_name[128] = {0};
struct audio_custom_mtmx_params_info *pinfo = &params->info;
int i = 0, err = 0;
+ int cust_ch_mixer_cfg[128], len = 0;
ALOGI("%s: ip_channels %d, op_channels %d, pcm_device_id %d",
__func__, pinfo->ip_channels, pinfo->op_channels, pcm_device_id);
- for (i = 0; i < (int)pinfo->op_channels; i++) {
- snprintf(mixer_ctl_name, sizeof(mixer_ctl_name), "%s %d %s %d",
- mixer_name_prefix, pcm_device_id, mixer_name_suffix, i+1);
- ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
- if (!ctl) {
- ALOGE("%s: ERROR. Could not get ctl for mixer cmd - %s",
- __func__, mixer_ctl_name);
- return -EINVAL;
- }
+ if (adev->use_old_pspd_mix_ctrl) {
+ /*
+ * Below code is to ensure backward compatibilty with older
+ * kernel version. Use old mixer control to set mixer coefficients
+ */
+ snprintf(mixer_ctl_name, sizeof(mixer_ctl_name),
+ "Audio Stream %d Channel Mix Cfg", pcm_device_id);
- err = mixer_ctl_set_array(ctl,
- &params->coeffs[pinfo->ip_channels * i],
- pinfo->ip_channels);
- if (err) {
- ALOGE("%s: ERROR. Mixer ctl set failed", __func__);
- return -EINVAL;
- }
+ ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
+ if (!ctl) {
+ ALOGE("%s: ERROR. Could not get ctl for mixer cmd - %s",
+ __func__, mixer_ctl_name);
+ return -EINVAL;
+ }
+ cust_ch_mixer_cfg[len++] = pinfo->ip_channels;
+ cust_ch_mixer_cfg[len++] = pinfo->op_channels;
+ for (i = 0; i < (int) (pinfo->op_channels * pinfo->ip_channels); i++) {
+ ALOGV("%s: coeff[%d] %d", __func__, i, params->coeffs[i]);
+ cust_ch_mixer_cfg[len++] = params->coeffs[i];
+ }
+ err = mixer_ctl_set_array(ctl, cust_ch_mixer_cfg, len);
+ if (err) {
+ ALOGE("%s: ERROR. Mixer ctl set failed", __func__);
+ return -EINVAL;
+ }
+ ALOGD("%s: Mixer ctl set for %s success", __func__, mixer_ctl_name);
+ } else {
+ for (i = 0; i < (int)pinfo->op_channels; i++) {
+ snprintf(mixer_ctl_name, sizeof(mixer_ctl_name), "%s %d %s %d",
+ mixer_name_prefix, pcm_device_id, mixer_name_suffix, i+1);
+
+ ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
+ if (!ctl) {
+ ALOGE("%s: ERROR. Could not get ctl for mixer cmd - %s",
+ __func__, mixer_ctl_name);
+ return -EINVAL;
+ }
+ err = mixer_ctl_set_array(ctl,
+ &params->coeffs[pinfo->ip_channels * i],
+ pinfo->ip_channels);
+ if (err) {
+ ALOGE("%s: ERROR. Mixer ctl set failed", __func__);
+ return -EINVAL;
+ }
+ }
}
return 0;
}
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 8f27e864..1638a229 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -1042,6 +1042,8 @@ int disable_audio_route(struct audio_device *adev,
audio_extn_sound_trigger_update_stream_status(usecase, ST_EVENT_STREAM_FREE);
audio_extn_listen_update_stream_status(usecase, LISTEN_EVENT_STREAM_FREE);
audio_extn_set_custom_mtmx_params(adev, usecase, false);
+ if (usecase->stream.out != NULL)
+ usecase->stream.out->pspd_coeff_sent = false;
ALOGV("%s: exit", __func__);
return 0;
}
@@ -4592,6 +4594,7 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer,
int channels = 0;
const size_t frame_size = audio_stream_out_frame_size(stream);
const size_t frames = (frame_size != 0) ? bytes / frame_size : bytes;
+ struct audio_usecase *usecase = NULL;
ATRACE_BEGIN("out_write");
lock_output_stream(out);
@@ -4713,6 +4716,20 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer,
adev->is_channel_status_set = true;
}
+ if ((adev->use_old_pspd_mix_ctrl == true) &&
+ (out->pspd_coeff_sent == false)) {
+ /*
+ * Need to resend pspd coefficients after stream started for
+ * older kernel version as it does not save the coefficients
+ * and also stream has to be started for coeff to apply.
+ */
+ usecase = get_usecase_from_list(adev, out->usecase);
+ if (usecase != NULL) {
+ audio_extn_set_custom_mtmx_params(adev, usecase, true);
+ out->pspd_coeff_sent = true;
+ }
+ }
+
if (is_offload_usecase(out->usecase)) {
ALOGVV("copl(%p): writing buffer (%zu bytes) to compress device", out, bytes);
if (out->send_new_metadata) {
@@ -6117,6 +6134,7 @@ int adev_open_output_stream(struct audio_hw_device *dev,
out->dynamic_pm_qos_config_supported = 0;
out->set_dual_mono = false;
out->prev_card_status_offline = false;
+ out->pspd_coeff_sent = false;
if ((flags & AUDIO_OUTPUT_FLAG_BD) &&
(property_get_bool("vendor.audio.matrix.limiter.enable", false)))
@@ -7824,6 +7842,8 @@ static int adev_open(const hw_module_t *module, const char *name,
hw_device_t **device)
{
int ret;
+ char mixer_ctl_name[128] = {0};
+ struct mixer_ctl *ctl = NULL;
ALOGD("%s: enter", __func__);
if (strcmp(name, AUDIO_HARDWARE_INTERFACE) != 0) return -EINVAL;
@@ -7899,6 +7919,7 @@ static int adev_open(const hw_module_t *module, const char *name,
adev->perf_lock_opts[1] = 0x20E;
adev->perf_lock_opts_size = 2;
adev->dsp_bit_width_enforce_mode = 0;
+ adev->use_old_pspd_mix_ctrl = false;
/* Loads platform specific libraries dynamically */
adev->platform = platform_init(adev);
@@ -8086,6 +8107,22 @@ static int adev_open(const hw_module_t *module, const char *name,
if (adev->device_cfg_params == NULL)
ALOGE("%s: Memory allocation failed for Device config params", __func__);
+ /*
+ * Check if new PSPD matrix mixer control is supported. If not
+ * supported, then set flag so that old mixer ctrl is sent while
+ * sending pspd coefficients on older kernel version. Query mixer
+ * control for default pcm id and channel value one.
+ */
+ snprintf(mixer_ctl_name, sizeof(mixer_ctl_name),
+ "AudStr %d ChMixer Weight Ch %d", 0, 1);
+
+ ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
+ if (!ctl) {
+ ALOGE("%s: ERROR. Could not get ctl for mixer cmd - %s",
+ __func__, mixer_ctl_name);
+ adev->use_old_pspd_mix_ctrl = true;
+ }
+
ALOGV("%s: exit", __func__);
return 0;
}
diff --git a/hal/audio_hw.h b/hal/audio_hw.h
index 003690a8..9e2b6fc4 100755..100644
--- a/hal/audio_hw.h
+++ b/hal/audio_hw.h
@@ -356,6 +356,7 @@ struct stream_out {
mix_matrix_params_t downmix_params;
bool set_dual_mono;
bool prev_card_status_offline;
+ bool pspd_coeff_sent;
};
struct stream_in {
@@ -539,6 +540,7 @@ struct audio_device {
unsigned int interactive_usecase_state;
bool dp_allowed_for_voice;
void *ext_hw_plugin;
+ bool use_old_pspd_mix_ctrl;
};
int select_devices(struct audio_device *adev,
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 948703f3..2ac38526 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -2544,6 +2544,8 @@ acdb_init_fail:
strdup("SLIM_0_RX Format");
my_data->current_backend_cfg[DEFAULT_CODEC_BACKEND].samplerate_mixer_ctl =
strdup("SLIM_0_RX SampleRate");
+ my_data->current_backend_cfg[DEFAULT_CODEC_BACKEND].channels_mixer_ctl =
+ strdup("SLIM_0_RX Channels");
my_data->current_backend_cfg[DSD_NATIVE_BACKEND].bitwidth_mixer_ctl =
strdup("SLIM_2_RX Format");