audio: enable pdm module firstly

PD#142470: audio: ensure pdm module enable firstly
1) Ensure pdm clk and module enable firstly
2) add control that hcic shift gain would be fixed with coeff

Change-Id: I9c0dd7cf0e36d2e653c3f593c853f5d14d1dfdcf
Signed-off-by: Xing Wang <xing.wang@amlogic.com>
This commit is contained in:
Xing Wang
2017-06-02 20:32:15 +08:00
committed by Victor Wan
parent 197e4f880d
commit 2342337e4a
3 changed files with 41 additions and 44 deletions

View File

@@ -104,6 +104,35 @@ static int aml_pdm_filter_mode_set_enum(
return 0;
}
int pdm_hcic_shift_gain = 1;
static const char *const pdm_hcic_shift_gain_texts[] = {
"keep with coeff",
"shift with -0x4",
};
static const struct soc_enum pdm_hcic_shift_gain_enum =
SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(pdm_hcic_shift_gain_texts),
pdm_hcic_shift_gain_texts);
static int pdm_hcic_shift_gain_get_enum(
struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
ucontrol->value.enumerated.item[0] = pdm_hcic_shift_gain;
return 0;
}
static int pdm_hcic_shift_gain_set_enum(
struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
pdm_hcic_shift_gain = ucontrol->value.enumerated.item[0];
return 0;
}
static int aml_pdm_cntrl_get_reg(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) {
struct soc_mixer_control *mixcntrl =
@@ -158,6 +187,11 @@ static const struct snd_kcontrol_new snd_pdm_controls[] = {
aml_pdm_cntrl_get_reg,
aml_pdm_cntrl_set_reg
),
SOC_ENUM_EXT("HCIC shift gain from coeff",
pdm_hcic_shift_gain_enum,
pdm_hcic_shift_gain_get_enum,
pdm_hcic_shift_gain_set_enum),
};
static irqreturn_t aml_pdm_isr_handler(int irq, void *data)
@@ -497,8 +531,6 @@ static int aml_pdm_dai_prepare(
aml_pdm_filter_ctrl(osr, p_pdm->filter_mode);
}
pr_info("%s\n", __func__);
return 0;
}
@@ -507,7 +539,6 @@ static int aml_pdm_dai_trigger(
struct snd_soc_dai *dai)
{
struct aml_pdm *p_pdm = snd_soc_dai_get_drvdata(dai);
struct aml_audio_controller *actrl = p_pdm->actrl;
pr_info("%s\n", __func__);
@@ -515,11 +546,6 @@ static int aml_pdm_dai_trigger(
case SNDRV_PCM_TRIGGER_START:
case SNDRV_PCM_TRIGGER_RESUME:
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
/* TODO */
if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
aml_pdm_set_clk(actrl, 1);
aml_pdm_enable(actrl, true);
}
if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
dev_info(substream->pcm->card->dev, "pdm capture enable\n");
aml_toddr_enable(p_pdm->tddr, 1);
@@ -529,12 +555,6 @@ static int aml_pdm_dai_trigger(
case SNDRV_PCM_TRIGGER_STOP:
case SNDRV_PCM_TRIGGER_SUSPEND:
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
/* do not disable pdm clk */
/*aml_pdm_set_clk(actrl, 0);*/
aml_pdm_enable(actrl, false);
}
if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
dev_info(substream->pcm->card->dev, "pdm capture enable\n");
aml_toddr_enable(p_pdm->tddr, 0);
@@ -545,7 +565,7 @@ static int aml_pdm_dai_trigger(
return -EINVAL;
}
return 0;
return 0;
}

View File

@@ -25,12 +25,7 @@
#include "iomap.h"
#include "pdm_hw_coeff.c"
void aml_pdm_enable(
struct aml_audio_controller *actrl,
bool is_enalbe)
{
aml_pdm_update_bits(PDM_CTRL, 1 << 31, is_enalbe << 31);
}
extern int pdm_hcic_shift_gain;
void aml_pdm_ctrl(
struct aml_audio_controller *actrl,
@@ -50,8 +45,9 @@ void aml_pdm_ctrl(
aml_pdm_write(PDM_CTRL, 0);
/* must be sure that clk and pdm is enable */
aml_pdm_write(PDM_CTRL,
(0 << 31) |
(1 << 31) |
/* invert the PDM_DCLK or not */
(0 << 30) |
/* output mode: 1: 24bits. 0: 32 bits */
@@ -88,17 +84,6 @@ void aml_pdm_arb_config(struct aml_audio_controller *actrl)
aml_audiobus_write(actrl, EE_AUDIO_ARB_CTRL, 1<<31|0xff<<0);
}
void aml_pdm_set_clk(
struct aml_audio_controller *actrl,
int is_enable)
{
return;
aml_audiobus_update_bits(actrl,
EE_AUDIO_CLK_PDMIN_CTRL0, 1 << 31, is_enable << 31);
aml_audiobus_update_bits(actrl,
EE_AUDIO_CLK_PDMIN_CTRL1, 1 << 31, is_enable << 31);
}
void aml_pdm_set_bclk_ratio(
struct aml_audio_controller *actrl,
int ratio)
@@ -187,9 +172,9 @@ static void aml_pdm_filters_config(int osr,
}
/* TODO: fixed hcic_shift 'cause of Dmic */
#if 0
hcic_shift -= 0x4;
#endif
if (pdm_hcic_shift_gain)
hcic_shift -= 0x4;
hcic_tap_num = 0x0007;
f1_tap_num = lpf1_len;

View File

@@ -19,20 +19,12 @@
#define __AML_PDM_HW_H__
#include "audio_io.h"
extern void aml_pdm_enable(
struct aml_audio_controller *actrl,
bool is_enalbe);
extern void aml_pdm_ctrl(
struct aml_audio_controller *actrl,
int bitdepth, int channels);
extern void aml_pdm_arb_config(struct aml_audio_controller *actrl);
extern void aml_pdm_set_clk(
struct aml_audio_controller *actrl,
int is_enable);
extern void aml_pdm_set_bclk_ratio(
struct aml_audio_controller *actrl,
int ratio);