Merge "stingray: update kernel / wifi prebuilt"
diff --git a/AndroidBoard.mk b/AndroidBoard.mk
index d16e172..9678291 100644
--- a/AndroidBoard.mk
+++ b/AndroidBoard.mk
@@ -49,6 +49,10 @@
include $(COMMON_DIR)/TegraBoard.mk
endif
-include $(LOCAL_PATH)/ril/Android.mk
+subdir_makefiles:= \
+ $(LOCAL_PATH)/ril/Android.mk \
+ $(LOCAL_PATH)/libaudio/Android.mk
+
+include $(subdir_makefiles)
-include vendor/moto/stingray/AndroidBoardVendor.mk
diff --git a/BoardConfig.mk b/BoardConfig.mk
index 754d91a..25492c4 100755
--- a/BoardConfig.mk
+++ b/BoardConfig.mk
@@ -7,6 +7,9 @@
ARCH_ARM_HAVE_TLS_REGISTER := true
TARGET_USERIMAGES_USE_EXT4 := true
+BOARD_SYSTEMIMAGE_PARTITION_SIZE := 134217728
+BOARD_USERDATAIMAGE_PARTITION_SIZE := 16777216
+BOARD_FLASH_BLOCK_SIZE := 4096
# Wifi related defines
BOARD_WPA_SUPPLICANT_DRIVER := WEXT
diff --git a/libaudio/Android.mk b/libaudio/Android.mk
new file mode 100644
index 0000000..9dca5bb
--- /dev/null
+++ b/libaudio/Android.mk
@@ -0,0 +1,56 @@
+ifneq ($(BUILD_TINY_ANDROID),true)
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+ AudioPolicyManager.cpp
+
+LOCAL_SHARED_LIBRARIES := \
+ libcutils \
+ libutils \
+ libmedia
+
+LOCAL_STATIC_LIBRARIES := libaudiopolicybase
+
+LOCAL_MODULE:= libaudiopolicy
+
+ifeq ($(BOARD_HAVE_BLUETOOTH),true)
+ LOCAL_CFLAGS += -DWITH_A2DP
+endif
+
+include $(BUILD_SHARED_LIBRARY)
+
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libaudio
+
+LOCAL_SHARED_LIBRARIES := \
+ libcutils \
+ libutils \
+ libmedia \
+ libhardware_legacy
+
+ifeq ($TARGET_OS)-$(TARGET_SIMULATOR),linux-true)
+LOCAL_LDLIBS += -ldl
+endif
+
+ifneq ($(TARGET_SIMULATOR),true)
+LOCAL_SHARED_LIBRARIES += libdl
+endif
+
+LOCAL_SRC_FILES += AudioHardware.cpp
+
+LOCAL_CFLAGS += -fno-short-enums
+
+LOCAL_STATIC_LIBRARIES += libaudiointerface
+ifeq ($(BOARD_HAVE_BLUETOOTH),true)
+ LOCAL_SHARED_LIBRARIES += liba2dp
+endif
+
+include $(BUILD_SHARED_LIBRARY)
+
+endif # not BUILD_TINY_ANDROID
+
diff --git a/libaudio/AudioHardware.cpp b/libaudio/AudioHardware.cpp
new file mode 100644
index 0000000..16e455c
--- /dev/null
+++ b/libaudio/AudioHardware.cpp
@@ -0,0 +1,941 @@
+/*
+** Copyright 2008, The Android Open-Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+#include <math.h>
+
+//#define LOG_NDEBUG 0
+#define LOG_TAG "AudioHardwareTegra"
+#include <utils/Log.h>
+#include <utils/String8.h>
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <dlfcn.h>
+#include <fcntl.h>
+
+// hardware specific functions
+
+#include "AudioHardware.h"
+#include <media/AudioRecord.h>
+
+namespace android {
+const uint32_t AudioHardware::inputSamplingRates[] = {
+ 8000, 16000, 44100
+};
+// ----------------------------------------------------------------------------
+
+AudioHardware::AudioHardware() :
+ mInit(false), mMicMute(true), mBluetoothNrec(true), mBluetoothId(0),
+ mOutput(0), mCurSndDevice(-1)
+{
+ int fd = ::open("/dev/audio_ctl", O_RDWR);
+ if (fd >= 0) {
+ if (::ioctl(fd, CPCAP_AUDIO_OUT_GET_OUTPUT, &mCurSndDevice))
+ LOGE("Could not open audio_ctl: %s", strerror(errno));
+ else
+ LOGI("current output device: %d", mCurSndDevice);
+ }
+ mInit = true;
+}
+
+AudioHardware::~AudioHardware()
+{
+ for (size_t index = 0; index < mInputs.size(); index++) {
+ closeInputStream((AudioStreamIn*)mInputs[index]);
+ }
+ mInputs.clear();
+ closeOutputStream((AudioStreamOut*)mOutput);
+ mInit = false;
+}
+
+status_t AudioHardware::initCheck()
+{
+ return mInit ? NO_ERROR : NO_INIT;
+}
+
+AudioStreamOut* AudioHardware::openOutputStream(
+ uint32_t devices, int *format, uint32_t *channels, uint32_t *sampleRate, status_t *status)
+{
+ { // scope for the lock
+ Mutex::Autolock lock(mLock);
+
+ // only one output stream allowed
+ if (mOutput) {
+ if (status) {
+ *status = INVALID_OPERATION;
+ }
+ return 0;
+ }
+
+ // create new output stream
+ AudioStreamOutTegra* out = new AudioStreamOutTegra();
+ status_t lStatus = out->set(this, devices, format, channels, sampleRate);
+ if (status) {
+ *status = lStatus;
+ }
+ if (lStatus == NO_ERROR) {
+ mOutput = out;
+ } else {
+ delete out;
+ }
+ }
+ return mOutput;
+}
+
+void AudioHardware::closeOutputStream(AudioStreamOut* out) {
+ Mutex::Autolock lock(mLock);
+ if (mOutput == 0 || mOutput != out) {
+ LOGW("Attempt to close invalid output stream");
+ }
+ else {
+ delete mOutput;
+ mOutput = 0;
+ }
+}
+
+AudioStreamIn* AudioHardware::openInputStream(
+ uint32_t devices, int *format, uint32_t *channels, uint32_t *sampleRate, status_t *status,
+ AudioSystem::audio_in_acoustics acoustic_flags)
+{
+ // check for valid input source
+ if (!AudioSystem::isInputDevice((AudioSystem::audio_devices)devices)) {
+ return 0;
+ }
+
+ mLock.lock();
+
+ AudioStreamInTegra* in = new AudioStreamInTegra();
+ status_t lStatus = in->set(this, devices, format, channels, sampleRate, acoustic_flags);
+ if (status) {
+ *status = lStatus;
+ }
+ if (lStatus != NO_ERROR) {
+ mLock.unlock();
+ delete in;
+ return 0;
+ }
+
+ mInputs.add(in);
+ mLock.unlock();
+
+ return in;
+}
+
+void AudioHardware::closeInputStream(AudioStreamIn* in) {
+ Mutex::Autolock lock(mLock);
+
+ ssize_t index = mInputs.indexOf((AudioStreamInTegra *)in);
+ if (index < 0) {
+ LOGW("Attempt to close invalid input stream");
+ } else {
+ mLock.unlock();
+ delete mInputs[index];
+ mLock.lock();
+ mInputs.removeAt(index);
+ }
+}
+
+status_t AudioHardware::setMode(int mode)
+{
+ status_t status = AudioHardwareBase::setMode(mode);
+ if (status == NO_ERROR) {
+ // make sure that doAudioRouteOrMute() is called by doRouting()
+ // even if the new device selected is the same as current one.
+ clearCurDevice();
+ }
+ return status;
+}
+
+bool AudioHardware::checkOutputStandby()
+{
+ if (mOutput)
+ if (!mOutput->checkStandby())
+ return false;
+
+ return true;
+}
+
+status_t AudioHardware::setMicMute(bool state)
+{
+ Mutex::Autolock lock(mLock);
+ return setMicMute_nosync(state);
+}
+
+// always call with mutex held
+status_t AudioHardware::setMicMute_nosync(bool state)
+{
+ if (mMicMute != state) {
+ mMicMute = state;
+ return NO_ERROR; //doAudioRouteOrMute(SND_DEVICE_CURRENT);
+ }
+ return NO_ERROR;
+}
+
+status_t AudioHardware::getMicMute(bool* state)
+{
+ *state = mMicMute;
+ return NO_ERROR;
+}
+
+status_t AudioHardware::setParameters(const String8& keyValuePairs)
+{
+ AudioParameter param = AudioParameter(keyValuePairs);
+ String8 value;
+ String8 key;
+ const char BT_NREC_KEY[] = "bt_headset_nrec";
+ const char BT_NAME_KEY[] = "bt_headset_name";
+ const char BT_NREC_VALUE_ON[] = "on";
+
+
+ LOGV("setParameters() %s", keyValuePairs.string());
+
+ if (keyValuePairs.length() == 0) return BAD_VALUE;
+
+ key = String8(BT_NREC_KEY);
+ if (param.get(key, value) == NO_ERROR) {
+ if (value == BT_NREC_VALUE_ON) {
+ mBluetoothNrec = true;
+ } else {
+ mBluetoothNrec = false;
+ LOGI("Turning noise reduction and echo cancellation off for BT "
+ "headset");
+ }
+ }
+ key = String8(BT_NAME_KEY);
+ if (param.get(key, value) == NO_ERROR) {
+ mBluetoothId = 0;
+#if 0
+ for (int i = 0; i < mNumSndEndpoints; i++) {
+ if (!strcasecmp(value.string(), mSndEndpoints[i].name)) {
+ mBluetoothId = mSndEndpoints[i].id;
+ LOGI("Using custom acoustic parameters for %s", value.string());
+ break;
+ }
+ }
+#endif
+ if (mBluetoothId == 0) {
+ LOGI("Using default acoustic parameters "
+ "(%s not in acoustic database)", value.string());
+ doRouting();
+ }
+ }
+ return NO_ERROR;
+}
+
+String8 AudioHardware::getParameters(const String8& keys)
+{
+ AudioParameter param = AudioParameter(keys);
+ return param.toString();
+}
+
+size_t AudioHardware::getInputBufferSize(uint32_t sampleRate, int format, int channelCount)
+{
+ if (format != AudioSystem::PCM_16_BIT) {
+ LOGW("getInputBufferSize bad format: %d", format);
+ return 0;
+ }
+ if (channelCount < 1 || channelCount > 2) {
+ LOGW("getInputBufferSize bad channel count: %d", channelCount);
+ return 0;
+ }
+
+ return 2048*channelCount;
+}
+
+status_t AudioHardware::setVoiceVolume(float v)
+{
+ if (v < 0.0) {
+ LOGW("setVoiceVolume(%f) under 0.0, assuming 0.0\n", v);
+ v = 0.0;
+ } else if (v > 1.0) {
+ LOGW("setVoiceVolume(%f) over 1.0, assuming 1.0\n", v);
+ v = 1.0;
+ }
+
+ int vol = lrint(v * 15.0);
+ LOGD("setVoiceVolume(%f)\n", v);
+ LOGI("Setting in-call volume to %d (available range is 0 to 15)\n", vol);
+
+ Mutex::Autolock lock(mLock);
+ {
+ int fd = open("/dev/audio_ctl", O_RDWR);
+ if (fd < 0) {
+ LOGE("could not open audio_ctl: %s\n", strerror(errno));
+ return NO_ERROR;
+ }
+ if (ioctl(fd, CPCAP_AUDIO_OUT_SET_VOLUME, vol) < 0)
+ LOGE("could not set volume: %s\n", strerror(errno));
+ close(fd);
+ }
+ return NO_ERROR;
+}
+
+status_t AudioHardware::setMasterVolume(float v)
+{
+ Mutex::Autolock lock(mLock);
+ int vol = ceil(v * 5.0);
+ LOGI("Set master volume to %d.\n", vol);
+ /*
+ set_volume_rpc(SND_DEVICE_HANDSET, SND_METHOD_VOICE, vol);
+ set_volume_rpc(SND_DEVICE_SPEAKER, SND_METHOD_VOICE, vol);
+ set_volume_rpc(SND_DEVICE_BT, SND_METHOD_VOICE, vol);
+ set_volume_rpc(SND_DEVICE_HEADSET, SND_METHOD_VOICE, vol);
+ */
+ // We return an error code here to let the audioflinger do in-software
+ // volume on top of the maximum volume that we set through the SND API.
+ // return error - software mixer will handle it
+ return -1;
+}
+
+// always call with mutex held
+status_t AudioHardware::doAudioRouteOrMute(uint32_t device)
+{
+#if 0
+ if (device == (uint32_t)SND_DEVICE_BT || device == (uint32_t)SND_DEVICE_CARKIT) {
+ if (mBluetoothId) {
+ device = mBluetoothId;
+ } else if (!mBluetoothNrec) {
+ device = CPCAP_AUDIO_OUT_SPEAKER;
+ }
+ }
+#endif
+
+ {
+ int fd = open("/dev/audio_ctl", O_RDWR);
+ if (fd < 0) {
+ LOGE("could not open audio_ctl: %s\n", strerror(errno));
+ return NO_ERROR;
+ }
+ if (ioctl(fd, CPCAP_AUDIO_OUT_SET_OUTPUT, device) < 0)
+ LOGE("could not set output: %s\n", strerror(errno));
+ close(fd);
+ }
+ return NO_ERROR;
+}
+
+status_t AudioHardware::doRouting()
+{
+ Mutex::Autolock lock(mLock);
+ uint32_t outputDevices = mOutput->devices();
+ status_t ret = NO_ERROR;
+ AudioStreamInTegra *input = getActiveInput_l();
+ uint32_t inputDevice = (input == NULL) ? 0 : input->devices();
+
+ int sndDevice = -1;
+
+ if (inputDevice != 0) {
+ LOGI("do input routing device %x\n", inputDevice);
+ if (inputDevice & AudioSystem::DEVICE_IN_BLUETOOTH_SCO_HEADSET) {
+ LOGI("Routing audio to Bluetooth PCM\n");
+ sndDevice = CPCAP_AUDIO_OUT_SPEAKER;
+ } else if (inputDevice & AudioSystem::DEVICE_IN_WIRED_HEADSET) {
+ if ((outputDevices & AudioSystem::DEVICE_OUT_WIRED_HEADSET) &&
+ (outputDevices & AudioSystem::DEVICE_OUT_SPEAKER)) {
+ LOGI("Routing audio to Wired Headset and Speaker\n");
+ sndDevice = CPCAP_AUDIO_OUT_SPEAKER;
+ } else {
+ LOGI("Routing audio to Wired Headset\n");
+ sndDevice = CPCAP_AUDIO_OUT_HEADSET;
+ }
+ } else {
+ if (outputDevices & AudioSystem::DEVICE_OUT_SPEAKER) {
+ LOGI("Routing audio to Speakerphone\n");
+ sndDevice = CPCAP_AUDIO_OUT_SPEAKER;
+ } else {
+ LOGI("Routing audio to Handset\n");
+ sndDevice = CPCAP_AUDIO_OUT_HEADSET;
+ }
+ }
+ }
+ // if inputDevice == 0, restore output routing
+
+ if (sndDevice == -1) {
+ if (outputDevices & (outputDevices - 1)) {
+ if ((outputDevices & AudioSystem::DEVICE_OUT_SPEAKER) == 0) {
+ LOGW("Hardware does not support requested route combination (%#X),"
+ " picking closest possible route...", outputDevices);
+ }
+ }
+
+ if (outputDevices &
+ (AudioSystem::DEVICE_OUT_BLUETOOTH_SCO | AudioSystem::DEVICE_OUT_BLUETOOTH_SCO_HEADSET)) {
+ LOGI("Routing audio to Bluetooth PCM\n");
+ sndDevice = CPCAP_AUDIO_OUT_SPEAKER;
+ } else if (outputDevices & AudioSystem::DEVICE_OUT_BLUETOOTH_SCO_CARKIT) {
+ LOGI("Routing audio to Bluetooth PCM\n");
+ sndDevice = CPCAP_AUDIO_OUT_SPEAKER;
+ } else if ((outputDevices & AudioSystem::DEVICE_OUT_WIRED_HEADSET) &&
+ (outputDevices & AudioSystem::DEVICE_OUT_SPEAKER)) {
+ LOGI("Routing audio to Wired Headset and Speaker\n");
+ sndDevice = CPCAP_AUDIO_OUT_SPEAKER;
+ } else if (outputDevices & AudioSystem::DEVICE_OUT_WIRED_HEADPHONE) {
+ if (outputDevices & AudioSystem::DEVICE_OUT_SPEAKER) {
+ LOGI("Routing audio to No microphone Wired Headset and Speaker (%d,%x)\n", mMode, outputDevices);
+ sndDevice = CPCAP_AUDIO_OUT_SPEAKER;
+ } else {
+ LOGI("Routing audio to No microphone Wired Headset (%d,%x)\n", mMode, outputDevices);
+ sndDevice = CPCAP_AUDIO_OUT_HEADSET;
+ }
+ } else if (outputDevices & AudioSystem::DEVICE_OUT_WIRED_HEADSET) {
+ LOGI("Routing audio to Wired Headset\n");
+ sndDevice = CPCAP_AUDIO_OUT_HEADSET;
+ } else if (outputDevices & AudioSystem::DEVICE_OUT_SPEAKER) {
+ LOGI("Routing audio to Speakerphone\n");
+ sndDevice = CPCAP_AUDIO_OUT_SPEAKER;
+ } else {
+ LOGI("Routing audio to Handset\n");
+ sndDevice = CPCAP_AUDIO_OUT_HEADSET;
+ }
+ }
+
+ if (sndDevice != -1 && sndDevice != mCurSndDevice) {
+ ret = doAudioRouteOrMute(sndDevice);
+ mCurSndDevice = sndDevice;
+ }
+
+ return ret;
+}
+
+status_t AudioHardware::checkMicMute()
+{
+ Mutex::Autolock lock(mLock);
+ if (mMode != AudioSystem::MODE_IN_CALL) {
+ setMicMute_nosync(true);
+ }
+
+ return NO_ERROR;
+}
+
+status_t AudioHardware::dumpInternals(int fd, const Vector<String16>& args)
+{
+ const size_t SIZE = 256;
+ char buffer[SIZE];
+ String8 result;
+ result.append("AudioHardware::dumpInternals\n");
+ snprintf(buffer, SIZE, "\tmInit: %s\n", mInit? "true": "false");
+ result.append(buffer);
+ snprintf(buffer, SIZE, "\tmMicMute: %s\n", mMicMute? "true": "false");
+ result.append(buffer);
+ snprintf(buffer, SIZE, "\tmBluetoothNrec: %s\n", mBluetoothNrec? "true": "false");
+ result.append(buffer);
+ snprintf(buffer, SIZE, "\tmBluetoothId: %d\n", mBluetoothId);
+ result.append(buffer);
+ ::write(fd, result.string(), result.size());
+ return NO_ERROR;
+}
+
+status_t AudioHardware::dump(int fd, const Vector<String16>& args)
+{
+ dumpInternals(fd, args);
+ for (size_t index = 0; index < mInputs.size(); index++) {
+ mInputs[index]->dump(fd, args);
+ }
+
+ if (mOutput) {
+ mOutput->dump(fd, args);
+ }
+ return NO_ERROR;
+}
+
+uint32_t AudioHardware::getInputSampleRate(uint32_t sampleRate)
+{
+ uint32_t i;
+ uint32_t prevDelta;
+ uint32_t delta;
+
+ for (i = 0, prevDelta = 0xFFFFFFFF; i < sizeof(inputSamplingRates)/sizeof(uint32_t); i++, prevDelta = delta) {
+ delta = abs(sampleRate - inputSamplingRates[i]);
+ if (delta > prevDelta) break;
+ }
+ // i is always > 0 here
+ return inputSamplingRates[i-1];
+}
+
+// getActiveInput_l() must be called with mLock held
+AudioHardware::AudioStreamInTegra *AudioHardware::getActiveInput_l()
+{
+ for (size_t i = 0; i < mInputs.size(); i++) {
+ // return first input found not being in standby mode
+ // as only one input can be in this state
+ if (mInputs[i]->state() > AudioStreamInTegra::AUDIO_INPUT_CLOSED) {
+ return mInputs[i];
+ }
+ }
+
+ return NULL;
+}
+// ----------------------------------------------------------------------------
+
+AudioHardware::AudioStreamOutTegra::AudioStreamOutTegra() :
+ mHardware(0), mFd(-1), mStartCount(0), mRetryCount(0), mStandby(true), mDevices(0)
+{
+}
+
+status_t AudioHardware::AudioStreamOutTegra::set(
+ AudioHardware* hw, uint32_t devices, int *pFormat, uint32_t *pChannels, uint32_t *pRate)
+{
+ int lFormat = pFormat ? *pFormat : 0;
+ uint32_t lChannels = pChannels ? *pChannels : 0;
+ uint32_t lRate = pRate ? *pRate : 0;
+
+ mHardware = hw;
+
+ // fix up defaults
+ if (lFormat == 0) lFormat = format();
+ if (lChannels == 0) lChannels = channels();
+ if (lRate == 0) lRate = sampleRate();
+
+ // check values
+ if ((lFormat != format()) ||
+ (lChannels != channels()) ||
+ (lRate != sampleRate())) {
+ if (pFormat) *pFormat = format();
+ if (pChannels) *pChannels = channels();
+ if (pRate) *pRate = sampleRate();
+ return BAD_VALUE;
+ }
+
+ if (pFormat) *pFormat = lFormat;
+ if (pChannels) *pChannels = lChannels;
+ if (pRate) *pRate = lRate;
+
+ mDevices = devices;
+
+ return NO_ERROR;
+}
+
+AudioHardware::AudioStreamOutTegra::~AudioStreamOutTegra()
+{
+ if (mFd >= 0) close(mFd);
+}
+
+ssize_t AudioHardware::AudioStreamOutTegra::write(const void* buffer, size_t bytes)
+{
+ // LOGD("AudioStreamOutTegra::write(%p, %u)", buffer, bytes);
+ status_t status = NO_INIT;
+ size_t count = bytes;
+ const uint8_t* p = static_cast<const uint8_t*>(buffer);
+
+ if (mStandby) {
+ // open driver
+ LOGV("open driver");
+ status = ::open("/dev/audio0_out", O_RDWR);
+ if (status < 0) {
+ LOGE("Cannot open /dev/audio0_out errno: %d", errno);
+ goto Error;
+ }
+ mFd = status;
+
+ mStandby = false;
+ }
+
+ while (count) {
+ ssize_t written = ::write(mFd, p, count);
+ if (written >= 0) {
+ count -= written;
+ p += written;
+ } else {
+ if (errno != EAGAIN) return written;
+ mRetryCount++;
+ LOGW("EAGAIN - retry");
+ }
+ }
+
+ return bytes;
+
+Error:
+ if (mFd >= 0) {
+ ::close(mFd);
+ mFd = -1;
+ }
+ // Simulate audio output timing in case of error
+ usleep(bytes * 1000000 / frameSize() / sampleRate());
+
+ return status;
+}
+
+status_t AudioHardware::AudioStreamOutTegra::standby()
+{
+ status_t status = NO_ERROR;
+ if (!mStandby && mFd >= 0) {
+ ::close(mFd);
+ mFd = -1;
+ }
+ mStandby = true;
+ return status;
+}
+
+status_t AudioHardware::AudioStreamOutTegra::dump(int fd, const Vector<String16>& args)
+{
+ const size_t SIZE = 256;
+ char buffer[SIZE];
+ String8 result;
+ result.append("AudioStreamOutTegra::dump\n");
+ snprintf(buffer, SIZE, "\tsample rate: %d\n", sampleRate());
+ result.append(buffer);
+ snprintf(buffer, SIZE, "\tbuffer size: %d\n", bufferSize());
+ result.append(buffer);
+ snprintf(buffer, SIZE, "\tchannels: %d\n", channels());
+ result.append(buffer);
+ snprintf(buffer, SIZE, "\tformat: %d\n", format());
+ result.append(buffer);
+ snprintf(buffer, SIZE, "\tmHardware: %p\n", mHardware);
+ result.append(buffer);
+ snprintf(buffer, SIZE, "\tmFd: %d\n", mFd);
+ result.append(buffer);
+ snprintf(buffer, SIZE, "\tmStartCount: %d\n", mStartCount);
+ result.append(buffer);
+ snprintf(buffer, SIZE, "\tmRetryCount: %d\n", mRetryCount);
+ result.append(buffer);
+ snprintf(buffer, SIZE, "\tmStandby: %s\n", mStandby? "true": "false");
+ result.append(buffer);
+ ::write(fd, result.string(), result.size());
+ return NO_ERROR;
+}
+
+bool AudioHardware::AudioStreamOutTegra::checkStandby()
+{
+ return mStandby;
+}
+
+status_t AudioHardware::AudioStreamOutTegra::setParameters(const String8& keyValuePairs)
+{
+ AudioParameter param = AudioParameter(keyValuePairs);
+ String8 key = String8(AudioParameter::keyRouting);
+ status_t status = NO_ERROR;
+ int device;
+ LOGV("AudioStreamOutTegra::setParameters() %s", keyValuePairs.string());
+
+ if (param.getInt(key, device) == NO_ERROR) {
+ mDevices = device;
+ LOGV("set output routing %x", mDevices);
+ status = mHardware->doRouting();
+ param.remove(key);
+ }
+
+ if (param.size()) {
+ status = BAD_VALUE;
+ }
+ return status;
+}
+
+String8 AudioHardware::AudioStreamOutTegra::getParameters(const String8& keys)
+{
+ AudioParameter param = AudioParameter(keys);
+ String8 value;
+ String8 key = String8(AudioParameter::keyRouting);
+
+ if (param.get(key, value) == NO_ERROR) {
+ LOGV("get routing %x", mDevices);
+ param.addInt(key, (int)mDevices);
+ }
+
+ LOGV("AudioStreamOutTegra::getParameters() %s", param.toString().string());
+ return param.toString();
+}
+
+status_t AudioHardware::AudioStreamOutTegra::getRenderPosition(uint32_t *dspFrames)
+{
+ //TODO: enable when supported by driver
+ return INVALID_OPERATION;
+}
+
+// ----------------------------------------------------------------------------
+
+AudioHardware::AudioStreamInTegra::AudioStreamInTegra() :
+ mHardware(0), mFd(-1), mState(AUDIO_INPUT_CLOSED), mRetryCount(0),
+#if 0
+ mFormat(AUDIO_HW_IN_FORMAT), mChannels(AUDIO_HW_IN_CHANNELS),
+ mSampleRate(AUDIO_HW_IN_SAMPLERATE), mBufferSize(AUDIO_HW_IN_BUFFERSIZE),
+#endif
+ mAcoustics((AudioSystem::audio_in_acoustics)0), mDevices(0)
+{
+}
+
+status_t AudioHardware::AudioStreamInTegra::set(
+ AudioHardware* hw, uint32_t devices, int *pFormat, uint32_t *pChannels, uint32_t *pRate,
+ AudioSystem::audio_in_acoustics acoustic_flags)
+{
+#if 1
+ return NO_ERROR;
+#else
+ if (pFormat == 0 || *pFormat != AUDIO_HW_IN_FORMAT) {
+ *pFormat = AUDIO_HW_IN_FORMAT;
+ return BAD_VALUE;
+ }
+ if (pRate == 0) {
+ return BAD_VALUE;
+ }
+ uint32_t rate = hw->getInputSampleRate(*pRate);
+ if (rate != *pRate) {
+ *pRate = rate;
+ return BAD_VALUE;
+ }
+
+ if (pChannels == 0 || (*pChannels != AudioSystem::CHANNEL_IN_MONO &&
+ *pChannels != AudioSystem::CHANNEL_IN_STEREO)) {
+ *pChannels = AUDIO_HW_IN_CHANNELS;
+ return BAD_VALUE;
+ }
+
+ mHardware = hw;
+
+ LOGV("AudioStreamInTegra::set(%d, %d, %u)", *pFormat, *pChannels, *pRate);
+ if (mFd >= 0) {
+ LOGE("Audio record already open");
+ return -EPERM;
+ }
+
+ // open audio input device
+ status_t status = ::open("/dev/msm_pcm_in", O_RDWR);
+ if (status < 0) {
+ LOGE("Cannot open /dev/msm_pcm_in errno: %d", errno);
+ goto Error;
+ }
+ mFd = status;
+
+ // configuration
+ LOGV("get config");
+ struct msm_audio_config config;
+ status = ioctl(mFd, AUDIO_GET_CONFIG, &config);
+ if (status < 0) {
+ LOGE("Cannot read config");
+ goto Error;
+ }
+
+ LOGV("set config");
+ config.channel_count = AudioSystem::popCount(*pChannels);
+ config.sample_rate = *pRate;
+ config.buffer_size = bufferSize();
+ config.buffer_count = 2;
+ config.codec_type = CODEC_TYPE_PCM;
+ status = ioctl(mFd, AUDIO_SET_CONFIG, &config);
+ if (status < 0) {
+ LOGE("Cannot set config");
+ if (ioctl(mFd, AUDIO_GET_CONFIG, &config) == 0) {
+ if (config.channel_count == 1) {
+ *pChannels = AudioSystem::CHANNEL_IN_MONO;
+ } else {
+ *pChannels = AudioSystem::CHANNEL_IN_STEREO;
+ }
+ *pRate = config.sample_rate;
+ }
+ goto Error;
+ }
+
+ LOGV("confirm config");
+ status = ioctl(mFd, AUDIO_GET_CONFIG, &config);
+ if (status < 0) {
+ LOGE("Cannot read config");
+ goto Error;
+ }
+ LOGV("buffer_size: %u", config.buffer_size);
+ LOGV("buffer_count: %u", config.buffer_count);
+ LOGV("channel_count: %u", config.channel_count);
+ LOGV("sample_rate: %u", config.sample_rate);
+
+ mDevices = devices;
+ mFormat = AUDIO_HW_IN_FORMAT;
+ mChannels = *pChannels;
+ mSampleRate = config.sample_rate;
+ mBufferSize = config.buffer_size;
+
+ //mHardware->setMicMute_nosync(false);
+ mState = AUDIO_INPUT_OPENED;
+
+ if (!acoustic)
+ return NO_ERROR;
+
+ audpre_index = calculate_audpre_table_index(mSampleRate);
+ tx_iir_index = (audpre_index * 2) + (hw->checkOutputStandby() ? 0 : 1);
+ LOGD("audpre_index = %d, tx_iir_index = %d\n", audpre_index, tx_iir_index);
+
+ /**
+ * If audio-preprocessing failed, we should not block record.
+ */
+ int (*msm72xx_set_audpre_params)(int, int);
+ msm72xx_set_audpre_params = (int (*)(int, int))::dlsym(acoustic, "msm72xx_set_audpre_params");
+ status = msm72xx_set_audpre_params(audpre_index, tx_iir_index);
+ if (status < 0)
+ LOGE("Cannot set audpre parameters");
+
+ int (*msm72xx_enable_audpre)(int, int, int);
+ msm72xx_enable_audpre = (int (*)(int, int, int))::dlsym(acoustic, "msm72xx_enable_audpre");
+ mAcoustics = acoustic_flags;
+ status = msm72xx_enable_audpre((int)acoustic_flags, audpre_index, tx_iir_index);
+ if (status < 0)
+ LOGE("Cannot enable audpre");
+
+ return NO_ERROR;
+
+Error:
+ if (mFd >= 0) {
+ ::close(mFd);
+ mFd = -1;
+ }
+ return status;
+#endif
+}
+
+AudioHardware::AudioStreamInTegra::~AudioStreamInTegra()
+{
+ LOGV("AudioStreamInTegra destructor");
+ standby();
+}
+
+ssize_t AudioHardware::AudioStreamInTegra::read( void* buffer, ssize_t bytes)
+{
+#if 1
+ return 0;
+#else
+ LOGV("AudioStreamInTegra::read(%p, %ld)", buffer, bytes);
+ if (!mHardware) return -1;
+
+ size_t count = bytes;
+ uint8_t* p = static_cast<uint8_t*>(buffer);
+
+ if (mState < AUDIO_INPUT_OPENED) {
+ Mutex::Autolock lock(mHardware->mLock);
+ if (set(mHardware, mDevices, &mFormat, &mChannels, &mSampleRate, mAcoustics) != NO_ERROR) {
+ return -1;
+ }
+ }
+
+ if (mState < AUDIO_INPUT_STARTED) {
+ mState = AUDIO_INPUT_STARTED;
+ // force routing to input device
+ mHardware->clearCurDevice();
+ mHardware->doRouting();
+ if (ioctl(mFd, AUDIO_START, 0)) {
+ LOGE("Error starting record");
+ standby();
+ return -1;
+ }
+ }
+
+ while (count) {
+ ssize_t bytesRead = ::read(mFd, buffer, count);
+ if (bytesRead >= 0) {
+ count -= bytesRead;
+ p += bytesRead;
+ } else {
+ if (errno != EAGAIN) return bytesRead;
+ mRetryCount++;
+ LOGW("EAGAIN - retrying");
+ }
+ }
+ return bytes;
+#endif
+}
+
+status_t AudioHardware::AudioStreamInTegra::standby()
+{
+#if 0
+ if (mState > AUDIO_INPUT_CLOSED) {
+ if (mFd >= 0) {
+ ::close(mFd);
+ mFd = -1;
+ }
+ mState = AUDIO_INPUT_CLOSED;
+ }
+ if (!mHardware) return -1;
+ // restore output routing if necessary
+ mHardware->clearCurDevice();
+ mHardware->doRouting();
+#endif
+ return NO_ERROR;
+}
+
+status_t AudioHardware::AudioStreamInTegra::dump(int fd, const Vector<String16>& args)
+{
+ const size_t SIZE = 256;
+ char buffer[SIZE];
+ String8 result;
+ result.append("AudioStreamInTegra::dump\n");
+ snprintf(buffer, SIZE, "\tsample rate: %d\n", sampleRate());
+ result.append(buffer);
+ snprintf(buffer, SIZE, "\tbuffer size: %d\n", bufferSize());
+ result.append(buffer);
+ snprintf(buffer, SIZE, "\tchannels: %d\n", channels());
+ result.append(buffer);
+ snprintf(buffer, SIZE, "\tformat: %d\n", format());
+ result.append(buffer);
+ snprintf(buffer, SIZE, "\tmHardware: %p\n", mHardware);
+ result.append(buffer);
+ snprintf(buffer, SIZE, "\tmFd count: %d\n", mFd);
+ result.append(buffer);
+ snprintf(buffer, SIZE, "\tmState: %d\n", mState);
+ result.append(buffer);
+ snprintf(buffer, SIZE, "\tmRetryCount: %d\n", mRetryCount);
+ result.append(buffer);
+ ::write(fd, result.string(), result.size());
+ return NO_ERROR;
+}
+
+status_t AudioHardware::AudioStreamInTegra::setParameters(const String8& keyValuePairs)
+{
+#if 1
+ return NO_ERROR;
+#else
+ AudioParameter param = AudioParameter(keyValuePairs);
+ String8 key = String8(AudioParameter::keyRouting);
+ status_t status = NO_ERROR;
+ int device;
+ LOGV("AudioStreamInTegra::setParameters() %s", keyValuePairs.string());
+
+ if (param.getInt(key, device) == NO_ERROR) {
+ LOGV("set input routing %x", device);
+ if (device & (device - 1)) {
+ status = BAD_VALUE;
+ } else {
+ mDevices = device;
+ status = mHardware->doRouting();
+ }
+ param.remove(key);
+ }
+
+ if (param.size()) {
+ status = BAD_VALUE;
+ }
+ return status;
+#endif
+}
+
+String8 AudioHardware::AudioStreamInTegra::getParameters(const String8& keys)
+{
+ AudioParameter param = AudioParameter(keys);
+ String8 value;
+ String8 key = String8(AudioParameter::keyRouting);
+
+ if (param.get(key, value) == NO_ERROR) {
+ LOGV("get routing %x", mDevices);
+ param.addInt(key, (int)mDevices);
+ }
+
+ LOGV("AudioStreamInTegra::getParameters() %s", param.toString().string());
+ return param.toString();
+}
+
+// ----------------------------------------------------------------------------
+
+extern "C" AudioHardwareInterface* createAudioHardware(void) {
+ return new AudioHardware();
+}
+
+}; // namespace android
diff --git a/libaudio/AudioHardware.h b/libaudio/AudioHardware.h
new file mode 100644
index 0000000..d87d560
--- /dev/null
+++ b/libaudio/AudioHardware.h
@@ -0,0 +1,195 @@
+/*
+** Copyright 2008, The Android Open-Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+#ifndef ANDROID_AUDIO_HARDWARE_H
+#define ANDROID_AUDIO_HARDWARE_H
+
+#include <stdint.h>
+#include <sys/types.h>
+
+#include <utils/threads.h>
+#include <utils/SortedVector.h>
+
+#include <hardware_legacy/AudioHardwareBase.h>
+
+extern "C" {
+#include <linux/msm_audio.h>
+}
+
+namespace android {
+
+#include "cpcap_audio.h"
+
+#define AUDIO_HW_NUM_OUT_BUF 4
+#define AUDIO_HW_OUT_LATENCY_MS 0
+
+class AudioHardware : public AudioHardwareBase
+{
+ class AudioStreamOutTegra;
+ class AudioStreamInTegra;
+
+public:
+ AudioHardware();
+ virtual ~AudioHardware();
+ virtual status_t initCheck();
+
+ virtual status_t setVoiceVolume(float volume);
+ virtual status_t setMasterVolume(float volume);
+
+ virtual status_t setMode(int mode);
+
+ // mic mute
+ virtual status_t setMicMute(bool state);
+ virtual status_t getMicMute(bool* state);
+
+ virtual status_t setParameters(const String8& keyValuePairs);
+ virtual String8 getParameters(const String8& keys);
+
+ // create I/O streams
+ virtual AudioStreamOut* openOutputStream(
+ uint32_t devices,
+ int *format=0,
+ uint32_t *channels=0,
+ uint32_t *sampleRate=0,
+ status_t *status=0);
+
+ virtual AudioStreamIn* openInputStream(
+
+ uint32_t devices,
+ int *format,
+ uint32_t *channels,
+ uint32_t *sampleRate,
+ status_t *status,
+ AudioSystem::audio_in_acoustics acoustics);
+
+ virtual void closeOutputStream(AudioStreamOut* out);
+ virtual void closeInputStream(AudioStreamIn* in);
+
+ virtual size_t getInputBufferSize(uint32_t sampleRate, int format, int channelCount);
+ void clearCurDevice() { mCurSndDevice = -1; }
+
+protected:
+ virtual status_t dump(int fd, const Vector<String16>& args);
+
+private:
+
+ status_t doAudioRouteOrMute(uint32_t device);
+ status_t setMicMute_nosync(bool state);
+ status_t checkMicMute();
+ status_t dumpInternals(int fd, const Vector<String16>& args);
+ uint32_t getInputSampleRate(uint32_t sampleRate);
+ bool checkOutputStandby();
+ status_t doRouting();
+ AudioStreamInTegra* getActiveInput_l();
+
+ class AudioStreamOutTegra : public AudioStreamOut {
+ public:
+ AudioStreamOutTegra();
+ virtual ~AudioStreamOutTegra();
+ status_t set(AudioHardware* mHardware,
+ uint32_t devices,
+ int *pFormat,
+ uint32_t *pChannels,
+ uint32_t *pRate);
+ virtual uint32_t sampleRate() const { return 44100; }
+ // must be 32-bit aligned - driver only seems to like 4800
+ virtual size_t bufferSize() const { return 4800; }
+ virtual uint32_t channels() const { return AudioSystem::CHANNEL_OUT_STEREO; }
+ virtual int format() const { return AudioSystem::PCM_16_BIT; }
+ virtual uint32_t latency() const { return (1000*AUDIO_HW_NUM_OUT_BUF*(bufferSize()/frameSize()))/sampleRate()+AUDIO_HW_OUT_LATENCY_MS; }
+ virtual status_t setVolume(float left, float right) { return INVALID_OPERATION; }
+ virtual ssize_t write(const void* buffer, size_t bytes);
+ virtual status_t standby();
+ virtual status_t dump(int fd, const Vector<String16>& args);
+ bool checkStandby();
+ virtual status_t setParameters(const String8& keyValuePairs);
+ virtual String8 getParameters(const String8& keys);
+ uint32_t devices() { return mDevices; }
+ virtual status_t getRenderPosition(uint32_t *dspFrames);
+
+ private:
+ AudioHardware* mHardware;
+ int mFd;
+ int mStartCount;
+ int mRetryCount;
+ bool mStandby;
+ uint32_t mDevices;
+ };
+
+ class AudioStreamInTegra : public AudioStreamIn {
+ public:
+ enum input_state {
+ AUDIO_INPUT_CLOSED,
+ AUDIO_INPUT_OPENED,
+ AUDIO_INPUT_STARTED
+ };
+
+ AudioStreamInTegra();
+ virtual ~AudioStreamInTegra();
+ status_t set(AudioHardware* mHardware,
+ uint32_t devices,
+ int *pFormat,
+ uint32_t *pChannels,
+ uint32_t *pRate,
+ AudioSystem::audio_in_acoustics acoustics);
+ virtual size_t bufferSize() const { return mBufferSize; }
+ virtual uint32_t channels() const { return mChannels; }
+ virtual int format() const { return mFormat; }
+ virtual uint32_t sampleRate() const { return mSampleRate; }
+ virtual status_t setGain(float gain) { return INVALID_OPERATION; }
+ virtual ssize_t read(void* buffer, ssize_t bytes);
+ virtual status_t dump(int fd, const Vector<String16>& args);
+ virtual status_t standby();
+ virtual status_t setParameters(const String8& keyValuePairs);
+ virtual String8 getParameters(const String8& keys);
+ virtual unsigned int getInputFramesLost() const { return 0; }
+ uint32_t devices() { return mDevices; }
+ int state() const { return mState; }
+
+ private:
+ AudioHardware* mHardware;
+ int mFd;
+ int mState;
+ int mRetryCount;
+ int mFormat;
+ uint32_t mChannels;
+ uint32_t mSampleRate;
+ size_t mBufferSize;
+ AudioSystem::audio_in_acoustics mAcoustics;
+ uint32_t mDevices;
+ };
+
+ static const uint32_t inputSamplingRates[];
+ bool mInit;
+ bool mMicMute;
+ bool mBluetoothNrec;
+ uint32_t mBluetoothId;
+ AudioStreamOutTegra* mOutput;
+ SortedVector <AudioStreamInTegra*> mInputs;
+
+ int mCurSndDevice;
+
+ friend class AudioStreamInTegra;
+ Mutex mLock;
+
+ int sndDevice;
+};
+
+// ----------------------------------------------------------------------------
+
+}; // namespace android
+
+#endif // ANDROID_AUDIO_HARDWARE_MSM72XX_H
diff --git a/libaudio/AudioPolicyManager.cpp b/libaudio/AudioPolicyManager.cpp
new file mode 100644
index 0000000..ca8f3bf
--- /dev/null
+++ b/libaudio/AudioPolicyManager.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "AudioPolicyManager"
+//#define LOG_NDEBUG 0
+#include <utils/Log.h>
+#include "AudioPolicyManager.h"
+#include <media/mediarecorder.h>
+
+namespace android {
+
+
+
+// ----------------------------------------------------------------------------
+// AudioPolicyManager for msm7k platform
+// Common audio policy manager code is implemented in AudioPolicyManagerBase class
+// ----------------------------------------------------------------------------
+
+// --- class factory
+
+
+extern "C" AudioPolicyInterface* createAudioPolicyManager(AudioPolicyClientInterface *clientInterface)
+{
+ return new AudioPolicyManager(clientInterface);
+}
+
+extern "C" void destroyAudioPolicyManager(AudioPolicyInterface *interface)
+{
+ delete interface;
+}
+
+}; // namespace android
diff --git a/libaudio/AudioPolicyManager.h b/libaudio/AudioPolicyManager.h
new file mode 100644
index 0000000..b591c1f
--- /dev/null
+++ b/libaudio/AudioPolicyManager.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <stdint.h>
+#include <sys/types.h>
+#include <utils/Timers.h>
+#include <utils/Errors.h>
+#include <utils/KeyedVector.h>
+#include <hardware_legacy/AudioPolicyManagerBase.h>
+
+
+namespace android {
+
+class AudioPolicyManager: public AudioPolicyManagerBase
+{
+
+public:
+ AudioPolicyManager(AudioPolicyClientInterface *clientInterface)
+ : AudioPolicyManagerBase(clientInterface) {}
+
+ virtual ~AudioPolicyManager() {}
+
+protected:
+ // true is current platform implements a back microphone
+ virtual bool hasBackMicrophone() const { return false; }
+#ifdef WITH_A2DP
+ // true is current platform supports suplication of notifications and ringtones over A2DP output
+ virtual bool a2dpUsedForSonification() const { return true; }
+#endif
+
+};
+};
diff --git a/libaudio/MODULE_LICENSE_APACHE2 b/libaudio/MODULE_LICENSE_APACHE2
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/libaudio/MODULE_LICENSE_APACHE2
diff --git a/libaudio/NOTICE b/libaudio/NOTICE
new file mode 100644
index 0000000..3237da6
--- /dev/null
+++ b/libaudio/NOTICE
@@ -0,0 +1,190 @@
+
+ Copyright (c) 2008-2009, The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
diff --git a/libaudio/cpcap_audio.h b/libaudio/cpcap_audio.h
new file mode 100644
index 0000000..3bcda24
--- /dev/null
+++ b/libaudio/cpcap_audio.h
@@ -0,0 +1,39 @@
+/* include/linux/cpcap_audio.h
+ *
+ * Copyright (C) 2010 Google, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef _CPCAP_AUDIO_H
+#define _CPCAP_AUDIO_H
+
+#include <asm/ioctl.h>
+
+#define CPCAP_AUDIO_MAGIC 'c'
+
+#define CPCAP_AUDIO_OUT_SPEAKER 0
+#define CPCAP_AUDIO_OUT_HEADSET 1
+#define CPCAP_AUDIO_OUT_MAX 1
+
+#define CPCAP_AUDIO_OUT_SET_OUTPUT _IOW(CPCAP_AUDIO_MAGIC, 0, unsigned int)
+
+#define CPCAP_AUDIO_OUT_VOL_MIN 0
+#define CPCAP_AUDIO_OUT_VOL_MAX 15
+
+#define CPCAP_AUDIO_OUT_SET_VOLUME _IOW(CPCAP_AUDIO_MAGIC, 1, unsigned int)
+
+#define CPCAP_AUDIO_OUT_GET_OUTPUT \
+ _IOR(CPCAP_AUDIO_MAGIC, 2, unsigned int *)
+#define CPCAP_AUDIO_OUT_GET_VOLUME \
+ _IOR(CPCAP_AUDIO_MAGIC, 3, unsigned int *)
+
+#endif/*_CPCAP_AUDIO_H*/
diff --git a/overlay/packages/apps/Phone/res/values/config.xml b/overlay/packages/apps/Phone/res/values/config.xml
new file mode 100644
index 0000000..23e2bce
--- /dev/null
+++ b/overlay/packages/apps/Phone/res/values/config.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- Stingray-specific phone app resources. -->
+<resources>
+
+ <!-- This device is not "voice capable"; it's data-only. -->
+ <bool name="voice_capable">false</bool>
+
+</resources>
diff --git a/ueventd.stingray.rc b/ueventd.stingray.rc
index 95c0b0c..80f8c8c 100644
--- a/ueventd.stingray.rc
+++ b/ueventd.stingray.rc
@@ -3,3 +3,4 @@
/dev/knvmap 0666 system system
/dev/nvmap 0666 system system
/dev/ov5650 0666 media camera
+/dev/audio* 0660 system audio