audio: Merge code from RSR project [1/2]

PD#SWPL-5495

Problem:
  There is some improvement code on RSR
  project, we need to merge them back to
  trunk.

Solution:
  Merge the code from rsr branch

Verify:
  A113

Change-Id: I0ba11c8ff412db659ff2f10bfc00d63c49f84bb5
Signed-off-by: yujie.wu <yujie.wu@amlogic.com>

Conflicts:
	sound/soc/amlogic/auge/tdm.c
This commit is contained in:
yujie.wu
2019-03-08 13:51:10 +08:00
committed by Dongjin Kim
parent 0400796f77
commit 4c7fb7757a
4 changed files with 23 additions and 38 deletions

View File

@@ -546,7 +546,7 @@
aml-audio-card,dai-link@2 {
format = "i2s";
mclk-fs = <256>;
//continuous-clock;
continuous-clock;
//bitclock-inversion;
//frame-inversion;
//bitclock-master = <&aml_tdmc>;

View File

@@ -546,7 +546,7 @@
aml-audio-card,dai-link@2 {
format = "i2s";
mclk-fs = <256>;
//continuous-clock;
continuous-clock;
//bitclock-inversion;
//frame-inversion;
//bitclock-master = <&aml_tdmc>;

View File

@@ -516,16 +516,28 @@ void spdifout_samesource_set(int spdif_index, int fifo_id,
int spdifin_get_sample_rate(void)
{
unsigned int val;
/*EE_AUDIO_SPDIFIN_STAT0*/
/*r_width_max bit17:8 (the max width of two edge;)*/
unsigned int max_width = 0;
val = audiobus_read(EE_AUDIO_SPDIFIN_STAT0);
/* NA when check min width of two edges */
if (((val >> 18) & 0x3ff) == 0x3ff)
return 0x7;
return 7;
/*check the max width of two edge when spdifin sr=32kHz*/
/*if max_width is more than 0x2f0(magic number),*/
/*sr(32kHz) is unavailable*/
max_width = ((val >> 8) & 0x3ff);
if ((((val >> 28) & 0x7) == 0) && (max_width == 0x3ff))
return 7;
return (val >> 28) & 0x7;
}
static int spdifin_get_channel_status(int sel)
{
unsigned int val;

View File

@@ -156,35 +156,6 @@ static const struct snd_pcm_hardware aml_tdm_hardware = {
.channels_max = 32,
};
static int tdm_clk_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_dai *cpu_dai = snd_kcontrol_chip(kcontrol);
struct aml_tdm *p_tdm = snd_soc_dai_get_drvdata(cpu_dai);
ucontrol->value.enumerated.item[0] = clk_get_rate(p_tdm->mclk);
return 0;
}
static int tdm_clk_set(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_dai *cpu_dai = snd_kcontrol_chip(kcontrol);
struct aml_tdm *p_tdm = snd_soc_dai_get_drvdata(cpu_dai);
int mclk_rate = p_tdm->last_mclk_freq;
int value = ucontrol->value.enumerated.item[0];
if (value > 2000000 || value < 0) {
pr_err("Fine tdm clk setting range (0~2000000), %d\n", value);
return 0;
}
mclk_rate += (value - 1000000);
aml_dai_set_tdm_sysclk(cpu_dai, 0, mclk_rate, 0);
return 0;
}
static int tdmin_clk_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
@@ -226,14 +197,10 @@ static const struct soc_enum i2sin_clk_enum[] = {
static const struct snd_kcontrol_new snd_tdm_controls[] = {
SOC_ENUM_EXT("I2SIn CLK", i2sin_clk_enum,
tdmin_clk_get,
NULL),
SOC_SINGLE_EXT("TDM MCLK Fine Setting",
0, 0, 2000000, 0,
tdm_clk_get,
tdm_clk_set),
NULL)
};
static irqreturn_t aml_tdm_ddr_isr(int irq, void *devid)
{
struct snd_pcm_substream *substream = (struct snd_pcm_substream *)devid;
@@ -1194,8 +1161,14 @@ static int aml_dai_set_tdm_slot(struct snd_soc_dai *cpu_dai,
static int aml_dai_tdm_probe(struct snd_soc_dai *cpu_dai)
{
int ret = 0;
struct aml_tdm *p_tdm = snd_soc_dai_get_drvdata(cpu_dai);
ret = snd_soc_add_dai_controls(cpu_dai, snd_tdm_controls,
ARRAY_SIZE(snd_tdm_controls));
if (ret < 0)
pr_err("%s, failed add snd spdif controls\n", __func__);
/* config ddr arb */
aml_tdm_arb_config(p_tdm->actrl);