From 995c17c160dd27461eb2d11de1a59f1c7bcef805 Mon Sep 17 00:00:00 2001 From: "peter.yang" Date: Tue, 30 Jan 2018 19:12:47 +0800 Subject: [PATCH] Add: export start-clock interface in ac101 to simple-card --- ac101.c | 30 ++++++++++++++++++++++++++---- simple-card.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 4 deletions(-) diff --git a/ac101.c b/ac101.c index 812636b..b82b566 100644 --- a/ac101.c +++ b/ac101.c @@ -107,6 +107,7 @@ struct ac10x_priv { struct gpio_desc* gpiod_spk_amp_switch; }; +static struct ac10x_priv* static_ac10x; void get_configuration(void) { @@ -391,9 +392,15 @@ static int late_enable_dac(struct snd_soc_codec* codec, int event) { ac10x->dac_enable++; break; case SND_SOC_DAPM_POST_PMD: + #if 0 if (ac10x->dac_enable > 0){ 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<aif1_clken > 0){ ac10x->aif1_clken--; if (ac10x->aif1_clken == 0){ + #else + { + if (ac10x->aif1_clken != 0) { + ac10x->aif1_clken = 0; + #endif /*disable AIF1CLK*/ snd_soc_update_bits(codec, SYSCLK_CTRL, (0x1<codec, SND_SOC_DAPM_PRE_PMU); + return 0; +} +EXPORT_SYMBOL(ac10x_start_clock); + static int ac10x_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) { @@ -1750,7 +1771,7 @@ static int ac10x_codec_probe(struct snd_soc_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); ac10x->dac_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; } i2c_set_clientdata(i2c, ac10x); + static_ac10x = ac10x; ac10x->regmap = devm_regmap_init_i2c(i2c, &ac101_regmap); if (IS_ERR(ac10x->regmap)) { diff --git a/simple-card.c b/simple-card.c index 618e7f9..2f991bf 100644 --- a/simple-card.c +++ b/simple-card.c @@ -8,6 +8,7 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ +#undef DEBUG #include #include #include @@ -194,10 +195,41 @@ err: 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 = { .startup = asoc_simple_card_startup, .shutdown = asoc_simple_card_shutdown, .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)