rockchip-rt5631 {
compatible = "rockchip-rt5631";
+ dais {
+ dai0 {
+ codec-name = "rt5631.0-001a";
+ cpu-dai-name = "rockchip-i2s.1";
+ format = "i2s";
+ //continuous-clock;
+ //bitclock-inversion;
+ //frame-inversion;
+ //bitclock-master;
+ //frame-master;
+ };
+ };
};
rockchip-hdmi-i2s {
compatible = "rockchip-hdmi-i2s";
+ dais {
+ dai0 {
+ codec-name = "hdmi-i2s";
+ cpu-dai-name = "rockchip-i2s.1";
+ format = "i2s";
+ //continuous-clock;
+ //bitclock-inversion;
+ //frame-inversion;
+ //bitclock-master;
+ //frame-master;
+ };
+ };
};
rockchip-hdmi-spdif {
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_codec *codec = rtd->codec;
struct rk610_codec_priv *rk610_codec =snd_soc_codec_get_drvdata(codec);
+ unsigned int dai_fmt = snd_soc_pcm_runtime->card->dai_link[0].dai_fmt
u16 iface = rk610_codec_read_reg_cache(codec, ACCELCODEC_R09) & 0x1f3;
u16 srate = rk610_codec_read_reg_cache(codec, ACCELCODEC_R00) & 0x180;
rk610_codec_write(codec,ACCELCODEC_R0B, ASC_DEC_DISABLE|ASC_INT_DISABLE); //0x00
/* set iface & srate */
- #ifdef CONFIG_SND_RK_CODEC_SOC_MASTER
- iface |= ASC_INVERT_BCLK;//·×ªBCLK master״̬ËͳöµÄÉÙÁË°ë¸öʱÖÓ£¬µ¼ÖÂδµ½×î´óÒôÁ¿µÄʱºòÆÆÒô¡¢
- #endif
+ if ((dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) == SND_SOC_DAIFMT_CBM_CFM)
+ iface |= ASC_INVERT_BCLK;//·×ªBCLK master״̬ËͳöµÄÉÙÁË°ë¸öʱÖÓ£¬µ¼ÖÂδµ½×î´óÒôÁ¿µÄʱºòÆÆÒô¡¢
+
rk610_codec_write(codec, ACCELCODEC_R09, iface);
if (coeff >= 0){
// rk610_codec_write(codec, ACCELCODEC_R00, srate|coeff_div[coeff].bclk);
config SND_RK_SOC_SPDIF
tristate
-config SND_RK_SOC_I2S_8CH
- bool "Soc RK I2S 8 Channel support(I2S0)"
- default y
- depends on SND_RK_SOC_I2S && !ARCH_RK3066B && !ARCH_RK3188 && !ARCH_RK319X
- help
- This supports the use of the 8 Channel I2S interface on rk processors.
-
-if SND_RK_SOC_I2S_8CH
-choice
- bool "Set I2S0 using the number of channels"
- default SND_I2SO_USE_DOUBLE_CHANNELS
- config SND_I2SO_USE_EIGHT_CHANNELS
- tristate "I2S0 use 8 channels"
-
- config SND_I2SO_USE_DOUBLE_CHANNELS
- tristate "I2S0 use 2 channels"
-endchoice
-endif
-
-config SND_RK_SOC_I2S_2CH
- bool "Soc RK I2S 2 Channel support(I2S1)"
- depends on SND_RK_SOC_I2S && !ARCH_RK2928 && !ARCH_RK3026
- default y if (ARCH_RK3066B || ARCH_RK3188)
- help
- This supports the use of the 2 Channel I2S interface on rk processors.
-
-choice
- bool "Set I2S GRF Output Voltage"
- depends on (ARCH_RK3066B || ARCH_RK3188) && SND_RK_SOC_I2S_2CH
- default SND_I2S_USE_33V
-
- config SND_I2S_USE_33V
- bool "I2S use 3.3V"
-
- config SND_I2S_USE_18V
- bool "I2S use 1.8V"
-endchoice
-
-config SND_RK_SOC_I2S2_2CH
- bool "Soc RK I2S 2 Channel support(I2S2)"
- default n
- depends on SND_RK_SOC_I2S && ARCH_RK30 && !ARCH_RK2928 && !ARCH_RK3066B && !ARCH_RK3026
- help
- This supports the use of the 2 Channel I2S2 interface on rk30 processors.
-
-if SND_RK_SOC_I2S_2CH || SND_RK_SOC_I2S_8CH || SND_RK_SOC_I2S2_2CH
-choice
- bool "Set i2s on DMA event mode"
- default SND_I2S_DMA_EVENT_STATIC
- config SND_I2S_DMA_EVENT_DYNAMIC
- tristate "dynamic mode"
-
- config SND_I2S_DMA_EVENT_STATIC
- tristate "static mode"
-endchoice
-endif
+if SND_RK_SOC
if SND_RK_SOC && RK_HDMI
choice
select SND_SOC_HDMI_SPDIF
tristate "HDMI use SPDIF"
endchoice
-endif
+endif #SND_RK_SOC && RK_HDMI
config SND_RK_SOC_AK4396
tristate "SoC I2S Audio support for rockchip - AK4396"
Say Y if you want to add support for SoC audio on rockchip
with the RK3190 internal codec.
-if SND_RK_SOC_I2S_2CH || SND_RK_SOC_I2S_8CH || SND_RK_SOC_I2S2_2CH
-choice
- bool "Set i2s type"
- default SND_RK_CODEC_SOC_SLAVE
- config SND_RK_CODEC_SOC_MASTER
- tristate "Codec run in Master"
-
- config SND_RK_CODEC_SOC_SLAVE
- tristate "Codec run in Slave"
-endchoice
-
-config ADJUST_VOL_BY_CODEC
- bool "Adjust volume by codec"
- default n
- help
- adjust volume by codec
-
-config PHONE_INCALL_IS_SUSPEND
- bool "Incalling Whether suspend codec"
- default n
- help
- set "y" phone incall status cannot into suspend codec
-
-endif
-
+endif #SND_RK_SOC
# ROCKCHIP Platform Support
-snd-soc-rockchip-objs := rk_pcm.o
+snd-soc-rockchip-objs := rk_pcm.o card_info.o
ifdef CONFIG_ARCH_RK29
snd-soc-rockchip-i2s-objs := rk29_i2s.o
else
--- /dev/null
+/*
+ * card_info.c
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/device.h>
+#include <linux/of.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/soc.h>
+
+/*
+ Get sound card infos:
+ codec-name
+ cpu-dai-name
+
+ format
+
+ continuous-clock
+
+ bitclock-inversion
+ frame-inversion
+
+ bitclock-master
+ frame-master
+
+ Get codec-name and cpu-dai-name in this fun,
+ and get oher infos in fun snd_soc_of_parse_daifmt().
+
+ Set in dts:
+ dais {
+ dai0 {
+ codec-name = "codec_name.i2c_bus-i2c_addr";
+ cpu-dai-name = "cpu_dai_name";
+ format = "i2s";
+ //continuous-clock;
+ //bitclock-inversion;
+ //frame-inversion;
+ //bitclock-master;
+ //frame-master;
+ };
+
+ dai1 {
+ codec-name = "codec_name.i2c_bus-i2c_addr";
+ cpu-dai-name = "cpu_dai_name";
+ };
+ };
+ */
+int rockchip_of_get_sound_card_info(struct snd_soc_card *card)
+{
+ struct device_node *dai_node, *child_dai_node;
+ int ret, dai_num;
+
+ dai_node = of_get_child_by_name(card->dev->of_node, "dais");
+ if (!dai_node) {
+ dev_err(card->dev, "%s() Can not get child: dais\n", __FUNCTION__);
+ return -EINVAL;
+ }
+
+ dai_num = 0;
+
+ for_each_child_of_node(dai_node, child_dai_node) {
+ //We only need to set fmt to cpu for dai 0.
+ if (dai_num == 0)
+ card->dai_link[dai_num].dai_fmt = snd_soc_of_parse_daifmt(child_dai_node, NULL);
+
+ ret = of_property_read_string(child_dai_node, "codec-name", &card->dai_link[dai_num].codec_name);
+ if (ret) {
+ dev_err(card->dev, "%s() Can not read property: codec-name for dai %d\n", __FUNCTION__, dai_num);
+ return ret;
+ }
+
+ ret = of_property_read_string(child_dai_node, "cpu-dai-name", &card->dai_link[dai_num].cpu_dai_name);
+ if (ret) {
+ dev_err(card->dev, "%s() Can not read property: cpu-dai-name for dai %d\n", __FUNCTION__, dai_num);
+ return ret;
+ }
+
+ //platform_name is same with cpu_dai_name.
+ card->dai_link[dai_num].platform_name= card->dai_link[dai_num].cpu_dai_name;
+
+ if (++dai_num >= card->num_links)
+ break;
+ }
+
+ if (dai_num < card->num_links) {
+ dev_err(card->dev, "%s() Can not get enough property for dais, dai: %d, max dai num: %d\n",
+ __FUNCTION__, dai_num, card->num_links);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(rockchip_of_get_sound_card_info);
+
+/* Module information */
+MODULE_AUTHOR("Jear <Jear.Chen@rock-chips.com>");
+MODULE_DESCRIPTION("ROCKCHIP ASoC Interface");
+MODULE_LICENSE("GPL");
--- /dev/null
+/*
+ * card_info.h - ALSA PCM interface for the Rockchip rk28 SoC
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _SND_SOC_ROCKCHIP_CARD_INFO_H
+#define _SND_SOC_ROCKCHIP_CARD_INFO_H
+
+int rockchip_of_get_sound_card_info(struct snd_soc_card *card);
+
+#endif /* _SND_SOC_ROCKCHIP_CARD_INFO_H */
#include <sound/pcm.h>
#include <sound/soc.h>
+#include "card_info.h"
#include "rk_pcm.h"
#include "rk_i2s.h"
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
- unsigned int pll_out = 0;
+ unsigned int pll_out = 0, dai_fmt = cpu_dai->card->dai_link[0].dai_fmt;
int div_bclk,div_mclk;
int ret;
DBG("Enter:%s, %d, rate=%d\n",__FUNCTION__,__LINE__,params_rate(params));
pll_out = 256 * params_rate(params);
-
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0);
- #endif
-
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
+
+ snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0);
+
+ if ((dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) == SND_SOC_DAIFMT_CBS_CFS) {
div_bclk = 63;
div_mclk = pll_out/(params_rate(params)*64) - 1;
-
- snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0);
+
snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_BCLK,div_bclk);
snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_MCLK, div_mclk);
- #endif
+ }
return 0;
}
{
.name = "RK2928",
.stream_name = "RK2928",
- .cpu_dai_name = "rockchip-i2s.0",
- .codec_name = "rk2928-codec",
.codec_dai_name = "rk2928-codec",
.ops = &rk2928_dai_ops,
-#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBM_CFM,
-#else
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBS_CFS,
-#endif
},
};
#define MAX_I2S 3
+static DEFINE_SPINLOCK(lock);
+
struct rk30_i2s_info {
void __iomem *regs;
bool i2s_tx_status;//active = true;
bool i2s_rx_status;
-
- spinlock_t spinlock_wr;//write read reg spin_lock
};
#if defined (CONFIG_RK_HDMI) && defined (CONFIG_SND_RK_SOC_HDMI_I2S)
extern int hdmi_get_hotplug(void);
+#else
+#define hdmi_get_hotplug() 0
#endif
static inline struct rk30_i2s_info *to_info(struct snd_soc_dai *dai)
static void rockchip_snd_txctrl(struct rk30_i2s_info *i2s, int on)
{
u32 opr, xfer, clr;
+ unsigned long flags;
+ int is_need_delay = false;
- spin_lock(&i2s->spinlock_wr);
+ spin_lock_irqsave(&lock, flags);
opr = readl(&(pheadi2s->I2S_DMACR));
xfer = readl(&(pheadi2s->I2S_XFER));
}
i2s->i2s_tx_status = 1;
- spin_unlock(&i2s->spinlock_wr);
+
} else { //stop tx
i2s->i2s_tx_status = 0;
opr &= ~I2S_TRAN_DMA_ENABLE;
writel(opr, &(pheadi2s->I2S_DMACR));
- if (i2s->i2s_rx_status == 0//sync stop i2s rx tx lcrk
-#if defined (CONFIG_RK_HDMI) && defined (CONFIG_SND_RK_SOC_HDMI_I2S)
- && hdmi_get_hotplug() == 0 //HDMI_HPD_REMOVED
-#endif
- ) {
+ if (i2s->i2s_rx_status == 0 && hdmi_get_hotplug() == 0) {
xfer &= ~I2S_TX_TRAN_START;
xfer &= ~I2S_RX_TRAN_START;
writel(xfer, &(pheadi2s->I2S_XFER));
+
clr |= I2S_TX_CLEAR;
clr |= I2S_RX_CLEAR;
writel(clr, &(pheadi2s->I2S_CLR));
- spin_unlock(&i2s->spinlock_wr);
- udelay(1);
+
+ is_need_delay = true;
+
I2S_DBG("rockchip_snd_txctrl: stop xfer\n");
- } else
- spin_unlock(&i2s->spinlock_wr);
+ }
}
+
+ spin_unlock_irqrestore(&lock, flags);
+
+ if (is_need_delay)
+ udelay(1);
}
static void rockchip_snd_rxctrl(struct rk30_i2s_info *i2s, int on)
{
u32 opr, xfer, clr;
+ unsigned long flags;
+ int is_need_delay = false;
- spin_lock(&i2s->spinlock_wr);
+ spin_lock_irqsave(&lock, flags);
opr = readl(&(pheadi2s->I2S_DMACR));
xfer = readl(&(pheadi2s->I2S_XFER));
}
i2s->i2s_rx_status = 1;
- spin_unlock(&i2s->spinlock_wr);
} else {
i2s->i2s_rx_status = 0;
opr &= ~I2S_RECE_DMA_ENABLE;
writel(opr, &(pheadi2s->I2S_DMACR));
- if (i2s->i2s_tx_status == 0//sync stop i2s rx tx lcrk
-#if defined (CONFIG_RK_HDMI) && defined (CONFIG_SND_RK_SOC_HDMI_I2S)
- && hdmi_get_hotplug() == 0 //HDMI_HPD_REMOVED
-#endif
- ) {
+ if (i2s->i2s_tx_status == 0 && hdmi_get_hotplug() == 0) {
xfer &= ~I2S_RX_TRAN_START;
xfer &= ~I2S_TX_TRAN_START;
writel(xfer, &(pheadi2s->I2S_XFER));
+
clr |= I2S_RX_CLEAR;
clr |= I2S_TX_CLEAR;
writel(clr, &(pheadi2s->I2S_CLR));
- spin_unlock(&i2s->spinlock_wr);
- udelay(1);
+
+ is_need_delay = true;
+
I2S_DBG("rockchip_snd_rxctrl: stop xfer\n");
- } else
- spin_unlock(&i2s->spinlock_wr);
+ }
}
+
+ spin_unlock_irqrestore(&lock, flags);
+
+ if (is_need_delay)
+ udelay(1);
}
/*
struct rk30_i2s_info *i2s = to_info(cpu_dai);
u32 tx_ctl,rx_ctl;
u32 iis_ckr_value;//clock generation register
+ unsigned long flags;
I2S_DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
- spin_lock(&i2s->spinlock_wr);
+ spin_lock_irqsave(&lock, flags);
tx_ctl = readl(&(pheadi2s->I2S_TXCR));
iis_ckr_value = readl(&(pheadi2s->I2S_CKR));
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
case SND_SOC_DAIFMT_CBM_CFM:
+ //Codec is master, so set cpu slave.
iis_ckr_value &= ~I2S_MODE_MASK;
iis_ckr_value |= I2S_SLAVE_MODE;
break;
case SND_SOC_DAIFMT_CBS_CFS:
+ //Codec is slave, so set cpu master.
iis_ckr_value &= ~I2S_MODE_MASK;
iis_ckr_value |= I2S_MASTER_MODE;
break;
rx_ctl = tx_ctl & 0x00007FFF;
writel(rx_ctl, &(pheadi2s->I2S_RXCR));
- spin_unlock(&i2s->spinlock_wr);
+ spin_unlock_irqrestore(&lock, flags);
return 0;
}
struct rk30_i2s_info *i2s = to_info(dai);
u32 iismod;
u32 dmarc;
- u32 iis_ckr_value;//clock generation register
-
+ unsigned long flags;
+
I2S_DBG("Enter %s, %d \n", __func__, __LINE__);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
else
dai->capture_dma_data = &i2s->capture_dma_data;
- spin_lock(&i2s->spinlock_wr);
+ spin_lock_irqsave(&lock, flags);
/* Working copies of register */
iismod = readl(&(pheadi2s->I2S_TXCR));
break;
}
- iis_ckr_value = readl(&(pheadi2s->I2S_CKR));
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- iis_ckr_value &= ~I2S_SLAVE_MODE;
- #endif
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- iis_ckr_value |= I2S_SLAVE_MODE;
- #endif
- writel(iis_ckr_value, &(pheadi2s->I2S_CKR));
-
dmarc = readl(&(pheadi2s->I2S_DMACR));
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
iismod = iismod & 0x00007FFF;
writel(iismod, &(pheadi2s->I2S_RXCR));
- spin_unlock(&i2s->spinlock_wr);
+ spin_unlock_irqrestore(&lock, flags);
return 0;
}
{
struct rk30_i2s_info *i2s;
u32 reg;
+ unsigned long flags;
i2s = to_info(cpu_dai);
- spin_lock(&i2s->spinlock_wr);
+ spin_lock_irqsave(&lock, flags);
//stereo mode MCLK/SCK=4
reg = readl(&(pheadi2s->I2S_CKR));
return -EINVAL;
}
writel(reg, &(pheadi2s->I2S_CKR));
- spin_unlock(&i2s->spinlock_wr);
+ spin_unlock_irqrestore(&lock, flags);
return 0;
}
goto err;
}
- spin_lock_init(&i2s->spinlock_wr);
-
i2s->i2s_clk= clk_get(&pdev->dev, NULL);
if (IS_ERR(i2s->i2s_clk)) {
dev_err(&pdev->dev, "Can't retrieve i2s clock\n");
regs_base = mem->start;
i2s->playback_dma_data.addr = regs_base + I2S_TXR_BUFF;
- i2s->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
- i2s->playback_dma_data.maxburst = 4;
+ i2s->playback_dma_data.addr_width = 4;
+ i2s->playback_dma_data.maxburst = 1;
i2s->capture_dma_data.addr = regs_base + I2S_RXR_BUFF;
- i2s->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
- i2s->capture_dma_data.maxburst = 4;
+ i2s->capture_dma_data.addr_width = 4;
+ i2s->capture_dma_data.maxburst = 1;
i2s->i2s_tx_status = false;
i2s->i2s_rx_status = false;
#include <sound/soc-dapm.h>
#include "../codecs/tlv320aic3111.h"
+#include "card_info.h"
#include "rk_pcm.h"
#include "rk_i2s.h"
static struct snd_soc_dai_link rk29_dai = {
.name = "AIC3111",
.stream_name = "AIC3111 PCM",
- .codec_name = "AIC3111.0-0018",
- .cpu_dai_name = "rockchip-i2s.0",
.codec_dai_name = "AIC3111 HiFi",
.init = rk29_aic3111_init,
.ops = &rk29_ops,
-#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBM_CFM,
-#else
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBS_CFS,
-#endif
};
static struct snd_soc_card rockchip_aic3111_snd_card = {
card->dev = &pdev->dev;
- ret = snd_soc_register_card(card);
+ ret = rockchip_of_get_sound_card_info(card);
+ if (ret) {
+ printk("%s() get sound card info failed:%d\n", __FUNCTION__, ret);
+ return ret;
+ }
+ ret = snd_soc_register_card(card);
if (ret)
printk("%s() register card failed:%d\n", __FUNCTION__, ret);
#include <linux/device.h>
#include "../codecs/wm8994.h"
+#include "card_info.h"
#include "rk_pcm.h"
#include "rk_i2s.h"
#include <linux/clk.h>
{
.name = "AIC3262 I2S1",
.stream_name = "AIC3262 PCM",
- .codec_name = "tlv320aic3262-codec",
-#if defined(CONFIG_SND_RK_SOC_I2S_8CH)
- .cpu_dai_name = "rockchip-i2s.0",
-#elif defined(CONFIG_SND_RK_SOC_I2S_2CH)
- .cpu_dai_name = "rockchip-i2s.1",
-#else
- .cpu_dai_name = "rockchip-i2s.2",
-#endif
.codec_dai_name = "aic326x-asi1",
.ops = &rk29_aif1_ops,
.init = rk29_aic3262_init,
-#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBM_CFM,
-#else
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBS_CFS,
-#endif
},
{
.name = "AIC3262 I2S2",
.stream_name = "AIC3262 PCM",
- .codec_name = "tlv320aic3262-codec",
-#if defined(CONFIG_SND_RK_SOC_I2S_8CH)
- .cpu_dai_name = "rockchip-i2s.0",
-#elif defined(CONFIG_SND_RK_SOC_I2S_2CH)
- .cpu_dai_name = "rockchip-i2s.1",
-#else
- .cpu_dai_name = "rockchip-i2s.2",
-#endif
.codec_dai_name = "aic326x-asi2",
.ops = &rk29_aif2_ops,
},
{
.name = "AIC3262 I2S3",
.stream_name = "AIC3262 PCM",
- .codec_name = "tlv320aic3262-codec",
-#if defined(CONFIG_SND_RK_SOC_I2S_8CH)
- .cpu_dai_name = "rockchip-i2s.0",
-#elif defined(CONFIG_SND_RK_SOC_I2S_2CH)
- .cpu_dai_name = "rockchip-i2s.1",
-#else
- .cpu_dai_name = "rockchip-i2s.2",
-#endif
.codec_dai_name = "aic326x-asi3",
.ops = &rk29_aif3_ops,
},
card->dev = &pdev->dev;
- ret = snd_soc_register_card(card);
+ ret = rockchip_of_get_sound_card_info(card);
+ if (ret) {
+ printk("%s() get sound card info failed:%d\n", __FUNCTION__, ret);
+ return ret;
+ }
+ ret = snd_soc_register_card(card);
if (ret)
printk("%s() register card failed:%d\n", __FUNCTION__, ret);
#include <sound/soc.h>
#include <sound/soc-dapm.h>
+#include "card_info.h"
#include "rk_pcm.h"
#include "rk_i2s.h"
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;
- unsigned int pll_out = 0;
+ unsigned int pll_out = 0, dai_fmt = cpu_dai->card->dai_link[0].dai_fmt;
int ret=-1;
DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
DBG("Enter:%s, %d, rate=%d\n",__FUNCTION__,__LINE__,params_rate(params));
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
+ if ((dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) == SND_SOC_DAIFMT_CBM_CFM)
+ return 0;
snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0);
snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_BCLK, (2 * 32 )-1); //bclk = 2 * 32 * lrck
break;
}
snd_soc_dai_set_sysclk(codec_dai,0,pll_out,SND_SOC_CLOCK_IN);
- #endif
+
return ret;
}
static struct snd_soc_dai_link rk29_dai = {
.name = "AK4396",
.stream_name = "AK4396 PCM",
- .codec_name = "spi1.0",
-#if defined(CONFIG_SND_RK_SOC_I2S_8CH)
- .cpu_dai_name = "rockchip-i2s.0",
-#elif defined(CONFIG_SND_RK_SOC_I2S_2CH)
- .cpu_dai_name = "rockchip-i2s.1",
-#else
- .cpu_dai_name = "rockchip-i2s.2",
-#endif
.codec_dai_name = "AK4396 HiFi",
.init = rk29_ak4396_init,
.ops = &rk29_ops,
-#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBM_CFM,
-#else
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBS_CFS,
-#endif
};
static struct snd_soc_card rockchip_ak4396_snd_card = {
card->dev = &pdev->dev;
- ret = snd_soc_register_card(card);
+ ret = rockchip_of_get_sound_card_info(card);
+ if (ret) {
+ printk("%s() get sound card info failed:%d\n", __FUNCTION__, ret);
+ return ret;
+ }
+ ret = snd_soc_register_card(card);
if (ret)
printk("%s() register card failed:%d\n", __FUNCTION__, ret);
#include <sound/soc-dapm.h>
#include "../codecs/cs42l52.h"
+#include "card_info.h"
#include "rk_pcm.h"
#include "rk_i2s.h"
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;
- unsigned int pll_out = 0;
+ unsigned int pll_out = 0, dai_fmt = cpu_dai->card->dai_link[0].dai_fmt;
unsigned int lrclk = 0;
int div_bclk,div_mclk;
struct clk *general_pll;
break;
}
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
+ if ((dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) == SND_SOC_DAIFMT_CBS_CFS) {
general_pll=clk_get(NULL, "general_pll");
if(clk_get_rate(general_pll)>260000000)
{
snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0);
snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_BCLK,div_bclk);
snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_MCLK, div_mclk);
- #endif
+ }
return 0;
static struct snd_soc_dai_link rk29_cs42l52_dai_link = {
.name = "CS42L52",
.stream_name = "CS42L52 PCM",
- .codec_name = "cs42l52.0-004a",
-#if defined(CONFIG_SND_RK_SOC_I2S_8CH)
- .cpu_dai_name = "rockchip-i2s.0",
-#elif defined(CONFIG_SND_RK_SOC_I2S_2CH)
- .cpu_dai_name = "rockchip-i2s.1",
-#else
- .cpu_dai_name = "rockchip-i2s.2",
-#endif
.codec_dai_name = "cs42l52-hifi",
.init = rk29_cs42l52_dai_init,
.ops = &rk29_cs42l52_ops,
-#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBM_CFM,
-#else
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBS_CFS,
-#endif
};
static struct snd_soc_card rockchip_cs42l52_snd_card = {
card->dev = &pdev->dev;
- ret = snd_soc_register_card(card);
+ ret = rockchip_of_get_sound_card_info(card);
+ if (ret) {
+ printk("%s() get sound card info failed:%d\n", __FUNCTION__, ret);
+ return ret;
+ }
+ ret = snd_soc_register_card(card);
if (ret)
printk("%s() register card failed:%d\n", __FUNCTION__, ret);
#include <sound/soc-dapm.h>
#include <sound/jack.h>
#include <linux/delay.h>
+#include "card_info.h"
#include "rk_pcm.h"
#include "rk_i2s.h"
#if 1
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;
- unsigned int pll_out = 0;
+ unsigned int pll_out = 0, dai_fmt = cpu_dai->card->dai_link[0].dai_fmt;
//unsigned int pll_div;
int ret;
return -EINVAL;
break;
}
-#if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
+ if ((dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) == SND_SOC_DAIFMT_CBM_CFM)
+ goto skip__;
snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0);
snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_BCLK, 64-1);//bclk = 2*32*lrck; 2*32fs
switch(params_rate(params)) {
DBG("rk29_hw_params_cx2070x:failed to set the sysclk for codec side\n");
return ret;
}
-#endif
+skip__:
-#if 0
- switch (params_rate(params))
- {
- case 8000:
- pll_div = 12;
- break;
- case 16000:
- pll_div = 6;
- break;
- case 32000:
- pll_div = 3;
- break;
- case 48000:
- pll_div = 2;
- break;
- case 96000:
- pll_div = 1;
- break;
- case 11025:
- pll_div = 8;
- break;
- case 22050:
- pll_div = 4;
- break;
- case 44100:
- pll_div = 2;
- break;
- case 88200:
- pll_div = 1;
- break;
- default:
- printk("Not yet supported!\n");
- return -EINVAL;
- }
- ret = snd_soc_dai_set_clkdiv(codec_dai, cx2070x_CLK_DIV_ID, pll_div*4);
- if (ret < 0)
- return ret;
-#endif
-
-#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- //snd_soc_dai_set_pll(codec_dai,0,pll_out, 22579200);
- snd_soc_dai_set_sysclk(codec_dai,0,pll_out, SND_SOC_CLOCK_IN);
-#endif
+ if ((dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) == SND_SOC_DAIFMT_CBM_CFM)
+ snd_soc_dai_set_sysclk(codec_dai,0,pll_out, SND_SOC_CLOCK_IN);
return 0;
}
{ /* Primary DAI i/f */
.name = "CX2070X AIF1",
.stream_name = "CX2070X PCM",
- .cpu_dai_name = "rockchip-i2s.1",
.codec_dai_name = "cx2070x-hifi",
- .codec_name = "cx2070x.0-0014",
.init = cx2070x_init,
.ops = &rk29_ops,
-#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBM_CFM,
-#else
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBS_CFS,
-#endif
},
};
card->dev = &pdev->dev;
- ret = snd_soc_register_card(card);
+ ret = rockchip_of_get_sound_card_info(card);
+ if (ret) {
+ printk("%s() get sound card info failed:%d\n", __FUNCTION__, ret);
+ return ret;
+ }
+ ret = snd_soc_register_card(card);
if (ret)
printk("%s() register card failed:%d\n", __FUNCTION__, ret);
#include <sound/soc-dapm.h>
#include "../codecs/es8323.h"
+#include "card_info.h"
#include "rk_pcm.h"
#include "rk_i2s.h"
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;
- unsigned int pll_out = 0;
+ unsigned int pll_out = 0, dai_fmt = cpu_dai->card->dai_link[0].dai_fmt;
int ret;
DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
}
DBG("Enter:%s, %d, rate=%d\n",__FUNCTION__,__LINE__,params_rate(params));
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0);
- snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_BCLK, (pll_out/4)/params_rate(params)-1);
- snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_MCLK, 3);
- #endif
+ if ((dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) == SND_SOC_DAIFMT_CBS_CFS) {
+ snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0);
+ snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_BCLK, (pll_out/4)/params_rate(params)-1);
+ snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_MCLK, 3);
+ }
DBG("Enter:%s, %d, LRCK=%d\n",__FUNCTION__,__LINE__,(pll_out/4)/params_rate(params));
return 0;
static struct snd_soc_dai_link rk29_dai = {
.name = "ES8323",
.stream_name = "ES8323 PCM",
- .codec_name = "ES8323.0-0010", // ES8323.0-0010
-#if defined(CONFIG_SND_RK_SOC_I2S_8CH)
- .cpu_dai_name = "rockchip-i2s.0",
-#elif defined(CONFIG_SND_RK_SOC_I2S_2CH)
- .cpu_dai_name = "rockchip-i2s.1", //Ó²¼þÉÏÊǽӵ½IIS0ÉÏ£¬µ«ÊÇÓÉÓÚxxÔÒò£¬Õâ±ß¶¨ÒåΪIIS1ÉÏ
-#else
- .cpu_dai_name = "rockchip-i2s.2",
-#endif
.codec_dai_name = "ES8323 HiFi",
.init = rk29_es8323_init,
.ops = &rk29_ops,
-#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBM_CFM,
-#else
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBS_CFS,
-#endif
};
static struct snd_soc_card rockchip_es8323_snd_card = {
card->dev = &pdev->dev;
- ret = snd_soc_register_card(card);
+ ret = rockchip_of_get_sound_card_info(card);
+ if (ret) {
+ printk("%s() get sound card info failed:%d\n", __FUNCTION__, ret);
+ return ret;
+ }
+ ret = snd_soc_register_card(card);
if (ret)
printk("%s() register card failed:%d\n", __FUNCTION__, ret);
#include <sound/soc.h>
#include <sound/soc-dapm.h>
+#include "card_info.h"
#include "rk_pcm.h"
#include "rk_i2s.h"
static struct snd_soc_dai_link hdmi_i2s_dai = {
.name = "HDMI I2S",
.stream_name = "HDMI PCM",
- .codec_name = "hdmi-i2s",
-#if defined(CONFIG_SND_RK_SOC_I2S_8CH)
- .cpu_dai_name = "rockchip-i2s.0",
-#elif defined(CONFIG_SND_RK_SOC_I2S_2CH)
- .cpu_dai_name = "rockchip-i2s.1",
-#endif
.codec_dai_name = "rk-hdmi-i2s-hifi",
.ops = &hdmi_i2s_hifi_ops,
-#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBM_CFM,
-#else
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBS_CFS,
-#endif
};
static struct snd_soc_card rockchip_hdmi_i2s_snd_card = {
card->dev = &pdev->dev;
- ret = snd_soc_register_card(card);
+ ret = rockchip_of_get_sound_card_info(card);
+ if (ret) {
+ printk("%s() get sound card info failed:%d\n", __FUNCTION__, ret);
+ return ret;
+ }
+ ret = snd_soc_register_card(card);
if (ret)
printk("%s() register card failed:%d\n", __FUNCTION__, ret);
#include <sound/soc.h>
#include <sound/soc-dapm.h>
#include "../codecs/rk610_codec.h"
+#include "card_info.h"
#include "rk_pcm.h"
#include "rk_i2s.h"
#ifdef CONFIG_MACH_RK_FAC
struct snd_soc_dai *codec_dai = rtd->codec_dai;
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
int ret;
- unsigned int pll_out = 0;
+ unsigned int pll_out = 0, dai_fmt = cpu_dai->card->dai_link[0].dai_fmt;
int div_bclk,div_mclk;
// struct clk *general_pll;
DBG("Enter:%s, %d, rate=%d\n",__FUNCTION__,__LINE__,params_rate(params));
snd_soc_dai_set_sysclk(codec_dai, 0, pll_out, SND_SOC_CLOCK_IN);
-// #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
-// snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0);
-// #endif
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
+ if ((dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) == SND_SOC_DAIFMT_CBS_CFS) {
div_bclk = 63;
div_mclk = pll_out/(params_rate(params)*64) - 1;
snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_BCLK,div_bclk);
snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_MCLK, div_mclk);
// DBG("Enter:%s, %d, LRCK=%d\n",__FUNCTION__,__LINE__,(pll_out/4)/params_rate(params));
- #endif
+ }
return 0;
}
static struct snd_soc_dai_link rk29_dai = {
.name = "RK610_CODEC",
.stream_name = "RK610 CODEC PCM",
-#if defined(CONFIG_MACH_RK3168_DS1006H)|| defined(CONFIG_MACH_RK3168_LR097)
- .codec_name = "RK610_CODEC.4-0060",
-#else
- .codec_name = "RK610_CODEC.0-0060",
-#endif
-#if defined(CONFIG_SND_RK_SOC_I2S_8CH)
- .cpu_dai_name = "rockchip-i2s.0",
-#elif defined(CONFIG_SND_RK_SOC_I2S_2CH)
- .cpu_dai_name = "rockchip-i2s.1",
-#else
- .cpu_dai_name = "rockchip-i2s.2",
-#endif
.codec_dai_name = "rk610_codec",
.ops = &rk29_ops,
-#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBM_CFM,
-#else
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBS_CFS,
-#endif
};
static struct snd_soc_card rockchip_rk610_snd_card = {
.name = "RK_RK610",
card->dev = &pdev->dev;
- ret = snd_soc_register_card(card);
+ ret = rockchip_of_get_sound_card_info(card);
+ if (ret) {
+ printk("%s() get sound card info failed:%d\n", __FUNCTION__, ret);
+ return ret;
+ }
+ ret = snd_soc_register_card(card);
if (ret)
printk("%s() register card failed:%d\n", __FUNCTION__, ret);
SNDRV_PCM_FMTBIT_S16_LE,
.channels_min = 2,
.channels_max = 8,
-#ifdef CONFIG_RK_SRAM_DMA
- .buffer_bytes_max = 24*1024,//period_bytes_max * periods_max
-#else
.buffer_bytes_max = 128*1024,
-#endif
.period_bytes_min = 64, ///PAGE_SIZE,
-#ifdef CONFIG_RK_SRAM_DMA
- .period_bytes_max = 8*1024,
-#else
.period_bytes_max = 2048*4,///PAGE_SIZE*2,
-#endif
.periods_min = 3,///2,
.periods_max = 128,
.fifo_size = 16,
#include <sound/soc-dapm.h>
#include "../codecs/rk1000_codec.h"
+#include "card_info.h"
#include "rk_pcm.h"
#include "rk_i2s.h"
{
.name = "RK1000",
.stream_name = "RK1000 CODEC PCM",
- .codec_name = "RK1000_CODEC.0-0060",
.codec_dai_name = "rk1000_codec",
-#if defined(CONFIG_SND_RK_SOC_I2S_8CH)
- .cpu_dai_name = "rockchip-i2s.0",
-#elif defined(CONFIG_SND_RK_SOC_I2S_2CH)
- .cpu_dai_name = "rockchip-i2s.1",
-#endif
.init = rk29_rk1000_codec_init,
.ops = &rk29_ops,
-#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBM_CFM,
-#else
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBS_CFS,
-#endif
}
};
card->dev = &pdev->dev;
- ret = snd_soc_register_card(card);
+ ret = rockchip_of_get_sound_card_info(card);
+ if (ret) {
+ printk("%s() get sound card info failed:%d\n", __FUNCTION__, ret);
+ return ret;
+ }
+ ret = snd_soc_register_card(card);
if (ret)
printk("%s() register card failed:%d\n", __FUNCTION__, ret);
#include <sound/soc-dapm.h>
#include "../codecs/rk3026_codec.h"
+#include "card_info.h"
#include "rk_pcm.h"
#include "rk_i2s.h"
{
.name = "RK3026 I2S1",
.stream_name = "RK3026 PCM",
- .codec_name = "rk3026-codec",
-#if defined(CONFIG_SND_RK_SOC_I2S_8CH)
- .cpu_dai_name = "rockchip-i2s.0",
-#elif defined(CONFIG_SND_RK_SOC_I2S_2CH)
- .cpu_dai_name = "rockchip-i2s.1",
-#endif
.codec_dai_name = "rk3026-hifi",
.init = rk3026_init,
.ops = &rk3026_hifi_ops,
-#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBM_CFM,
-#else
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBS_CFS,
-#endif
},
{
.name = "RK3026 I2S2",
.stream_name = "RK3026 PCM",
- .codec_name = "rk3026-codec",
-#if defined(CONFIG_SND_RK_SOC_I2S_8CH)
- .cpu_dai_name = "rockchip-i2s.0",
-#elif defined(CONFIG_SND_RK_SOC_I2S_2CH)
- .cpu_dai_name = "rockchip-i2s.1",
-#endif
.codec_dai_name = "rk3026-voice",
.ops = &rk3026_voice_ops,
},
card->dev = &pdev->dev;
- ret = snd_soc_register_card(card);
+ ret = rockchip_of_get_sound_card_info(card);
+ if (ret) {
+ printk("%s() get sound card info failed:%d\n", __FUNCTION__, ret);
+ return ret;
+ }
+ ret = snd_soc_register_card(card);
if (ret)
printk("%s() register card failed:%d\n", __FUNCTION__, ret);
#include <sound/soc.h>
#include <sound/soc-dapm.h>
#include "../codecs/rk3190_codec.h"
+#include "card_info.h"
#include "rk_pcm.h"
#include "rk_i2s.h"
{
.name = "RK3190 I2S1",
.stream_name = "RK3190 PCM",
- .codec_name = "rk3190-codec",
-#if defined(CONFIG_SND_RK_SOC_I2S_8CH)
- .cpu_dai_name = "rockchip-i2s.0",
-#elif defined(CONFIG_SND_RK_SOC_I2S_2CH)
- .cpu_dai_name = "rockchip-i2s.1",
-#endif
.codec_dai_name = "rk3190-hifi",
.init = rk3190_init,
.ops = &rk3190_hifi_ops,
-#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBM_CFM,
-#else
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBS_CFS,
-#endif
},
{
.name = "RK3190 I2S2",
.stream_name = "RK3190 PCM",
- .codec_name = "rk3190-codec",
-#if defined(CONFIG_SND_RK_SOC_I2S_8CH)
- .cpu_dai_name = "rockchip-i2s.0",
-#elif defined(CONFIG_SND_RK_SOC_I2S_2CH)
- .cpu_dai_name = "rockchip-i2s.1",
-#endif
.codec_dai_name = "rk3190-voice",
.ops = &rk3190_voice_ops,
},
card->dev = &pdev->dev;
- ret = snd_soc_register_card(card);
+ ret = rockchip_of_get_sound_card_info(card);
+ if (ret) {
+ printk("%s() get sound card info failed:%d\n", __FUNCTION__, ret);
+ return ret;
+ }
+ ret = snd_soc_register_card(card);
if (ret)
printk("%s() register card failed:%d\n", __FUNCTION__, ret);
#include <sound/soc-dapm.h>
#include "../codecs/rk616_codec.h"
+#include "card_info.h"
#include "rk_pcm.h"
#include "rk_i2s.h"
struct snd_soc_dai *codec_dai = rtd->codec_dai;
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
unsigned int pll_out = 0, div = 4;
- int ret;
DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
{
.name = "RK616 I2S1",
.stream_name = "RK616 PCM",
- .codec_name = "rk616-codec.4-0050",
-#if defined(CONFIG_SND_RK_SOC_I2S_8CH)
- .cpu_dai_name = "rockchip-i2s.0",
-#elif defined(CONFIG_SND_RK_SOC_I2S_2CH)
- .cpu_dai_name = "rockchip-i2s.1",
-#endif
.codec_dai_name = "rk616-hifi",
.init = rk616_init,
.ops = &rk616_hifi_ops,
-#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBM_CFM,
-#else
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBS_CFS,
-#endif
},
{
.name = "RK616 I2S2",
.stream_name = "RK616 PCM",
- .codec_name = "rk616-codec.4-0050",
-#if defined(CONFIG_SND_RK_SOC_I2S_8CH)
- .cpu_dai_name = "rockchip-i2s.0",
-#elif defined(CONFIG_SND_RK_SOC_I2S_2CH)
- .cpu_dai_name = "rockchip-i2s.1",
-#endif
.codec_dai_name = "rk616-voice",
.ops = &rk616_voice_ops,
- .no_pcm = 1;
+ .no_pcm = 1,
},
};
card->dev = &pdev->dev;
- ret = snd_soc_register_card(card);
+ ret = rockchip_of_get_sound_card_info(card);
+ if (ret) {
+ printk("%s() get sound card info failed:%d\n", __FUNCTION__, ret);
+ return ret;
+ }
+ ret = snd_soc_register_card(card);
if (ret)
printk("%s() register card failed:%d\n", __FUNCTION__, ret);
#include <linux/of_gpio.h>
#include "../codecs/rt3261.h"
+#include "card_info.h"
#include "rk_pcm.h"
#include "rk_i2s.h"
static struct snd_soc_dai_link rockchip_rt3261_dai[] = {
{
.name = "RT3261 I2S1",
- .stream_name = "RT3261 PCM",
- .codec_name = "rt3261.0-001c",
- #if defined(CONFIG_SND_RK_SOC_I2S_8CH)
- .cpu_dai_name = "rockchip-i2s.0",
- #elif defined(CONFIG_SND_RK_SOC_I2S_2CH)
- .cpu_dai_name = "rockchip-i2s.1",
- #endif
+ .stream_name = "RT3261 PCM1",
.codec_dai_name = "rt3261-aif1",
.init = rockchip_rt3261_init,
.ops = &rockchip_rt3261_hifi_ops,
-#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBM_CFM,
-#else
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBS_CFS,
-#endif
},
{
.name = "RT3261 I2S2",
- .stream_name = "RT3261 PCM",
- .codec_name = "rt3261.0-001c",
- #if defined(CONFIG_SND_RK_SOC_I2S_8CH)
- .cpu_dai_name = "rockchip-i2s.0",
- #elif defined(CONFIG_SND_RK_SOC_I2S_2CH)
- .cpu_dai_name = "rockchip-i2s.1",
- #endif
+ .stream_name = "RT3261 PCM2",
.codec_dai_name = "rt3261-aif2",
.ops = &rockchip_rt3261_voice_ops,
- .no_pcm = 1;
+ .no_pcm = 1,
},
};
.num_links = ARRAY_SIZE(rockchip_rt3261_dai),
};
+/*
+dts:
+ rockchip-rt3261 {
+ compatible = "rockchip-rt3261";
+ dais {
+ dai0 {
+ codec-name = "rt3261.0-001c";
+ cpu-dai-name = "rockchip-i2s.1";
+ format = "i2s";
+ };
+
+ dai1 {
+ codec-name = "rt3261.0-001c";
+ cpu-dai-name = "rockchip-i2s.1";
+ };
+ };
+ };
+*/
static int rockchip_rt3261_audio_probe(struct platform_device *pdev)
{
int ret;
card->dev = &pdev->dev;
- ret = snd_soc_register_card(card);
+ ret = rockchip_of_get_sound_card_info(card);
+ if (ret) {
+ printk("%s() get sound card info failed:%d\n", __FUNCTION__, ret);
+ return ret;
+ }
+ ret = snd_soc_register_card(card);
if (ret)
printk("%s() register card failed:%d\n", __FUNCTION__, ret);
#include <sound/soc-dapm.h>
#include <sound/jack.h>
#include <linux/delay.h>
+#include "card_info.h"
#include "rk_pcm.h"
#include "rk_i2s.h"
#if 1
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;
- unsigned int pll_out = 0;
+ unsigned int pll_out = 0, dai_fmt = cpu_dai->card->dai_link[0].dai_fmt;
unsigned int pll_div;
int ret;
return -EINVAL;
break;
}
-#if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
+ if ((dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) == SND_SOC_DAIFMT_CBM_CFM)
+ goto skip__;
snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0);
snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_BCLK, 64-1);//bclk = 2*32*lrck; 2*32fs
switch(params_rate(params)) {
ret = snd_soc_dai_set_clkdiv(codec_dai, RT5512_CLK_DIV_ID, pll_div*4);
if (ret < 0)
return ret;
-#endif
+skip__:
-#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- //snd_soc_dai_set_pll(codec_dai,0,pll_out, 22579200);
- snd_soc_dai_set_sysclk(codec_dai,0,pll_out, SND_SOC_CLOCK_IN);
-#endif
+ if ((dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) == SND_SOC_DAIFMT_CBM_CFM)
+ snd_soc_dai_set_sysclk(codec_dai,0,pll_out, SND_SOC_CLOCK_IN);
return 0;
}
{ /* Primary DAI i/f */
.name = "RT5512 AIF1",
.stream_name = "RT5512 PCM",
- .cpu_dai_name = "rockchip-i2s.1",
.codec_dai_name = "RT5512-aif1",
- .codec_name = "rt5512.1-0018",
.init = rt5512_init,
.ops = &rk29_ops,
-#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBM_CFM,
-#else
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBS_CFS,
-#endif
},
};
card->dev = &pdev->dev;
- ret = snd_soc_register_card(card);
+ ret = rockchip_of_get_sound_card_info(card);
+ if (ret) {
+ printk("%s() get sound card info failed:%d\n", __FUNCTION__, ret);
+ return ret;
+ }
+ ret = snd_soc_register_card(card);
if (ret)
printk("%s() register card failed:%d\n", __FUNCTION__, ret);
#include <sound/soc-dapm.h>
#include "../codecs/rt5616.h"
+#include "card_info.h"
#include "rk_pcm.h"
#include "rk_i2s.h"
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;
- unsigned int pll_out = 0;
- int ret;
+ unsigned int pll_out = 0, dai_fmt = cpu_dai->card->dai_link[0].dai_fmt;
DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
break;
}
DBG("Enter:%s, %d, rate=%d\n",__FUNCTION__,__LINE__,params_rate(params));
-
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
-#if 0 //use pll from blck
- /*Set the pll of rt5616,the Pll source from BITCLK on CPU is master mode*/
- //bitclk is 64fs
- ret=snd_soc_dai_set_pll(codec_dai,0,params_rate(params)*64,pll_out);
- if (ret < 0)
- {
- DBG("rk29_hw_params_rt5616:failed to set the pll for codec side\n");
- return ret;
- }
-#endif
- /*Set the system clk for codec*/
- ret=snd_soc_dai_set_sysclk(codec_dai, 0,pll_out,SND_SOC_CLOCK_IN);
- if (ret < 0)
- {
- DBG("rk29_hw_params_rt5616:failed to set the sysclk for codec side\n");
- return ret;
- }
- #endif
+ snd_soc_dai_set_sysclk(codec_dai,0,pll_out, SND_SOC_CLOCK_IN);
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
-
- // snd_soc_dai_set_pll(codec_dai,0,pll_out, 22579200);
- snd_soc_dai_set_sysclk(codec_dai,0,pll_out, SND_SOC_CLOCK_IN);
-
- #endif
-
-
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0);
- snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_BCLK, (pll_out/4)/params_rate(params)-1);
- snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_MCLK, 3);
- #endif
+ if ((dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) == SND_SOC_DAIFMT_CBS_CFS) {
+ snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0);
+ snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_BCLK, (pll_out/4)/params_rate(params)-1);
+ snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_MCLK, 3);
+ }
DBG("Enter:%s, %d, LRCK=%d\n",__FUNCTION__,__LINE__,(pll_out/4)/params_rate(params));
static struct snd_soc_dai_link rk29_dai = {
.name = "rt5616",
.stream_name = "rt5616 PCM",
- .codec_name = "rt5616.0-001b",
-#if defined(CONFIG_SND_RK_SOC_I2S_8CH)
- .cpu_dai_name = "rockchip-i2s.0",
-#elif defined(CONFIG_SND_RK_SOC_I2S_2CH)
- .cpu_dai_name = "rockchip-i2s.1",
-#else
- .cpu_dai_name = "rockchip-i2s.2",
-#endif
.codec_dai_name = "rt5616-aif1",
.init = rk29_rt5616_init,
.ops = &rk29_ops,
-#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBM_CFM,
-#else
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBS_CFS,
-#endif
};
static struct snd_soc_card rockchip_rt5616_snd_card = {
card->dev = &pdev->dev;
- ret = snd_soc_register_card(card);
+ ret = rockchip_of_get_sound_card_info(card);
+ if (ret) {
+ printk("%s() get sound card info failed:%d\n", __FUNCTION__, ret);
+ return ret;
+ }
+ ret = snd_soc_register_card(card);
if (ret)
printk("%s() register card failed:%d\n", __FUNCTION__, ret);
#include <sound/soc-dapm.h>
#include "../codecs/rt5621.h"
+#include "card_info.h"
#include "rk_pcm.h"
#include "rk_i2s.h"
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;
- unsigned int pll_out = 0;
+ unsigned int pll_out = 0, dai_fmt = cpu_dai->card->dai_link[0].dai_fmt;
unsigned int lrclk = 0;
int ret;
}
DBG("Enter:%s, %d, rate=%d\n",__FUNCTION__,__LINE__,params_rate(params));
-#if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
-#if 0 //use pll from blck
- /*Set the pll of rt5621,the Pll source from BITCLK on CPU is master mode*/
- //bitclk is 64fs
- ret=snd_soc_dai_set_pll(codec_dai,RT5621_PLL_FR_BCLK,params_rate(params)*64,pll_out);
- if (ret < 0) {
- DBG("rk29_hw_params_rt5621:failed to set the pll for codec side\n");
- return ret;
+ if ((dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) == SND_SOC_DAIFMT_CBM_CFM) {
+
+ if((24576000%params_rate(params))==0) //for 8k,16k,32k,48k
+ {
+ snd_soc_dai_set_pll(codec_dai,RT5621_PLL_FR_MCLK,pll_out, 24576000);
+ snd_soc_dai_set_sysclk(codec_dai,0, 24576000, SND_SOC_CLOCK_IN);
+ }
+ else if((22579200%params_rate(params))==0) //for 11k,22k,44k
+ {
+ snd_soc_dai_set_pll(codec_dai,RT5621_PLL_FR_MCLK,pll_out, 22579200);
+ snd_soc_dai_set_sysclk(codec_dai,0, 22579200, SND_SOC_CLOCK_IN);
+ }
}
-#endif
- /*Set the system clk for codec*/
- ret=snd_soc_dai_set_sysclk(codec_dai, 0,pll_out,SND_SOC_CLOCK_IN);
- if (ret < 0) {
- DBG("rk29_hw_params_rt5621:failed to set the sysclk for codec side\n");
- return ret;
- }
-#endif
-
-
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- if((24576000%params_rate(params))==0) //for 8k,16k,32k,48k
- {
- snd_soc_dai_set_pll(codec_dai,RT5621_PLL_FR_MCLK,pll_out, 24576000);
- snd_soc_dai_set_sysclk(codec_dai,0, 24576000, SND_SOC_CLOCK_IN);
- }
- else if((22579200%params_rate(params))==0) //for 11k,22k,44k
- {
- snd_soc_dai_set_pll(codec_dai,RT5621_PLL_FR_MCLK,pll_out, 22579200);
- snd_soc_dai_set_sysclk(codec_dai,0, 22579200, SND_SOC_CLOCK_IN);
- }
-
-#endif
+ if ((dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) == SND_SOC_DAIFMT_CBS_CFS) {
+ /*Set the system clk for codec*/
+ ret=snd_soc_dai_set_sysclk(codec_dai, 0,pll_out,SND_SOC_CLOCK_IN);
+ if (ret < 0) {
+ DBG("rk29_hw_params_rt5621:failed to set the sysclk for codec side\n");
+ return ret;
+ }
-#if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0);
- snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_BCLK, (pll_out/4)/params_rate(params)-1);
- snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_MCLK, 3);
-#endif
+ snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0);
+ snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_BCLK, (pll_out/4)/params_rate(params)-1);
+ snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_MCLK, 3);
+ }
DBG("Enter:%s, %d, LRCK=%d\n",__FUNCTION__,__LINE__,(pll_out/4)/params_rate(params));
static struct snd_soc_dai_link rk29_dai = {
.name = "RT5621",
.stream_name = "RT5621 PCM",
- .codec_name = "RT5621.0-001a",
- .cpu_dai_name = "rockchip-i2s.0",
.codec_dai_name = "RT5621 HiFi",
.init = rk29_rt5621_init,
.ops = &rk29_ops,
-#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBM_CFM,
-#else
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBS_CFS,
-#endif
};
static struct snd_soc_card rockchip_rt5621_snd_card = {
card->dev = &pdev->dev;
- ret = snd_soc_register_card(card);
+ ret = rockchip_of_get_sound_card_info(card);
+ if (ret) {
+ printk("%s() get sound card info failed:%d\n", __FUNCTION__, ret);
+ return ret;
+ }
+ ret = snd_soc_register_card(card);
if (ret)
printk("%s() register card failed:%d\n", __FUNCTION__, ret);
#include <sound/soc-dapm.h>\r
\r
#include "../codecs/rt5625.h"\r
+#include "card_info.h"\r
#include "rk_pcm.h"\r
#include "rk_i2s.h"\r
\r
{\r
.name = "RT5625 I2S1",\r
.stream_name = "RT5625 PCM",\r
- .codec_name = "rt5625.0-001f",\r
- .cpu_dai_name = "rockchip-i2s.0",\r
.codec_dai_name = "rt5625-aif1",\r
.ops = &rk29_ops,\r
-#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)\r
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |\r
- SND_SOC_DAIFMT_CBM_CFM,\r
-#else\r
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |\r
- SND_SOC_DAIFMT_CBS_CFS,\r
-#endif\r
},\r
{\r
.name = "RT5625 I2S2",\r
.stream_name = "RT5625 PCM",\r
- .codec_name = "rt5625.0-001f",\r
- .cpu_dai_name = "rockchip-i2s.0",\r
.codec_dai_name = "rt5625-aif2",\r
.ops = &rt5625_voice_ops,\r
},\r
\r
card->dev = &pdev->dev;\r
\r
- ret = snd_soc_register_card(card);\r
+ ret = rockchip_of_get_sound_card_info(card);
+ if (ret) {
+ printk("%s() get sound card info failed:%d\n", __FUNCTION__, ret);
+ return ret;
+ }\r
\r
+ ret = snd_soc_register_card(card);\r
if (ret)\r
printk("%s() register card failed:%d\n", __FUNCTION__, ret);\r
\r
#include <sound/soc.h>
#include <sound/soc-dapm.h>
-#include "../codecs/rt5631.h"
+#include "card_info.h"
#include "rk_pcm.h"
#include "rk_i2s.h"
-#ifdef CONFIG_MACH_RK_FAC
-#include <plat/config.h>
-extern int codec_type;
-#endif
#if 0
#define DBG(x...) printk(KERN_INFO x)
#else
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;
- unsigned int pll_out = 0;
+ unsigned int pll_out = 0, dai_fmt = cpu_dai->card->dai_link[0].dai_fmt;
int ret;
DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
return -EINVAL;
break;
}
-#if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
+
snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0);
+
+ /*Set the system clk for codec*/
+ ret=snd_soc_dai_set_sysclk(codec_dai, 0,pll_out,SND_SOC_CLOCK_IN);
+ if (ret < 0)
+ {
+ DBG("rk29_hw_params_rt5631:failed to set the sysclk for codec side\n");
+ return ret;
+ }
+
+ //Codec is master, so is not need to set clkdiv for cpu.
+ if ((dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) == SND_SOC_DAIFMT_CBM_CFM)
+ return 0;
+
snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_BCLK, 64-1);//bclk = 2*32*lrck; 2*32fs
switch(params_rate(params)) {
case 176400:
DBG("default:%s, %d, MCLK=%d BCLK=%d LRCK=%d\n",
__FUNCTION__,__LINE__,pll_out,pll_out/4,params_rate(params));
break;
- }
-
-#if 0 //use pll from blck
- /*Set the pll of rt5631,the Pll source from BITCLK on CPU is master mode*/
- //bitclk is 64fs
- ret=snd_soc_dai_set_pll(codec_dai,0,params_rate(params)*64,pll_out);
- if (ret < 0)
- {
- DBG("rk29_hw_params_rt5631:failed to set the pll for codec side\n");
- return ret;
- }
-#endif
- /*Set the system clk for codec*/
- ret=snd_soc_dai_set_sysclk(codec_dai, 0,pll_out,SND_SOC_CLOCK_IN);
- if (ret < 0)
- {
- DBG("rk29_hw_params_rt5631:failed to set the sysclk for codec side\n");
- return ret;
- }
-#endif
+ }
-#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- //snd_soc_dai_set_pll(codec_dai,0,pll_out, 22579200);
- snd_soc_dai_set_sysclk(codec_dai,0,pll_out, SND_SOC_CLOCK_IN);
-#endif
return 0;
}
static struct snd_soc_dai_link rk29_dai = {
.name = "rt5631",
.stream_name = "rt5631 PCM",
- .codec_name = "rt5631.0-001a",
-#if defined(CONFIG_SND_RK_SOC_I2S_8CH)
- .cpu_dai_name = "rockchip-i2s.0",
-#elif defined(CONFIG_SND_RK_SOC_I2S_2CH)
- .cpu_dai_name = "rockchip-i2s.1",
-#else
- .cpu_dai_name = "rockchip-i2s.2",
-#endif
.codec_dai_name = "rt5631-hifi",
.init = rk29_rt5631_init,
.ops = &rk29_ops,
-#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBM_CFM,
-#else
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBS_CFS,
-#endif
};
static struct snd_soc_card rockchip_rt5631_snd_card = {
card->dev = &pdev->dev;
- ret = snd_soc_register_card(card);
+ ret = rockchip_of_get_sound_card_info(card);
+ if (ret) {
+ printk("%s() get sound card info failed:%d\n", __FUNCTION__, ret);
+ return ret;
+ }
+ ret = snd_soc_register_card(card);
if (ret)
printk("%s() register card failed:%d\n", __FUNCTION__, ret);
#include <sound/soc.h>
#include <sound/soc-dapm.h>
#include "../codecs/rt5631_phone.h"
+#include "card_info.h"
#include "rk_pcm.h"
#include "rk_i2s.h"
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;
- unsigned int pll_out = 0;
+ unsigned int pll_out = 0, dai_fmt = cpu_dai->card->dai_link[0].dai_fmt;
int ret;
DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
DBG("Enter:%s, %d, rate=%d\n",__FUNCTION__,__LINE__,params_rate(params));
snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0);
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- /*Set the system clk for codec*/
- ret=snd_soc_dai_set_sysclk(codec_dai, 0,pll_out,SND_SOC_CLOCK_IN);
- if (ret < 0)
- {
- DBG("rk29_hw_params_rt5631:failed to set the sysclk for codec side\n");
- return ret;
- }
- snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_BCLK, (pll_out/4)/params_rate(params)-1);
- snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_MCLK, 3);
- #endif
+ if ((dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) == SND_SOC_DAIFMT_CBS_CFS) {
+ /*Set the system clk for codec*/
+ ret=snd_soc_dai_set_sysclk(codec_dai, 0,pll_out,SND_SOC_CLOCK_IN);
+ if (ret < 0)
+ {
+ DBG("rk29_hw_params_rt5631:failed to set the sysclk for codec side\n");
+ return ret;
+ }
+ snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_BCLK, (pll_out/4)/params_rate(params)-1);
+ snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_MCLK, 3);
+ }
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- snd_soc_dai_set_sysclk(codec_dai,0,pll_out, SND_SOC_CLOCK_IN);
- #endif
+ if ((dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) == SND_SOC_DAIFMT_CBM_CFM)
+ snd_soc_dai_set_sysclk(codec_dai,0,pll_out, SND_SOC_CLOCK_IN);
DBG("Enter:%s, %d, LRCK=%d\n",__FUNCTION__,__LINE__,(pll_out/4)/params_rate(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;
- unsigned int pll_out = 0;
+ unsigned int pll_out = 0, dai_fmt = cpu_dai->card->dai_link[0].dai_fmt;
int ret;
DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
DBG("Enter:%s, %d, rate=%d\n",__FUNCTION__,__LINE__,params_rate(params));
snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0);
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
- /*Set the system clk for codec*/
- ret=snd_soc_dai_set_sysclk(codec_dai, 0,pll_out,SND_SOC_CLOCK_IN);
- if (ret < 0)
- {
- DBG("rk29_hw_params_rt5631:failed to set the sysclk for codec side\n");
- return ret;
- }
- snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_BCLK, (pll_out/4)/params_rate(params)-1);
- snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_MCLK, 3);
- #endif
+ if ((dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) == SND_SOC_DAIFMT_CBS_CFS) {
+ /*Set the system clk for codec*/
+ ret=snd_soc_dai_set_sysclk(codec_dai, 0,pll_out,SND_SOC_CLOCK_IN);
+ if (ret < 0)
+ {
+ DBG("rk29_hw_params_rt5631:failed to set the sysclk for codec side\n");
+ return ret;
+ }
+ snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_BCLK, (pll_out/4)/params_rate(params)-1);
+ snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_MCLK, 3);
+ }
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- snd_soc_dai_set_sysclk(codec_dai,0,pll_out, SND_SOC_CLOCK_IN);
- #endif
+ if ((dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) == SND_SOC_DAIFMT_CBM_CFM)
+ snd_soc_dai_set_sysclk(codec_dai,0,pll_out, SND_SOC_CLOCK_IN);
DBG("Enter:%s, %d, LRCK=%d\n",__FUNCTION__,__LINE__,(pll_out/4)/params_rate(params));
{
.name = "RT5631 hifi",
.stream_name = "RT5631 hifi stream",
- .codec_name = "RT5631.0-001a",
- #if defined(CONFIG_SND_RK_SOC_I2S_8CH)
- .cpu_dai_name = "rockchip-i2s.0",
- #elif defined(CONFIG_SND_RK_SOC_I2S_2CH)
- .cpu_dai_name = "rockchip-i2s.1",
- #else
- .cpu_dai_name = "rockchip-i2s.2",
- #endif
.codec_dai_name = "RT5631 HiFi",
.init = rk29_rt5631_init,
.ops = &rk29_ops,
-#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBM_CFM,
-#else
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBS_CFS,
-#endif
},
{
.name = "RT5631 voice",
.stream_name = "RT5631 voice stream",
- .codec_name = "RT5631.0-001a",
- #if defined(CONFIG_SND_RK_SOC_I2S_8CH)
- .cpu_dai_name = "rockchip-i2s.0",
- #elif defined(CONFIG_SND_RK_SOC_I2S_2CH)
- .cpu_dai_name = "rockchip-i2s.1",
- #else
- .cpu_dai_name = "rockchip-i2s.2",
- #endif
.codec_dai_name = "rt5631-voice",
.ops = &rk29_ops_voice,
},
card->dev = &pdev->dev;
- ret = snd_soc_register_card(card);
+ ret = rockchip_of_get_sound_card_info(card);
+ if (ret) {
+ printk("%s() get sound card info failed:%d\n", __FUNCTION__, ret);
+ return ret;
+ }
+ ret = snd_soc_register_card(card);
if (ret)
printk("%s() register card failed:%d\n", __FUNCTION__, ret);
#include <sound/soc-dapm.h>\r
\r
#include "../codecs/rt5639.h"\r
+#include "card_info.h"\r
#include "rk_pcm.h"\r
#include "rk_i2s.h"\r
\r
{\r
.name = "RT5639 I2S1",\r
.stream_name = "RT5639 PCM",\r
- .codec_name = "rt5639.0-001c",\r
- .cpu_dai_name = "rockchip-i2s.0",\r
.codec_dai_name = "rt5639-aif1",\r
.ops = &rk29_ops,\r
-#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)\r
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |\r
- SND_SOC_DAIFMT_CBM_CFM,\r
-#else\r
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |\r
- SND_SOC_DAIFMT_CBS_CFS,\r
-#endif\r
},\r
{\r
.name = "RT5639 I2S2",\r
.stream_name = "RT5639 PCM",\r
- .codec_name = "rt5639.0-001c",\r
- .cpu_dai_name = "rockchip-i2s.0",\r
.codec_dai_name = "rt5639-aif2",\r
.ops = &rt5639_voice_ops,\r
},\r
\r
card->dev = &pdev->dev;\r
\r
- ret = snd_soc_register_card(card);\r
+ ret = rockchip_of_get_sound_card_info(card);
+ if (ret) {
+ printk("%s() get sound card info failed:%d\n", __FUNCTION__, ret);
+ return ret;
+ }\r
\r
+ ret = snd_soc_register_card(card);\r
if (ret)\r
printk("%s() register card failed:%d\n", __FUNCTION__, ret);\r
\r
#include <sound/soc-dapm.h>
#include "../codecs/rt5640.h"
+#include "card_info.h"
#include "rk_pcm.h"
#include "rk_i2s.h"
{
.name = "RT5640 I2S1",
.stream_name = "RT5640 PCM",
- .codec_name = "rt5640.0-001c",
- #if defined(CONFIG_SND_RK_SOC_I2S_8CH)
- .cpu_dai_name = "rockchip-i2s.1",
- #elif defined(CONFIG_SND_RK_SOC_I2S_2CH)
- .cpu_dai_name = "rockchip-i2s.1",
- #endif
.codec_dai_name = "rt5640-aif1",
.init = rk29_rt5640_init,
.ops = &rk29_ops,
-#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBM_CFM,
-#else
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBS_CFS,
-#endif
},
{
.name = "RT5640 I2S2",
.stream_name = "RT5640 PCM",
- .codec_name = "rt5640.0-001c",
- #if defined(CONFIG_SND_RK_SOC_I2S_8CH)
- .cpu_dai_name = "rockchip-i2s.1",
- #elif defined(CONFIG_SND_RK_SOC_I2S_2CH)
- .cpu_dai_name = "rockchip-i2s.1",
- #endif
.codec_dai_name = "rt5640-aif2",
.ops = &rt5640_voice_ops,
},
card->dev = &pdev->dev;
- ret = snd_soc_register_card(card);
+ ret = rockchip_of_get_sound_card_info(card);
+ if (ret) {
+ printk("%s() get sound card info failed:%d\n", __FUNCTION__, ret);
+ return ret;
+ }
+ ret = snd_soc_register_card(card);
if (ret)
printk("%s() register card failed:%d\n", __FUNCTION__, ret);
#include <sound/soc-dapm.h>
#include "../codecs/wm8900.h"
+#include "card_info.h"
#include "rk_pcm.h"
#include "rk_i2s.h"
#include <linux/clk.h>
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;
- unsigned int pll_out = 0;
+ unsigned int pll_out = 0, dai_fmt = cpu_dai->card->dai_link[0].dai_fmt;
int div_bclk,div_mclk;
int ret;
struct clk *general_pll;
//snd_soc_dai_set_pll(codec_dai, NULL, 12000000, pll_out);
snd_soc_dai_set_clkdiv(codec_dai, WM8900_LRCLK_MODE, 0x000);
- #if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- snd_soc_dai_set_clkdiv(codec_dai, WM8900_BCLK_DIV, WM8900_BCLK_DIV_4);
- snd_soc_dai_set_clkdiv(codec_dai, WM8900_DAC_LRCLK,(pll_out/4)/params_rate(params));
- snd_soc_dai_set_clkdiv(codec_dai, WM8900_ADC_LRCLK,(pll_out/4)/params_rate(params));
- #endif
-
- #if defined (CONFIG_SND_RK_CODEC_SOC_SLAVE)
+ if ((dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) == SND_SOC_DAIFMT_CBM_CFM) {
+ snd_soc_dai_set_clkdiv(codec_dai, WM8900_BCLK_DIV, WM8900_BCLK_DIV_4);
+ snd_soc_dai_set_clkdiv(codec_dai, WM8900_DAC_LRCLK,(pll_out/4)/params_rate(params));
+ snd_soc_dai_set_clkdiv(codec_dai, WM8900_ADC_LRCLK,(pll_out/4)/params_rate(params));
+ } else {
general_pll=clk_get(NULL, "general_pll");
if(clk_get_rate(general_pll)>260000000)
{
snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0);
snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_BCLK,div_bclk);
snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_MCLK, div_mclk);
- #endif
+ }
DBG("Enter:%s, %d, LRCK=%d\n",__FUNCTION__,__LINE__,(pll_out/4)/params_rate(params));
return 0;
static struct snd_soc_dai_link rk29_dai = {
.name = "WM8900",
.stream_name = "WM8900 PCM",
- .codec_name = "WM8900.0-001a",
- .cpu_dai_name = "rockchip-i2s.0",
.codec_dai_name = "WM8900 HiFi",
.init = rk29_wm8900_init,
.ops = &rk29_ops,
-#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBM_CFM,
-#else
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBS_CFS,
-#endif
};
static struct snd_soc_card rockchip_wm8900_snd_card = {
card->dev = &pdev->dev;
- ret = snd_soc_register_card(card);
+ ret = rockchip_of_get_sound_card_info(card);
+ if (ret) {
+ printk("%s() get sound card info failed:%d\n", __FUNCTION__, ret);
+ return ret;
+ }
+ ret = snd_soc_register_card(card);
if (ret)
printk("%s() register card failed:%d\n", __FUNCTION__, ret);
#include <sound/soc-dapm.h>
#include "../codecs/wm8988.h"
+#include "card_info.h"
#include "rk_pcm.h"
#include "rk_i2s.h"
static struct snd_soc_dai_link rk29_dai = {
.name = "WM8988",
.stream_name = "WM8988 PCM",
- .codec_name = "WM8988.0-001a",
- .cpu_dai_name = "rockchip-i2s.0",
.codec_dai_name = "WM8988 HiFi",
.init = rk29_wm8988_init,
.ops = &rk29_ops,
-#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBM_CFM,
-#else
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBS_CFS,
-#endif
};
static struct snd_soc_card rockchip_wm8988_snd_card = {
card->dev = &pdev->dev;
- ret = snd_soc_register_card(card);
+ ret = rockchip_of_get_sound_card_info(card);
+ if (ret) {
+ printk("%s() get sound card info failed:%d\n", __FUNCTION__, ret);
+ return ret;
+ }
+ ret = snd_soc_register_card(card);
if (ret)
printk("%s() register card failed:%d\n", __FUNCTION__, ret);
#include <sound/soc-dapm.h>
#include "../codecs/wm8994.h"
+#include "card_info.h"
#include "rk_pcm.h"
#include "rk_i2s.h"
#include <linux/clk.h>
{
.name = "WM8994 I2S1",
.stream_name = "WM8994 PCM",
- .codec_name = "wm8994-codec",
-#if defined(CONFIG_SND_RK_SOC_I2S_8CH)
- .cpu_dai_name = "rockchip-i2s.0",
-#elif defined(CONFIG_SND_RK_SOC_I2S_2CH)
- .cpu_dai_name = "rockchip-i2s.1",
-#endif
.codec_dai_name = "wm8994-aif1",
.ops = &rk29_aif1_ops,
.init = rk29_wm8994_init,
-#if defined (CONFIG_SND_RK_CODEC_SOC_MASTER)
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBM_CFM,
-#else
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBS_CFS,
-#endif
},
{
.name = "WM8994 I2S2",
.stream_name = "WM8994 PCM",
- .codec_name = "wm8994-codec",
-#if defined(CONFIG_SND_RK_SOC_I2S_8CH)
- .cpu_dai_name = "rockchip-i2s.0",
-#elif defined(CONFIG_SND_RK_SOC_I2S_2CH)
- .cpu_dai_name = "rockchip-i2s.1",
-#endif
.codec_dai_name = "wm8994-aif2",
.ops = &rk29_aif2_ops,
},
card->dev = &pdev->dev;
- ret = snd_soc_register_card(card);
+ ret = rockchip_of_get_sound_card_info(card);
+ if (ret) {
+ printk("%s() get sound card info failed:%d\n", __FUNCTION__, ret);
+ return ret;
+ }
+ ret = snd_soc_register_card(card);
if (ret)
printk("%s() register card failed:%d\n", __FUNCTION__, ret);