hal: Backend port specific channel mapping for afe-loopback
- Add support for Backend port specific channel map for afe-loopback usecase. Change-Id: I7a246a97d5ca38e084e4675563bb283d839ac0fe
This commit is contained in:
parent
3acae22b3b
commit
3e6e3fd337
|
@ -621,12 +621,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) {
|
||||
|
@ -658,21 +663,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;
|
||||
|
@ -710,7 +736,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;
|
||||
|
|
|
@ -282,7 +282,8 @@ bool audio_extn_is_hifi_audio_supported(void);
|
|||
|
||||
//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
|
||||
|
|
|
@ -4342,8 +4342,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)) {
|
||||
|
@ -4363,8 +4363,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);
|
||||
}
|
||||
|
|
|
@ -4893,8 +4893,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)) {
|
||||
|
@ -4915,8 +4915,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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue