Skip to content

Commit cf536e2

Browse files
nfrapradobroonie
authored andcommitted
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: AngeloGioacchino Del Regno <[email protected]> Signed-off-by: Nícolas F. R. A. Prado <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 3fec903 commit cf536e2

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

sound/soc/mediatek/common/mtk-soc-card.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ struct mtk_soc_card_data {
1616
const struct mtk_sof_priv *sof_priv;
1717
struct list_head sof_dai_link_list;
1818
struct mtk_platform_card_data *card_data;
19+
struct snd_soc_component *accdet;
1920
void *mach_priv;
2021
};
2122

sound/soc/mediatek/common/mtk-soundcard-driver.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <linux/module.h>
1010
#include <linux/of.h>
11+
#include <linux/of_platform.h>
1112
#include <sound/soc.h>
1213

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

193194
int mtk_soundcard_common_probe(struct platform_device *pdev)
194195
{
195-
struct device_node *platform_node, *adsp_node;
196+
struct device_node *platform_node, *adsp_node, *accdet_node;
197+
struct snd_soc_component *accdet_comp;
198+
struct platform_device *accdet_pdev;
196199
const struct mtk_soundcard_pdata *pdata;
197200
struct mtk_soc_card_data *soc_card_data;
198201
struct snd_soc_dai_link *orig_dai_link, *dai_link;
@@ -250,6 +253,20 @@ int mtk_soundcard_common_probe(struct platform_device *pdev)
250253

251254
soc_card_data->card_data->jacks = jacks;
252255

256+
accdet_node = of_parse_phandle(pdev->dev.of_node, "mediatek,accdet", 0);
257+
if (accdet_node) {
258+
accdet_pdev = of_find_device_by_node(accdet_node);
259+
if (accdet_pdev) {
260+
accdet_comp = snd_soc_lookup_component(&accdet_pdev->dev, NULL);
261+
if (accdet_comp)
262+
soc_card_data->accdet = accdet_comp;
263+
else
264+
dev_err(&pdev->dev, "No sound component found from mediatek,accdet property\n");
265+
} else {
266+
dev_err(&pdev->dev, "No device found from mediatek,accdet property\n");
267+
}
268+
}
269+
253270
platform_node = of_parse_phandle(pdev->dev.of_node, "mediatek,platform", 0);
254271
if (!platform_node)
255272
return dev_err_probe(&pdev->dev, -EINVAL,

0 commit comments

Comments
 (0)