Ver Fonte

Merge "asoc: codecs: Add compile rules for RX/TX macro modules"

Linux Build Service Account há 6 anos atrás
pai
commit
6891816204
3 ficheiros alterados com 153 adições e 3 exclusões
  1. 82 0
      asoc/codecs/bolero/Android.mk
  2. 14 0
      asoc/codecs/bolero/Kbuild
  3. 57 3
      asoc/codecs/bolero/rx-macro.c

+ 82 - 0
asoc/codecs/bolero/Android.mk

@@ -0,0 +1,82 @@
+# 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,$(MSMSTEPPE)),true)
+AUDIO_SELECT  := CONFIG_SND_SOC_SM6150=m
+endif
+
+AUDIO_CHIPSET := audio
+# Build/Package only in case of supported target
+ifeq ($(call is-board-platform-in-list,$(MSMSTEPPE)),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=bolero_cdc_dlkm
+KBUILD_OPTIONS += BOARD_PLATFORM=$(TARGET_BOARD_PLATFORM)
+KBUILD_OPTIONS += $(AUDIO_SELECT)
+
+###########################################################
+include $(CLEAR_VARS)
+LOCAL_MODULE              := $(AUDIO_CHIPSET)_bolero_cdc.ko
+LOCAL_MODULE_KBUILD_NAME  := bolero_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)_wsa_macro.ko
+LOCAL_MODULE_KBUILD_NAME  := wsa_macro_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)_va_macro.ko
+LOCAL_MODULE_KBUILD_NAME  := va_macro_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)_tx_macro.ko
+LOCAL_MODULE_KBUILD_NAME  := tx_macro_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)_rx_macro.ko
+LOCAL_MODULE_KBUILD_NAME  := rx_macro_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

+ 14 - 0
asoc/codecs/bolero/Kbuild

@@ -70,6 +70,14 @@ ifdef CONFIG_VA_MACRO
 	VA_OBJS += va-macro.o
 endif
 
+ifdef CONFIG_TX_MACRO
+	TX_OBJS += tx-macro.o
+endif
+
+ifdef CONFIG_RX_MACRO
+	RX_OBJS += rx-macro.o
+endif
+
 LINUX_INC +=	-Iinclude/linux
 
 INCS +=		$(COMMON_INC) \
@@ -121,5 +129,11 @@ wsa_macro_dlkm-y := $(WSA_OBJS)
 obj-$(CONFIG_VA_MACRO) += va_macro_dlkm.o
 va_macro_dlkm-y := $(VA_OBJS)
 
+obj-$(CONFIG_TX_MACRO) += tx_macro_dlkm.o
+tx_macro_dlkm-y := $(TX_OBJS)
+
+obj-$(CONFIG_RX_MACRO) += rx_macro_dlkm.o
+rx_macro_dlkm-y := $(RX_OBJS)
+
 # inject some build related information
 DEFINES += -DBUILD_TIMESTAMP=\"$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')\"

+ 57 - 3
asoc/codecs/bolero/rx-macro.c

@@ -227,6 +227,8 @@ struct rx_macro_priv {
 	int rx_mclk_users;
 	int swr_clk_users;
 	int rx_mclk_cnt;
+	bool is_native_on;
+	u16 mclk_mux;
 	struct mutex mclk_lock;
 	struct mutex swr_clk_lock;
 	struct rx_swr_ctrl_data *swr_ctrl_data;
@@ -307,6 +309,10 @@ static const char *const rx_macro_mux_text[] = {
 	"ZERO", "AIF1_PB", "AIF2_PB", "AIF3_PB", "AIF4_PB"
 };
 
+static const char *const rx_macro_native_text[] = {"OFF", "ON"};
+static const struct soc_enum rx_macro_native_enum =
+	SOC_ENUM_SINGLE_EXT(2, rx_macro_native_text);
+
 RX_MACRO_DAPM_ENUM(rx_int0_2, BOLERO_CDC_RX_INP_MUX_RX_INT0_CFG1, 0,
 		rx_int_mix_mux_text);
 RX_MACRO_DAPM_ENUM(rx_int1_2, BOLERO_CDC_RX_INP_MUX_RX_INT1_CFG1, 0,
@@ -730,22 +736,25 @@ static int rx_macro_mclk_enable(struct rx_macro_priv *rx_priv,
 				 bool mclk_enable, bool dapm)
 {
 	struct regmap *regmap = dev_get_regmap(rx_priv->dev->parent, NULL);
-	int ret = 0;
+	int ret = 0, mclk_mux = MCLK_MUX0;
 
 	dev_dbg(rx_priv->dev, "%s: mclk_enable = %u, dapm = %d clk_users= %d\n",
 		__func__, mclk_enable, dapm, rx_priv->rx_mclk_users);
 
+	if(rx_priv->is_native_on)
+		mclk_mux = MCLK_MUX1;
 	mutex_lock(&rx_priv->mclk_lock);
 	if (mclk_enable) {
 		if (rx_priv->rx_mclk_users == 0) {
 			ret = bolero_request_clock(rx_priv->dev,
-					RX_MACRO, MCLK_MUX0, true);
+					RX_MACRO, mclk_mux, true);
 			if (ret < 0) {
 				dev_err(rx_priv->dev,
 					"%s: rx request clock enable failed\n",
 					__func__);
 				goto exit;
 			}
+			rx_priv->mclk_mux = mclk_mux;
 			regcache_mark_dirty(regmap);
 			regcache_sync_region(regmap,
 					RX_START_OFFSET,
@@ -774,7 +783,8 @@ static int rx_macro_mclk_enable(struct rx_macro_priv *rx_priv,
 				BOLERO_CDC_RX_CLK_RST_CTRL_MCLK_CONTROL,
 				0x01, 0x00);
 			bolero_request_clock(rx_priv->dev,
-					RX_MACRO, MCLK_MUX0, false);
+					RX_MACRO, mclk_mux, false);
+			rx_priv->mclk_mux = MCLK_MUX0;
 		}
 	}
 exit:
@@ -796,6 +806,17 @@ static int rx_macro_mclk_event(struct snd_soc_dapm_widget *w,
 	dev_dbg(rx_dev, "%s: event = %d\n", __func__, event);
 	switch (event) {
 	case SND_SOC_DAPM_PRE_PMU:
+		/* if swr_clk_users > 0, call device down */
+		if (rx_priv->swr_clk_users > 0) {
+			if ((rx_priv->mclk_mux == MCLK_MUX0 &&
+			     rx_priv->is_native_on) ||
+			     (rx_priv->mclk_mux == MCLK_MUX1 &&
+			     !rx_priv->is_native_on)) {
+				swrm_wcd_notify(
+				rx_priv->swr_ctrl_data[0].rx_swr_pdev,
+				SWR_DEVICE_DOWN, NULL);
+			}
+		}
 		ret = rx_macro_mclk_enable(rx_priv, 1, true);
 		break;
 	case SND_SOC_DAPM_POST_PMD:
@@ -1227,6 +1248,36 @@ err:
 	return -EINVAL;
 }
 
+static int rx_macro_get_native(struct snd_kcontrol *kcontrol,
+			       struct snd_ctl_elem_value *ucontrol)
+{
+	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
+	struct device *rx_dev = NULL;
+	struct rx_macro_priv *rx_priv = NULL;
+
+	if (!rx_macro_get_data(codec, &rx_dev, &rx_priv, __func__))
+		return -EINVAL;
+
+	ucontrol->value.integer.value[0] =
+				(rx_priv->is_native_on == true ? 1 : 0);
+	return 0;
+}
+
+static int rx_macro_put_native(struct snd_kcontrol *kcontrol,
+			       struct snd_ctl_elem_value *ucontrol)
+{
+	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
+	struct device *rx_dev = NULL;
+	struct rx_macro_priv *rx_priv = NULL;
+
+	if (!rx_macro_get_data(codec, &rx_dev, &rx_priv, __func__))
+		return -EINVAL;
+
+	rx_priv->is_native_on =
+			(!ucontrol->value.integer.value[0] ? false : true);
+	return 0;
+}
+
 static void rx_macro_idle_detect_control(struct snd_soc_codec *codec,
 					 struct rx_macro_priv *rx_priv,
 					 int interp, int event)
@@ -1695,6 +1746,9 @@ static const struct snd_kcontrol_new rx_macro_snd_controls[] = {
 	SOC_SINGLE_EXT("RX_COMP2 Switch", SND_SOC_NOPM, RX_MACRO_COMP2, 1, 0,
 		rx_macro_get_compander, rx_macro_set_compander),
 
+	SOC_ENUM_EXT("RX_Native", rx_macro_native_enum, rx_macro_get_native,
+		rx_macro_put_native),
+
 	SOC_SINGLE_SX_TLV("IIR0 INP0 Volume",
 		BOLERO_CDC_RX_SIDETONE_IIR0_IIR_GAIN_B1_CTL, 0, -84, 40,
 		digital_gain),