summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--audio-ril-interface/Android.mk27
-rw-r--r--audio-ril-interface/audio-ril-interface.cpp159
-rw-r--r--gta04.mk3
-rw-r--r--tinyalsa-audio.xml38
4 files changed, 224 insertions, 3 deletions
diff --git a/audio-ril-interface/Android.mk b/audio-ril-interface/Android.mk
new file mode 100644
index 0000000..2b77bf5
--- /dev/null
+++ b/audio-ril-interface/Android.mk
@@ -0,0 +1,27 @@
+LOCAL_PATH:= $(call my-dir)
+
+ifeq ($(TARGET_DEVICE),gta04)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libaudio-ril-interface
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := audio-ril-interface.cpp
+
+LOCAL_SHARED_LIBRARIES := \
+ liblog \
+ libcutils \
+ libtinyalsa
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)
+LOCAL_C_INCLUDES := $(LOCAL_PATH)
+LOCAL_C_INCLUDES += \
+ external/tinyalsa/include \
+ hardware/tinyalsa-audio/include/
+
+LOCAL_PRELINK_MODULE := false
+
+include $(BUILD_SHARED_LIBRARY)
+
+endif
diff --git a/audio-ril-interface/audio-ril-interface.cpp b/audio-ril-interface/audio-ril-interface.cpp
new file mode 100644
index 0000000..dba1832
--- /dev/null
+++ b/audio-ril-interface/audio-ril-interface.cpp
@@ -0,0 +1,159 @@
+/**
+ * Audio RIL Interface for GTA04
+ *
+ * Copyright (C) 2012 Paul Kocialkowski <contact@paulk.fr>
+ *
+ * Audio RIL Interface is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Audio RIL Interface 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Audio RIL Interface. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define LOG_TAG "AudioRILInterface"
+#include <cutils/log.h>
+#include <media/AudioSystem.h>
+#include <tinyalsa/asoundlib.h>
+
+#include <audio_ril_interface.h>
+
+#define DEVICE "Goldelico GTA04"
+
+/*
+ * Structures
+ */
+
+struct gta04_pdata {
+ struct pcm *voice_pcm;
+ int mode;
+};
+
+/*
+ * Functions
+ */
+
+void *gta04_pdata_create(void)
+{
+ struct gta04_pdata *pdata = NULL;
+
+ pdata = (struct gta04_pdata *) calloc(1, sizeof(struct gta04_pdata));
+ return (void *) pdata;
+}
+
+void gta04_pdata_destroy(void *pdata)
+{
+ if(pdata != NULL)
+ free(pdata);
+}
+
+int gta04_mode(void *pdata, int mode)
+{
+ struct pcm_config config;
+ struct gta04_pdata *gta04_pdata = NULL;
+ void *buffer = NULL;
+ int size = 0;
+
+ if(pdata == NULL)
+ return -1;
+
+ gta04_pdata = (struct gta04_pdata *) pdata;
+
+ if(mode == android::AudioSystem::MODE_IN_CALL && gta04_pdata->mode != android::AudioSystem::MODE_IN_CALL) {
+ LOGD("Starting call, activating voice!");
+
+ /*
+ * It seems that on GTA04 A4, microphone voice routing to
+ * the modem only works when a capture channel is active.
+ * Note that Android will close any existing capture channel.
+ */
+ memset(&config, 0, sizeof(config));
+
+ config.channels = 2;
+ config.rate = 44100;
+ config.period_size = 1056;
+ config.period_count = 2;
+ config.format = PCM_FORMAT_S16_LE;
+
+ gta04_pdata->voice_pcm = pcm_open(0, 0, PCM_IN, &config);
+ if(!gta04_pdata->voice_pcm || !pcm_is_ready(gta04_pdata->voice_pcm)) {
+ LOGE("Failed to open capture channel!");
+ }
+
+ size = pcm_get_buffer_size(gta04_pdata->voice_pcm);
+ buffer = malloc(size);
+
+ LOGD("Reading one sample");
+
+ pcm_read(gta04_pdata->voice_pcm, buffer, size);
+
+ free(buffer);
+ } else if(mode != android::AudioSystem::MODE_IN_CALL && gta04_pdata->mode == android::AudioSystem::MODE_IN_CALL) {
+ LOGD("Ending call, deactivating voice!");
+
+ if(gta04_pdata->voice_pcm != NULL)
+ pcm_close(gta04_pdata->voice_pcm);
+
+ gta04_pdata->voice_pcm = NULL;
+ }
+
+ gta04_pdata->mode = mode;
+
+ return 0;
+}
+
+int gta04_mic_mute(void *pdata, int mute)
+{
+ return 0;
+}
+
+int gta04_voice_volume(void *pdata, float volume)
+{
+ return 0;
+}
+
+int gta04_routing(void *pdata, int route)
+{
+ return 0;
+}
+
+/*
+ * Interface
+ */
+
+extern "C" {
+
+struct audio_ril_interface gta04_interface = {
+ NULL,
+ gta04_mode,
+ gta04_mic_mute,
+ gta04_voice_volume,
+ gta04_routing
+};
+
+struct audio_ril_interface *audio_ril_interface_open(void)
+{
+ LOGE("%s (%s)", __func__, DEVICE);
+
+ gta04_interface.pdata = gta04_pdata_create();
+
+ return &gta04_interface;
+}
+
+void audio_ril_interface_close(struct audio_ril_interface *interface_p)
+{
+ LOGE("%s (%s)", __func__, DEVICE);
+
+ gta04_pdata_destroy(interface_p->pdata);
+}
+
+}
diff --git a/gta04.mk b/gta04.mk
index bad70f2..00b9b94 100644
--- a/gta04.mk
+++ b/gta04.mk
@@ -27,7 +27,8 @@ PRODUCT_COPY_FILES += \
# Audio
PRODUCT_PACKAGES += \
libaudio \
- libaudiopolicy
+ libaudiopolicy \
+ libaudio-ril-inteface
PRODUCT_COPY_FILES += \
device/goldelico/gta04/tinyalsa-audio.xml:system/etc/tinyalsa-audio.xml
diff --git a/tinyalsa-audio.xml b/tinyalsa-audio.xml
index 49598c3..7a0bf22 100644
--- a/tinyalsa-audio.xml
+++ b/tinyalsa-audio.xml
@@ -9,12 +9,45 @@
<ctl name="DAC1 Analog Playback Volume" value="16" />
<ctl name="DAC2 Analog Playback Volume" value="16" />
- <ctl name="Analog Capture Volume" value="5" />
<ctl name="TX1 Digital Capture Volume" value="12" />
<ctl name="TX2 Digital Capture Volume" value="12" />
+
+ <ctl name="Analog Capture Volume" value="5" />
+ <ctl name="Voice route" value="Voice to SoC" />
+ </path>
+ </device>
+ <device type="output" name="earpiece" mode="normal">
+ <path name="enable">
+ <ctl name="Earpiece Mixer AudioL2" value="on" />
+ <ctl name="Earpiece Playback Volume" value="3" />
+ </path>
+ <path name="disable">
+ <ctl name="Earpiece Mixer AudioL2" value="off" />
+ <ctl name="Earpiece Playback Volume" value="0" />
</path>
</device>
- <device type="output" name="speaker">
+ <device type="output" name="earpiece" mode="in-call">
+ <path name="enable">
+ <ctl name="Voice route" value="Voice to twl4030" />
+ <ctl name="Earpiece Mixer Voice" value="on" />
+ <ctl name="Earpiece Playback Volume" value="3" />
+ <ctl name="DAC Voice Digital Downlink Volume" value="40" />
+ <ctl name="DAC Voice Analog Downlink Switch" value="on" />
+
+ <ctl name="Analog Left Main Mic Capture Switch" attr="mic" value="on" />
+ <ctl name="DAC Voice Analog Downlink Volume" attr="voice-volume" value="0-15" />
+ </path>
+ <path name="disable">
+ <ctl name="Voice route" value="Voice to SoC" />
+ <ctl name="Earpiece Mixer Voice" value="off" />
+ <ctl name="Earpiece Playback Volume" value="0" />
+ <ctl name="DAC Voice Digital Downlink Volume" value="0" />
+ <ctl name="DAC Voice Analog Downlink Switch" value="off" />
+
+ <ctl name="Analog Left Main Mic Capture Switch" attr="mic" value="off" />
+ </path>
+ </device>
+ <device type="output" name="speaker" mode="normal">
<path name="enable">
<ctl name="HandsfreeL Mux" value="AudioL2" />
<ctl name="HandsfreeR Mux" value="AudioR2" />
@@ -26,6 +59,7 @@
<ctl name="HandsfreeR Switch" value="off" />
</path>
</device>
+
<device type="input" name="builtin-mic">
<path name="enable">
<ctl name="Analog Left Main Mic Capture Switch" value="on" />