Merge "hal: add support for device mute"

This commit is contained in:
Linux Build Service Account 2014-03-14 07:44:12 -07:00 committed by Gerrit - the friendly Code Review server
commit e8cd776b58
5 changed files with 114 additions and 2 deletions

View File

@ -1017,6 +1017,44 @@ int platform_set_mic_mute(void *platform, bool state)
return ret;
}
int platform_set_device_mute(void *platform, bool state, char *dir)
{
struct platform_data *my_data = (struct platform_data *)platform;
struct audio_device *adev = my_data->adev;
struct mixer_ctl *ctl;
char *mixer_ctl_name = NULL;
int ret = 0;
uint32_t set_values[ ] = {0,
ALL_SESSION_VSID,
0};
if(dir == NULL) {
ALOGE("%s: Invalid direction:%s", __func__, dir);
return -EINVAL;
}
if (!strncmp("rx", dir, sizeof("rx"))) {
mixer_ctl_name = "Voice Rx Device Mute";
} else if (!strncmp("tx", dir, sizeof("tx"))) {
mixer_ctl_name = "Voice Tx Device Mute";
} else {
return -EINVAL;
}
set_values[0] = state;
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("%s: Setting device mute state: %d, mixer ctrl:%s",
__func__,state, mixer_ctl_name);
mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values));
return ret;
}
snd_device_t platform_get_output_snd_device(void *platform, audio_devices_t devices)
{
struct platform_data *my_data = (struct platform_data *)platform;

View File

@ -561,6 +561,12 @@ int platform_set_mic_mute(void *platform, bool state)
return ret;
}
int platform_set_device_mute(void *platform, bool state, char *dir)
{
LOGE("%s: Not implemented", __func__);
return -ENOSYS;
}
snd_device_t platform_get_output_snd_device(void *platform, audio_devices_t devices)
{
struct platform_data *my_data = (struct platform_data *)platform;

View File

@ -1092,6 +1092,44 @@ int platform_set_mic_mute(void *platform, bool state)
return ret;
}
int platform_set_device_mute(void *platform, bool state, char *dir)
{
struct platform_data *my_data = (struct platform_data *)platform;
struct audio_device *adev = my_data->adev;
struct mixer_ctl *ctl;
char *mixer_ctl_name = NULL;
int ret = 0;
uint32_t set_values[ ] = {0,
ALL_SESSION_VSID,
0};
if(dir == NULL) {
ALOGE("%s: Invalid direction:%s", __func__, dir);
return -EINVAL;
}
if (!strncmp("rx", dir, sizeof("rx"))) {
mixer_ctl_name = "Voice Rx Device Mute";
} else if (!strncmp("tx", dir, sizeof("tx"))) {
mixer_ctl_name = "Voice Tx Device Mute";
} else {
return -EINVAL;
}
set_values[0] = state;
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("%s: Setting device mute state: %d, mixer ctrl:%s",
__func__,state, mixer_ctl_name);
mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values));
return ret;
}
snd_device_t platform_get_output_snd_device(void *platform, audio_devices_t devices)
{
struct platform_data *my_data = (struct platform_data *)platform;

View File

@ -45,6 +45,7 @@ int platform_stop_voice_call(void *platform, uint32_t vsid);
int platform_set_voice_volume(void *platform, int volume);
int platform_set_mic_mute(void *platform, bool state);
int platform_get_sample_rate(void *platform, uint32_t *rate);
int platform_set_device_mute(void *platform, bool state, char *dir);
snd_device_t platform_get_output_snd_device(void *platform, audio_devices_t devices);
snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_device);
int platform_set_hdmi_channels(void *platform, int channel_count);

View File

@ -38,6 +38,8 @@
#define AUDIO_PARAMETER_KEY_CALL_STATE "call_state"
#define AUDIO_PARAMETER_KEY_AUDIO_MODE "audio_mode"
#define AUDIO_PARAMETER_KEY_ALL_CALL_STATES "all_call_states"
#define AUDIO_PARAMETER_KEY_DEVICE_MUTE "device_mute"
#define AUDIO_PARAMETER_KEY_DIRECTION "direction"
#define VOICE_EXTN_PARAMETER_VALUE_MAX_LEN 256
@ -440,6 +442,7 @@ int voice_extn_set_parameters(struct audio_device *adev,
int value;
int ret = 0, err;
char *kv_pairs = str_parms_to_str(parms);
char str_value[256] = {0};
ALOGV_IF(kv_pairs != NULL, "%s: enter: %s", __func__, kv_pairs);
@ -465,8 +468,34 @@ int voice_extn_set_parameters(struct audio_device *adev,
ret = -EINVAL;
goto done;
}
} else {
ALOGV("%s: Not handled here", __func__);
}
err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_DEVICE_MUTE, str_value,
sizeof(str_value));
if (err >= 0) {
str_parms_del(parms, AUDIO_PARAMETER_KEY_DEVICE_MUTE);
bool mute = false;
if (!strncmp("true", str_value, sizeof("true"))) {
mute = true;
}
err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_DIRECTION, str_value,
sizeof(str_value));
if (err >= 0) {
str_parms_del(parms, AUDIO_PARAMETER_KEY_DIRECTION);
} else {
ALOGE("%s: direction key not found", __func__);
ret = -EINVAL;
goto done;
}
ret = platform_set_device_mute(adev->platform, mute, str_value);
if (ret != 0) {
ALOGE("%s: Failed to set mute err:%d", __func__, ret);
ret = -EINVAL;
goto done;
}
}
done: