Browse Source

Merge "ASoC: msm: use snd event fwk for ssr on auto platform"

qctecmdr 5 years ago
parent
commit
b922f017c8
8 changed files with 106 additions and 62 deletions
  1. 1 4
      Android.mk
  2. 78 54
      asoc/sa8155.c
  3. 1 0
      config/gvmauto.conf
  4. 1 0
      config/gvmautoconf.h
  5. 1 0
      config/sa8155auto.conf
  6. 1 0
      config/sa8155autoconf.h
  7. 9 1
      soc/Android.mk
  8. 14 3
      soc/Kbuild

+ 1 - 4
Android.mk

@@ -17,6 +17,7 @@ include $(MY_LOCAL_PATH)/include/uapi/Android.mk
 include $(MY_LOCAL_PATH)/ipc/Android.mk
 include $(MY_LOCAL_PATH)/dsp/Android.mk
 include $(MY_LOCAL_PATH)/dsp/codecs/Android.mk
+include $(MY_LOCAL_PATH)/soc/Android.mk
 include $(MY_LOCAL_PATH)/asoc/Android.mk
 include $(MY_LOCAL_PATH)/asoc/codecs/Android.mk
 endif
@@ -30,10 +31,6 @@ include $(MY_LOCAL_PATH)/soc/Android.mk
 endif
 endif
 
-ifneq ($(TARGET_PRODUCT), $(filter $(TARGET_PRODUCT), msmnile_au msmnile_gvmq))
-include $(MY_LOCAL_PATH)/soc/Android.mk
-endif
-
 ifeq ($(call is-board-platform-in-list,msmnile),true)
 ifneq ($(TARGET_PRODUCT), $(filter $(TARGET_PRODUCT), msmnile_au msmnile_gvmq))
 $(shell rm -rf $(PRODUCT_OUT)/obj/vendor/qcom/opensource/audio-kernel/asoc/codecs/aqt1000/Module.symvers)

+ 78 - 54
asoc/sa8155.c

@@ -45,6 +45,7 @@
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
 #include <sound/info.h>
+#include <soc/snd_event.h>
 #include <dsp/audio_notifier.h>
 #include <dsp/q6afe-v2.h>
 #include <dsp/q6core.h>
@@ -693,9 +694,6 @@ static SOC_ENUM_SINGLE_EXT_DECL(mi2s_tx_format, bit_format_text);
 static SOC_ENUM_SINGLE_EXT_DECL(aux_pcm_rx_format, bit_format_text);
 static SOC_ENUM_SINGLE_EXT_DECL(aux_pcm_tx_format, bit_format_text);
 
-static bool is_initial_boot = true;
-static struct platform_device *spdev;
-
 static struct afe_clk_set mi2s_clk[MI2S_MAX] = {
 	{
 		AFE_API_VERSION_I2S_CONFIG,
@@ -7298,6 +7296,78 @@ static void msm_i2s_auxpcm_deinit(struct platform_device *pdev)
 		pdata->mi2s_intf_conf[count].msm_is_mi2s_master = 0;
 	}
 }
+
+static int sa8155_ssr_enable(struct device *dev, void *data)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct snd_soc_card *card = platform_get_drvdata(pdev);
+	int ret = 0;
+
+	if (!card) {
+		dev_err(dev, "%s: card is NULL\n", __func__);
+		ret = -EINVAL;
+		goto err;
+	}
+
+	dev_dbg(dev, "%s: setting snd_card to ONLINE\n", __func__);
+	snd_soc_card_change_online_state(card, 1);
+
+err:
+	return ret;
+}
+
+static void sa8155_ssr_disable(struct device *dev, void *data)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct snd_soc_card *card = platform_get_drvdata(pdev);
+
+	if (!card) {
+		dev_err(dev, "%s: card is NULL\n", __func__);
+		return;
+	}
+
+	dev_dbg(dev, "%s: setting snd_card to OFFLINE\n", __func__);
+	snd_soc_card_change_online_state(card, 0);
+}
+
+static const struct snd_event_ops sa8155_ssr_ops = {
+	.enable = sa8155_ssr_enable,
+	.disable = sa8155_ssr_disable,
+};
+
+static int msm_audio_ssr_compare(struct device *dev, void *data)
+{
+	struct device_node *node = data;
+
+	dev_dbg(dev, "%s: dev->of_node = 0x%p, node = 0x%p\n",
+		__func__, dev->of_node, node);
+	return (dev->of_node && dev->of_node == node);
+}
+
+static int msm_audio_ssr_register(struct device *dev)
+{
+	struct device_node *np = dev->of_node;
+	struct snd_event_clients *ssr_clients = NULL;
+	struct device_node *node;
+	int ret;
+	int i;
+
+	for (i = 0; ; i++) {
+		node = of_parse_phandle(np, "qcom,msm_audio_ssr_devs", i);
+		if (!node)
+			break;
+		snd_event_mstr_add_client(&ssr_clients,
+					msm_audio_ssr_compare, node);
+	}
+
+	ret = snd_event_master_register(dev, &sa8155_ssr_ops,
+					ssr_clients, NULL);
+	if (!ret)
+		snd_event_notify(dev, SND_EVENT_UP);
+
+	return ret;
+}
+
 static int msm_asoc_machine_probe(struct platform_device *pdev)
 {
 	struct snd_soc_card *card;
@@ -7364,7 +7434,6 @@ static int msm_asoc_machine_probe(struct platform_device *pdev)
 		goto err;
 	}
 	dev_info(&pdev->dev, "Sound card %s registered\n", card->name);
-	spdev = pdev;
 
 	/* Parse pinctrl info from devicetree */
 	ret = msm_get_pinctrl(pdev);
@@ -7379,6 +7448,11 @@ static int msm_asoc_machine_probe(struct platform_device *pdev)
 
 	msm_i2s_auxpcm_init(pdev);
 
+	ret = msm_audio_ssr_register(&pdev->dev);
+	if (ret)
+		pr_err("%s: Registration with SND event FWK failed ret = %d\n",
+			__func__, ret);
+
 	return 0;
 err:
 	msm_release_pinctrl(pdev);
@@ -7407,58 +7481,9 @@ static struct platform_driver sa8155_asoc_machine_driver = {
 	.remove = msm_asoc_machine_remove,
 };
 
-static int sa8155_notifier_service_cb(struct notifier_block *this,
-					 unsigned long opcode, void *ptr)
-{
-	struct snd_soc_card *card = NULL;
-
-	pr_debug("%s: Service opcode 0x%lx\n", __func__, opcode);
-
-	switch (opcode) {
-	case AUDIO_NOTIFIER_SERVICE_DOWN:
-		if (!spdev)
-			return -EINVAL;
-		card = platform_get_drvdata(spdev);
-		if (card == NULL){
-			pr_err("%s: card is NULL\n",__func__);
-			return -EINVAL;
-		} else {
-			pr_debug("%s: setting snd_card to OFFLINE\n", __func__);
-			snd_soc_card_change_online_state(card, 0);
-		}
-		break;
-	case AUDIO_NOTIFIER_SERVICE_UP:
-		if (is_initial_boot) {
-			is_initial_boot = false;
-			break;
-		}
-		if (!spdev)
-			return -EINVAL;
-		card = platform_get_drvdata(spdev);
-		if (card == NULL){
-			pr_err("%s: card is NULL\n",__func__);
-			return -EINVAL;
-		} else {
-			pr_debug("%s: setting snd_card to ONLINE\n", __func__);
-			snd_soc_card_change_online_state(card, 1);
-		}
-		break;
-	default:
-		break;
-	}
-	return NOTIFY_OK;
-}
-
-static struct notifier_block service_nb = {
-	.notifier_call  = sa8155_notifier_service_cb,
-	.priority = -INT_MAX,
-};
-
 int __init sa8155_init(void)
 {
 	pr_debug("%s\n", __func__);
-	audio_notifier_register("sa8155", AUDIO_NOTIFIER_ADSP_DOMAIN,
-				      &service_nb);
 	return platform_driver_register(&sa8155_asoc_machine_driver);
 }
 
@@ -7466,7 +7491,6 @@ void sa8155_exit(void)
 {
 	pr_debug("%s\n", __func__);
 	platform_driver_unregister(&sa8155_asoc_machine_driver);
-	audio_notifier_deregister("sa8155");
 }
 
 module_init(sa8155_init);

+ 1 - 0
config/gvmauto.conf

@@ -12,3 +12,4 @@ CONFIG_DOLBY_LICENSE=m
 CONFIG_SND_SOC_MSM_STUB=m
 CONFIG_SND_SOC_MSM_HDMI_CODEC_RX=m
 CONFIG_MSM_QDSP6V2_CODECS=m
+CONFIG_SND_EVENT=m

+ 1 - 0
config/gvmautoconf.h

@@ -24,3 +24,4 @@
 #define CONFIG_SND_SOC_MSM_STUB 1
 #define CONFIG_SND_SOC_MSM_HDMI_CODEC_RX 1
 #define CONFIG_MSM_QDSP6V2_CODECS 1
+#define CONFIG_SND_EVENT 1

+ 1 - 0
config/sa8155auto.conf

@@ -12,3 +12,4 @@ CONFIG_DOLBY_LICENSE=m
 CONFIG_SND_SOC_MSM_STUB=m
 CONFIG_SND_SOC_MSM_HDMI_CODEC_RX=m
 CONFIG_MSM_QDSP6V2_CODECS=m
+CONFIG_SND_EVENT=m

+ 1 - 0
config/sa8155autoconf.h

@@ -16,3 +16,4 @@
 #define CONFIG_SND_SOC_MSM_STUB 1
 #define CONFIG_SND_SOC_MSM_HDMI_CODEC_RX 1
 #define CONFIG_MSM_QDSP6V2_CODECS 1
+#define CONFIG_SND_EVENT 1

+ 9 - 1
soc/Android.mk

@@ -4,8 +4,12 @@
 
 # Check if this driver needs be built for current target
 ifeq ($(call is-board-platform,msmnile),true)
+ifeq ($(TARGET_PRODUCT), $(filter $(TARGET_PRODUCT), msmnile_au msmnile_gvmq))
+AUDIO_SELECT  := CONFIG_SND_SOC_SA8155=m
+else
 AUDIO_SELECT  := CONFIG_SND_SOC_SM8150=m
 endif
+endif
 
 ifeq ($(call is-board-platform-in-list,$(MSMSTEPPE) $(TRINKET)),true)
 AUDIO_SELECT  := CONFIG_SND_SOC_SM6150=m
@@ -68,6 +72,7 @@ LOCAL_MODULE_PATH         := $(KERNEL_MODULES_OUT)
 include $(DLKM_DIR)/AndroidKernelModule.mk
 endif
 ###########################################################
+ifneq ($(TARGET_PRODUCT), $(filter $(TARGET_PRODUCT), msmnile_au msmnile_gvmq))
 include $(CLEAR_VARS)
 LOCAL_MODULE              := $(AUDIO_CHIPSET)_swr.ko
 LOCAL_MODULE_KBUILD_NAME  := swr_dlkm.ko
@@ -83,8 +88,10 @@ LOCAL_MODULE_TAGS         := optional
 LOCAL_MODULE_DEBUG_ENABLE := true
 LOCAL_MODULE_PATH         := $(KERNEL_MODULES_OUT)
 include $(DLKM_DIR)/AndroidKernelModule.mk
+endif
 ###########################################################
-ifeq ($(call is-board-platform-in-list, $(MSMSTEPPE) kona lito),true)
+ifeq ($(call is-board-platform-in-list,msmnile $(MSMSTEPPE) kona lito),true)
+ifneq ($(TARGET_PRODUCT), $(filter $(TARGET_PRODUCT), msmnile))
 include $(CLEAR_VARS)
 LOCAL_MODULE              := $(AUDIO_CHIPSET)_snd_event.ko
 LOCAL_MODULE_KBUILD_NAME  := snd_event_dlkm.ko
@@ -93,6 +100,7 @@ LOCAL_MODULE_DEBUG_ENABLE := true
 LOCAL_MODULE_PATH         := $(KERNEL_MODULES_OUT)
 include $(DLKM_DIR)/AndroidKernelModule.mk
 endif
+endif
 ###########################################################
 
 endif # DLKM check

+ 14 - 3
soc/Kbuild

@@ -15,9 +15,15 @@ endif
 
 ifeq ($(KERNEL_BUILD), 0)
 	ifeq ($(CONFIG_ARCH_SM8150), y)
-		include $(AUDIO_ROOT)/config/sm8150auto.conf
-		export
-		INCS    +=  -include $(AUDIO_ROOT)/config/sm8150autoconf.h
+		ifdef CONFIG_SND_SOC_SA8155
+			include $(AUDIO_ROOT)/config/sa8155auto.conf
+			export
+			INCS    +=  -include $(AUDIO_ROOT)/config/sa8155autoconf.h
+		else
+			include $(AUDIO_ROOT)/config/sm8150auto.conf
+			export
+			INCS    +=  -include $(AUDIO_ROOT)/config/sm8150autoconf.h
+		endif
 	endif
 	ifeq ($(CONFIG_ARCH_KONA), y)
 		include $(AUDIO_ROOT)/config/konaauto.conf
@@ -48,6 +54,11 @@ ifeq ($(KERNEL_BUILD), 0)
 		export
 		INCS    +=  -include $(AUDIO_ROOT)/config/qcs405autoconf.h
 	endif
+	ifeq ($(CONFIG_QTI_GVM), y)
+		include $(AUDIO_ROOT)/config/gvmauto.conf
+		export
+		INCS    +=  -include $(AUDIO_ROOT)/config/gvmautoconf.h
+	endif
 endif
 
 # As per target team, build is done as follows: