# Add your debugging flag (or not) to CFLAGS
VCODEC_SOC_CHIP_NAME := $(strip $(subst ", , $(CONFIG_VENDOR_CHIP_PREFIX)))
VCODEC_SOC_CHIP_TYPE := $(strip $(subst ", , $(CONFIG_VENDOR_CHIP_SUFFIX)))

ifeq ($(CONFIG_VCODEC_PLATFORM_VCODECV300), y)
PLATFORM := VCodecV300
endif

ifeq ($(CONFIG_VCODEC_PLATFORM_VCODECV310), y)
EXTRA_CFLAGS += -DVCODEC_V310
EXTRA_CFLAGS += -DVCODEC_PLATFORM_ECONOMIC
PLATFORM := VCodecV310
endif

ifeq ($(CONFIG_VCODEC_PLATFORM_VCODECV320), y)
PLATFORM := VCodecV320
SMMU_VER := smmu_v3
EXTRA_CFLAGS += -DVCODECV320
EXTRA_CFLAGS += -DVCODEC_PLATFORM_ECONOMIC
endif

ifeq ($(CONFIG_VCODEC_PLATFORM_VCODECV500), y)
PLATFORM := VCodecV500
SMMU_VER := smmu_v2
EXTRA_CFLAGS += -DVCODECV500
endif

ifeq ($(CONFIG_VCODEC_PLATFORM_VCODECV520), y)
PLATFORM := VCodecV500
SMMU_VER := smmu_v3
EXTRA_CFLAGS += -DVCODECV520
EXTRA_CFLAGS += -DVCODECV500
endif

ifeq ($(CONFIG_VCODEC_PLATFORM_VCODECV600), y)
ifeq ($(pcie_udp_verify),true)
PLATFORM := VCodecV700
SMMU_VER := smmu_v3
EXTRA_CFLAGS += -DVCODECV700
EXTRA_CFLAGS += -DVCODECV500
else
PLATFORM := VCodecV600
SMMU_VER := smmu_v3
EXTRA_CFLAGS += -DVCODECV600
EXTRA_CFLAGS += -DVCODECV500
endif
endif

ifeq ($(CONFIG_VCODEC_PLATFORM_VCODECV700), y)
PLATFORM := VCodecV700
SMMU_VER := smmu_v3
EXTRA_CFLAGS += -DVCODECV700
EXTRA_CFLAGS += -DVCODECV500
endif

ifeq ($(CONFIG_VCODEC_PLATFORM_VCODECV720), y)
PLATFORM := VCodecV720
SMMU_VER := smmu_v3
EXTRA_CFLAGS += -DVCODECV700
EXTRA_CFLAGS += -DVCODECV500
endif

ifeq ($(CONFIG_VCODEC_PLATFORM_VCODECV730), y)
PLATFORM := VCodecV730
SMMU_VER := smmu_v3
EXTRA_CFLAGS += -DVCODECV700
EXTRA_CFLAGS += -DVCODECV500
endif

ifeq ($(CONFIG_VCODEC_PLATFORM_VCODECV750), y)
PLATFORM := VCodecV750
SMMU_VER := smmu_v3
EXTRA_CFLAGS += -DVCODECV500
endif

ifeq ($(CONFIG_VCODEC_PLATFORM_VCODECV760), y)
PLATFORM := VCodecV760
SMMU_VER := smmu_v3
EXTRA_CFLAGS += -DVCODECV760
EXTRA_CFLAGS += -DVCODECV500
endif

ifeq ($(CONFIG_VCODEC_PLATFORM_VCODECV800), y)
PLATFORM := VCodecV800
SMMU_VER := smmu_v3
EXTRA_CFLAGS += -DVCODECV500
endif

ifeq ($(CONFIG_VCODEC_PLATFORM_VCODECV900), y)
PLATFORM := VCodecV900
SMMU_VER := smmu_v3
EXTRA_CFLAGS += -DVCODECV500
EXTRA_CFLAGS += -I$(srctree)/platform_source/vcodec/venc/venc_freq_new_platform
else
EXTRA_CFLAGS += -I$(srctree)/platform_source/vcodec/venc/venc_freq_old_platform
endif

ifeq ($(CONFIG_VCODEC_PLATFORM_VCODECV910), y)
PLATFORM := VCodecV910
SMMU_VER := smmu_v3
EXTRA_CFLAGS += -DVCODECV500
EXTRA_CFLAGS += -I$(srctree)/platform_source/vcodec/venc/venc_freq_new_platform
else
EXTRA_CFLAGS += -I$(srctree)/platform_source/vcodec/venc/venc_freq_old_platform
endif

include $(srctree)/platform_source/vcodec/venc/drv_venc_make.cfg

EXTRA_CFLAGS += $(VENC_CFLAGS) -fno-pic
EXTRA_CFLAGS += -I$(srctree)/platform_source/vcodec/venc
EXTRA_CFLAGS += -I$(srctree)/platform_source/vcodec/venc/include
EXTRA_CFLAGS += -I$(srctree)/platform_source/vcodec/venc/product/include
EXTRA_CFLAGS += -I$(srctree)/platform_source/vcodec/venc/product/$(PLATFORM)
EXTRA_CFLAGS += -I$(srctree)/platform_source/vcodec/venc/product/common

ifeq ($(VCODEC_SOC_CHIP_TYPE), )
EXTRA_CFLAGS += -I$(srctree)/drivers/platform_drivers/ap/platform/$(VCODEC_SOC_CHIP_NAME)
else
EXTRA_CFLAGS += -I$(srctree)/drivers/platform_drivers/ap/platform/$(VCODEC_SOC_CHIP_NAME)_$(VCODEC_SOC_CHIP_TYPE)
endif

ifeq ($(VCODEC_SOC_CHIP_TYPE), scout)
EXTRA_CFLAGS += -DSCOUT
endif

ifeq ($(CONFIG_SOC_PG_INFO), y)
EXTRA_CFLAGS += -I$(srctree)/drivers/platform_drivers/ap/platform/common
EXTRA_CFLAGS += -DCONFIG_SOC_PG_INFO
endif

ifeq ($(CONFIG_LOAD_VENC), y)
EXTRA_CFLAGS += -DLOAD_VENC
EXTRA_CFLAGS += -I$(srctree)/platform_source/vcodec/venc/load_image
obj-$(CONFIG_LOAD_VENC) += load_image/
endif

ifeq ($(es_low_freq),true)
EXTRA_CFLAGS += -DCONFIG_ES_VENC_LOW_FREQ
endif

ifeq ($(CONFIG_VCODEC_DEBUG), y)
EXTRA_CFLAGS += -DVENC_DEBUG_ENABLE
endif

MOD_NAME := vcodec_venc
obj-$(CONFIG_VCODEC_VENC) += $(MOD_NAME).o
$(MOD_NAME)-objs :=  venc_regulator.o    \
                    drv_venc_intf.o      \
                    drv_venc_efl.o       \
                    drv_venc_osal.o      \
                    drv_venc.o           \
                    drv_mem.o         \
                    power_manager.o   \
                    drv_venc_intf_check.o \
                    product/$(PLATFORM)/hal_venc.o

ifeq ($(pcie_udp_verify),true)
EXTRA_CFLAGS += -DPCIE_UDP
pcie_link_enable := true
endif

ifeq ($(CONFIG_PCIE_KPORT_EP_FPGA_VERIFY),y)
pcie_link_enable := true
endif

ifneq ($(filter VCodecV500 VCodecV600 VCodecV700 VCodecV720 VCodecV730 VCodecV750 VCodecV760 VCodecV800 VCodecV900 VCodecV910,$(PLATFORM)),)
$(MOD_NAME)-objs += product/common/venc/hal_venc_common.o \
                    product/common/hal_common.o
endif

EXTRA_CFLAGS += -I$(srctree)/platform_source/vcodec/venc/product/$(SMMU_VER)
$(MOD_NAME)-objs += product/$(SMMU_VER)/smmu.o

ifeq ($(SUPPORT_CMDLIST),YES)
EXTRA_CFLAGS += -I$(srctree)/platform_source/vcodec/venc/product/common/cmdlist
$(MOD_NAME)-objs += product/common/cmdlist/hal_cmdlist.o \
                    drv_cmdlist.o
endif

ifeq ($(VENC_MCORE_ENABLE),YES)
EXTRA_CFLAGS += -I$(srctree)/platform_source/vcodec/venc/mcore
$(MOD_NAME)-objs += mcore/drv_venc_ipc.o
$(MOD_NAME)-objs += mcore/drv_venc_mcore.o
endif

ifeq ($(VENC_WIRELESS_LOW_LATENCY_ENABLE), YES)
EXTRA_CFLAGS += -DENABLE_VENC_WIRELESS_LOW_LATENCY
EXTRA_CFLAGS += -I$(srctree)/platform_source/vcodec/venc/wireless_lowdelay
EXTRA_CFLAGS += -I$(srctree)/platform_source/vcodec/venc/wireless_lowdelay/$(PLATFORM)
$(MOD_NAME)-objs += wireless_lowdelay/drv_venc_queue.o
$(MOD_NAME)-objs += wireless_lowdelay/drv_venc_thread.o
$(MOD_NAME)-objs += wireless_lowdelay/drv_venc_wireless.o
$(MOD_NAME)-objs += wireless_lowdelay/hal_wireless_lowdelay_common_cfg.o
$(MOD_NAME)-objs += wireless_lowdelay/$(PLATFORM)/venc_wireless_lowdelay_cfg.o
endif

ifeq ($(CONFIG_LPMCU_INTERACT_THERMAL), y)
EXTRA_CFLAGS += -DENABLE_VENC_LOW_TEMP
$(MOD_NAME)-objs += venc_thermal_process.o
endif

# when compile module, do not compile dpm and pcie
ifeq ($(CONFIG_VCODEC_VENC),y)
ifeq ($(CONFIG_VCODEC_DPM_ENABLE),y)
EXTRA_CFLAGS += -DVENC_DPM_ENABLE
obj-$(CONFIG_VCODEC_VENC) +=  drv_venc_dpm.o
endif

ifeq ($(pcie_link_enable),true)
EXTRA_CFLAGS += -DPCIE_LINK
obj-$(CONFIG_VCODEC_VENC) += drv_venc_pcie.o
endif


ifeq ($(VENC_AXI_CLK_ENABLE),YES)
$(MOD_NAME)-objs += product/$(PLATFORM)/venc_aclk.o
endif
endif

EXTRA_CFLAGS += -DVENC_CLK_RATE_LEVEL_MAX=$(VENC_CLK_RATE_LEVEL_MAX)