Audio: DLKM support for all audio modules

Switch to DLKM for all audio kernel modules.

Change-Id: I6a96023a21f655f873531af9ace81f2b01eb0f58
Signed-off-by: Laxminath Kasam <lkasam@codeaurora.org>
diff --git a/asoc/Android.mk b/asoc/Android.mk
new file mode 100644
index 0000000..9497ae9
--- /dev/null
+++ b/asoc/Android.mk
@@ -0,0 +1,73 @@
+# Android makefile for audio kernel modules
+
+# Assume no targets will be supported
+
+# Check if this driver needs be built for current target
+ifeq ($(call is-board-platform,sdm845),true)
+TARGET := sdm845
+AUDIO_SELECT  := CONFIG_SND_SOC_SDM845=m
+endif
+
+ifeq ($(call is-board-platform,sdm670),true)
+TARGET := sdm670
+AUDIO_SELECT  := CONFIG_SND_SOC_SDM670=m
+endif
+
+AUDIO_CHIPSET := audio
+# Build/Package only in case of supported target
+ifeq ($(call is-board-platform-in-list,sdm845 sdm670),true)
+
+LOCAL_PATH := $(call my-dir)
+
+# This makefile is only for DLKM
+ifneq ($(findstring vendor,$(LOCAL_PATH)),)
+
+ifneq ($(findstring opensource,$(LOCAL_PATH)),)
+	AUDIO_BLD_DIR := $(ANDROID_BUILD_TOP)/vendor/qcom/opensource/audio-kernel
+endif # opensource
+
+DLKM_DIR := $(TOP)/device/qcom/common/dlkm
+
+# Build audio.ko as $(AUDIO_CHIPSET)_audio.ko
+###########################################################
+# This is set once per LOCAL_PATH, not per (kernel) module
+KBUILD_OPTIONS := AUDIO_ROOT=$(AUDIO_BLD_DIR)
+
+# We are actually building audio.ko here, as per the
+# requirement we are specifying <chipset>_audio.ko as LOCAL_MODULE.
+# This means we need to rename the module to <chipset>_audio.ko
+# after audio.ko is built.
+KBUILD_OPTIONS += MODNAME=platform_dlkm
+KBUILD_OPTIONS += BOARD_PLATFORM=$(TARGET_BOARD_PLATFORM)
+KBUILD_OPTIONS += $(AUDIO_SELECT)
+
+###########################################################
+include $(CLEAR_VARS)
+LOCAL_MODULE              := $(AUDIO_CHIPSET)_platform.ko
+LOCAL_MODULE_KBUILD_NAME  := platform_dlkm.ko
+LOCAL_MODULE_TAGS         := optional
+LOCAL_MODULE_DEBUG_ENABLE := true
+LOCAL_MODULE_PATH         := $(KERNEL_MODULES_OUT)
+include $(DLKM_DIR)/AndroidKernelModule.mk
+###########################################################
+ifeq ($(call is-board-platform,sdm670),true)
+include $(CLEAR_VARS)
+LOCAL_MODULE              := $(AUDIO_CHIPSET)_cpe_lsm.ko
+LOCAL_MODULE_KBUILD_NAME  := cpe_lsm_dlkm.ko
+LOCAL_MODULE_TAGS         := optional
+LOCAL_MODULE_DEBUG_ENABLE := true
+LOCAL_MODULE_PATH         := $(KERNEL_MODULES_OUT)
+include $(DLKM_DIR)/AndroidKernelModule.mk
+endif
+###########################################################
+include $(CLEAR_VARS)
+LOCAL_MODULE              := $(AUDIO_CHIPSET)_machine_$(TARGET).ko
+LOCAL_MODULE_KBUILD_NAME  := machine_dlkm.ko
+LOCAL_MODULE_TAGS         := optional
+LOCAL_MODULE_DEBUG_ENABLE := true
+LOCAL_MODULE_PATH         := $(KERNEL_MODULES_OUT)
+include $(DLKM_DIR)/AndroidKernelModule.mk
+###########################################################
+
+endif # DLKM check
+endif # supported target check
diff --git a/asoc/Kbuild b/asoc/Kbuild
new file mode 100644
index 0000000..eb32e88
--- /dev/null
+++ b/asoc/Kbuild
@@ -0,0 +1,161 @@
+# We can build either as part of a standalone Kernel build or as
+# an external module.  Determine which mechanism is being used
+KERNEL_BUILD := 0
+
+
+ifeq ($(KERNEL_BUILD), 0)
+	# These are configurable via Kconfig for kernel-based builds
+	# Need to explicitly configure for Android-based builds
+	ifeq ($(CONFIG_ARCH_SDM845), y)
+		include $(AUDIO_ROOT)/config/sdm845auto.conf
+		export
+	endif
+	ifeq ($(CONFIG_ARCH_SDM670), y)
+		include $(AUDIO_ROOT)/config/sdm670auto.conf
+		export
+	endif
+endif
+
+
+# As per target team, build is done as follows:
+# Defconfig : build with default flags
+# Slub      : defconfig  + CONFIG_SLUB_DEBUG := y +
+#	      CONFIG_SLUB_DEBUG_ON := y + CONFIG_PAGE_POISONING := y
+# Perf      : Using appropriate msmXXXX-perf_defconfig
+#
+# Shipment builds (user variants) should not have any debug feature
+# enabled. This is identified using 'TARGET_BUILD_VARIANT'. Slub builds
+# are identified using the CONFIG_SLUB_DEBUG_ON configuration. Since
+# there is no other way to identify defconfig builds, QTI internal
+# representation of perf builds (identified using the string 'perf'),
+# is used to identify if the build is a slub or defconfig one. This
+# way no critical debug feature will be enabled for perf and shipment
+# builds. Other OEMs are also protected using the TARGET_BUILD_VARIANT
+# config.
+
+############ UAPI ############
+UAPI_DIR :=	uapi
+UAPI_INC :=	-I$(AUDIO_ROOT)/include/$(UAPI_DIR)
+
+############ COMMON ############
+COMMON_DIR :=	include
+COMMON_INC :=	-I$(AUDIO_ROOT)/$(COMMON_DIR)
+
+############ ASoC Drivers ############
+
+
+# for SDM6xx sound card driver
+ifeq ($(CONFIG_SND_SOC_SDM670), m)
+	MACHINE_OBJS += sdm660-common.o
+endif
+
+# for SDM6xx sound card driver
+ifeq ($(CONFIG_SND_SOC_INT_CODEC), m)
+	MACHINE_OBJS += sdm660-internal.o
+endif
+
+# for SDM6xx sound card driver
+ifeq ($(CONFIG_SND_SOC_EXT_CODEC), m)
+	MACHINE_OBJS += sdm660-external.o
+	MACHINE_OBJS += sdm660-ext-dai-links.o
+endif
+
+# for SDM845 sound card driver
+ifeq ($(CONFIG_SND_SOC_MACHINE_SDM845), m)
+	MACHINE_OBJS += sdm845.o
+endif
+
+ifeq ($(CONFIG_SND_SOC_CPE), m)
+	CPE_LSM_OBJS += msm-cpe-lsm.o
+endif
+
+ifeq ($(CONFIG_SND_SOC_QDSP6V2), m)
+	PLATFORM_OBJS += msm-audio-effects-q6-v2.o
+	PLATFORM_OBJS += msm-compress-q6-v2.o
+	PLATFORM_OBJS += msm-dai-fe.o
+	PLATFORM_OBJS += msm-dai-q6-hdmi-v2.o
+	PLATFORM_OBJS += msm-dai-q6-v2.o
+	PLATFORM_OBJS += msm-dai-slim.o
+	PLATFORM_OBJS += msm-dai-stub-v2.o
+	PLATFORM_OBJS += msm-ds2-dap-config.o
+	PLATFORM_OBJS += msm-lsm-client.o
+	PLATFORM_OBJS += msm-pcm-afe-v2.o
+	PLATFORM_OBJS += msm-pcm-dtmf-v2.o
+	PLATFORM_OBJS += msm-pcm-hostless.o
+	PLATFORM_OBJS += msm-pcm-host-voice-v2.o
+	PLATFORM_OBJS += msm-pcm-loopback-v2.o
+	PLATFORM_OBJS += msm-pcm-q6-noirq.o
+	PLATFORM_OBJS += msm-pcm-q6-v2.o
+	PLATFORM_OBJS += msm-pcm-routing-devdep.o
+	PLATFORM_OBJS += msm-pcm-routing-v2.o
+	PLATFORM_OBJS += msm-pcm-voice-v2.o
+	PLATFORM_OBJS += msm-pcm-voip-v2.o
+	PLATFORM_OBJS += msm-qti-pp-config.o
+	PLATFORM_OBJS += msm-transcode-loopback-q6-v2.o
+	PLATFORM_OBJS += platform_init.o
+endif
+
+LINUX_INC +=	-Iinclude/linux
+
+INCS :=		$(COMMON_INC) \
+		$(UAPI_INC)
+
+ifeq ($(CONFIG_ARCH_SDM845), y)
+INCS    +=  -include $(AUDIO_ROOT)/config/sdm845autoconf.h
+endif
+ifeq ($(CONFIG_ARCH_SDM670), y)
+INCS    +=  -include $(AUDIO_ROOT)/config/sdm670autoconf.h
+endif
+
+EXTRA_CFLAGS += $(INCS)
+
+
+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)
+
+# Currently, for versions of gcc which support it, the kernel Makefile
+# is disabling the maybe-uninitialized warning.  Re-enable it for the
+# AUDIO driver.  Note that we must use EXTRA_CFLAGS here so that it
+# will override the kernel settings.
+ifeq ($(call cc-option-yn, -Wmaybe-uninitialized),y)
+EXTRA_CFLAGS += -Wmaybe-uninitialized
+endif
+#EXTRA_CFLAGS += -Wmissing-prototypes
+
+ifeq ($(call cc-option-yn, -Wheader-guard),y)
+EXTRA_CFLAGS += -Wheader-guard
+endif
+
+
+KBUILD_EXTRA_SYMBOLS +=$(OUT)/obj/vendor/qcom/opensource/audio-kernel/dsp/Module.symvers
+KBUILD_EXTRA_SYMBOLS +=$(OUT)/obj/vendor/qcom/opensource/audio-kernel/asoc/codecs/Module.symvers
+KBUILD_EXTRA_SYMBOLS +=$(OUT)/obj/vendor/qcom/opensource/audio-kernel/asoc/codecs/wcd934x/Module.symvers
+KBUILD_EXTRA_SYMBOLS +=$(OUT)/obj/vendor/qcom/opensource/audio-kernel/asoc/codecs/sdm660_cdc/Module.symvers
+KBUILD_EXTRA_SYMBOLS +=$(OUT)/obj/vendor/qcom/opensource/audio-kernel/asoc/codecs/msm_sdw/Module.symvers
+# Module information used by KBuild framework
+obj-$(CONFIG_SND_SOC_QDSP6V2) += platform_dlkm.o
+platform_dlkm-y := $(PLATFORM_OBJS)
+
+obj-$(CONFIG_SND_SOC_MACHINE_SDM845) += machine_dlkm.o
+machine_dlkm-y := $(MACHINE_OBJS)
+
+obj-$(CONFIG_SND_SOC_EXT_CODEC) += machine_dlkm.o
+machine_dlkm-y := $(MACHINE_OBJS)
+
+obj-$(CONFIG_SND_SOC_INT_CODEC) += machine_dlkm.o
+machine_dlkm-y := $(MACHINE_OBJS)
+
+obj-$(CONFIG_SND_SOC_CPE) += cpe_lsm_dlkm.o
+cpe_lsm_dlkm-y := $(CPE_LSM_OBJS)
+
+# inject some build related information
+DEFINES += -DBUILD_TIMESTAMP=\"$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')\"
diff --git a/asoc/codecs/Android.mk b/asoc/codecs/Android.mk
new file mode 100644
index 0000000..863da5a
--- /dev/null
+++ b/asoc/codecs/Android.mk
@@ -0,0 +1,121 @@
+# Android makefile for audio kernel modules
+
+# Assume no targets will be supported
+
+# Check if this driver needs be built for current target
+ifeq ($(call is-board-platform,sdm845),true)
+AUDIO_SELECT  := CONFIG_SND_SOC_SDM845=m
+endif
+
+ifeq ($(call is-board-platform,sdm670),true)
+AUDIO_SELECT  := CONFIG_SND_SOC_SDM670=m
+endif
+
+AUDIO_CHIPSET := audio
+# Build/Package only in case of supported target
+ifeq ($(call is-board-platform-in-list,sdm845 sdm670),true)
+
+LOCAL_PATH := $(call my-dir)
+
+# This makefile is only for DLKM
+ifneq ($(findstring vendor,$(LOCAL_PATH)),)
+
+ifneq ($(findstring opensource,$(LOCAL_PATH)),)
+	AUDIO_BLD_DIR := $(ANDROID_BUILD_TOP)/vendor/qcom/opensource/audio-kernel
+endif # opensource
+
+DLKM_DIR := $(TOP)/device/qcom/common/dlkm
+
+# Build audio.ko as $(AUDIO_CHIPSET)_audio.ko
+###########################################################
+# This is set once per LOCAL_PATH, not per (kernel) module
+KBUILD_OPTIONS := AUDIO_ROOT=$(AUDIO_BLD_DIR)
+
+# We are actually building audio.ko here, as per the
+# requirement we are specifying <chipset>_audio.ko as LOCAL_MODULE.
+# This means we need to rename the module to <chipset>_audio.ko
+# after audio.ko is built.
+KBUILD_OPTIONS += MODNAME=wcd_core_dlkm
+KBUILD_OPTIONS += BOARD_PLATFORM=$(TARGET_BOARD_PLATFORM)
+KBUILD_OPTIONS += $(AUDIO_SELECT)
+
+###########################################################
+include $(CLEAR_VARS)
+LOCAL_MODULE              := $(AUDIO_CHIPSET)_wcd_core.ko
+LOCAL_MODULE_KBUILD_NAME  := wcd_core_dlkm.ko
+LOCAL_MODULE_TAGS         := optional
+LOCAL_MODULE_DEBUG_ENABLE := true
+LOCAL_MODULE_PATH         := $(KERNEL_MODULES_OUT)
+include $(DLKM_DIR)/AndroidKernelModule.mk
+###########################################################
+include $(CLEAR_VARS)
+LOCAL_MODULE              := $(AUDIO_CHIPSET)_wcd9xxx.ko
+LOCAL_MODULE_KBUILD_NAME  := wcd9xxx_dlkm.ko
+LOCAL_MODULE_TAGS         := optional
+LOCAL_MODULE_DEBUG_ENABLE := true
+LOCAL_MODULE_PATH         := $(KERNEL_MODULES_OUT)
+include $(DLKM_DIR)/AndroidKernelModule.mk
+###########################################################
+ifeq ($(call is-board-platform,sdm670),true)
+include $(CLEAR_VARS)
+LOCAL_MODULE              := $(AUDIO_CHIPSET)_wcd_cpe.ko
+LOCAL_MODULE_KBUILD_NAME  := wcd_cpe_dlkm.ko
+LOCAL_MODULE_TAGS         := optional
+LOCAL_MODULE_DEBUG_ENABLE := true
+LOCAL_MODULE_PATH         := $(KERNEL_MODULES_OUT)
+include $(DLKM_DIR)/AndroidKernelModule.mk
+endif
+###########################################################
+include $(CLEAR_VARS)
+LOCAL_MODULE              := $(AUDIO_CHIPSET)_wcd_spi.ko
+LOCAL_MODULE_KBUILD_NAME  := wcd_spi_dlkm.ko
+LOCAL_MODULE_TAGS         := optional
+LOCAL_MODULE_DEBUG_ENABLE := true
+LOCAL_MODULE_PATH         := $(KERNEL_MODULES_OUT)
+include $(DLKM_DIR)/AndroidKernelModule.mk
+###########################################################
+ifeq ($(call is-board-platform,sdm670),true)
+include $(CLEAR_VARS)
+LOCAL_MODULE              := $(AUDIO_CHIPSET)_wcd9335.ko
+LOCAL_MODULE_KBUILD_NAME  := wcd9335_dlkm.ko
+LOCAL_MODULE_TAGS         := optional
+LOCAL_MODULE_DEBUG_ENABLE := true
+LOCAL_MODULE_PATH         := $(KERNEL_MODULES_OUT)
+include $(DLKM_DIR)/AndroidKernelModule.mk
+endif
+###########################################################
+include $(CLEAR_VARS)
+LOCAL_MODULE              := $(AUDIO_CHIPSET)_wsa881x.ko
+LOCAL_MODULE_KBUILD_NAME  := wsa881x_dlkm.ko
+LOCAL_MODULE_TAGS         := optional
+LOCAL_MODULE_DEBUG_ENABLE := true
+LOCAL_MODULE_PATH         := $(KERNEL_MODULES_OUT)
+include $(DLKM_DIR)/AndroidKernelModule.mk
+###########################################################
+include $(CLEAR_VARS)
+LOCAL_MODULE              := $(AUDIO_CHIPSET)_stub.ko
+LOCAL_MODULE_KBUILD_NAME  := stub_dlkm.ko
+LOCAL_MODULE_TAGS         := optional
+LOCAL_MODULE_DEBUG_ENABLE := true
+LOCAL_MODULE_PATH         := $(KERNEL_MODULES_OUT)
+include $(DLKM_DIR)/AndroidKernelModule.mk
+###########################################################
+include $(CLEAR_VARS)
+LOCAL_MODULE              := $(AUDIO_CHIPSET)_mbhc.ko
+LOCAL_MODULE_KBUILD_NAME  := mbhc_dlkm.ko
+LOCAL_MODULE_TAGS         := optional
+LOCAL_MODULE_DEBUG_ENABLE := true
+LOCAL_MODULE_PATH         := $(KERNEL_MODULES_OUT)
+include $(DLKM_DIR)/AndroidKernelModule.mk
+###########################################################
+include $(CLEAR_VARS)
+LOCAL_MODULE              := $(AUDIO_CHIPSET)_hdmi.ko
+LOCAL_MODULE_KBUILD_NAME  := hdmi_dlkm.ko
+LOCAL_MODULE_TAGS         := optional
+LOCAL_MODULE_DEBUG_ENABLE := true
+LOCAL_MODULE_PATH         := $(KERNEL_MODULES_OUT)
+include $(DLKM_DIR)/AndroidKernelModule.mk
+###########################################################
+
+endif # DLKM check
+endif # supported target check
diff --git a/asoc/codecs/Kbuild b/asoc/codecs/Kbuild
new file mode 100644
index 0000000..83d4da4
--- /dev/null
+++ b/asoc/codecs/Kbuild
@@ -0,0 +1,181 @@
+# We can build either as part of a standalone Kernel build or as
+# an external module.  Determine which mechanism is being used
+KERNEL_BUILD := 0
+
+
+ifeq ($(KERNEL_BUILD), 0)
+	# These are configurable via Kconfig for kernel-based builds
+	# Need to explicitly configure for Android-based builds
+	ifeq ($(CONFIG_ARCH_SDM845), y)
+		include $(AUDIO_ROOT)/config/sdm845auto.conf
+		export
+	endif
+	ifeq ($(CONFIG_ARCH_SDM670), y)
+		include $(AUDIO_ROOT)/config/sdm670auto.conf
+		export
+	endif
+endif
+
+
+# As per target team, build is done as follows:
+# Defconfig : build with default flags
+# Slub      : defconfig  + CONFIG_SLUB_DEBUG := y +
+#	      CONFIG_SLUB_DEBUG_ON := y + CONFIG_PAGE_POISONING := y
+# Perf      : Using appropriate msmXXXX-perf_defconfig
+#
+# Shipment builds (user variants) should not have any debug feature
+# enabled. This is identified using 'TARGET_BUILD_VARIANT'. Slub builds
+# are identified using the CONFIG_SLUB_DEBUG_ON configuration. Since
+# there is no other way to identify defconfig builds, QTI internal
+# representation of perf builds (identified using the string 'perf'),
+# is used to identify if the build is a slub or defconfig one. This
+# way no critical debug feature will be enabled for perf and shipment
+# builds. Other OEMs are also protected using the TARGET_BUILD_VARIANT
+# config.
+
+############ UAPI ############
+UAPI_DIR :=	uapi
+UAPI_INC :=	-I$(AUDIO_ROOT)/include/$(UAPI_DIR)
+
+############ COMMON ############
+COMMON_DIR :=	include
+COMMON_INC :=	-I$(AUDIO_ROOT)/$(COMMON_DIR)
+
+############ ASoC Codecs ############
+ifeq ($(CONFIG_WCD9XXX_CODEC_CORE), m)
+	CORE_OBJS += wcd9xxx-rst.o
+	CORE_OBJS += wcd9xxx-core-init.o
+	CORE_OBJS += wcd9xxx-core.o
+	CORE_OBJS += wcd9xxx-irq.o
+	CORE_OBJS += wcd9xxx-slimslave.o
+	CORE_OBJS += wcd9xxx-utils.o
+	CORE_OBJS += wcd9335-regmap.o
+	CORE_OBJS += wcd9335-tables.o
+	CORE_OBJS += msm-cdc-pinctrl.o
+	CORE_OBJS += msm-cdc-supply.o
+	CORE_OBJS += wcd934x/wcd934x-regmap.o
+	CORE_OBJS += wcd934x/wcd934x-tables.o
+endif
+
+ifeq ($(CONFIG_SND_SOC_WCD9XXX_V2), m)
+	WCD9XXX_OBJS += wcd9xxx-common-v2.o
+	WCD9XXX_OBJS += wcd9xxx-resmgr-v2.o
+	WCD9XXX_OBJS += wcdcal-hwdep.o
+	WCD9XXX_OBJS += wcd9xxx-soc-init.o
+	WCD9XXX_OBJS += wcd-dsp-utils.o
+	WCD9XXX_OBJS += wcd-dsp-mgr.o
+	WCD9XXX_OBJS += audio-ext-clk-up.o
+endif
+
+ifeq ($(CONFIG_SND_SOC_WCD9335), m)
+	WCD9335_OBJS += wcd9335.o
+endif
+
+ifeq ($(CONFIG_SND_SOC_WSA881X), m)
+	WSA881X_OBJS += wsa881x.o
+	WSA881X_OBJS += wsa881x-tables.o
+	WSA881X_OBJS += wsa881x-regmap.o
+	WSA881X_OBJS += wsa881x-temp-sensor.o
+endif
+
+ifeq ($(CONFIG_SND_SOC_MSM_STUB), m)
+	STUB_OBJS += msm_stub.o
+endif
+ifeq ($(CONFIG_SND_SOC_WCD_SPI), m)
+	SPI_OBJS += wcd-spi.o
+endif
+
+ifeq ($(CONFIG_SND_SOC_WCD_CPE), m)
+	WCD_CPE_OBJS += wcd_cpe_core.o
+	WCD_CPE_OBJS += wcd_cpe_services.o
+endif
+
+ifeq ($(CONFIG_SND_SOC_WCD_MBHC), m)
+	MBHC_OBJS += wcd-mbhc-v2.o
+endif
+
+ifeq ($(CONFIG_SND_SOC_WCD_MBHC_ADC), m)
+	MBHC_OBJS += wcd-mbhc-adc.o
+endif
+
+ifeq ($(CONFIG_SND_SOC_WCD_MBHC_LEGACY), m)
+	MBHC_OBJS += wcd-mbhc-legacy.o
+endif
+
+ifeq ($(CONFIG_SND_SOC_MSM_HDMI_CODEC_RX), m)
+	HDMICODEC_OBJS += msm_hdmi_codec_rx.o
+endif
+
+LINUX_INC +=	-Iinclude/linux
+
+INCS :=		$(COMMON_INC) \
+		$(UAPI_INC)
+
+ifeq ($(CONFIG_ARCH_SDM845), y)
+INCS    +=  -include $(AUDIO_ROOT)/config/sdm845autoconf.h
+endif
+ifeq ($(CONFIG_ARCH_SDM670), y)
+INCS    +=  -include $(AUDIO_ROOT)/config/sdm670autoconf.h
+endif
+
+EXTRA_CFLAGS += $(INCS)
+
+
+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)
+
+# Currently, for versions of gcc which support it, the kernel Makefile
+# is disabling the maybe-uninitialized warning.  Re-enable it for the
+# AUDIO driver.  Note that we must use EXTRA_CFLAGS here so that it
+# will override the kernel settings.
+ifeq ($(call cc-option-yn, -Wmaybe-uninitialized),y)
+EXTRA_CFLAGS += -Wmaybe-uninitialized
+endif
+#EXTRA_CFLAGS += -Wmissing-prototypes
+
+ifeq ($(call cc-option-yn, -Wheader-guard),y)
+EXTRA_CFLAGS += -Wheader-guard
+endif
+
+
+KBUILD_EXTRA_SYMBOLS +=$(OUT)/obj/vendor/qcom/opensource/audio-kernel/dsp/Module.symvers
+KBUILD_EXTRA_SYMBOLS +=$(OUT)/obj/vendor/qcom/opensource/audio-kernel/soc/Module.symvers
+# Module information used by KBuild framework
+obj-$(CONFIG_WCD9XXX_CODEC_CORE) += wcd_core_dlkm.o
+wcd_core_dlkm-y := $(CORE_OBJS)
+
+obj-$(CONFIG_SND_SOC_WCD9XXX_V2) += wcd9xxx_dlkm.o
+wcd9xxx_dlkm-y := $(WCD9XXX_OBJS)
+
+obj-$(CONFIG_SND_SOC_WCD9335) += wcd9335_dlkm.o
+wcd9335_dlkm-y := $(WCD9335_OBJS)
+
+obj-$(CONFIG_SND_SOC_WSA881X) += wsa881x_dlkm.o
+wsa881x_dlkm-y := $(WSA881X_OBJS)
+
+obj-$(CONFIG_SND_SOC_MSM_STUB) += stub_dlkm.o
+stub_dlkm-y := $(STUB_OBJS)
+
+obj-$(CONFIG_SND_SOC_WCD_CPE) += wcd_cpe_dlkm.o
+wcd_cpe_dlkm-y := $(WCD_CPE_OBJS)
+
+obj-$(CONFIG_SND_SOC_WCD_SPI) += wcd_spi_dlkm.o
+wcd_spi_dlkm-y := $(SPI_OBJS)
+
+obj-$(CONFIG_SND_SOC_WCD_MBHC) += mbhc_dlkm.o
+mbhc_dlkm-y := $(MBHC_OBJS)
+
+obj-$(CONFIG_SND_SOC_MSM_HDMI_CODEC_RX) += hdmi_dlkm.o
+hdmi_dlkm-y := $(HDMICODEC_OBJS)
+
+# inject some build related information
+DEFINES += -DBUILD_TIMESTAMP=\"$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')\"
diff --git a/asoc/codecs/cpe_core.h b/asoc/codecs/cpe_core.h
index 9f7c2f3..99504c5 100644
--- a/asoc/codecs/cpe_core.h
+++ b/asoc/codecs/cpe_core.h
@@ -173,7 +173,22 @@
 			    struct cpe_lsm_session *session, void *data);
 };
 
+#if IS_ENABLED(CONFIG_SND_SOC_WCD_CPE)
 int wcd_cpe_get_lsm_ops(struct wcd_cpe_lsm_ops *lsm_ops);
 int wcd_cpe_get_afe_ops(struct wcd_cpe_afe_ops *afe_ops);
 void *wcd_cpe_get_core_handle(struct snd_soc_codec *codec);
+#else /* CONFIG_SND_SOC_WCD_CPE */
+static inline int wcd_cpe_get_lsm_ops(struct wcd_cpe_lsm_ops *lsm_ops)
+{
+	return 0;
+}
+static inline int wcd_cpe_get_afe_ops(struct wcd_cpe_afe_ops *afe_ops)
+{
+	return 0;
+}
+static inline void *wcd_cpe_get_core_handle(struct snd_soc_codec *codec)
+{
+	return NULL;
+}
+#endif /* CONFIG_SND_SOC_WCD_CPE */
 #endif
diff --git a/asoc/codecs/msm_sdw/Android.mk b/asoc/codecs/msm_sdw/Android.mk
new file mode 100644
index 0000000..421420b
--- /dev/null
+++ b/asoc/codecs/msm_sdw/Android.mk
@@ -0,0 +1,46 @@
+# Android makefile for audio kernel modules
+
+# Assume no targets will be supported
+
+AUDIO_CHIPSET := audio
+# Build/Package only in case of supported target
+ifeq ($(call is-board-platform,sdm670),true)
+AUDIO_SELECT  := CONFIG_SND_SOC_SDM670=m
+
+LOCAL_PATH := $(call my-dir)
+
+# This makefile is only for DLKM
+ifneq ($(findstring vendor,$(LOCAL_PATH)),)
+
+ifneq ($(findstring opensource,$(LOCAL_PATH)),)
+	AUDIO_BLD_DIR := $(ANDROID_BUILD_TOP)/vendor/qcom/opensource/audio-kernel
+endif # opensource
+
+DLKM_DIR := $(TOP)/device/qcom/common/dlkm
+
+# Build audio.ko as $(AUDIO_CHIPSET)_audio.ko
+###########################################################
+# This is set once per LOCAL_PATH, not per (kernel) module
+KBUILD_OPTIONS := AUDIO_ROOT=$(AUDIO_BLD_DIR)
+
+# We are actually building audio.ko here, as per the
+# requirement we are specifying <chipset>_audio.ko as LOCAL_MODULE.
+# This means we need to rename the module to <chipset>_audio.ko
+# after audio.ko is built.
+KBUILD_OPTIONS += MODNAME=msm_sdw_dlkm
+KBUILD_OPTIONS += BOARD_PLATFORM=$(TARGET_BOARD_PLATFORM)
+KBUILD_OPTIONS += $(AUDIO_SELECT)
+
+###########################################################
+include $(CLEAR_VARS)
+LOCAL_MODULE              := $(AUDIO_CHIPSET)_msm_sdw.ko
+LOCAL_MODULE_KBUILD_NAME  := msm_sdw_dlkm.ko
+LOCAL_MODULE_TAGS         := optional
+LOCAL_MODULE_DEBUG_ENABLE := true
+LOCAL_MODULE_PATH         := $(KERNEL_MODULES_OUT)
+include $(DLKM_DIR)/AndroidKernelModule.mk
+###########################################################
+###########################################################
+
+endif # DLKM check
+endif # supported target check
diff --git a/asoc/codecs/msm_sdw/Kbuild b/asoc/codecs/msm_sdw/Kbuild
new file mode 100644
index 0000000..a55948e
--- /dev/null
+++ b/asoc/codecs/msm_sdw/Kbuild
@@ -0,0 +1,104 @@
+# We can build either as part of a standalone Kernel build or as
+# an external module.  Determine which mechanism is being used
+KERNEL_BUILD := 0
+
+
+ifeq ($(KERNEL_BUILD), 0)
+	# These are configurable via Kconfig for kernel-based builds
+	# Need to explicitly configure for Android-based builds
+	ifeq ($(CONFIG_ARCH_SDM845), y)
+		include $(AUDIO_ROOT)/config/sdm845auto.conf
+		export
+	endif
+	ifeq ($(CONFIG_ARCH_SDM670), y)
+		include $(AUDIO_ROOT)/config/sdm670auto.conf
+		export
+	endif
+endif
+
+
+# As per target team, build is done as follows:
+# Defconfig : build with default flags
+# Slub      : defconfig  + CONFIG_SLUB_DEBUG := y +
+#	      CONFIG_SLUB_DEBUG_ON := y + CONFIG_PAGE_POISONING := y
+# Perf      : Using appropriate msmXXXX-perf_defconfig
+#
+# Shipment builds (user variants) should not have any debug feature
+# enabled. This is identified using 'TARGET_BUILD_VARIANT'. Slub builds
+# are identified using the CONFIG_SLUB_DEBUG_ON configuration. Since
+# there is no other way to identify defconfig builds, QTI internal
+# representation of perf builds (identified using the string 'perf'),
+# is used to identify if the build is a slub or defconfig one. This
+# way no critical debug feature will be enabled for perf and shipment
+# builds. Other OEMs are also protected using the TARGET_BUILD_VARIANT
+# config.
+
+############ UAPI ############
+UAPI_DIR :=	uapi
+UAPI_INC :=	-I$(AUDIO_ROOT)/include/$(UAPI_DIR)
+
+############ COMMON ############
+COMMON_DIR :=	include
+COMMON_INC :=	-I$(AUDIO_ROOT)/$(COMMON_DIR)
+
+############ MSM Soundwire ############
+
+# for MSM Soundwire Codec
+ifeq ($(CONFIG_SND_SOC_MSM_SDW), m)
+	MSM_SDW_OBJS += msm_sdw_cdc.o
+	MSM_SDW_OBJS += msm_sdw_regmap.o
+	MSM_SDW_OBJS += msm-sdw-tables.o
+	MSM_SDW_OBJS += msm_sdw_cdc_utils.o
+endif
+
+LINUX_INC +=	-Iinclude/linux
+
+INCS :=		$(COMMON_INC) \
+		$(UAPI_INC)
+
+ifeq ($(CONFIG_ARCH_SDM845), y)
+INCS    +=  -include $(AUDIO_ROOT)/config/sdm845autoconf.h
+endif
+ifeq ($(CONFIG_ARCH_SDM670), y)
+INCS    +=  -include $(AUDIO_ROOT)/config/sdm670autoconf.h
+endif
+
+EXTRA_CFLAGS += $(INCS)
+
+
+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)
+
+# Currently, for versions of gcc which support it, the kernel Makefile
+# is disabling the maybe-uninitialized warning.  Re-enable it for the
+# AUDIO driver.  Note that we must use EXTRA_CFLAGS here so that it
+# will override the kernel settings.
+ifeq ($(call cc-option-yn, -Wmaybe-uninitialized),y)
+EXTRA_CFLAGS += -Wmaybe-uninitialized
+endif
+#EXTRA_CFLAGS += -Wmissing-prototypes
+
+ifeq ($(call cc-option-yn, -Wheader-guard),y)
+EXTRA_CFLAGS += -Wheader-guard
+endif
+
+KBUILD_EXTRA_SYMBOLS +=$(OUT)/obj/vendor/qcom/opensource/audio-kernel/ipc/Module.symvers
+KBUILD_EXTRA_SYMBOLS +=$(OUT)/obj/vendor/qcom/opensource/audio-kernel/dsp/Module.symvers
+KBUILD_EXTRA_SYMBOLS +=$(OUT)/obj/vendor/qcom/opensource/audio-kernel/asoc/Module.symvers
+KBUILD_EXTRA_SYMBOLS +=$(OUT)/obj/vendor/qcom/opensource/audio-kernel/asoc/codecs/Module.symvers
+KBUILD_EXTRA_SYMBOLS +=$(OUT)/obj/vendor/qcom/opensource/audio-kernel/soc/Module.symvers
+# Module information used by KBuild framework
+obj-$(CONFIG_SND_SOC_MSM_SDW) += msm_sdw_dlkm.o
+msm_sdw_dlkm-y := $(MSM_SDW_OBJS)
+
+# inject some build related information
+DEFINES += -DBUILD_TIMESTAMP=\"$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')\"
diff --git a/asoc/codecs/msm_sdw/msm_sdw.h b/asoc/codecs/msm_sdw/msm_sdw.h
index 3285f5f..d4ac433 100644
--- a/asoc/codecs/msm_sdw/msm_sdw.h
+++ b/asoc/codecs/msm_sdw/msm_sdw.h
@@ -156,6 +156,7 @@
 	struct snd_info_entry *version_entry;
 };
 
+#if IS_ENABLED(CONFIG_SND_SOC_MSM_SDW)
 extern int msm_sdw_set_spkr_mode(struct snd_soc_codec *codec, int mode);
 extern int msm_sdw_set_spkr_gain_offset(struct snd_soc_codec *codec,
 					int offset);
@@ -167,4 +168,32 @@
 extern int msm_sdw_codec_info_create_codec_entry(
 	struct snd_info_entry *codec_root,
 	struct snd_soc_codec *codec);
+#else /* CONFIG_SND_SOC_MSM_SDW */
+static inline int msm_sdw_set_spkr_mode(struct snd_soc_codec *codec, int mode)
+{
+	return 0;
+}
+static inline int msm_sdw_set_spkr_gain_offset(struct snd_soc_codec *codec,
+					int offset);
+{
+	return 0;
+}
+static inline void msm_sdw_gpio_cb(
+	int (*sdw_cdc_gpio_fn)(bool enable, struct snd_soc_codec *codec),
+	struct snd_soc_codec *codec);
+{
+
+}
+static inline struct regmap *msm_sdw_regmap_init(struct device *dev,
+					  const struct regmap_config *config);
+{
+	return NULL;
+}
+static inline int msm_sdw_codec_info_create_codec_entry(
+	struct snd_info_entry *codec_root,
+	struct snd_soc_codec *codec)
+{
+	return 0;
+}
+#endif /* CONFIG_SND_SOC_MSM_SDW */
 #endif
diff --git a/asoc/codecs/sdm660_cdc/Android.mk b/asoc/codecs/sdm660_cdc/Android.mk
new file mode 100644
index 0000000..f322a65
--- /dev/null
+++ b/asoc/codecs/sdm660_cdc/Android.mk
@@ -0,0 +1,53 @@
+# Android makefile for audio kernel modules
+
+# Assume no targets will be supported
+
+AUDIO_CHIPSET := audio
+# Build/Package only in case of supported target
+ifeq ($(call is-board-platform,sdm670),true)
+
+LOCAL_PATH := $(call my-dir)
+
+# This makefile is only for DLKM
+ifneq ($(findstring vendor,$(LOCAL_PATH)),)
+
+ifneq ($(findstring opensource,$(LOCAL_PATH)),)
+	AUDIO_BLD_DIR := $(ANDROID_BUILD_TOP)/vendor/qcom/opensource/audio-kernel
+endif # opensource
+
+DLKM_DIR := $(TOP)/device/qcom/common/dlkm
+
+# Build audio.ko as $(AUDIO_CHIPSET)_audio.ko
+###########################################################
+# This is set once per LOCAL_PATH, not per (kernel) module
+KBUILD_OPTIONS := AUDIO_ROOT=$(AUDIO_BLD_DIR)
+
+# We are actually building audio.ko here, as per the
+# requirement we are specifying <chipset>_audio.ko as LOCAL_MODULE.
+# This means we need to rename the module to <chipset>_audio.ko
+# after audio.ko is built.
+KBUILD_OPTIONS += MODNAME=analog_cdc_dlkm
+KBUILD_OPTIONS += BOARD_PLATFORM=$(TARGET_BOARD_PLATFORM)
+KBUILD_OPTIONS += $(AUDIO_SELECT)
+
+###########################################################
+include $(CLEAR_VARS)
+LOCAL_MODULE              := $(AUDIO_CHIPSET)_analog_cdc.ko
+LOCAL_MODULE_KBUILD_NAME  := analog_cdc_dlkm.ko
+LOCAL_MODULE_TAGS         := optional
+LOCAL_MODULE_DEBUG_ENABLE := true
+LOCAL_MODULE_PATH         := $(KERNEL_MODULES_OUT)
+include $(DLKM_DIR)/AndroidKernelModule.mk
+###########################################################
+include $(CLEAR_VARS)
+LOCAL_MODULE              := $(AUDIO_CHIPSET)_digital_cdc.ko
+LOCAL_MODULE_KBUILD_NAME  := digital_cdc_dlkm.ko
+LOCAL_MODULE_TAGS         := optional
+LOCAL_MODULE_DEBUG_ENABLE := true
+LOCAL_MODULE_PATH         := $(KERNEL_MODULES_OUT)
+include $(DLKM_DIR)/AndroidKernelModule.mk
+###########################################################
+###########################################################
+
+endif # DLKM check
+endif # supported target check
diff --git a/asoc/codecs/sdm660_cdc/Kbuild b/asoc/codecs/sdm660_cdc/Kbuild
new file mode 100644
index 0000000..c1777ee
--- /dev/null
+++ b/asoc/codecs/sdm660_cdc/Kbuild
@@ -0,0 +1,110 @@
+# We can build either as part of a standalone Kernel build or as
+# an external module.  Determine which mechanism is being used
+KERNEL_BUILD := 0
+
+
+ifeq ($(KERNEL_BUILD), 0)
+	# These are configurable via Kconfig for kernel-based builds
+	# Need to explicitly configure for Android-based builds
+	ifeq ($(CONFIG_ARCH_SDM845), y)
+		include $(AUDIO_ROOT)/config/sdm845auto.conf
+		export
+	endif
+	ifeq ($(CONFIG_ARCH_SDM670), y)
+		include $(AUDIO_ROOT)/config/sdm670auto.conf
+		export
+	endif
+endif
+
+
+# As per target team, build is done as follows:
+# Defconfig : build with default flags
+# Slub      : defconfig  + CONFIG_SLUB_DEBUG := y +
+#	      CONFIG_SLUB_DEBUG_ON := y + CONFIG_PAGE_POISONING := y
+# Perf      : Using appropriate msmXXXX-perf_defconfig
+#
+# Shipment builds (user variants) should not have any debug feature
+# enabled. This is identified using 'TARGET_BUILD_VARIANT'. Slub builds
+# are identified using the CONFIG_SLUB_DEBUG_ON configuration. Since
+# there is no other way to identify defconfig builds, QTI internal
+# representation of perf builds (identified using the string 'perf'),
+# is used to identify if the build is a slub or defconfig one. This
+# way no critical debug feature will be enabled for perf and shipment
+# builds. Other OEMs are also protected using the TARGET_BUILD_VARIANT
+# config.
+
+############ UAPI ############
+UAPI_DIR :=	uapi
+UAPI_INC :=	-I$(AUDIO_ROOT)/include/$(UAPI_DIR)
+
+############ COMMON ############
+COMMON_DIR :=	include
+COMMON_INC :=	-I$(AUDIO_ROOT)/$(COMMON_DIR)
+
+############ SDM660_CDC ############
+
+# for SDM660_CDC Codec
+ifeq ($(CONFIG_SND_SOC_ANALOG_CDC), m)
+	ANALOG_CDC_OBJS += msm-analog-cdc.o
+	ANALOG_CDC_OBJS += sdm660-cdc-irq.o
+endif
+
+ifeq ($(CONFIG_SND_SOC_DIGITAL_CDC), m)
+	DIGITAL_CDC_OBJS += msm-digital-cdc.o
+	DIGITAL_CDC_OBJS += msm-digital-cdc-regmap.o
+endif
+LINUX_INC +=	-Iinclude/linux
+
+INCS :=		$(COMMON_INC) \
+		$(UAPI_INC)
+
+ifeq ($(CONFIG_ARCH_SDM845), y)
+INCS    +=  -include $(AUDIO_ROOT)/config/sdm845autoconf.h
+endif
+ifeq ($(CONFIG_ARCH_SDM670), y)
+INCS    +=  -include $(AUDIO_ROOT)/config/sdm670autoconf.h
+endif
+
+EXTRA_CFLAGS += $(INCS)
+
+
+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)
+
+# Currently, for versions of gcc which support it, the kernel Makefile
+# is disabling the maybe-uninitialized warning.  Re-enable it for the
+# AUDIO driver.  Note that we must use EXTRA_CFLAGS here so that it
+# will override the kernel settings.
+ifeq ($(call cc-option-yn, -Wmaybe-uninitialized),y)
+EXTRA_CFLAGS += -Wmaybe-uninitialized
+endif
+#EXTRA_CFLAGS += -Wmissing-prototypes
+
+ifeq ($(call cc-option-yn, -Wheader-guard),y)
+EXTRA_CFLAGS += -Wheader-guard
+endif
+
+
+KBUILD_EXTRA_SYMBOLS +=$(OUT)/obj/vendor/qcom/opensource/audio-kernel/ipc/Module.symvers
+KBUILD_EXTRA_SYMBOLS +=$(OUT)/obj/vendor/qcom/opensource/audio-kernel/dsp/Module.symvers
+KBUILD_EXTRA_SYMBOLS +=$(OUT)/obj/vendor/qcom/opensource/audio-kernel/asoc/Module.symvers
+KBUILD_EXTRA_SYMBOLS +=$(OUT)/obj/vendor/qcom/opensource/audio-kernel/asoc/codecs/Module.symvers
+KBUILD_EXTRA_SYMBOLS +=$(OUT)/obj/vendor/qcom/opensource/audio-kernel/soc/Module.symvers
+# Module information used by KBuild framework
+obj-$(CONFIG_SND_SOC_ANALOG_CDC) += analog_cdc_dlkm.o
+analog_cdc_dlkm-y := $(ANALOG_CDC_OBJS)
+
+obj-$(CONFIG_SND_SOC_DIGITAL_CDC) += digital_cdc_dlkm.o
+digital_cdc_dlkm-y := $(DIGITAL_CDC_OBJS)
+
+# inject some build related information
+DEFINES += -DBUILD_TIMESTAMP=\"$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')\"
diff --git a/asoc/codecs/sdm660_cdc/msm-analog-cdc.h b/asoc/codecs/sdm660_cdc/msm-analog-cdc.h
index fffdf31..9591487 100644
--- a/asoc/codecs/sdm660_cdc/msm-analog-cdc.h
+++ b/asoc/codecs/sdm660_cdc/msm-analog-cdc.h
@@ -221,20 +221,48 @@
 	struct sdm660_cdc_regulator regulator[MAX_REGULATOR];
 };
 
-
+#if IS_ENABLED(CONFIG_SND_SOC_ANALOG_CDC)
 extern int msm_anlg_cdc_mclk_enable(struct snd_soc_codec *codec,
 				    int mclk_enable, bool dapm);
-
 extern int msm_anlg_cdc_hs_detect(struct snd_soc_codec *codec,
 		    struct wcd_mbhc_config *mbhc_cfg);
-
 extern void msm_anlg_cdc_hs_detect_exit(struct snd_soc_codec *codec);
-
 extern void sdm660_cdc_update_int_spk_boost(bool enable);
-
 extern void msm_anlg_cdc_spk_ext_pa_cb(
 		int (*codec_spk_ext_pa)(struct snd_soc_codec *codec,
 		int enable), struct snd_soc_codec *codec);
 int msm_anlg_codec_info_create_codec_entry(struct snd_info_entry *codec_root,
 					   struct snd_soc_codec *codec);
+#else /* CONFIG_SND_SOC_ANALOG_CDC */
+static inline int msm_anlg_cdc_mclk_enable(struct snd_soc_codec *codec,
+					   int mclk_enable, bool dapm)
+{
+	return 0;
+}
+static inline int msm_anlg_cdc_hs_detect(struct snd_soc_codec *codec,
+				struct wcd_mbhc_config *mbhc_cfg)
+{
+	return 0;
+}
+static inline void msm_anlg_cdc_hs_detect_exit(struct snd_soc_codec *codec)
+{
+
+}
+static inline void sdm660_cdc_update_int_spk_boost(bool enable)
+{
+
+}
+static inline void msm_anlg_cdc_spk_ext_pa_cb(
+		int (*codec_spk_ext_pa)(struct snd_soc_codec *codec,
+		int enable), struct snd_soc_codec *codec)
+{
+
+}
+static inline int msm_anlg_codec_info_create_codec_entry(
+					struct snd_info_entry *codec_root,
+					struct snd_soc_codec *codec)
+{
+	return 0;
+}
+#endif /* CONFIG_SND_SOC_ANALOG_CDC */
 #endif
diff --git a/asoc/codecs/sdm660_cdc/msm-digital-cdc.h b/asoc/codecs/sdm660_cdc/msm-digital-cdc.h
index 42c31d5..cb6cfe2 100644
--- a/asoc/codecs/sdm660_cdc/msm-digital-cdc.h
+++ b/asoc/codecs/sdm660_cdc/msm-digital-cdc.h
@@ -89,10 +89,26 @@
 	BAND_MAX,
 };
 
+#if IS_ENABLED(CONFIG_SND_SOC_DIGITAL_CDC)
 extern void msm_dig_cdc_hph_comp_cb(
 		int (*codec_hph_comp_gpio)(
 			bool enable, struct snd_soc_codec *codec),
 		struct snd_soc_codec *codec);
 int msm_dig_codec_info_create_codec_entry(struct snd_info_entry *codec_root,
 					  struct snd_soc_codec *codec);
+#else /* CONFIG_SND_SOC_DIGITAL_CDC */
+static inline void msm_dig_cdc_hph_comp_cb(
+		int (*codec_hph_comp_gpio)(
+			bool enable, struct snd_soc_codec *codec),
+		struct snd_soc_codec *codec)
+{
+
+}
+static inline int msm_dig_codec_info_create_codec_entry(
+				struct snd_info_entry *codec_root,
+				struct snd_soc_codec *codec)
+{
+	return 0;
+}
+#endif /* CONFIG_SND_SOC_DIGITAL_CDC */
 #endif
diff --git a/asoc/codecs/wcd-mbhc-legacy.h b/asoc/codecs/wcd-mbhc-legacy.h
index 594393d..af3a7dc 100644
--- a/asoc/codecs/wcd-mbhc-legacy.h
+++ b/asoc/codecs/wcd-mbhc-legacy.h
@@ -15,7 +15,7 @@
 #include "wcdcal-hwdep.h"
 #include "wcd-mbhc-v2.h"
 
-#ifdef CONFIG_SND_SOC_WCD_MBHC_LEGACY
+#if IS_ENABLED(CONFIG_SND_SOC_WCD_MBHC_LEGACY)
 void wcd_mbhc_legacy_init(struct wcd_mbhc *mbhc);
 #else
 static inline void wcd_mbhc_legacy_init(struct wcd_mbhc *mbhc)
diff --git a/asoc/codecs/wcd-mbhc-v2.c b/asoc/codecs/wcd-mbhc-v2.c
index d7c5921..3c501b4 100644
--- a/asoc/codecs/wcd-mbhc-v2.c
+++ b/asoc/codecs/wcd-mbhc-v2.c
@@ -2121,5 +2121,17 @@
 }
 EXPORT_SYMBOL(wcd_mbhc_deinit);
 
+static int __init mbhc_init(void)
+{
+	return 0;
+}
+
+static void __exit mbhc_exit(void)
+{
+}
+
+module_init(mbhc_init);
+module_exit(mbhc_exit);
+
 MODULE_DESCRIPTION("wcd MBHC v2 module");
 MODULE_LICENSE("GPL v2");
diff --git a/asoc/codecs/wcd9335.h b/asoc/codecs/wcd9335.h
index 48826e6..f5f1038 100644
--- a/asoc/codecs/wcd9335.h
+++ b/asoc/codecs/wcd9335.h
@@ -137,6 +137,7 @@
 	RX_GAIN_OFFSET_0_DB,
 };
 
+#if IS_ENABLED(CONFIG_SND_SOC_WCD9335)
 extern void *tasha_get_afe_config(struct snd_soc_codec *codec,
 				  enum afe_config_type config_type);
 extern int tasha_cdc_mclk_enable(struct snd_soc_codec *codec, int enable,
@@ -163,4 +164,75 @@
 extern int tasha_set_spkr_mode(struct snd_soc_codec *codec, int mode);
 extern int tasha_set_spkr_gain_offset(struct snd_soc_codec *codec, int offset);
 extern enum codec_variant tasha_codec_ver(void);
+#else /* CONFIG_SND_SOC_WCD9335 */
+static inline void *tasha_get_afe_config(struct snd_soc_codec *codec,
+				  enum afe_config_type config_type)
+{
+	return NULL;
+}
+static inline int tasha_cdc_mclk_enable(struct snd_soc_codec *codec,
+					int enable,
+					bool dapm)
+{
+	return 0;
+}
+static inline int tasha_cdc_mclk_tx_enable(struct snd_soc_codec *codec,
+					   int enable,
+					   bool dapm)
+{
+	return 0;
+}
+static inline int tasha_enable_efuse_sensing(struct snd_soc_codec *codec)
+{
+	return 0;
+}
+static inline int tasha_mbhc_hs_detect(struct snd_soc_codec *codec,
+				struct wcd_mbhc_config *mbhc_cfg)
+{
+	return 0;
+}
+static inline void tasha_mbhc_hs_detect_exit(struct snd_soc_codec *codec)
+{
+
+}
+static inline void tasha_mbhc_zdet_gpio_ctrl(
+		int (*zdet_gpio_cb)(struct snd_soc_codec *codec, bool high),
+		struct snd_soc_codec *codec)
+{
+
+}
+static inline int tasha_codec_info_create_codec_entry(
+		struct snd_info_entry *codec_root,
+		struct snd_soc_codec *codec)
+{
+	return 0;
+}
+static inline void tasha_event_register(
+	int (*machine_event_cb)(struct snd_soc_codec *codec,
+				enum wcd9335_codec_event),
+	struct snd_soc_codec *codec)
+{
+
+}
+static inline int tasha_codec_enable_standalone_micbias(
+				struct snd_soc_codec *codec,
+				int micb_num,
+				bool enable)
+{
+	return 0;
+}
+static inline int tasha_set_spkr_mode(struct snd_soc_codec *codec, int mode)
+{
+	return 0;
+}
+static inline int tasha_set_spkr_gain_offset(struct snd_soc_codec *codec,
+					     int offset)
+{
+	return 0;
+}
+static inline enum codec_variant tasha_codec_ver(void)
+{
+	return 0;
+}
+#endif /* CONFIG_SND_SOC_WCD9335 */
 #endif
diff --git a/asoc/codecs/wcd934x/Android.mk b/asoc/codecs/wcd934x/Android.mk
new file mode 100644
index 0000000..627d04f
--- /dev/null
+++ b/asoc/codecs/wcd934x/Android.mk
@@ -0,0 +1,54 @@
+# Android makefile for audio kernel modules
+
+# Assume no targets will be supported
+
+# Check if this driver needs be built for current target
+ifeq ($(call is-board-platform,sdm845),true)
+AUDIO_SELECT  := CONFIG_SND_SOC_SDM845=m
+endif
+
+ifeq ($(call is-board-platform,sdm670),true)
+AUDIO_SELECT  := CONFIG_SND_SOC_SDM670=m
+endif
+
+AUDIO_CHIPSET := audio
+# Build/Package only in case of supported target
+ifeq ($(call is-board-platform-in-list,sdm845 sdm670),true)
+
+LOCAL_PATH := $(call my-dir)
+
+# This makefile is only for DLKM
+ifneq ($(findstring vendor,$(LOCAL_PATH)),)
+
+ifneq ($(findstring opensource,$(LOCAL_PATH)),)
+	AUDIO_BLD_DIR := $(ANDROID_BUILD_TOP)/vendor/qcom/opensource/audio-kernel
+endif # opensource
+
+DLKM_DIR := $(TOP)/device/qcom/common/dlkm
+
+# Build audio.ko as $(AUDIO_CHIPSET)_audio.ko
+###########################################################
+# This is set once per LOCAL_PATH, not per (kernel) module
+KBUILD_OPTIONS := AUDIO_ROOT=$(AUDIO_BLD_DIR)
+
+# We are actually building audio.ko here, as per the
+# requirement we are specifying <chipset>_audio.ko as LOCAL_MODULE.
+# This means we need to rename the module to <chipset>_audio.ko
+# after audio.ko is built.
+KBUILD_OPTIONS += MODNAME=wcd934x_dlkm
+KBUILD_OPTIONS += BOARD_PLATFORM=$(TARGET_BOARD_PLATFORM)
+KBUILD_OPTIONS += $(AUDIO_SELECT)
+
+###########################################################
+include $(CLEAR_VARS)
+LOCAL_MODULE              := $(AUDIO_CHIPSET)_wcd934x.ko
+LOCAL_MODULE_KBUILD_NAME  := wcd934x_dlkm.ko
+LOCAL_MODULE_TAGS         := optional
+LOCAL_MODULE_DEBUG_ENABLE := true
+LOCAL_MODULE_PATH         := $(KERNEL_MODULES_OUT)
+include $(DLKM_DIR)/AndroidKernelModule.mk
+###########################################################
+###########################################################
+
+endif # DLKM check
+endif # supported target check
diff --git a/asoc/codecs/wcd934x/Kbuild b/asoc/codecs/wcd934x/Kbuild
new file mode 100644
index 0000000..6bc854c
--- /dev/null
+++ b/asoc/codecs/wcd934x/Kbuild
@@ -0,0 +1,105 @@
+# We can build either as part of a standalone Kernel build or as
+# an external module.  Determine which mechanism is being used
+KERNEL_BUILD := 0
+
+
+ifeq ($(KERNEL_BUILD), 0)
+	# These are configurable via Kconfig for kernel-based builds
+	# Need to explicitly configure for Android-based builds
+	ifeq ($(CONFIG_ARCH_SDM845), y)
+		include $(AUDIO_ROOT)/config/sdm845auto.conf
+		export
+	endif
+	ifeq ($(CONFIG_ARCH_SDM670), y)
+		include $(AUDIO_ROOT)/config/sdm670auto.conf
+		export
+	endif
+endif
+
+
+# As per target team, build is done as follows:
+# Defconfig : build with default flags
+# Slub      : defconfig  + CONFIG_SLUB_DEBUG := y +
+#	      CONFIG_SLUB_DEBUG_ON := y + CONFIG_PAGE_POISONING := y
+# Perf      : Using appropriate msmXXXX-perf_defconfig
+#
+# Shipment builds (user variants) should not have any debug feature
+# enabled. This is identified using 'TARGET_BUILD_VARIANT'. Slub builds
+# are identified using the CONFIG_SLUB_DEBUG_ON configuration. Since
+# there is no other way to identify defconfig builds, QTI internal
+# representation of perf builds (identified using the string 'perf'),
+# is used to identify if the build is a slub or defconfig one. This
+# way no critical debug feature will be enabled for perf and shipment
+# builds. Other OEMs are also protected using the TARGET_BUILD_VARIANT
+# config.
+
+############ UAPI ############
+UAPI_DIR :=	uapi
+UAPI_INC :=	-I$(AUDIO_ROOT)/include/$(UAPI_DIR)
+
+############ COMMON ############
+COMMON_DIR :=	include
+COMMON_INC :=	-I$(AUDIO_ROOT)/$(COMMON_DIR)
+
+############ WCD934X ############
+
+# for WCD934X Codec
+ifeq ($(CONFIG_SND_SOC_WCD934X), m)
+	WCD934X_OBJS += wcd934x.o
+	WCD934X_OBJS += wcd934x-dsp-cntl.o
+	WCD934X_OBJS += wcd934x-mbhc.o
+	WCD934X_OBJS += wcd934x-dsd.o
+endif
+
+LINUX_INC +=	-Iinclude/linux
+
+INCS :=		$(COMMON_INC) \
+		$(UAPI_INC)
+
+ifeq ($(CONFIG_ARCH_SDM845), y)
+INCS    +=  -include $(AUDIO_ROOT)/config/sdm845autoconf.h
+endif
+ifeq ($(CONFIG_ARCH_SDM670), y)
+INCS    +=  -include $(AUDIO_ROOT)/config/sdm670autoconf.h
+endif
+
+EXTRA_CFLAGS += $(INCS)
+
+
+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)
+
+# Currently, for versions of gcc which support it, the kernel Makefile
+# is disabling the maybe-uninitialized warning.  Re-enable it for the
+# AUDIO driver.  Note that we must use EXTRA_CFLAGS here so that it
+# will override the kernel settings.
+ifeq ($(call cc-option-yn, -Wmaybe-uninitialized),y)
+EXTRA_CFLAGS += -Wmaybe-uninitialized
+endif
+#EXTRA_CFLAGS += -Wmissing-prototypes
+
+ifeq ($(call cc-option-yn, -Wheader-guard),y)
+EXTRA_CFLAGS += -Wheader-guard
+endif
+
+
+KBUILD_EXTRA_SYMBOLS +=$(OUT)/obj/vendor/qcom/opensource/audio-kernel/ipc/Module.symvers
+KBUILD_EXTRA_SYMBOLS +=$(OUT)/obj/vendor/qcom/opensource/audio-kernel/dsp/Module.symvers
+KBUILD_EXTRA_SYMBOLS +=$(OUT)/obj/vendor/qcom/opensource/audio-kernel/asoc/Module.symvers
+KBUILD_EXTRA_SYMBOLS +=$(OUT)/obj/vendor/qcom/opensource/audio-kernel/asoc/codecs/Module.symvers
+KBUILD_EXTRA_SYMBOLS +=$(OUT)/obj/vendor/qcom/opensource/audio-kernel/soc/Module.symvers
+# Module information used by KBuild framework
+obj-$(CONFIG_SND_SOC_WCD934X) += wcd934x_dlkm.o
+wcd934x_dlkm-y := $(WCD934X_OBJS)
+
+# inject some build related information
+DEFINES += -DBUILD_TIMESTAMP=\"$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')\"
diff --git a/asoc/msm-audio-effects-q6-v2.c b/asoc/msm-audio-effects-q6-v2.c
index 2385bac..5bab856 100644
--- a/asoc/msm-audio-effects-q6-v2.c
+++ b/asoc/msm-audio-effects-q6-v2.c
@@ -37,6 +37,11 @@
 } while (0)
 
 
+/**
+ * msm_audio_effects_is_effmodule_supp_in_top -
+ *        Checks if given topology and module in effects
+ *
+ */
 bool msm_audio_effects_is_effmodule_supp_in_top(int effect_module,
 						int topology)
 {
@@ -56,6 +61,7 @@
 		return false;
 	}
 }
+EXPORT_SYMBOL(msm_audio_effects_is_effmodule_supp_in_top);
 
 int msm_audio_effects_enable_extn(struct audio_client *ac,
 				struct msm_nt_eff_all_config *effects,
@@ -102,6 +108,16 @@
 	return rc;
 }
 
+/**
+ * msm_audio_effects_virtualizer_handler -
+ *        Audio effects handler for virtualizer
+ *
+ * @ac: audio client handle
+ * @pbe: virtualizer params
+ * @values: values to be updated
+ *
+ * Return 0 on success or error on failure
+ */
 int msm_audio_effects_virtualizer_handler(struct audio_client *ac,
 				struct virtualizer_params *virtualizer,
 				long *values)
@@ -263,7 +279,18 @@
 	kfree(params);
 	return rc;
 }
+EXPORT_SYMBOL(msm_audio_effects_virtualizer_handler);
 
+/**
+ * msm_audio_effects_reverb_handler -
+ *        Audio effects handler for reverb
+ *
+ * @ac: audio client handle
+ * @pbe: reverb params
+ * @values: values to be updated
+ *
+ * Return 0 on success or error on failure
+ */
 int msm_audio_effects_reverb_handler(struct audio_client *ac,
 				     struct reverb_params *reverb,
 				     long *values)
@@ -733,7 +760,18 @@
 	kfree(params);
 	return rc;
 }
+EXPORT_SYMBOL(msm_audio_effects_reverb_handler);
 
+/**
+ * msm_audio_effects_bass_boost_handler -
+ *        Audio effects handler for bass_boost
+ *
+ * @ac: audio client handle
+ * @bass_boost: bass_boost params
+ * @values: values to be updated
+ *
+ * Return 0 on success or error on failure
+ */
 int msm_audio_effects_bass_boost_handler(struct audio_client *ac,
 					struct bass_boost_params *bass_boost,
 					long *values)
@@ -868,7 +906,18 @@
 	kfree(params);
 	return rc;
 }
+EXPORT_SYMBOL(msm_audio_effects_bass_boost_handler);
 
+/**
+ * msm_audio_effects_pbe_handler -
+ *        Audio effects handler for pbe
+ *
+ * @ac: audio client handle
+ * @pbe: pbe params
+ * @values: values to be updated
+ *
+ * Return 0 on success or error on failure
+ */
 int msm_audio_effects_pbe_handler(struct audio_client *ac,
 					struct pbe_params *pbe,
 					long *values)
@@ -975,7 +1024,18 @@
 	kfree(params);
 	return rc;
 }
+EXPORT_SYMBOL(msm_audio_effects_pbe_handler);
 
+/**
+ * msm_audio_effects_popless_eq_handler -
+ *        Audio effects handler for popless equalizer
+ *
+ * @ac: audio client handle
+ * @eq: equalizer params
+ * @values: values to be updated
+ *
+ * Return 0 on success or error on failure
+ */
 int msm_audio_effects_popless_eq_handler(struct audio_client *ac,
 					 struct eq_params *eq,
 					 long *values)
@@ -1207,6 +1267,7 @@
 	kfree(params);
 	return rc;
 }
+EXPORT_SYMBOL(msm_audio_effects_popless_eq_handler);
 
 static int __msm_audio_effects_volume_handler(struct audio_client *ac,
 					      struct soft_volume_params *vol,
@@ -1370,9 +1431,21 @@
 						  SOFT_VOLUME_INSTANCE_1);
 }
 
+/**
+ * msm_audio_effects_volume_handler_v2 -
+ *        Audio effects handler for volume
+ *
+ * @ac: audio client handle
+ * @vol: volume params
+ * @values: values to be updated
+ * @instance: instance to update
+ *
+ * Return 0 on success or error on failure
+ */
 int msm_audio_effects_volume_handler_v2(struct audio_client *ac,
 					struct soft_volume_params *vol,
 					long *values, int instance)
 {
 	return __msm_audio_effects_volume_handler(ac, vol, values, instance);
 }
+EXPORT_SYMBOL(msm_audio_effects_volume_handler_v2);
diff --git a/asoc/msm-compress-q6-v2.c b/asoc/msm-compress-q6-v2.c
index cd9c281..b30c424 100644
--- a/asoc/msm-compress-q6-v2.c
+++ b/asoc/msm-compress-q6-v2.c
@@ -4541,17 +4541,15 @@
 	.remove = msm_compr_remove,
 };
 
-static int __init msm_soc_platform_init(void)
+int __init msm_compress_dsp_init(void)
 {
 	return platform_driver_register(&msm_compr_driver);
 }
-module_init(msm_soc_platform_init);
 
-static void __exit msm_soc_platform_exit(void)
+void __exit msm_compress_dsp_exit(void)
 {
 	platform_driver_unregister(&msm_compr_driver);
 }
-module_exit(msm_soc_platform_exit);
 
 MODULE_DESCRIPTION("Compress Offload platform driver");
 MODULE_LICENSE("GPL v2");
diff --git a/asoc/msm-cpe-lsm.c b/asoc/msm-cpe-lsm.c
index 87297ec..6377784 100644
--- a/asoc/msm-cpe-lsm.c
+++ b/asoc/msm-cpe-lsm.c
@@ -3335,8 +3335,19 @@
 	.probe = msm_cpe_lsm_probe,
 	.remove = msm_cpe_lsm_remove,
 };
-module_platform_driver(msm_cpe_lsm_driver);
 
+int __init msm_cpe_lsm_init(void)
+{
+	return platform_driver_register(&msm_cpe_lsm_driver);
+}
+
+void __exit msm_cpe_lsm_exit(void)
+{
+	platform_driver_unregister(&msm_cpe_lsm_driver);
+}
+
+module_init(msm_cpe_lsm_init);
+module_exit(msm_cpe_lsm_exit);
 MODULE_DESCRIPTION("CPE LSM platform driver");
 MODULE_DEVICE_TABLE(of, msm_cpe_lsm_dt_match);
 MODULE_LICENSE("GPL v2");
diff --git a/asoc/msm-dai-fe.c b/asoc/msm-dai-fe.c
index 89a9cc2..c988eee 100644
--- a/asoc/msm-dai-fe.c
+++ b/asoc/msm-dai-fe.c
@@ -2698,17 +2698,15 @@
 	},
 };
 
-static int __init msm_fe_dai_init(void)
+int __init msm_fe_dai_init(void)
 {
 	return platform_driver_register(&msm_fe_dai_driver);
 }
-module_init(msm_fe_dai_init);
 
-static void __exit msm_fe_dai_exit(void)
+void __exit msm_fe_dai_exit(void)
 {
 	platform_driver_unregister(&msm_fe_dai_driver);
 }
-module_exit(msm_fe_dai_exit);
 
 /* Module information */
 MODULE_DESCRIPTION("MSM Frontend DAI driver");
diff --git a/asoc/msm-dai-q6-hdmi-v2.c b/asoc/msm-dai-q6-hdmi-v2.c
index 212c4e3..eb9f5f5 100644
--- a/asoc/msm-dai-q6-hdmi-v2.c
+++ b/asoc/msm-dai-q6-hdmi-v2.c
@@ -538,17 +538,15 @@
 	},
 };
 
-static int __init msm_dai_q6_hdmi_init(void)
+int __init msm_dai_q6_hdmi_init(void)
 {
 	return platform_driver_register(&msm_dai_q6_hdmi_driver);
 }
-module_init(msm_dai_q6_hdmi_init);
 
-static void __exit msm_dai_q6_hdmi_exit(void)
+void __exit msm_dai_q6_hdmi_exit(void)
 {
 	platform_driver_unregister(&msm_dai_q6_hdmi_driver);
 }
-module_exit(msm_dai_q6_hdmi_exit);
 
 /* Module information */
 MODULE_DESCRIPTION("MSM DSP HDMI DAI driver");
diff --git a/asoc/msm-dai-q6-v2.c b/asoc/msm-dai-q6-v2.c
index cfe47ed..70fcadc 100644
--- a/asoc/msm-dai-q6-v2.c
+++ b/asoc/msm-dai-q6-v2.c
@@ -8857,7 +8857,7 @@
 	},
 };
 
-static int __init msm_dai_q6_init(void)
+int __init msm_dai_q6_init(void)
 {
 	int rc;
 
@@ -8927,16 +8927,17 @@
 fail:
 	return rc;
 }
-module_init(msm_dai_q6_init);
 
-static void __exit msm_dai_q6_exit(void)
+void __exit msm_dai_q6_exit(void)
 {
+	platform_driver_unregister(&msm_dai_q6_tdm_driver);
+	platform_driver_unregister(&msm_dai_q6_spdif_driver);
+	platform_driver_unregister(&msm_dai_mi2s_q6);
+	platform_driver_unregister(&msm_dai_q6_mi2s_driver);
 	platform_driver_unregister(&msm_dai_q6_dev);
 	platform_driver_unregister(&msm_dai_q6);
 	platform_driver_unregister(&msm_auxpcm_dev_driver);
-	platform_driver_unregister(&msm_dai_q6_spdif_driver);
 }
-module_exit(msm_dai_q6_exit);
 
 /* Module information */
 MODULE_DESCRIPTION("MSM DSP DAI driver");
diff --git a/asoc/msm-dai-slim.c b/asoc/msm-dai-slim.c
index 0e7c7b1..427fd6c 100644
--- a/asoc/msm-dai-slim.c
+++ b/asoc/msm-dai-slim.c
@@ -642,7 +642,7 @@
 	.id_table = msm_dai_slim_dt_match,
 };
 
-static int __init msm_dai_slim_init(void)
+int __init msm_dai_slim_init(void)
 {
 	int rc;
 
@@ -652,12 +652,11 @@
 			__func__, rc);
 	return rc;
 }
-module_init(msm_dai_slim_init);
 
-static void __exit msm_dai_slim_exit(void)
+void __exit msm_dai_slim_exit(void)
 {
+	slim_driver_unregister(&msm_dai_slim_driver);
 }
-module_exit(msm_dai_slim_exit);
 
 /* Module information */
 MODULE_DESCRIPTION("Slimbus apps-owned channel handling driver");
diff --git a/asoc/msm-dai-stub-v2.c b/asoc/msm-dai-stub-v2.c
index 3a2c3d3..d4178c8 100644
--- a/asoc/msm-dai-stub-v2.c
+++ b/asoc/msm-dai-stub-v2.c
@@ -354,7 +354,7 @@
 	},
 };
 
-static int __init msm_dai_stub_init(void)
+int __init msm_dai_stub_init(void)
 {
 	int rc = 0;
 
@@ -378,16 +378,14 @@
 fail:
 	return rc;
 }
-module_init(msm_dai_stub_init);
 
-static void __exit msm_dai_stub_exit(void)
+void __exit msm_dai_stub_exit(void)
 {
 	pr_debug("%s:\n", __func__);
 
 	platform_driver_unregister(&msm_dai_stub_dev);
 	platform_driver_unregister(&msm_dai_stub_driver);
 }
-module_exit(msm_dai_stub_exit);
 
 /* Module information */
 MODULE_DESCRIPTION("MSM Stub DSP DAI driver");
diff --git a/asoc/msm-ds2-dap-config.c b/asoc/msm-ds2-dap-config.c
index 7381e5d..419da8f 100644
--- a/asoc/msm-ds2-dap-config.c
+++ b/asoc/msm-ds2-dap-config.c
@@ -2269,7 +2269,7 @@
 
 static int msm_ds2_dap_set_security_control(u32 cmd, void *arg)
 {
-	return 0
+	return 0;
 }
 
 static int msm_ds2_dap_update_dev_map_port_id(int32_t device_id, int port_id)
diff --git a/asoc/msm-dts-srs-tm-config.c b/asoc/msm-dts-srs-tm-config.c
deleted file mode 100644
index 78174af..0000000
--- a/asoc/msm-dts-srs-tm-config.c
+++ /dev/null
@@ -1,357 +0,0 @@
-/*
- * Copyright (c) 2012-2014, 2016-2017, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- */
-
-#include <linux/err.h>
-#include <linux/module.h>
-#include <linux/bitops.h>
-#include <linux/mutex.h>
-#include <linux/atomic.h>
-#include <sound/asound.h>
-#include <sound/control.h>
-#include <asoc/msm-dts-srs-tm-config.h>
-#include <dsp/msm_audio_ion.h>
-#include <dsp/q6adm-v2.h>
-#include "msm-pcm-routing-v2.h"
-
-static int srs_port_id[AFE_MAX_PORTS] = {-1};
-static int srs_copp_idx[AFE_MAX_PORTS] = {-1};
-static union srs_trumedia_params_u msm_srs_trumedia_params;
-static struct ion_client *ion_client;
-static struct ion_handle *ion_handle;
-static struct param_outband po;
-static atomic_t ref_cnt;
-#define ION_MEM_SIZE	(8 * 1024)
-
-static int set_port_id(int port_id, int copp_idx)
-{
-	int index = adm_validate_and_get_port_index(port_id);
-
-	if (index < 0) {
-		pr_err("%s: Invalid port idx %d port_id %#x\n", __func__, index,
-			port_id);
-		return -EINVAL;
-	}
-	srs_port_id[index] = port_id;
-	srs_copp_idx[index] = copp_idx;
-	return 0;
-}
-
-static void msm_dts_srs_tm_send_params(__s32 port_id, __u32 techs)
-{
-	__s32 index = adm_validate_and_get_port_index(port_id);
-
-	if (index < 0) {
-		pr_err("%s: Invalid port idx %d port_id 0x%x\n",
-			__func__, index, port_id);
-		return;
-	}
-	if ((srs_copp_idx[index] < 0) ||
-	    (srs_copp_idx[index] >= MAX_COPPS_PER_PORT)) {
-		pr_debug("%s: send params called before copp open. so, caching\n",
-			 __func__);
-		return;
-	}
-	pr_debug("SRS %s: called, port_id = %d, techs flags = %u\n",
-		__func__, port_id, techs);
-	/* force all if techs is set to 1 */
-	if (techs == 1)
-		techs = 0xFFFFFFFF;
-
-	if (techs & (1 << SRS_ID_WOWHD))
-		srs_trumedia_open(port_id, srs_copp_idx[index], SRS_ID_WOWHD,
-			(void *)&msm_srs_trumedia_params.srs_params.wowhd);
-	if (techs & (1 << SRS_ID_CSHP))
-		srs_trumedia_open(port_id, srs_copp_idx[index], SRS_ID_CSHP,
-			(void *)&msm_srs_trumedia_params.srs_params.cshp);
-	if (techs & (1 << SRS_ID_HPF))
-		srs_trumedia_open(port_id, srs_copp_idx[index], SRS_ID_HPF,
-			(void *)&msm_srs_trumedia_params.srs_params.hpf);
-	if (techs & (1 << SRS_ID_AEQ))
-		srs_trumedia_open(port_id, srs_copp_idx[index], SRS_ID_AEQ,
-			(void *)&msm_srs_trumedia_params.srs_params.aeq);
-	if (techs & (1 << SRS_ID_HL))
-		srs_trumedia_open(port_id, srs_copp_idx[index], SRS_ID_HL,
-			(void *)&msm_srs_trumedia_params.srs_params.hl);
-	if (techs & (1 << SRS_ID_GEQ))
-		srs_trumedia_open(port_id, srs_copp_idx[index], SRS_ID_GEQ,
-			(void *)&msm_srs_trumedia_params.srs_params.geq);
-	if (techs & (1 << SRS_ID_GLOBAL))
-		srs_trumedia_open(port_id, srs_copp_idx[index], SRS_ID_GLOBAL,
-			(void *)&msm_srs_trumedia_params.srs_params.global);
-}
-
-
-static int msm_dts_srs_trumedia_control_get(struct snd_kcontrol *kcontrol,
-					    struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.integer.value[0] = 0;
-	return 0;
-}
-
-static int msm_dts_srs_trumedia_control_set_(int port_id,
-					    struct snd_kcontrol *kcontrol,
-					    struct snd_ctl_elem_value *ucontrol)
-{
-
-	__u16 offset, value, max = sizeof(msm_srs_trumedia_params) >> 1;
-
-	if (SRS_CMD_UPLOAD ==
-		(ucontrol->value.integer.value[0] & SRS_CMD_UPLOAD)) {
-		__u32 techs = ucontrol->value.integer.value[0] & 0xFF;
-		__s32 index = adm_validate_and_get_port_index(port_id);
-
-		if (index < 0) {
-			pr_err("%s: Invalid port idx %d port_id 0x%x\n",
-					__func__, index, port_id);
-				return -EINVAL;
-			}
-		pr_debug("SRS %s: send params request, flag = %u\n",
-					__func__, techs);
-		if (srs_port_id[index] >= 0 && techs)
-			msm_dts_srs_tm_send_params(port_id, techs);
-		return 0;
-	}
-	offset = (__u16)((ucontrol->value.integer.value[0] &
-			SRS_PARAM_OFFSET_MASK) >> 16);
-	value = (__u16)(ucontrol->value.integer.value[0] &
-			SRS_PARAM_VALUE_MASK);
-	if (offset < max) {
-		msm_srs_trumedia_params.raw_params[offset] = value;
-		pr_debug("SRS %s: index set... (max %d, requested %d, value 0x%X)\n",
-			 __func__, max, offset, value);
-	} else {
-		pr_err("SRS %s: index out of bounds! (max %d, requested %d)\n",
-		       __func__, max, offset);
-	}
-	return 0;
-}
-
-static int msm_dts_srs_trumedia_control_set(struct snd_kcontrol *kcontrol,
-				      struct snd_ctl_elem_value *ucontrol)
-{
-	int ret, port_id;
-
-	pr_debug("SRS control normal called\n");
-	msm_pcm_routing_acquire_lock();
-	port_id = SLIMBUS_0_RX;
-	ret = msm_dts_srs_trumedia_control_set_(port_id, kcontrol, ucontrol);
-	msm_pcm_routing_release_lock();
-	return ret;
-}
-
-static int msm_dts_srs_trumedia_control_i2s_set(struct snd_kcontrol *kcontrol,
-					  struct snd_ctl_elem_value *ucontrol)
-{
-	int ret, port_id;
-
-	pr_debug("SRS control I2S called\n");
-	msm_pcm_routing_acquire_lock();
-	port_id = PRIMARY_I2S_RX;
-	ret = msm_dts_srs_trumedia_control_set_(port_id, kcontrol, ucontrol);
-	msm_pcm_routing_release_lock();
-	return ret;
-}
-
-static int msm_dts_srs_trumedia_control_mi2s_set(struct snd_kcontrol *kcontrol,
-					  struct snd_ctl_elem_value *ucontrol)
-{
-	int ret, port_id;
-
-	pr_debug("SRS control MI2S called\n");
-	msm_pcm_routing_acquire_lock();
-	port_id = AFE_PORT_ID_PRIMARY_MI2S_RX;
-	ret = msm_dts_srs_trumedia_control_set_(port_id, kcontrol, ucontrol);
-	msm_pcm_routing_release_lock();
-	return ret;
-}
-
-static int msm_dts_srs_trumedia_control_hdmi_set(struct snd_kcontrol *kcontrol,
-					   struct snd_ctl_elem_value *ucontrol)
-{
-	int ret, port_id;
-
-	pr_debug("SRS control HDMI called\n");
-	msm_pcm_routing_acquire_lock();
-	port_id = HDMI_RX;
-	ret = msm_dts_srs_trumedia_control_set_(port_id, kcontrol, ucontrol);
-	msm_pcm_routing_release_lock();
-	return ret;
-}
-
-static const struct snd_kcontrol_new lpa_srs_trumedia_controls[] = {
-	{.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-	.name = "SRS TruMedia",
-	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |
-			SNDRV_CTL_ELEM_ACCESS_READWRITE,
-	.info = snd_soc_info_volsw,
-	.get = msm_dts_srs_trumedia_control_get,
-	.put = msm_dts_srs_trumedia_control_set,
-	.private_value = ((unsigned long)&(struct soc_mixer_control)
-	{.reg = SND_SOC_NOPM,
-	.rreg = SND_SOC_NOPM,
-	.shift = 0,
-	.rshift = 0,
-	.max = 0xFFFFFFFF,
-	.platform_max = 0xFFFFFFFF,
-	.invert = 0
-	})
-	}
-};
-
-static const struct snd_kcontrol_new lpa_srs_trumedia_controls_hdmi[] = {
-	{.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-	.name = "SRS TruMedia HDMI",
-	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |
-			SNDRV_CTL_ELEM_ACCESS_READWRITE,
-	.info = snd_soc_info_volsw,
-	.get = msm_dts_srs_trumedia_control_get,
-	.put = msm_dts_srs_trumedia_control_hdmi_set,
-	.private_value = ((unsigned long)&(struct soc_mixer_control)
-	{.reg = SND_SOC_NOPM,
-	.rreg = SND_SOC_NOPM,
-	.shift = 0,
-	.rshift = 0,
-	.max = 0xFFFFFFFF,
-	.platform_max = 0xFFFFFFFF,
-	.invert = 0
-	})
-	}
-};
-
-static const struct snd_kcontrol_new lpa_srs_trumedia_controls_i2s[] = {
-	{.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-	.name = "SRS TruMedia I2S",
-	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |
-		SNDRV_CTL_ELEM_ACCESS_READWRITE,
-	.info = snd_soc_info_volsw,
-	.get = msm_dts_srs_trumedia_control_get,
-	.put = msm_dts_srs_trumedia_control_i2s_set,
-	.private_value = ((unsigned long)&(struct soc_mixer_control)
-	{.reg = SND_SOC_NOPM,
-	.rreg = SND_SOC_NOPM,
-	.shift = 0,
-	.rshift = 0,
-	.max = 0xFFFFFFFF,
-	.platform_max = 0xFFFFFFFF,
-	.invert = 0
-	})
-	}
-};
-
-static const struct snd_kcontrol_new lpa_srs_trumedia_controls_mi2s[] = {
-	{
-		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-		.name = "SRS TruMedia MI2S",
-		.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |
-			SNDRV_CTL_ELEM_ACCESS_READWRITE,
-		.info = snd_soc_info_volsw,
-		.get = msm_dts_srs_trumedia_control_get,
-		.put = msm_dts_srs_trumedia_control_mi2s_set,
-		.private_value = ((unsigned long)&(struct soc_mixer_control)
-		{
-			.reg = SND_SOC_NOPM,
-			.rreg = SND_SOC_NOPM,
-			.shift = 0,
-			.rshift = 0,
-			.max = 0xFFFFFFFF,
-			.platform_max = 0xFFFFFFFF,
-			.invert = 0
-		})
-	}
-};
-
-void msm_dts_srs_tm_add_controls(struct snd_soc_platform *platform)
-{
-	snd_soc_add_platform_controls(platform,
-				lpa_srs_trumedia_controls,
-			ARRAY_SIZE(lpa_srs_trumedia_controls));
-
-	snd_soc_add_platform_controls(platform,
-				lpa_srs_trumedia_controls_hdmi,
-			ARRAY_SIZE(lpa_srs_trumedia_controls_hdmi));
-
-	snd_soc_add_platform_controls(platform,
-				lpa_srs_trumedia_controls_i2s,
-			ARRAY_SIZE(lpa_srs_trumedia_controls_i2s));
-	snd_soc_add_platform_controls(platform,
-				lpa_srs_trumedia_controls_mi2s,
-			ARRAY_SIZE(lpa_srs_trumedia_controls_mi2s));
-}
-
-static int reg_ion_mem(void)
-{
-	int rc;
-
-	rc = msm_audio_ion_alloc("SRS_TRUMEDIA", &ion_client, &ion_handle,
-				 ION_MEM_SIZE, &po.paddr, (size_t *)&po.size,
-				 &po.kvaddr);
-	if (rc != 0)
-		pr_err("%s: failed to allocate memory.\n", __func__);
-		pr_debug("%s: exited ion_client = %pK, ion_handle = %pK, phys_addr = %lu, length = %d, vaddr = %pK, rc = 0x%x\n",
-			__func__, ion_client, ion_handle, (long)po.paddr,
-			(unsigned int)po.size, po.kvaddr, rc);
-	return rc;
-}
-
-void msm_dts_srs_tm_ion_memmap(struct param_outband *po_)
-{
-	if (po.kvaddr == NULL) {
-		pr_debug("%s: callingreg_ion_mem()\n", __func__);
-		reg_ion_mem();
-	}
-	po_->size = ION_MEM_SIZE;
-	po_->kvaddr = po.kvaddr;
-	po_->paddr = po.paddr;
-}
-
-static void unreg_ion_mem(void)
-{
-	msm_audio_ion_free(ion_client, ion_handle);
-	po.kvaddr = NULL;
-	po.paddr = 0;
-	po.size = 0;
-}
-
-void msm_dts_srs_tm_deinit(int port_id)
-{
-	set_port_id(port_id, -1);
-	atomic_dec(&ref_cnt);
-	if (po.kvaddr != NULL) {
-		if (!atomic_read(&ref_cnt)) {
-			pr_debug("%s: calling unreg_ion_mem()\n", __func__);
-			unreg_ion_mem();
-		}
-	}
-}
-
-void msm_dts_srs_tm_init(int port_id, int copp_idx)
-{
-	int cur_ref_cnt = 0;
-
-	if (set_port_id(port_id, copp_idx) < 0) {
-		pr_err("%s: Invalid port_id: %d\n", __func__, port_id);
-		return;
-	}
-
-	cur_ref_cnt = atomic_read(&ref_cnt);
-	atomic_inc(&ref_cnt);
-	if (!cur_ref_cnt && po.kvaddr == NULL) {
-		pr_debug("%s: calling reg_ion_mem()\n", __func__);
-		if (reg_ion_mem() != 0) {
-			atomic_dec(&ref_cnt);
-			po.kvaddr = NULL;
-			return;
-		}
-	}
-	msm_dts_srs_tm_send_params(port_id, 1);
-}
diff --git a/asoc/msm-lsm-client.c b/asoc/msm-lsm-client.c
index 339125e..15cdfb1 100644
--- a/asoc/msm-lsm-client.c
+++ b/asoc/msm-lsm-client.c
@@ -2401,17 +2401,15 @@
 	.remove = msm_lsm_remove,
 };
 
-static int __init msm_soc_platform_init(void)
+int __init msm_lsm_client_init(void)
 {
 	return platform_driver_register(&msm_lsm_driver);
 }
-module_init(msm_soc_platform_init);
 
-static void __exit msm_soc_platform_exit(void)
+void __exit msm_lsm_client_exit(void)
 {
 	platform_driver_unregister(&msm_lsm_driver);
 }
-module_exit(msm_soc_platform_exit);
 
 MODULE_DESCRIPTION("LSM client platform driver");
 MODULE_DEVICE_TABLE(of, msm_lsm_client_dt_match);
diff --git a/asoc/msm-pcm-afe-v2.c b/asoc/msm-pcm-afe-v2.c
index 102fad8..f700f0b 100644
--- a/asoc/msm-pcm-afe-v2.c
+++ b/asoc/msm-pcm-afe-v2.c
@@ -904,19 +904,17 @@
 	.remove = msm_afe_remove,
 };
 
-static int __init msm_soc_platform_init(void)
+int __init msm_pcm_afe_init(void)
 {
 	pr_debug("%s\n", __func__);
 	return platform_driver_register(&msm_afe_driver);
 }
-module_init(msm_soc_platform_init);
 
-static void __exit msm_soc_platform_exit(void)
+void __exit msm_pcm_afe_exit(void)
 {
 	pr_debug("%s\n", __func__);
 	platform_driver_unregister(&msm_afe_driver);
 }
-module_exit(msm_soc_platform_exit);
 
 MODULE_DESCRIPTION("AFE PCM module platform driver");
 MODULE_LICENSE("GPL v2");
diff --git a/asoc/msm-pcm-dtmf-v2.c b/asoc/msm-pcm-dtmf-v2.c
index c387c7d..7bc823b 100644
--- a/asoc/msm-pcm-dtmf-v2.c
+++ b/asoc/msm-pcm-dtmf-v2.c
@@ -580,17 +580,15 @@
 	.remove = msm_pcm_remove,
 };
 
-static int __init msm_soc_platform_init(void)
+int __init msm_pcm_dtmf_init(void)
 {
 	return platform_driver_register(&msm_pcm_driver);
 }
-module_init(msm_soc_platform_init);
 
-static void __exit msm_soc_platform_exit(void)
+void __exit msm_pcm_dtmf_exit(void)
 {
 	platform_driver_unregister(&msm_pcm_driver);
 }
-module_exit(msm_soc_platform_exit);
 
 MODULE_DESCRIPTION("DTMF platform driver");
 MODULE_LICENSE("GPL v2");
diff --git a/asoc/msm-pcm-host-voice-v2.c b/asoc/msm-pcm-host-voice-v2.c
index 55b07bc..0c47ec1 100644
--- a/asoc/msm-pcm-host-voice-v2.c
+++ b/asoc/msm-pcm-host-voice-v2.c
@@ -1504,7 +1504,7 @@
 	.remove = msm_pcm_remove,
 };
 
-static int __init msm_soc_platform_init(void)
+int __init msm_voice_host_init(void)
 {
 	int i = 0;
 	struct session *s = NULL;
@@ -1541,13 +1541,11 @@
 
 	return platform_driver_register(&msm_pcm_driver);
 }
-module_init(msm_soc_platform_init);
 
-static void __exit msm_soc_platform_exit(void)
+void __exit msm_voice_host_exit(void)
 {
 	platform_driver_unregister(&msm_pcm_driver);
 }
-module_exit(msm_soc_platform_exit);
 
 MODULE_DESCRIPTION("PCM module platform driver");
 MODULE_LICENSE("GPL v2");
diff --git a/asoc/msm-pcm-hostless.c b/asoc/msm-pcm-hostless.c
index 35766b4..90d76b4 100644
--- a/asoc/msm-pcm-hostless.c
+++ b/asoc/msm-pcm-hostless.c
@@ -66,17 +66,15 @@
 	.remove = msm_pcm_hostless_remove,
 };
 
-static int __init msm_soc_platform_init(void)
+int __init msm_pcm_hostless_init(void)
 {
 	return platform_driver_register(&msm_pcm_hostless_driver);
 }
-module_init(msm_soc_platform_init);
 
-static void __exit msm_soc_platform_exit(void)
+void __exit msm_pcm_hostless_exit(void)
 {
 	platform_driver_unregister(&msm_pcm_hostless_driver);
 }
-module_exit(msm_soc_platform_exit);
 
 MODULE_DESCRIPTION("Hostless platform driver");
 MODULE_LICENSE("GPL v2");
diff --git a/asoc/msm-pcm-loopback-v2.c b/asoc/msm-pcm-loopback-v2.c
index a6ac8ca..e50a005 100644
--- a/asoc/msm-pcm-loopback-v2.c
+++ b/asoc/msm-pcm-loopback-v2.c
@@ -785,17 +785,15 @@
 	.remove = msm_pcm_remove,
 };
 
-static int __init msm_soc_platform_init(void)
+int __init msm_pcm_loopback_init(void)
 {
 	return platform_driver_register(&msm_pcm_driver);
 }
-module_init(msm_soc_platform_init);
 
-static void __exit msm_soc_platform_exit(void)
+void __exit msm_pcm_loopback_exit(void)
 {
 	platform_driver_unregister(&msm_pcm_driver);
 }
-module_exit(msm_soc_platform_exit);
 
 MODULE_DESCRIPTION("PCM loopback platform driver");
 MODULE_LICENSE("GPL v2");
diff --git a/asoc/msm-pcm-q6-noirq.c b/asoc/msm-pcm-q6-noirq.c
index 3e03437..307e7a6 100644
--- a/asoc/msm-pcm-q6-noirq.c
+++ b/asoc/msm-pcm-q6-noirq.c
@@ -1252,33 +1252,31 @@
 	snd_soc_unregister_platform(&pdev->dev);
 	return 0;
 }
-static const struct of_device_id msm_pcm_dt_match[] = {
+static const struct of_device_id msm_pcm_noirq_dt_match[] = {
 	{.compatible = "qcom,msm-pcm-dsp-noirq"},
 	{}
 };
-MODULE_DEVICE_TABLE(of, msm_pcm_dt_match);
+MODULE_DEVICE_TABLE(of, msm_pcm_noirq_dt_match);
 
 static struct platform_driver msm_pcm_driver_noirq = {
 	.driver = {
 		.name = "msm-pcm-dsp-noirq",
 		.owner = THIS_MODULE,
-		.of_match_table = msm_pcm_dt_match,
+		.of_match_table = msm_pcm_noirq_dt_match,
 	},
 	.probe = msm_pcm_probe,
 	.remove = msm_pcm_remove,
 };
 
-static int __init msm_soc_platform_init(void)
+int __init msm_pcm_noirq_init(void)
 {
 	return platform_driver_register(&msm_pcm_driver_noirq);
 }
-module_init(msm_soc_platform_init);
 
-static void __exit msm_soc_platform_exit(void)
+void __exit msm_pcm_noirq_exit(void)
 {
 	platform_driver_unregister(&msm_pcm_driver_noirq);
 }
-module_exit(msm_soc_platform_exit);
 
 MODULE_DESCRIPTION("PCM NOIRQ module platform driver");
 MODULE_LICENSE("GPL v2");
diff --git a/asoc/msm-pcm-q6-v2.c b/asoc/msm-pcm-q6-v2.c
index 4910dec..0a0e26d 100644
--- a/asoc/msm-pcm-q6-v2.c
+++ b/asoc/msm-pcm-q6-v2.c
@@ -1863,7 +1863,7 @@
 	.remove = msm_pcm_remove,
 };
 
-static int __init msm_soc_platform_init(void)
+int __init msm_pcm_dsp_init(void)
 {
 	init_waitqueue_head(&the_locks.enable_wait);
 	init_waitqueue_head(&the_locks.eos_wait);
@@ -1872,13 +1872,11 @@
 
 	return platform_driver_register(&msm_pcm_driver);
 }
-module_init(msm_soc_platform_init);
 
-static void __exit msm_soc_platform_exit(void)
+void __exit msm_pcm_dsp_exit(void)
 {
 	platform_driver_unregister(&msm_pcm_driver);
 }
-module_exit(msm_soc_platform_exit);
 
 MODULE_DESCRIPTION("PCM module platform driver");
 MODULE_LICENSE("GPL v2");
diff --git a/asoc/msm-pcm-routing-v2.c b/asoc/msm-pcm-routing-v2.c
index 3338ac6..965518b 100644
--- a/asoc/msm-pcm-routing-v2.c
+++ b/asoc/msm-pcm-routing-v2.c
@@ -30,7 +30,7 @@
 #include <sound/pcm_params.h>
 #include <sound/hwdep.h>
 #include <sound/audio_effects.h>
-#include <asoc/msm-dts-srs-tm-config.h>
+#include <dsp/msm-dts-srs-tm-config.h>
 #include <dsp/q6voice.h>
 #include <dsp/q6adm-v2.h>
 #include <dsp/q6asm-v2.h>
@@ -17781,7 +17781,7 @@
 	return ret;
 }
 
-static int __init msm_soc_routing_platform_init(void)
+int __init msm_soc_routing_platform_init(void)
 {
 	mutex_init(&routing_lock);
 	if (msm_routing_init_cal_data())
@@ -17795,16 +17795,14 @@
 
 	return platform_driver_register(&msm_routing_pcm_driver);
 }
-module_init(msm_soc_routing_platform_init);
 
-static void __exit msm_soc_routing_platform_exit(void)
+void __exit msm_soc_routing_platform_exit(void)
 {
 	msm_routing_delete_cal_data();
 	memset(&be_dai_name_table, 0, sizeof(be_dai_name_table));
 	mutex_destroy(&routing_lock);
 	platform_driver_unregister(&msm_routing_pcm_driver);
 }
-module_exit(msm_soc_routing_platform_exit);
 
 MODULE_DESCRIPTION("MSM routing platform driver");
 MODULE_LICENSE("GPL v2");
diff --git a/asoc/msm-pcm-voice-v2.c b/asoc/msm-pcm-voice-v2.c
index 9972132..7b236b4 100644
--- a/asoc/msm-pcm-voice-v2.c
+++ b/asoc/msm-pcm-voice-v2.c
@@ -758,7 +758,7 @@
 	.remove = msm_pcm_remove,
 };
 
-static int __init msm_soc_platform_init(void)
+int __init msm_pcm_voice_init(void)
 {
 	int i = 0;
 
@@ -769,13 +769,11 @@
 
 	return platform_driver_register(&msm_pcm_driver);
 }
-module_init(msm_soc_platform_init);
 
-static void __exit msm_soc_platform_exit(void)
+void __exit msm_pcm_voice_exit(void)
 {
 	platform_driver_unregister(&msm_pcm_driver);
 }
-module_exit(msm_soc_platform_exit);
 
 MODULE_DESCRIPTION("Voice PCM module platform driver");
 MODULE_LICENSE("GPL v2");
diff --git a/asoc/msm-pcm-voip-v2.c b/asoc/msm-pcm-voip-v2.c
index 86dcaca..58fc534 100644
--- a/asoc/msm-pcm-voip-v2.c
+++ b/asoc/msm-pcm-voip-v2.c
@@ -1684,7 +1684,7 @@
 	.remove = msm_pcm_remove,
 };
 
-static int __init msm_soc_platform_init(void)
+int __init msm_pcm_voip_init(void)
 {
 	memset(&voip_info, 0, sizeof(voip_info));
 	voip_info.mode = MODE_PCM;
@@ -1703,13 +1703,11 @@
 
 	return platform_driver_register(&msm_pcm_driver);
 }
-module_init(msm_soc_platform_init);
 
-static void __exit msm_soc_platform_exit(void)
+void __exit msm_pcm_voip_exit(void)
 {
 	platform_driver_unregister(&msm_pcm_driver);
 }
-module_exit(msm_soc_platform_exit);
 
 MODULE_DESCRIPTION("PCM module platform driver");
 MODULE_LICENSE("GPL v2");
diff --git a/asoc/msm-transcode-loopback-q6-v2.c b/asoc/msm-transcode-loopback-q6-v2.c
index eaef498..94ebbf7 100644
--- a/asoc/msm-transcode-loopback-q6-v2.c
+++ b/asoc/msm-transcode-loopback-q6-v2.c
@@ -951,20 +951,18 @@
 	.remove = msm_transcode_remove,
 };
 
-static int __init msm_soc_platform_init(void)
+int __init msm_transcode_loopback_init(void)
 {
 	memset(&transcode_info, 0, sizeof(struct msm_transcode_loopback));
 	mutex_init(&transcode_info.lock);
 	return platform_driver_register(&msm_transcode_loopback_driver);
 }
-module_init(msm_soc_platform_init);
 
-static void __exit msm_soc_platform_exit(void)
+void __exit msm_transcode_loopback_exit(void)
 {
 	mutex_destroy(&transcode_info.lock);
 	platform_driver_unregister(&msm_transcode_loopback_driver);
 }
-module_exit(msm_soc_platform_exit);
 
 MODULE_DESCRIPTION("Transcode loopback platform driver");
 MODULE_LICENSE("GPL v2");
diff --git a/asoc/platform_init.c b/asoc/platform_init.c
new file mode 100644
index 0000000..79d0e41
--- /dev/null
+++ b/asoc/platform_init.c
@@ -0,0 +1,69 @@
+/*
+Copyright (c) 2017, The Linux Foundation. All rights reserved.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License version 2 and
+only version 2 as published by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+*
+*/
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include "platform_init.h"
+
+static int __init audio_platform_init(void)
+{
+	msm_compress_dsp_init();
+	msm_fe_dai_init();
+	msm_dai_q6_hdmi_init();
+	msm_dai_q6_init();
+	msm_dai_slim_init();
+	msm_dai_stub_init();
+	msm_lsm_client_init();
+	msm_pcm_afe_init();
+	msm_pcm_dtmf_init();
+	msm_pcm_hostless_init();
+	msm_voice_host_init();
+	msm_pcm_loopback_init();
+	msm_pcm_noirq_init();
+	msm_pcm_dsp_init();
+	msm_soc_routing_platform_init();
+	msm_pcm_voice_init();
+	msm_pcm_voip_init();
+	msm_transcode_loopback_init();
+
+	return 0;
+}
+
+static void audio_platform_exit(void)
+{
+	msm_transcode_loopback_exit();
+	msm_pcm_voip_exit();
+	msm_pcm_voice_exit();
+	msm_soc_routing_platform_exit();
+	msm_pcm_dsp_exit();
+	msm_pcm_noirq_exit();
+	msm_pcm_loopback_exit();
+	msm_voice_host_exit();
+	msm_pcm_hostless_exit();
+	msm_pcm_dtmf_exit();
+	msm_pcm_afe_exit();
+	msm_lsm_client_exit();
+	msm_dai_stub_exit();
+	msm_dai_slim_exit();
+	msm_dai_q6_exit();
+	msm_dai_q6_hdmi_exit();
+	msm_fe_dai_exit();
+	msm_compress_dsp_exit();
+}
+
+module_init(audio_platform_init);
+module_exit(audio_platform_exit);
+
+MODULE_DESCRIPTION("Audio Platform driver");
+MODULE_LICENSE("GPL v2");
diff --git a/asoc/platform_init.h b/asoc/platform_init.h
new file mode 100644
index 0000000..db9b32d
--- /dev/null
+++ b/asoc/platform_init.h
@@ -0,0 +1,58 @@
+/*
+Copyright (c) 2017, The Linux Foundation. All rights reserved.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License version 2 and
+only version 2 as published by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+*
+*/
+
+#ifndef __PLATFORM_INIT_H__
+#define __PLATFORM_INIT_H__
+int msm_compress_dsp_init(void);
+int msm_fe_dai_init(void);
+int msm_dai_q6_hdmi_init(void);
+int msm_dai_q6_init(void);
+int msm_dai_slim_init(void);
+int msm_dai_stub_init(void);
+int msm_lsm_client_init(void);
+int msm_pcm_afe_init(void);
+int msm_pcm_dtmf_init(void);
+int msm_pcm_hostless_init(void);
+int msm_voice_host_init(void);
+int msm_pcm_loopback_init(void);
+int msm_pcm_noirq_init(void);
+int msm_pcm_dsp_init(void);
+int msm_soc_routing_platform_init(void);
+int msm_pcm_voice_init(void);
+int msm_pcm_voip_init(void);
+int msm_transcode_loopback_init(void);
+int msm_cpe_lsm_init(void);
+
+void msm_cpe_lsm_exit(void);
+void msm_transcode_loopback_exit(void);
+void msm_pcm_voip_exit(void);
+void msm_pcm_voice_exit(void);
+void msm_soc_routing_platform_exit(void);
+void msm_pcm_dsp_exit(void);
+void msm_pcm_noirq_exit(void);
+void msm_pcm_loopback_exit(void);
+void msm_voice_host_exit(void);
+void msm_pcm_hostless_exit(void);
+void msm_pcm_dtmf_exit(void);
+void msm_pcm_afe_exit(void);
+void msm_lsm_client_exit(void);
+void msm_dai_stub_exit(void);
+void msm_dai_slim_exit(void);
+void msm_dai_q6_exit(void);
+void msm_dai_q6_hdmi_exit(void);
+void msm_fe_dai_exit(void);
+void msm_compress_dsp_exit(void);
+
+#endif
+