exynos9610: add libaudioproxy shim
authorJan Altensen <info@stricted.net>
Sat, 11 Jul 2020 00:42:26 +0000 (02:42 +0200)
committerJan Altensen <info@stricted.net>
Sat, 17 Oct 2020 14:30:56 +0000 (16:30 +0200)
Change-Id: Ia33ba25ddda23eb015aea05d92d62d43d98c165d

common.mk
extract-files.sh
shims/Android.mk [new file with mode: 0644]
shims/libaudioproxy/Android.mk [new file with mode: 0644]
shims/libaudioproxy/shim.cpp [new file with mode: 0644]

index 787e58ccf74301af8b54fd2f8126ed450b1ddc21..582fd3922b5550e1b74d036091dfec4a649c2b29 100644 (file)
--- 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 \
index 7be3dd18433a9af9462df9b319e1196162f58736..c0be6553e6a0e8ef312ee8749933f6ef1a1e8855 100755 (executable)
@@ -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 (file)
index 0000000..23e21b6
--- /dev/null
@@ -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 (file)
index 0000000..81625a3
--- /dev/null
@@ -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 (file)
index 0000000..5c9c33f
--- /dev/null
@@ -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 <errno.h>
+#include <unistd.h>
+#include <sound/asound.h>
+
+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