# SPDX-License-Identifier: GPL-2.0-only

KDIR := $(TOP)/kernel_platform/msm-kernel

ifeq ($(CONFIG_ARCH_WAIPIO), y)
ifeq ($(CONFIG_ARCH_QTI_VM), y)
	include $(DISPLAY_ROOT)/config/gki_waipiodisptui.conf
	LINUX_INC +=	-include $(DISPLAY_ROOT)/config/gki_waipiodisptuiconf.h
else
	include $(DISPLAY_ROOT)/config/gki_waipiodisp.conf
	LINUX_INC +=	-include $(DISPLAY_ROOT)/config/gki_waipiodispconf.h
endif
endif

ifeq ($(CONFIG_ARCH_NEO), y)
	include $(DISPLAY_ROOT)/config/gki_neodisp.conf
	LINUX_INC +=	-include $(DISPLAY_ROOT)/config/gki_neodispconf.h
endif

ifeq ($(CONFIG_ARCH_PARROT), y)
	include $(DISPLAY_ROOT)/config/gki_parrotdisp.conf
	LINUX_INC +=	-include $(DISPLAY_ROOT)/config/gki_parrotdispconf.h
endif

ifeq ($(CONFIG_ARCH_KALAMA), y)
ifeq ($(CONFIG_ARCH_QTI_VM), y)
        include $(DISPLAY_ROOT)/config/gki_kalamadisptui.conf
        LINUX_INC += -include $(DISPLAY_ROOT)/config/gki_kalamadisptuiconf.h
else
	include $(DISPLAY_ROOT)/config/gki_kalamadisp.conf
	LINUX_INC += -include $(DISPLAY_ROOT)/config/gki_kalamadispconf.h
endif
endif

ifeq (y, $(findstring y, $(CONFIG_ARCH_SA8155) $(CONFIG_ARCH_SA6155) $(CONFIG_ARCH_SA8195)))
	include $(DISPLAY_ROOT)/config/augen3disp.conf
	LINUX_INC += -include $(DISPLAY_ROOT)/config/augen3dispconf.h
endif

LINUX_INC +=	-Iinclude/linux \
		-Iinclude/linux/drm

LINUX_INC +=	-I$(DISPLAY_ROOT) \
	-I$(DISPLAY_ROOT)/include \
	-I$(KERNEL_ROOT)/drivers/clk/qcom \
	-I$(KERNEL_SRC)/drivers/clk/qcom \
	-I$(DISPLAY_ROOT)/include/linux \
	-I$(DISPLAY_ROOT)/rotator \
	-I$(DISPLAY_ROOT)/msm \
	-I$(DISPLAY_ROOT)/msm/dp \
	-I$(DISPLAY_ROOT)/msm/dsi \
	-I$(DISPLAY_ROOT)/msm/sde \
	-I$(DISPLAY_ROOT)/include/uapi/display \

CDEFINES +=	-DANI_LITTLE_BYTE_ENDIAN \
	-DANI_LITTLE_BIT_ENDIAN \
	-DDOT11F_LITTLE_ENDIAN_HOST \
	-DANI_COMPILER_TYPE_GCC \
	-DANI_OS_TYPE_ANDROID=6 \
	-DPTT_SOCK_SVC_ENABLE \
	-Wall\
	-Werror\
	-D__linux__

KBUILD_CPPFLAGS += $(CDEFINES)

ccflags-y += $(LINUX_INC)

ifeq ($(call cc-option-yn, -Wmaybe-uninitialized),y)
EXTRA_CFLAGS += -Wmaybe-uninitialized
endif

KBUILD_EXTRA_SYMBOLS +=$(OUT)/obj/vendor/qcom/opensource/display-drivers/hdcp/Module.symvers
KBUILD_EXTRA_SYMBOLS +=$(OUT)/obj/vendor/qcom/opensource/display-drivers/msm/Module.symvers

ifeq ($(call cc-option-yn, -Wheader-guard),y)
EXTRA_CFLAGS += -Wheader-guard
endif

ifneq ($(MODNAME), qdsp6v2)
CHIP_NAME ?= $(MODNAME)
CDEFINES += -DMULTI_IF_NAME=\"$(CHIP_NAME)\"
endif

######### CONFIG_DRM_MSM ########
obj-m += msm_drm.o

msm_drm-$(CONFIG_HDCP_QSEECOM) := ../hdcp/msm_hdcp.o

msm_drm-$(CONFIG_MSM_SDE_ROTATOR) += ../rotator/sde_rotator_dev.o \
				     ../rotator/sde_rotator_dev.o \
				     ../rotator/sde_rotator_core.o \
				     ../rotator/sde_rotator_base.o \
				     ../rotator/sde_rotator_formats.o \
				     ../rotator/sde_rotator_util.o \
				     ../rotator/sde_rotator_io_util.o \
				     ../rotator/sde_rotator_smmu.o \
				     ../rotator/sde_rotator_r1_wb.o \
				     ../rotator/sde_rotator_r1_pipe.o \
				     ../rotator/sde_rotator_r1_ctl.o \
				     ../rotator/sde_rotator_r1.o \
				     ../rotator/sde_rotator_r3.o

ifeq ($(CONFIG_MSM_SDE_ROTATOR), y)
msm_drm-$(CONFIG_SYNC_FILE) += ../rotator/sde_rotator_sync.o

msm_drm-$(CONFIG_DEBUG_FS) += ../rotator/sde_rotator_debug.o \
			      ../rotator/sde_rotator_r1_debug.o \
			      ../rotator/sde_rotator_r3_debug.o
endif

msm_drm-$(CONFIG_DRM_SDE_VM) += sde/sde_vm_common.o \
				sde/sde_vm_primary.o \
				sde/sde_vm_trusted.o \
				sde/sde_vm_msgq.o

msm_drm-$(CONFIG_DRM_MSM_DP) += dp/dp_altmode.o \
				dp/dp_parser.o \
				dp/dp_power.o \
				dp/dp_catalog.o \
				dp/dp_catalog_v420.o \
				dp/dp_catalog_v200.o \
				dp/dp_aux.o \
				dp/dp_panel.o \
				dp/dp_link.o \
				dp/dp_ctrl.o \
				dp/dp_audio.o \
				dp/dp_debug.o \
				dp/dp_hpd.o \
				dp/dp_aux_bridge.o \
				dp/dp_bridge_hpd.o \
				dp/dp_mst_sim.o \
				dp/dp_mst_sim_helper.o \
				dp/dp_gpio_hpd.o \
				dp/dp_lphw_hpd.o \
				dp/dp_display.o \
				dp/dp_drm.o \
				dp/dp_hdcp2p2.o \
				sde_hdcp_1x.o \
				sde_hdcp_2x.o \
				dp/dp_pll.o \
				dp/dp_pll_5nm.o \
				dp/dp_pll_4nm.o

msm_drm-$(CONFIG_DRM_MSM_DP_MST) += dp/dp_mst_drm.o

msm_drm-$(CONFIG_DRM_MSM_DP_USBPD_LEGACY) += dp/dp_usbpd.o

msm_drm-$(CONFIG_DRM_MSM_SDE) += sde/sde_crtc.o \
				 sde/sde_encoder.o \
				 sde/sde_encoder_dce.o \
				 sde/sde_encoder_phys_vid.o \
				 sde/sde_encoder_phys_cmd.o \
				 sde/sde_irq.o sde/sde_core_irq.o \
				 sde/sde_core_perf.o \
				 sde/sde_rm.o \
				 sde/sde_kms_utils.o \
				 sde/sde_kms.o \
				 sde/sde_plane.o \
				 sde/sde_connector.o \
				 sde/sde_color_processing.o \
				 sde/sde_vbif.o \
				 sde_dbg.o \
				 sde_dbg_evtlog.o \
				 sde_io_util.o \
				 sde_vm_event.o \
				 sde/sde_hw_reg_dma_v1_color_proc.o \
				 sde/sde_hw_color_proc_v4.o \
				 sde/sde_hw_ad4.o \
				 sde/sde_hw_uidle.o \
				 sde_edid_parser.o \
				 sde/sde_hw_catalog.o \
				 sde/sde_hw_cdm.o \
				 sde/sde_hw_dspp.o \
				 sde/sde_hw_intf.o \
				 sde/sde_hw_lm.o \
				 sde/sde_hw_ctl.o \
				 sde/sde_hw_util.o \
				 sde/sde_hw_sspp.o \
				 sde/sde_hw_wb.o \
				 sde/sde_hw_pingpong.o \
				 sde/sde_hw_top.o \
				 sde/sde_hw_interrupts.o \
				 sde/sde_hw_vbif.o \
				 sde/sde_formats.o \
				 sde_power_handle.o \
				 sde/sde_hw_color_processing_v1_7.o \
				 sde/sde_reg_dma.o \
				 sde/sde_hw_reg_dma_v1.o \
				 sde/sde_hw_dsc.o \
				 sde/sde_hw_dsc_1_2.o \
				 sde/sde_hw_vdc.o \
				 sde/sde_hw_ds.o \
				 sde/sde_fence.o \
				 sde/sde_hw_qdss.o \
				 sde_dsc_helper.o \
				 sde_vdc_helper.o \
				 sde/sde_hw_dnsc_blur.o \
				 sde/sde_hw_rc.o

msm_drm-$(CONFIG_DRM_SDE_WB) += sde/sde_wb.o \
				sde/sde_encoder_phys_wb.o

msm_drm-$(CONFIG_DRM_SDE_RSC) += sde_rsc.o \
				 sde_rsc_hw.o \
				 sde_rsc_hw_v3.o

msm_drm-$(CONFIG_DRM_MSM_DSI) += dsi/dsi_phy.o \
				 dsi/dsi_pwr.o \
				 dsi/dsi_phy.o \
				 dsi/dsi_phy_hw_v3_0.o \
				 dsi/dsi_phy_hw_v4_0.o \
				 dsi/dsi_phy_hw_v5_0.o \
				 dsi/dsi_phy_timing_calc.o \
				 dsi/dsi_phy_timing_v3_0.o \
				 dsi/dsi_phy_timing_v4_0.o \
				 dsi/dsi_pll.o \
				 dsi/dsi_pll_5nm.o \
				 dsi/dsi_pll_4nm.o \
				 dsi/dsi_ctrl_hw_cmn.o \
				 dsi/dsi_ctrl_hw_2_2.o \
				 dsi/dsi_ctrl.o \
				 dsi/dsi_catalog.o \
				 dsi/dsi_drm.o \
				 dsi/dsi_display.o \
				 dsi/dsi_panel.o \
				 dsi/dsi_clk_manager.o \
				 dsi/dsi_display_test.o

msm_drm-$(CONFIG_DSI_PARSER) += dsi/dsi_parser.o

msm_drm-$(CONFIG_THERMAL_OF) += msm_cooling_device.o

msm_drm-$(CONFIG_DRM_MSM) += msm_atomic.o \
			     msm_fb.o \
			     msm_drv.o \
			     msm_gem.o \
			     msm_gem_prime.o \
			     msm_gem_vma.o \
			     msm_smmu.o \
			     msm_prop.o

CDEFINES += -DBUILD_TIMESTAMP=\"$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')\"

