ASoC: nau8822: support master mode
PATCH 1/1 ASoC: nau8822: support master mode
From: David Lin <[email protected]>
The driver selects the proper BCLK divide through the BCLK and FS at the hardware parameter when the I2S master mode.
--- sound/soc/codecs/nau8822.c | 18 ++++++++++++++++++ sound/soc/codecs/nau8822.h | 7 +++++++ 2 files changed, 25 insertions(+)
sound/soc/codecs/nau8822.c +18 -0
@@ -828,6 +828,24 @@ static int nau8822_hw_params(struct snd_pcm_substream *substream,struct snd_soc_component *component = dai->component;struct nau8822 *nau8822 =snd_soc_component_get_drvdata (component);int val_len =0 , val_rate =0 ; +unsigned int ctrl_val, bclk_fs, bclk_div; + +/* make BCLK and LRC divide configuration if the codec as master. */ +snd_soc_component_read (component,NAU8822_REG_CLOCKING , &ctrl_val); +if (ctrl_val &NAU8822_CLK_MASTER ) { +/* get the bclk and fs ratio */ + bclk_fs =snd_soc_params_to_bclk (params) /params_rate (params); +if (bclk_fs <=32 ) + bclk_div =NAU8822_BCLKDIV_8 ; +else if (bclk_fs <=64 ) + bclk_div =NAU8822_BCLKDIV_4 ; +else if (bclk_fs <=128 ) + bclk_div =NAU8822_BCLKDIV_2 ; +else +return -EINVAL ; +snd_soc_component_update_bits (component,NAU8822_REG_CLOCKING , +NAU8822_BCLKSEL_MASK , bclk_div); + }switch (params_format (params)) {case SNDRV_PCM_FORMAT_S16_LE :
sound/soc/codecs/nau8822.h +7 -0
@@ -107,10 +107,17 @@/* NAU8822_REG_CLOCKING (0x6) */ #define NAU8822_CLKIOEN_MASK 0x1 +#define NAU8822_CLK_MASTER 0x1 +#define NAU8822_CLK_SLAVE 0x0#define NAU8822_MCLKSEL_SFT 5#define NAU8822_MCLKSEL_MASK (0x7 << 5)#define NAU8822_BCLKSEL_SFT 2#define NAU8822_BCLKSEL_MASK (0x7 << 2) +#define NAU8822_BCLKDIV_1 (0x0 << 2) +#define NAU8822_BCLKDIV_2 (0x1 << 2) +#define NAU8822_BCLKDIV_4 (0x2 << 2) +#define NAU8822_BCLKDIV_8 (0x3 << 2) +#define NAU8822_BCLKDIV_16 (0x4 << 2)#define NAU8822_CLKM_MASK (0x1 << 8)#define NAU8822_CLKM_MCLK (0x0 << 8)#define NAU8822_CLKM_PLL (0x1 << 8)
Signature · 1 line
2.18.0
Mark Brown
maintainerApplied "ASoC: nau8822: support master mode" to the asoc tree
The patch
ASoC: nau8822: support master mode
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.3
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
2e927ad7981db6765a2a0e8694371e0154b6e820Mon Sep 17 00:00:00 2001
From: David Lin <[email protected]>
Date: Mon, 10 Jun 2019 11:05:23 +0800
Subject: [PATCH] ASoC: nau8822: support master mode
The driver selects the proper BCLK divide through the BCLK and FS at the hardware parameter when the I2S master mode.
--- sound/soc/codecs/nau8822.c | 18 ++++++++++++++++++ sound/soc/codecs/nau8822.h | 7 +++++++ 2 files changed, 25 insertions(+)
sound/soc/codecs/nau8822.c +18 -0
@@ -828,6 +828,24 @@ static int nau8822_hw_params(struct snd_pcm_substream *substream,struct snd_soc_component *component = dai->component;struct nau8822 *nau8822 =snd_soc_component_get_drvdata (component);int val_len =0 , val_rate =0 ; +unsigned int ctrl_val, bclk_fs, bclk_div; + +/* make BCLK and LRC divide configuration if the codec as master. */ +snd_soc_component_read (component,NAU8822_REG_CLOCKING , &ctrl_val); +if (ctrl_val &NAU8822_CLK_MASTER ) { +/* get the bclk and fs ratio */ + bclk_fs =snd_soc_params_to_bclk (params) /params_rate (params); +if (bclk_fs <=32 ) + bclk_div =NAU8822_BCLKDIV_8 ; +else if (bclk_fs <=64 ) + bclk_div =NAU8822_BCLKDIV_4 ; +else if (bclk_fs <=128 ) + bclk_div =NAU8822_BCLKDIV_2 ; +else +return -EINVAL ; +snd_soc_component_update_bits (component,NAU8822_REG_CLOCKING , +NAU8822_BCLKSEL_MASK , bclk_div); + }switch (params_format (params)) {case SNDRV_PCM_FORMAT_S16_LE :
sound/soc/codecs/nau8822.h +7 -0
@@ -107,10 +107,17 @@/* NAU8822_REG_CLOCKING (0x6) */ #define NAU8822_CLKIOEN_MASK 0x1 +#define NAU8822_CLK_MASTER 0x1 +#define NAU8822_CLK_SLAVE 0x0#define NAU8822_MCLKSEL_SFT 5#define NAU8822_MCLKSEL_MASK (0x7 << 5)#define NAU8822_BCLKSEL_SFT 2#define NAU8822_BCLKSEL_MASK (0x7 << 2) +#define NAU8822_BCLKDIV_1 (0x0 << 2) +#define NAU8822_BCLKDIV_2 (0x1 << 2) +#define NAU8822_BCLKDIV_4 (0x2 << 2) +#define NAU8822_BCLKDIV_8 (0x3 << 2) +#define NAU8822_BCLKDIV_16 (0x4 << 2)#define NAU8822_CLKM_MASK (0x1 << 8)#define NAU8822_CLKM_MCLK (0x0 << 8)#define NAU8822_CLKM_PLL (0x1 << 8)
Signature · 1 line
2.20.1