From d500d5ee8d8484adbd1c90a1c1b1d1203e5e0b2f Mon Sep 17 00:00:00 2001 From: Konsta Date: Wed, 11 Dec 2024 01:35:24 +0200 Subject: [PATCH] gbm_mesa: Add android makefiles and init/vintf fragments * APEX is based on cuttlefish implementation [1]. [1]: https://android.googlesource.com/device/google/cuttlefish/+/refs/tags/android-16.0.0_r1/guest/hals/gralloc/ --- Android.bp | 28 +++++++ cros_gralloc/aidl/Android.bp | 81 +++++++++++++++++++ .../aidl/allocator.minigbm_gbm_mesa.rc | 7 ++ cros_gralloc/aidl/apex_file_contexts | 5 ++ cros_gralloc/aidl/apex_linkerconfig.json | 4 + cros_gralloc/aidl/apex_manifest.json | 5 ++ cros_gralloc/gralloc4/Android.bp | 63 +++++++++++++++ ....allocator@4.0-service.minigbm_gbm_mesa.rc | 24 ++++++ cros_gralloc/mapper_stablec/Android.bp | 27 +++++++ .../mapper.minigbm_gbm_mesa.xml | 9 +++ gbm_mesa_driver/Android.bp | 40 +++++++++ 11 files changed, 293 insertions(+) create mode 100644 cros_gralloc/aidl/allocator.minigbm_gbm_mesa.rc create mode 100644 cros_gralloc/aidl/apex_file_contexts create mode 100644 cros_gralloc/aidl/apex_linkerconfig.json create mode 100644 cros_gralloc/aidl/apex_manifest.json create mode 100644 cros_gralloc/gralloc4/android.hardware.graphics.allocator@4.0-service.minigbm_gbm_mesa.rc create mode 100644 cros_gralloc/mapper_stablec/mapper.minigbm_gbm_mesa.xml create mode 100644 gbm_mesa_driver/Android.bp diff --git a/Android.bp b/Android.bp index c1a69eb..e7daa47 100644 --- a/Android.bp +++ b/Android.bp @@ -80,6 +80,7 @@ msm_cflags = [ "-DHAS_DMABUF_SYSTEM_HEAP", "-DQCOM_DISABLE_COMPRESSED_NV12", ] +arcvm_cflags = ["-DVIRTIO_GPU_NEXT"] mediatek_cflags = [ "-DDRV_MEDIATEK", @@ -103,6 +104,7 @@ cc_defaults { "intel": intel_cflags, "meson": meson_cflags, "msm": msm_cflags, + "arcvm": arcvm_cflags, "mt8186": mediatek_cflags + ["-DMTK_MT8186"], "mt8188": mediatek_cflags + ["-DMTK_MT8188G"], "mt8196": mediatek_cflags + ["-DMTK_MT8196"], @@ -316,3 +318,29 @@ cc_library_shared { defaults: ["minigbm_cros_gralloc0_defaults"], shared_libs: ["libminigbm_gralloc_msm"], } + +// ARCVM +cc_library_shared { + name: "libminigbm_gralloc_arcvm", + defaults: ["minigbm_cros_gralloc_library_defaults"], + cflags: arcvm_cflags, +} + +cc_library_shared { + name: "gralloc.minigbm_arcvm", + defaults: ["minigbm_cros_gralloc0_defaults"], + shared_libs: ["libminigbm_gralloc_arcvm"], +} + +// mediatek +cc_library_shared { + name: "libminigbm_gralloc_mediatek", + defaults: ["minigbm_cros_gralloc_library_defaults"], + cflags: mediatek_cflags, +} + +cc_library_shared { + name: "gralloc.minigbm_gbm_mesa", + defaults: ["minigbm_cros_gralloc0_defaults"], + shared_libs: ["libminigbm_gralloc_gbm_mesa"], +} diff --git a/cros_gralloc/aidl/Android.bp b/cros_gralloc/aidl/Android.bp index b52f806..98d8ee5 100644 --- a/cros_gralloc/aidl/Android.bp +++ b/cros_gralloc/aidl/Android.bp @@ -50,14 +50,95 @@ cc_binary { ], } +cc_binary { + name: "android.hardware.graphics.allocator-service.minigbm_gbm_mesa", + defaults: ["minigbm_cros_gralloc_defaults"], + relative_install_path: "hw", + init_rc: ["allocator.minigbm_gbm_mesa.rc"], + vintf_fragments: ["allocator.xml"], + vendor: true, + shared_libs: [ + "android.hardware.graphics.allocator-V2-ndk", + "android.hardware.graphics.mapper@4.0", + "libbase", + "libbinder_ndk", + "libgralloctypes", + "libhidlbase", + "liblog", + "libminigbm_gralloc4_utils_gbm_mesa", + "libminigbm_gralloc_gbm_mesa", + ], + static_libs: [ + "libaidlcommonsupport", + ], + srcs: [ + "Allocator.cpp", + "Main.cpp", + ], +} + filegroup { name: "allocator.minigbm.rc", srcs: ["allocator.rc"] } +filegroup { + name: "allocator.minigbm_gbm_mesa.rc", + srcs: ["allocator.minigbm_gbm_mesa.rc"], +} + prebuilt_etc { name: "allocator.minigbm.xml", src: "allocator.xml", sub_dir: "vintf", installable: false, } + +linker_config { + name: "android.hardware.graphics.allocator.minigbm_gbm_mesa-linker-config", + src: "apex_linkerconfig.json", + installable: false, +} + +genrule { + name: "gen-android.hardware.graphics.allocator.minigbm_gbm_mesa.rc", + srcs: [":allocator.minigbm_gbm_mesa.rc"], + out: ["android.hardware.graphics.allocator-service.minigbm_gbm_mesa.rc"], + cmd: "sed -E 's%/vendor/bin/%/apex/com.android.hardware.graphics.allocator.minigbm_gbm_mesa/bin/%' $(in) > $(out)", +} + +prebuilt_etc { + name: "android.hardware.graphics.allocator.minigbm_gbm_mesa.rc", + src: ":gen-android.hardware.graphics.allocator.minigbm_gbm_mesa.rc", + installable: false, +} + +apex { + name: "com.android.hardware.graphics.allocator.minigbm_gbm_mesa", + manifest: "apex_manifest.json", + file_contexts: "apex_file_contexts", + key: "com.android.hardware.key", + certificate: ":com.android.hardware.certificate", + updatable: false, + vendor: true, + + binaries: [ + "android.hardware.graphics.allocator-service.minigbm_gbm_mesa", + ], + native_shared_libs: [ + "dri_gbm", + "libgbm_mesa", + "libgbm_mesa_wrapper", + "mapper.minigbm_gbm_mesa", + ], + prebuilts: [ + "allocator.minigbm.xml", + "android.hardware.graphics.allocator.minigbm_gbm_mesa-linker-config", + "android.hardware.graphics.allocator.minigbm_gbm_mesa.rc", + "mapper.minigbm_gbm_mesa.xml", + ], + overrides: [ + "android.hardware.graphics.allocator-service.minigbm_gbm_mesa", + "mapper.minigbm_gbm_mesa", + ], +} diff --git a/cros_gralloc/aidl/allocator.minigbm_gbm_mesa.rc b/cros_gralloc/aidl/allocator.minigbm_gbm_mesa.rc new file mode 100644 index 0000000..4ffa834 --- /dev/null +++ b/cros_gralloc/aidl/allocator.minigbm_gbm_mesa.rc @@ -0,0 +1,7 @@ +service vendor.graphics.allocator /vendor/bin/hw/android.hardware.graphics.allocator-service.minigbm_gbm_mesa + class hal animation + user system + group graphics drmrpc + capabilities SYS_NICE + onrestart restart surfaceflinger + task_profiles ServiceCapacityLow diff --git a/cros_gralloc/aidl/apex_file_contexts b/cros_gralloc/aidl/apex_file_contexts new file mode 100644 index 0000000..ae29971 --- /dev/null +++ b/cros_gralloc/aidl/apex_file_contexts @@ -0,0 +1,5 @@ +(/.*)? u:object_r:vendor_file:s0 +/etc(/.*)? u:object_r:vendor_configs_file:s0 +/etc/linker.config.pb u:object_r:linkerconfig_file:s0 +/lib64(/.*)? u:object_r:same_process_hal_file:s0 +/bin/hw/android\.hardware\.graphics\.allocator-service\.minigbm_gbm_mesa u:object_r:hal_graphics_allocator_default_exec:s0 diff --git a/cros_gralloc/aidl/apex_linkerconfig.json b/cros_gralloc/aidl/apex_linkerconfig.json new file mode 100644 index 0000000..c858ae5 --- /dev/null +++ b/cros_gralloc/aidl/apex_linkerconfig.json @@ -0,0 +1,4 @@ +{ + // visible so that mapper can be loaded from the apex + "visible": true +} \ No newline at end of file diff --git a/cros_gralloc/aidl/apex_manifest.json b/cros_gralloc/aidl/apex_manifest.json new file mode 100644 index 0000000..70e6c31 --- /dev/null +++ b/cros_gralloc/aidl/apex_manifest.json @@ -0,0 +1,5 @@ +{ + "name": "com.android.hardware.graphics.allocator.minigbm_gbm_mesa", + "version": 1, + "vendorBootstrap": true +} diff --git a/cros_gralloc/gralloc4/Android.bp b/cros_gralloc/gralloc4/Android.bp index 34e3ee0..593fb7b 100644 --- a/cros_gralloc/gralloc4/Android.bp +++ b/cros_gralloc/gralloc4/Android.bp @@ -55,6 +55,21 @@ cc_library { ], } +cc_library { + name: "libminigbm_gralloc4_utils_gbm_mesa", + defaults: ["minigbm_cros_gralloc_defaults"], + vendor: true, + srcs: [ + "CrosGralloc4Utils.cc", + ], + shared_libs: [ + "android.hardware.graphics.mapper@4.0", + "libgralloctypes", + "libhidlbase", + "libminigbm_gralloc_gbm_mesa", + ], +} + cc_defaults { name: "minigbm_gralloc4_common_defaults", defaults: ["minigbm_cros_gralloc_defaults"], @@ -101,6 +116,14 @@ cc_binary { init_rc: ["android.hardware.graphics.allocator@4.0-service.minigbm_msm.rc"], } +cc_binary { + name: "android.hardware.graphics.allocator@4.0-service.minigbm_arcvm", + defaults: ["minigbm_gralloc4_allocator_defaults"], + shared_libs: ["libminigbm_gralloc_arcvm"], + vintf_fragment_modules: ["android.hardware.graphics.allocator@4.0.xml"], + init_rc: ["android.hardware.graphics.allocator@4.0-service.minigbm_arcvm.rc"], +} + cc_binary { name: "android.hardware.graphics.allocator@4.0-service.minigbm_intel", defaults: ["minigbm_gralloc4_allocator_defaults"], @@ -118,6 +141,22 @@ cc_binary { }, } +cc_binary { + name: "android.hardware.graphics.allocator@4.0-service.minigbm_mediatek", + defaults: ["minigbm_gralloc4_allocator_defaults"], + shared_libs: ["libminigbm_gralloc_mediatek"], + vintf_fragment_modules: ["android.hardware.graphics.allocator@4.0.xml"], + init_rc: ["android.hardware.graphics.allocator@4.0-service.minigbm_mediatek.rc"], +} + +cc_binary { + name: "android.hardware.graphics.allocator@4.0-service.minigbm_gbm_mesa", + defaults: ["minigbm_gralloc4_allocator_defaults"], + shared_libs: ["libminigbm_gralloc_gbm_mesa"], + vintf_fragment_modules: ["android.hardware.graphics.allocator@4.0.xml"], + init_rc: ["android.hardware.graphics.allocator@4.0-service.minigbm_gbm_mesa.rc"], +} + vintf_fragment { name: "android.hardware.graphics.mapper@4.0.xml", src: "android.hardware.graphics.mapper@4.0.xml", @@ -140,6 +179,14 @@ cc_library_shared { srcs: [":minigbm_gralloc4_mapper_files"], } +cc_library_shared { + name: "android.hardware.graphics.mapper@4.0-impl.minigbm_arcvm", + defaults: ["minigbm_gralloc4_common_defaults"], + shared_libs: ["libminigbm_gralloc_arcvm"], + vintf_fragment_modules: ["android.hardware.graphics.mapper@4.0.xml"], + srcs: [":minigbm_gralloc4_mapper_files"], +} + cc_library_shared { name: "android.hardware.graphics.mapper@4.0-impl.minigbm_intel", defaults: ["minigbm_gralloc4_common_defaults"], @@ -156,3 +203,19 @@ cc_library_shared { }, }, } + +cc_library_shared { + name: "android.hardware.graphics.mapper@4.0-impl.minigbm_mediatek", + defaults: ["minigbm_gralloc4_common_defaults"], + shared_libs: ["libminigbm_gralloc_mediatek"], + vintf_fragment_modules: ["android.hardware.graphics.mapper@4.0.xml"], + srcs: [":minigbm_gralloc4_mapper_files"], +} + +cc_library_shared { + name: "android.hardware.graphics.mapper@4.0-impl.minigbm_gbm_mesa", + defaults: ["minigbm_gralloc4_common_defaults"], + shared_libs: ["libminigbm_gralloc_gbm_mesa"], + vintf_fragment_modules: ["android.hardware.graphics.mapper@4.0.xml"], + srcs: [":minigbm_gralloc4_mapper_files"], +} diff --git a/cros_gralloc/gralloc4/android.hardware.graphics.allocator@4.0-service.minigbm_gbm_mesa.rc b/cros_gralloc/gralloc4/android.hardware.graphics.allocator@4.0-service.minigbm_gbm_mesa.rc new file mode 100644 index 0000000..ad3fd70 --- /dev/null +++ b/cros_gralloc/gralloc4/android.hardware.graphics.allocator@4.0-service.minigbm_gbm_mesa.rc @@ -0,0 +1,24 @@ +# +# Copyright 2020 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. +# + +service vendor.graphics.allocator-4-0 /vendor/bin/hw/android.hardware.graphics.allocator@4.0-service.minigbm_gbm_mesa + interface android.hardware.graphics.allocator@4.0::IAllocator default + class hal animation + user system + group graphics drmrpc + capabilities SYS_NICE + onrestart restart surfaceflinger + task_profiles ServiceCapacityLow diff --git a/cros_gralloc/mapper_stablec/Android.bp b/cros_gralloc/mapper_stablec/Android.bp index 401c177..710f606 100644 --- a/cros_gralloc/mapper_stablec/Android.bp +++ b/cros_gralloc/mapper_stablec/Android.bp @@ -43,9 +43,36 @@ cc_library_shared { cpp_std: "c++20", } +cc_library_shared { + name: "mapper.minigbm_gbm_mesa", + defaults: ["minigbm_gralloc4_common_defaults"], + vintf_fragments: ["mapper.minigbm_gbm_mesa.xml"], + shared_libs: [ + "android.hardware.graphics.allocator-V2-ndk", + "libminigbm_gralloc_gbm_mesa", + ], + header_libs: [ + "libbase_headers", + "libimapper_stablec", + "libimapper_providerutils", + ], + srcs: [ + ":minigbm_gralloc4_mapper_files", + "Mapper.cpp", + ], + cpp_std: "c++20", +} + prebuilt_etc { name: "mapper.minigbm.xml", src: "mapper.minigbm.xml", sub_dir: "vintf", installable: false, } + +prebuilt_etc { + name: "mapper.minigbm_gbm_mesa.xml", + src: "mapper.minigbm_gbm_mesa.xml", + sub_dir: "vintf", + installable: false, +} diff --git a/cros_gralloc/mapper_stablec/mapper.minigbm_gbm_mesa.xml b/cros_gralloc/mapper_stablec/mapper.minigbm_gbm_mesa.xml new file mode 100644 index 0000000..08ba7f4 --- /dev/null +++ b/cros_gralloc/mapper_stablec/mapper.minigbm_gbm_mesa.xml @@ -0,0 +1,9 @@ + + + mapper + 5.0 + + minigbm_gbm_mesa + + + diff --git a/gbm_mesa_driver/Android.bp b/gbm_mesa_driver/Android.bp new file mode 100644 index 0000000..d6c8be5 --- /dev/null +++ b/gbm_mesa_driver/Android.bp @@ -0,0 +1,40 @@ +// +// Copyright (C) 2022 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. + +cc_library_shared { + name: "libminigbm_gralloc_gbm_mesa", + defaults: ["minigbm_cros_gralloc_library_defaults"], + cflags: [ + "-DDRV_EXTERNAL", + "-DHAS_DMABUF_SYSTEM_HEAP", + ], + srcs: [ + "gbm_mesa_driver.cpp", + "gbm_mesa_internals.cpp", + ], + cpp_std: "c++17", + required: ["libgbm_mesa_wrapper"], +} + +cc_library_shared { + name: "libgbm_mesa_wrapper", + vendor: true, + srcs: ["gbm_mesa_wrapper.c"], + shared_libs: [ + "libdrm", + "libgbm_mesa", + "liblog", + ], +}