Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 //
0003 // mt8186-mt6366-common.c
0004 //  --  MT8186 MT6366 ALSA common driver
0005 //
0006 // Copyright (c) 2022 MediaTek Inc.
0007 // Author: Jiaxin Yu <jiaxin.yu@mediatek.com>
0008 //
0009 #include <sound/soc.h>
0010 
0011 #include "../../codecs/mt6358.h"
0012 #include "../common/mtk-afe-platform-driver.h"
0013 #include "mt8186-afe-common.h"
0014 #include "mt8186-mt6366-common.h"
0015 
0016 int mt8186_mt6366_init(struct snd_soc_pcm_runtime *rtd)
0017 {
0018     struct snd_soc_component *cmpnt_afe =
0019         snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
0020     struct snd_soc_component *cmpnt_codec =
0021         asoc_rtd_to_codec(rtd, 0)->component;
0022     struct mtk_base_afe *afe = snd_soc_component_get_drvdata(cmpnt_afe);
0023     struct mt8186_afe_private *afe_priv = afe->platform_priv;
0024     struct snd_soc_dapm_context *dapm = &rtd->card->dapm;
0025     int ret;
0026 
0027     /* set mtkaif protocol */
0028     mt6358_set_mtkaif_protocol(cmpnt_codec,
0029                    MT6358_MTKAIF_PROTOCOL_1);
0030     afe_priv->mtkaif_protocol = MT6358_MTKAIF_PROTOCOL_1;
0031 
0032     ret = snd_soc_dapm_sync(dapm);
0033     if (ret) {
0034         dev_err(rtd->dev, "failed to snd_soc_dapm_sync\n");
0035         return ret;
0036     }
0037 
0038     return 0;
0039 }
0040 EXPORT_SYMBOL_GPL(mt8186_mt6366_init);
0041 
0042 int mt8186_mt6366_card_set_be_link(struct snd_soc_card *card,
0043                    struct snd_soc_dai_link *link,
0044                    struct device_node *node,
0045                    char *link_name)
0046 {
0047     int ret;
0048 
0049     if (node && strcmp(link->name, link_name) == 0) {
0050         ret = snd_soc_of_get_dai_link_codecs(card->dev, node, link);
0051         if (ret < 0)
0052             return dev_err_probe(card->dev, ret, "get dai link codecs fail\n");
0053     }
0054 
0055     return 0;
0056 }
0057 EXPORT_SYMBOL_GPL(mt8186_mt6366_card_set_be_link);