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/
This commit is contained in:
Konsta 2024-12-11 01:35:24 +02:00 committed by Brendan Szymanski
parent e297f9bacd
commit d500d5ee8d
11 changed files with 293 additions and 0 deletions

View file

@ -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"],
}

View file

@ -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",
],
}

View file

@ -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

View file

@ -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

View file

@ -0,0 +1,4 @@
{
// visible so that mapper can be loaded from the apex
"visible": true
}

View file

@ -0,0 +1,5 @@
{
"name": "com.android.hardware.graphics.allocator.minigbm_gbm_mesa",
"version": 1,
"vendorBootstrap": true
}

View file

@ -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"],
}

View file

@ -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

View file

@ -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,
}

View file

@ -0,0 +1,9 @@
<manifest version="1.0" type="device">
<hal format="native">
<name>mapper</name>
<version>5.0</version>
<interface>
<instance>minigbm_gbm_mesa</instance>
</interface>
</hal>
</manifest>

View file

@ -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",
],
}