From 54e2de33b0a35c1b5df27662b6e4b6b79ed0e790 Mon Sep 17 00:00:00 2001 From: Lukas0610 Date: Mon, 19 Feb 2018 16:45:52 +0100 Subject: [PATCH] universal7580: libshims: add OMX shim Change-Id: I103aa42a8384da0cbd8ee2cfa8af2c543479b3fa --- .../android.hardware.media.omx@1.0-service.rc | 7 +++ device-common.mk | 4 ++ libshims/libExynosOMX/Android.mk | 29 +++++++++ .../libExynosOMX/Exynos_OMX_VdecControl.c | 61 +++++++++++++++++++ 4 files changed, 101 insertions(+) create mode 100644 configs/init/android.hardware.media.omx@1.0-service.rc create mode 100644 libshims/libExynosOMX/Android.mk create mode 100644 libshims/libExynosOMX/Exynos_OMX_VdecControl.c diff --git a/configs/init/android.hardware.media.omx@1.0-service.rc b/configs/init/android.hardware.media.omx@1.0-service.rc new file mode 100644 index 0000000..2f2d31c --- /dev/null +++ b/configs/init/android.hardware.media.omx@1.0-service.rc @@ -0,0 +1,7 @@ +service mediacodec /vendor/bin/hw/android.hardware.media.omx@1.0-service + class main + user mediacodec + group camera drmrpc mediadrm + ioprio rt 4 + writepid /dev/cpuset/foreground/tasks + setenv LD_PRELOAD "/vendor/lib/libExynosOMX_shim.so" diff --git a/device-common.mk b/device-common.mk index 9b45b7d..5492cab 100644 --- a/device-common.mk +++ b/device-common.mk @@ -116,6 +116,10 @@ PRODUCT_PACKAGES += \ android.hardware.wifi@1.0 \ android.hardware.wifi@1.0-impl +# Overriden service definition +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/configs/init/android.hardware.media.omx@1.0-service.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/android.hardware.media.omx@1.0-service.rc + # Properties -include $(LOCAL_PATH)/system_prop.mk diff --git a/libshims/libExynosOMX/Android.mk b/libshims/libExynosOMX/Android.mk new file mode 100644 index 0000000..ad33af9 --- /dev/null +++ b/libshims/libExynosOMX/Android.mk @@ -0,0 +1,29 @@ +# +# Copyright (C) 2018 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 := Exynos_OMX_VdecControl.c + +LOCAL_SHARED_LIBRARIES := liblog + +LOCAL_MODULE := libExynosOMX_shim +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := SHARED_LIBRARIES +LOCAL_PROPRIETARY_MODULE := true + +include $(BUILD_SHARED_LIBRARY) diff --git a/libshims/libExynosOMX/Exynos_OMX_VdecControl.c b/libshims/libExynosOMX/Exynos_OMX_VdecControl.c new file mode 100644 index 0000000..68b1739 --- /dev/null +++ b/libshims/libExynosOMX/Exynos_OMX_VdecControl.c @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2017 TeamNexus + * + * 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. + */ + +#define LOG_TAG "libExynosOMX_shim" + +#include +#include +#include + +int Exynos_OSAL_Strcmp(const char *s1, const char *s2) +{ + void *ptr; + int ret; + Dl_info info; + + /* get address of parent function */ + ptr = __builtin_return_address(0); + + /* skip index-check if we couldn't get return-address */ + if (!ptr) { + ALOGE("%s: failed to retrieve return address", __func__); + goto exit; + } + + /* get infos about parent function */ + ret = dladdr(ptr, &info); + + /* skip index-check if we couldn't get infos about parent function */ + if (!ret) { + ALOGE("%s: failed to retrieve informations about parent function", __func__); + goto exit; + } + + /* check if the parent function is Exynos_OMX_VideoDecodeGetExtensionIndex() */ + if (strcmp(info.dli_sname, "Exynos_OMX_VideoDecodeGetExtensionIndex")) { + /* no log here... */ + goto exit; + } + + /* prevent check for storeMetaDataInBuffers-support to succeed */ + if (!strcmp(s1, "OMX.google.android.index.storeMetaDataInBuffers")) { + ALOGI("%s: failing check for storeMetaDataInBuffers-support", __func__); + return -1; + } + +exit: + return strcmp(s1, s2); +} -- 2.20.1