Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c8940293 authored by Derek Chen's avatar Derek Chen
Browse files

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



Switch to use SND event FWK for SSR handling
instead of audio notifier on automotive platform.

Change-Id: I8d0b1ac8f09417a8b33a8e8141f7ae06e1195f54
Signed-off-by: default avatarDerek Chen <chenche@codeaurora.org>
parent f53de7f9
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -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
Original line number Diff line number Diff line
@@ -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
Original line number Diff line number Diff line
@@ -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
Original line number Diff line number Diff line
@@ -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
Original line number Diff line number Diff line
@@ -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
Loading