dragonboards: refactor graphics configs to independent fragments am: 6749c910f3 am: 9e382093fe

Original change: https://android-review.googlesource.com/c/device/linaro/dragonboard/+/2750582

Change-Id: Ieea84b8cfc90d526abb48530a9f3222a6df1d8d2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk
index 64d3f9e..08c5c57 100644
--- a/BoardConfigCommon.mk
+++ b/BoardConfigCommon.mk
@@ -37,19 +37,6 @@
 PRODUCT_FULL_TREBLE := true
 BOARD_VNDK_VERSION := current
 
-# Mesa DRM hwcomposer
-BOARD_USES_DRM_HWCOMPOSER := true
-BOARD_GPU_DRIVERS := freedreno
-TARGET_USES_HWC2 := true
-
-ifeq ($(TARGET_BUILD_MESA),true)
-BOARD_MESA3D_USES_MESON_BUILD := true
-BOARD_MESA3D_GALLIUM_DRIVERS := freedreno
-BOARD_MESA3D_VULKAN_DRIVERS := freedreno
-else
-BOARD_USE_CUSTOMIZED_MESA := true
-endif
-
 # WiFi
 WPA_SUPPLICANT_VERSION := VER_0_8_X
 BOARD_WPA_SUPPLICANT_DRIVER := NL80211
diff --git a/db845c.mk b/db845c.mk
index ea61e1e..ac760d8 100644
--- a/db845c.mk
+++ b/db845c.mk
@@ -1,4 +1,7 @@
 $(call inherit-product, device/linaro/dragonboard/full.mk)
+$(call inherit-product, device/linaro/dragonboard/shared/graphics/drm_hwcomposer/device.mk)
+$(call inherit-product, device/linaro/dragonboard/shared/graphics/mesa/device.mk)
+$(call inherit-product, device/linaro/dragonboard/shared/graphics/minigbm_msm/device.mk)
 $(call inherit-product, device/linaro/dragonboard/db845c/device.mk)
 
 ifeq ($(TARGET_KERNEL_USE),5.4)
diff --git a/db845c/BoardConfig.mk b/db845c/BoardConfig.mk
index 83db993..c710008 100644
--- a/db845c/BoardConfig.mk
+++ b/db845c/BoardConfig.mk
@@ -51,3 +51,8 @@
 # dlkm partition
 include device/linaro/dragonboard/shared/utils/dlkm_loader/BoardConfig.mk
 BOARD_SEPOLICY_DIRS += device/linaro/dragonboard/shared/utils/dlkm_loader/sepolicy/
+
+# Graphics
+include device/linaro/dragonboard/shared/graphics/drm_hwcomposer/BoardConfig.mk
+include device/linaro/dragonboard/shared/graphics/mesa/BoardConfig.mk
+BOARD_SEPOLICY_DIRS += device/linaro/dragonboard/shared/graphics/minigbm_msm/sepolicy/
diff --git a/db845c/device.mk b/db845c/device.mk
index 23f16a9..792fac8 100644
--- a/db845c/device.mk
+++ b/db845c/device.mk
@@ -58,8 +58,6 @@
 PRODUCT_VENDOR_PROPERTIES += ro.soc.manufacturer=Qualcomm
 PRODUCT_VENDOR_PROPERTIES += ro.soc.model=SDM845
 
-PRODUCT_PROPERTY_OVERRIDES += ro.sf.lcd_density=160
-
 # Copy firmware files
 $(call inherit-product-if-exists, vendor/linaro/db845c/$(EXPECTED_LINARO_VENDOR_VERSION)/device.mk)
 $(call inherit-product-if-exists, vendor/linaro/rb5/$(EXPECTED_LINARO_VENDOR_VERSION)/device.mk)
diff --git a/full.mk b/full.mk
index 66f6414..fd9fb18 100644
--- a/full.mk
+++ b/full.mk
@@ -41,59 +41,6 @@
     android.hardware.drm-service.clearkey \
     android.hardware.drm-service.widevine
 
-# Mesa
-PRODUCT_PACKAGES += \
-    libGLES_mesa \
-    libEGL_mesa \
-    libGLESv1_CM_mesa \
-    libGLESv2_mesa \
-    libgallium_dri \
-    libglapi
-
-TARGET_BUILD_MESA ?= false
-ifeq ($(TARGET_BUILD_MESA), true)
-   PRODUCT_SOONG_NAMESPACES += \
-       external/mesa3d
-endif
-
-PRODUCT_PROPERTY_OVERRIDES += \
-    ro.hardware.gralloc=minigbm_msm \
-    ro.hardware.hwcomposer=drm \
-    ro.opengles.version=196608 \
-    persist.demo.rotationlock=1
-
-# Vulkan
-PRODUCT_PACKAGES += \
-       vulkan.freedreno
-
-PRODUCT_COPY_FILES += \
-       frameworks/native/data/etc/android.hardware.vulkan.level-1.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.vulkan.level.xml \
-       frameworks/native/data/etc/android.hardware.vulkan.version-1_1.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.vulkan.version.xml \
-       frameworks/native/data/etc/android.software.vulkan.deqp.level-2021-03-01.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.vulkan.deqp.level.xml \
-
-PRODUCT_VENDOR_PROPERTIES += \
-       ro.hardware.vulkan=freedreno
-
-# Will need to enable this after ANDROID_external_memory_android_hardware_buffer lands in mesa
-#TARGET_USES_VULKAN = true
-
-#
-# Hardware Composer HAL
-#
-PRODUCT_PACKAGES += \
-    hwcomposer.drm \
-    android.hardware.graphics.composer@2.3-impl \
-    android.hardware.graphics.composer@2.3-service
-
-#
-# Gralloc HAL
-#
-PRODUCT_PACKAGES += \
-    gralloc.minigbm_msm \
-    android.hardware.graphics.allocator@4.0-service.minigbm_msm \
-    android.hardware.graphics.mapper@4.0-impl.minigbm_msm
-
-
 # Use Launcher3QuickStep
 PRODUCT_PACKAGES += Launcher3QuickStep
 
diff --git a/rb5.mk b/rb5.mk
index 8d4f174..50a31e8 100644
--- a/rb5.mk
+++ b/rb5.mk
@@ -1,4 +1,7 @@
 $(call inherit-product, device/linaro/dragonboard/full.mk)
+$(call inherit-product, device/linaro/dragonboard/shared/graphics/drm_hwcomposer/device.mk)
+$(call inherit-product, device/linaro/dragonboard/shared/graphics/mesa/device.mk)
+$(call inherit-product, device/linaro/dragonboard/shared/graphics/minigbm_msm/device.mk)
 $(call inherit-product, device/linaro/dragonboard/rb5/device.mk)
 
 # Product overrides
diff --git a/rb5/BoardConfig.mk b/rb5/BoardConfig.mk
index ac26584..24195a5 100644
--- a/rb5/BoardConfig.mk
+++ b/rb5/BoardConfig.mk
@@ -48,3 +48,8 @@
 # dlkm partition
 include device/linaro/dragonboard/shared/utils/dlkm_loader/BoardConfig.mk
 BOARD_SEPOLICY_DIRS += device/linaro/dragonboard/shared/utils/dlkm_loader/sepolicy/
+
+# Graphics
+include device/linaro/dragonboard/shared/graphics/drm_hwcomposer/BoardConfig.mk
+include device/linaro/dragonboard/shared/graphics/mesa/BoardConfig.mk
+BOARD_SEPOLICY_DIRS += device/linaro/dragonboard/shared/graphics/minigbm_msm/sepolicy/
diff --git a/rb5/device.mk b/rb5/device.mk
index a1c1b59..34cfea4 100644
--- a/rb5/device.mk
+++ b/rb5/device.mk
@@ -56,8 +56,6 @@
 PRODUCT_VENDOR_PROPERTIES += ro.soc.manufacturer=Qualcomm
 PRODUCT_VENDOR_PROPERTIES += ro.soc.model=QRB5165
 
-PRODUCT_PROPERTY_OVERRIDES += ro.sf.lcd_density=160
-
 # Copy firmware files
 $(call inherit-product-if-exists, vendor/linaro/rb5/$(EXPECTED_LINARO_VENDOR_VERSION)/device.mk)
 
diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts
index 22e9d45..014cd9c 100644
--- a/sepolicy/file_contexts
+++ b/sepolicy/file_contexts
@@ -54,7 +54,6 @@
 
 /vendor/bin/grep									u:object_r:vendor_toolbox_exec:s0
 /vendor/bin/hw/android\.hardware\.gatekeeper@1\.0-service\.software			u:object_r:hal_gatekeeper_default_exec:s0
-/vendor/bin/hw/android\.hardware\.graphics\.allocator@4\.0-service\.minigbm_msm		u:object_r:hal_graphics_allocator_default_exec:s0
 /vendor/bin/pd-mapper									u:object_r:pd_mapper_exec:s0
 /vendor/bin/qrtr-cfg									u:object_r:qrtr_exec:s0
 /vendor/bin/qrtr-ns									u:object_r:qrtr_exec:s0
@@ -68,12 +67,9 @@
 /vendor/lib(64)?/dri/.*									u:object_r:same_process_hal_file:s0
 /vendor/lib(64)?/hw/gralloc\.gbm\.so							u:object_r:same_process_hal_file:s0
 /vendor/lib(64)?/hw/android\.hardware\.health@2\.0-impl-2\.1-cuttlefish\.so		u:object_r:same_process_hal_file:s0
-/vendor/lib(64)?/hw/gralloc\.minigbm_msm\.so						u:object_r:same_process_hal_file:s0
-/vendor/lib(64)?/hw/android\.hardware\.graphics\.mapper@4\.0-impl\.minigbm_msm\.so	u:object_r:same_process_hal_file:s0
 /vendor/lib(64)?/hw/vulkan\.freedreno\.so						u:object_r:same_process_hal_file:s0
 /vendor/lib(64)?/libdrm\.so								u:object_r:same_process_hal_file:s0
 /vendor/lib(64)?/libdrm_freedreno\.so							u:object_r:same_process_hal_file:s0
 /vendor/lib(64)?/libgbm_mesa\.so							u:object_r:same_process_hal_file:s0
 /vendor/lib(64)?/libglapi\.so								u:object_r:same_process_hal_file:s0
-/vendor/lib(64)?/libminigbm_gralloc_msm\.so						u:object_r:same_process_hal_file:s0
 /vendor/lib(64)?/libqrtr\.so								u:object_r:same_process_hal_file:s0
diff --git a/shared/graphics/drm_hwcomposer/BoardConfig.mk b/shared/graphics/drm_hwcomposer/BoardConfig.mk
new file mode 100644
index 0000000..8c35fbf
--- /dev/null
+++ b/shared/graphics/drm_hwcomposer/BoardConfig.mk
@@ -0,0 +1,19 @@
+#
+# Copyright (C) 2013 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.
+#
+
+# DRM hwcomposer
+BOARD_USES_DRM_HWCOMPOSER := true
+TARGET_USES_HWC2 := true
diff --git a/shared/graphics/drm_hwcomposer/device.mk b/shared/graphics/drm_hwcomposer/device.mk
new file mode 100644
index 0000000..7e3c75e
--- /dev/null
+++ b/shared/graphics/drm_hwcomposer/device.mk
@@ -0,0 +1,24 @@
+#
+# Copyright (C) 2014 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.
+#
+
+# Hardware Composer HAL
+PRODUCT_PACKAGES := \
+    hwcomposer.drm \
+    android.hardware.graphics.composer@2.3-impl \
+    android.hardware.graphics.composer@2.3-service
+
+PRODUCT_PROPERTY_OVERRIDES := \
+    ro.hardware.hwcomposer=drm
diff --git a/shared/graphics/mesa/BoardConfig.mk b/shared/graphics/mesa/BoardConfig.mk
new file mode 100644
index 0000000..8836060
--- /dev/null
+++ b/shared/graphics/mesa/BoardConfig.mk
@@ -0,0 +1,24 @@
+#
+# Copyright (C) 2013 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.
+#
+
+BOARD_GPU_DRIVERS := freedreno
+ifeq ($(TARGET_BUILD_MESA),true)
+BOARD_MESA3D_USES_MESON_BUILD := true
+BOARD_MESA3D_GALLIUM_DRIVERS := freedreno
+BOARD_MESA3D_VULKAN_DRIVERS := freedreno
+else
+BOARD_USE_CUSTOMIZED_MESA := true
+endif
diff --git a/shared/graphics/mesa/device.mk b/shared/graphics/mesa/device.mk
new file mode 100644
index 0000000..f38c568
--- /dev/null
+++ b/shared/graphics/mesa/device.mk
@@ -0,0 +1,55 @@
+#
+# Copyright (C) 2014 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.
+#
+
+# GLES
+PRODUCT_PACKAGES := \
+    libGLES_mesa \
+    libEGL_mesa \
+    libGLESv1_CM_mesa \
+    libGLESv2_mesa \
+    libgallium_dri \
+    libglapi
+
+TARGET_BUILD_MESA ?= false
+ifeq ($(TARGET_BUILD_MESA), true)
+   PRODUCT_SOONG_NAMESPACES += \
+       external/mesa3d
+endif
+
+PRODUCT_PROPERTY_OVERRIDES := \
+    ro.sf.lcd_density=160 \
+    ro.opengles.version=196608 \
+    persist.demo.rotationlock=1
+
+PRODUCT_COPY_FILES += \
+    frameworks/native/data/etc/android.hardware.opengles.aep.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.opengles.aep.xml \
+    frameworks/native/data/etc/android.software.opengles.deqp.level-2022-03-01.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.opengles.deqp.level.xml
+
+# Vulkan
+PRODUCT_PACKAGES += \
+    vulkan.freedreno
+
+PRODUCT_COPY_FILES += \
+    frameworks/native/data/etc/android.hardware.vulkan.compute-0.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.vulkan.compute.xml \
+    frameworks/native/data/etc/android.hardware.vulkan.level-1.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.vulkan.level.xml \
+    frameworks/native/data/etc/android.hardware.vulkan.version-1_1.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.vulkan.version.xml \
+    frameworks/native/data/etc/android.software.vulkan.deqp.level-2021-03-01.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.vulkan.deqp.level.xml
+
+PRODUCT_VENDOR_PROPERTIES += \
+    ro.hardware.vulkan=freedreno
+
+# Will need to enable this after ANDROID_external_memory_android_hardware_buffer lands in Freedreno
+#TARGET_USES_VULKAN = true
diff --git a/shared/graphics/minigbm_msm/device.mk b/shared/graphics/minigbm_msm/device.mk
new file mode 100644
index 0000000..fcdb6a0
--- /dev/null
+++ b/shared/graphics/minigbm_msm/device.mk
@@ -0,0 +1,23 @@
+#
+# Copyright (C) 2014 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.
+#
+
+PRODUCT_PACKAGES := \
+    gralloc.minigbm_msm \
+    android.hardware.graphics.allocator@4.0-service.minigbm_msm \
+    android.hardware.graphics.mapper@4.0-impl.minigbm_msm
+
+PRODUCT_PROPERTY_OVERRIDES := \
+    ro.hardware.gralloc=minigbm_msm
diff --git a/shared/graphics/minigbm_msm/sepolicy/file_contexts b/shared/graphics/minigbm_msm/sepolicy/file_contexts
new file mode 100644
index 0000000..3cd05e9
--- /dev/null
+++ b/shared/graphics/minigbm_msm/sepolicy/file_contexts
@@ -0,0 +1,11 @@
+/vendor/bin/hw/android\.hardware\.graphics\.allocator-service\.minigbm			u:object_r:hal_graphics_allocator_default_exec:s0
+/vendor/bin/hw/android\.hardware\.graphics\.allocator@4\.0-service\.minigbm		u:object_r:hal_graphics_allocator_default_exec:s0
+/vendor/bin/hw/android\.hardware\.graphics\.allocator@4\.0-service\.minigbm_msm		u:object_r:hal_graphics_allocator_default_exec:s0
+
+/vendor/lib(64)?/libminigbm_gralloc.so							u:object_r:same_process_hal_file:s0
+/vendor/lib(64)?/libminigbm_gralloc4_utils.so						u:object_r:same_process_hal_file:s0
+/vendor/lib(64)?/libminigbm_gralloc_msm\.so						u:object_r:same_process_hal_file:s0
+/vendor/lib(64)?/hw/android\.hardware\.graphics\.mapper@4\.0-impl\.minigbm\.so		u:object_r:same_process_hal_file:s0
+/vendor/lib(64)?/hw/android\.hardware\.graphics\.mapper@4\.0-impl\.minigbm_msm\.so	u:object_r:same_process_hal_file:s0
+/vendor/lib(64)?/hw/gralloc\.minigbm_msm\.so						u:object_r:same_process_hal_file:s0
+/vendor/lib(64)?/hw/mapper\.minigbm\.so							u:object_r:same_process_hal_file:s0
diff --git a/shared/graphics/minigbm_msm/sepolicy/minigbm_debug.te b/shared/graphics/minigbm_msm/sepolicy/minigbm_debug.te
new file mode 100644
index 0000000..b486932
--- /dev/null
+++ b/shared/graphics/minigbm_msm/sepolicy/minigbm_debug.te
@@ -0,0 +1,2 @@
+vendor_public_prop(vendor_minigbm_debug_prop)
+set_prop(vendor_init, vendor_minigbm_debug_prop)
diff --git a/shared/graphics/minigbm_msm/sepolicy/minigbm_macros b/shared/graphics/minigbm_msm/sepolicy/minigbm_macros
new file mode 100644
index 0000000..a2b0523
--- /dev/null
+++ b/shared/graphics/minigbm_msm/sepolicy/minigbm_macros
@@ -0,0 +1,6 @@
+#####################################
+# minigbm_access(client_domain)
+# Allow client_domain to communicate with the minigbm lib
+define(`minigbm_access', `
+allow $1 vendor_minigbm_debug_prop:file { getattr map open read };
+')
diff --git a/shared/graphics/minigbm_msm/sepolicy/property_contexts b/shared/graphics/minigbm_msm/sepolicy/property_contexts
new file mode 100644
index 0000000..f6a7d01
--- /dev/null
+++ b/shared/graphics/minigbm_msm/sepolicy/property_contexts
@@ -0,0 +1 @@
+vendor.minigbm.debug  u:object_r:vendor_minigbm_debug_prop:s0