summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kocialkowski <contact@paulk.fr>2012-11-08 14:26:52 +0100
committerPaul Kocialkowski <contact@paulk.fr>2012-11-08 14:26:52 +0100
commit2e6b9a121300c12b76ecfa0854347a85dc86cb60 (patch)
tree28910957850839b0c29d7d9b25a5656d498a5b6b
parent85b389dedc2d16493f9753c6091e4bd1fd98a2c7 (diff)
downloaddevice_samsung_aries-common-2e6b9a121300c12b76ecfa0854347a85dc86cb60.zip
device_samsung_aries-common-2e6b9a121300c12b76ecfa0854347a85dc86cb60.tar.gz
device_samsung_aries-common-2e6b9a121300c12b76ecfa0854347a85dc86cb60.tar.bz2
Switch to Samsung-RIL and Samsung-RIL-Client
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
-rw-r--r--device_base.mk6
-rw-r--r--libaudio/AudioHardware.cpp8
-rw-r--r--samsung-ril-client/Android.mk18
-rw-r--r--samsung-ril-client/samsung-ril-client.c313
4 files changed, 341 insertions, 4 deletions
diff --git a/device_base.mk b/device_base.mk
index 2f7a8e4..fd8914a 100644
--- a/device_base.mk
+++ b/device_base.mk
@@ -102,6 +102,12 @@ PRODUCT_PACKAGES += \
audio.a2dp.default \
libs3cjpeg
+# RIL/RIL client/libsamsung-ipc
+PRODUCT_PACKAGES += libsamsung-ril \
+ libsamsung-ril-client \
+ ipc-modemctrl
+
+
# Libs
PRODUCT_PACKAGES += \
libstagefrighthw
diff --git a/libaudio/AudioHardware.cpp b/libaudio/AudioHardware.cpp
index 4d1661e..d573087 100644
--- a/libaudio/AudioHardware.cpp
+++ b/libaudio/AudioHardware.cpp
@@ -156,10 +156,10 @@ status_t AudioHardware::initCheck()
void AudioHardware::loadRILD(void)
{
- mSecRilLibHandle = dlopen("libsecril-client.so", RTLD_NOW);
+ mSecRilLibHandle = dlopen("libsamsung-ril-client.so", RTLD_NOW);
if (mSecRilLibHandle) {
- LOGV("libsecril-client.so is loaded");
+ LOGV("libsamsung-ril-client.so is loaded");
openClientRILD = (HRilClient (*)(void))
dlsym(mSecRilLibHandle, "OpenClient_RILD");
@@ -181,7 +181,7 @@ void AudioHardware::loadRILD(void)
if (!openClientRILD || !disconnectRILD || !closeClientRILD ||
!isConnectedRILD || !connectRILD ||
!setCallVolume || !setCallAudioPath || !setCallClockSync) {
- LOGE("Can't load all functions from libsecril-client.so");
+ LOGE("Can't load all functions from libsamsung-ril-client.so");
dlclose(mSecRilLibHandle);
mSecRilLibHandle = NULL;
@@ -195,7 +195,7 @@ void AudioHardware::loadRILD(void)
}
}
} else {
- LOGE("Can't load libsecril-client.so");
+ LOGE("Can't load libsamsung-ril-client.so");
}
}
diff --git a/samsung-ril-client/Android.mk b/samsung-ril-client/Android.mk
new file mode 100644
index 0000000..b1050e7
--- /dev/null
+++ b/samsung-ril-client/Android.mk
@@ -0,0 +1,18 @@
+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
new file mode 100644
index 0000000..fa0d146
--- /dev/null
+++ b/samsung-ril-client/samsung-ril-client.c
@@ -0,0 +1,313 @@
+/**
+ * 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;
+}