ASoC: Add support for DAC PCM1789
v2 cover ASoC: Add support for DAC PCM1789
Hello everyone,
The current series is the second version to add the support of Texas Instrument's DAC PCM1789. This DAC is very minimalist and does not have many registers.
It is important to notice that this DAC needs to always have clocks enabled (even without any data) otherwise it will be in a "desynchronized" state and can not send data correctly.
This issue has been solved by performing a reset each time a sound is played. This reset can produce a "pop" noise.
Depending on your DAI, you will need to provide and enable the MCLK to be able to communicate with this codec throught i2c.
Changes since v1:
- Create a new file to support pcm1789 instead of converting the existing pcm179x driver. All the patches are merged into one patch.
- Update the code to use gpiod for the reset.
- Add some fixes according to Thomas Petazzoni's reviews
- Create a new patch to add device-tree bindings for this new DAC.
Thank you in advance for any review.
Best regards,
Mylène
Mylène Josserand (2):
ASoC: codecs: Add support for PCM1789
ASoC: Add bindings for PCM1789
.../devicetree/bindings/sound/pcm1789.txt | 21 ++ sound/soc/codecs/Kconfig | 12 + sound/soc/codecs/Makefile | 4 + sound/soc/codecs/pcm1789-i2c.c | 76 ++++++ sound/soc/codecs/pcm1789.c | 288 +++++++++++++++++++++ sound/soc/codecs/pcm1789.h | 28 ++ 6 files changed, 429 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/pcm1789.txt create mode 100644 sound/soc/codecs/pcm1789-i2c.c create mode 100644 sound/soc/codecs/pcm1789.c create mode 100644 sound/soc/codecs/pcm1789.h
Signature · 6 lines
2.11.0 _______________________________________________ Alsa-devel mailing list [email protected] http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
PATCH v2 1/2 ASoC: codecs: Add support for PCM1789
Add Texas Instruments's PCM1789 DAC support. It is a simple DAC and does not have many registers.
One particularity about this DAC is that the clocks must be always enabled. Also, an entire software reset is necessary while starting to play a sound otherwise, the clocks are not synchronized (so the DAC is not able to send data).
--- sound/soc/codecs/Kconfig | 12 ++ sound/soc/codecs/Makefile | 4 + sound/soc/codecs/pcm1789-i2c.c | 76 +++++++++++ sound/soc/codecs/pcm1789.c | 288 +++++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/pcm1789.h | 28 ++++ 5 files changed, 408 insertions(+) create mode 100644 sound/soc/codecs/pcm1789-i2c.c create mode 100644 sound/soc/codecs/pcm1789.c create mode 100644 sound/soc/codecs/pcm1789.h
sound/soc/codecs/Kconfig +12 -0
@@ -112,6 +112,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_NAU8825 if I2C select SND_SOC_HDMI_CODEC select SND_SOC_PCM1681 if I2C + select SND_SOC_PCM1789_I2C if I2C select SND_SOC_PCM179X_I2C if I2C select SND_SOC_PCM179X_SPI if SPI_MASTER select SND_SOC_PCM186X_I2C if I2C
@@ -676,6 +677,17 @@ config SND_SOC_PCM1681 tristate "Texas Instruments PCM1681 CODEC" depends on I2C +config SND_SOC_PCM1789 + tristate + +config SND_SOC_PCM1789_I2C + tristate "Texas Instruments PCM1789 CODEC (I2C)" + depends on I2C + select SND_SOC_PCM1789 + help + Enable support for Texas Instruments PCM1789 CODEC. + Select this if your PCM1789 is connected via an I2C bus. + config SND_SOC_PCM179X tristate
sound/soc/codecs/Makefile +4 -0
@@ -108,6 +108,8 @@ snd-soc-nau8824-objs := nau8824.o snd-soc-nau8825-objs := nau8825.o snd-soc-hdmi-codec-objs := hdmi-codec.o snd-soc-pcm1681-objs := pcm1681.o +snd-soc-pcm1789-codec-objs := pcm1789.o +snd-soc-pcm1789-i2c-objs := pcm1789-i2c.o snd-soc-pcm179x-codec-objs := pcm179x.o snd-soc-pcm179x-i2c-objs := pcm179x-i2c.o snd-soc-pcm179x-spi-objs := pcm179x-spi.o
@@ -359,6 +361,8 @@ obj-$(CONFIG_SND_SOC_NAU8825) += snd-soc-nau8825.o obj-$(CONFIG_SND_SOC_HDMI_CODEC) += snd-soc-hdmi-codec.o obj-$(CONFIG_SND_SOC_PCM1681) += snd-soc-pcm1681.o obj-$(CONFIG_SND_SOC_PCM179X) += snd-soc-pcm179x-codec.o +obj-$(CONFIG_SND_SOC_PCM1789_I2C) += snd-soc-pcm1789-i2c.o +obj-$(CONFIG_SND_SOC_PCM1789) += snd-soc-pcm1789-codec.o obj-$(CONFIG_SND_SOC_PCM179X_I2C) += snd-soc-pcm179x-i2c.o obj-$(CONFIG_SND_SOC_PCM179X_SPI) += snd-soc-pcm179x-spi.o obj-$(CONFIG_SND_SOC_PCM186X) += snd-soc-pcm186x.o
sound/soc/codecs/pcm1789-i2c.c new file +76 -0
76 lines not on this page · raw message
sound/soc/codecs/pcm1789.c new file +288 -0
288 lines not on this page · raw message
sound/soc/codecs/pcm1789.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* definitions for PCM1789 +* +* Copyright (c) Bootlin 2018 +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#ifndef __PCM1789_H__ +#define __PCM1789_H__ + +#define PCM1789_FORMATS (SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S24_LE | \ + SNDRV_PCM_FMTBIT_S16_LE) + +extern const struct regmap_config pcm1789_regmap_config; + +int pcm1789_common_init (struct device *dev,struct regmap *regmap); +int pcm1789_common_exit (struct device *dev); + +#endif
Signature · 6 lines
2.11.0 _______________________________________________ Alsa-devel mailing list [email protected] http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Mark Brown
maintainerRe: [PATCH v2 1/2] ASoC: codecs: Add support for PCM1789
sound/soc/codecs/pcm1789-i2c.c line 10
Quoted 13 lines · Mylène Josserand
sound/soc/codecs/pcm1789-i2c.c new file +10
-0@@ -0,0 +1,76 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* PCM1789 ASoC I2C driver +* +* Copyright (c) Bootlin 2018 +* +* Mylène Josserand <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License
Please don't mix C and C++ style comments in a single comment like this
- it looks unintentional. Just use the same style for the whole thing. You also don't need to include all the boilerplate with the SPDX header.
Quoted 11 lines
sound/soc/codecs/pcm1789-i2c.c new file +10
-0+static bool pcm1789_accessible_reg (struct device *dev,unsigned int reg) +{ +return reg >=PCM1789_MUTE_CONTROL && reg <=PCM1789_DAC_VOL_RIGHT ; +} + +static bool pcm1789_writeable_reg (struct device *dev,unsigned int reg) +{ +return pcm1789_accessible_reg (dev, reg); +} +static void pcm1789_work_queue (struct work_struct *work)
sound/soc/codecs/pcm1789-i2c.c
Quoted 10 lines
sound/soc/codecs/pcm1789-i2c.c new file +10
-0+{ +struct pcm1789_private *priv =container_of (work, + struct pcm1789_private, + work); + +/* Perform a software reset to remove codec from desynchronized state */ +if (regmap_update_bits (priv->regmap,PCM1789_MUTE_CONTROL , +0x3 <<PCM1789_MUTE_SRET ,0 ) <0 ) +dev_err (priv->dev,"Error while setting SRET" ); +}
A reset sounds like we'd also need to resync the register map, presumably this is something else? The comment could be clearer.
Re: [PATCH v2 1/2] ASoC: codecs: Add support for PCM1789
Quoted 11 lines · Mark Brown
Quoted 9 lines · Mylène Josserand
sound/soc/codecs/pcm1789-i2c.c new file +6
-0@@ -0,0 +1,76 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* PCM1789 ASoC I2C driver +* +* Copyright (c) Bootlin 2018 +*
Quoted 9 lines
sound/soc/codecs/pcm1789-i2c.c line 10
Quoted 4 lines
sound/soc/codecs/pcm1789-i2c.c new file +4
-0+* Mylène Josserand <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License Please don't mix C and C++ style comments in a single comment like this
- it looks unintentional. Just use the same style for the whole thing. You also don't need to include all the boilerplate with the SPDX header.
I think Linus made it clear that he wants the SPDX header to be a C++ comment, the documentation has:
"
2. Style:
The SPDX license identifier is added in form of a comment. The comment style depends on the file type::
C source: // SPDX-License-Identifier: <SPDX License Expression>
"
I agree the boilerplate should be removed.
Signature · 3 lines
Alexandre Belloni, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
Mark Brown
maintainerRe: [PATCH v2 1/2] ASoC: codecs: Add support for PCM1789
Quoted 8 lines · Alexandre Belloni
Quoted 3 lines · Mark Brown
Please don't mix C and C++ style comments in a single comment like this
- it looks unintentional. Just use the same style for the whole thing. You also don't need to include all the boilerplate with the SPDX header.I think Linus made it clear that he wants the SPDX header to be a C++ comment, the documentation has:
Sure, so make the entire thing a C++ comment then.
Re: [PATCH v2 1/2] ASoC: codecs: Add support for PCM1789
Hello Mark,
Thanks for the review.
Quoted 11 lines · On Mon, 5 Mar 2018 15:59:38 +0000 Mark Brown <[email protected]> wrote:
Quoted 8 lines · Alexandre Belloni
Quoted 3 lines · Mark Brown
Please don't mix C and C++ style comments in a single comment like this
- it looks unintentional. Just use the same style for the whole thing. You also don't need to include all the boilerplate with the SPDX header.I think Linus made it clear that he wants the SPDX header to be a C++ comment, the documentation has:
Sure, so make the entire thing a C++ comment then.
Ok, I saw other drivers with this mix C++/C comment code so I wrote it like this but no problem using only C++ comment.
I will send a v3 with this modification only (except if I have other reviews).
Best regards,
Signature · 7 lines
Mylène Josserand, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering http://bootlin.com _______________________________________________ Alsa-devel mailing list [email protected] http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
PATCH v2 2/2 ASoC: Add bindings for PCM1789
In reply to Mylène JosserandAdd a device-tree binding for Texas Instrument's PCM1789 codec. For the moment, only I2C bus is supported but SPI could be added in future.
--- Documentation/devicetree/bindings/sound/pcm1789.txt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/pcm1789.txt
Documentation/devicetree/bindings/sound/pcm1789.txt new file +21 -0
@@ -0,0 +1,21 @@ +Texas Instruments pcm1789 DT bindings + +This driver supports the I2C bus. + +Required properties: + + - compatible: "ti,pcm1789" + +Required properties on I2C: + + - reg: the I2C address + - reset-gpios: GPIO to control the RESET pin + +Examples: + + codec: pcm1789@4c { + compatible = "ti,pcm1789"; + reg = <0x4c>; + reset-gpios = <&gpio2 14 GPIO_ACTIVE_LOW>; + #sound-dai-cells = <0>; + };
Signature · 1 line
2.11.0
Rob Herring
maintainerRe: [PATCH v2 2/2] ASoC: Add bindings for PCM1789
Quoted 16 lines · Mylène Josserand
Add a device-tree binding for Texas Instrument's PCM1789 codec. For the moment, only I2C bus is supported but SPI could be added in future.
Signed-off-by Mylène Josserand <[email protected]>--- Documentation/devicetree/bindings/sound/pcm1789.txt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/pcm1789.txtDocumentation/devicetree/bindings/sound/pcm1789.txt new file +0
-0
Documentation/devicetree/bindings/sound/pcm1789.txt line 1
Quoted 1 line
Documentation/devicetree/bindings/sound/pcm1789.txt new file +1
-0@@ -0,0 +1,21 @@ +Texas Instruments pcm1789 DT bindings
What function does this device provide?
Documentation/devicetree/bindings/sound/pcm1789.txt line 3
Quoted 2 lines
Documentation/devicetree/bindings/sound/pcm1789.txt new file +2
-0+ +This driver supports the I2C bus.
Bindings describe h/w, not drivers.
Documentation/devicetree/bindings/sound/pcm1789.txt line 16
Quoted 13 lines
Documentation/devicetree/bindings/sound/pcm1789.txt new file +13
-0+ +Required properties: + + - compatible: "ti,pcm1789" + +Required properties on I2C: + + - reg: the I2C address + - reset-gpios: GPIO to control the RESET pin + +Examples: + + codec: pcm1789@4c {
audio-codec@4c
If that's the function...
Quoted 8 lines
Documentation/devicetree/bindings/sound/pcm1789.txt new file +5
-0+ compatible = "ti,pcm1789"; + reg = <0x4c>; + reset-gpios = <&gpio2 14 GPIO_ACTIVE_LOW>; + #sound-dai-cells = <0>; + };Signature · 1 line
2.11.0
Re: [PATCH v2 2/2] ASoC: Add bindings for PCM1789
Hello Rob,
Thank you for the review.
Quoted 11 lines · On Wed, 7 Mar 2018 16:30:48 -0600 Rob Herring <[email protected]> wrote:
Quoted 10 lines · Mylène Josserand
Add a device-tree binding for Texas Instrument's PCM1789 codec. For the moment, only I2C bus is supported but SPI could be added in future.
Signed-off-by Mylène Josserand <[email protected]>--- Documentation/devicetree/bindings/sound/pcm1789.txt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/pcm1789.txt
Quoted 9 lines
Documentation/devicetree/bindings/sound/pcm1789.txt line 1
Quoted 7 lines
Documentation/devicetree/bindings/sound/pcm1789.txt new file +1
-0@@ -0,0 +1,21 @@ +Texas Instruments pcm1789 DT bindingsWhat function does this device provide?
Sorry, I forgot to mention this information.
Quoted 5 lines
Documentation/devicetree/bindings/sound/pcm1789.txt line 3
Quoted 3 lines
Documentation/devicetree/bindings/sound/pcm1789.txt new file +2
-0+ +This driver supports the I2C bus.Bindings describe h/w, not drivers.
True, I will reformulate it.
Quoted 17 lines
Quoted 4 lines
Documentation/devicetree/bindings/sound/pcm1789.txt new file +3
-0+ +Required properties: +Documentation/devicetree/bindings/sound/pcm1789.txt line 16
Quoted 10 lines
Documentation/devicetree/bindings/sound/pcm1789.txt new file +10
-0+ - compatible: "ti,pcm1789" + +Required properties on I2C: + + - reg: the I2C address + - reset-gpios: GPIO to control the RESET pin + +Examples: + + codec: pcm1789@4c {audio-codec@4c
Quoted 1 line
If that's the function...
Yep, I will change that.
Quoted 9 lines
Quoted 9 lines
Documentation/devicetree/bindings/sound/pcm1789.txt new file +5
-0+ compatible = "ti,pcm1789"; + reg = <0x4c>; + reset-gpios = <&gpio2 14 GPIO_ACTIVE_LOW>; + #sound-dai-cells = <0>; + };Signature · 1 line
2.11.0
Thanks,
Best regards,
Signature · 7 lines
Mylène Josserand, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering http://bootlin.com _______________________________________________ Alsa-devel mailing list [email protected] http://mailman.alsa-project.org/mailman/listinfo/alsa-devel