mirror of
https://github.com/torvalds/linux.git
synced 2025-01-01 15:51:46 +00:00
Merge remote-tracking branches 'asoc/topic/mediatek', 'asoc/topic/ml26124' and 'asoc/topic/omap' into asoc-next
This commit is contained in:
commit
861fe71725
13
Documentation/devicetree/bindings/sound/mt8173-max98090.txt
Normal file
13
Documentation/devicetree/bindings/sound/mt8173-max98090.txt
Normal file
@ -0,0 +1,13 @@
|
||||
MT8173 with MAX98090 CODEC
|
||||
|
||||
Required properties:
|
||||
- compatible : "mediatek,mt8173-max98090"
|
||||
- mediatek,audio-codec: the phandle of the MAX98090 audio codec
|
||||
|
||||
Example:
|
||||
|
||||
sound {
|
||||
compatible = "mediatek,mt8173-max98090";
|
||||
mediatek,audio-codec = <&max98090>;
|
||||
};
|
||||
|
@ -0,0 +1,13 @@
|
||||
MT8173 with RT5650 RT5676 CODECS
|
||||
|
||||
Required properties:
|
||||
- compatible : "mediatek,mt8173-rt5650-rt5676"
|
||||
- mediatek,audio-codec: the phandles of rt5650 and rt5676 codecs
|
||||
|
||||
Example:
|
||||
|
||||
sound {
|
||||
compatible = "mediatek,mt8173-rt5650-rt5676";
|
||||
mediatek,audio-codec = <&rt5650 &rt5676>;
|
||||
};
|
||||
|
45
Documentation/devicetree/bindings/sound/mtk-afe-pcm.txt
Normal file
45
Documentation/devicetree/bindings/sound/mtk-afe-pcm.txt
Normal file
@ -0,0 +1,45 @@
|
||||
Mediatek AFE PCM controller
|
||||
|
||||
Required properties:
|
||||
- compatible = "mediatek,mt8173-afe-pcm";
|
||||
- reg: register location and size
|
||||
- interrupts: Should contain AFE interrupt
|
||||
- clock-names: should have these clock names:
|
||||
"infra_sys_audio_clk",
|
||||
"top_pdn_audio",
|
||||
"top_pdn_aud_intbus",
|
||||
"bck0",
|
||||
"bck1",
|
||||
"i2s0_m",
|
||||
"i2s1_m",
|
||||
"i2s2_m",
|
||||
"i2s3_m",
|
||||
"i2s3_b";
|
||||
|
||||
Example:
|
||||
|
||||
afe: mt8173-afe-pcm@11220000 {
|
||||
compatible = "mediatek,mt8173-afe-pcm";
|
||||
reg = <0 0x11220000 0 0x1000>;
|
||||
interrupts = <GIC_SPI 134 IRQ_TYPE_EDGE_FALLING>;
|
||||
clocks = <&infracfg INFRA_AUDIO>,
|
||||
<&topckgen TOP_AUDIO_SEL>,
|
||||
<&topckgen TOP_AUD_INTBUS_SEL>,
|
||||
<&topckgen TOP_APLL1_DIV0>,
|
||||
<&topckgen TOP_APLL2_DIV0>,
|
||||
<&topckgen TOP_I2S0_M_CK_SEL>,
|
||||
<&topckgen TOP_I2S1_M_CK_SEL>,
|
||||
<&topckgen TOP_I2S2_M_CK_SEL>,
|
||||
<&topckgen TOP_I2S3_M_CK_SEL>,
|
||||
<&topckgen TOP_I2S3_B_CK_SEL>;
|
||||
clock-names = "infra_sys_audio_clk",
|
||||
"top_pdn_audio",
|
||||
"top_pdn_aud_intbus",
|
||||
"bck0",
|
||||
"bck1",
|
||||
"i2s0_m",
|
||||
"i2s1_m",
|
||||
"i2s2_m",
|
||||
"i2s3_m",
|
||||
"i2s3_b";
|
||||
};
|
@ -45,6 +45,7 @@ source "sound/soc/nuc900/Kconfig"
|
||||
source "sound/soc/omap/Kconfig"
|
||||
source "sound/soc/kirkwood/Kconfig"
|
||||
source "sound/soc/intel/Kconfig"
|
||||
source "sound/soc/mediatek/Kconfig"
|
||||
source "sound/soc/mxs/Kconfig"
|
||||
source "sound/soc/pxa/Kconfig"
|
||||
source "sound/soc/qcom/Kconfig"
|
||||
|
@ -24,6 +24,7 @@ obj-$(CONFIG_SND_SOC) += dwc/
|
||||
obj-$(CONFIG_SND_SOC) += fsl/
|
||||
obj-$(CONFIG_SND_SOC) += jz4740/
|
||||
obj-$(CONFIG_SND_SOC) += intel/
|
||||
obj-$(CONFIG_SND_SOC) += mediatek/
|
||||
obj-$(CONFIG_SND_SOC) += mxs/
|
||||
obj-$(CONFIG_SND_SOC) += nuc900/
|
||||
obj-$(CONFIG_SND_SOC) += omap/
|
||||
|
@ -341,6 +341,7 @@ static int ml26124_hw_params(struct snd_pcm_substream *substream,
|
||||
struct snd_soc_codec *codec = dai->codec;
|
||||
struct ml26124_priv *priv = snd_soc_codec_get_drvdata(codec);
|
||||
int i = get_coeff(priv->mclk, params_rate(hw_params));
|
||||
int srate;
|
||||
|
||||
if (i < 0)
|
||||
return i;
|
||||
@ -370,53 +371,16 @@ static int ml26124_hw_params(struct snd_pcm_substream *substream,
|
||||
BIT(0) | BIT(1), 0);
|
||||
}
|
||||
|
||||
switch (params_rate(hw_params)) {
|
||||
case 16000:
|
||||
snd_soc_update_bits(codec, ML26124_SMPLING_RATE, 0xf,
|
||||
get_srate(params_rate(hw_params)));
|
||||
snd_soc_update_bits(codec, ML26124_PLLNL, 0xff,
|
||||
coeff_div[i].pllnl);
|
||||
snd_soc_update_bits(codec, ML26124_PLLNH, 0x1,
|
||||
coeff_div[i].pllnh);
|
||||
snd_soc_update_bits(codec, ML26124_PLLML, 0xff,
|
||||
coeff_div[i].pllml);
|
||||
snd_soc_update_bits(codec, ML26124_PLLMH, 0x3f,
|
||||
coeff_div[i].pllmh);
|
||||
snd_soc_update_bits(codec, ML26124_PLLDIV, 0x1f,
|
||||
coeff_div[i].plldiv);
|
||||
break;
|
||||
case 32000:
|
||||
snd_soc_update_bits(codec, ML26124_SMPLING_RATE, 0xf,
|
||||
get_srate(params_rate(hw_params)));
|
||||
snd_soc_update_bits(codec, ML26124_PLLNL, 0xff,
|
||||
coeff_div[i].pllnl);
|
||||
snd_soc_update_bits(codec, ML26124_PLLNH, 0x1,
|
||||
coeff_div[i].pllnh);
|
||||
snd_soc_update_bits(codec, ML26124_PLLML, 0xff,
|
||||
coeff_div[i].pllml);
|
||||
snd_soc_update_bits(codec, ML26124_PLLMH, 0x3f,
|
||||
coeff_div[i].pllmh);
|
||||
snd_soc_update_bits(codec, ML26124_PLLDIV, 0x1f,
|
||||
coeff_div[i].plldiv);
|
||||
break;
|
||||
case 48000:
|
||||
snd_soc_update_bits(codec, ML26124_SMPLING_RATE, 0xf,
|
||||
get_srate(params_rate(hw_params)));
|
||||
snd_soc_update_bits(codec, ML26124_PLLNL, 0xff,
|
||||
coeff_div[i].pllnl);
|
||||
snd_soc_update_bits(codec, ML26124_PLLNH, 0x1,
|
||||
coeff_div[i].pllnh);
|
||||
snd_soc_update_bits(codec, ML26124_PLLML, 0xff,
|
||||
coeff_div[i].pllml);
|
||||
snd_soc_update_bits(codec, ML26124_PLLMH, 0x3f,
|
||||
coeff_div[i].pllmh);
|
||||
snd_soc_update_bits(codec, ML26124_PLLDIV, 0x1f,
|
||||
coeff_div[i].plldiv);
|
||||
break;
|
||||
default:
|
||||
pr_err("%s:this rate is no support for ml26124\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
srate = get_srate(params_rate(hw_params));
|
||||
if (srate < 0)
|
||||
return srate;
|
||||
|
||||
snd_soc_update_bits(codec, ML26124_SMPLING_RATE, 0xf, srate);
|
||||
snd_soc_update_bits(codec, ML26124_PLLNL, 0xff, coeff_div[i].pllnl);
|
||||
snd_soc_update_bits(codec, ML26124_PLLNH, 0x1, coeff_div[i].pllnh);
|
||||
snd_soc_update_bits(codec, ML26124_PLLML, 0xff, coeff_div[i].pllml);
|
||||
snd_soc_update_bits(codec, ML26124_PLLMH, 0x3f, coeff_div[i].pllmh);
|
||||
snd_soc_update_bits(codec, ML26124_PLLDIV, 0x1f, coeff_div[i].plldiv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
30
sound/soc/mediatek/Kconfig
Normal file
30
sound/soc/mediatek/Kconfig
Normal file
@ -0,0 +1,30 @@
|
||||
config SND_SOC_MEDIATEK
|
||||
tristate "ASoC support for Mediatek chip"
|
||||
depends on ARCH_MEDIATEK
|
||||
help
|
||||
This adds ASoC platform driver support for Mediatek chip
|
||||
that can be used with other codecs.
|
||||
Select Y if you have such device.
|
||||
Ex: MT8173
|
||||
|
||||
config SND_SOC_MT8173_MAX98090
|
||||
tristate "ASoC Audio driver for MT8173 with MAX98090 codec"
|
||||
depends on SND_SOC_MEDIATEK
|
||||
select SND_SOC_MAX98090
|
||||
help
|
||||
This adds ASoC driver for Mediatek MT8173 boards
|
||||
with the MAX98090 audio codec.
|
||||
Select Y if you have such device.
|
||||
If unsure select "N".
|
||||
|
||||
config SND_SOC_MT8173_RT5650_RT5676
|
||||
tristate "ASoC Audio driver for MT8173 with RT5650 RT5676 codecs"
|
||||
depends on SND_SOC_MEDIATEK
|
||||
select SND_SOC_RT5645
|
||||
select SND_SOC_RT5677
|
||||
help
|
||||
This adds ASoC driver for Mediatek MT8173 boards
|
||||
with the RT5650 and RT5676 codecs.
|
||||
Select Y if you have such device.
|
||||
If unsure select "N".
|
||||
|
5
sound/soc/mediatek/Makefile
Normal file
5
sound/soc/mediatek/Makefile
Normal file
@ -0,0 +1,5 @@
|
||||
# MTK Platform Support
|
||||
obj-$(CONFIG_SND_SOC_MEDIATEK) += mtk-afe-pcm.o
|
||||
# Machine support
|
||||
obj-$(CONFIG_SND_SOC_MT8173_MAX98090) += mt8173-max98090.o
|
||||
obj-$(CONFIG_SND_SOC_MT8173_RT5650_RT5676) += mt8173-rt5650-rt5676.o
|
213
sound/soc/mediatek/mt8173-max98090.c
Normal file
213
sound/soc/mediatek/mt8173-max98090.c
Normal file
@ -0,0 +1,213 @@
|
||||
/*
|
||||
* mt8173-max98090.c -- MT8173 MAX98090 ALSA SoC machine driver
|
||||
*
|
||||
* Copyright (c) 2015 MediaTek Inc.
|
||||
* Author: Koro Chen <koro.chen@mediatek.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 and
|
||||
* only version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <sound/soc.h>
|
||||
#include <sound/jack.h>
|
||||
#include <linux/gpio.h>
|
||||
#include "../codecs/max98090.h"
|
||||
|
||||
static struct snd_soc_jack mt8173_max98090_jack;
|
||||
|
||||
static struct snd_soc_jack_pin mt8173_max98090_jack_pins[] = {
|
||||
{
|
||||
.pin = "Headphone",
|
||||
.mask = SND_JACK_HEADPHONE,
|
||||
},
|
||||
{
|
||||
.pin = "Headset Mic",
|
||||
.mask = SND_JACK_MICROPHONE,
|
||||
},
|
||||
};
|
||||
|
||||
static const struct snd_soc_dapm_widget mt8173_max98090_widgets[] = {
|
||||
SND_SOC_DAPM_SPK("Speaker", NULL),
|
||||
SND_SOC_DAPM_MIC("Int Mic", NULL),
|
||||
SND_SOC_DAPM_HP("Headphone", NULL),
|
||||
SND_SOC_DAPM_MIC("Headset Mic", NULL),
|
||||
};
|
||||
|
||||
static const struct snd_soc_dapm_route mt8173_max98090_routes[] = {
|
||||
{"Speaker", NULL, "SPKL"},
|
||||
{"Speaker", NULL, "SPKR"},
|
||||
{"DMICL", NULL, "Int Mic"},
|
||||
{"Headphone", NULL, "HPL"},
|
||||
{"Headphone", NULL, "HPR"},
|
||||
{"Headset Mic", NULL, "MICBIAS"},
|
||||
{"IN34", NULL, "Headset Mic"},
|
||||
};
|
||||
|
||||
static const struct snd_kcontrol_new mt8173_max98090_controls[] = {
|
||||
SOC_DAPM_PIN_SWITCH("Speaker"),
|
||||
SOC_DAPM_PIN_SWITCH("Int Mic"),
|
||||
SOC_DAPM_PIN_SWITCH("Headphone"),
|
||||
SOC_DAPM_PIN_SWITCH("Headset Mic"),
|
||||
};
|
||||
|
||||
static int mt8173_max98090_hw_params(struct snd_pcm_substream *substream,
|
||||
struct snd_pcm_hw_params *params)
|
||||
{
|
||||
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
||||
struct snd_soc_dai *codec_dai = rtd->codec_dai;
|
||||
|
||||
return snd_soc_dai_set_sysclk(codec_dai, 0, params_rate(params) * 256,
|
||||
SND_SOC_CLOCK_IN);
|
||||
}
|
||||
|
||||
static struct snd_soc_ops mt8173_max98090_ops = {
|
||||
.hw_params = mt8173_max98090_hw_params,
|
||||
};
|
||||
|
||||
static int mt8173_max98090_init(struct snd_soc_pcm_runtime *runtime)
|
||||
{
|
||||
int ret;
|
||||
struct snd_soc_card *card = runtime->card;
|
||||
struct snd_soc_codec *codec = runtime->codec;
|
||||
|
||||
/* enable jack detection */
|
||||
ret = snd_soc_card_jack_new(card, "Headphone", SND_JACK_HEADPHONE,
|
||||
&mt8173_max98090_jack, NULL, 0);
|
||||
if (ret) {
|
||||
dev_err(card->dev, "Can't snd_soc_jack_new %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = snd_soc_jack_add_pins(&mt8173_max98090_jack,
|
||||
ARRAY_SIZE(mt8173_max98090_jack_pins),
|
||||
mt8173_max98090_jack_pins);
|
||||
if (ret) {
|
||||
dev_err(card->dev, "Can't snd_soc_jack_add_pins %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return max98090_mic_detect(codec, &mt8173_max98090_jack);
|
||||
}
|
||||
|
||||
/* Digital audio interface glue - connects codec <---> CPU */
|
||||
static struct snd_soc_dai_link mt8173_max98090_dais[] = {
|
||||
/* Front End DAI links */
|
||||
{
|
||||
.name = "MAX98090 Playback",
|
||||
.stream_name = "MAX98090 Playback",
|
||||
.cpu_dai_name = "DL1",
|
||||
.platform_name = "11220000.mt8173-afe-pcm",
|
||||
.codec_name = "snd-soc-dummy",
|
||||
.codec_dai_name = "snd-soc-dummy-dai",
|
||||
.trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
|
||||
.dynamic = 1,
|
||||
.dpcm_playback = 1,
|
||||
},
|
||||
{
|
||||
.name = "MAX98090 Capture",
|
||||
.stream_name = "MAX98090 Capture",
|
||||
.cpu_dai_name = "VUL",
|
||||
.platform_name = "11220000.mt8173-afe-pcm",
|
||||
.codec_name = "snd-soc-dummy",
|
||||
.codec_dai_name = "snd-soc-dummy-dai",
|
||||
.trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
|
||||
.dynamic = 1,
|
||||
.dpcm_capture = 1,
|
||||
},
|
||||
/* Back End DAI links */
|
||||
{
|
||||
.name = "Codec",
|
||||
.cpu_dai_name = "I2S",
|
||||
.platform_name = "11220000.mt8173-afe-pcm",
|
||||
.no_pcm = 1,
|
||||
.codec_dai_name = "HiFi",
|
||||
.init = mt8173_max98090_init,
|
||||
.ops = &mt8173_max98090_ops,
|
||||
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
|
||||
SND_SOC_DAIFMT_CBS_CFS,
|
||||
.dpcm_playback = 1,
|
||||
.dpcm_capture = 1,
|
||||
},
|
||||
};
|
||||
|
||||
static struct snd_soc_card mt8173_max98090_card = {
|
||||
.name = "mt8173-max98090",
|
||||
.dai_link = mt8173_max98090_dais,
|
||||
.num_links = ARRAY_SIZE(mt8173_max98090_dais),
|
||||
.controls = mt8173_max98090_controls,
|
||||
.num_controls = ARRAY_SIZE(mt8173_max98090_controls),
|
||||
.dapm_widgets = mt8173_max98090_widgets,
|
||||
.num_dapm_widgets = ARRAY_SIZE(mt8173_max98090_widgets),
|
||||
.dapm_routes = mt8173_max98090_routes,
|
||||
.num_dapm_routes = ARRAY_SIZE(mt8173_max98090_routes),
|
||||
};
|
||||
|
||||
static int mt8173_max98090_dev_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct snd_soc_card *card = &mt8173_max98090_card;
|
||||
struct device_node *codec_node;
|
||||
int ret, i;
|
||||
|
||||
codec_node = of_parse_phandle(pdev->dev.of_node,
|
||||
"mediatek,audio-codec", 0);
|
||||
if (!codec_node) {
|
||||
dev_err(&pdev->dev,
|
||||
"Property 'audio-codec' missing or invalid\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
for (i = 0; i < card->num_links; i++) {
|
||||
if (mt8173_max98090_dais[i].codec_name)
|
||||
continue;
|
||||
mt8173_max98090_dais[i].codec_of_node = codec_node;
|
||||
}
|
||||
card->dev = &pdev->dev;
|
||||
|
||||
ret = snd_soc_register_card(card);
|
||||
if (ret)
|
||||
dev_err(&pdev->dev, "%s snd_soc_register_card fail %d\n",
|
||||
__func__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int mt8173_max98090_dev_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct snd_soc_card *card = platform_get_drvdata(pdev);
|
||||
|
||||
snd_soc_unregister_card(card);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct of_device_id mt8173_max98090_dt_match[] = {
|
||||
{ .compatible = "mediatek,mt8173-max98090", },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, mt8173_max98090_dt_match);
|
||||
|
||||
static struct platform_driver mt8173_max98090_driver = {
|
||||
.driver = {
|
||||
.name = "mt8173-max98090",
|
||||
.owner = THIS_MODULE,
|
||||
.of_match_table = mt8173_max98090_dt_match,
|
||||
#ifdef CONFIG_PM
|
||||
.pm = &snd_soc_pm_ops,
|
||||
#endif
|
||||
},
|
||||
.probe = mt8173_max98090_dev_probe,
|
||||
.remove = mt8173_max98090_dev_remove,
|
||||
};
|
||||
|
||||
module_platform_driver(mt8173_max98090_driver);
|
||||
|
||||
/* Module information */
|
||||
MODULE_DESCRIPTION("MT8173 MAX98090 ALSA SoC machine driver");
|
||||
MODULE_AUTHOR("Koro Chen <koro.chen@mediatek.com>");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
MODULE_ALIAS("platform:mt8173-max98090");
|
||||
|
278
sound/soc/mediatek/mt8173-rt5650-rt5676.c
Normal file
278
sound/soc/mediatek/mt8173-rt5650-rt5676.c
Normal file
@ -0,0 +1,278 @@
|
||||
/*
|
||||
* mt8173-rt5650-rt5676.c -- MT8173 machine driver with RT5650/5676 codecs
|
||||
*
|
||||
* Copyright (c) 2015 MediaTek Inc.
|
||||
* Author: Koro Chen <koro.chen@mediatek.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 and
|
||||
* only version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/of_gpio.h>
|
||||
#include <sound/soc.h>
|
||||
#include <sound/jack.h>
|
||||
#include "../codecs/rt5645.h"
|
||||
#include "../codecs/rt5677.h"
|
||||
|
||||
#define MCLK_FOR_CODECS 12288000
|
||||
|
||||
static const struct snd_soc_dapm_widget mt8173_rt5650_rt5676_widgets[] = {
|
||||
SND_SOC_DAPM_SPK("Speaker", NULL),
|
||||
SND_SOC_DAPM_MIC("Int Mic", NULL),
|
||||
SND_SOC_DAPM_HP("Headphone", NULL),
|
||||
SND_SOC_DAPM_MIC("Headset Mic", NULL),
|
||||
};
|
||||
|
||||
static const struct snd_soc_dapm_route mt8173_rt5650_rt5676_routes[] = {
|
||||
{"Speaker", NULL, "SPOL"},
|
||||
{"Speaker", NULL, "SPOR"},
|
||||
{"Speaker", NULL, "Sub AIF2TX"}, /* IF2 ADC to 5650 */
|
||||
{"Sub DMIC L1", NULL, "Int Mic"}, /* DMIC from 5676 */
|
||||
{"Sub DMIC R1", NULL, "Int Mic"},
|
||||
{"Headphone", NULL, "HPOL"},
|
||||
{"Headphone", NULL, "HPOR"},
|
||||
{"Headphone", NULL, "Sub AIF2TX"}, /* IF2 ADC to 5650 */
|
||||
{"Headset Mic", NULL, "micbias1"},
|
||||
{"Headset Mic", NULL, "micbias2"},
|
||||
{"IN1P", NULL, "Headset Mic"},
|
||||
{"IN1N", NULL, "Headset Mic"},
|
||||
{"Sub AIF2RX", NULL, "Headset Mic"}, /* IF2 DAC from 5650 */
|
||||
};
|
||||
|
||||
static const struct snd_kcontrol_new mt8173_rt5650_rt5676_controls[] = {
|
||||
SOC_DAPM_PIN_SWITCH("Speaker"),
|
||||
SOC_DAPM_PIN_SWITCH("Int Mic"),
|
||||
SOC_DAPM_PIN_SWITCH("Headphone"),
|
||||
SOC_DAPM_PIN_SWITCH("Headset Mic"),
|
||||
};
|
||||
|
||||
static int mt8173_rt5650_rt5676_hw_params(struct snd_pcm_substream *substream,
|
||||
struct snd_pcm_hw_params *params)
|
||||
{
|
||||
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
||||
int i, ret;
|
||||
|
||||
for (i = 0; i < rtd->num_codecs; i++) {
|
||||
struct snd_soc_dai *codec_dai = rtd->codec_dais[i];
|
||||
|
||||
/* pll from mclk 12.288M */
|
||||
ret = snd_soc_dai_set_pll(codec_dai, 0, 0, MCLK_FOR_CODECS,
|
||||
params_rate(params) * 512);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* sysclk from pll */
|
||||
ret = snd_soc_dai_set_sysclk(codec_dai, 1,
|
||||
params_rate(params) * 512,
|
||||
SND_SOC_CLOCK_IN);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct snd_soc_ops mt8173_rt5650_rt5676_ops = {
|
||||
.hw_params = mt8173_rt5650_rt5676_hw_params,
|
||||
};
|
||||
|
||||
static struct snd_soc_jack mt8173_rt5650_rt5676_jack;
|
||||
|
||||
static int mt8173_rt5650_rt5676_init(struct snd_soc_pcm_runtime *runtime)
|
||||
{
|
||||
struct snd_soc_card *card = runtime->card;
|
||||
struct snd_soc_codec *codec = runtime->codec_dais[0]->codec;
|
||||
struct snd_soc_codec *codec_sub = runtime->codec_dais[1]->codec;
|
||||
int ret;
|
||||
|
||||
rt5645_sel_asrc_clk_src(codec,
|
||||
RT5645_DA_STEREO_FILTER |
|
||||
RT5645_AD_STEREO_FILTER,
|
||||
RT5645_CLK_SEL_I2S1_ASRC);
|
||||
rt5677_sel_asrc_clk_src(codec_sub,
|
||||
RT5677_DA_STEREO_FILTER |
|
||||
RT5677_AD_STEREO1_FILTER,
|
||||
RT5677_CLK_SEL_I2S1_ASRC);
|
||||
rt5677_sel_asrc_clk_src(codec_sub,
|
||||
RT5677_AD_STEREO2_FILTER |
|
||||
RT5677_I2S2_SOURCE,
|
||||
RT5677_CLK_SEL_I2S2_ASRC);
|
||||
|
||||
/* enable jack detection */
|
||||
ret = snd_soc_card_jack_new(card, "Headset Jack",
|
||||
SND_JACK_HEADPHONE | SND_JACK_MICROPHONE |
|
||||
SND_JACK_BTN_0 | SND_JACK_BTN_1 |
|
||||
SND_JACK_BTN_2 | SND_JACK_BTN_3,
|
||||
&mt8173_rt5650_rt5676_jack, NULL, 0);
|
||||
if (ret) {
|
||||
dev_err(card->dev, "Can't new Headset Jack %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return rt5645_set_jack_detect(codec,
|
||||
&mt8173_rt5650_rt5676_jack,
|
||||
&mt8173_rt5650_rt5676_jack,
|
||||
&mt8173_rt5650_rt5676_jack);
|
||||
}
|
||||
|
||||
static struct snd_soc_dai_link_component mt8173_rt5650_rt5676_codecs[] = {
|
||||
{
|
||||
.dai_name = "rt5645-aif1",
|
||||
},
|
||||
{
|
||||
.dai_name = "rt5677-aif1",
|
||||
},
|
||||
};
|
||||
|
||||
/* Digital audio interface glue - connects codec <---> CPU */
|
||||
static struct snd_soc_dai_link mt8173_rt5650_rt5676_dais[] = {
|
||||
/* Front End DAI links */
|
||||
{
|
||||
.name = "rt5650_rt5676 Playback",
|
||||
.stream_name = "rt5650_rt5676 Playback",
|
||||
.cpu_dai_name = "DL1",
|
||||
.platform_name = "11220000.mt8173-afe-pcm",
|
||||
.codec_name = "snd-soc-dummy",
|
||||
.codec_dai_name = "snd-soc-dummy-dai",
|
||||
.trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
|
||||
.dynamic = 1,
|
||||
.dpcm_playback = 1,
|
||||
},
|
||||
{
|
||||
.name = "rt5650_rt5676 Capture",
|
||||
.stream_name = "rt5650_rt5676 Capture",
|
||||
.cpu_dai_name = "VUL",
|
||||
.platform_name = "11220000.mt8173-afe-pcm",
|
||||
.codec_name = "snd-soc-dummy",
|
||||
.codec_dai_name = "snd-soc-dummy-dai",
|
||||
.trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
|
||||
.dynamic = 1,
|
||||
.dpcm_capture = 1,
|
||||
},
|
||||
|
||||
/* Back End DAI links */
|
||||
{
|
||||
.name = "Codec",
|
||||
.cpu_dai_name = "I2S",
|
||||
.platform_name = "11220000.mt8173-afe-pcm",
|
||||
.no_pcm = 1,
|
||||
.codecs = mt8173_rt5650_rt5676_codecs,
|
||||
.num_codecs = 2,
|
||||
.init = mt8173_rt5650_rt5676_init,
|
||||
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
|
||||
SND_SOC_DAIFMT_CBS_CFS,
|
||||
.ops = &mt8173_rt5650_rt5676_ops,
|
||||
.ignore_pmdown_time = 1,
|
||||
.dpcm_playback = 1,
|
||||
.dpcm_capture = 1,
|
||||
},
|
||||
{ /* rt5676 <-> rt5650 intercodec link: Sets rt5676 I2S2 as master */
|
||||
.name = "rt5650_rt5676 intercodec",
|
||||
.stream_name = "rt5650_rt5676 intercodec",
|
||||
.cpu_dai_name = "snd-soc-dummy-dai",
|
||||
.platform_name = "snd-soc-dummy",
|
||||
.no_pcm = 1,
|
||||
.codec_dai_name = "rt5677-aif2",
|
||||
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
|
||||
SND_SOC_DAIFMT_CBM_CFM,
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
static struct snd_soc_codec_conf mt8173_rt5650_rt5676_codec_conf[] = {
|
||||
{
|
||||
.name_prefix = "Sub",
|
||||
},
|
||||
};
|
||||
|
||||
static struct snd_soc_card mt8173_rt5650_rt5676_card = {
|
||||
.name = "mtk-rt5650-rt5676",
|
||||
.dai_link = mt8173_rt5650_rt5676_dais,
|
||||
.num_links = ARRAY_SIZE(mt8173_rt5650_rt5676_dais),
|
||||
.codec_conf = mt8173_rt5650_rt5676_codec_conf,
|
||||
.num_configs = ARRAY_SIZE(mt8173_rt5650_rt5676_codec_conf),
|
||||
.controls = mt8173_rt5650_rt5676_controls,
|
||||
.num_controls = ARRAY_SIZE(mt8173_rt5650_rt5676_controls),
|
||||
.dapm_widgets = mt8173_rt5650_rt5676_widgets,
|
||||
.num_dapm_widgets = ARRAY_SIZE(mt8173_rt5650_rt5676_widgets),
|
||||
.dapm_routes = mt8173_rt5650_rt5676_routes,
|
||||
.num_dapm_routes = ARRAY_SIZE(mt8173_rt5650_rt5676_routes),
|
||||
};
|
||||
|
||||
static int mt8173_rt5650_rt5676_dev_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct snd_soc_card *card = &mt8173_rt5650_rt5676_card;
|
||||
int ret;
|
||||
|
||||
mt8173_rt5650_rt5676_codecs[0].of_node =
|
||||
of_parse_phandle(pdev->dev.of_node, "mediatek,audio-codec", 0);
|
||||
if (!mt8173_rt5650_rt5676_codecs[0].of_node) {
|
||||
dev_err(&pdev->dev,
|
||||
"Property 'audio-codec' missing or invalid\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
mt8173_rt5650_rt5676_codecs[1].of_node =
|
||||
of_parse_phandle(pdev->dev.of_node, "mediatek,audio-codec", 1);
|
||||
if (!mt8173_rt5650_rt5676_codecs[1].of_node) {
|
||||
dev_err(&pdev->dev,
|
||||
"Property 'audio-codec' missing or invalid\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
mt8173_rt5650_rt5676_codec_conf[0].of_node =
|
||||
mt8173_rt5650_rt5676_codecs[1].of_node;
|
||||
|
||||
mt8173_rt5650_rt5676_dais[3].codec_of_node =
|
||||
mt8173_rt5650_rt5676_codecs[1].of_node;
|
||||
|
||||
card->dev = &pdev->dev;
|
||||
platform_set_drvdata(pdev, card);
|
||||
|
||||
ret = snd_soc_register_card(card);
|
||||
if (ret)
|
||||
dev_err(&pdev->dev, "%s snd_soc_register_card fail %d\n",
|
||||
__func__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int mt8173_rt5650_rt5676_dev_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct snd_soc_card *card = platform_get_drvdata(pdev);
|
||||
|
||||
snd_soc_unregister_card(card);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct of_device_id mt8173_rt5650_rt5676_dt_match[] = {
|
||||
{ .compatible = "mediatek,mt8173-rt5650-rt5676", },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, mt8173_rt5650_rt5676_dt_match);
|
||||
|
||||
static struct platform_driver mt8173_rt5650_rt5676_driver = {
|
||||
.driver = {
|
||||
.name = "mtk-rt5650-rt5676",
|
||||
.owner = THIS_MODULE,
|
||||
.of_match_table = mt8173_rt5650_rt5676_dt_match,
|
||||
#ifdef CONFIG_PM
|
||||
.pm = &snd_soc_pm_ops,
|
||||
#endif
|
||||
},
|
||||
.probe = mt8173_rt5650_rt5676_dev_probe,
|
||||
.remove = mt8173_rt5650_rt5676_dev_remove,
|
||||
};
|
||||
|
||||
module_platform_driver(mt8173_rt5650_rt5676_driver);
|
||||
|
||||
/* Module information */
|
||||
MODULE_DESCRIPTION("MT8173 RT5650 and RT5676 SoC machine driver");
|
||||
MODULE_AUTHOR("Koro Chen <koro.chen@mediatek.com>");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
MODULE_ALIAS("platform:mtk-rt5650-rt5676");
|
||||
|
109
sound/soc/mediatek/mtk-afe-common.h
Normal file
109
sound/soc/mediatek/mtk-afe-common.h
Normal file
@ -0,0 +1,109 @@
|
||||
/*
|
||||
* mtk_afe_common.h -- Mediatek audio driver common definitions
|
||||
*
|
||||
* Copyright (c) 2015 MediaTek Inc.
|
||||
* Author: Koro Chen <koro.chen@mediatek.com>
|
||||
* Sascha Hauer <s.hauer@pengutronix.de>
|
||||
* Hidalgo Huang <hidalgo.huang@mediatek.com>
|
||||
* Ir Lian <ir.lian@mediatek.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 and
|
||||
* only version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef _MTK_AFE_COMMON_H_
|
||||
#define _MTK_AFE_COMMON_H_
|
||||
|
||||
#include <linux/clk.h>
|
||||
#include <linux/regmap.h>
|
||||
|
||||
enum {
|
||||
MTK_AFE_MEMIF_DL1,
|
||||
MTK_AFE_MEMIF_DL2,
|
||||
MTK_AFE_MEMIF_VUL,
|
||||
MTK_AFE_MEMIF_DAI,
|
||||
MTK_AFE_MEMIF_AWB,
|
||||
MTK_AFE_MEMIF_MOD_DAI,
|
||||
MTK_AFE_MEMIF_HDMI,
|
||||
MTK_AFE_MEMIF_NUM,
|
||||
MTK_AFE_IO_MOD_PCM1 = MTK_AFE_MEMIF_NUM,
|
||||
MTK_AFE_IO_MOD_PCM2,
|
||||
MTK_AFE_IO_PMIC,
|
||||
MTK_AFE_IO_I2S,
|
||||
MTK_AFE_IO_2ND_I2S,
|
||||
MTK_AFE_IO_HW_GAIN1,
|
||||
MTK_AFE_IO_HW_GAIN2,
|
||||
MTK_AFE_IO_MRG_O,
|
||||
MTK_AFE_IO_MRG_I,
|
||||
MTK_AFE_IO_DAIBT,
|
||||
MTK_AFE_IO_HDMI,
|
||||
};
|
||||
|
||||
enum {
|
||||
MTK_AFE_IRQ_1,
|
||||
MTK_AFE_IRQ_2,
|
||||
MTK_AFE_IRQ_3,
|
||||
MTK_AFE_IRQ_4,
|
||||
MTK_AFE_IRQ_5,
|
||||
MTK_AFE_IRQ_6,
|
||||
MTK_AFE_IRQ_7,
|
||||
MTK_AFE_IRQ_8,
|
||||
MTK_AFE_IRQ_NUM,
|
||||
};
|
||||
|
||||
enum {
|
||||
MTK_CLK_INFRASYS_AUD,
|
||||
MTK_CLK_TOP_PDN_AUD,
|
||||
MTK_CLK_TOP_PDN_AUD_BUS,
|
||||
MTK_CLK_I2S0_M,
|
||||
MTK_CLK_I2S1_M,
|
||||
MTK_CLK_I2S2_M,
|
||||
MTK_CLK_I2S3_M,
|
||||
MTK_CLK_I2S3_B,
|
||||
MTK_CLK_BCK0,
|
||||
MTK_CLK_BCK1,
|
||||
MTK_CLK_NUM
|
||||
};
|
||||
|
||||
struct mtk_afe;
|
||||
struct snd_pcm_substream;
|
||||
|
||||
struct mtk_afe_memif_data {
|
||||
int id;
|
||||
const char *name;
|
||||
int reg_ofs_base;
|
||||
int reg_ofs_cur;
|
||||
int fs_shift;
|
||||
int mono_shift;
|
||||
int enable_shift;
|
||||
int irq_reg_cnt;
|
||||
int irq_cnt_shift;
|
||||
int irq_en_shift;
|
||||
int irq_fs_shift;
|
||||
int irq_clr_shift;
|
||||
};
|
||||
|
||||
struct mtk_afe_memif {
|
||||
unsigned int phys_buf_addr;
|
||||
int buffer_size;
|
||||
unsigned int hw_ptr; /* Previous IRQ's HW ptr */
|
||||
struct snd_pcm_substream *substream;
|
||||
const struct mtk_afe_memif_data *data;
|
||||
const struct mtk_afe_irq_data *irqdata;
|
||||
};
|
||||
|
||||
struct mtk_afe {
|
||||
/* address for ioremap audio hardware register */
|
||||
void __iomem *base_addr;
|
||||
struct device *dev;
|
||||
struct regmap *regmap;
|
||||
struct mtk_afe_memif memif[MTK_AFE_MEMIF_NUM];
|
||||
struct clk *clocks[MTK_CLK_NUM];
|
||||
};
|
||||
#endif
|
1233
sound/soc/mediatek/mtk-afe-pcm.c
Normal file
1233
sound/soc/mediatek/mtk-afe-pcm.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -245,6 +245,8 @@ static const struct snd_soc_dapm_widget aic34_dapm_widgets[] = {
|
||||
static const struct snd_soc_dapm_route audio_map[] = {
|
||||
{"Ext Spk", NULL, "HPLOUT"},
|
||||
{"Ext Spk", NULL, "HPROUT"},
|
||||
{"Ext Spk", NULL, "HPLCOM"},
|
||||
{"Ext Spk", NULL, "HPRCOM"},
|
||||
{"Headphone Jack", NULL, "LLOUT"},
|
||||
{"Headphone Jack", NULL, "RLOUT"},
|
||||
{"FM Transmitter", NULL, "LLOUT"},
|
||||
@ -288,15 +290,8 @@ static int rx51_aic34_init(struct snd_soc_pcm_runtime *rtd)
|
||||
struct snd_soc_codec *codec = rtd->codec;
|
||||
struct snd_soc_card *card = rtd->card;
|
||||
struct rx51_audio_pdata *pdata = snd_soc_card_get_drvdata(card);
|
||||
|
||||
struct snd_soc_dapm_context *dapm = &codec->dapm;
|
||||
int err;
|
||||
|
||||
/* Set up NC codec pins */
|
||||
snd_soc_dapm_nc_pin(dapm, "MIC3L");
|
||||
snd_soc_dapm_nc_pin(dapm, "MIC3R");
|
||||
snd_soc_dapm_nc_pin(dapm, "LINE1R");
|
||||
|
||||
err = tpa6130a2_add_controls(codec);
|
||||
if (err < 0) {
|
||||
dev_err(card->dev, "Failed to add TPA6130A2 controls\n");
|
||||
@ -383,6 +378,7 @@ static struct snd_soc_card rx51_sound_card = {
|
||||
.num_aux_devs = ARRAY_SIZE(rx51_aux_dev),
|
||||
.codec_conf = rx51_codec_conf,
|
||||
.num_configs = ARRAY_SIZE(rx51_codec_conf),
|
||||
.fully_routed = true,
|
||||
|
||||
.controls = aic34_rx51_controls,
|
||||
.num_controls = ARRAY_SIZE(aic34_rx51_controls),
|
||||
|
Loading…
Reference in New Issue
Block a user