Unverified Commit cf536e26 authored by Nícolas F. R. A. Prado's avatar Nícolas F. R. A. Prado Committed by Mark Brown
Browse files

ASoC: mediatek: common: Handle mediatek,accdet property



Handle the optional mediatek,accdet property. When present, retrieve the
sound component from its phandle, so the machine sound driver can use it
to register the audio jack and initialize the MT6359 ACCDET for jack
detection.

Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: default avatarNícolas F. R. A. Prado <nfraprado@collabora.com>
Link: https://patch.msgid.link/20250306-mt8188-accdet-v3-2-7828e835ff4b@collabora.com


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 3fec903f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ struct mtk_soc_card_data {
	const struct mtk_sof_priv *sof_priv;
	struct list_head sof_dai_link_list;
	struct mtk_platform_card_data *card_data;
	struct snd_soc_component *accdet;
	void *mach_priv;
};

+18 −1
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@

#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_platform.h>
#include <sound/soc.h>

#include "mtk-dsp-sof-common.h"
@@ -192,7 +193,9 @@ EXPORT_SYMBOL_GPL(mtk_soundcard_common_capture_ops);

int mtk_soundcard_common_probe(struct platform_device *pdev)
{
	struct device_node *platform_node, *adsp_node;
	struct device_node *platform_node, *adsp_node, *accdet_node;
	struct snd_soc_component *accdet_comp;
	struct platform_device *accdet_pdev;
	const struct mtk_soundcard_pdata *pdata;
	struct mtk_soc_card_data *soc_card_data;
	struct snd_soc_dai_link *orig_dai_link, *dai_link;
@@ -250,6 +253,20 @@ int mtk_soundcard_common_probe(struct platform_device *pdev)

	soc_card_data->card_data->jacks = jacks;

	accdet_node = of_parse_phandle(pdev->dev.of_node, "mediatek,accdet", 0);
	if (accdet_node) {
		accdet_pdev = of_find_device_by_node(accdet_node);
		if (accdet_pdev) {
			accdet_comp = snd_soc_lookup_component(&accdet_pdev->dev, NULL);
			if (accdet_comp)
				soc_card_data->accdet = accdet_comp;
			else
				dev_err(&pdev->dev, "No sound component found from mediatek,accdet property\n");
		} else {
			dev_err(&pdev->dev, "No device found from mediatek,accdet property\n");
		}
	}

	platform_node = of_parse_phandle(pdev->dev.of_node, "mediatek,platform", 0);
	if (!platform_node)
		return dev_err_probe(&pdev->dev, -EINVAL,