Created
August 12, 2017 13:04
-
-
Save mizuhiki/822dacd7e98af8da810ba3e3f2da3bb3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/sound/soc/bcm/rpi-proto.c b/sound/soc/bcm/rpi-proto.c | |
index 9db678e..f400467 100644 | |
--- a/sound/soc/bcm/rpi-proto.c | |
+++ b/sound/soc/bcm/rpi-proto.c | |
@@ -38,6 +38,7 @@ static int snd_rpi_proto_startup(struct snd_pcm_substream *substream) | |
return 0; | |
} | |
+#if 0 | |
static int snd_rpi_proto_hw_params(struct snd_pcm_substream *substream, | |
struct snd_pcm_hw_params *params) | |
{ | |
@@ -72,6 +73,54 @@ static struct snd_soc_ops snd_rpi_proto_ops = { | |
.startup = snd_rpi_proto_startup, | |
.hw_params = snd_rpi_proto_hw_params, | |
}; | |
+#endif | |
+ | |
+static int snd_rpi_proto_hw_params(struct snd_pcm_substream *substream, | |
+ struct snd_pcm_hw_params *params) | |
+{ | |
+ /* Changed to do nothing here. Instead, setting BCLK in prepare. */ | |
+ return 0; | |
+} | |
+ | |
+static int snd_rpi_proto_prepare(struct snd_pcm_substream *substream) | |
+{ | |
+ struct snd_pcm_runtime *runtime = substream->runtime; | |
+ struct snd_soc_pcm_runtime *rtd = substream->private_data; | |
+ struct snd_soc_codec *codec = rtd->codec; | |
+ struct snd_soc_dai *codec_dai = rtd->codec_dai; | |
+ struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | |
+ int sysclk = 12288000; /* This is fixed on this board */ | |
+ unsigned int rate = runtime->rate; | |
+ int ratio = (rate == 32000)? 96: (rate == 96000)? 128: 64; | |
+ int ret; | |
+ | |
+ /* dev_info(codec->dev, "prepare rate=%d ratio=%d\n", rate, ratio); */ | |
+ | |
+ /* Set proto bclk */ | |
+ ret = snd_soc_dai_set_bclk_ratio(cpu_dai, ratio); | |
+ if (ret < 0) { | |
+ dev_err(codec->dev, "Failed to set BCLK ratio %d\n", ret); | |
+ return ret; | |
+ } | |
+ | |
+ /* Set proto sysclk */ | |
+ ret = snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_XTAL, | |
+ sysclk, SND_SOC_CLOCK_IN); | |
+ if (ret < 0) { | |
+ dev_err(codec->dev, | |
+ "Failed to set WM8731 SYSCLK: %d\n", ret); | |
+ return ret; | |
+ } | |
+ | |
+ return 0; | |
+} | |
+ | |
+/* machine stream operations */ | |
+static struct snd_soc_ops snd_rpi_proto_ops = { | |
+ .startup = snd_rpi_proto_startup, | |
+ .hw_params = snd_rpi_proto_hw_params, | |
+ .prepare = snd_rpi_proto_prepare, | |
+}; | |
static struct snd_soc_dai_link snd_rpi_proto_dai[] = { | |
{ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment