Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 33bd01ba authored by vivek mehta's avatar vivek mehta Committed by android-build-merger
Browse files

Merge "hal: add sidetone support for USB" into oc-dr1-dev

am: 3a280826

Change-Id: I137f39de09a49b6d49e1077a7ab31c721d197b2e
parents ec9e2c79 3a280826
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -80,6 +80,10 @@ ifeq ($(strip $(AUDIO_FEATURE_ENABLED_USB_TUNNEL)),true)
    LOCAL_SRC_FILES += audio_extn/usb.c
endif

ifeq ($(strip $(AUDIO_FEATURE_ENABLED_USB_SIDETONE_VOLUME)),true)
    LOCAL_CFLAGS += -DUSB_SIDETONE_VOLUME
endif

LOCAL_SHARED_LIBRARIES := \
	libaudioutils \
	liblog \
+6 −1
Original line number Diff line number Diff line
@@ -505,9 +505,12 @@ static void usb_get_sidetone_mixer(struct usb_card_config *usb_card_info)
            usb_card_info->usb_sidetone_index[USB_SIDETONE_ENABLE_INDEX] = index;
            /* Disable device sidetone by default */
            mixer_ctl_set_value(ctl, 0, false);
            ALOGV("%s:: sidetone mixer Control found(%s) ... disabling by default",
                   __func__, usb_sidetone_enable_str[index]);
            break;
        }
    }
#ifdef USB_SIDETONE_VOLUME
    for (index = 0;
         index < sizeof(usb_sidetone_volume_str)/sizeof(usb_sidetone_volume_str[0]);
         index++) {
@@ -520,7 +523,7 @@ static void usb_get_sidetone_mixer(struct usb_card_config *usb_card_info)
            break;
        }
    }

#endif // USB_SIDETONE_VOLUME
    if ((usb_card_info->usb_snd_mixer != NULL) && (usb_audio_debug_enable))
        usb_soundcard_list_controls(usb_card_info->usb_snd_mixer);

@@ -848,6 +851,7 @@ int audio_extn_usb_enable_sidetone(int device, bool enable)
                else
                    break;

#ifdef USB_SIDETONE_VOLUME
                if ((i = card_info->usb_sidetone_index[USB_SIDETONE_VOLUME_INDEX]) != -1) {
                    ctl = mixer_get_ctl_by_name(
                                card_info->usb_snd_mixer,
@@ -859,6 +863,7 @@ int audio_extn_usb_enable_sidetone(int device, bool enable)
                        mixer_ctl_set_value(ctl, 0,
                                            usb_get_sidetone_gain(card_info));
                }
#endif // USB_SIDETONE_VOLUME
                ret = 0;
                break;
            }
+22 −0
Original line number Diff line number Diff line
@@ -2335,3 +2335,25 @@ int platform_get_app_type_v2(void *platform __unused,
    return -ENOSYS;
}

int platform_set_sidetone(struct audio_device *adev,
                          snd_device_t out_snd_device,
                          bool enable, char *str)
{
    int ret;
    if (out_snd_device == SND_DEVICE_OUT_USB_HEADSET ||
        out_snd_device == SND_DEVICE_OUT_VOICE_USB_HEADSET) {
            ret = audio_extn_usb_enable_sidetone(out_snd_device, enable);
            if (ret)
                ALOGI("%s: usb device %d does not support device sidetone\n",
                  __func__, out_snd_device);
    } else {
        ALOGV("%s: sidetone out device(%d) mixer cmd = %s\n",
              __func__, out_snd_device, str);

        if (enable)
            audio_route_apply_and_update_path(adev->audio_route, str);
        else
            audio_route_reset_and_update_path(adev->audio_route, str);
    }
    return 0;
}
+22 −0
Original line number Diff line number Diff line
@@ -1169,3 +1169,25 @@ int platform_get_app_type_v2(void *platform __unused,
int platform_get_snd_device_backend_index(snd_device_t snd_device) {
    return -ENOSYS;
}

int platform_set_sidetone(struct audio_device *adev,
                          snd_device_t out_snd_device,
                          bool enable, char *str)
{
    int ret;
    if (out_snd_device == SND_DEVICE_OUT_USB_HEADSET ||
        out_snd_device == SND_DEVICE_OUT_VOICE_USB_HEADSET) {
            ret = audio_extn_usb_enable_sidetone(out_snd_device, enable);
            if (ret)
                ALOGI("%s: usb device %d does not support device sidetone\n",
                  __func__, out_snd_device);
    } else {
        ALOGV("%s: sidetone out device(%d) mixer cmd = %s\n",
              __func__, out_snd_device, str);
        if (enable)
            audio_route_apply_and_update_path(adev->audio_route, str);
        else
            audio_route_reset_and_update_path(adev->audio_route, str);
    }
    return 0;
}
+24 −0
Original line number Diff line number Diff line
@@ -3028,6 +3028,8 @@ int platform_set_parameters(void *platform, struct str_parms *parms)
        ALOGV("%s: max_mic_count %s/%d", __func__, value, my_data->max_mic_count);
    }

    // to-do: disable setting sidetone gain, will revist this later
    // audio_extn_usb_set_sidetone_gain(parms, value, len);
done:
    ALOGV("%s: exit with code(%d)", __func__, ret);
    if (kv_pairs != NULL)
@@ -4013,3 +4015,25 @@ int platform_get_app_type_v2(void *platform,
    }
    return 0;
}

int platform_set_sidetone(struct audio_device *adev,
                          snd_device_t out_snd_device,
                          bool enable, char *str)
{
    int ret;
    if (out_snd_device == SND_DEVICE_OUT_USB_HEADSET ||
        out_snd_device == SND_DEVICE_OUT_VOICE_USB_HEADSET) {
            ret = audio_extn_usb_enable_sidetone(out_snd_device, enable);
            if (ret)
                ALOGI("%s: usb device %d does not support device sidetone\n",
                  __func__, out_snd_device);
    } else {
        ALOGV("%s: sidetone out device(%d) mixer cmd = %s\n",
              __func__, out_snd_device, str);
        if (enable)
            audio_route_apply_and_update_path(adev->audio_route, str);
        else
            audio_route_reset_and_update_path(adev->audio_route, str);
    }
    return 0;
}
Loading