diff --git a/hal/audio_extn/audio_extn.c b/hal/audio_extn/audio_extn.c index 3a0af4e9..0783ba09 100644 --- a/hal/audio_extn/audio_extn.c +++ b/hal/audio_extn/audio_extn.c @@ -665,12 +665,17 @@ void audio_extn_set_anc_parameters(struct audio_device *adev, // END: ANC_HEADSET ------------------------------------------------------- static int32_t afe_proxy_set_channel_mapping(struct audio_device *adev, - int channel_count) + int channel_count, + snd_device_t snd_device) { - struct mixer_ctl *ctl; + struct mixer_ctl *ctl = NULL, *be_ctl = NULL; const char *mixer_ctl_name = "Playback Device Channel Map"; - long set_values[8] = {0}; - int ret; + const char *be_mixer_ctl_name = "Backend Device Channel Map"; + long set_values[FCC_8] = {0}; + long be_set_values[FCC_8 + 1] = {0}; + int ret = -1; + int be_idx = -1; + ALOGV("%s channel_count:%d",__func__, channel_count); switch (channel_count) { @@ -702,21 +707,42 @@ static int32_t afe_proxy_set_channel_mapping(struct audio_device *adev, return -EINVAL; } - ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); + be_idx = platform_get_snd_device_backend_index(snd_device); + + if (be_idx >= 0) { + be_ctl = mixer_get_ctl_by_name(adev->mixer, be_mixer_ctl_name); + if (!be_ctl) { + ALOGD("%s: Could not get ctl for mixer cmd - %s, using default control", + __func__, be_mixer_ctl_name); + ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); + } else + ctl = be_ctl; + } else + ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); + if (!ctl) { ALOGE("%s: Could not get ctl for mixer cmd - %s", __func__, mixer_ctl_name); return -EINVAL; } + ALOGV("AFE: set mapping(%ld %ld %ld %ld %ld %ld %ld %ld) for channel:%d", set_values[0], set_values[1], set_values[2], set_values[3], set_values[4], set_values[5], set_values[6], set_values[7], channel_count); - ret = mixer_ctl_set_array(ctl, set_values, channel_count); + + if (!be_ctl) + ret = mixer_ctl_set_array(ctl, set_values, channel_count); + else { + be_set_values[0] = be_idx; + memcpy(&be_set_values[1], set_values, sizeof(long) * channel_count); + ret = mixer_ctl_set_array(ctl, be_set_values, ARRAY_SIZE(be_set_values)); + } + return ret; } int32_t audio_extn_set_afe_proxy_channel_mixer(struct audio_device *adev, - int channel_count) + int channel_count, snd_device_t snd_device) { int32_t ret = 0; const char *channel_cnt_str = NULL; @@ -754,7 +780,7 @@ int32_t audio_extn_set_afe_proxy_channel_mixer(struct audio_device *adev, mixer_ctl_set_enum_by_string(ctl, channel_cnt_str); if (channel_count == 6 || channel_count == 8 || channel_count == 2) { - ret = afe_proxy_set_channel_mapping(adev, channel_count); + ret = afe_proxy_set_channel_mapping(adev, channel_count, snd_device); } else { ALOGE("%s: set unsupported channel count(%d)", __func__, channel_count); ret = -EINVAL; diff --git a/hal/audio_extn/audio_extn.h b/hal/audio_extn/audio_extn.h index a41463bb..6d2a1c44 100644 --- a/hal/audio_extn/audio_extn.h +++ b/hal/audio_extn/audio_extn.h @@ -252,7 +252,8 @@ bool audio_extn_is_wsa_enabled(); //START: AFE_PROXY_FEATURE int32_t audio_extn_set_afe_proxy_channel_mixer(struct audio_device *adev, - int channel_count); + int channel_count, + snd_device_t snd_device); int32_t audio_extn_read_afe_proxy_channel_masks(struct stream_out *out); int32_t audio_extn_get_afe_proxy_channel_count(); //END: AFE_PROXY_FEATURE diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c index f4b28dcc..01e468a8 100644 --- a/hal/msm8916/platform.c +++ b/hal/msm8916/platform.c @@ -4325,8 +4325,8 @@ snd_device_t platform_get_output_snd_device(void *platform, struct stream_out *o } else if (devices & AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET || devices & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET) { ALOGD("%s: setting USB hadset channel capability(2) for Proxy", __func__); - audio_extn_set_afe_proxy_channel_mixer(adev, 2); snd_device = SND_DEVICE_OUT_USB_HEADSET; + audio_extn_set_afe_proxy_channel_mixer(adev, 2, snd_device); } else if (devices & (AUDIO_DEVICE_OUT_USB_DEVICE | AUDIO_DEVICE_OUT_USB_HEADSET)) { @@ -4344,8 +4344,8 @@ snd_device_t platform_get_output_snd_device(void *platform, struct stream_out *o } else if (devices & AUDIO_DEVICE_OUT_PROXY) { channel_count = audio_extn_get_afe_proxy_channel_count(); ALOGD("%s: setting sink capability(%d) for Proxy", __func__, channel_count); - audio_extn_set_afe_proxy_channel_mixer(adev, channel_count); snd_device = SND_DEVICE_OUT_AFE_PROXY; + audio_extn_set_afe_proxy_channel_mixer(adev, channel_count, snd_device); } else { ALOGE("%s: Unknown device(s) %#x", __func__, devices); } diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c index 5a05f1c2..7048d6b2 100644 --- a/hal/msm8974/platform.c +++ b/hal/msm8974/platform.c @@ -5193,8 +5193,8 @@ snd_device_t platform_get_output_snd_device(void *platform, struct stream_out *o } else if (devices & AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET || devices & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET) { ALOGD("%s: setting USB hadset channel capability(2) for Proxy", __func__); - audio_extn_set_afe_proxy_channel_mixer(adev, 2); snd_device = SND_DEVICE_OUT_USB_HEADSET; + audio_extn_set_afe_proxy_channel_mixer(adev, 2, snd_device); } else if (devices & (AUDIO_DEVICE_OUT_USB_DEVICE | AUDIO_DEVICE_OUT_USB_HEADSET)) { @@ -5215,8 +5215,8 @@ snd_device_t platform_get_output_snd_device(void *platform, struct stream_out *o } else if (devices & AUDIO_DEVICE_OUT_PROXY) { channel_count = audio_extn_get_afe_proxy_channel_count(); ALOGD("%s: setting sink capability(%d) for Proxy", __func__, channel_count); - audio_extn_set_afe_proxy_channel_mixer(adev, channel_count); snd_device = SND_DEVICE_OUT_AFE_PROXY; + audio_extn_set_afe_proxy_channel_mixer(adev, channel_count, snd_device); } else { ALOGE("%s: Unknown device(s) %#x", __func__, devices); }