From 6d8bc472b1de17780ccfabd2e77972ae58dd6cf3 Mon Sep 17 00:00:00 2001 From: JeevakaPrabu Date: Thu, 17 Oct 2024 18:56:02 +0000 Subject: [PATCH] Move media diffs to respective git projects Patches moved to projects device-intel-sepolicy, MediaSDK_C2 MediaSDK and vpl-gpu-rt git projects under projectceladon. Tests done: - Android boot in GVT-d - Camera preview and capture - Video playback and recording - adb reboot Tracked-On: OAM-126508 Signed-off-by: JeevakaPrabu --- ...dated-media-c2-hal-from-hidl-to-aidl.patch | 26 - ...001-Updated-Flags-to-fix-build-error.patch | 45 -- .../0001-Fixed-build-error-in-A15.patch | 44 -- ...build-error-in-mediasdk_c2-component.patch | 31 - ...dated-media-c2-hal-from-hidl-to-aidl.patch | 561 ----------------- ...xed-gralloc4-regression-on-Android-U.patch | 261 -------- .../0004-Add-support-for-mapper5.patch | 582 ------------------ 7 files changed, 1550 deletions(-) delete mode 100644 bsp_diff/common/device/intel/sepolicy/0003-Updated-media-c2-hal-from-hidl-to-aidl.patch delete mode 100644 bsp_diff/common/vendor/intel/external/mediasdk_opensource/0001-Updated-Flags-to-fix-build-error.patch delete mode 100644 bsp_diff/common/vendor/intel/external/onevpl-intel-gpu/0001-Fixed-build-error-in-A15.patch delete mode 100644 bsp_diff/common/vendor/intel/mediasdk_c2/0001-Fixed-build-error-in-mediasdk_c2-component.patch delete mode 100644 bsp_diff/common/vendor/intel/mediasdk_c2/0002-Updated-media-c2-hal-from-hidl-to-aidl.patch delete mode 100644 bsp_diff/common/vendor/intel/mediasdk_c2/0003-Fixed-gralloc4-regression-on-Android-U.patch delete mode 100644 bsp_diff/common/vendor/intel/mediasdk_c2/0004-Add-support-for-mapper5.patch diff --git a/bsp_diff/common/device/intel/sepolicy/0003-Updated-media-c2-hal-from-hidl-to-aidl.patch b/bsp_diff/common/device/intel/sepolicy/0003-Updated-media-c2-hal-from-hidl-to-aidl.patch deleted file mode 100644 index 8c28244076..0000000000 --- a/bsp_diff/common/device/intel/sepolicy/0003-Updated-media-c2-hal-from-hidl-to-aidl.patch +++ /dev/null @@ -1,26 +0,0 @@ -From af7d8a2320463c7ec6ed21f3e96f571a931eb1bb Mon Sep 17 00:00:00 2001 -From: Ankit Agarwal -Date: Fri, 2 Aug 2024 21:11:01 +0530 -Subject: [PATCH] Updated media c2 hal from hidl to aidl. - -Updated android.hardware.media.c2 hal from hidl V1.0 to aidl V1. -updated sepolicy to run media c2 aidl. - -Tests: Prepared EB and its booted successfully. - -Tracked-On: OAM-122196 -Signed-off-by: Ankit Agarwal ---- - codec2/msdk-codec2/file_contexts | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/codec2/msdk-codec2/file_contexts b/codec2/msdk-codec2/file_contexts -index 5963a5c..7db1f35 100644 ---- a/codec2/msdk-codec2/file_contexts -+++ b/codec2/msdk-codec2/file_contexts -@@ -1 +1 @@ --/vendor/bin/hw/hardware\.intel\.media\.c2@1\.0-service u:object_r:codec2_hal_default_exec:s0 -+/vendor/bin/hw/android\.hardware\.media\.c2-service\.intel u:object_r:codec2_hal_default_exec:s0 --- -2.34.1 - diff --git a/bsp_diff/common/vendor/intel/external/mediasdk_opensource/0001-Updated-Flags-to-fix-build-error.patch b/bsp_diff/common/vendor/intel/external/mediasdk_opensource/0001-Updated-Flags-to-fix-build-error.patch deleted file mode 100644 index 1e2cd200e2..0000000000 --- a/bsp_diff/common/vendor/intel/external/mediasdk_opensource/0001-Updated-Flags-to-fix-build-error.patch +++ /dev/null @@ -1,45 +0,0 @@ -From dc3bcd2da83446fec9e252ac07c5b2840d41298e Mon Sep 17 00:00:00 2001 -From: Ankit Agarwal -Date: Thu, 13 Jun 2024 09:31:05 +0530 -Subject: [PATCH] Updated Flags to fix build error. - -Observed build failure in A15 due to missing flags and due to -inheritance declaration. - -Tracked-On: NA -Signed-off-by: Ankit Agarwal ---- - _studio/shared/include/mfx_utils.h | 2 +- - android/mfx_defs.mk | 3 +++ - 2 files changed, 4 insertions(+), 1 deletion(-) - -diff --git a/_studio/shared/include/mfx_utils.h b/_studio/shared/include/mfx_utils.h -index 8394cc48..33bbfe26 100644 ---- a/_studio/shared/include/mfx_utils.h -+++ b/_studio/shared/include/mfx_utils.h -@@ -131,7 +131,7 @@ template - struct result_of; - - template --struct result_of : std::result_of {}; -+struct result_of {}; - - template - struct result_of -diff --git a/android/mfx_defs.mk b/android/mfx_defs.mk -index fac4bcdd..abfeae31 100644 ---- a/android/mfx_defs.mk -+++ b/android/mfx_defs.mk -@@ -21,6 +21,9 @@ MEDIA_VERSION_ALL := $(MEDIA_VERSION).pre$(MEDIA_VERSION_EXTRA) - MFX_CFLAGS += -DMEDIA_VERSION_STR=\"\\\"${MEDIA_VERSION_ALL}\\\"\" - - # Android version preference: -+ifneq ($(filter 15 15.% V% ,$(PLATFORM_VERSION)),) -+ MFX_ANDROID_VERSION:= MFX_V -+endif - ifneq ($(filter 14 14.% U% ,$(PLATFORM_VERSION)),) - MFX_ANDROID_VERSION:= MFX_U - endif --- -2.34.1 - diff --git a/bsp_diff/common/vendor/intel/external/onevpl-intel-gpu/0001-Fixed-build-error-in-A15.patch b/bsp_diff/common/vendor/intel/external/onevpl-intel-gpu/0001-Fixed-build-error-in-A15.patch deleted file mode 100644 index 820a209a96..0000000000 --- a/bsp_diff/common/vendor/intel/external/onevpl-intel-gpu/0001-Fixed-build-error-in-A15.patch +++ /dev/null @@ -1,44 +0,0 @@ -From f12ae5ab2f0867983ac243ecf6b0f862e72bb190 Mon Sep 17 00:00:00 2001 -From: Ankit Agarwal -Date: Thu, 13 Jun 2024 09:34:12 +0530 -Subject: [PATCH] Fixed build error in A15. - -Observed build failure in A15 due to inheritance declaration and -unsupported api. - -Tracked-On: NA -Signed-off-by: Ankit Agarwal ---- - _studio/mfx_lib/vpp/src/mfx_vpp_hw.cpp | 2 +- - _studio/shared/include/mfx_utils.h | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/_studio/mfx_lib/vpp/src/mfx_vpp_hw.cpp b/_studio/mfx_lib/vpp/src/mfx_vpp_hw.cpp -index 3f3876e7..bbc1a4fe 100644 ---- a/_studio/mfx_lib/vpp/src/mfx_vpp_hw.cpp -+++ b/_studio/mfx_lib/vpp/src/mfx_vpp_hw.cpp -@@ -2785,7 +2785,7 @@ mfxStatus VideoVPPHW::Init( - { - CmDevice* pCmDevice = QueryCoreInterface(m_pCore, MFXICORECM_GUID); - -- sts = m_SCD.Init(par->vpp.In.CropW, par->vpp.In.CropH, par->vpp.In.Width, par->vpp.In.PicStruct, pCmDevice, CommonCaps::IsCmSupported(m_pCore->GetHWType())); -+ sts = m_SCD.Init(par->vpp.In.CropW, par->vpp.In.CropH, par->vpp.In.Width, par->vpp.In.PicStruct, pCmDevice); - MFX_CHECK_STS(sts); - - m_SCD.SetGoPSize(ns_asc::Immediate_GoP); -diff --git a/_studio/shared/include/mfx_utils.h b/_studio/shared/include/mfx_utils.h -index bab156a8..e43d7d01 100644 ---- a/_studio/shared/include/mfx_utils.h -+++ b/_studio/shared/include/mfx_utils.h -@@ -318,7 +318,7 @@ template - struct result_of; - - template --struct result_of : std::result_of {}; -+struct result_of {}; - - template - struct result_of --- -2.34.1 - diff --git a/bsp_diff/common/vendor/intel/mediasdk_c2/0001-Fixed-build-error-in-mediasdk_c2-component.patch b/bsp_diff/common/vendor/intel/mediasdk_c2/0001-Fixed-build-error-in-mediasdk_c2-component.patch deleted file mode 100644 index bde72b2bc1..0000000000 --- a/bsp_diff/common/vendor/intel/mediasdk_c2/0001-Fixed-build-error-in-mediasdk_c2-component.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 057d69729e52125219e3a94a71a9c58a57193bd8 Mon Sep 17 00:00:00 2001 -From: Ankit Agarwal -Date: Tue, 18 Jun 2024 10:12:52 +0530 -Subject: [PATCH] Fixed build error in mediasdk_c2 component. - -Observed build error due to missing assert header. -Added assert header. - -Tests: Prepared EB, there was no build error. - -Tracked-On: NA -Signed-off-by: Ankit Agarwal ---- - c2_components/src/mfx_c2_component.cpp | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/c2_components/src/mfx_c2_component.cpp b/c2_components/src/mfx_c2_component.cpp -index 0980177..6cdd74e 100755 ---- a/c2_components/src/mfx_c2_component.cpp -+++ b/c2_components/src/mfx_c2_component.cpp -@@ -23,6 +23,7 @@ - #include "mfx_c2_debug.h" - #include "mfx_c2_components_registry.h" - #include "mfx_c2_components_monitor.h" -+#include - - using namespace android; - --- -2.34.1 - diff --git a/bsp_diff/common/vendor/intel/mediasdk_c2/0002-Updated-media-c2-hal-from-hidl-to-aidl.patch b/bsp_diff/common/vendor/intel/mediasdk_c2/0002-Updated-media-c2-hal-from-hidl-to-aidl.patch deleted file mode 100644 index 45bf29b0df..0000000000 --- a/bsp_diff/common/vendor/intel/mediasdk_c2/0002-Updated-media-c2-hal-from-hidl-to-aidl.patch +++ /dev/null @@ -1,561 +0,0 @@ -From e89e975fa4e38f92a316f752cfd915d08ddc8af7 Mon Sep 17 00:00:00 2001 -From: Ankit Agarwal -Date: Fri, 2 Aug 2024 22:38:24 +0530 -Subject: [PATCH] Updated media c2 hal from hidl to aidl. - -Updated android.hardware.media.c2 hal from hidl V1.0 to aidl V1. -The contents of this file was copied from AOSP -frameworks/av/media/codec2/hal/services/vendor.cpp and modified then. - -Tests: Prepared EB and its booted successfully. - -Tracked-On: OAM-122196 -Signed-off-by: Ankit Agarwal ---- - c2_store/Android.bp | 65 ++++---- - ...android.hardware.media.c2-service.intel.rc | 7 + - .../hardware.intel.media.c2@1.0-service.rc | 6 - - c2_store/manifest_media_c2_V1_0_default.xml | 11 -- - c2_store/manifest_media_c2_V1_1_default.xml | 11 -- - c2_store/manifest_media_c2_V1_2_default.xml | 11 -- - c2_store/manifest_media_c2_default.xml | 7 + - ...roid.hardware.media.c2-default-arm.policy} | 0 - ...id.hardware.media.c2-default-arm64.policy} | 0 - ...d.hardware.media.c2-default-riscv64.policy | 75 ++++++++++ - ...roid.hardware.media.c2-default-x86.policy} | 0 - ...d.hardware.media.c2-default-x86_64.policy} | 0 - c2_store/src/mfx_c2_service.cpp | 141 +++++++++++++----- - c2_store/src/mfx_c2_store.cpp | 2 +- - 14 files changed, 231 insertions(+), 105 deletions(-) - create mode 100644 c2_store/android.hardware.media.c2-service.intel.rc - delete mode 100644 c2_store/hardware.intel.media.c2@1.0-service.rc - delete mode 100644 c2_store/manifest_media_c2_V1_0_default.xml - delete mode 100644 c2_store/manifest_media_c2_V1_1_default.xml - delete mode 100644 c2_store/manifest_media_c2_V1_2_default.xml - create mode 100644 c2_store/manifest_media_c2_default.xml - rename c2_store/seccomp_policy/{android.hardware.media.c2@1.0-arm.policy => android.hardware.media.c2-default-arm.policy} (100%) - rename c2_store/seccomp_policy/{android.hardware.media.c2@1.0-arm64.policy => android.hardware.media.c2-default-arm64.policy} (100%) - create mode 100644 c2_store/seccomp_policy/android.hardware.media.c2-default-riscv64.policy - rename c2_store/seccomp_policy/{android.hardware.media.c2@1.0-x86.policy => android.hardware.media.c2-default-x86.policy} (100%) - rename c2_store/seccomp_policy/{android.hardware.media.c2@1.0-x86_64.policy => android.hardware.media.c2-default-x86_64.policy} (100%) - mode change 100755 => 100644 c2_store/src/mfx_c2_service.cpp - mode change 100755 => 100644 c2_store/src/mfx_c2_store.cpp - -diff --git a/c2_store/Android.bp b/c2_store/Android.bp -index 64c044e..aca3302 100644 ---- a/c2_store/Android.bp -+++ b/c2_store/Android.bp -@@ -1,12 +1,12 @@ - cc_library_static { - -- name: "libmfx_c2_store", -+ name: "libmfx_c2_store", - -- defaults: ["mfx_c2_defaults"], -+ defaults: ["mfx_c2_defaults"], - -- cflags: [ -- "-fexceptions" -- ], -+ cflags: [ -+ "-fexceptions" -+ ], - - header_libs: [ - "mfx_c2_components_headers", -@@ -21,12 +21,18 @@ cc_library_static { - } - - cc_binary { -- -- name: "hardware.intel.media.c2@1.0-service", -- defaults: ["libcodec2-hidl-defaults", "mfx_c2_exe_defaults"], -+ name: "android.hardware.media.c2-service.intel", - vendor: true, - relative_install_path: "hw", - -+ init_rc: ["android.hardware.media.c2-service.intel.rc"], -+ -+ defaults: [ -+ "libcodec2-hidl-defaults", -+ "libcodec2-aidl-defaults", -+ "mfx_c2_exe_defaults", -+ ], -+ - local_include_dirs: [ - "include", - ], -@@ -35,8 +41,6 @@ cc_binary { - "src/mfx_c2_service.cpp", - ], - -- init_rc: ["hardware.intel.media.c2@1.0-service.rc"], -- - header_libs: [ - "mfx_c2_components_headers", - "libmedia_headers", -@@ -46,43 +50,54 @@ cc_binary { - static_libs: [ - "libmfx_c2_store", - "libmfx_c2_utils_va", -- "libexpat" -+ "libexpat", - ], - -+ // minijail is used to protect against unexpected system calls. - shared_libs: [ -- "android.hardware.media.omx@1.0", - "libavservices_minijail", - "libbinder", -- "libhidltransport", -- "libhwbinder", -- "libstagefright_omx", -- "libstagefright_xmlparser", -+ "libbinder_ndk", - ], -- -- vintf_fragments: ["manifest_media_c2_V1_0_default.xml"], -- -- required: ["android.hardware.media.c2@1.0-vendor.policy"], -+ required: ["android.hardware.media.c2-vendor-seccomp_policy"], - - compile_multilib: "32", -+ // The content in manifest_media_c2_default.xml can be included -+ // directly in the main device manifest.xml file or via vintf_fragments. -+ // (Remove the line below if the entry is already in the main manifest.) -+ vintf_fragments: ["manifest_media_c2_default.xml"], - } - -+// seccomp policy file. -+// -+// This should be modified to suit the target device and architecture. -+// -+// Files in the "seccomp_policy" subdirectory are only provided as examples. -+// They may not work on some devices and/or architectures without modification. - prebuilt_etc { -- name: "android.hardware.media.c2@1.0-vendor.policy", -+ name: "android.hardware.media.c2-vendor-seccomp_policy", - vendor: true, - sub_dir: "seccomp_policy", - -+ // If a specific architecture is targeted, multiple choices are not needed. - arch: { - arm: { -- src: "seccomp_policy/android.hardware.media.c2@1.0-arm.policy", -+ src: "seccomp_policy/android.hardware.media.c2-default-arm.policy", - }, - arm64: { -- src: "seccomp_policy/android.hardware.media.c2@1.0-arm64.policy", -+ src: "seccomp_policy/android.hardware.media.c2-default-arm64.policy", -+ }, -+ riscv64: { -+ src: "seccomp_policy/android.hardware.media.c2-default-riscv64.policy", - }, - x86: { -- src: "seccomp_policy/android.hardware.media.c2@1.0-x86.policy", -+ src: "seccomp_policy/android.hardware.media.c2-default-x86.policy", - }, - x86_64: { -- src: "seccomp_policy/android.hardware.media.c2@1.0-x86_64.policy", -+ src: "seccomp_policy/android.hardware.media.c2-default-x86_64.policy", - }, - }, -+ -+ //This may be removed. -+ required: ["crash_dump.policy"], - } -diff --git a/c2_store/android.hardware.media.c2-service.intel.rc b/c2_store/android.hardware.media.c2-service.intel.rc -new file mode 100644 -index 0000000..a67a932 ---- /dev/null -+++ b/c2_store/android.hardware.media.c2-service.intel.rc -@@ -0,0 +1,7 @@ -+service hardware-intel-media-c2-hal /vendor/bin/hw/android.hardware.media.c2-service.intel -+ class hal -+ user mediacodec -+ group camera mediadrm drmrpc -+ ioprio rt 4 -+ task_profiles ProcessCapacityHigh -+ -diff --git a/c2_store/hardware.intel.media.c2@1.0-service.rc b/c2_store/hardware.intel.media.c2@1.0-service.rc -deleted file mode 100644 -index 5ec4a5a..0000000 ---- a/c2_store/hardware.intel.media.c2@1.0-service.rc -+++ /dev/null -@@ -1,6 +0,0 @@ --service hardware-intel-media-c2-hal-1-0 /vendor/bin/hw/hardware.intel.media.c2@1.0-service -- class hal -- user mediacodec -- group camera mediadrm drmrpc -- ioprio rt 4 -- writepid /dev/cpuset/foreground/tasks -diff --git a/c2_store/manifest_media_c2_V1_0_default.xml b/c2_store/manifest_media_c2_V1_0_default.xml -deleted file mode 100644 -index e97c3ce..0000000 ---- a/c2_store/manifest_media_c2_V1_0_default.xml -+++ /dev/null -@@ -1,11 +0,0 @@ -- -- -- android.hardware.media.c2 -- hwbinder -- 1.0 -- -- IComponentStore -- default -- -- -- -diff --git a/c2_store/manifest_media_c2_V1_1_default.xml b/c2_store/manifest_media_c2_V1_1_default.xml -deleted file mode 100644 -index bf0d72f..0000000 ---- a/c2_store/manifest_media_c2_V1_1_default.xml -+++ /dev/null -@@ -1,11 +0,0 @@ -- -- -- android.hardware.media.c2 -- hwbinder -- 1.1 -- -- IComponentStore -- default -- -- -- -diff --git a/c2_store/manifest_media_c2_V1_2_default.xml b/c2_store/manifest_media_c2_V1_2_default.xml -deleted file mode 100644 -index a5e8d87..0000000 ---- a/c2_store/manifest_media_c2_V1_2_default.xml -+++ /dev/null -@@ -1,11 +0,0 @@ -- -- -- android.hardware.media.c2 -- hwbinder -- 1.2 -- -- IComponentStore -- default -- -- -- -diff --git a/c2_store/manifest_media_c2_default.xml b/c2_store/manifest_media_c2_default.xml -new file mode 100644 -index 0000000..7558d87 ---- /dev/null -+++ b/c2_store/manifest_media_c2_default.xml -@@ -0,0 +1,7 @@ -+ -+ -+ android.hardware.media.c2 -+ 1 -+ IComponentStore/default -+ -+ -diff --git a/c2_store/seccomp_policy/android.hardware.media.c2@1.0-arm.policy b/c2_store/seccomp_policy/android.hardware.media.c2-default-arm.policy -similarity index 100% -rename from c2_store/seccomp_policy/android.hardware.media.c2@1.0-arm.policy -rename to c2_store/seccomp_policy/android.hardware.media.c2-default-arm.policy -diff --git a/c2_store/seccomp_policy/android.hardware.media.c2@1.0-arm64.policy b/c2_store/seccomp_policy/android.hardware.media.c2-default-arm64.policy -similarity index 100% -rename from c2_store/seccomp_policy/android.hardware.media.c2@1.0-arm64.policy -rename to c2_store/seccomp_policy/android.hardware.media.c2-default-arm64.policy -diff --git a/c2_store/seccomp_policy/android.hardware.media.c2-default-riscv64.policy b/c2_store/seccomp_policy/android.hardware.media.c2-default-riscv64.policy -new file mode 100644 -index 0000000..27f0b95 ---- /dev/null -+++ b/c2_store/seccomp_policy/android.hardware.media.c2-default-riscv64.policy -@@ -0,0 +1,75 @@ -+# Copyright (C) 2019 The Android Open Source 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. -+ -+futex: 1 -+# ioctl calls are filtered via the selinux policy. -+ioctl: 1 -+sched_yield: 1 -+close: 1 -+dup: 1 -+ppoll: 1 -+mprotect: arg2 in ~PROT_EXEC || arg2 in ~PROT_WRITE -+mmap: arg2 in ~PROT_EXEC || arg2 in ~PROT_WRITE -+getuid: 1 -+getrlimit: 1 -+fstat: 1 -+newfstatat: 1 -+fstatfs: 1 -+memfd_create: 1 -+ftruncate: 1 -+ -+mremap: arg3 == 3 || arg3 == MREMAP_MAYMOVE -+munmap: 1 -+prctl: 1 -+writev: 1 -+sigaltstack: 1 -+clone: 1 -+exit: 1 -+lseek: 1 -+rt_sigprocmask: 1 -+openat: 1 -+write: 1 -+nanosleep: 1 -+setpriority: 1 -+set_tid_address: 1 -+getdents64: 1 -+readlinkat: 1 -+read: 1 -+pread64: 1 -+gettimeofday: 1 -+faccessat: 1 -+exit_group: 1 -+restart_syscall: 1 -+rt_sigreturn: 1 -+getrandom: 1 -+madvise: 1 -+ -+# crash dump policy additions -+clock_gettime: 1 -+getpid: 1 -+gettid: 1 -+pipe2: 1 -+recvmsg: 1 -+process_vm_readv: 1 -+tgkill: 1 -+rt_sigaction: 1 -+rt_tgsigqueueinfo: 1 -+#mprotect: arg2 in 0x1|0x2 -+munmap: 1 -+#mmap: arg2 in 0x1|0x2 -+geteuid: 1 -+getgid: 1 -+getegid: 1 -+getgroups: 1 -+ -diff --git a/c2_store/seccomp_policy/android.hardware.media.c2@1.0-x86.policy b/c2_store/seccomp_policy/android.hardware.media.c2-default-x86.policy -similarity index 100% -rename from c2_store/seccomp_policy/android.hardware.media.c2@1.0-x86.policy -rename to c2_store/seccomp_policy/android.hardware.media.c2-default-x86.policy -diff --git a/c2_store/seccomp_policy/android.hardware.media.c2@1.0-x86_64.policy b/c2_store/seccomp_policy/android.hardware.media.c2-default-x86_64.policy -similarity index 100% -rename from c2_store/seccomp_policy/android.hardware.media.c2@1.0-x86_64.policy -rename to c2_store/seccomp_policy/android.hardware.media.c2-default-x86_64.policy -diff --git a/c2_store/src/mfx_c2_service.cpp b/c2_store/src/mfx_c2_service.cpp -old mode 100755 -new mode 100644 -index c81d5fa..34362cf ---- a/c2_store/src/mfx_c2_service.cpp -+++ b/c2_store/src/mfx_c2_service.cpp -@@ -1,4 +1,4 @@ --// Copyright (c) 2017-2022 Intel Corporation -+// Copyright (c) 2017-2024 Intel Corporation - // - // Permission is hereby granted, free of charge, to any person obtaining a copy - // of this software and associated documentation files (the "Software"), to deal -@@ -36,81 +36,142 @@ - */ - - // The contents of this file was copied --// from AOSP hardware/google/av/codec2/hidl/services/vendor.cpp -+// from AOSP frameworks/av/media/codec2/hal/services/vendor.cpp - // and modified then. - - //#define LOG_NDEBUG 0 --#define LOG_TAG "hardware.intel.media.c2@1.0-service" -+#define LOG_TAG "android.hardware.media.c2-service.intel" - - #include "mfx_c2_store.h" - --#include --#include --#include -+#include - #include --#include - -+#include - #include -+#include -+ -+// HIDL -+#include -+#include -+#include -+ -+// AIDL -+#include -+#include -+#include -+#include - --// This is created by module "codec2.vendor.base.policy". This can be modified. -+// This is the absolute on-device path of the prebuild_etc module -+// "android.hardware.media.c2-default-seccomp_policy" in Android.bp. - static constexpr char kBaseSeccompPolicyPath[] = -- "/vendor/etc/seccomp_policy/android.hardware.media.c2@1.0-vendor.policy"; -+ "/vendor/etc/seccomp_policy/" -+ "android.hardware.media.c2-vendor-seccomp_policy"; - --// Additional device-specific seccomp permissions can be added in this file. -+// Additional seccomp permissions can be added in this file. -+// This file does not exist by default. - static constexpr char kExtSeccompPolicyPath[] = -- "/vendor/etc/seccomp_policy/android.hardware.media.c2@1.0-vendor.ext.policy"; -+ "/vendor/etc/seccomp_policy/" -+ "android.hardware.media.c2-extended-seccomp_policy"; -+ -+// We want multiple threads to be running so that a blocking operation -+// on one codec does not block the other codecs. -+// For HIDL: Extra threads may be needed to handle a stacked IPC sequence that -+// contains alternating binder and hwbinder calls. (See b/35283480.) -+static constexpr int kThreadCount = 8; - --// Create and register IComponentStore service. --void RegisterC2Service() --{ -- using namespace ::android::hardware::media::c2::V1_0; -- android::sp store; -+void runAidlService() { -+ ABinderProcess_setThreadPoolMaxThreadCount(kThreadCount); -+ ABinderProcess_startThreadPool(); - -- ALOGD("Instantiating MFX IComponentStore service..."); -+ // Create IComponentStore service. -+ using namespace ::aidl::android::hardware::media::c2; -+ std::shared_ptr store; -+ -+ LOG(DEBUG) << "Instantiating MFX IComponentStore service..."; - - c2_status_t status = C2_OK; - std::shared_ptr c2_store(MfxC2ComponentStore::Create(&status)); - if (c2_store) { -- store = new utils::ComponentStore(c2_store); -+ store = ::ndk::SharedRefBase::make(c2_store); - } else { - ALOGD("Creation MFX IComponentStore failed with status: %d", (int)status); - } - -- if (!store) { -- ALOGE("Cannot create Codec2's IComponentStore service."); -+ if (store == nullptr) { -+ LOG(ERROR) << "Cannot create Codec2's IComponentStore service."; - } else { -- if (store->registerAsService("default") != android::OK) { -- ALOGE("Cannot register Codec2's " -- "IComponentStore service."); -+ const std::string serviceName = -+ std::string(IComponentStore::descriptor) + "/default"; -+ binder_exception_t ex = AServiceManager_addService( -+ store->asBinder().get(), serviceName.c_str()); -+ if (ex != EX_NONE) { -+ LOG(ERROR) << "Cannot register Codec2's IComponentStore service" -+ " with instance name << \"" -+ << serviceName << "\"."; - } else { -- ALOGI("Codec2's IComponentStore service created."); -+ LOG(DEBUG) << "Codec2's IComponentStore service registered. " -+ "Instance name: \"" << serviceName << "\"."; - } - } -+ -+ ABinderProcess_joinThreadPool(); - } - -+void runHidlService() { -+ using namespace ::android; - --int main(int /* argc */, char** /* argv */) { -- // ALOGD("hardware.intel.media.c2@1.0-service starting..."); -+ // Enable vndbinder to allow vendor-to-vendor binder calls. -+ ProcessState::initWithDriver("/dev/vndbinder"); - -- signal(SIGPIPE, SIG_IGN); -+ ProcessState::self()->startThreadPool(); -+ hardware::configureRpcThreadpool(kThreadCount, true /* callerWillJoin */); -+ -+ // Create IComponentStore service. -+ { -+ using namespace ::android::hardware::media::c2::V1_0; -+ sp store; -+ -+ ALOGD("Instantiating MFX IComponentStore service..."); - -- try { -- android::SetUpMinijail(kBaseSeccompPolicyPath, kExtSeccompPolicyPath); -- -- // vndbinder is needed by BufferQueue. -- android::ProcessState::initWithDriver("/dev/vndbinder"); -- android::ProcessState::self()->startThreadPool(); -+ c2_status_t status = C2_OK; -+ std::shared_ptr c2_store(MfxC2ComponentStore::Create(&status)); -+ if (c2_store) { -+ store = new utils::ComponentStore(c2_store); -+ } else { -+ ALOGD("Creation MFX IComponentStore failed with status: %d", (int)status); -+ } - -- // Extra threads may be needed to handle a stacked IPC sequence that -- // contains alternating binder and hwbinder calls. (See b/35283480.) -- android::hardware::configureRpcThreadpool(8, true /* callerWillJoin */); -+ if (store == nullptr) { -+ LOG(ERROR) << "Cannot create Codec2's IComponentStore service."; -+ } else { -+ constexpr char const* serviceName = "default"; -+ if (store->registerAsService(serviceName) != OK) { -+ LOG(ERROR) << "Cannot register Codec2's IComponentStore service" -+ " with instance name << \"" -+ << serviceName << "\"."; -+ } else { -+ LOG(DEBUG) << "Codec2's IComponentStore service registered. " -+ "Instance name: \"" << serviceName << "\"."; -+ } -+ } -+ } - -- RegisterC2Service(); -+ hardware::joinRpcThreadpool(); -+} - -- android::hardware::joinRpcThreadpool(); -+int main(int /* argc */, char** /* argv */) { -+ const bool aidlEnabled = ::aidl::android::hardware::media::c2::utils::IsSelected(); -+ LOG(DEBUG) << "android.hardware.media.c2" << (aidlEnabled ? "-V1" : "@1.0") -+ << "-service starting..."; - -- } catch(const std::exception& ex) { -- // ALOGE("hardware.intel.media.c2@1.0-service exception: %s", ex.what()); -+ // Set up minijail to limit system calls. -+ signal(SIGPIPE, SIG_IGN); -+ android::SetUpMinijail(kBaseSeccompPolicyPath, kExtSeccompPolicyPath); -+ if (aidlEnabled) { -+ runAidlService(); -+ } else { -+ runHidlService(); - } - return 0; - } -diff --git a/c2_store/src/mfx_c2_store.cpp b/c2_store/src/mfx_c2_store.cpp -old mode 100755 -new mode 100644 -index 3f25dd9..285d018 ---- a/c2_store/src/mfx_c2_store.cpp -+++ b/c2_store/src/mfx_c2_store.cpp -@@ -1,4 +1,4 @@ --// Copyright (c) 2017-2021 Intel Corporation -+// Copyright (c) 2017-2024 Intel Corporation - // - // Permission is hereby granted, free of charge, to any person obtaining a copy - // of this software and associated documentation files (the "Software"), to deal --- -2.34.1 - diff --git a/bsp_diff/common/vendor/intel/mediasdk_c2/0003-Fixed-gralloc4-regression-on-Android-U.patch b/bsp_diff/common/vendor/intel/mediasdk_c2/0003-Fixed-gralloc4-regression-on-Android-U.patch deleted file mode 100644 index 39332bca7a..0000000000 --- a/bsp_diff/common/vendor/intel/mediasdk_c2/0003-Fixed-gralloc4-regression-on-Android-U.patch +++ /dev/null @@ -1,261 +0,0 @@ -From 34831b521337399437dda51821ef0b5fc5bcb9fd Mon Sep 17 00:00:00 2001 -From: zhangyichix -Date: Wed, 25 Oct 2023 14:06:11 +0800 -Subject: [PATCH] Fixed gralloc4 regression on Android U -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Start with Android U, the get function of IMapper4 -will check whether the buffer handle is reserved. -  -1. Call importBuffer to preserve handle before getting the buffer's info. -2. Call freeBuffer at the end. -3. Switch to use gralloc4. - -Tracked-On: OAM-112928 -Signed-off-by: zhangyichix ---- - .../src/mfx_c2_encoder_component.cpp | 12 ----- - c2_utils/include/mfx_defs.h | 2 +- - c2_utils/include/mfx_gralloc1.h | 2 +- - c2_utils/include/mfx_gralloc4.h | 8 ++- - c2_utils/include/mfx_gralloc_interface.h | 3 +- - c2_utils/src/mfx_gralloc1.cpp | 2 +- - c2_utils/src/mfx_gralloc4.cpp | 54 ++++++++++++++++--- - 7 files changed, 60 insertions(+), 23 deletions(-) - -diff --git a/c2_components/src/mfx_c2_encoder_component.cpp b/c2_components/src/mfx_c2_encoder_component.cpp -index 085ed03..c90a392 100755 ---- a/c2_components/src/mfx_c2_encoder_component.cpp -+++ b/c2_components/src/mfx_c2_encoder_component.cpp -@@ -1375,23 +1375,11 @@ void MfxC2EncoderComponent::DoWork(std::unique_ptr&& work) - mfxMemId mem_id = nullptr; - bool decode_target = false; - native_handle_t *grallocHandle = android::UnwrapNativeCodec2GrallocHandle(c_graph_block->handle()); -- // From Android U, the get function of IMapper4 will check whether the buffer handle is reserved. -- // So we need to call importBuffer before getting the buffer's info. --#if PLATFORM_SDK_VERSION >= 34 && defined(USE_GRALLOC4) // Android 14(U) -- buffer_handle_t importedHandle = MfxGrallocInstance::getInstance()->ImportBuffer(grallocHandle); -- -- mfxStatus mfx_sts = frame_converter->ConvertGrallocToVa(importedHandle, -- decode_target, &mem_id); -- -- native_handle_delete(const_cast(importedHandle)); -- importedHandle = nullptr; --#else - mfxStatus mfx_sts = frame_converter->ConvertGrallocToVa(grallocHandle, - decode_target, &mem_id); - - native_handle_delete(grallocHandle); - grallocHandle = nullptr; --#endif - - if (MFX_ERR_NONE != mfx_sts) { - res = MfxStatusToC2(mfx_sts); -diff --git a/c2_utils/include/mfx_defs.h b/c2_utils/include/mfx_defs.h -index 42e4832..0a6fc26 100755 ---- a/c2_utils/include/mfx_defs.h -+++ b/c2_utils/include/mfx_defs.h -@@ -34,7 +34,7 @@ - - // includes below are to get Intel color formats - --// #define HAVE_GRALLOC4 // We use gralloc4 but keep supporting gralloc1 -+#define HAVE_GRALLOC4 // We use gralloc4 but keep supporting gralloc1 - - #ifdef HAVE_GRALLOC4 - #define USE_GRALLOC4 -diff --git a/c2_utils/include/mfx_gralloc1.h b/c2_utils/include/mfx_gralloc1.h -index 250e373..9d98b13 100755 ---- a/c2_utils/include/mfx_gralloc1.h -+++ b/c2_utils/include/mfx_gralloc1.h -@@ -38,7 +38,7 @@ public: - virtual c2_status_t GetBufferDetails(const buffer_handle_t handle, BufferDetails* details) override; - - virtual c2_status_t Alloc(const uint16_t width, const uint16_t height, buffer_handle_t* handle); -- virtual c2_status_t Free(const buffer_handle_t handle); -+ virtual c2_status_t FreeBuffer(const buffer_handle_t handle) override; - virtual c2_status_t LockFrame(buffer_handle_t handle, uint8_t** data, C2PlanarLayout *layout); - virtual c2_status_t UnlockFrame(buffer_handle_t handle); - virtual buffer_handle_t ImportBuffer(const buffer_handle_t rawHandle) override; -diff --git a/c2_utils/include/mfx_gralloc4.h b/c2_utils/include/mfx_gralloc4.h -index f66804c..0b4e9c4 100644 ---- a/c2_utils/include/mfx_gralloc4.h -+++ b/c2_utils/include/mfx_gralloc4.h -@@ -44,12 +44,18 @@ public: - virtual ~MfxGralloc4Module(); - - // Wrapper for IMapper::get -- virtual Error4 get(const native_handle_t* bufferHandle, const IMapper4::MetadataType& metadataType, -+ virtual Error4 Get(const native_handle_t* bufferHandle, const IMapper4::MetadataType& metadataType, -+ hidl_vec& outVec); -+ virtual Error4 GetWithImported(const native_handle_t* handle, const IMapper4::MetadataType& metadataType, - hidl_vec& outVec); - - virtual c2_status_t GetBufferDetails(const buffer_handle_t handle, BufferDetails* details) override; - virtual c2_status_t GetBackingStore(const buffer_handle_t rawHandle, uint64_t *id) override; -+ -+ // Start with Android U, the get function of IMapper4 will check whether the buffer handle is reserved. -+ // So we need to call importBuffer to preserve handle before getting the buffer's info. - virtual buffer_handle_t ImportBuffer(const buffer_handle_t rawHandle) override; -+ virtual c2_status_t FreeBuffer(const buffer_handle_t rawHandle) override; - - // TODO: not fully tested - virtual c2_status_t LockFrame(buffer_handle_t handle, uint8_t** data, C2PlanarLayout *layout); -diff --git a/c2_utils/include/mfx_gralloc_interface.h b/c2_utils/include/mfx_gralloc_interface.h -index 33b6ced..a7560a0 100644 ---- a/c2_utils/include/mfx_gralloc_interface.h -+++ b/c2_utils/include/mfx_gralloc_interface.h -@@ -57,4 +57,5 @@ public: - virtual c2_status_t GetBackingStore(const buffer_handle_t rawHandle, uint64_t *id) = 0; - - virtual buffer_handle_t ImportBuffer(const buffer_handle_t rawHandle) = 0; --}; -\ No newline at end of file -+ virtual c2_status_t FreeBuffer(const buffer_handle_t rawHandle) = 0; -+}; -diff --git a/c2_utils/src/mfx_gralloc1.cpp b/c2_utils/src/mfx_gralloc1.cpp -index 1ab02eb..96addbf 100755 ---- a/c2_utils/src/mfx_gralloc1.cpp -+++ b/c2_utils/src/mfx_gralloc1.cpp -@@ -190,7 +190,7 @@ c2_status_t MfxGralloc1Module::Alloc(const uint16_t width, const uint16_t height - return res; - } - --c2_status_t MfxGralloc1Module::Free(const buffer_handle_t handle) -+c2_status_t MfxGralloc1Module::FreeBuffer(const buffer_handle_t handle) - { - MFX_DEBUG_TRACE_FUNC; - c2_status_t res = C2_OK; -diff --git a/c2_utils/src/mfx_gralloc4.cpp b/c2_utils/src/mfx_gralloc4.cpp -index 767a477..09a7145 100644 ---- a/c2_utils/src/mfx_gralloc4.cpp -+++ b/c2_utils/src/mfx_gralloc4.cpp -@@ -51,7 +51,7 @@ MfxGralloc4Module::~MfxGralloc4Module() - - } - --Error4 MfxGralloc4Module::get(const native_handle_t* handle, const IMapper4::MetadataType& metadataType, -+Error4 MfxGralloc4Module::Get(const native_handle_t* handle, const IMapper4::MetadataType& metadataType, - hidl_vec& outVec) - { - Error4 err; -@@ -66,13 +66,34 @@ Error4 MfxGralloc4Module::get(const native_handle_t* handle, const IMapper4::Met - return err; - } - -+Error4 MfxGralloc4Module::GetWithImported(const native_handle_t* handle, const IMapper4::MetadataType& metadataType, -+ hidl_vec& outVec) -+{ -+ Error4 err; -+ if (nullptr == m_mapper) -+ return Error4::NO_RESOURCES; -+ -+ auto importedHnd = ImportBuffer(handle); -+ m_mapper->get(const_cast(importedHnd), metadataType, -+ [&](const auto& tmpError, const hidl_vec& tmpVec) -+ { -+ err = tmpError; -+ outVec = tmpVec; -+ }); -+ -+ (void)FreeBuffer(importedHnd); -+ return err; -+} -+ - c2_status_t MfxGralloc4Module::GetBufferDetails(const buffer_handle_t handle, BufferDetails *details) - { - MFX_DEBUG_TRACE_FUNC; - c2_status_t res = C2_OK; - -+ buffer_handle_t importedHnd = nullptr; - do - { -+ importedHnd = ImportBuffer(handle); - details->handle = handle; - - details->prime = handle->data[0]; -@@ -80,7 +101,7 @@ c2_status_t MfxGralloc4Module::GetBufferDetails(const buffer_handle_t handle, Bu - - hidl_vec vec; - -- if (IsFailed(get(handle, gralloc4::MetadataType_Width, vec))) -+ if (IsFailed(Get(importedHnd, gralloc4::MetadataType_Width, vec))) - { - res = C2_CORRUPTED; - break; -@@ -91,7 +112,7 @@ c2_status_t MfxGralloc4Module::GetBufferDetails(const buffer_handle_t handle, Bu - details->width = details->allocWidth = width; - MFX_DEBUG_TRACE_I32(details->width); - -- if (IsFailed(get(handle, gralloc4::MetadataType_Height, vec))) -+ if (IsFailed(Get(importedHnd, gralloc4::MetadataType_Height, vec))) - { - res = C2_CORRUPTED; - break; -@@ -103,7 +124,7 @@ c2_status_t MfxGralloc4Module::GetBufferDetails(const buffer_handle_t handle, Bu - MFX_DEBUG_TRACE_I32(details->height); - - hardware::graphics::common::V1_2::PixelFormat pixelFormat; -- if (IsFailed(get(handle, gralloc4::MetadataType_PixelFormatRequested, vec))) -+ if (IsFailed(Get(importedHnd, gralloc4::MetadataType_PixelFormatRequested, vec))) - { - res = C2_CORRUPTED; - break; -@@ -112,7 +133,7 @@ c2_status_t MfxGralloc4Module::GetBufferDetails(const buffer_handle_t handle, Bu - details->format = static_cast(pixelFormat); - MFX_DEBUG_TRACE_I32(details->format); - -- if(IsFailed(get(handle, gralloc4::MetadataType_PlaneLayouts, vec))) -+ if(IsFailed(Get(importedHnd, gralloc4::MetadataType_PlaneLayouts, vec))) - { - res = C2_CORRUPTED; - break; -@@ -134,6 +155,8 @@ c2_status_t MfxGralloc4Module::GetBufferDetails(const buffer_handle_t handle, Bu - MFX_DEBUG_TRACE_STREAM("details->pitches[" << i << "] = " << details->pitches[i]); - } - } while (false); -+ -+ (void)FreeBuffer(importedHnd); - MFX_DEBUG_TRACE__android_c2_status_t(res); - return res; - } -@@ -144,7 +167,7 @@ c2_status_t MfxGralloc4Module::GetBackingStore(const buffer_handle_t handle, uin - c2_status_t res = C2_OK; - - hidl_vec vec; -- if(IsFailed(get(handle, android::gralloc4::MetadataType_BufferId, vec))) -+ if(IsFailed(GetWithImported(handle, android::gralloc4::MetadataType_BufferId, vec))) - res = C2_CORRUPTED; - gralloc4::decodeBufferId(vec, id); - -@@ -174,6 +197,25 @@ buffer_handle_t MfxGralloc4Module::ImportBuffer(const buffer_handle_t rawHandle) - return outBuffer; - } - -+c2_status_t MfxGralloc4Module::FreeBuffer(const buffer_handle_t rawHandle) -+{ -+ MFX_DEBUG_TRACE_FUNC; -+ c2_status_t res = C2_OK; -+ Error4 err; -+ if (nullptr == m_mapper) -+ res = C2_CORRUPTED; -+ if (C2_OK == res) -+ { -+ err = m_mapper->freeBuffer(const_cast(rawHandle)); -+ -+ if (IsFailed(err)) -+ res = C2_CORRUPTED; -+ } -+ -+ MFX_DEBUG_TRACE__android_c2_status_t(res); -+ return res; -+} -+ - c2_status_t MfxGralloc4Module::LockFrame(buffer_handle_t handle, uint8_t** data, C2PlanarLayout *layout) - { - MFX_DEBUG_TRACE_FUNC; --- -2.45.2 - diff --git a/bsp_diff/common/vendor/intel/mediasdk_c2/0004-Add-support-for-mapper5.patch b/bsp_diff/common/vendor/intel/mediasdk_c2/0004-Add-support-for-mapper5.patch deleted file mode 100644 index f23f9adfc4..0000000000 --- a/bsp_diff/common/vendor/intel/mediasdk_c2/0004-Add-support-for-mapper5.patch +++ /dev/null @@ -1,582 +0,0 @@ -From 6a0ac7ee444e9d21c77c5514fb82262d845b30aa Mon Sep 17 00:00:00 2001 -From: Jeevaka Prabu Badrappan -Date: Tue, 13 Aug 2024 18:09:34 +0530 -Subject: [PATCH] Add support for mapper5 - -As IMapper4 is deprecated from Android15, changes done to use -IMapper5 stable-c mapper. - -Tests done: -- Android boot in GVT-d and BM config -- H/W accelerated video playback -- adb reboot - -Tracked-On: OAM-123348 -Signed-off-by: Jeevaka Prabu Badrappan ---- - c2_components/Android.bp | 15 +- - c2_utils/Android.bp | 10 +- - c2_utils/include/mfx_defs.h | 11 +- - c2_utils/include/mfx_gralloc_instance.h | 1 + - c2_utils/include/mfx_mapper5.h | 36 +++ - c2_utils/src/mfx_gralloc_instance.cpp | 8 +- - c2_utils/src/mfx_mapper5.cpp | 371 ++++++++++++++++++++++++ - 7 files changed, 443 insertions(+), 9 deletions(-) - create mode 100644 c2_utils/include/mfx_mapper5.h - create mode 100644 c2_utils/src/mfx_mapper5.cpp - -diff --git a/c2_components/Android.bp b/c2_components/Android.bp -index 1e560bd..f3867eb 100644 ---- a/c2_components/Android.bp -+++ b/c2_components/Android.bp -@@ -31,7 +31,10 @@ cc_library_headers { - cc_library_shared { - name: "libmfx_c2_components_hw", - -- defaults: ["mfx_c2_defaults"], -+ defaults: [ -+ "mfx_c2_defaults", -+ "android.hardware.graphics.allocator-ndk_shared", -+ ], - - static_libs: [ - "libmfx_c2_buffers", -@@ -57,6 +60,8 @@ cc_library_shared { - "android.hardware.graphics.bufferqueue@2.0", - "android.hardware.graphics.common@1.2", - "android.hardware.graphics.mapper@4.0", -+ "libbinder_ndk", -+ "libvndksupport", - ], - - local_include_dirs: [ -@@ -79,5 +84,11 @@ cc_library_shared { - - ], - -+ header_libs: [ -+ "libui_headers", -+ "libimapper_stablec", -+ "libimapper_providerutils", -+ ], -+ - vendor: true, --} -\ No newline at end of file -+} -diff --git a/c2_utils/Android.bp b/c2_utils/Android.bp -index 2082e9a..a88f952 100644 ---- a/c2_utils/Android.bp -+++ b/c2_utils/Android.bp -@@ -34,9 +34,14 @@ cc_library_static { - "android.hardware.graphics.bufferqueue@2.0", - "android.hardware.graphics.common@1.2", - "android.hardware.graphics.mapper@4.0", -+ "libbinder_ndk", -+ "libvndksupport", - ], - -- defaults: ["mfx_c2_defaults"], -+ defaults: [ -+ "mfx_c2_defaults", -+ "android.hardware.graphics.allocator-ndk_shared", -+ ], - - srcs: [ - "src/*.cpp", -@@ -69,6 +74,9 @@ cc_library_static { - "libva_headers", - "libcodec2_vndk_headers", - "libcodec2_headers", -+ "libui_headers", -+ "libimapper_stablec", -+ "libimapper_providerutils", - ], - - vendor: true, -diff --git a/c2_utils/include/mfx_defs.h b/c2_utils/include/mfx_defs.h -index 0a6fc26..86e4b58 100755 ---- a/c2_utils/include/mfx_defs.h -+++ b/c2_utils/include/mfx_defs.h -@@ -34,18 +34,19 @@ - - // includes below are to get Intel color formats - --#define HAVE_GRALLOC4 // We use gralloc4 but keep supporting gralloc1 -- --#ifdef HAVE_GRALLOC4 -+#if PLATFORM_SDK_VERSION >= 35 -+ #define USE_MAPPER5 -+#elif PLATFORM_SDK_VERSION >= 34 - #define USE_GRALLOC4 --#else // HAVE_GRALLOC4 -+#else - #ifdef MFX_C2_USE_PRIME - // USE_GRALLOC1 required for using PRIME buffer descriptor - - // opens definition GRALLOC1_PFN_GET_PRIME in - // i915_private_android_types.h - #define USE_GRALLOC1 - #endif // MFX_C2_USE_PRIME --#endif // HAVE_GRALLOC4 -+#endif -+ - #define DRV_I915 - #include - -diff --git a/c2_utils/include/mfx_gralloc_instance.h b/c2_utils/include/mfx_gralloc_instance.h -index 6eb064a..ea41b99 100644 ---- a/c2_utils/include/mfx_gralloc_instance.h -+++ b/c2_utils/include/mfx_gralloc_instance.h -@@ -23,6 +23,7 @@ - #include "mfx_gralloc_interface.h" - #include "mfx_gralloc1.h" - #include "mfx_gralloc4.h" -+#include "mfx_mapper5.h" - - class MfxGrallocInstance - { -diff --git a/c2_utils/include/mfx_mapper5.h b/c2_utils/include/mfx_mapper5.h -new file mode 100644 -index 0000000..2b3a533 ---- /dev/null -+++ b/c2_utils/include/mfx_mapper5.h -@@ -0,0 +1,36 @@ -+// Copyright (c) 2024 Intel Corporation -+// SPDX-License-Identifier: Apache-2.0 -+ -+#pragma once -+ -+#include -+#include -+#include -+#include -+#include "mfx_gralloc_interface.h" -+ -+#ifdef USE_MAPPER5 -+using namespace android; -+using hardware::hidl_vec; -+using hardware::hidl_handle; -+ -+class MfxMapper5Module : public IMfxGrallocModule -+{ -+public: -+ virtual c2_status_t Init() override; -+ -+ virtual ~MfxMapper5Module(); -+ -+ virtual c2_status_t GetBufferDetails(const buffer_handle_t handle, -+ BufferDetails* details) override; -+ virtual c2_status_t GetBackingStore(const buffer_handle_t rawHandle, uint64_t *id) override; -+ virtual buffer_handle_t ImportBuffer(const buffer_handle_t rawHandle) override; -+ virtual c2_status_t FreeBuffer(const buffer_handle_t rawHandle); -+ virtual c2_status_t LockFrame(buffer_handle_t handle, uint8_t** data, C2PlanarLayout *layout); -+ virtual c2_status_t UnlockFrame(buffer_handle_t handle); -+ -+private: -+ AIMapper *m_mapper; -+}; -+ -+#endif -diff --git a/c2_utils/src/mfx_gralloc_instance.cpp b/c2_utils/src/mfx_gralloc_instance.cpp -index 614da9a..fd1cc15 100644 ---- a/c2_utils/src/mfx_gralloc_instance.cpp -+++ b/c2_utils/src/mfx_gralloc_instance.cpp -@@ -38,11 +38,17 @@ std::shared_ptr MfxGrallocInstance::getInstance() - std::lock_guard lock(m_mutex); - if (nullptr == m_instance) - { --#ifdef USE_GRALLOC4 -+#ifdef USE_MAPPER5 -+ MFX_DEBUG_TRACE_MSG("using mapper5"); -+ ALOGI("using mapper5"); -+ m_instance = std::make_shared(); -+#elif USE_GRALLOC4 - MFX_DEBUG_TRACE_MSG("using gralloc4"); -+ ALOGI("using gralloc4"); - m_instance = std::make_shared(); - #else - MFX_DEBUG_TRACE_MSG("using gralloc1"); -+ ALOGI("using gralloc1"); - m_instance = std::make_shared(); - #endif - if(C2_OK != m_instance->Init()) -diff --git a/c2_utils/src/mfx_mapper5.cpp b/c2_utils/src/mfx_mapper5.cpp -new file mode 100644 -index 0000000..12a4822 ---- /dev/null -+++ b/c2_utils/src/mfx_mapper5.cpp -@@ -0,0 +1,371 @@ -+// Copyright (c) 2024 Intel Corporation -+// SPDX-License-Identifier: Apache-2.0 -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include // dlopen -+#include -+#include -+#include -+#include -+ -+#include "mfx_mapper5.h" -+#include "cros_gralloc/cros_gralloc_helpers.h" -+#include "mfx_c2_utils.h" -+#include "mfx_debug.h" -+#include "mfx_c2_debug.h" -+ -+using namespace aidl::android::hardware::graphics::allocator; -+using aidl::android::hardware::graphics::common::BufferUsage; -+using aidl::android::hardware::graphics::common::ChromaSiting; -+using aidl::android::hardware::graphics::common::Dataspace; -+using aidl::android::hardware::graphics::common::ExtendableType; -+using aidl::android::hardware::graphics::common::PlaneLayout; -+using aidl::android::hardware::graphics::common::PlaneLayoutComponent; -+using aidl::android::hardware::graphics::common::PlaneLayoutComponentType; -+using aidl::android::hardware::graphics::common::PlaneLayout; -+using aidl::android::hardware::graphics::common::StandardMetadataType; -+using android::hardware::graphics::common::V1_2::PixelFormat; -+using android::hardware::graphics::mapper::StandardMetadata; -+using android::hardware::hidl_handle; -+ -+using ADataspace = aidl::android::hardware::graphics::common::Dataspace; -+using APixelFormat = aidl::android::hardware::graphics::common::PixelFormat; -+ -+#ifdef USE_MAPPER5 -+ -+static const auto kIAllocatorServiceName = IAllocator::descriptor + std::string("/default"); -+static const auto kIAllocatorMinimumVersion = 2; -+ -+#undef MFX_DEBUG_MODULE_NAME -+#define MFX_DEBUG_MODULE_NAME "mfx_mapper5" -+ -+ -+typedef AIMapper_Error (*AIMapper_loadIMapperFn)(AIMapper *_Nullable *_Nonnull outImplementation); -+ -+static std::shared_ptr waitForAllocator() { -+ if (__builtin_available(android 31, *)) { -+ if (!AServiceManager_isDeclared(kIAllocatorServiceName.c_str())) { -+ return nullptr; -+ } -+ auto allocator = IAllocator::fromBinder( -+ ndk::SpAIBinder(AServiceManager_waitForService(kIAllocatorServiceName.c_str()))); -+ if (!allocator) { -+ ALOGE("AIDL IAllocator declared but failed to get service"); -+ return nullptr; -+ } -+ -+ int32_t version = 0; -+ if (!allocator->getInterfaceVersion(&version).isOk()) { -+ ALOGE("Failed to query interface version"); -+ return nullptr; -+ } -+ if (version < kIAllocatorMinimumVersion) { -+ return nullptr; -+ } -+ return allocator; -+ } else { -+ return nullptr; -+ } -+} -+ -+static void *loadIMapperLibrary() { -+ static void *imapperLibrary = []() -> void * { -+ auto allocator = waitForAllocator(); -+ std::string mapperSuffix; -+ auto status = allocator->getIMapperLibrarySuffix(&mapperSuffix); -+ if (!status.isOk()) { -+ ALOGE("Failed to get IMapper library suffix"); -+ return nullptr; -+ } -+ std::string lib_name = "mapper." + mapperSuffix + ".so"; -+ void *so = android_load_sphal_library(lib_name.c_str(), RTLD_LOCAL | RTLD_NOW); -+ if (!so) { -+ ALOGE("Failed to load mapper.minigbm.so"); -+ } -+ return so; -+ }(); -+ return imapperLibrary; -+} -+ -+template -+static auto getStandardMetadata(AIMapper *mapper, buffer_handle_t bufferHandle) -+ -> decltype(StandardMetadata::value::decode(NULL, 0)) { -+ using Value = typename StandardMetadata::value; -+ // TODO: Tune for common-case better -+ android::FatVector buffer; -+ int32_t sizeRequired = mapper->v5.getStandardMetadata(bufferHandle, -+ static_cast(T), -+ buffer.data(), buffer.size()); -+ if (sizeRequired < 0) { -+ ALOGW_IF(-AIMAPPER_ERROR_UNSUPPORTED != sizeRequired, -+ "Unexpected error %d from valid getStandardMetadata call", -sizeRequired); -+ return std::nullopt; -+ } -+ if ((size_t)sizeRequired > buffer.size()) { -+ buffer.resize(sizeRequired); -+ sizeRequired = mapper->v5.getStandardMetadata(bufferHandle, static_cast(T), -+ buffer.data(), buffer.size()); -+ } -+ if (sizeRequired < 0 || (size_t)sizeRequired > buffer.size()) { -+ ALOGW("getStandardMetadata failed, received %d with buffer size %zd", sizeRequired, -+ buffer.size()); -+ // Generate a fail type -+ return std::nullopt; -+ } -+ return Value::decode(buffer.data(), sizeRequired); -+} -+ -+c2_status_t MfxMapper5Module::Init() -+{ -+ MFX_DEBUG_TRACE_FUNC; -+ -+ void *so = loadIMapperLibrary(); -+ if (!so) { -+ ALOGE("loadIMapperLibrary failed"); -+ return C2_CORRUPTED; -+ } -+ auto loadIMapper = (AIMapper_loadIMapperFn)dlsym(so, "AIMapper_loadIMapper"); -+ AIMapper *mapper = nullptr; -+ AIMapper_Error error = loadIMapper(&mapper); -+ if (error != AIMAPPER_ERROR_NONE) { -+ ALOGE("AIMapper_loadIMapper failed %d", error); -+ return C2_CORRUPTED; -+ } -+ -+ m_mapper = mapper; -+ -+ return C2_OK; -+} -+ -+MfxMapper5Module::~MfxMapper5Module() -+{ -+} -+ -+c2_status_t MfxMapper5Module::GetBufferDetails(const buffer_handle_t handle, BufferDetails *details) -+{ -+ MFX_DEBUG_TRACE_FUNC; -+ c2_status_t res = C2_OK; -+ -+ if (nullptr == m_mapper) { -+ ALOGE("mapper is null"); -+ return C2_NO_INIT; -+ } -+ -+ auto importedHandle = ImportBuffer(handle); -+ if (nullptr == importedHandle) { -+ ALOGE("ImportBuffer failed"); -+ return C2_CORRUPTED; -+ } -+ -+ do -+ { -+ details->handle = handle; -+ -+ details->prime = handle->data[0]; -+ MFX_DEBUG_TRACE_I32(details->prime); -+ -+ auto width = -+ getStandardMetadata(m_mapper, importedHandle); -+ if (!width.has_value()) { -+ ALOGE("WIDTH get failed"); -+ res = C2_CORRUPTED; -+ break; -+ } -+ -+ details->width = details->allocWidth = *width; -+ MFX_DEBUG_TRACE_I32(details->width); -+ -+ auto height = -+ getStandardMetadata(m_mapper, importedHandle); -+ if (!height.has_value()) { -+ ALOGE("HEIGHT get failed"); -+ res = C2_CORRUPTED; -+ break; -+ } -+ details->height = details->allocHeight = *height; -+ MFX_DEBUG_TRACE_I32(details->height); -+ -+ auto pixelFormat = -+ getStandardMetadata(m_mapper, -+ importedHandle); -+ if (!pixelFormat.has_value()) { -+ ALOGE("PIXEL_FORMAT_REQUESTED get failed"); -+ res = C2_CORRUPTED; -+ break; -+ } -+ -+ details->format = static_cast>(*pixelFormat); -+ MFX_DEBUG_TRACE_I32(details->format); -+ -+ auto layouts_opt = getStandardMetadata(m_mapper, -+ importedHandle); -+ if (!(layouts_opt.has_value())) { -+ ALOGE("PLANE_LAYOUTS get failed"); -+ res = C2_CORRUPTED; -+ break; -+ } -+ -+ std::vector &layouts = *layouts_opt; -+ details->planes_count = layouts.size(); -+ MFX_DEBUG_TRACE_I32(details->planes_count); -+ -+ for(int i = 0; i < layouts.size(); i++) -+ { -+ details->pitches[i] = layouts[i].strideInBytes; -+ MFX_DEBUG_TRACE_STREAM("details->pitches[" << i << "] = " << details->pitches[i]); -+ } -+ } while (false); -+ -+ (void)FreeBuffer(importedHandle); -+ MFX_DEBUG_TRACE__android_c2_status_t(res); -+ return res; -+} -+ -+c2_status_t MfxMapper5Module::GetBackingStore(const buffer_handle_t handle, uint64_t *id) -+{ -+ MFX_DEBUG_TRACE_FUNC; -+ c2_status_t res = C2_OK; -+ -+ auto importedHandle = ImportBuffer(handle); -+ if (nullptr == importedHandle) { -+ ALOGE("ImportBuffer failed"); -+ return C2_CORRUPTED; -+ } -+ -+ auto bufferId = -+ getStandardMetadata(m_mapper, importedHandle); -+ if (!bufferId.has_value()) { -+ ALOGE("BufferId get failed"); -+ res = C2_CORRUPTED; -+ } else { -+ *id = *bufferId; -+ } -+ -+ (void)FreeBuffer(importedHandle); -+ MFX_DEBUG_TRACE__android_c2_status_t(res); -+ return res; -+} -+ -+buffer_handle_t MfxMapper5Module::ImportBuffer(const buffer_handle_t rawHandle) -+{ -+ MFX_DEBUG_TRACE_FUNC; -+ c2_status_t res = C2_OK; -+ buffer_handle_t outBuffer = nullptr; -+ -+ if (nullptr == m_mapper) { -+ ALOGE("mapper is null"); -+ res = C2_NO_INIT; -+ } -+ -+ if (C2_OK == res) -+ { -+ AIMapper_Error error = m_mapper->v5.importBuffer(hardware::hidl_handle(rawHandle), -+ &outBuffer); -+ if (error != AIMAPPER_ERROR_NONE) { -+ ALOGE("importBuffer failed"); -+ res = C2_CORRUPTED; -+ } -+ } -+ -+ MFX_DEBUG_TRACE__android_c2_status_t(res); -+ return outBuffer; -+} -+ -+c2_status_t MfxMapper5Module::FreeBuffer(const buffer_handle_t handle) -+{ -+ MFX_DEBUG_TRACE_FUNC; -+ c2_status_t res = C2_OK; -+ -+ if (nullptr == m_mapper) { -+ ALOGE("mapper is null"); -+ res = C2_NO_INIT; -+ } -+ -+ if (C2_OK == res) -+ { -+ AIMapper_Error error = m_mapper->v5.freeBuffer(handle); -+ if (error != AIMAPPER_ERROR_NONE) { -+ ALOGE("freeBuffer failed"); -+ res = C2_CORRUPTED; -+ } -+ } -+ -+ MFX_DEBUG_TRACE__android_c2_status_t(res); -+ return res; -+} -+ -+c2_status_t MfxMapper5Module::LockFrame(buffer_handle_t handle, uint8_t** data, -+ C2PlanarLayout *layout) -+{ -+ MFX_DEBUG_TRACE_FUNC; -+ c2_status_t res = C2_OK; -+ -+ if (!layout) { -+ ALOGE("layout is invalid"); -+ return C2_BAD_VALUE; -+ } -+ -+ if (nullptr == m_mapper) { -+ ALOGE("mapper is null"); -+ return C2_NO_INIT; -+ } -+ -+ BufferDetails details; -+ -+ if (C2_OK != GetBufferDetails(handle, &details)) { -+ ALOGE("GetBufferDetails failed"); -+ return C2_BAD_VALUE; -+ } -+ -+ const ARect region{0, 0, details.width, details.height}; -+ uint8_t *img = nullptr; -+ AIMapper_Error error = m_mapper->v5.lock(handle, -+ AHardwareBuffer_UsageFlags::AHARDWAREBUFFER_USAGE_CPU_READ_MASK | -+ AHardwareBuffer_UsageFlags::AHARDWAREBUFFER_USAGE_CPU_WRITE_MASK, -+ region, -1, (void**)&img); -+ if (error != AIMAPPER_ERROR_NONE) { -+ ALOGE("lock failed"); -+ res = C2_CORRUPTED; -+ } -+ -+ if (C2_OK == res) { -+ InitNV12PlaneLayout(details.pitches, layout); -+ InitNV12PlaneData(details.pitches[C2PlanarLayout::PLANE_Y], -+ details.allocHeight, (uint8_t*)img, data); -+ } -+ -+ return res; -+} -+ -+c2_status_t MfxMapper5Module::UnlockFrame(buffer_handle_t handle) -+{ -+ MFX_DEBUG_TRACE_FUNC; -+ c2_status_t res = C2_OK; -+ -+ if (nullptr == m_mapper) { -+ ALOGE("mapper is null"); -+ return C2_NO_INIT; -+ } -+ -+ int releaseFence = -1; -+ AIMapper_Error error = m_mapper->v5.unlock(handle, &releaseFence); -+ if (error != AIMAPPER_ERROR_NONE) { -+ ALOGE("unlock failed"); -+ res = C2_CORRUPTED; -+ } -+ -+ MFX_DEBUG_TRACE__android_c2_status_t(res); -+ return res; -+} -+ -+#endif --- -2.45.2 -