summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kocialkowski <contact@paulk.fr>2013-03-07 14:08:23 (GMT)
committerPaul Kocialkowski <contact@paulk.fr>2013-03-07 20:53:17 (GMT)
commit2f0942e4df16247863dd5717b7e61535bcd11cf1 (patch)
tree5764ba03c7ca6339ba3ff23bf211ee1de248fa58
parentf8d4236a32dcd298ed8c0fd42d5349eae848e0c5 (diff)
downloaddevice_samsung_crespo-2f0942e4df16247863dd5717b7e61535bcd11cf1.zip
device_samsung_crespo-2f0942e4df16247863dd5717b7e61535bcd11cf1.tar.gz
device_samsung_crespo-2f0942e4df16247863dd5717b7e61535bcd11cf1.tar.bz2
Audio-RIL-Interface
Change-Id: I797e43fd217a8bba07ebea9a3cbf47c5c209d0de Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
-rw-r--r--audio-ril-interface/Android.mk35
-rw-r--r--audio-ril-interface/audio-ril-interface.c193
-rw-r--r--device_base.mk11
-rw-r--r--libaudio/AudioHardware.cpp8
-rw-r--r--samsung-ril-client/Android.mk18
-rw-r--r--samsung-ril-client/samsung-ril-client.c313
6 files changed, 238 insertions, 340 deletions
diff --git a/audio-ril-interface/Android.mk b/audio-ril-interface/Android.mk
new file mode 100644
index 0000000..ccb4af5
--- /dev/null
+++ b/audio-ril-interface/Android.mk
@@ -0,0 +1,35 @@
+#
+# Copyright (C) 2013 Paul Kocialkowski
+#
+# This program 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.
+#
+# 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.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := audio-ril-interface.c
+
+LOCAL_C_INCLUDES := \
+ hardware/ril/samsung-ril/include \
+ hardware/ril/samsung-ril/srs-client/include \
+ device/samsung/crespo/libaudio/
+
+LOCAL_SHARED_LIBRARIES := liblog libcutils libsrs-client
+LOCAL_PRELINK_MODULE := false
+
+LOCAL_MODULE := libaudio-ril-interface
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/audio-ril-interface/audio-ril-interface.c b/audio-ril-interface/audio-ril-interface.c
new file mode 100644
index 0000000..98b66ac
--- /dev/null
+++ b/audio-ril-interface/audio-ril-interface.c
@@ -0,0 +1,193 @@
+/*
+ * Copyright (C) 2013 Paul Kocialkowski
+ *
+ * This program 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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdlib.h>
+
+#define LOG_TAG "Audio-RIL-Interface"
+#include <cutils/log.h>
+
+#include <secril-client.h>
+
+#include <samsung-ril-socket.h>
+#include <srs-client.h>
+
+HRilClient OpenClient_RILD(void)
+{
+ struct srs_client *client = NULL;
+
+ LOGE("%s()", __func__);
+
+ signal(SIGPIPE, SIG_IGN);
+
+ srs_client_create(&client);
+
+ return (void *) client;
+}
+
+int Connect_RILD(HRilClient data)
+{
+ struct srs_client *client;
+ int rc;
+
+ LOGE("%s(%p)", __func__, data);
+
+ if (data == NULL)
+ return RIL_CLIENT_ERR_INVAL;
+
+ client = (struct srs_client *) data;
+
+ rc = srs_client_open(client);
+ if (rc < 0) {
+ LOGE("%s: Failed to open SRS client", __func__);
+ return RIL_CLIENT_ERR_CONNECT;
+ }
+
+ rc = srs_client_ping(client);
+ if (rc < 0) {
+ LOGE("%s: Failed to ping SRS client", __func__);
+ return RIL_CLIENT_ERR_UNKNOWN;
+ }
+
+ return RIL_CLIENT_ERR_SUCCESS;
+}
+
+int Disconnect_RILD(HRilClient data)
+{
+ struct srs_client *client;
+ int rc;
+
+ LOGE("%s(%p)", __func__, data);
+
+ if (data == NULL)
+ return RIL_CLIENT_ERR_INVAL;
+
+ client = (struct srs_client *) data;
+
+ rc = srs_client_close(client);
+ if (rc < 0) {
+ LOGE("%s: Failed to close SRS client", __func__);
+ return RIL_CLIENT_ERR_INVAL;
+ }
+
+ return RIL_CLIENT_ERR_SUCCESS;
+}
+
+int CloseClient_RILD(HRilClient data)
+{
+ struct srs_client *client;
+ int rc;
+
+ LOGE("%s(%p)", __func__, data);
+
+ if (data == NULL)
+ return RIL_CLIENT_ERR_INVAL;
+
+ client = (struct srs_client *) data;
+
+ srs_client_destroy(client);
+
+ return RIL_CLIENT_ERR_SUCCESS;
+}
+
+int isConnected_RILD(HRilClient data)
+{
+ struct srs_client *client;
+ int rc;
+
+ LOGE("%s(%p)", __func__, data);
+
+ if (data == NULL)
+ return RIL_CLIENT_ERR_INVAL;
+
+ client = (struct srs_client *) data;
+
+ rc = srs_client_ping(client);
+ if (rc < 0) {
+ LOGE("%s: Failed to ping SRS client", __func__);
+ return 0;
+ }
+
+ return 1;
+}
+
+int SetCallVolume(HRilClient data, SoundType type, int level)
+{
+ struct srs_client *client;
+ struct srs_snd_call_volume call_volume;
+ int rc;
+
+ LOGE("%s(%p, %d, %d)", __func__, data, type, level);
+
+ if (data == NULL)
+ return RIL_CLIENT_ERR_INVAL;
+
+ client = (struct srs_client *) data;
+
+ call_volume.type = (enum srs_snd_type) type;
+ call_volume.volume = level;
+
+ rc = srs_client_send(client, SRS_SND_SET_CALL_VOLUME, &call_volume, sizeof(call_volume));
+ if (rc < 0)
+ return RIL_CLIENT_ERR_UNKNOWN;
+
+ return RIL_CLIENT_ERR_SUCCESS;
+}
+
+
+int SetCallAudioPath(HRilClient data, AudioPath path)
+{
+ struct srs_client *client;
+ struct srs_snd_call_audio_path call_audio_path;
+ int rc;
+
+ LOGE("%s(%p, %d)", __func__, data, path);
+
+ if (data == NULL)
+ return RIL_CLIENT_ERR_INVAL;
+
+ client = (struct srs_client *) data;
+
+ call_audio_path.path = path;
+
+ rc = srs_client_send(client, SRS_SND_SET_CALL_AUDIO_PATH, &call_audio_path, sizeof(call_audio_path));
+ if (rc < 0)
+ return RIL_CLIENT_ERR_UNKNOWN;
+
+ return RIL_CLIENT_ERR_SUCCESS;
+}
+
+int SetCallClockSync(HRilClient data, SoundClockCondition condition)
+{
+ struct srs_client *client;
+ struct srs_snd_call_clock_sync call_clock_sync;
+ int rc;
+
+ LOGE("%s(%p, %d)", __func__, data, condition);
+
+ if (data == NULL)
+ return RIL_CLIENT_ERR_INVAL;
+
+ client = (struct srs_client *) data;
+
+ call_clock_sync.sync = condition;
+
+ rc = srs_client_send(client, SRS_SND_SET_CALL_CLOCK_SYNC, &call_clock_sync, sizeof(call_clock_sync));
+ if (rc < 0)
+ return RIL_CLIENT_ERR_UNKNOWN;
+
+ return RIL_CLIENT_ERR_SUCCESS;
+}
diff --git a/device_base.mk b/device_base.mk
index eb37550..e43e586 100644
--- a/device_base.mk
+++ b/device_base.mk
@@ -127,12 +127,13 @@ PRODUCT_PACKAGES += \
PRODUCT_PACKAGES += \
camera.herring
-# audio
+# Audio
PRODUCT_PACKAGES += \
audio_policy.herring \
audio.primary.herring \
audio.a2dp.default \
- libaudioutils
+ libaudioutils \
+ libaudio-ril-interface
# NFC
PRODUCT_PACKAGES += \
@@ -143,9 +144,9 @@ PRODUCT_PACKAGES += \
libcamera \
com.android.future.usb.accessory
-# RIL/RIL client/libsamsung-ipc
-PRODUCT_PACKAGES += libsamsung-ril \
- libsamsung-ril-client \
+# RIL
+PRODUCT_PACKAGES += \
+ libsamsung-ril \
ipc-modemctrl
# Sensors
diff --git a/libaudio/AudioHardware.cpp b/libaudio/AudioHardware.cpp
index e501463..ab403af 100644
--- a/libaudio/AudioHardware.cpp
+++ b/libaudio/AudioHardware.cpp
@@ -145,10 +145,10 @@ status_t AudioHardware::initCheck()
void AudioHardware::loadRILD(void)
{
- mSecRilLibHandle = dlopen("libsamsung-ril-client.so", RTLD_NOW);
+ mSecRilLibHandle = dlopen("libaudio-ril-interface.so", RTLD_NOW);
if (mSecRilLibHandle) {
- LOGV("libsamsung-ril-client.so is loaded");
+ LOGV("libaudio-ril-interface.so is loaded");
openClientRILD = (HRilClient (*)(void))
dlsym(mSecRilLibHandle, "OpenClient_RILD");
@@ -170,7 +170,7 @@ void AudioHardware::loadRILD(void)
if (!openClientRILD || !disconnectRILD || !closeClientRILD ||
!isConnectedRILD || !connectRILD ||
!setCallVolume || !setCallAudioPath || !setCallClockSync) {
- LOGE("Can't load all functions from libsamsung-ril-client.so");
+ LOGE("Can't load all functions from libaudio-ril-interface.so");
dlclose(mSecRilLibHandle);
mSecRilLibHandle = NULL;
@@ -184,7 +184,7 @@ void AudioHardware::loadRILD(void)
}
}
} else {
- LOGE("Can't load libsamsung-ril-client.so");
+ LOGE("Can't load libaudio-ril-interface.so");
}
}
diff --git a/samsung-ril-client/Android.mk b/samsung-ril-client/Android.mk
deleted file mode 100644
index b1050e7..0000000
--- a/samsung-ril-client/Android.mk
+++ /dev/null
@@ -1,18 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libsamsung-ril-client
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := samsung-ril-client.c
-
-LOCAL_SHARED_LIBRARIES := liblog libcutils
-LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)
-LOCAL_C_INCLUDES := $(LOCAL_PATH)
-LOCAL_C_INCLUDES += hardware/ril/samsung-ril/include \
- device/samsung/crespo/libaudio/
-
-LOCAL_PRELINK_MODULE := false
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/samsung-ril-client/samsung-ril-client.c b/samsung-ril-client/samsung-ril-client.c
deleted file mode 100644
index fa0d146..0000000
--- a/samsung-ril-client/samsung-ril-client.c
+++ /dev/null
@@ -1,313 +0,0 @@
-/**
- * Samsung RIL Client (Samsung RIL Socket Client-side implementation)
- *
- * Copyright (C) 2011 Paul Kocialkowski <contact@paulk.fr>
- *
- * samsung-ril-client 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.
- *
- * samsung-ril-client 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 samsung-ril-client. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <sys/select.h>
-
-#include <signal.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <cutils/sockets.h>
-
-#define LOG_TAG "SRS-Client"
-#include <cutils/log.h>
-
-#include <secril-client.h>
-#include <samsung-ril-socket.h>
-
-int srs_send_message(HRilClient client, struct srs_message *message)
-{
- int client_fd = *((int *) client->prv);
- fd_set fds;
-
- struct srs_header header;
- void *data;
-
- int rc;
-
- header.length = message->data_len + sizeof(header);
- header.group = SRS_GROUP(message->command);
- header.index = SRS_INDEX(message->command);
-
- data = malloc(header.length);
- memset(data, 0, header.length);
-
- memcpy(data, &header, sizeof(header));
- memcpy((void *) (data + sizeof(header)), message->data, message->data_len);
-
- FD_ZERO(&fds);
- FD_SET(client_fd, &fds);
-
- // We can't rely on select RC
- select(client_fd + 1, NULL, &fds, NULL, NULL);
-
- rc = write(client_fd, data, header.length);
-
- free(data);
-
- return rc;
-}
-
-int srs_send(HRilClient client, unsigned short command, void *data, int data_len)
-{
- struct srs_message message;
- int rc;
-
- LOGE("%s", __func__);
-
- message.command = command;
- message.data = data;
- message.data_len = data_len;
-
- rc = srs_send_message(client, &message);
-
- return rc;
-}
-
-int srs_recv_timed(HRilClient client, struct srs_message *message, long sec, long usec)
-{
- void *raw_data = malloc(SRS_DATA_MAX_SIZE);
- struct srs_header *header;
- int rc;
-
- int client_fd = *((int *) client->prv);
- struct timeval timeout;
- fd_set fds;
-
- FD_ZERO(&fds);
- FD_SET(client_fd, &fds);
-
- timeout.tv_sec = sec;
- timeout.tv_usec = usec;
-
- select(client_fd + 1, &fds, NULL, NULL, &timeout);
-
- rc = read(client_fd, raw_data, SRS_DATA_MAX_SIZE);
- if(rc < sizeof(struct srs_header)) {
- return -1;
- }
-
- header = raw_data;
-
- message->command = SRS_COMMAND(header);
- message->data_len = header->length - sizeof(struct srs_header);
- message->data = malloc(message->data_len);
-
- memcpy(message->data, raw_data + sizeof(struct srs_header), message->data_len);
-
- free(raw_data);
-
- return 0;
-}
-
-int srs_recv(HRilClient client, struct srs_message *message)
-{
- return srs_recv_timed(client, message, 0, 0);
-}
-
-int srs_ping(HRilClient client)
-{
- int caffe_w = SRS_CONTROL_CAFFE;
- int caffe_r = 0;
- int rc = 0;
-
- struct srs_message message;
-
- rc = srs_send(client, SRS_CONTROL_PING, &caffe_w, sizeof(caffe_w));
-
- if(rc < 0) {
- return -1;
- }
-
- rc = srs_recv_timed(client, &message, 0, 300);
-
- if(rc < 0) {
- return -1;
- }
-
- if(message.data == NULL)
- return -1;
-
- caffe_r = *((int *) message.data);
-
- if(caffe_r == SRS_CONTROL_CAFFE) {
- LOGD("Caffe is ready!");
- rc = 0;
- } else {
- LOGE("Caffe went wrong!");
- rc = -1;
- }
-
- free(message.data);
- return rc;
-}
-
-HRilClient OpenClient_RILD(void)
-{
- HRilClient client;
- int *client_fd_p = NULL;
-
- LOGE("%s", __func__);
-
- signal(SIGPIPE, SIG_IGN);
-
- client = malloc(sizeof(struct RilClient));
- client->prv = malloc(sizeof(int));
- client_fd_p = (int *) client->prv;
- *client_fd_p = -1;
-
- return client;
-}
-
-int Connect_RILD(HRilClient client)
-{
- int t = 0;
- int fd = -1;
- int rc;
- int *client_fd_p = (int *) client->prv;
-
- LOGE("%s", __func__);
-
-socket_connect:
- while(t < 5) {
- fd = socket_local_client(SRS_SOCKET_NAME, ANDROID_SOCKET_NAMESPACE_ABSTRACT, SOCK_STREAM);
-
- if(fd > 0)
- break;
-
- LOGE("Socket creation to RIL failed: trying another time");
-
- t++;
- usleep(300);
- }
-
- if(fd < 0) {
- LOGE("Socket creation to RIL failed too many times");
- return RIL_CLIENT_ERR_CONNECT;
- }
-
- *client_fd_p = fd;
-
- LOGE("Socket creation done, sending ping");
-
- rc = srs_ping(client);
-
- if(rc < 0) {
- LOGE("Ping failed!");
- goto socket_connect;
- } else {
- LOGD("Ping went alright");
- }
-
- return RIL_CLIENT_ERR_SUCCESS;
-}
-
-int Disconnect_RILD(HRilClient client)
-{
- int client_fd = *((int *) client->prv);
-
- LOGE("%s", __func__);
-
- close(client_fd);
-
- return RIL_CLIENT_ERR_SUCCESS;
-}
-
-int CloseClient_RILD(HRilClient client)
-{
- int *client_fd_p = (int *) client->prv;
-
- LOGE("%s", __func__);
-
- if(client_fd_p != NULL)
- free(client_fd_p);
-
- free(client);
-
- return RIL_CLIENT_ERR_SUCCESS;
-}
-
-int isConnected_RILD(HRilClient client)
-{
- int client_fd = *((int *) client->prv);
- int rc;
-
- LOGE("%s", __func__);
-
- if(client_fd < 0) {
- return 0;
- }
-
- rc = srs_ping(client);
-
- if(rc < 0) {
- LOGE("Ping failed!");
- close(client_fd);
-
- return 0;
- } else {
- LOGD("Ping went alright");
- }
-
- return 1;
-}
-
-int SetCallVolume(HRilClient client, SoundType type, int vol_level)
-{
- struct srs_snd_call_volume call_volume;
-
- LOGD("Asking call volume");
-
- call_volume.type = (enum srs_snd_type) type;
- call_volume.volume = vol_level;
-
- srs_send(client, SRS_SND_SET_CALL_VOLUME, (void *) &call_volume, sizeof(call_volume));
-
- return RIL_CLIENT_ERR_SUCCESS;
-}
-
-
-int SetCallAudioPath(HRilClient client, AudioPath path)
-{
- srs_send(client, SRS_SND_SET_CALL_AUDIO_PATH, (void *) &path, sizeof(enum srs_snd_path));
-
- LOGD("Asking audio path");
-
- return RIL_CLIENT_ERR_SUCCESS;
-}
-
-int SetCallClockSync(HRilClient client, SoundClockCondition condition)
-{
- unsigned char data = condition;
-
- LOGD("Asking clock sync");
-
- srs_send(client, SRS_SND_SET_CALL_CLOCK_SYNC, &data, sizeof(data));
-
- return RIL_CLIENT_ERR_SUCCESS;
-}