Merge remote-tracking branch 'aosp/upstream-main' into 'aosp/master'
... to pull in crrev.com/c/3015656 to handle potential allocator
service startup failures for Cuttlefish.
Bug: b/187802138
Test: launch_cvd
Change-Id: Ibf547f86bda0046cafa6eb273c507a81954e9a88
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..ad09b32
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,238 @@
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package {
+ default_applicable_licenses: ["external_minigbm_license"],
+}
+
+// Added automatically by a large-scale-change that took the approach of
+// 'apply every license found to every target'. While this makes sure we respect
+// every license restriction, it may not be entirely correct.
+//
+// e.g. GPL in an MIT project might only apply to the contrib/ directory.
+//
+// Please consider splitting the single license below into multiple licenses,
+// taking care not to lose any license_kind information, and overriding the
+// default license using the 'licenses: [...]' property on targets as needed.
+//
+// For unused files, consider creating a 'fileGroup' with "//visibility:private"
+// to attach the license to, and including a comment whether the files may be
+// used in the current project.
+// See: http://go/android-license-faq
+license {
+ name: "external_minigbm_license",
+ visibility: [":__subpackages__"],
+ license_kinds: [
+ "SPDX-license-identifier-Apache-2.0",
+ "SPDX-license-identifier-BSD",
+ "SPDX-license-identifier-MIT",
+ ],
+ license_text: [
+ "LICENSE",
+ ],
+}
+
+filegroup {
+ name: "minigbm_core_files",
+
+ srcs: [
+ "amdgpu.c",
+ "drv.c",
+ "dumb_driver.c",
+ "exynos.c",
+ "helpers_array.c",
+ "helpers.c",
+ "i915.c",
+ "mediatek.c",
+ "msm.c",
+ "rockchip.c",
+ "vc4.c",
+ "virtgpu.c",
+ "virtgpu_cross_domain.c",
+ "virtgpu_virgl.c",
+ ],
+}
+
+filegroup {
+ name: "minigbm_gralloc_common_files",
+
+ srcs: [
+ "cros_gralloc/cros_gralloc_buffer.cc",
+ "cros_gralloc/cros_gralloc_helpers.cc",
+ "cros_gralloc/cros_gralloc_driver.cc",
+ ],
+}
+
+filegroup {
+ name: "minigbm_gralloc0_files",
+ srcs: ["cros_gralloc/gralloc0/gralloc0.cc"],
+}
+
+cc_defaults {
+ name: "minigbm_defaults",
+
+ cflags: [
+ "-D_GNU_SOURCE=1",
+ "-D_FILE_OFFSET_BITS=64",
+ "-Wall",
+ "-Wsign-compare",
+ "-Wpointer-arith",
+ "-Wcast-qual",
+ "-Wcast-align",
+ "-Wno-unused-parameter",
+ ],
+}
+
+cc_library_headers {
+ name: "minigbm_headers",
+ host_supported: true,
+ vendor_available: true,
+ export_include_dirs: ["."],
+}
+
+cc_defaults {
+ name: "minigbm_cros_gralloc_defaults",
+
+ defaults: ["minigbm_defaults"],
+
+ header_libs: [
+ "libhardware_headers",
+ "libnativebase_headers",
+ "libsystem_headers",
+ "minigbm_headers",
+ ],
+
+ static_libs: ["libarect"],
+
+ vendor: true,
+
+ shared_libs: [
+ "libcutils",
+ "libdrm",
+ "libnativewindow",
+ "libsync",
+ "liblog",
+ ],
+}
+
+cc_defaults {
+ name: "minigbm_cros_gralloc_library_defaults",
+
+ defaults: ["minigbm_cros_gralloc_defaults"],
+ srcs: [
+ ":minigbm_core_files",
+ ":minigbm_gralloc_common_files",
+ ],
+}
+
+cc_defaults {
+ name: "minigbm_cros_gralloc0_defaults",
+
+ defaults: ["minigbm_cros_gralloc_defaults"],
+ relative_install_path: "hw",
+
+ srcs: [":minigbm_gralloc0_files"],
+}
+
+cc_library {
+ name: "libgbm",
+ defaults: ["minigbm_defaults"],
+ host_supported: true,
+
+ srcs: [
+ ":minigbm_core_files",
+ "gbm.c",
+ "gbm_helpers.c",
+ ],
+
+ target: {
+ host: {
+ // Avoid linking to another host copy of libdrm; this library will cause
+ // binary GPU drivers to be loaded from the host, which might be linked
+ // to a system copy of libdrm, which conflicts with the AOSP one
+ allow_undefined_symbols: true,
+ header_libs: ["libdrm_headers"],
+ },
+ android: {
+ shared_libs: [
+ "libdrm",
+ "liblog"
+ ],
+ },
+ },
+ apex_available: [
+ "//apex_available:platform",
+ "com.android.virt",
+ ],
+
+ export_include_dirs: ["."],
+}
+
+// Generic
+cc_library_shared {
+ name: "libminigbm_gralloc",
+ defaults: ["minigbm_cros_gralloc_library_defaults"],
+}
+
+cc_library_shared {
+ name: "gralloc.minigbm",
+ defaults: ["minigbm_cros_gralloc0_defaults"],
+ shared_libs: ["libminigbm_gralloc"],
+}
+
+// Intel
+cc_library_shared {
+ name: "libminigbm_gralloc_intel",
+ defaults: ["minigbm_cros_gralloc_library_defaults"],
+ cflags: ["-DDRV_I915"],
+ enabled: false,
+ arch: {
+ x86: {
+ enabled: true,
+ },
+ x86_64: {
+ enabled: true,
+ },
+ },
+}
+
+cc_library_shared {
+ name: "gralloc.minigbm_intel",
+ defaults: ["minigbm_cros_gralloc0_defaults"],
+ shared_libs: ["libminigbm_gralloc_intel"],
+ enabled: false,
+ arch: {
+ x86: {
+ enabled: true,
+ },
+ x86_64: {
+ enabled: true,
+ },
+ },
+}
+
+// Meson
+cc_library_shared {
+ name: "libminigbm_gralloc_meson",
+ defaults: ["minigbm_cros_gralloc_library_defaults"],
+ cflags: ["-DDRV_MESON"],
+}
+
+cc_library_shared {
+ name: "gralloc.minigbm_meson",
+ defaults: ["minigbm_cros_gralloc0_defaults"],
+ shared_libs: ["libminigbm_gralloc_meson"],
+}
+
+// MSM
+cc_library_shared {
+ name: "libminigbm_gralloc_msm",
+ defaults: ["minigbm_cros_gralloc_library_defaults"],
+ cflags: ["-DDRV_MSM"],
+}
+
+cc_library_shared {
+ name: "gralloc.minigbm_msm",
+ defaults: ["minigbm_cros_gralloc0_defaults"],
+ shared_libs: ["libminigbm_gralloc_msm"],
+}
diff --git a/Android.mk b/Android.mk
deleted file mode 100644
index e45a898..0000000
--- a/Android.mk
+++ /dev/null
@@ -1,88 +0,0 @@
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-ifeq ($(strip $(BOARD_USES_MINIGBM)), true)
-
-MINIGBM_GRALLOC_MK := $(call my-dir)/Android.gralloc.mk
-LOCAL_PATH := $(call my-dir)
-intel_drivers := i915 i965
-
-MINIGBM_SRC := \
- amdgpu.c \
- dri.c \
- drv.c \
- dumb_driver.c \
- exynos.c \
- helpers_array.c \
- helpers.c \
- i915.c \
- mediatek.c \
- meson.c \
- msm.c \
- radeon.c \
- rockchip.c \
- vc4.c \
- virtio_gpu.c
-
-MINIGBM_CPPFLAGS := -std=c++14
-MINIGBM_CFLAGS := \
- -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 \
- -Wall -Wsign-compare -Wpointer-arith \
- -Wcast-qual -Wcast-align \
- -Wno-unused-parameter
-
-ifneq ($(filter $(intel_drivers), $(BOARD_GPU_DRIVERS)),)
-MINIGBM_CPPFLAGS += -DDRV_I915
-MINIGBM_CFLAGS += -DDRV_I915
-LOCAL_SHARED_LIBRARIES += libdrm_intel
-endif
-
-ifneq ($(filter meson, $(BOARD_GPU_DRIVERS)),)
-MINIGBM_CPPFLAGS += -DDRV_MESON
-MINIGBM_CFLAGS += -DDRV_MESON
-endif
-
-include $(CLEAR_VARS)
-
-SUBDIRS := cros_gralloc
-
-LOCAL_SHARED_LIBRARIES := \
- libcutils \
- libdrm
-
-LOCAL_SRC_FILES := $(MINIGBM_SRC)
-
-include $(MINIGBM_GRALLOC_MK)
-
-LOCAL_CFLAGS := $(MINIGBM_CFLAGS)
-LOCAL_CPPFLAGS := $(MINIGBM_CPPFLAGS)
-
-LOCAL_MODULE := gralloc.$(TARGET_BOARD_PLATFORM)
-LOCAL_MODULE_TAGS := optional
-# The preferred path for vendor HALs is /vendor/lib/hw
-LOCAL_PROPRIETARY_MODULE := true
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_MODULE_CLASS := SHARED_LIBRARIES
-LOCAL_MODULE_SUFFIX := $(TARGET_SHLIB_SUFFIX)
-LOCAL_HEADER_LIBRARIES += \
- libhardware_headers libnativebase_headers libsystem_headers
-LOCAL_SHARED_LIBRARIES += libnativewindow libsync liblog
-LOCAL_STATIC_LIBRARIES += libarect
-include $(BUILD_SHARED_LIBRARY)
-
-
-include $(CLEAR_VARS)
-LOCAL_SHARED_LIBRARIES := libcutils
-LOCAL_STATIC_LIBRARIES := libdrm
-
-LOCAL_SRC_FILES += $(MINIGBM_SRC) gbm.c gbm_helpers.c
-
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
-LOCAL_CFLAGS := $(MINIGBM_CFLAGS)
-LOCAL_CPPFLAGS := $(MINIGBM_CPPFLAGS)
-
-LOCAL_MODULE := libminigbm
-LOCAL_MODULE_TAGS := optional
-include $(BUILD_SHARED_LIBRARY)
-
-endif
diff --git a/METADATA b/METADATA
new file mode 100644
index 0000000..b281ea4
--- /dev/null
+++ b/METADATA
@@ -0,0 +1,17 @@
+name: "minigbm"
+description:
+ ""
+
+third_party {
+ url {
+ type: HOMEPAGE
+ value: "https://www.chromium.org/"
+ }
+ url {
+ type: GIT
+ value: "https://chromium.googlesource.com/chromiumos/platform/minigbm/"
+ }
+ version: ""
+ last_upgrade_date { year: 2018 month: 6 day: 25 }
+ license_type: NOTICE
+}
diff --git a/MODULE_LICENSE_BSD b/MODULE_LICENSE_BSD
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/MODULE_LICENSE_BSD
diff --git a/OWNERS.android b/OWNERS.android
new file mode 100644
index 0000000..be55e00
--- /dev/null
+++ b/OWNERS.android
@@ -0,0 +1,2 @@
+adelva@google.com
+natsu@google.com
diff --git a/cros_gralloc/gralloc0/gralloc0.cc b/cros_gralloc/gralloc0/gralloc0.cc
index b322bee..afd40d4 100644
--- a/cros_gralloc/gralloc0/gralloc0.cc
+++ b/cros_gralloc/gralloc0/gralloc0.cc
@@ -573,6 +573,8 @@
.lockAsync = gralloc0_lock_async,
.unlockAsync = gralloc0_unlock_async,
.lockAsync_ycbcr = gralloc0_lock_async_ycbcr,
+ .validateBufferSize = NULL,
+ .getTransportSize = NULL,
},
.alloc = nullptr,
diff --git a/cros_gralloc/gralloc3/Android.bp b/cros_gralloc/gralloc3/Android.bp
new file mode 100644
index 0000000..ac6931f
--- /dev/null
+++ b/cros_gralloc/gralloc3/Android.bp
@@ -0,0 +1,79 @@
+//
+// Copyright (C) 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.
+
+package {
+ // See: http://go/android-license-faq
+ // A large-scale-change added 'default_applicable_licenses' to import
+ // all of the 'license_kinds' from "external_minigbm_license"
+ // to get the below license kinds:
+ // SPDX-license-identifier-BSD
+ default_applicable_licenses: ["external_minigbm_license"],
+}
+
+filegroup {
+ name: "minigbm_gralloc3_allocator_files",
+ srcs: [
+ "CrosGralloc3Allocator.cc",
+ "CrosGralloc3AllocatorService.cc",
+ "CrosGralloc3Utils.cc",
+ ],
+}
+
+filegroup {
+ name: "minigbm_gralloc3_mapper_files",
+ srcs: [
+ "CrosGralloc3Mapper.cc",
+ "CrosGralloc3Utils.cc",
+ ],
+}
+
+cc_defaults {
+ name: "minigbm_gralloc3_common_defaults",
+ defaults: ["minigbm_cros_gralloc_defaults"],
+
+ shared_libs: [
+ "android.hardware.graphics.mapper@3.0",
+ "libgralloctypes",
+ "libhidlbase",
+ "libbase",
+ "libutils",
+ ],
+
+ cflags: ["-Wno-sign-compare"],
+ relative_install_path: "hw",
+}
+
+cc_defaults {
+ name: "minigbm_gralloc3_allocator_defaults",
+ defaults: ["minigbm_gralloc3_common_defaults"],
+
+ shared_libs: ["android.hardware.graphics.allocator@3.0"],
+ srcs: [":minigbm_gralloc3_allocator_files"],
+}
+
+cc_binary {
+ name: "android.hardware.graphics.allocator@3.0-service.minigbm",
+ defaults: ["minigbm_gralloc3_allocator_defaults"],
+ shared_libs: ["libminigbm_gralloc"],
+ init_rc: ["android.hardware.graphics.allocator@3.0-service.minigbm.rc"],
+}
+
+cc_library_shared {
+ name: "android.hardware.graphics.mapper@3.0-impl.minigbm",
+ defaults: ["minigbm_gralloc3_common_defaults"],
+ shared_libs: ["libminigbm_gralloc"],
+
+ srcs: [":minigbm_gralloc3_mapper_files"],
+}
diff --git a/cros_gralloc/gralloc3/android.hardware.graphics.allocator@3.0-service.minigbm.rc b/cros_gralloc/gralloc3/android.hardware.graphics.allocator@3.0-service.minigbm.rc
index 7377cee..14e2511 100644
--- a/cros_gralloc/gralloc3/android.hardware.graphics.allocator@3.0-service.minigbm.rc
+++ b/cros_gralloc/gralloc3/android.hardware.graphics.allocator@3.0-service.minigbm.rc
@@ -11,4 +11,4 @@
group graphics drmrpc
capabilities SYS_NICE
onrestart restart surfaceflinger
- writepid /dev/cpuset/system-background/tasks
+ task_profiles ServiceCapacityLow
diff --git a/cros_gralloc/gralloc4/Android.bp b/cros_gralloc/gralloc4/Android.bp
new file mode 100644
index 0000000..b9d94a9
--- /dev/null
+++ b/cros_gralloc/gralloc4/Android.bp
@@ -0,0 +1,97 @@
+//
+// Copyright (C) 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.
+
+package {
+ // See: http://go/android-license-faq
+ // A large-scale-change added 'default_applicable_licenses' to import
+ // all of the 'license_kinds' from "external_minigbm_license"
+ // to get the below license kinds:
+ // SPDX-license-identifier-Apache-2.0
+ // SPDX-license-identifier-BSD
+ default_applicable_licenses: ["external_minigbm_license"],
+}
+
+filegroup {
+ name: "minigbm_gralloc4_allocator_files",
+ srcs: [
+ "CrosGralloc4Allocator.cc",
+ "CrosGralloc4AllocatorService.cc",
+ "CrosGralloc4Utils.cc",
+ ],
+}
+
+filegroup {
+ name: "minigbm_gralloc4_mapper_files",
+ srcs: [
+ "CrosGralloc4Mapper.cc",
+ "CrosGralloc4Utils.cc",
+ ],
+}
+
+cc_defaults {
+ name: "minigbm_gralloc4_common_defaults",
+ defaults: ["minigbm_cros_gralloc_defaults"],
+
+ shared_libs: [
+ "android.hardware.graphics.mapper@4.0",
+ "libgralloctypes",
+ "libhidlbase",
+ "libbase",
+ "libutils",
+ ],
+
+ cflags: ["-Wno-sign-compare"],
+ relative_install_path: "hw",
+}
+
+cc_defaults {
+ name: "minigbm_gralloc4_allocator_defaults",
+ defaults: ["minigbm_gralloc4_common_defaults"],
+
+ shared_libs: ["android.hardware.graphics.allocator@4.0"],
+ srcs: [":minigbm_gralloc4_allocator_files"],
+}
+
+cc_binary {
+ name: "android.hardware.graphics.allocator@4.0-service.minigbm",
+ defaults: ["minigbm_gralloc4_allocator_defaults"],
+ shared_libs: ["libminigbm_gralloc"],
+ vintf_fragments: ["android.hardware.graphics.allocator@4.0.xml"],
+ init_rc: ["android.hardware.graphics.allocator@4.0-service.minigbm.rc"],
+}
+
+cc_binary {
+ name: "android.hardware.graphics.allocator@4.0-service.minigbm_msm",
+ defaults: ["minigbm_gralloc4_allocator_defaults"],
+ shared_libs: ["libminigbm_gralloc_msm"],
+ vintf_fragments: ["android.hardware.graphics.allocator@4.0.xml"],
+ init_rc: ["android.hardware.graphics.allocator@4.0-service.minigbm_msm.rc"],
+}
+
+cc_library_shared {
+ name: "android.hardware.graphics.mapper@4.0-impl.minigbm",
+ defaults: ["minigbm_gralloc4_common_defaults"],
+ shared_libs: ["libminigbm_gralloc"],
+ vintf_fragments: ["android.hardware.graphics.mapper@4.0.xml"],
+ srcs: [":minigbm_gralloc4_mapper_files"],
+}
+
+cc_library_shared {
+ name: "android.hardware.graphics.mapper@4.0-impl.minigbm_msm",
+ defaults: ["minigbm_gralloc4_common_defaults"],
+ shared_libs: ["libminigbm_gralloc_msm"],
+ vintf_fragments: ["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.rc b/cros_gralloc/gralloc4/android.hardware.graphics.allocator@4.0-service.minigbm.rc
index a96a6e1..4f8680b 100644
--- a/cros_gralloc/gralloc4/android.hardware.graphics.allocator@4.0-service.minigbm.rc
+++ b/cros_gralloc/gralloc4/android.hardware.graphics.allocator@4.0-service.minigbm.rc
@@ -21,4 +21,4 @@
group graphics drmrpc
capabilities SYS_NICE
onrestart restart surfaceflinger
- writepid /dev/cpuset/system-background/tasks
+ task_profiles ServiceCapacityLow
diff --git a/cros_gralloc/gralloc4/android.hardware.graphics.allocator@4.0-service.minigbm_msm.rc b/cros_gralloc/gralloc4/android.hardware.graphics.allocator@4.0-service.minigbm_msm.rc
new file mode 100644
index 0000000..8ecc94b
--- /dev/null
+++ b/cros_gralloc/gralloc4/android.hardware.graphics.allocator@4.0-service.minigbm_msm.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_msm
+ 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/gralloc4/android.hardware.graphics.allocator@4.0.xml b/cros_gralloc/gralloc4/android.hardware.graphics.allocator@4.0.xml
new file mode 100644
index 0000000..04695ef
--- /dev/null
+++ b/cros_gralloc/gralloc4/android.hardware.graphics.allocator@4.0.xml
@@ -0,0 +1,11 @@
+<manifest version="1.0" type="device">
+ <hal format="hidl">
+ <name>android.hardware.graphics.allocator</name>
+ <transport>hwbinder</transport>
+ <version>4.0</version>
+ <interface>
+ <name>IAllocator</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+</manifest>
diff --git a/cros_gralloc/gralloc4/android.hardware.graphics.mapper@4.0.xml b/cros_gralloc/gralloc4/android.hardware.graphics.mapper@4.0.xml
new file mode 100644
index 0000000..3160c77
--- /dev/null
+++ b/cros_gralloc/gralloc4/android.hardware.graphics.mapper@4.0.xml
@@ -0,0 +1,11 @@
+<manifest version="1.0" type="device">
+ <hal format="hidl">
+ <name>android.hardware.graphics.mapper</name>
+ <transport arch="32+64">passthrough</transport>
+ <version>4.0</version>
+ <interface>
+ <name>IMapper</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+</manifest>
diff --git a/virtgpu_virgl.c b/virtgpu_virgl.c
index 4cdb609..5b74744 100644
--- a/virtgpu_virgl.c
+++ b/virtgpu_virgl.c
@@ -612,7 +612,7 @@
virgl_add_combination(drv, DRM_FORMAT_RGB888, &LINEAR_METADATA, BO_USE_SW_MASK);
virgl_add_combination(drv, DRM_FORMAT_BGR888, &LINEAR_METADATA, BO_USE_SW_MASK);
virgl_add_combination(drv, DRM_FORMAT_ABGR16161616F, &LINEAR_METADATA,
- BO_USE_SW_MASK | BO_USE_TEXTURE_MASK);
+ BO_USE_SW_MASK | BO_USE_TEXTURE_MASK);
virgl_add_combination(drv, DRM_FORMAT_ABGR2101010, &LINEAR_METADATA,
BO_USE_SW_MASK | BO_USE_TEXTURE_MASK);
virgl_add_combination(drv, DRM_FORMAT_P010, &LINEAR_METADATA,