mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 11:26:02 +09:00
ASoC: rockchip: Add support for multicodecs machine driver
This patch adds support for sound which link multiple codecs to the same cpu dai. Change-Id: I77d3e9c10d03c2b8809c6d82b5268dba279ee6f0 Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com>
This commit is contained in:
@@ -69,6 +69,13 @@ config SND_SOC_ROCKCHIP_MAX98090
|
||||
Say Y or M here if you want to add support for SoC audio on Rockchip
|
||||
boards using the MAX98090 codec and HDMI codec, such as Veyron.
|
||||
|
||||
config SND_SOC_ROCKCHIP_MULTICODECS
|
||||
tristate "ASoC support for Rockchip multicodecs"
|
||||
depends on SND_SOC_ROCKCHIP && CLKDEV_LOOKUP
|
||||
help
|
||||
Say Y or M here if you want to add support for SoC audio on Rockchip
|
||||
boards using multicodecs, such as RK3308 boards.
|
||||
|
||||
config SND_SOC_ROCKCHIP_RT5645
|
||||
tristate "ASoC support for Rockchip boards using a RT5645/RT5650 codec"
|
||||
depends on SND_SOC_ROCKCHIP && I2C && GPIOLIB && CLKDEV_LOOKUP
|
||||
|
||||
@@ -21,11 +21,13 @@ obj-$(CONFIG_SND_SOC_ROCKCHIP_SPDIFRX) += snd-soc-rockchip-spdifrx.o
|
||||
obj-$(CONFIG_SND_SOC_ROCKCHIP_VAD) += snd-soc-rockchip-vad.o
|
||||
|
||||
snd-soc-rockchip-max98090-objs := rockchip_max98090.o
|
||||
snd-soc-rockchip-multicodecs-objs := rockchip_multicodecs.o
|
||||
snd-soc-rockchip-rt5645-objs := rockchip_rt5645.o
|
||||
snd-soc-rk3288-hdmi-analog-objs := rk3288_hdmi_analog.o
|
||||
snd-soc-rk3399-gru-sound-objs := rk3399_gru_sound.o
|
||||
|
||||
obj-$(CONFIG_SND_SOC_ROCKCHIP_MAX98090) += snd-soc-rockchip-max98090.o
|
||||
obj-$(CONFIG_SND_SOC_ROCKCHIP_MULTICODECS) += snd-soc-rockchip-multicodecs.o
|
||||
obj-$(CONFIG_SND_SOC_ROCKCHIP_RT5645) += snd-soc-rockchip-rt5645.o
|
||||
obj-$(CONFIG_SND_SOC_RK3288_HDMI_ANALOG) += snd-soc-rk3288-hdmi-analog.o
|
||||
obj-$(CONFIG_SND_SOC_RK3399_GRU_SOUND) += snd-soc-rk3399-gru-sound.o
|
||||
|
||||
@@ -48,9 +48,9 @@ static struct snd_soc_jack mc_hp_jack;
|
||||
static int rk_multicodecs_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;
|
||||
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
|
||||
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
|
||||
struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
|
||||
struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
|
||||
struct multicodecs_data *mc_data = snd_soc_card_get_drvdata(rtd->card);
|
||||
unsigned int mclk;
|
||||
int ret;
|
||||
@@ -88,7 +88,7 @@ static int rk_dailink_init(struct snd_soc_pcm_runtime *rtd)
|
||||
|
||||
#ifdef CONFIG_SND_SOC_RK3308
|
||||
if (rk3308_codec_set_jack_detect_cb)
|
||||
rk3308_codec_set_jack_detect_cb(rtd->codec_dai->component, &mc_hp_jack);
|
||||
rk3308_codec_set_jack_detect_cb(asoc_rtd_to_codec(rtd, 0)->component, &mc_hp_jack);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -212,6 +212,8 @@ static int rk_multicodecs_probe(struct platform_device *pdev)
|
||||
struct snd_soc_card *card;
|
||||
struct device_node *np = pdev->dev.of_node;
|
||||
struct snd_soc_dai_link *link;
|
||||
struct snd_soc_dai_link_component *cpus;
|
||||
struct snd_soc_dai_link_component *platforms;
|
||||
struct snd_soc_dai_link_component *codecs;
|
||||
struct multicodecs_data *mc_data;
|
||||
struct of_phandle_args args;
|
||||
@@ -231,6 +233,14 @@ static int rk_multicodecs_probe(struct platform_device *pdev)
|
||||
if (!mc_data)
|
||||
return -ENOMEM;
|
||||
|
||||
cpus = devm_kzalloc(&pdev->dev, sizeof(*cpus), GFP_KERNEL);
|
||||
if (!cpus)
|
||||
return -ENOMEM;
|
||||
|
||||
platforms = devm_kzalloc(&pdev->dev, sizeof(*platforms), GFP_KERNEL);
|
||||
if (!platforms)
|
||||
return -ENOMEM;
|
||||
|
||||
card = &mc_data->snd_card;
|
||||
card->dev = &pdev->dev;
|
||||
|
||||
@@ -244,6 +254,10 @@ static int rk_multicodecs_probe(struct platform_device *pdev)
|
||||
link->stream_name = link->name;
|
||||
link->init = rk_dailink_init;
|
||||
link->ops = &rk_ops;
|
||||
link->cpus = cpus;
|
||||
link->platforms = platforms;
|
||||
link->num_cpus = 1;
|
||||
link->num_platforms = 1;
|
||||
|
||||
card->dai_link = link;
|
||||
card->num_links = 1;
|
||||
@@ -292,11 +306,11 @@ static int rk_multicodecs_probe(struct platform_device *pdev)
|
||||
/* Only reference the codecs[0].of_node which maybe as master. */
|
||||
rk_multicodecs_parse_daifmt(np, codecs[0].of_node, mc_data, prefix);
|
||||
|
||||
link->cpu_of_node = of_parse_phandle(np, "rockchip,cpu", 0);
|
||||
if (!link->cpu_of_node)
|
||||
link->cpus->of_node = of_parse_phandle(np, "rockchip,cpu", 0);
|
||||
if (!link->cpus->of_node)
|
||||
return -ENODEV;
|
||||
|
||||
link->platform_of_node = link->cpu_of_node;
|
||||
link->platforms->of_node = link->cpus->of_node;
|
||||
|
||||
mc_data->mclk_fs = DEFAULT_MCLK_FS;
|
||||
if (!of_property_read_u32(np, "rockchip,mclk-fs", &val))
|
||||
|
||||
Reference in New Issue
Block a user