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

Commit 98d38379 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "ASoC: msm: add machine drv as apr child node"

parents 7016b69a 609be450
Loading
Loading
Loading
Loading
+25 −26
Original line number Diff line number Diff line
@@ -691,6 +691,7 @@ 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] = {
	{
@@ -7183,6 +7184,7 @@ 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);
@@ -7223,48 +7225,45 @@ static struct platform_driver sa8155_asoc_machine_driver = {
	.remove = msm_asoc_machine_remove,
};

static int dummy_asoc_machine_probe(struct platform_device *pdev)
{
	return 0;
}

static int dummy_asoc_machine_remove(struct platform_device *pdev)
{
	return 0;
}

static struct platform_device sa8155_dummy_asoc_machine_device = {
	.name = "sa8155-asoc-snd-dummy",
};

static struct platform_driver sa8155_dummy_asoc_machine_driver = {
	.driver = {
		.name = "sa8155-asoc-snd-dummy",
		.owner = THIS_MODULE,
	},
	.probe = dummy_asoc_machine_probe,
	.remove = dummy_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) {
			platform_driver_register(&sa8155_dummy_asoc_machine_driver);
			platform_device_register(&sa8155_dummy_asoc_machine_device);
			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;
}