[alsa-devel] [PATCH 0/7] Let Atmel use simple-audio-card
Alexandre,
following patchset is sent as a bare minimum I need to use MAX9867 codec in master mode on AT91SAM9G20 based board.
Codec's MCLK is driven by PCK0 and SSC is wired as follows: RK0 <-- BCLK RF0 <-- LRCLK TD0 --> SDIN RD0 <-- SDOUT
Following DT framgment was used:
i2c-gpio-0 { codec: max9867@18 { compatible = "maxim,max9867"; reg = <0x18>; #sound-dai-cells = <0>; }; };
sound { compatible = "simple-audio-card";
pinctrl-names = "default"; pinctrl-0 = <&pinctrl_pck0_as_mck>;
simple-audio-card,name = "simear4-max9867"; simple-audio-card,format = "i2s"; simple-audio-card,bitclock-master = <&codec_dai>; simple-audio-card,frame-master = <&codec_dai>; simple-audio-card,routing = "LINE_IN", "Line In Jack", "Speaker", "HPOUT"; simple-audio-card,widgets = "Line", "Line In Jack", "Speaker", "Speaker";
cpu_dai: simple-audio-card,cpu { sound-dai = <&ssc0>; };
codec_dai: simple-audio-card,codec { sound-dai = <&codec>; clocks = <&pck0>; clock-frequency = <12384000>; }; };
&ssc0 { status = "okay"; pinctrl-0 = <&pinctrl_board_ssc0_tx &pinctrl_ssc0_rx>; atmel,clk-from-rk-pin; #sound-dai-cells = <0>; };
Codec code itself seems to be unused since it was merged and I'm wondering whenever it worked at all. A comment from codec author would help a lot, just to be sure I did not break anything.
By no means this code is ready to be merged (only except those patches with commit log and after carefull consideration :)), I'm posting it as a base for discussion.
Thank you, ladis
Ladislav Michl (7): ASoC: atmel: Remove redundant dev_err() call in probe function ASoC: atmel_ssc_dai: Fix TCMR settings in I2S slave mode ASoC: simple_card_utils: Set clock frequency ASoC: max9867: Show Kconfig entry ASoC: max9867: Calculate LRCLK divider ASoC: max9867: Fix BSEL value in master mode. ASoC: max9867: Take chip out of shutdown
sound/soc/atmel/atmel-classd.c | 7 +-- sound/soc/atmel/atmel-pdmic.c | 7 +-- sound/soc/atmel/atmel_ssc_dai.c | 2 +- sound/soc/codecs/Kconfig | 3 +- sound/soc/codecs/max9867.c | 110 +++------------------------------- sound/soc/generic/simple-card-utils.c | 4 ++ 6 files changed, 19 insertions(+), 114 deletions(-)
There is an error message within devm_ioremap_resource already, so remove the redundant dev_err() call.
Signed-off-by: Ladislav Michl ladis@linux-mips.org --- sound/soc/atmel/atmel-classd.c | 7 ++----- sound/soc/atmel/atmel-pdmic.c | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/sound/soc/atmel/atmel-classd.c b/sound/soc/atmel/atmel-classd.c index ebabed69f0e6..540f0b6a95aa 100644 --- a/sound/soc/atmel/atmel-classd.c +++ b/sound/soc/atmel/atmel-classd.c @@ -580,11 +580,8 @@ static int atmel_classd_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); io_base = devm_ioremap_resource(dev, res); - if (IS_ERR(io_base)) { - ret = PTR_ERR(io_base); - dev_err(dev, "failed to remap register memory: %d\n", ret); - return ret; - } + if (IS_ERR(io_base)) + return PTR_ERR(io_base);
dd->phy_base = res->start;
diff --git a/sound/soc/atmel/atmel-pdmic.c b/sound/soc/atmel/atmel-pdmic.c index 8e3d34be9e69..0729f656f7eb 100644 --- a/sound/soc/atmel/atmel-pdmic.c +++ b/sound/soc/atmel/atmel-pdmic.c @@ -629,11 +629,8 @@ static int atmel_pdmic_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); io_base = devm_ioremap_resource(dev, res); - if (IS_ERR(io_base)) { - ret = PTR_ERR(io_base); - dev_err(dev, "failed to remap register memory: %d\n", ret); - return ret; - } + if (IS_ERR(io_base)) + return PTR_ERR(io_base);
dd->phy_base = res->start;
Hi,
On 30/01/2018 at 12:06:54 +0100, Ladislav Michl wrote:
There is an error message within devm_ioremap_resource already, so remove the redundant dev_err() call.
That one can be sent as-is, don't forget to send to Mark Brown as he is the asoc maintainer.
Signed-off-by: Ladislav Michl ladis@linux-mips.org
sound/soc/atmel/atmel-classd.c | 7 ++----- sound/soc/atmel/atmel-pdmic.c | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/sound/soc/atmel/atmel-classd.c b/sound/soc/atmel/atmel-classd.c index ebabed69f0e6..540f0b6a95aa 100644 --- a/sound/soc/atmel/atmel-classd.c +++ b/sound/soc/atmel/atmel-classd.c @@ -580,11 +580,8 @@ static int atmel_classd_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); io_base = devm_ioremap_resource(dev, res);
- if (IS_ERR(io_base)) {
ret = PTR_ERR(io_base);
dev_err(dev, "failed to remap register memory: %d\n", ret);
return ret;
- }
if (IS_ERR(io_base))
return PTR_ERR(io_base);
dd->phy_base = res->start;
diff --git a/sound/soc/atmel/atmel-pdmic.c b/sound/soc/atmel/atmel-pdmic.c index 8e3d34be9e69..0729f656f7eb 100644 --- a/sound/soc/atmel/atmel-pdmic.c +++ b/sound/soc/atmel/atmel-pdmic.c @@ -629,11 +629,8 @@ static int atmel_pdmic_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); io_base = devm_ioremap_resource(dev, res);
- if (IS_ERR(io_base)) {
ret = PTR_ERR(io_base);
dev_err(dev, "failed to remap register memory: %d\n", ret);
return ret;
- }
if (IS_ERR(io_base))
return PTR_ERR(io_base);
dd->phy_base = res->start;
-- 2.15.1
On 27/02/2018 at 17:54, Alexandre Belloni wrote:
Hi,
On 30/01/2018 at 12:06:54 +0100, Ladislav Michl wrote:
There is an error message within devm_ioremap_resource already, so remove the redundant dev_err() call.
That one can be sent as-is, don't forget to send to Mark Brown as he is the asoc maintainer.
Good, you can add my: Acked-by: Nicolas Ferre nicolas.ferre@microchip.com
Signed-off-by: Ladislav Michl ladis@linux-mips.org
sound/soc/atmel/atmel-classd.c | 7 ++----- sound/soc/atmel/atmel-pdmic.c | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/sound/soc/atmel/atmel-classd.c b/sound/soc/atmel/atmel-classd.c index ebabed69f0e6..540f0b6a95aa 100644 --- a/sound/soc/atmel/atmel-classd.c +++ b/sound/soc/atmel/atmel-classd.c @@ -580,11 +580,8 @@ static int atmel_classd_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); io_base = devm_ioremap_resource(dev, res);
- if (IS_ERR(io_base)) {
ret = PTR_ERR(io_base);
dev_err(dev, "failed to remap register memory: %d\n", ret);
return ret;
- }
if (IS_ERR(io_base))
return PTR_ERR(io_base);
dd->phy_base = res->start;
diff --git a/sound/soc/atmel/atmel-pdmic.c b/sound/soc/atmel/atmel-pdmic.c index 8e3d34be9e69..0729f656f7eb 100644 --- a/sound/soc/atmel/atmel-pdmic.c +++ b/sound/soc/atmel/atmel-pdmic.c @@ -629,11 +629,8 @@ static int atmel_pdmic_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); io_base = devm_ioremap_resource(dev, res);
- if (IS_ERR(io_base)) {
ret = PTR_ERR(io_base);
dev_err(dev, "failed to remap register memory: %d\n", ret);
return ret;
- }
if (IS_ERR(io_base))
return PTR_ERR(io_base);
dd->phy_base = res->start;
-- 2.15.1
The patch
ASoC: atmel: Remove redundant dev_err() call in probe function
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
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
From 1f598e6861ab1d3cc46d6eff155c0a0a6736de38 Mon Sep 17 00:00:00 2001
From: Ladislav Michl ladis@linux-mips.org Date: Thu, 1 Mar 2018 14:37:31 +0100 Subject: [PATCH] ASoC: atmel: Remove redundant dev_err() call in probe function
There is an error message within devm_ioremap_resource already, so remove the redundant dev_err() call.
Signed-off-by: Ladislav Michl ladis@linux-mips.org Acked-by: Nicolas Ferre nicolas.ferre@microchip.com Acked-by: Alexandre Belloni alexandre.belloni@free-electrons.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/atmel/atmel-classd.c | 7 ++----- sound/soc/atmel/atmel-pdmic.c | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/sound/soc/atmel/atmel-classd.c b/sound/soc/atmel/atmel-classd.c index 27bb55ca07ae..709a13221d79 100644 --- a/sound/soc/atmel/atmel-classd.c +++ b/sound/soc/atmel/atmel-classd.c @@ -582,11 +582,8 @@ static int atmel_classd_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); io_base = devm_ioremap_resource(dev, res); - if (IS_ERR(io_base)) { - ret = PTR_ERR(io_base); - dev_err(dev, "failed to remap register memory: %d\n", ret); - return ret; - } + if (IS_ERR(io_base)) + return PTR_ERR(io_base);
dd->phy_base = res->start;
diff --git a/sound/soc/atmel/atmel-pdmic.c b/sound/soc/atmel/atmel-pdmic.c index 5f72baa5f5c7..53217dfac5fe 100644 --- a/sound/soc/atmel/atmel-pdmic.c +++ b/sound/soc/atmel/atmel-pdmic.c @@ -631,11 +631,8 @@ static int atmel_pdmic_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); io_base = devm_ioremap_resource(dev, res); - if (IS_ERR(io_base)) { - ret = PTR_ERR(io_base); - dev_err(dev, "failed to remap register memory: %d\n", ret); - return ret; - } + if (IS_ERR(io_base)) + return PTR_ERR(io_base);
dd->phy_base = res->start;
Signed-off-by: Ladislav Michl ladis@linux-mips.org --- sound/soc/atmel/atmel_ssc_dai.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c index a1e2c5682dcd..8e145487cb18 100644 --- a/sound/soc/atmel/atmel_ssc_dai.c +++ b/sound/soc/atmel/atmel_ssc_dai.c @@ -647,7 +647,7 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream,
tcmr = SSC_BF(TCMR_PERIOD, 0) | SSC_BF(TCMR_STTDLY, START_DELAY) - | SSC_BF(TCMR_START, SSC_START_FALLING_RF) + | SSC_BF(TCMR_START, SSC_START_TX_RX) | SSC_BF(TCMR_CKI, SSC_CKI_FALLING) | SSC_BF(TCMR_CKO, SSC_CKO_NONE) | SSC_BF(TCMR_CKS, ssc->clk_from_rk_pin ?
This one needs a proper git message because it is not obvious what this is fixing.
Also, this doesn't exactly fix salve mode. Instead it is enabled synchronous mode. Maybe we need a new DT property to handle sychronous RX/TX. Probably something like what is done here:
https://elixir.bootlin.com/linux/latest/source/Documentation/devicetree/bind...
But our default would be asynchronous.
On 30/01/2018 at 12:08:10 +0100, Ladislav Michl wrote:
Signed-off-by: Ladislav Michl ladis@linux-mips.org
sound/soc/atmel/atmel_ssc_dai.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c index a1e2c5682dcd..8e145487cb18 100644 --- a/sound/soc/atmel/atmel_ssc_dai.c +++ b/sound/soc/atmel/atmel_ssc_dai.c @@ -647,7 +647,7 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream,
tcmr = SSC_BF(TCMR_PERIOD, 0) | SSC_BF(TCMR_STTDLY, START_DELAY)
| SSC_BF(TCMR_START, SSC_START_FALLING_RF)
| SSC_BF(TCMR_START, SSC_START_TX_RX) | SSC_BF(TCMR_CKI, SSC_CKI_FALLING) | SSC_BF(TCMR_CKO, SSC_CKO_NONE) | SSC_BF(TCMR_CKS, ssc->clk_from_rk_pin ?
-- 2.15.1
On Tue, Feb 27, 2018 at 06:09:21PM +0100, Alexandre Belloni wrote:
This one needs a proper git message because it is not obvious what this is fixing.
And is also incomplete, as all synchronous slave modes need fixing :)
Also, this doesn't exactly fix salve mode. Instead it is enabled synchronous mode. Maybe we need a new DT property to handle sychronous RX/TX. Probably something like what is done here:
https://elixir.bootlin.com/linux/latest/source/Documentation/devicetree/bind...
Thank you for usefull pointer, will send v2.
But our default would be asynchronous.
On 30/01/2018 at 12:08:10 +0100, Ladislav Michl wrote:
Signed-off-by: Ladislav Michl ladis@linux-mips.org
sound/soc/atmel/atmel_ssc_dai.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c index a1e2c5682dcd..8e145487cb18 100644 --- a/sound/soc/atmel/atmel_ssc_dai.c +++ b/sound/soc/atmel/atmel_ssc_dai.c @@ -647,7 +647,7 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream,
tcmr = SSC_BF(TCMR_PERIOD, 0) | SSC_BF(TCMR_STTDLY, START_DELAY)
| SSC_BF(TCMR_START, SSC_START_FALLING_RF)
| SSC_BF(TCMR_START, SSC_START_TX_RX) | SSC_BF(TCMR_CKI, SSC_CKI_FALLING) | SSC_BF(TCMR_CKO, SSC_CKO_NONE) | SSC_BF(TCMR_CKS, ssc->clk_from_rk_pin ?
-- 2.15.1
-- Alexandre Belloni, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
Signed-off-by: Ladislav Michl ladis@linux-mips.org --- sound/soc/generic/simple-card-utils.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index 3751a07de6aa..6b0cadc56933 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -185,6 +185,10 @@ int asoc_simple_card_parse_clk(struct device *dev, */ clk = devm_get_clk_from_child(dev, node, NULL); if (!IS_ERR(clk)) { + if (!of_property_read_u32(node, "clock-frequency", &val)) { + if (clk_set_rate(clk, val)) + dev_err(dev, "failed to set frequency %d\n", val); + } simple_dai->sysclk = clk_get_rate(clk);
asoc_simple_card_clk_register(simple_dai, clk);
On 30/01/2018 at 12:08:45 +0100, Ladislav Michl wrote:
Signed-off-by: Ladislav Michl ladis@linux-mips.org
sound/soc/generic/simple-card-utils.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index 3751a07de6aa..6b0cadc56933 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -185,6 +185,10 @@ int asoc_simple_card_parse_clk(struct device *dev, */ clk = devm_get_clk_from_child(dev, node, NULL); if (!IS_ERR(clk)) {
if (!of_property_read_u32(node, "clock-frequency", &val)) {
if (clk_set_rate(clk, val))
dev_err(dev, "failed to set frequency %d\n", val);
}
This would need to be documented in the simple card bindings but I think you may instead use: assigned-clocks and assigned-clock-rates.
Allow codec to be selected.
Signed-off-by: Ladislav Michl ladis@linux-mips.org --- sound/soc/codecs/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 2b331f7266ab..56542e939a5f 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -615,7 +615,8 @@ config SND_SOC_MAX98504 depends on I2C
config SND_SOC_MAX9867 - tristate + tristate "Maxim MAX9867 CODEC" + depends on I2C
config SND_SOC_MAX98925 tristate
The patch
ASoC: max9867: Show Kconfig entry
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
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
From 3ac9ce8858ae3c6fef308692dc4580c164adc96b Mon Sep 17 00:00:00 2001
From: Ladislav Michl ladis@linux-mips.org Date: Thu, 1 Mar 2018 15:19:23 +0100 Subject: [PATCH] ASoC: max9867: Show Kconfig entry
Allow codec to be selected.
Signed-off-by: Ladislav Michl ladis@linux-mips.org Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/codecs/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 2b331f7266ab..56542e939a5f 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -615,7 +615,8 @@ config SND_SOC_MAX98504 depends on I2C
config SND_SOC_MAX9867 - tristate + tristate "Maxim MAX9867 CODEC" + depends on I2C
config SND_SOC_MAX98925 tristate
Do not limit sample rate to a few precalculated frequencies based on "Common NI Values Table" and put the same equation used to create that table directly in code.
Signed-off-by: Ladislav Michl ladis@linux-mips.org --- sound/soc/codecs/max9867.c | 64 +++------------------------------------------- 1 file changed, 4 insertions(+), 60 deletions(-)
diff --git a/sound/soc/codecs/max9867.c b/sound/soc/codecs/max9867.c index 2f60924fe919..026b7cf94910 100644 --- a/sound/soc/codecs/max9867.c +++ b/sound/soc/codecs/max9867.c @@ -126,75 +126,19 @@ static const struct snd_soc_dapm_route max9867_audio_map[] = { {"LINE_IN", NULL, "Right Line"}, };
-enum rates { - pcm_rate_8, pcm_rate_16, pcm_rate_24, - pcm_rate_32, pcm_rate_44, - pcm_rate_48, max_pcm_rate, -}; - -static const struct ni_div_rates { - u32 mclk; - u16 ni[max_pcm_rate]; -} ni_div[] = { - {11289600, {0x116A, 0x22D4, 0x343F, 0x45A9, 0x6000, 0x687D} }, - {12000000, {0x1062, 0x20C5, 0x3127, 0x4189, 0x5A51, 0x624E} }, - {12288000, {0x1000, 0x2000, 0x3000, 0x4000, 0x5833, 0x6000} }, - {13000000, {0x0F20, 0x1E3F, 0x2D5F, 0x3C7F, 0x535F, 0x5ABE} }, - {19200000, {0x0A3D, 0x147B, 0x1EB8, 0x28F6, 0x3873, 0x3D71} }, - {24000000, {0x1062, 0x20C5, 0x1893, 0x4189, 0x5A51, 0x624E} }, - {26000000, {0x0F20, 0x1E3F, 0x16AF, 0x3C7F, 0x535F, 0x5ABE} }, - {27000000, {0x0E90, 0x1D21, 0x15D8, 0x3A41, 0x5048, 0x5762} }, -}; - -static inline int get_ni_value(int mclk, int rate) -{ - int i, ret = 0; - - /* find the closest rate index*/ - for (i = 0; i < ARRAY_SIZE(ni_div); i++) { - if (ni_div[i].mclk >= mclk) - break; - } - if (i == ARRAY_SIZE(ni_div)) - return -EINVAL; - - switch (rate) { - case 8000: - return ni_div[i].ni[pcm_rate_8]; - case 16000: - return ni_div[i].ni[pcm_rate_16]; - case 32000: - return ni_div[i].ni[pcm_rate_32]; - case 44100: - return ni_div[i].ni[pcm_rate_44]; - case 48000: - return ni_div[i].ni[pcm_rate_48]; - default: - pr_err("%s wrong rate %d\n", __func__, rate); - ret = -EINVAL; - } - return ret; -} - static int max9867_dai_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { struct snd_soc_codec *codec = dai->codec; struct max9867_priv *max9867 = snd_soc_codec_get_drvdata(codec); - unsigned int ni_h, ni_l; - int value; - - value = get_ni_value(max9867->sysclk, params_rate(params)); - if (value < 0) - return value; + unsigned int ni = DIV_ROUND_CLOSEST_ULL(96 * 0x10000 * + (unsigned long long)params_rate(params), max9867->sysclk);
- ni_h = (0xFF00 & value) >> 8; - ni_l = 0x00FF & value; /* set up the ni value */ regmap_update_bits(max9867->regmap, MAX9867_AUDIOCLKHIGH, - MAX9867_NI_HIGH_MASK, ni_h); + MAX9867_NI_HIGH_MASK, (0xFF00 & ni) >> 8); regmap_update_bits(max9867->regmap, MAX9867_AUDIOCLKLOW, - MAX9867_NI_LOW_MASK, ni_l); + MAX9867_NI_LOW_MASK, 0x00FF & ni); if (!max9867->master) { /* * digital pll locks on to any externally supplied LRCLK signal
Signed-off-by: Ladislav Michl ladis@linux-mips.org --- Note: It should be reconsidered where BSEL should be set.
sound/soc/codecs/max9867.c | 43 +++---------------------------------------- 1 file changed, 3 insertions(+), 40 deletions(-)
diff --git a/sound/soc/codecs/max9867.c b/sound/soc/codecs/max9867.c index 026b7cf94910..6272cf5df4a9 100644 --- a/sound/soc/codecs/max9867.c +++ b/sound/soc/codecs/max9867.c @@ -148,46 +148,6 @@ static int max9867_dai_hw_params(struct snd_pcm_substream *substream, MAX9867_RAPID_LOCK, MAX9867_RAPID_LOCK); regmap_update_bits(max9867->regmap, MAX9867_AUDIOCLKHIGH, MAX9867_PLL, MAX9867_PLL); - } else { - unsigned long int bclk_rate, pclk_bclk_ratio; - int bclk_value; - - bclk_rate = params_rate(params) * 2 * params_width(params); - pclk_bclk_ratio = max9867->pclk/bclk_rate; - switch (params_width(params)) { - case 8: - case 16: - switch (pclk_bclk_ratio) { - case 2: - bclk_value = MAX9867_IFC1B_PCLK_2; - break; - case 4: - bclk_value = MAX9867_IFC1B_PCLK_4; - break; - case 8: - bclk_value = MAX9867_IFC1B_PCLK_8; - break; - case 16: - bclk_value = MAX9867_IFC1B_PCLK_16; - break; - default: - dev_err(codec->dev, - "unsupported sampling rate\n"); - return -EINVAL; - } - break; - case 24: - bclk_value = MAX9867_IFC1B_24BIT; - break; - case 32: - bclk_value = MAX9867_IFC1B_32BIT; - break; - default: - dev_err(codec->dev, "unsupported sampling rate\n"); - return -EINVAL; - } - regmap_update_bits(max9867->regmap, MAX9867_IFC1B, - MAX9867_IFC1B_BCLK_MASK, bclk_value); } return 0; } @@ -244,6 +204,9 @@ static int max9867_set_dai_sysclk(struct snd_soc_dai *codec_dai, value &= ~MAX9867_FREQ_MASK; regmap_update_bits(max9867->regmap, MAX9867_SYSCLK, MAX9867_PSCLK_MASK, value); + regmap_update_bits(max9867->regmap, MAX9867_IFC1B, + MAX9867_IFC1B_BCLK_MASK, 0x010); + return 0; }
This also needs a proper commit message.
On 30/01/2018 at 12:10:33 +0100, Ladislav Michl wrote:
Signed-off-by: Ladislav Michl ladis@linux-mips.org
Note: It should be reconsidered where BSEL should be set.
sound/soc/codecs/max9867.c | 43 +++---------------------------------------- 1 file changed, 3 insertions(+), 40 deletions(-)
diff --git a/sound/soc/codecs/max9867.c b/sound/soc/codecs/max9867.c index 026b7cf94910..6272cf5df4a9 100644 --- a/sound/soc/codecs/max9867.c +++ b/sound/soc/codecs/max9867.c @@ -148,46 +148,6 @@ static int max9867_dai_hw_params(struct snd_pcm_substream *substream, MAX9867_RAPID_LOCK, MAX9867_RAPID_LOCK); regmap_update_bits(max9867->regmap, MAX9867_AUDIOCLKHIGH, MAX9867_PLL, MAX9867_PLL);
- } else {
unsigned long int bclk_rate, pclk_bclk_ratio;
int bclk_value;
bclk_rate = params_rate(params) * 2 * params_width(params);
pclk_bclk_ratio = max9867->pclk/bclk_rate;
switch (params_width(params)) {
case 8:
case 16:
switch (pclk_bclk_ratio) {
case 2:
bclk_value = MAX9867_IFC1B_PCLK_2;
break;
case 4:
bclk_value = MAX9867_IFC1B_PCLK_4;
break;
case 8:
bclk_value = MAX9867_IFC1B_PCLK_8;
break;
case 16:
bclk_value = MAX9867_IFC1B_PCLK_16;
break;
default:
dev_err(codec->dev,
"unsupported sampling rate\n");
return -EINVAL;
}
break;
case 24:
bclk_value = MAX9867_IFC1B_24BIT;
break;
case 32:
bclk_value = MAX9867_IFC1B_32BIT;
break;
default:
dev_err(codec->dev, "unsupported sampling rate\n");
return -EINVAL;
}
regmap_update_bits(max9867->regmap, MAX9867_IFC1B,
} return 0;MAX9867_IFC1B_BCLK_MASK, bclk_value);
} @@ -244,6 +204,9 @@ static int max9867_set_dai_sysclk(struct snd_soc_dai *codec_dai, value &= ~MAX9867_FREQ_MASK; regmap_update_bits(max9867->regmap, MAX9867_SYSCLK, MAX9867_PSCLK_MASK, value);
- regmap_update_bits(max9867->regmap, MAX9867_IFC1B,
MAX9867_IFC1B_BCLK_MASK, 0x010);
This magic value has to be defined somewhere.
- return 0;
}
-- 2.15.1
On Tue, Feb 27, 2018 at 06:23:09PM +0100, Alexandre Belloni wrote:
This also needs a proper commit message.
Meanwhile more patches for this driver accumulated, so I'll send simple ones first and those I'm uncertain of later.
Now few questions: - should hw_params emit any error message when asked to set for example unsupported sample rate? Many drivers do so, but it seems strange. - table used in this driver is overkill, frequencies can be calculated directly (patch ready), but that brings question about SNDRV_PCM_RATE_CONTINUOUS: what does it exactly mean? What if codec is able to set "any" rate, but there are rounding errors?
On 30/01/2018 at 12:10:33 +0100, Ladislav Michl wrote:
Signed-off-by: Ladislav Michl ladis@linux-mips.org
Note: It should be reconsidered where BSEL should be set.
sound/soc/codecs/max9867.c | 43 +++---------------------------------------- 1 file changed, 3 insertions(+), 40 deletions(-)
diff --git a/sound/soc/codecs/max9867.c b/sound/soc/codecs/max9867.c index 026b7cf94910..6272cf5df4a9 100644 --- a/sound/soc/codecs/max9867.c +++ b/sound/soc/codecs/max9867.c @@ -148,46 +148,6 @@ static int max9867_dai_hw_params(struct snd_pcm_substream *substream, MAX9867_RAPID_LOCK, MAX9867_RAPID_LOCK); regmap_update_bits(max9867->regmap, MAX9867_AUDIOCLKHIGH, MAX9867_PLL, MAX9867_PLL);
- } else {
unsigned long int bclk_rate, pclk_bclk_ratio;
int bclk_value;
bclk_rate = params_rate(params) * 2 * params_width(params);
pclk_bclk_ratio = max9867->pclk/bclk_rate;
switch (params_width(params)) {
case 8:
case 16:
switch (pclk_bclk_ratio) {
case 2:
bclk_value = MAX9867_IFC1B_PCLK_2;
break;
case 4:
bclk_value = MAX9867_IFC1B_PCLK_4;
break;
case 8:
bclk_value = MAX9867_IFC1B_PCLK_8;
break;
case 16:
bclk_value = MAX9867_IFC1B_PCLK_16;
break;
default:
dev_err(codec->dev,
"unsupported sampling rate\n");
return -EINVAL;
}
break;
case 24:
bclk_value = MAX9867_IFC1B_24BIT;
break;
case 32:
bclk_value = MAX9867_IFC1B_32BIT;
break;
default:
dev_err(codec->dev, "unsupported sampling rate\n");
return -EINVAL;
}
regmap_update_bits(max9867->regmap, MAX9867_IFC1B,
} return 0;MAX9867_IFC1B_BCLK_MASK, bclk_value);
} @@ -244,6 +204,9 @@ static int max9867_set_dai_sysclk(struct snd_soc_dai *codec_dai, value &= ~MAX9867_FREQ_MASK; regmap_update_bits(max9867->regmap, MAX9867_SYSCLK, MAX9867_PSCLK_MASK, value);
- regmap_update_bits(max9867->regmap, MAX9867_IFC1B,
MAX9867_IFC1B_BCLK_MASK, 0x010);
This magic value has to be defined somewhere.
- return 0;
}
-- 2.15.1
-- Alexandre Belloni, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
On 27/02/2018 at 20:03:38 +0100, Ladislav Michl wrote:
On Tue, Feb 27, 2018 at 06:23:09PM +0100, Alexandre Belloni wrote:
This also needs a proper commit message.
Meanwhile more patches for this driver accumulated, so I'll send simple ones first and those I'm uncertain of later.
Now few questions:
- should hw_params emit any error message when asked to set for example unsupported sample rate? Many drivers do so, but it seems strange.
I would thin that is correct because then the eror goes up to userspace and it knows it has to resample.
- table used in this driver is overkill, frequencies can be calculated directly (patch ready), but that brings question about SNDRV_PCM_RATE_CONTINUOUS: what does it exactly mean? What if codec is able to set "any" rate, but there are rounding errors?
That is a good question I can't answer.
On 30/01/2018 at 12:10:33 +0100, Ladislav Michl wrote:
Signed-off-by: Ladislav Michl ladis@linux-mips.org
Note: It should be reconsidered where BSEL should be set.
sound/soc/codecs/max9867.c | 43 +++---------------------------------------- 1 file changed, 3 insertions(+), 40 deletions(-)
diff --git a/sound/soc/codecs/max9867.c b/sound/soc/codecs/max9867.c index 026b7cf94910..6272cf5df4a9 100644 --- a/sound/soc/codecs/max9867.c +++ b/sound/soc/codecs/max9867.c @@ -148,46 +148,6 @@ static int max9867_dai_hw_params(struct snd_pcm_substream *substream, MAX9867_RAPID_LOCK, MAX9867_RAPID_LOCK); regmap_update_bits(max9867->regmap, MAX9867_AUDIOCLKHIGH, MAX9867_PLL, MAX9867_PLL);
- } else {
unsigned long int bclk_rate, pclk_bclk_ratio;
int bclk_value;
bclk_rate = params_rate(params) * 2 * params_width(params);
pclk_bclk_ratio = max9867->pclk/bclk_rate;
switch (params_width(params)) {
case 8:
case 16:
switch (pclk_bclk_ratio) {
case 2:
bclk_value = MAX9867_IFC1B_PCLK_2;
break;
case 4:
bclk_value = MAX9867_IFC1B_PCLK_4;
break;
case 8:
bclk_value = MAX9867_IFC1B_PCLK_8;
break;
case 16:
bclk_value = MAX9867_IFC1B_PCLK_16;
break;
default:
dev_err(codec->dev,
"unsupported sampling rate\n");
return -EINVAL;
}
break;
case 24:
bclk_value = MAX9867_IFC1B_24BIT;
break;
case 32:
bclk_value = MAX9867_IFC1B_32BIT;
break;
default:
dev_err(codec->dev, "unsupported sampling rate\n");
return -EINVAL;
}
regmap_update_bits(max9867->regmap, MAX9867_IFC1B,
} return 0;MAX9867_IFC1B_BCLK_MASK, bclk_value);
} @@ -244,6 +204,9 @@ static int max9867_set_dai_sysclk(struct snd_soc_dai *codec_dai, value &= ~MAX9867_FREQ_MASK; regmap_update_bits(max9867->regmap, MAX9867_SYSCLK, MAX9867_PSCLK_MASK, value);
- regmap_update_bits(max9867->regmap, MAX9867_IFC1B,
MAX9867_IFC1B_BCLK_MASK, 0x010);
This magic value has to be defined somewhere.
- return 0;
}
-- 2.15.1
-- Alexandre Belloni, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
On Wed, Feb 28, 2018 at 11:00:54AM +0100, Alexandre Belloni wrote:
On 27/02/2018 at 20:03:38 +0100, Ladislav Michl wrote:
On Tue, Feb 27, 2018 at 06:23:09PM +0100, Alexandre Belloni wrote:
This also needs a proper commit message.
Meanwhile more patches for this driver accumulated, so I'll send simple ones first and those I'm uncertain of later.
Now few questions:
- should hw_params emit any error message when asked to set for example unsupported sample rate? Many drivers do so, but it seems strange.
I would thin that is correct because then the eror goes up to userspace and it knows it has to resample.
Perhaps I didn't express it clearly enough. I mean all those dev_err(dev, "sunsupported rate\n"); Here only human sitting in realspace is able to react somehow, but I'd say he's only annoyed.
I would expect driver is able to set any rate it is advertising, so returned -EINVAL is considered to be a programming error (which shouldn't clutter kernel log).
- table used in this driver is overkill, frequencies can be calculated directly (patch ready), but that brings question about SNDRV_PCM_RATE_CONTINUOUS: what does it exactly mean? What if codec is able to set "any" rate, but there are rounding errors?
That is a good question I can't answer.
Thank you anyway, hopefully someone else would be able to answer.
Consider patch bellow - with introduced change codec is able to set any rate in master mode (it is an example only, it needs more work), but not any rate will be matched exactly. Of course, for each master clock rate it is possible to compute exact supported rates and advertise them. Is that way forward or is there any trick with SNDRV_PCM_RATE_CONTINUOUS?
Subject: ASoC: max9867: Use continuous sample rate
Drop "Common NI Values Table" and calculate LRCLK divider.
Signed-off-by: Ladislav Michl ladis@linux-mips.org
diff --git a/sound/soc/codecs/max9867.c b/sound/soc/codecs/max9867.c index 0a6bd9f4d00a..d9b81a95a200 100644 --- a/sound/soc/codecs/max9867.c +++ b/sound/soc/codecs/max9867.c @@ -126,75 +126,19 @@ static const struct snd_soc_dapm_route max9867_audio_map[] = { {"LINE_IN", NULL, "Right Line"}, };
-enum rates { - pcm_rate_8, pcm_rate_16, pcm_rate_24, - pcm_rate_32, pcm_rate_44, - pcm_rate_48, max_pcm_rate, -}; - -static const struct ni_div_rates { - u32 mclk; - u16 ni[max_pcm_rate]; -} ni_div[] = { - {11289600, {0x116A, 0x22D4, 0x343F, 0x45A9, 0x6000, 0x687D} }, - {12000000, {0x1062, 0x20C5, 0x3127, 0x4189, 0x5A51, 0x624E} }, - {12288000, {0x1000, 0x2000, 0x3000, 0x4000, 0x5833, 0x6000} }, - {13000000, {0x0F20, 0x1E3F, 0x2D5F, 0x3C7F, 0x535F, 0x5ABE} }, - {19200000, {0x0A3D, 0x147B, 0x1EB8, 0x28F6, 0x3873, 0x3D71} }, - {24000000, {0x1062, 0x20C5, 0x1893, 0x4189, 0x5A51, 0x624E} }, - {26000000, {0x0F20, 0x1E3F, 0x16AF, 0x3C7F, 0x535F, 0x5ABE} }, - {27000000, {0x0E90, 0x1D21, 0x15D8, 0x3A41, 0x5048, 0x5762} }, -}; - -static inline int get_ni_value(int mclk, int rate) -{ - int i, ret = 0; - - /* find the closest rate index*/ - for (i = 0; i < ARRAY_SIZE(ni_div); i++) { - if (ni_div[i].mclk >= mclk) - break; - } - if (i == ARRAY_SIZE(ni_div)) - return -EINVAL; - - switch (rate) { - case 8000: - return ni_div[i].ni[pcm_rate_8]; - case 16000: - return ni_div[i].ni[pcm_rate_16]; - case 32000: - return ni_div[i].ni[pcm_rate_32]; - case 44100: - return ni_div[i].ni[pcm_rate_44]; - case 48000: - return ni_div[i].ni[pcm_rate_48]; - default: - pr_err("%s wrong rate %d\n", __func__, rate); - ret = -EINVAL; - } - return ret; -} - static int max9867_dai_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { struct snd_soc_component *component = dai->component; struct max9867_priv *max9867 = snd_soc_component_get_drvdata(component); - unsigned int ni_h, ni_l; - int value; + unsigned int ni = DIV_ROUND_CLOSEST_ULL(96ULL * 0x10000 * params_rate(params), + max9867->pclk);
- value = get_ni_value(max9867->sysclk, params_rate(params)); - if (value < 0) - return value; - - ni_h = (0xFF00 & value) >> 8; - ni_l = 0x00FF & value; /* set up the ni value */ regmap_update_bits(max9867->regmap, MAX9867_AUDIOCLKHIGH, - MAX9867_NI_HIGH_MASK, ni_h); + MAX9867_NI_HIGH_MASK, (0xFF00 & ni) >> 8); regmap_update_bits(max9867->regmap, MAX9867_AUDIOCLKLOW, - MAX9867_NI_LOW_MASK, ni_l); + MAX9867_NI_LOW_MASK, 0x00FF & ni); if (!max9867->master) { /* * digital pll locks on to any externally supplied LRCLK signal @@ -241,13 +185,13 @@ static int max9867_set_dai_sysclk(struct snd_soc_dai *codec_dai, /* Set the prescaler based on the master clock frequency*/ if (freq >= 10000000 && freq <= 20000000) { value |= MAX9867_PSCLK_10_20; - max9867->pclk = freq; + max9867->pclk = freq; } else if (freq >= 20000000 && freq <= 40000000) { value |= MAX9867_PSCLK_20_40; - max9867->pclk = freq/2; + max9867->pclk = freq / 2; } else if (freq >= 40000000 && freq <= 60000000) { value |= MAX9867_PSCLK_40_60; - max9867->pclk = freq/4; + max9867->pclk = freq / 4; } else { dev_err(component->dev, "Invalid clock frequency %uHz (required 10-60MHz)\n", @@ -322,10 +266,6 @@ static const struct snd_soc_dai_ops max9867_dai_ops = { .hw_params = max9867_dai_hw_params, };
-#define MAX9867_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\ - SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000) -#define MAX9867_FORMATS (SNDRV_PCM_FMTBIT_S16_LE) - static struct snd_soc_dai_driver max9867_dai[] = { { .name = "max9867-aif1", @@ -333,15 +273,19 @@ static struct snd_soc_dai_driver max9867_dai[] = { .stream_name = "HiFi Playback", .channels_min = 1, .channels_max = 2, - .rates = MAX9867_RATES, - .formats = MAX9867_FORMATS, + .rates = SNDRV_PCM_RATE_CONTINUOUS, + .rate_min = 8000, + .rate_max = 48000, + .formats = SNDRV_PCM_FMTBIT_S16_LE, }, .capture = { .stream_name = "HiFi Capture", .channels_min = 1, .channels_max = 2, - .rates = MAX9867_RATES, - .formats = MAX9867_FORMATS, + .rates = SNDRV_PCM_RATE_CONTINUOUS, + .rate_min = 8000, + .rate_max = 48000, + .formats = SNDRV_PCM_FMTBIT_S16_LE, }, .ops = &max9867_dai_ops, }
On 28/02/2018 at 11:23:13 +0100, Ladislav Michl wrote:
On Wed, Feb 28, 2018 at 11:00:54AM +0100, Alexandre Belloni wrote:
On 27/02/2018 at 20:03:38 +0100, Ladislav Michl wrote:
On Tue, Feb 27, 2018 at 06:23:09PM +0100, Alexandre Belloni wrote:
This also needs a proper commit message.
Meanwhile more patches for this driver accumulated, so I'll send simple ones first and those I'm uncertain of later.
Now few questions:
- should hw_params emit any error message when asked to set for example unsupported sample rate? Many drivers do so, but it seems strange.
I would thin that is correct because then the eror goes up to userspace and it knows it has to resample.
Perhaps I didn't express it clearly enough. I mean all those dev_err(dev, "sunsupported rate\n"); Here only human sitting in realspace is able to react somehow, but I'd say he's only annoyed.
I would expect driver is able to set any rate it is advertising, so returned -EINVAL is considered to be a programming error (which shouldn't clutter kernel log).
Ah yes, please feel free to remove the dev_err messages. I also find that they clutter the kernel output needlessly.
- table used in this driver is overkill, frequencies can be calculated directly (patch ready), but that brings question about SNDRV_PCM_RATE_CONTINUOUS: what does it exactly mean? What if codec is able to set "any" rate, but there are rounding errors?
That is a good question I can't answer.
Thank you anyway, hopefully someone else would be able to answer.
Well, Mark is not Cced, you'd have to get his attention somehow ;)
Consider patch bellow - with introduced change codec is able to set any rate in master mode (it is an example only, it needs more work), but not any rate will be matched exactly. Of course, for each master clock rate it is possible to compute exact supported rates and advertise them. Is that way forward or is there any trick with SNDRV_PCM_RATE_CONTINUOUS?
Subject: ASoC: max9867: Use continuous sample rate
Drop "Common NI Values Table" and calculate LRCLK divider.
Signed-off-by: Ladislav Michl ladis@linux-mips.org
diff --git a/sound/soc/codecs/max9867.c b/sound/soc/codecs/max9867.c index 0a6bd9f4d00a..d9b81a95a200 100644 --- a/sound/soc/codecs/max9867.c +++ b/sound/soc/codecs/max9867.c @@ -126,75 +126,19 @@ static const struct snd_soc_dapm_route max9867_audio_map[] = { {"LINE_IN", NULL, "Right Line"}, };
-enum rates {
- pcm_rate_8, pcm_rate_16, pcm_rate_24,
- pcm_rate_32, pcm_rate_44,
- pcm_rate_48, max_pcm_rate,
-};
-static const struct ni_div_rates {
- u32 mclk;
- u16 ni[max_pcm_rate];
-} ni_div[] = {
- {11289600, {0x116A, 0x22D4, 0x343F, 0x45A9, 0x6000, 0x687D} },
- {12000000, {0x1062, 0x20C5, 0x3127, 0x4189, 0x5A51, 0x624E} },
- {12288000, {0x1000, 0x2000, 0x3000, 0x4000, 0x5833, 0x6000} },
- {13000000, {0x0F20, 0x1E3F, 0x2D5F, 0x3C7F, 0x535F, 0x5ABE} },
- {19200000, {0x0A3D, 0x147B, 0x1EB8, 0x28F6, 0x3873, 0x3D71} },
- {24000000, {0x1062, 0x20C5, 0x1893, 0x4189, 0x5A51, 0x624E} },
- {26000000, {0x0F20, 0x1E3F, 0x16AF, 0x3C7F, 0x535F, 0x5ABE} },
- {27000000, {0x0E90, 0x1D21, 0x15D8, 0x3A41, 0x5048, 0x5762} },
-};
-static inline int get_ni_value(int mclk, int rate) -{
- int i, ret = 0;
- /* find the closest rate index*/
- for (i = 0; i < ARRAY_SIZE(ni_div); i++) {
if (ni_div[i].mclk >= mclk)
break;
- }
- if (i == ARRAY_SIZE(ni_div))
return -EINVAL;
- switch (rate) {
- case 8000:
return ni_div[i].ni[pcm_rate_8];
- case 16000:
return ni_div[i].ni[pcm_rate_16];
- case 32000:
return ni_div[i].ni[pcm_rate_32];
- case 44100:
return ni_div[i].ni[pcm_rate_44];
- case 48000:
return ni_div[i].ni[pcm_rate_48];
- default:
pr_err("%s wrong rate %d\n", __func__, rate);
ret = -EINVAL;
- }
- return ret;
-}
static int max9867_dai_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { struct snd_soc_component *component = dai->component; struct max9867_priv *max9867 = snd_soc_component_get_drvdata(component);
- unsigned int ni_h, ni_l;
- int value;
- unsigned int ni = DIV_ROUND_CLOSEST_ULL(96ULL * 0x10000 * params_rate(params),
max9867->pclk);
- value = get_ni_value(max9867->sysclk, params_rate(params));
- if (value < 0)
return value;
- ni_h = (0xFF00 & value) >> 8;
- ni_l = 0x00FF & value; /* set up the ni value */ regmap_update_bits(max9867->regmap, MAX9867_AUDIOCLKHIGH,
MAX9867_NI_HIGH_MASK, ni_h);
regmap_update_bits(max9867->regmap, MAX9867_AUDIOCLKLOW,MAX9867_NI_HIGH_MASK, (0xFF00 & ni) >> 8);
MAX9867_NI_LOW_MASK, ni_l);
if (!max9867->master) { /*MAX9867_NI_LOW_MASK, 0x00FF & ni);
- digital pll locks on to any externally supplied LRCLK signal
@@ -241,13 +185,13 @@ static int max9867_set_dai_sysclk(struct snd_soc_dai *codec_dai, /* Set the prescaler based on the master clock frequency*/ if (freq >= 10000000 && freq <= 20000000) { value |= MAX9867_PSCLK_10_20;
max9867->pclk = freq;
} else if (freq >= 20000000 && freq <= 40000000) { value |= MAX9867_PSCLK_20_40;max9867->pclk = freq;
max9867->pclk = freq/2;
} else if (freq >= 40000000 && freq <= 60000000) { value |= MAX9867_PSCLK_40_60;max9867->pclk = freq / 2;
max9867->pclk = freq/4;
} else { dev_err(component->dev, "Invalid clock frequency %uHz (required 10-60MHz)\n",max9867->pclk = freq / 4;
@@ -322,10 +266,6 @@ static const struct snd_soc_dai_ops max9867_dai_ops = { .hw_params = max9867_dai_hw_params, };
-#define MAX9867_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\
- SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000)
-#define MAX9867_FORMATS (SNDRV_PCM_FMTBIT_S16_LE)
static struct snd_soc_dai_driver max9867_dai[] = { { .name = "max9867-aif1", @@ -333,15 +273,19 @@ static struct snd_soc_dai_driver max9867_dai[] = { .stream_name = "HiFi Playback", .channels_min = 1, .channels_max = 2,
.rates = MAX9867_RATES,
.formats = MAX9867_FORMATS,
.rates = SNDRV_PCM_RATE_CONTINUOUS,
.rate_min = 8000,
.rate_max = 48000,
}, .capture = { .stream_name = "HiFi Capture", .channels_min = 1, .channels_max = 2,.formats = SNDRV_PCM_FMTBIT_S16_LE,
.rates = MAX9867_RATES,
.formats = MAX9867_FORMATS,
.rates = SNDRV_PCM_RATE_CONTINUOUS,
.rate_min = 8000,
.rate_max = 48000,
}, .ops = &max9867_dai_ops, }.formats = SNDRV_PCM_FMTBIT_S16_LE,
Signed-off-by: Ladislav Michl ladis@linux-mips.org --- Note: It would be great to take only used parts of codec out of shutdown and put them to sleep again once unused.
sound/soc/codecs/max9867.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/sound/soc/codecs/max9867.c b/sound/soc/codecs/max9867.c index 6272cf5df4a9..06d11b9f4286 100644 --- a/sound/soc/codecs/max9867.c +++ b/sound/soc/codecs/max9867.c @@ -158,8 +158,7 @@ static int max9867_prepare(struct snd_pcm_substream *substream, struct snd_soc_codec *codec = dai->codec; struct max9867_priv *max9867 = snd_soc_codec_get_drvdata(codec);
- regmap_update_bits(max9867->regmap, MAX9867_PWRMAN, - MAX9867_SHTDOWN_MASK, MAX9867_SHTDOWN_MASK); + regmap_write(max9867->regmap, MAX9867_PWRMAN, 0xff); return 0; }
participants (4)
-
Alexandre Belloni
-
Ladislav Michl
-
Mark Brown
-
Nicolas Ferre