From 5201b38ca1d45c08aeb673dcc26442f863478c8d Mon Sep 17 00:00:00 2001 From: Jan Altensen Date: Sat, 11 Jul 2020 02:42:26 +0200 Subject: [PATCH] exynos9610: add libaudioproxy shim Change-Id: Ia33ba25ddda23eb015aea05d92d62d43d98c165d --- common.mk | 4 +++ extract-files.sh | 1 + shims/Android.mk | 18 ++++++++++ shims/libaudioproxy/Android.mk | 26 +++++++++++++++ shims/libaudioproxy/shim.cpp | 60 ++++++++++++++++++++++++++++++++++ 5 files changed, 109 insertions(+) create mode 100644 shims/Android.mk create mode 100644 shims/libaudioproxy/Android.mk create mode 100644 shims/libaudioproxy/shim.cpp diff --git a/common.mk b/common.mk index 787e58c..582fd39 100644 --- a/common.mk +++ b/common.mk @@ -225,6 +225,10 @@ PRODUCT_COPY_FILES += \ $(COMMON_PATH)/configs/sensors/hals.conf:$(TARGET_COPY_OUT_VENDOR)/etc/sensors/hals.conf \ $(COMMON_PATH)/configs/sensors/mot_sensor_settings.json:$(TARGET_COPY_OUT_VENDOR)/etc/sensors/mot_sensor_settings.json +# Shims +PRODUCT_PACKAGES += \ + libaudioproxy_shim + # Thermal PRODUCT_COPY_FILES += \ $(COMMON_PATH)/configs/thermal/exynos-thermal.conf:$(TARGET_COPY_OUT_VENDOR)/exynos-thermal.conf \ diff --git a/extract-files.sh b/extract-files.sh index 7be3dd1..c0be655 100755 --- a/extract-files.sh +++ b/extract-files.sh @@ -71,5 +71,6 @@ extract "${MY_DIR}/proprietary-files-vendor.txt" "${SRC}" \ # Fix proprietary blobs BLOB_ROOT="$LINEAGE_ROOT"/vendor/"$VENDOR"/"$DEVICE_COMMON"/proprietary patchelf --replace-needed libmedia.so libmedia_ims.so $BLOB_ROOT/lib64/libmediaadaptor.so +patchelf --add-needed libaudioproxy_shim.so $BLOB_ROOT/vendor/lib/libaudioproxy.so "${MY_DIR}/setup-makefiles.sh" diff --git a/shims/Android.mk b/shims/Android.mk new file mode 100644 index 0000000..23e21b6 --- /dev/null +++ b/shims/Android.mk @@ -0,0 +1,18 @@ +# +# Copyright (C) 2020 The LineageOS 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. + +LOCAL_PATH := $(call my-dir) + +include $(call all-subdir-makefiles,$(LOCAL_PATH)) diff --git a/shims/libaudioproxy/Android.mk b/shims/libaudioproxy/Android.mk new file mode 100644 index 0000000..81625a3 --- /dev/null +++ b/shims/libaudioproxy/Android.mk @@ -0,0 +1,26 @@ +# +# Copyright (C) 2020 The LineageOS 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. + +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) +LOCAL_SRC_FILES := shim.cpp + +LOCAL_MODULE := libaudioproxy_shim +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := SHARED_LIBRARIES +LOCAL_PROPRIETARY_MODULE := true + +include $(BUILD_SHARED_LIBRARY) diff --git a/shims/libaudioproxy/shim.cpp b/shims/libaudioproxy/shim.cpp new file mode 100644 index 0000000..5c9c33f --- /dev/null +++ b/shims/libaudioproxy/shim.cpp @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2020 The LineageOS 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 +#include +#include + +extern "C" int get_dai_link(int /*param_1*/,int /*param_2*/) { + /*if (param_1 != 0) { + __android_log_print(2,"audio_route","requested PCM for %d",param_2); + }*/ + return -1; +} + +// possibly audio_route_missing_ctl(struct audio_route *ar) +extern "C" int audio_route_missing_ctl(int *param_1) { + if (param_1 == 0) { + //__android_log_print(6,"audio_route","invalid audio_route"); + return 0; + } + int a = *(int *)(param_1 + 0x18); + return a; +} + +struct mixer { + int fd; + struct snd_ctl_card_info card_info; + struct snd_ctl_elem_info *elem_info; + struct mixer_ctl *ctl; + unsigned int count; +}; + +struct audio_route { + struct mixer *mixer; + unsigned int num_mixer_ctls; + struct mixer_state *mixer_state; + + unsigned int mixer_path_size; + unsigned int num_mixer_paths; + struct mixer_path *mixer_path; +}; + +extern "C" int mixer_read_event(struct mixer *mixer, struct snd_ctl_event *ev) { + ssize_t count = read(mixer->fd, ev, sizeof(*ev)); + + return (count >= 0) ? 0 : -errno; +} \ No newline at end of file -- 2.20.1