[alsa-devel] [PATCH 1/2] ASoC: pcm3060: Add control for differential output
DAC may be switched between differential and single-ended output.
Signed-off-by: Kirill Marinushkin kmarinushkin@birdec.tech --- sound/soc/codecs/pcm3060.c | 9 +++++++++ sound/soc/codecs/pcm3060.h | 1 + 2 files changed, 10 insertions(+)
diff --git a/sound/soc/codecs/pcm3060.c b/sound/soc/codecs/pcm3060.c index 494d9d662be8..f792ad637ae4 100644 --- a/sound/soc/codecs/pcm3060.c +++ b/sound/soc/codecs/pcm3060.c @@ -179,6 +179,13 @@ static struct snd_soc_dai_driver pcm3060_dai[] = {
/* dapm */
+static const char * const pcm3060_dapm_out_dif_txt[] = { + "Differential", "Single-Ended" +}; + +static SOC_ENUM_SINGLE_DECL(pcm3060_dapm_out_dif_enum, PCM3060_REG64, + PCM3060_REG_SHIFT_SE, pcm3060_dapm_out_dif_txt); + static DECLARE_TLV_DB_SCALE(pcm3060_dapm_tlv, -10050, 50, 1);
static const struct snd_kcontrol_new pcm3060_dapm_controls[] = { @@ -195,6 +202,8 @@ static const struct snd_kcontrol_new pcm3060_dapm_controls[] = { 0, pcm3060_dapm_tlv), SOC_DOUBLE("Master Capture Switch", PCM3060_REG73, PCM3060_REG_SHIFT_MUT11, PCM3060_REG_SHIFT_MUT12, 1, 1), + + SOC_ENUM("DAC Out Differential", pcm3060_dapm_out_dif_enum), };
static const struct snd_soc_dapm_widget pcm3060_dapm_widgets[] = { diff --git a/sound/soc/codecs/pcm3060.h b/sound/soc/codecs/pcm3060.h index fd89a68aa8a7..32080ff00166 100644 --- a/sound/soc/codecs/pcm3060.h +++ b/sound/soc/codecs/pcm3060.h @@ -38,6 +38,7 @@ int pcm3060_remove(struct device *dev); #define PCM3060_REG_ADPSV 0x20 #define PCM3060_REG_DAPSV 0x10 #define PCM3060_REG_SE 0x01 +#define PCM3060_REG_SHIFT_SE 0x00
#define PCM3060_REG65 0x41 #define PCM3060_REG66 0x42
In the initial commit [1], I added differential outputs of the codec as separate `+` and `-` widgets:
OUTL+ OUTR+ OUTL- OUTR-
Later, in the commit [2], I added a control to switch the outputs between differential and single-ended modes. Having this control, the `+` and `-` separation in widgets seems for me confusing. There are no functional benefits in such separation, so I find reasonable to get rid of it:
OUTL OUTR
The new naming is more friendly for sound cards, and is better aligned with other codec drivers in kernel.
Renaming outputs now should not be a problem from the backwards- compatibility perspective, as the driver for PCM3060 is added into the mainline very recently, and did not yet appear in any releases.
[1] commit 6ee47d4a8dac ("ASoC: pcm3060: Add codec driver") [2] commit c33260d09337 ("ASoC: pcm3060: Add control for differential output")
Signed-off-by: Kirill Marinushkin kmarinushkin@birdec.tech --- sound/soc/codecs/pcm3060.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/sound/soc/codecs/pcm3060.c b/sound/soc/codecs/pcm3060.c index f792ad637ae4..078a3b1fc064 100644 --- a/sound/soc/codecs/pcm3060.c +++ b/sound/soc/codecs/pcm3060.c @@ -207,20 +207,16 @@ static const struct snd_kcontrol_new pcm3060_dapm_controls[] = { };
static const struct snd_soc_dapm_widget pcm3060_dapm_widgets[] = { - SND_SOC_DAPM_OUTPUT("OUTL+"), - SND_SOC_DAPM_OUTPUT("OUTR+"), - SND_SOC_DAPM_OUTPUT("OUTL-"), - SND_SOC_DAPM_OUTPUT("OUTR-"), + SND_SOC_DAPM_OUTPUT("OUTL"), + SND_SOC_DAPM_OUTPUT("OUTR"),
SND_SOC_DAPM_INPUT("INL"), SND_SOC_DAPM_INPUT("INR"), };
static const struct snd_soc_dapm_route pcm3060_dapm_map[] = { - { "OUTL+", NULL, "Playback" }, - { "OUTR+", NULL, "Playback" }, - { "OUTL-", NULL, "Playback" }, - { "OUTR-", NULL, "Playback" }, + { "OUTL", NULL, "Playback" }, + { "OUTR", NULL, "Playback" },
{ "Capture", NULL, "INL" }, { "Capture", NULL, "INR" },
Hello Mark,
On 11/05/18 12:20, Mark Brown wrote:
On Mon, Oct 29, 2018 at 09:59:12AM +0100, Kirill Marinushkin wrote:
DAC may be switched between differential and single-ended output.
Isn't this something that'd be better controlled by DT - it's usually going to be part of the board design?
I agree with that. I implemented it as a switch, just because that's how other codec drivers do. In such situations, I prefer to be aligned with already existing code.
Indeed, it's more logical to implement such setup via DT. I will rewrite and send it as patch v2.
Best Regards, Kirill
Output of pcm3060 codec may be configured as single-ended or differential
Signed-off-by: Kirill Marinushkin kmarinushkin@birdec.tech Cc: devicetree@vger.kernel.org --- Documentation/devicetree/bindings/sound/pcm3060.txt | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/Documentation/devicetree/bindings/sound/pcm3060.txt b/Documentation/devicetree/bindings/sound/pcm3060.txt index 90fcb8523099..97de66932d44 100644 --- a/Documentation/devicetree/bindings/sound/pcm3060.txt +++ b/Documentation/devicetree/bindings/sound/pcm3060.txt @@ -9,9 +9,15 @@ Required properties: - reg : the I2C address of the device for I2C, the chip select number for SPI.
+Optional properties: + +- ti,out-single-ended: "true" if output is single-ended; + "false" or not specified if output is differential. + Examples:
pcm3060: pcm3060@46 { compatible = "ti,pcm3060"; reg = <0x46>; + ti,out-single-ended = "true"; };
DAC output may be differential (default) or single-ended.
Signed-off-by: Kirill Marinushkin kmarinushkin@birdec.tech --- sound/soc/codecs/pcm3060.c | 14 ++++++++++++++ sound/soc/codecs/pcm3060.h | 1 + 2 files changed, 15 insertions(+)
diff --git a/sound/soc/codecs/pcm3060.c b/sound/soc/codecs/pcm3060.c index 494d9d662be8..5f479aa61097 100644 --- a/sound/soc/codecs/pcm3060.c +++ b/sound/soc/codecs/pcm3060.c @@ -274,9 +274,23 @@ EXPORT_SYMBOL(pcm3060_regmap);
/* device */
+static void pcm3060_parse_dt(const struct device_node *np, + struct pcm3060_priv *priv) +{ + priv->out_se = of_property_read_bool(np, "ti,out-single-ended"); +} + int pcm3060_probe(struct device *dev) { int rc; + struct pcm3060_priv *priv = dev_get_drvdata(dev); + + if (dev->of_node) + pcm3060_parse_dt(dev->of_node, priv); + + if (priv->out_se) + regmap_update_bits(priv->regmap, PCM3060_REG64, + PCM3060_REG_SE, PCM3060_REG_SE);
rc = devm_snd_soc_register_component(dev, &pcm3060_soc_comp_driver, pcm3060_dai, diff --git a/sound/soc/codecs/pcm3060.h b/sound/soc/codecs/pcm3060.h index fd89a68aa8a7..c895cf40ee10 100644 --- a/sound/soc/codecs/pcm3060.h +++ b/sound/soc/codecs/pcm3060.h @@ -25,6 +25,7 @@ struct pcm3060_priv_dai { struct pcm3060_priv { struct regmap *regmap; struct pcm3060_priv_dai dai[PCM3060_DAI_IDS_NUM]; + u8 out_se: 1; };
int pcm3060_probe(struct device *dev);
The patch
ASoC: pcm3060: Add DT property for single-ended output
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 b1c0000bde8fb287f4fd3493ca4167efee344c3e Mon Sep 17 00:00:00 2001
From: Kirill Marinushkin kmarinushkin@birdec.tech Date: Mon, 12 Nov 2018 08:08:33 +0100 Subject: [PATCH] ASoC: pcm3060: Add DT property for single-ended output
DAC output may be differential (default) or single-ended.
Signed-off-by: Kirill Marinushkin kmarinushkin@birdec.tech Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/codecs/pcm3060.c | 14 ++++++++++++++ sound/soc/codecs/pcm3060.h | 1 + 2 files changed, 15 insertions(+)
diff --git a/sound/soc/codecs/pcm3060.c b/sound/soc/codecs/pcm3060.c index 771b46e1974b..1dd851a7b43b 100644 --- a/sound/soc/codecs/pcm3060.c +++ b/sound/soc/codecs/pcm3060.c @@ -270,9 +270,23 @@ EXPORT_SYMBOL(pcm3060_regmap);
/* device */
+static void pcm3060_parse_dt(const struct device_node *np, + struct pcm3060_priv *priv) +{ + priv->out_se = of_property_read_bool(np, "ti,out-single-ended"); +} + int pcm3060_probe(struct device *dev) { int rc; + struct pcm3060_priv *priv = dev_get_drvdata(dev); + + if (dev->of_node) + pcm3060_parse_dt(dev->of_node, priv); + + if (priv->out_se) + regmap_update_bits(priv->regmap, PCM3060_REG64, + PCM3060_REG_SE, PCM3060_REG_SE);
rc = devm_snd_soc_register_component(dev, &pcm3060_soc_comp_driver, pcm3060_dai, diff --git a/sound/soc/codecs/pcm3060.h b/sound/soc/codecs/pcm3060.h index fd89a68aa8a7..c895cf40ee10 100644 --- a/sound/soc/codecs/pcm3060.h +++ b/sound/soc/codecs/pcm3060.h @@ -25,6 +25,7 @@ struct pcm3060_priv_dai { struct pcm3060_priv { struct regmap *regmap; struct pcm3060_priv_dai dai[PCM3060_DAI_IDS_NUM]; + u8 out_se: 1; };
int pcm3060_probe(struct device *dev);
Hello Mark,
Thank you for applying this patch series.
I think you forgot one patch in the series: patch [1] is a documentation for patch [2]. It has a different naming scheme, because that's how the document [3] recommends. That's why it was not obvious that they relate to each other.
Document [3] also says:
The Documentation/ portion of the patch should come in the series before the code implementing the binding.
Therefore, could you to apply patch [1] to the same branch as [2]?
Best Regards, Kirill
[1] [PATCH v2 1/3] dt-bindings: sound: Add documentation for pcm3060 property out-single-ended [2] [PATCH v2 2/3] ASoC: pcm3060: Add DT property for single-ended output [3] Documentation/devicetree/bindings/submitting-patches.txt
On 11/14/18 01:37, Mark Brown wrote:
The patch
ASoC: pcm3060: Add DT property for single-ended output
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 b1c0000bde8fb287f4fd3493ca4167efee344c3e Mon Sep 17 00:00:00 2001 From: Kirill Marinushkin kmarinushkin@birdec.tech Date: Mon, 12 Nov 2018 08:08:33 +0100 Subject: [PATCH] ASoC: pcm3060: Add DT property for single-ended output
DAC output may be differential (default) or single-ended.
Signed-off-by: Kirill Marinushkin kmarinushkin@birdec.tech Signed-off-by: Mark Brown broonie@kernel.org
sound/soc/codecs/pcm3060.c | 14 ++++++++++++++ sound/soc/codecs/pcm3060.h | 1 + 2 files changed, 15 insertions(+)
diff --git a/sound/soc/codecs/pcm3060.c b/sound/soc/codecs/pcm3060.c index 771b46e1974b..1dd851a7b43b 100644 --- a/sound/soc/codecs/pcm3060.c +++ b/sound/soc/codecs/pcm3060.c @@ -270,9 +270,23 @@ EXPORT_SYMBOL(pcm3060_regmap);
/* device */
+static void pcm3060_parse_dt(const struct device_node *np,
struct pcm3060_priv *priv)
+{
- priv->out_se = of_property_read_bool(np, "ti,out-single-ended");
+}
int pcm3060_probe(struct device *dev) { int rc;
struct pcm3060_priv *priv = dev_get_drvdata(dev);
if (dev->of_node)
pcm3060_parse_dt(dev->of_node, priv);
if (priv->out_se)
regmap_update_bits(priv->regmap, PCM3060_REG64,
PCM3060_REG_SE, PCM3060_REG_SE);
rc = devm_snd_soc_register_component(dev, &pcm3060_soc_comp_driver, pcm3060_dai,
diff --git a/sound/soc/codecs/pcm3060.h b/sound/soc/codecs/pcm3060.h index fd89a68aa8a7..c895cf40ee10 100644 --- a/sound/soc/codecs/pcm3060.h +++ b/sound/soc/codecs/pcm3060.h @@ -25,6 +25,7 @@ struct pcm3060_priv_dai { struct pcm3060_priv { struct regmap *regmap; struct pcm3060_priv_dai dai[PCM3060_DAI_IDS_NUM];
- u8 out_se: 1;
};
int pcm3060_probe(struct device *dev);
In the initial commit [1], I added differential output of the codec as separate `+` and `-` widgets:
OUTL+ OUTR+ OUTL- OUTR-
Later, in the commit [2], I added a device tree property to configure the output as single-ended or differential. Having this property, the `+` and `-` separation in widgets seems for me confusing. There are no functional benefits in such separation, so I find reasonable to get rid of it:
OUTL OUTR
The new naming is more friendly for sound cards, and is better aligned with other codec drivers in kernel.
Renaming the output widgets now should not be a problem from the backwards- compatibility perspective, as the driver for PCM3060 is added into the mainline very recently, and did not yet appear in any releases.
[1] commit 6ee47d4a8dac ("ASoC: pcm3060: Add codec driver") [2] commit a78c62de00d5 ("ASoC: pcm3060: Add DT property for single-ended output")
Signed-off-by: Kirill Marinushkin kmarinushkin@birdec.tech --- sound/soc/codecs/pcm3060.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/sound/soc/codecs/pcm3060.c b/sound/soc/codecs/pcm3060.c index 5f479aa61097..1dd851a7b43b 100644 --- a/sound/soc/codecs/pcm3060.c +++ b/sound/soc/codecs/pcm3060.c @@ -198,20 +198,16 @@ static const struct snd_kcontrol_new pcm3060_dapm_controls[] = { };
static const struct snd_soc_dapm_widget pcm3060_dapm_widgets[] = { - SND_SOC_DAPM_OUTPUT("OUTL+"), - SND_SOC_DAPM_OUTPUT("OUTR+"), - SND_SOC_DAPM_OUTPUT("OUTL-"), - SND_SOC_DAPM_OUTPUT("OUTR-"), + SND_SOC_DAPM_OUTPUT("OUTL"), + SND_SOC_DAPM_OUTPUT("OUTR"),
SND_SOC_DAPM_INPUT("INL"), SND_SOC_DAPM_INPUT("INR"), };
static const struct snd_soc_dapm_route pcm3060_dapm_map[] = { - { "OUTL+", NULL, "Playback" }, - { "OUTR+", NULL, "Playback" }, - { "OUTL-", NULL, "Playback" }, - { "OUTR-", NULL, "Playback" }, + { "OUTL", NULL, "Playback" }, + { "OUTR", NULL, "Playback" },
{ "Capture", NULL, "INL" }, { "Capture", NULL, "INR" },
participants (2)
-
Kirill Marinushkin
-
Mark Brown