From: Marcus Cooper <[email protected]>
Signed-off-by: Marcus Cooper <[email protected]>
---
sound/soc/sunxi/hdmiaudio/sunxi-hdmiaudio.c | 4 +-
sound/soc/sunxi/hdmiaudio/sunxi-sndhdmi.c | 197 +---------------------------
2 files changed, 5 insertions(+), 196 deletions(-)
diff --git a/sound/soc/sunxi/hdmiaudio/sunxi-hdmiaudio.c
b/sound/soc/sunxi/hdmiaudio/sunxi-hdmiaudio.c
index ced8f47..c3b4beb 100644
--- a/sound/soc/sunxi/hdmiaudio/sunxi-hdmiaudio.c
+++ b/sound/soc/sunxi/hdmiaudio/sunxi-hdmiaudio.c
@@ -480,7 +480,7 @@ static int sunxi_hdmiaudio_resume(struct snd_soc_dai
*cpu_dai)
return 0;
}
-#define SUNXI_I2S_RATES (SNDRV_PCM_RATE_8000_192000 | SNDRV_PCM_RATE_KNOT)
+#define SUNXI_HDMI_RATES (SNDRV_PCM_RATE_8000_192000 | SNDRV_PCM_RATE_KNOT)
static struct snd_soc_dai_ops sunxi_hdmiaudio_dai_ops = {
.trigger = sunxi_hdmiaudio_trigger,
.hw_params = sunxi_hdmiaudio_hw_params,
@@ -496,7 +496,7 @@ static struct snd_soc_dai_driver sunxi_hdmiaudio_dai = {
.playback = {
.channels_min = 1,
.channels_max = 2,
- .rates = SUNXI_I2S_RATES,
+ .rates = SUNXI_HDMI_RATES,
.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE
},
.symmetric_rates = 1,
diff --git a/sound/soc/sunxi/hdmiaudio/sunxi-sndhdmi.c
b/sound/soc/sunxi/hdmiaudio/sunxi-sndhdmi.c
index 2d29ad9..ee62f3c 100644
--- a/sound/soc/sunxi/hdmiaudio/sunxi-sndhdmi.c
+++ b/sound/soc/sunxi/hdmiaudio/sunxi-sndhdmi.c
@@ -26,169 +26,6 @@
#include "sunxi-hdmiaudio.h"
-static struct clk *xtal;
-
-static int clk_users;
-static DEFINE_MUTEX(clk_lock);
-
-#ifdef ENFORCE_RATES
-static struct snd_pcm_hw_constraint_list hw_constraints_rates = {
- .count = ARRAY_SIZE(rates),
- .list = rates,
- .mask = 0,
-};
-#endif
-
-static int sunxi_sndhdmi_startup(struct snd_pcm_substream *substream)
-{
- int ret = 0;
- #ifdef ENFORCE_RATES
- struct snd_pcm_runtime *runtime = substream->runtime;;
- #endif
- mutex_lock(&clk_lock);
- mutex_unlock(&clk_lock);
- if (!ret) {
- #ifdef ENFORCE_RATES
- ret = snd_pcm_hw_constraint_list(runtime, 0,
- SNDRV_PCM_HW_PARAM_RATE,
- &hw_constraints_rates);
- if (ret < 0)
-
- #endif
- }
- return ret;
-}
-
-static void sunxi_sndhdmi_shutdown(struct snd_pcm_substream *substream)
-{
- mutex_lock(&clk_lock);
- clk_users -= 1;
- if (clk_users == 0) {
- clk_put(xtal);
- xtal = NULL;
- }
- mutex_unlock(&clk_lock);
-}
-
-typedef struct __MCLK_SET_INF
-{
- __u32 samp_rate; // sample rate
- __u16 mult_fs; // multiply of smaple rate
-
- __u8 clk_div; // mpll division
- __u8 mpll; // select mpll, 0 - 24.576 Mhz, 1 - 22.5792 Mhz
-
-} __mclk_set_inf;
-
-typedef struct __BCLK_SET_INF
-{
- __u8 bitpersamp; // bits per sample
- __u8 clk_div; // clock division
- __u16 mult_fs; // multiplay of sample rate
-
-} __bclk_set_inf;
-
-//bclk divider table
-static __bclk_set_inf BCLK_INF[] =
-{
- // 16bits per sample
- {16, 4, 128}, {16, 6, 192}, {16, 8, 256},
- {16, 12, 384}, {16, 16, 512},
-
- //24 bits per sample
- {24, 4, 192}, {24, 8, 384}, {24, 16, 768},
-
- //32 bits per sample
- {32, 2, 128}, {32, 4, 256}, {32, 6, 384},
- {32, 8, 512}, {32, 12, 768},
-
- //end flag
- {0xff, 0, 0},
-};
-
-//mclk divider table
-static __mclk_set_inf MCLK_INF[] =
-{
- // 8k bitrate
- { 8000, 128, 24, 0}, { 8000, 192, 16, 0}, { 8000, 256, 12, 0},
- { 8000, 384, 8, 0}, { 8000, 512, 6, 0}, { 8000, 768, 4, 0},
-
- // 16k bitrate
- { 16000, 128, 12, 0}, { 16000, 192, 8, 0}, { 16000, 256, 6, 0},
- { 16000, 384, 4, 0}, { 16000, 768, 2, 0},
-
- // 32k bitrate
- { 32000, 128, 6, 0}, { 32000, 192, 4, 0}, { 32000, 384, 2, 0},
- { 32000, 768, 1, 0},
-
- // 64k bitrate
- { 64000, 192, 2, 0}, { 64000, 384, 1, 0},
-
- //128k bitrate
- {128000, 192, 1, 0},
-
- // 12k bitrate
- { 12000, 128, 16, 0}, { 12000, 256, 8, 0}, { 12000, 512, 4, 0},
-
- // 24k bitrate
- { 24000, 128, 8, 0}, { 24000, 256, 4, 0}, { 24000, 512, 2, 0},
-
- // 48K bitrate
- { 48000, 128, 4, 0}, { 48000, 256, 2, 0}, { 48000, 512, 1, 0},
-
- // 96k bitrate
- { 96000, 128 , 2, 0}, { 96000, 256, 1, 0},
-
- //192k bitrate
- {192000, 128, 1, 0},
-
- //11.025k bitrate
- { 11025, 128, 16, 1}, { 11205, 256, 8, 1}, { 11205, 512, 4, 1},
-
- //22.05k bitrate
- { 22050, 128, 8, 1}, { 22050, 256, 4, 1},
- { 22050, 512, 2, 1},
-
- //44.1k bitrate
- { 44100, 128, 4, 1}, { 44100, 256, 2, 1}, { 44100, 512, 1, 1},
-
- //88.2k bitrate
- { 88200, 128, 2, 1}, { 88200, 256, 1, 1},
-
- //176.4k bitrate
- {176400, 128, 1, 1},
-
- //end flag 0xffffffff
- {0xffffffff, 0, 0, 0},
-};
-
-static s32 get_clock_divder(u32 sample_rate, u32 sample_width, u32 * mclk_div,
- u32* mpll, u32* bclk_div, u32* mult_fs)
-{
- u32 i, j, ret = -EINVAL;
-
- for(i=0; i< 100; i++) {
- if((MCLK_INF[i].samp_rate == sample_rate) &&
- ((MCLK_INF[i].mult_fs == 256) || (MCLK_INF[i].mult_fs
== 128))) {
- for(j=0; j<ARRAY_SIZE(BCLK_INF); j++) {
- if((BCLK_INF[j].bitpersamp ==
sample_width) &&
- (BCLK_INF[j].mult_fs ==
MCLK_INF[i].mult_fs)) {
- //set mclk and bclk division
- *mclk_div =
MCLK_INF[i].clk_div;
- *mpll = MCLK_INF[i].mpll;
- *bclk_div =
BCLK_INF[j].clk_div;
- *mult_fs = MCLK_INF[i].mult_fs;
- ret = 0;
- break;
- }
- }
- }else if(MCLK_INF[i].samp_rate == 0xffffffff)
- break;
- }
-
- return ret;
-}
-
static int sunxi_sndhdmi_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
@@ -196,38 +33,12 @@ static int sunxi_sndhdmi_hw_params(struct
snd_pcm_substream *substream,
struct snd_soc_dai *codec_dai = rtd->codec_dai;
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
int ret = 0;
- unsigned long rate = params_rate(params);
- u32 mclk_div=0, mpll=0, bclk_div=0, mult_fs=0;
-
- get_clock_divder(rate, 32, &mclk_div, &mpll, &bclk_div, &mult_fs);
-
- ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- if (ret < 0)
- return ret;
-
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
- if (ret < 0)
- return ret;
-
- ret = snd_soc_dai_set_sysclk(cpu_dai, 0 , mpll, 0);
- if (ret < 0)
- return ret;
-
- ret = snd_soc_dai_set_sysclk(codec_dai, 0 , mpll, 0);
- if (ret < 0)
- return ret;
-
- ret = snd_soc_dai_set_clkdiv(cpu_dai, SUNXI_DIV_MCLK, mclk_div);
- if (ret < 0)
- return ret;
- ret = snd_soc_dai_set_clkdiv(cpu_dai, SUNXI_DIV_BCLK, bclk_div);
+ ret = snd_soc_dai_set_fmt(codec_dai, 0);
if (ret < 0)
return ret;
- ret = snd_soc_dai_set_clkdiv(codec_dai, 0, mult_fs);
+ ret = snd_soc_dai_set_fmt(cpu_dai, 0);
if (ret < 0)
return ret;
@@ -235,9 +46,7 @@ static int sunxi_sndhdmi_hw_params(struct snd_pcm_substream
*substream,
}
static struct snd_soc_ops sunxi_sndhdmi_ops = {
- .startup = sunxi_sndhdmi_startup,
- .shutdown = sunxi_sndhdmi_shutdown,
- .hw_params = sunxi_sndhdmi_hw_params,
+ .hw_params = sunxi_sndhdmi_hw_params,
};
static struct snd_soc_dai_link sunxi_sndhdmi_dai_link = {
--
1.8.3.2
--
You received this message because you are subscribed to the Google Groups
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.