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

Commit 4113f34d authored by Iliyan Malchev's avatar Iliyan Malchev
Browse files

working msm8960 audio.primary and audio_policy HALs



These HALs build on JB and work on mako

Change-Id: I89bff4f1269d47a33d8e2a53a0b65d69aaf53240
Signed-off-by: default avatarIliyan Malchev <malchev@google.com>
parent 4765c439
Loading
Loading
Loading
Loading
+14 −14
Original line number Diff line number Diff line
@@ -24,10 +24,10 @@
#include <unistd.h>
#include <dlfcn.h>

#define LOG_TAG "ALSAControl"
#define LOG_TAG "alsa.msm8960"
//#define LOG_NDEBUG 0
#define LOG_NDDEBUG 0
#include <utils/Log.h>

#include <utils/String8.h>

#include <cutils/properties.h>
@@ -41,9 +41,9 @@ namespace android_audio_legacy

ALSAControl::ALSAControl(const char *device)
{
    LOGD("ALSAControl: ctor device %s", device);
    ALOGD("ALSAControl: ctor device %s", device);
    mHandle = mixer_open(device);
    LOGV("ALSAControl: ctor mixer %p", mHandle);
    ALOGV("ALSAControl: ctor mixer %p", mHandle);
}

ALSAControl::~ALSAControl()
@@ -56,7 +56,7 @@ status_t ALSAControl::get(const char *name, unsigned int &value, int index)
    struct mixer_ctl *ctl;

    if (!mHandle) {
        LOGE("Control not initialized");
        ALOGE("Control not initialized");
        return NO_INIT;
    }

@@ -72,16 +72,16 @@ status_t ALSAControl::set(const char *name, unsigned int value, int index)
{
    struct mixer_ctl *ctl;
    int ret = 0;
    LOGD("set:: name %s value %d index %d", name, value, index);
    ALOGD("set:: name %s value %d index %d", name, value, index);
    if (!mHandle) {
        LOGE("Control not initialized");
        ALOGE("Control not initialized");
        return NO_INIT;
    }

    // ToDo: Do we need to send index here? Right now it works with 0
    ctl = mixer_get_control(mHandle, name, 0);
    if(ctl == NULL) {
        LOGE("Could not get the mixer control");
        ALOGE("Could not get the mixer control");
        return BAD_VALUE;
    }
    ret = mixer_ctl_set(ctl, value);
@@ -92,16 +92,16 @@ status_t ALSAControl::set(const char *name, const char *value)
{
    struct mixer_ctl *ctl;
    int ret = 0;
    LOGD("set:: name %s value %s", name, value);
    ALOGD("set:: name %s value %s", name, value);

    if (!mHandle) {
        LOGE("Control not initialized");
        ALOGE("Control not initialized");
        return NO_INIT;
    }

    ctl = mixer_get_control(mHandle, name, 0);
    if(ctl == NULL) {
        LOGE("Could not get the mixer control");
        ALOGE("Could not get the mixer control");
        return BAD_VALUE;
    }
    ret = mixer_ctl_select(ctl, value);
@@ -112,16 +112,16 @@ status_t ALSAControl::setext(const char *name, int count, char **setValues)
{
    struct mixer_ctl *ctl;
    int ret = 0;
    LOGD("setext:: name %s count %d", name, count);
    ALOGD("setext:: name %s count %d", name, count);
    if (!mHandle) {
        LOGE("Control not initialized");
        ALOGE("Control not initialized");
        return NO_INIT;
    }

    // ToDo: Do we need to send index here? Right now it works with 0
    ctl = mixer_get_control(mHandle, name, 0);
    if(ctl == NULL) {
        LOGE("Could not get the mixer control");
        ALOGE("Could not get the mixer control");
        return BAD_VALUE;
    }
    ret = mixer_ctl_set_value(ctl, count, setValues);
+12 −11
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@

#define LOG_TAG "AudioHardwareALSA"
#include <utils/Log.h>

#include <utils/String8.h>

#include <cutils/properties.h>
@@ -100,16 +101,16 @@ static int initMixer (snd_mixer_t **mixer, const char *name)
    int err;

    if ((err = snd_mixer_open(mixer, 0)) < 0) {
        LOGE("Unable to open mixer: %s", snd_strerror(err));
        ALOGE("Unable to open mixer: %s", snd_strerror(err));
        return err;
    }

    if ((err = snd_mixer_attach(*mixer, name)) < 0) {
        LOGW("Unable to attach mixer to device %s: %s",
        ALOGW("Unable to attach mixer to device %s: %s",
            name, snd_strerror(err));

        if ((err = snd_mixer_attach(*mixer, "hw:00")) < 0) {
            LOGE("Unable to attach mixer to device default: %s",
            ALOGE("Unable to attach mixer to device default: %s",
                snd_strerror(err));

            snd_mixer_close (*mixer);
@@ -119,7 +120,7 @@ static int initMixer (snd_mixer_t **mixer, const char *name)
    }

    if ((err = snd_mixer_selem_register(*mixer, NULL, NULL)) < 0) {
        LOGE("Unable to register mixer elements: %s", snd_strerror(err));
        ALOGE("Unable to register mixer elements: %s", snd_strerror(err));
        snd_mixer_close (*mixer);
        *mixer = NULL;
        return err;
@@ -127,7 +128,7 @@ static int initMixer (snd_mixer_t **mixer, const char *name)

    // Get the mixer controls from the kernel
    if ((err = snd_mixer_load(*mixer)) < 0) {
        LOGE("Unable to load mixer elements: %s", snd_strerror(err));
        ALOGE("Unable to load mixer elements: %s", snd_strerror(err));
        snd_mixer_close (*mixer);
        *mixer = NULL;
        return err;
@@ -204,7 +205,7 @@ ALSAMixer::ALSAMixer()
            }
        }

        LOGV("Mixer: master '%s' %s.", info->name, info->elem ? "found" : "not found");
        ALOGV("Mixer: master '%s' %s.", info->name, info->elem ? "found" : "not found");

        for (int j = 0; mixerProp[j][i].device; j++) {

@@ -240,10 +241,10 @@ ALSAMixer::ALSAMixer()
                    break;
                }
            }
            LOGV("Mixer: route '%s' %s.", info->name, info->elem ? "found" : "not found");
            ALOGV("Mixer: route '%s' %s.", info->name, info->elem ? "found" : "not found");
        }
    }
    LOGV("mixer initialized.");
    ALOGV("mixer initialized.");
}

ALSAMixer::~ALSAMixer()
@@ -261,7 +262,7 @@ ALSAMixer::~ALSAMixer()
            }
        }
    }
    LOGV("mixer destroyed.");
    ALOGV("mixer destroyed.");
}

status_t ALSAMixer::setMasterVolume(float volume)
@@ -360,7 +361,7 @@ status_t ALSAMixer::setCaptureMuteState(uint32_t device, bool state)

                int err = snd_mixer_selem_set_capture_switch_all (info->elem, static_cast<int>(!state));
                if (err < 0) {
                    LOGE("Unable to %s capture mixer switch %s",
                    ALOGE("Unable to %s capture mixer switch %s",
                        state ? "enable" : "disable", info->name);
                    return INVALID_OPERATION;
                }
@@ -401,7 +402,7 @@ status_t ALSAMixer::setPlaybackMuteState(uint32_t device, bool state)

                int err = snd_mixer_selem_set_playback_switch_all (info->elem, static_cast<int>(!state));
                if (err < 0) {
                    LOGE("Unable to %s playback mixer switch %s",
                    ALOGE("Unable to %s playback mixer switch %s",
                        state ? "enable" : "disable", info->name);
                    return INVALID_OPERATION;
                }
+12 −11
Original line number Diff line number Diff line
@@ -24,9 +24,8 @@
#include <unistd.h>
#include <dlfcn.h>

#define LOG_TAG "ALSAStreamOps"
#define LOG_TAG "audio.primary.msm8960"
//#define LOG_NDEBUG 0
#define LOG_NDDEBUG 0
#include <utils/Log.h>
#include <utils/String8.h>

@@ -56,7 +55,7 @@ ALSAStreamOps::~ALSAStreamOps()
        if((mParent->mVoipStreamCount)) {
            mParent->mVoipStreamCount--;
            if(mParent->mVoipStreamCount > 0) {
                LOGD("ALSAStreamOps::close() Ignore");
                ALOGD("ALSAStreamOps::close() Ignore");
                return ;
            }
       }
@@ -165,7 +164,7 @@ status_t ALSAStreamOps::set(int *format,
                break;

            default:
                LOGE("Unknown PCM format %i. Forcing default", *format);
                ALOGE("Unknown PCM format %i. Forcing default", *format);
                break;
        }

@@ -194,7 +193,7 @@ status_t ALSAStreamOps::setParameters(const String8& keyValuePairs)
    int device;
    if (param.getInt(key, device) == NO_ERROR) {
        // Ignore routing if device is 0.
        LOGD("setParameters(): keyRouting with device %d", device);
        ALOGD("setParameters(): keyRouting with device %d", device);
        mDevices = device;
        if(device) {
            mParent->doRouting(device);
@@ -205,7 +204,7 @@ status_t ALSAStreamOps::setParameters(const String8& keyValuePairs)
    else {
        key = String8(AudioParameter::keyHandleFm);
        if (param.getInt(key, device) == NO_ERROR) {
        LOGD("setParameters(): handleFm with device %d", device);
        ALOGD("setParameters(): handleFm with device %d", device);
        mDevices = device;
            if(device) {
                mParent->handleFm(device);
@@ -228,6 +227,7 @@ String8 ALSAStreamOps::getParameters(const String8& keys)
        param.addInt(key, (int)mDevices);
    }
    else {
#if 0
        key = String8(AudioParameter::keyVoipCheck);
        if (param.get(key, value) == NO_ERROR) {
            if((!strncmp(mHandle->useCase, SND_USE_CASE_VERB_IP_VOICECALL, strlen(SND_USE_CASE_VERB_IP_VOICECALL))) ||
@@ -236,8 +236,9 @@ String8 ALSAStreamOps::getParameters(const String8& keys)
            else
                param.addInt(key, false);
        }
#endif
    }
    LOGV("getParameters() %s", param.toString().string());
    ALOGV("getParameters() %s", param.toString().string());
    return param.toString();
}

@@ -251,7 +252,7 @@ uint32_t ALSAStreamOps::sampleRate() const
//
size_t ALSAStreamOps::bufferSize() const
{
    LOGV("bufferSize() returns %d", mHandle->bufferSize);
    ALOGV("bufferSize() returns %d", mHandle->bufferSize);
    return mHandle->bufferSize;
}

@@ -285,7 +286,7 @@ int ALSAStreamOps::format() const
            break;
    }

    LOGD("ALSAFormat:0x%x,audioSystemFormat:0x%x",ALSAFormat,audioSystemFormat);
    ALOGD("ALSAFormat:0x%x,audioSystemFormat:0x%x",ALSAFormat,audioSystemFormat);
    return audioSystemFormat;
}

@@ -331,7 +332,7 @@ uint32_t ALSAStreamOps::channels() const

void ALSAStreamOps::close()
{
    LOGD("close");
    ALOGD("close");
    if((!strncmp(mHandle->useCase, SND_USE_CASE_VERB_IP_VOICECALL, strlen(SND_USE_CASE_VERB_IP_VOICECALL))) ||
       (!strncmp(mHandle->useCase, SND_USE_CASE_MOD_PLAY_VOIP, strlen(SND_USE_CASE_MOD_PLAY_VOIP)))) {
       mParent->mVoipMicMute = false;
@@ -353,7 +354,7 @@ void ALSAStreamOps::close()
//
status_t ALSAStreamOps::open(int mode)
{
    LOGD("open");
    ALOGD("open");
    return mParent->mALSADevice->open(mHandle);
}

+9 −14
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ LOCAL_SRC_FILES := \
LOCAL_STATIC_LIBRARIES := \
    libmedia_helper \
    libaudiohw_legacy \
    libaudiopolicy_legacy \

LOCAL_SHARED_LIBRARIES := \
    libcutils \
@@ -31,23 +32,18 @@ LOCAL_SHARED_LIBRARIES := \
    libhardware \
    libc        \
    libpower    \
    libalsa-intf \
    libcsd-client \
    libsurround_proc
    libalsa-intf

LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/audio-alsa
LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/audcal
LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/audio-acdb-util
LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/libalsa-intf
LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/audio-qmi/csd-client
LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/surround_sound/
LOCAL_C_INCLUDES += hardware/libhardware/include
LOCAL_C_INCLUDES += hardware/libhardware_legacy/include
LOCAL_C_INCLUDES += frameworks/base/include
LOCAL_C_INCLUDES += system/core/include

LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr

LOCAL_MODULE := audio.primary.msm8960
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
@@ -55,6 +51,7 @@ LOCAL_MODULE_TAGS := optional

include $(BUILD_SHARED_LIBRARY)

ifeq (1,1) # use default audio policy manager
# This is the ALSA audio policy manager

include $(CLEAR_VARS)
@@ -66,8 +63,8 @@ ifeq ($(BOARD_HAVE_BLUETOOTH),true)
endif

LOCAL_SRC_FILES := \
    AudioPolicyManagerALSA.cpp	\
    audio_policy_hal.cpp
    audio_policy_hal.cpp \
    AudioPolicyManagerALSA.cpp

LOCAL_MODULE := audio_policy.msm8960
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
@@ -75,6 +72,7 @@ LOCAL_MODULE_TAGS := optional

LOCAL_STATIC_LIBRARIES := \
    libmedia_helper \
    libaudiohw_legacy \
    libaudiopolicy_legacy

LOCAL_SHARED_LIBRARIES := \
@@ -85,7 +83,7 @@ LOCAL_SHARED_LIBRARIES := \
LOCAL_C_INCLUDES += hardware/libhardware_legacy/audio

include $(BUILD_SHARED_LIBRARY)

endif

# This is the ALSA module which behaves closely like the original

@@ -101,10 +99,7 @@ ifneq ($(ALSA_DEFAULT_SAMPLE_RATE),)
    LOCAL_CFLAGS += -DALSA_DEFAULT_SAMPLE_RATE=$(ALSA_DEFAULT_SAMPLE_RATE)
endif

LOCAL_C_INCLUDES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/libalsa-intf
LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/audio-qmi/csd-client

LOCAL_SRC_FILES:= \
    alsa_default.cpp \
@@ -113,11 +108,11 @@ LOCAL_SRC_FILES:= \
LOCAL_SHARED_LIBRARIES := \
    libcutils \
    liblog    \
    libalsa-intf \
    libcsd-client
    libalsa-intf

LOCAL_MODULE:= alsa.msm8960
LOCAL_MODULE_TAGS := optional

  include $(BUILD_SHARED_LIBRARY)

endif
+103 −111

File changed.

Preview size limit exceeded, changes collapsed.

Loading