From 14c2dfe8ad2ef4beffee05e26af09f6bdd1b0fbb Mon Sep 17 00:00:00 2001 From: Paul Kocialkowski Date: Tue, 31 Dec 2013 20:39:05 +0100 Subject: Audio-RIL-Interface Signed-off-by: Paul Kocialkowski --- audio-ril-interface/Android.mk | 35 ++++++ audio-ril-interface/audio-ril-interface.c | 200 ++++++++++++++++++++++++++++++ device.mk | 4 + 3 files changed, 239 insertions(+) create mode 100644 audio-ril-interface/Android.mk create mode 100644 audio-ril-interface/audio-ril-interface.c diff --git a/audio-ril-interface/Android.mk b/audio-ril-interface/Android.mk new file mode 100644 index 0000000..eb9313d --- /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 . +# + +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/tuna/audio/ + +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..6f010e0 --- /dev/null +++ b/audio-ril-interface/audio-ril-interface.c @@ -0,0 +1,200 @@ +/* + * 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 . + */ + +#include + +#define LOG_TAG "Audio-RIL-Interface" +#include + +#include + +#include +#include + +void *OpenClient_RILD(void) +{ + struct srs_client *client = NULL; + + ALOGD("%s()", __func__); + + signal(SIGPIPE, SIG_IGN); + + srs_client_create(&client); + + return (void *) client; +} + +int Connect_RILD(void *data) +{ + struct srs_client *client; + int rc; + + ALOGD("%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) { + ALOGE("%s: Failed to open SRS client", __func__); + return RIL_CLIENT_ERR_CONNECT; + } + + rc = srs_client_ping(client); + if (rc < 0) { + ALOGE("%s: Failed to ping SRS client", __func__); + return RIL_CLIENT_ERR_UNKNOWN; + } + + return RIL_CLIENT_ERR_SUCCESS; +} + +int Disconnect_RILD(void *data) +{ + struct srs_client *client; + int rc; + + ALOGD("%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) { + ALOGE("%s: Failed to close SRS client", __func__); + return RIL_CLIENT_ERR_INVAL; + } + + return RIL_CLIENT_ERR_SUCCESS; +} + +int CloseClient_RILD(void *data) +{ + struct srs_client *client; + int rc; + + ALOGD("%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(void *data) +{ + struct srs_client *client; + int rc; + + ALOGD("%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) { + ALOGE("%s: Failed to ping SRS client", __func__); + return 0; + } + + return 1; +} + +int SetCallVolume(void *data, enum ril_sound_type type, int level) +{ + struct srs_client *client; + struct srs_snd_call_volume call_volume; + int rc; + + ALOGD("%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(void *data, enum ril_audio_path path) +{ + struct srs_client *client; + struct srs_snd_call_audio_path call_audio_path; + int rc; + + ALOGD("%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(void *data, enum ril_clock_state condition) +{ + struct srs_client *client; + struct srs_snd_call_clock_sync call_clock_sync; + int rc; + + ALOGD("%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; +} + +int RegisterUnsolicitedHandler(void *data, int command, void *callback) +{ + ALOGD("%s(%p, %d, %p)", __func__, data, command, callback); + + return RIL_CLIENT_ERR_SUCCESS; +} diff --git a/device.mk b/device.mk index 847974c..ef56715 100644 --- a/device.mk +++ b/device.mk @@ -24,6 +24,10 @@ DEVICE_PACKAGE_OVERLAYS := device/samsung/maguro/overlay PRODUCT_COPY_FILES := \ frameworks/native/data/etc/android.hardware.telephony.gsm.xml:system/etc/permissions/android.hardware.telephony.gsm.xml +# Audio +PRODUCT_PACKAGES += \ + libaudio-ril-interface + # RIL PRODUCT_PACKAGES += \ libsamsung-ril -- cgit v1.1