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

Commit e4b673e7 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "hal: add usb audio tunnel support"

parents f1346ce3 8c03e67b
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -74,6 +74,11 @@ ifdef MULTIPLE_HW_VARIANTS_ENABLED
  LOCAL_SRC_FILES +=  $(AUDIO_PLATFORM)/hw_info.c
endif

ifeq ($(strip $(AUDIO_FEATURE_ENABLED_USB_TUNNEL)),true)
    LOCAL_CFLAGS += -DUSB_TUNNEL_ENABLED
    LOCAL_SRC_FILES += audio_extn/usb.c
endif

LOCAL_SHARED_LIBRARIES := \
	liblog \
	libcutils \
+25 −0
Original line number Diff line number Diff line
@@ -70,6 +70,31 @@ int audio_extn_hfp_set_mic_mute(struct audio_device *adev, bool state);

#endif

#ifndef USB_TUNNEL_ENABLED
#define audio_extn_usb_init(adev)                                      (0)
#define audio_extn_usb_deinit()                                        (0)
#define audio_extn_usb_add_device(device, card)                        (0)
#define audio_extn_usb_remove_device(device, card)                     (0)
#define audio_extn_usb_is_config_supported(bit_width, sample_rate, ch, pb) (false)
#define audio_extn_usb_enable_sidetone(device, enable)                 (0)
#define audio_extn_usb_set_sidetone_gain(parms, value, len)            (0)
#define audio_extn_usb_is_capture_supported()                          (false)
#else
void audio_extn_usb_init(void *adev);
void audio_extn_usb_deinit();
void audio_extn_usb_add_device(audio_devices_t device, int card);
void audio_extn_usb_remove_device(audio_devices_t device, int card);
bool audio_extn_usb_is_config_supported(unsigned int *bit_width,
                                        unsigned int *sample_rate,
                                        unsigned int *ch,
                                        bool is_playback);
int audio_extn_usb_enable_sidetone(int device, bool enable);
int audio_extn_usb_set_sidetone_gain(struct str_parms *parms,
                                     char *value, int len);
bool audio_extn_usb_is_capture_supported();
#endif


#ifndef SOUND_TRIGGER_ENABLED
#define audio_extn_sound_trigger_init(adev)                            (0)
#define audio_extn_sound_trigger_deinit(adev)                          (0)

hal/audio_extn/usb.c

0 → 100644
+1034 −0

File added.

Preview size limit exceeded, changes collapsed.

+41 −1
Original line number Diff line number Diff line
@@ -855,6 +855,8 @@ static void check_and_route_playback_usecases(struct audio_device *adev,
    bool switch_device[AUDIO_USECASE_MAX];
    int i, num_uc_to_switch = 0;

    platform_check_and_set_playback_backend_cfg(adev, uc_info, snd_device);

    /*
     * This function is to make sure that all the usecases that are active on
     * the hardware codec backend are always routed to any one device that is
@@ -1199,7 +1201,8 @@ int select_devices(struct audio_device *adev,

    /* Enable new sound devices */
    if (out_snd_device != SND_DEVICE_NONE) {
        if (usecase->devices & AUDIO_DEVICE_OUT_ALL_CODEC_BACKEND)
        if ((usecase->devices & AUDIO_DEVICE_OUT_ALL_CODEC_BACKEND) ||
            (usecase->devices & AUDIO_DEVICE_OUT_USB_DEVICE))
            check_and_route_playback_usecases(adev, usecase, out_snd_device);
        enable_snd_device(adev, out_snd_device);
    }
@@ -3555,6 +3558,43 @@ static int adev_set_parameters(struct audio_hw_device *dev, const char *kvpairs)
        adev->bt_wb_speech_enabled = !strcmp(value, AUDIO_PARAMETER_VALUE_ON);
    }

    ret = str_parms_get_str(parms, AUDIO_PARAMETER_DEVICE_CONNECT, value, sizeof(value));
    if (ret >= 0) {
        audio_devices_t device = (audio_devices_t)strtoul(value, NULL, 10);
        if (device == AUDIO_DEVICE_OUT_USB_DEVICE) {
            ret = str_parms_get_str(parms, "card", value, sizeof(value));
            if (ret >= 0) {
                const int card = atoi(value);
                audio_extn_usb_add_device(AUDIO_DEVICE_OUT_USB_DEVICE, card);
            }
        } else if (device == AUDIO_DEVICE_IN_USB_DEVICE) {
            ret = str_parms_get_str(parms, "card", value, sizeof(value));
            if (ret >= 0) {
                const int card = atoi(value);
                audio_extn_usb_add_device(AUDIO_DEVICE_IN_USB_DEVICE, card);
            }
        }
    }

    ret = str_parms_get_str(parms, AUDIO_PARAMETER_DEVICE_DISCONNECT, value, sizeof(value));
    if (ret >= 0) {
        audio_devices_t device = (audio_devices_t)strtoul(value, NULL, 10);
        if (device == AUDIO_DEVICE_OUT_USB_DEVICE) {
            ret = str_parms_get_str(parms, "card", value, sizeof(value));
            if (ret >= 0) {
                const int card = atoi(value);

                audio_extn_usb_remove_device(AUDIO_DEVICE_OUT_USB_DEVICE, card);
            }
        } else if (device == AUDIO_DEVICE_IN_USB_DEVICE) {
            ret = str_parms_get_str(parms, "card", value, sizeof(value));
            if (ret >= 0) {
                const int card = atoi(value);
                audio_extn_usb_remove_device(AUDIO_DEVICE_IN_USB_DEVICE, card);
            }
        }
    }

    audio_extn_hfp_set_parameters(adev, parms);
done:
    str_parms_destroy(parms);
+2 −0
Original line number Diff line number Diff line
@@ -49,6 +49,8 @@
#define ACDB_DEV_TYPE_IN 2

#define MAX_SUPPORTED_CHANNEL_MASKS 2
#define MAX_SUPPORTED_FORMATS 15
#define MAX_SUPPORTED_SAMPLE_RATES 7
#define DEFAULT_HDMI_OUT_CHANNELS   2

#define ERROR_LOG_ENTRIES 16
Loading