Add: export start-clock interface in ac101 to simple-card
This commit is contained in:
parent
10e0f12b16
commit
995c17c160
2 changed files with 58 additions and 4 deletions
30
ac101.c
30
ac101.c
|
@ -107,6 +107,7 @@ struct ac10x_priv {
|
||||||
|
|
||||||
struct gpio_desc* gpiod_spk_amp_switch;
|
struct gpio_desc* gpiod_spk_amp_switch;
|
||||||
};
|
};
|
||||||
|
static struct ac10x_priv* static_ac10x;
|
||||||
|
|
||||||
void get_configuration(void)
|
void get_configuration(void)
|
||||||
{
|
{
|
||||||
|
@ -391,9 +392,15 @@ static int late_enable_dac(struct snd_soc_codec* codec, int event) {
|
||||||
ac10x->dac_enable++;
|
ac10x->dac_enable++;
|
||||||
break;
|
break;
|
||||||
case SND_SOC_DAPM_POST_PMD:
|
case SND_SOC_DAPM_POST_PMD:
|
||||||
|
#if 0
|
||||||
if (ac10x->dac_enable > 0){
|
if (ac10x->dac_enable > 0){
|
||||||
ac10x->dac_enable--;
|
ac10x->dac_enable--;
|
||||||
if (ac10x->dac_enable == 0){
|
#else
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
if (ac10x->dac_enable != 0){
|
||||||
|
ac10x->dac_enable = 0;
|
||||||
|
|
||||||
snd_soc_update_bits(codec, DAC_DIG_CTRL, (0x1<<ENHPF),(0x0<<ENHPF));
|
snd_soc_update_bits(codec, DAC_DIG_CTRL, (0x1<<ENHPF),(0x0<<ENHPF));
|
||||||
snd_soc_update_bits(codec, DAC_DIG_CTRL, (0x1<<ENDA), (0x0<<ENDA));
|
snd_soc_update_bits(codec, DAC_DIG_CTRL, (0x1<<ENDA), (0x0<<ENDA));
|
||||||
/*disable dac module clk*/
|
/*disable dac module clk*/
|
||||||
|
@ -518,9 +525,15 @@ static int ac10x_aif1clk(struct snd_soc_codec* codec, int event) {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case SND_SOC_DAPM_POST_PMD:
|
case SND_SOC_DAPM_POST_PMD:
|
||||||
|
#if 0
|
||||||
if (ac10x->aif1_clken > 0){
|
if (ac10x->aif1_clken > 0){
|
||||||
ac10x->aif1_clken--;
|
ac10x->aif1_clken--;
|
||||||
if (ac10x->aif1_clken == 0){
|
if (ac10x->aif1_clken == 0){
|
||||||
|
#else
|
||||||
|
{
|
||||||
|
if (ac10x->aif1_clken != 0) {
|
||||||
|
ac10x->aif1_clken = 0;
|
||||||
|
#endif
|
||||||
/*disable AIF1CLK*/
|
/*disable AIF1CLK*/
|
||||||
snd_soc_update_bits(codec, SYSCLK_CTRL, (0x1<<AIF1CLK_ENA), (0x0<<AIF1CLK_ENA));
|
snd_soc_update_bits(codec, SYSCLK_CTRL, (0x1<<AIF1CLK_ENA), (0x0<<AIF1CLK_ENA));
|
||||||
snd_soc_update_bits(codec, MOD_CLK_ENA, (0x1<<MOD_CLK_AIF1), (0x0<<MOD_CLK_AIF1));
|
snd_soc_update_bits(codec, MOD_CLK_ENA, (0x1<<MOD_CLK_AIF1), (0x0<<MOD_CLK_AIF1));
|
||||||
|
@ -1394,9 +1407,11 @@ static int ac10x_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
|
||||||
reg_val &= ~(0x1<<AIF1_MSTR_MOD);
|
reg_val &= ~(0x1<<AIF1_MSTR_MOD);
|
||||||
switch(fmt & SND_SOC_DAIFMT_MASTER_MASK) {
|
switch(fmt & SND_SOC_DAIFMT_MASTER_MASK) {
|
||||||
case SND_SOC_DAIFMT_CBM_CFM: /* codec clk & frm master, ap is slave*/
|
case SND_SOC_DAIFMT_CBM_CFM: /* codec clk & frm master, ap is slave*/
|
||||||
|
pr_warn("AC101 as Master\n");
|
||||||
reg_val |= (0x0<<AIF1_MSTR_MOD);
|
reg_val |= (0x0<<AIF1_MSTR_MOD);
|
||||||
break;
|
break;
|
||||||
case SND_SOC_DAIFMT_CBS_CFS: /* codec clk & frm slave, ap is master*/
|
case SND_SOC_DAIFMT_CBS_CFS: /* codec clk & frm slave, ap is master*/
|
||||||
|
pr_warn("AC101 as Slave\n");
|
||||||
reg_val |= (0x1<<AIF1_MSTR_MOD);
|
reg_val |= (0x1<<AIF1_MSTR_MOD);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -1405,7 +1420,7 @@ static int ac10x_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Disable TDM mode
|
* Enable TDM mode
|
||||||
*/
|
*/
|
||||||
reg_val |= (0x1 << AIF1_TDMM_ENA);
|
reg_val |= (0x1 << AIF1_TDMM_ENA);
|
||||||
// reg_val &= ~(0x1 << AIF1_TDMM_ENA);
|
// reg_val &= ~(0x1 << AIF1_TDMM_ENA);
|
||||||
|
@ -1559,7 +1574,7 @@ static int ac10x_set_bias_level(struct snd_soc_codec *codec,
|
||||||
/*
|
/*
|
||||||
* due to miss channels order in cpu_dai, we meed defer the clock starting.
|
* due to miss channels order in cpu_dai, we meed defer the clock starting.
|
||||||
*/
|
*/
|
||||||
static void ac10x_work_start_clock(struct work_struct *work) {
|
static void __ac10x_work_start_clock(struct work_struct *work) {
|
||||||
struct ac10x_priv *ac10x = container_of(work, struct ac10x_priv, dlywork.work);
|
struct ac10x_priv *ac10x = container_of(work, struct ac10x_priv, dlywork.work);
|
||||||
|
|
||||||
/* enable global clock */
|
/* enable global clock */
|
||||||
|
@ -1570,6 +1585,12 @@ static void ac10x_work_start_clock(struct work_struct *work) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ac10x_start_clock(void) {
|
||||||
|
ac10x_aif1clk(static_ac10x->codec, SND_SOC_DAPM_PRE_PMU);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(ac10x_start_clock);
|
||||||
|
|
||||||
static int ac10x_trigger(struct snd_pcm_substream *substream, int cmd,
|
static int ac10x_trigger(struct snd_pcm_substream *substream, int cmd,
|
||||||
struct snd_soc_dai *dai)
|
struct snd_soc_dai *dai)
|
||||||
{
|
{
|
||||||
|
@ -1750,7 +1771,7 @@ static int ac10x_codec_probe(struct snd_soc_codec *codec)
|
||||||
}
|
}
|
||||||
ac10x->codec = codec;
|
ac10x->codec = codec;
|
||||||
|
|
||||||
INIT_DELAYED_WORK(&ac10x->dlywork, ac10x_work_start_clock);
|
INIT_DELAYED_WORK(&ac10x->dlywork, __ac10x_work_start_clock);
|
||||||
INIT_WORK(&ac10x->codec_resume, codec_resume_work);
|
INIT_WORK(&ac10x->codec_resume, codec_resume_work);
|
||||||
ac10x->dac_enable = 0;
|
ac10x->dac_enable = 0;
|
||||||
ac10x->adc_enable = 0;
|
ac10x->adc_enable = 0;
|
||||||
|
@ -1884,6 +1905,7 @@ static int ac10x_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
i2c_set_clientdata(i2c, ac10x);
|
i2c_set_clientdata(i2c, ac10x);
|
||||||
|
static_ac10x = ac10x;
|
||||||
|
|
||||||
ac10x->regmap = devm_regmap_init_i2c(i2c, &ac101_regmap);
|
ac10x->regmap = devm_regmap_init_i2c(i2c, &ac101_regmap);
|
||||||
if (IS_ERR(ac10x->regmap)) {
|
if (IS_ERR(ac10x->regmap)) {
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
* it under the terms of the GNU General Public License version 2 as
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
* published by the Free Software Foundation.
|
* published by the Free Software Foundation.
|
||||||
*/
|
*/
|
||||||
|
#undef DEBUG
|
||||||
#include <linux/clk.h>
|
#include <linux/clk.h>
|
||||||
#include <linux/device.h>
|
#include <linux/device.h>
|
||||||
#include <linux/gpio.h>
|
#include <linux/gpio.h>
|
||||||
|
@ -194,10 +195,41 @@ err:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern int ac10x_start_clock(void);
|
||||||
|
|
||||||
|
static int asoc_simple_card_trigger(struct snd_pcm_substream *substream, int cmd)
|
||||||
|
{
|
||||||
|
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
||||||
|
struct simple_card_data *priv = snd_soc_card_get_drvdata(rtd->card);
|
||||||
|
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
printk("%s() stream=%d cmd=%d\n",
|
||||||
|
__FUNCTION__, substream->stream, cmd);
|
||||||
|
|
||||||
|
switch (cmd) {
|
||||||
|
case SNDRV_PCM_TRIGGER_START:
|
||||||
|
case SNDRV_PCM_TRIGGER_RESUME:
|
||||||
|
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
|
||||||
|
ac10x_start_clock();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SNDRV_PCM_TRIGGER_STOP:
|
||||||
|
case SNDRV_PCM_TRIGGER_SUSPEND:
|
||||||
|
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ret = -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static struct snd_soc_ops asoc_simple_card_ops = {
|
static struct snd_soc_ops asoc_simple_card_ops = {
|
||||||
.startup = asoc_simple_card_startup,
|
.startup = asoc_simple_card_startup,
|
||||||
.shutdown = asoc_simple_card_shutdown,
|
.shutdown = asoc_simple_card_shutdown,
|
||||||
.hw_params = asoc_simple_card_hw_params,
|
.hw_params = asoc_simple_card_hw_params,
|
||||||
|
.trigger = asoc_simple_card_trigger,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
|
static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
|
||||||
|
|
Loading…
Reference in a new issue