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

Commit dbf1e5fd authored by Daniel Hillenbrand's avatar Daniel Hillenbrand Committed by Matt Mower
Browse files

hal: Support the audio amplifier hook

* Original legacy HAL commit:
  Ib236598a5888b2af19bcfb81e285f644a0e84c0d
* Example: http://review.cyanogenmod.org/38221

Change-Id: Ic944a9f7059c78b79322dae9c787cdd8bb029cff
parent fd42377c
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -137,6 +137,12 @@ LOCAL_SHARED_LIBRARIES := \
	libdl \
	libexpat

ifneq ($(BOARD_AUDIO_AMPLIFIER),)
    LOCAL_CFLAGS += -DUSES_AUDIO_AMPLIFIER
    LOCAL_SHARED_LIBRARIES += libaudioamp
    LOCAL_C_INCLUDES += $(BOARD_AUDIO_AMPLIFIER)
endif

LOCAL_C_INCLUDES += \
	external/tinyalsa/include \
	external/tinycompress/include \
+24 −0
Original line number Diff line number Diff line
@@ -55,6 +55,10 @@
#include "sound/compress_params.h"
#include "sound/asound.h"

#ifdef USES_AUDIO_AMPLIFIER
#include <audio_amplifier.h>
#endif

#define COMPRESS_OFFLOAD_NUM_FRAGMENTS 4
/* ToDo: Check and update a proper value in msec */
#define COMPRESS_OFFLOAD_PLAYBACK_LATENCY 96
@@ -813,6 +817,13 @@ int select_devices(struct audio_device *adev, audio_usecase_t uc_id)

    enable_audio_route(adev, usecase);

#ifdef USES_AUDIO_AMPLIFIER
    /* Rely on amplifier_set_devices to distinguish between in/out devices */
    amplifier_set_devices(in_snd_device);
    amplifier_set_devices(out_snd_device);
#endif


    /* Applicable only on the targets that has external modem.
     * Enable device command should be sent to modem only after
     * enabling voice call mixer controls
@@ -2900,6 +2911,10 @@ static int adev_set_mode(struct audio_hw_device *dev, audio_mode_t mode)
    pthread_mutex_lock(&adev->lock);
    if (adev->mode != mode) {
        ALOGD("%s mode %d\n", __func__, mode);
#ifdef USES_AUDIO_AMPLIFIER
        if (amplifier_set_mode(mode) != 0)
            ALOGE("Failed setting amplifier mode");
#endif
        adev->mode = mode;
    }
    pthread_mutex_unlock(&adev->lock);
@@ -3113,6 +3128,10 @@ static int adev_close(hw_device_t *device)
    pthread_mutex_lock(&adev_init_lock);

    if ((--audio_device_ref_count) == 0) {
#ifdef USES_AUDIO_AMPLIFIER
        if (amplifier_close() != 0)
            ALOGE("Amplifier close failed");
#endif
        audio_extn_listen_deinit(adev);
        audio_route_free(adev->audio_route);
        free(adev->snd_dev_ref_cnt);
@@ -3255,6 +3274,11 @@ static int adev_open(const hw_module_t *module, const char *name,

    *device = &adev->device.common;

#ifdef USES_AUDIO_AMPLIFIER
    if (amplifier_open() != 0)
        ALOGE("Amplifier initialization failed");
#endif

    audio_device_ref_count++;

    char value[PROPERTY_VALUE_MAX];