#@TYPE: Machine
#@NAME: SA2150P
#@DESCRIPTION: Machine configuration for QTI SA2150P

require conf/machine/include/qcs40x.inc
require conf/machine/include/sa2150p-eap.inc

DEFAULTTUNE = "aarch64"

MACHINE_MNT_POINTS = "/firmware /persist /cache /dsp"

SERIAL_CONSOLES = "115200;ttyMSM0"

KERNEL_CONFIG = "${@['vendor/sa2150p-perf_defconfig', 'vendor/sa2150p_defconfig'][d.getVar('VARIANT', True) == ('' or 'debug')]}"

PREFERRED_VERSION_iproute2 = "4.4.0"

USRFS_FSCONFIG = "-C ${WORKDIR}/usrfs_fsconfig.conf"
USR_IMAGE_BASENAME  = "${MACHINE}-usrfs"
MAKEEXT4_MOUNT_OPT = "-a /"

BOOTIMAGE_TARGET = "${MACHINE}-boot.img"
CACHEIMAGE_TARGET = "${MACHINE}-cache.ext4"
PERSISTIMAGE_TARGET = "${MACHINE}-persist.ext4"
RECOVERYIMAGE_TARGET = "${MACHINE}-recoveryfs.ext4"
SYSTEMIMAGE_TARGET = "${MACHINE}-sysfs.ext4"
SYSTEMRWIMAGE_TARGET = "${MACHINE}-systemrw.ext4"
USERDATAIMAGE_TARGET = "${MACHINE}-usrfs.ext4"

# Sizes for EXT4 (in bytes)
SYSTEM_SIZE_EXT4 = "681574400"
SYSTEMRW_SIZE_EXT4 = "8388608"
USERDATA_SIZE_EXT4 = "5000000000"
CACHE_SIZE_EXT4 = "80000000"

# Enable dm-verity feature for non debug builds
DISTRO_FEATURES += "${@bb.utils.contains('VARIANT', 'perf', 'dm-verity', '', d)}"
DISTRO_FEATURES_FILTER_NATIVE += "${@bb.utils.contains('VARIANT', 'perf', 'dm-verity', '', d)}"

# Formats of root filesystem images.
IMAGE_FSTYPES += "ext4"
RECOVERY_IMAGE = "0"

KERNEL_IMAGETYPE = "Image.gz-dtb"
IMAGE_EXT4_EXTRA_OPTIONS = "${@bb.utils.contains('DISTRO_FEATURES','ro-rootfs',' -J -b 4096 ','',d)}"

DISTRO_FEATURES += "persist-image"
DISTRO_FEATURES += "ab-boot-support"
DISTRO_FEATURES_NATIVE += "ab-boot-support"
DISTRO_FEATURES:append = "vipertooth"

PREFERRED_PROVIDER_virtual/libgles1 = "adreno"
PREFERRED_PROVIDER_virtual/libgles2 = "adreno"
PREFERRED_PROVIDER_virtual/egl = "adreno"

QPERM_FILE_pn-start-script-ab-slot-util = "${bindir}/getslotsuffix:0:1000"
QPERM_FILE_pn-system-core = "${sysconfdir}/build.prop:5002:5002"
QPERM_FILE_pn-system-prop = "/build.prop:5002:5002"

BBMASK += "meta-qti-audio/recipes-products/images/machine-image.bbappend"
BBMASK += "meta-qti-audio-cal/"
BBMASK += "meta-qti-audio-external/"
BBMASK += "meta-qti-bt/"

# Enable coredump
SYSTEMD_ENABLE_COREDUMP = "1"
SYSTEMD_COREDUMP_PATH = "${userfsdatadir}/coredump"

# Enable SELinux
DISTRO_FEATURES += "selinux"
DISTRO_FEATURES_FILTER_NATIVE  += "selinux"
DEFAULT_ENFORCING = "enforcing"

# Set openssl (1.1.1) as openssl provider
PREFERRED_PROVIDER_openssl          = "openssl"
PREFERRED_VERSION_openssl           = "1.1.1a"
PREFERRED_PROVIDER_openssl-native   = "openssl-native"

# qti-adsp ensures cdsp subsystem is supported
MACHINE_FEATURES:append = " qti-adsp "
# qti-cdsp ensures cdsp subsystem is supported
MACHINE_FEATURES:append = " qti-cdsp "
# can ensures libcanwrapper is supported should be generic
MACHINE_FEATURES:append = " can"

# Enable early ethernet
DISTRO_FEATURES += "early-eth"

# Enable SDK feature
SDK_IMAGE = "1"
