Skip to contentSkip to conversation

ASoC: generic: Add generic DT based simple codec

PATCH In review Jean-Francois Moine 7 participants 13 messages Sep 19, 2013 – Sep 30, 2013 6 messages not in the archive

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: generic: Add generic DT based simple codec

This patch adds a simple sound codec which is described by the DT. This codec may be used when no specific codec action is needed.

---
 .../devicetree/bindings/sound/simple-codec.txt | 103 +++++++++++++
 sound/soc/generic/Kconfig                      |   6 +
 sound/soc/generic/Makefile                     |   2 +
 sound/soc/generic/simple-codec.c               | 197 +++++++++++++++++++++++++
 4 files changed, 3088 insertions(+)
Documentation/devicetree/bindings/sound/simple-codec.txt new file +103 -0
new file mode 100644
index 0000000..75be747
@@ -0,0 +1,103 @@
+Device-Tree bindings for the simple codec
+
+Required properties:
+- compatible: should be "linux,simple-codec".
+- dai-name: name of the codec
+
+Optional properties:
+- capture: information about capture
+- playback: information about playback
+At least one of the 'capture' or 'playback' nodes must be present.
+
+Child 'capture' and 'playback' required properties:
+- stream-name: name of the stream
+- formats: list of the supported formats (see below)
+- rates: list of the supported rates (see below)
+- #channels: minimum and maximum numbers of channels
+
+Formats:
+	"s8"
+	"u8"
+	"s16_le"
+	"s16_be"
+	"u16_le"
+	"u16_be"
+	"s24_le"
+	"s24_be"
+	"u24_le"
+	"u24_be"
+	"s32_le"
+	"s32_be"
+	"u32_le"
+	"u32_be"
+	"float_le"
+	"float_be"
+	"float64_le"
+	"float64_be"
+	"iec958_subframe_le"
+	"iec958_subframe_be"
+	"mu_law"
+	"a_law"
+	"ima_adpcm"
+	"mpeg"
+	"gsm"
+	"special"
+	"s24_3l"
+	"s24_3be"
+	"u24_3le"
+	"u24_3be"
+	"s20_3le"
+	"s20_3be"
+	"u20_3le"
+	"u20_3be"
+	"s18_3le"
+	"s18_3b"
+	"u18_3le"
+	"u18_3be"
+	"g723_24"
+	"g723_24_1b"
+	"g723_40"
+	"g723_40_1b"
+	"dsd_u8"
+	"dsd_u16_le"
+
+Rates:
+	5512
+	8000
+	11025
+	16000
+	22050
+	32000
+	44100
+	48000
+	64000
+	88200
+	96000
+	176400
+	192000
+
+Examples:
+
+	spdifo: spdif-transmitter {
+		compatible = "linux,simple-codec";
+		dai-name = "dit-hifi";
+		playback {
+			stream-name = "S/PDIF Playback";
+			formats = "s16_le";
+			rates = <8000 11025 16000 22050 32000 44100
+				48000 64000 88200 96000>;
+			#channels = <1 384>;
+		};
+	};
+
+	hdmio: hdmi-transmitter {
+		compatible = "linux,simple-codec";
+		dai-name = "hdmi-hifi";
+		playback {
+			stream-name = "HDMI Playback";
+			formats = "s16_le", "s24_le";
+			rates = <32000 44100 48000 88200 96000
+				176400 192000>;
+			#channels = <2 8>;
+		};
+	};
sound/soc/generic/Kconfig +6 -0
index 610f612..d9221539 100644
@@ -2,3 +2,9 @@ config SND_SIMPLE_CARD
 	tristate "ASoC Simple sound card support"
 	help
 	  This option enables generic simple sound card support
+
+config SND_SIMPLE_CODEC
+	tristate "ASoC Simple sound codec support"
+	depends on OF
+	help
+	  This option enables generic simple sound codec support
sound/soc/generic/Makefile +2 -0
index 9c3b246..f94620e 100644
@@ -1,3 +1,5 @@
 snd-soc-simple-card-objs	:= simple-card.o
+snd-soc-simple-codec-objs	:= simple-codec.o
 
 obj-$(CONFIG_SND_SIMPLE_CARD)	+= snd-soc-simple-card.o
+obj-$(CONFIG_SND_SIMPLE_CODEC)	+= snd-soc-simple-codec.o
sound/soc/generic/simple-codec.c new file +197 -0

197 lines not on this page · raw message

Signature · 6 lines
Ken ar c'hentañ	|	      ** Breizh ha Linux atav! **
Jef		|		http://moinejf.free.fr/
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#1 lore raw
Quoted 2 lines · Jean-Francois Moine

This patch adds a simple sound codec which is described by the DT. This codec may be used when no specific codec action is needed.

Hrm. I'm generally not enthusiastic about this sort of thing because it requires every user of the device to understand the capabilities of the device instead of being able to just say they have a device of type X - it seems better to type the data in once in a driver and then reference it. That said...

Quoted 2 lines

+Child 'capture' and 'playback' required properties:
+- stream-name: name of the stream

What does this mean in the binding?

Documentation/devicetree/bindings/sound/simple-codec.txt line 20

Quoted 3 lines
Documentation/devicetree/bindings/sound/simple-codec.txt new file +3 -0
+Formats:
+	"s8"
+	"u8"

I'd cut this down to just the PCM formats for now - many of the formats you list there aren't terribly well defined even within ALSA, I don't think some of them have ever been used at all. A binding document should really document what things mean as well.

Documentation/devicetree/bindings/sound/simple-codec.txt line 66

Quoted 3 lines
Documentation/devicetree/bindings/sound/simple-codec.txt new file +3 -0
+Rates:
+	5512
+	8000

This shouldn't be a list of defined rates, it should allow any number, and it should support ranges since while some devices do enumerate specific rates simpler devices often just support a continuous range of rates.

sound/soc/generic/Kconfig

Quoted 2 lines
sound/soc/generic/Kconfig +0 -0

CODEC drivers should go in codecs.

Quoted 1 line

+#define DRV_NAME "simple-codec"

Just write the string in the one place where it is used.

sound/soc/generic/Kconfig

Quoted 10 lines
sound/soc/generic/Kconfig +10 -0
+static char *format_tb[] = {
+	"s8", "u8", "s16_le", "s16_be",
+	"u16_le", "u16_be", "s24_le", "s24_be",
+	"u24_le", "u24_be", "s32_le", "s32_be",
+	"u32_le", "u32_be", "float_le", "float_be",
+
+	"float64_le", "float64_be", "iec958_subframe_le", "iec958_subframe_be",
+	"mu_law", "a_law", "ima_adpcm", "mpeg",
+	"gsm", "", "", "",
+	"", "", "", "special",

This seems a bit obscure and fragile - an explicit lookup table would be better I think.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
Quoted 9 lines · On Thu, 19 Sep 2013 11:40:28 +0100 Mark Brown…
Quoted 2 lines · Jean-Francois Moine

This patch adds a simple sound codec which is described by the DT. This codec may be used when no specific codec action is needed.

Hrm. I'm generally not enthusiastic about this sort of thing because it requires every user of the device to understand the capabilities of the device instead of being able to just say they have a device of type X - it seems better to type the data in once in a driver and then reference it. That said...

Well, first, the codecs hdmi and dmic have no DT support. Then, from the Cubox point of vue, the codec hdmi offers playback and capture while the Cubox has only playback (via the tda998x HDMI transmitter), and, also, the codec spdif transmitter has a lot of sample rates while the Dove audio device supports only 44.1, 48 and 96 kHz.

So, instead of adding new hdmi and spdif_transmitter codecs, I thought it could be useful to have a generic codec with DT support.

On the other hand, as the first use of this codec is for the Cubox, an other solution could be to have the codec included in the kirkwood driver (declared by DT as either i2s or s/pdif). This would simplify the use or not of s/pdif in this driver.

Quoted 4 lines
Quoted 2 lines

+Child 'capture' and 'playback' required properties:
+- stream-name: name of the stream

What does this mean in the binding?

Indeed, the stream name could be implicit (either "Playback" or "Capture"), but, as the users are aware of it, a more friendly name is nicer ("S/PDIF Playback").

Quoted 8 lines

Documentation/devicetree/bindings/sound/simple-codec.txt line 20

Quoted 3 lines
Documentation/devicetree/bindings/sound/simple-codec.txt new file +3 -0
+Formats:
+	"s8"
+	"u8"

I'd cut this down to just the PCM formats for now - many of the formats you list there aren't terribly well defined even within ALSA, I don't think some of them have ever been used at all. A binding document should really document what things mean as well.

I have no idea about which format is used or not, and there is no explanation about their meanings in the uapi (but I can search them..).

Otherwise, for Dove, we need at least "s16_le", "s24_le" and "s32_le" and, perhaps, "iec958_subframe_le" and "iec958_subframe_be".

So, what do you think should be the format set?

Quoted 8 lines

Documentation/devicetree/bindings/sound/simple-codec.txt line 66

Quoted 3 lines
Documentation/devicetree/bindings/sound/simple-codec.txt new file +3 -0
+Rates:
+	5512
+	8000

This shouldn't be a list of defined rates, it should allow any number, and it should support ranges since while some devices do enumerate specific rates simpler devices often just support a continuous range of rates.

There cannot be any number because the rates are coded by discrete values in a bitmap.

For the continuous range, I was thinking about the value '0' followed by the min and max rates. Have you any other syntax in mind?

Quoted 4 lines

sound/soc/generic/Kconfig

Quoted 2 lines
sound/soc/generic/Kconfig +0 -0

CODEC drivers should go in codecs.

OK.

Quoted 3 lines
Quoted 1 line

+#define DRV_NAME "simple-codec"

Just write the string in the one place where it is used.

OK.

Quoted 5 lines
Quoted 5 lines
sound/soc/generic/Kconfig +5 -0
+static char *format_tb[] = {
+	"s8", "u8", "s16_le", "s16_be",
+	"u16_le", "u16_be", "s24_le", "s24_be",
+	"u24_le", "u24_be", "s32_le", "s32_be",
+	"u32_le", "u32_be", "float_le", "float_be",
Quoted 8 lines

sound/soc/generic/Kconfig

Quoted 5 lines
sound/soc/generic/Kconfig +5 -0
+
+	"float64_le", "float64_be", "iec958_subframe_le", "iec958_subframe_be",
+	"mu_law", "a_law", "ima_adpcm", "mpeg",
+	"gsm", "", "", "",
+	"", "", "", "special",

This seems a bit obscure and fragile - an explicit lookup table would be better I think.

OK.

Signature · 6 lines
Ken ar c'hentañ	|	      ** Breizh ha Linux atav! **
Jef		|		http://moinejf.free.fr/
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#4 lore raw
Quoted 2 lines · Jean-Francois Moine

Otherwise, for Dove, we need at least "s16_le", "s24_le" and "s32_le" and, perhaps, "iec958_subframe_le" and "iec958_subframe_be".

The audio block can't do IEC958 subframes in the format ALSA wants them. The hardware format is different. I've sent a commit removing these foramts from sound/soc/kirkwood with a full explanation. Mark seems not to have merged even that one though.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20130919174952.GC12758-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org

#6 lore raw
Quoted 8 lines · Russell King - ARM Linux
Quoted 2 lines · Jean-Francois Moine

Otherwise, for Dove, we need at least "s16_le", "s24_le" and "s32_le" and, perhaps, "iec958_subframe_le" and "iec958_subframe_be".

The audio block can't do IEC958 subframes in the format ALSA wants them. The hardware format is different. I've sent a commit removing these foramts from sound/soc/kirkwood with a full explanation. Mark seems not to have merged even that one though.

It's there in -next, it missed the merge window - there's no DAI in mainline yet that would allow those formats anyway.

maintainer
#7 lore raw
In reply to Jean-Francois Moine
Quoted 6 lines · Jean-Francois Moine

Well, first, the codecs hdmi and dmic have no DT support. Then, from the Cubox point of vue, the codec hdmi offers playback and capture while the Cubox has only playback (via the tda998x HDMI transmitter), and, also, the codec spdif transmitter has a lot of sample rates while the Dove audio device supports only 44.1, 48 and 96 kHz.

All those restrictions should be constrained by either the machine binding or the driver for the SoC side though. I do see why you might want this, I'm just a bit ambivalent about the merits.

Quoted 7 lines

So, instead of adding new hdmi and spdif_transmitter codecs, I thought it could be useful to have a generic codec with DT support.

On the other hand, as the first use of this codec is for the Cubox, an other solution could be to have the codec included in the kirkwood driver (declared by DT as either i2s or s/pdif). This would simplify the use or not of s/pdif in this driver.

That'd work too.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

+Child 'capture' and 'playback' required properties:
+- stream-name: name of the stream

What does this mean in the binding?

Indeed, the stream name could be implicit (either "Playback" or "Capture"), but, as the users are aware of it, a more friendly name is nicer ("S/PDIF Playback").

So you need to say that it's for display purposes.

Quoted 7 lines

I have no idea about which format is used or not, and there is no explanation about their meanings in the uapi (but I can search them..).

Otherwise, for Dove, we need at least "s16_le", "s24_le" and "s32_le" and, perhaps, "iec958_subframe_le" and "iec958_subframe_be".

So, what do you think should be the format set?

PCM plus IEC seems fine, it's more the more obscure formats that ring alarm bells.

Quoted 11 lines
Quoted 8 lines

Documentation/devicetree/bindings/sound/simple-codec.txt line 66

Quoted 3 lines
Documentation/devicetree/bindings/sound/simple-codec.txt new file +3 -0
+Rates:
+	5512
+	8000

This shouldn't be a list of defined rates, it should allow any number, and it should support ranges since while some devices do enumerate specific rates simpler devices often just support a continuous range of rates.

There cannot be any number because the rates are coded by discrete values in a bitmap.

Not quite - _KNOT and _CONTINUOUS are options in that bitmap... in any case this would be a Linux implementation thing.

Quoted 2 lines

For the continuous range, I was thinking about the value '0' followed by the min and max rates. Have you any other syntax in mind?

That'd probably work, not sure if there's a more idiomatic way of doing
that in DT though.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130919/2ddd1c55/attachment-0001.sig>

#8 lore raw
In reply to Jean-Francois Moine

Documentation/devicetree/bindings/sound/simple-codec.txt line 4

Quoted 9 lines · Jean-Francois Moine

This patch adds a simple sound codec which is described by the DT. This codec may be used when no specific codec action is needed.

Documentation/devicetree/bindings/sound/simple-codec.txt +4 -0
 
+Device-Tree bindings for the simple codec
+
+Required properties:
+- compatible: should be "linux,simple-codec".

We shouldn't have any Linux-specific bindings. It might be reasonable to define a binding for a "simple CODEC", but there's no reason it should be Linux-specific.

Quoted 1 line

+- dai-name: name of the codec

That should be internal to the driver; it's Linux-specific.

Documentation/devicetree/bindings/sound/simple-codec.txt line 10

Quoted 4 lines
Documentation/devicetree/bindings/sound/simple-codec.txt +4 -0
+Optional properties:
+- capture: information about capture
+- playback: information about playback
+At least one of the 'capture' or 'playback' nodes must be present.

Judging by the example, those are nodes not properties.

Quoted 2 lines

+Child 'capture' and 'playback' required properties:
+- stream-name: name of the stream

Stream name is also probably too Linux-specific.

Documentation/devicetree/bindings/sound/simple-codec.txt line 20

Quoted 7 lines
+- formats: list of the supported formats (see below)
+- rates: list of the supported rates (see below)
+- #channels: minimum and maximum numbers of channels
Documentation/devicetree/bindings/sound/simple-codec.txt +4 -0
+
+Formats:
+	"s8"
+	"u8"

I think the binding should specify on-the-wire formats, not in-memory formats. For example, if this binding is used to represent an I2S CODEC, it's more important to know whether it supports left-justified, right-justified, DSP mode, etc., and the max number of bits (or perhaps a list of supported numbers of bits) per channel in each case.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#10 lore raw
Quoted 8 lines · Stephen Warren
Quoted 2 lines · Jean-Francois Moine

+Required properties:
+- compatible: should be "linux,simple-codec".

We shouldn't have any Linux-specific bindings. It might be reasonable to define a binding for a "simple CODEC", but there's no reason it should be Linux-specific.

What's the vendor prefix to use then? The same thought did occur to me but I wasn't sure what to suggest instead.

Quoted 3 lines
Quoted 1 line

+- dai-name: name of the codec

That should be internal to the driver; it's Linux-specific.

I do think it's reasonable to define a name for display purposes however this binding doesn't say that, I did say something to that effect already IIRC.

Quoted 9 lines

Documentation/devicetree/bindings/sound/simple-codec.txt line 20

Quoted 3 lines
Documentation/devicetree/bindings/sound/simple-codec.txt new file +3 -0
+Formats:
+	"s8"
+	"u8"

I think the binding should specify on-the-wire formats, not in-memory formats. For example, if this binding is used to represent an I2S CODEC, it's more important to know whether it supports left-justified, right-justified, DSP mode, etc., and the max number of bits (or perhaps a list of supported numbers of bits) per channel in each case.

I didn't query this myself since my expecation with this is that the rest of the wire format properties will come from the binding that pulls this together into a card (since this will need to be set at that level for other CODECs which are more flexible) so I saw this as providing additional information which would normally not be fixed at that level. Arguably this could be pushed up there too, though it's not normal to fix the word size.

We should really be defining things like signed and unsigned as well as the bits per word since they do make a difference, though in practice you very rarely see anything except unsigned and some of the formats listed don't seem to have ever even been used in Linux.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#12 lore raw
Quoted 6 lines · Mark Brown
Quoted 4 lines · Stephen Warren
Quoted 2 lines · Jean-Francois Moine

+Required properties: +- compatible: should be
"linux,simple-codec".

Quoted 6 lines
Quoted 3 lines

We shouldn't have any Linux-specific bindings. It might be reasonable to define a binding for a "simple CODEC", but there's no reason it should be Linux-specific.

What's the vendor prefix to use then? The same thought did occur to me but I wasn't sure what to suggest instead.

For other non-vendor-specific/generic bindings, we've simply omitted the vendor prefix from the compatible value, e.g.: gpio-keys, i2c-gpio, regulator-fixed, etc.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#13 lore raw
In reply to a message not in the archive
Quoted 6 lines · Stephen Warren
Quoted 4 lines · Jean-Francois Moine

This patch adds a simple sound codec which is described by the DT. This codec may be used when no specific codec action is needed.

Documentation/devicetree/bindings/sound/simple-codec.txt +0 -0
Quoted 8 lines

Documentation/devicetree/bindings/sound/simple-codec.txt line 4

Quoted 4 lines
Documentation/devicetree/bindings/sound/simple-codec.txt +4 -0
+Device-Tree bindings for the simple codec
+
+Required properties:
+- compatible: should be "linux,simple-codec".

We shouldn't have any Linux-specific bindings. It might be reasonable to define a binding for a "simple CODEC", but there's no reason it should be Linux-specific.

Further, just define the type of codec h/w. If linux can use its simple-codec driver for it, then add a match table entry for said codec. Then the DT is future proof when you decide the simple driver doesn't really work for that h/w.

Rob
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#14 lore raw
Quoted 10 lines · Rob Herring
Quoted 3 lines · Stephen Warren

We shouldn't have any Linux-specific bindings. It might be reasonable to define a binding for a "simple CODEC", but there's no reason it should be Linux-specific.

Further, just define the type of codec h/w. If linux can use its simple-codec driver for it, then add a match table entry for said codec. Then the DT is future proof when you decide the simple driver doesn't really work for that h/w.

So, this is what I keep telling people to do but lots of people don't
want to do this - it eliminates the need have this binding at all since
if you know which type of device you have there's no need to specify
fixed properties of the device via DT.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130927/eb239154/attachment.sig>

A message that is not in the archive (sent off-list or not yet received): CAL_JsqKmfurrCqEYRNqcLRZMU-VjPin2dvK1Q6CMcK4i=+x-8w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#16 lore raw
Quoted 16 lines · Rob Herring
Quoted 6 lines · Stephen Warren
Quoted 4 lines · Jean-Francois Moine

This patch adds a simple sound codec which is described by the DT. This codec may be used when no specific codec action is needed.

Documentation/devicetree/bindings/sound/simple-codec.txt +0 -0
Quoted 8 lines

Documentation/devicetree/bindings/sound/simple-codec.txt line 4

Quoted 4 lines
Documentation/devicetree/bindings/sound/simple-codec.txt +4 -0
+Device-Tree bindings for the simple codec
+
+Required properties:
+- compatible: should be "linux,simple-codec".

We shouldn't have any Linux-specific bindings. It might be reasonable to define a binding for a "simple CODEC", but there's no reason it should be Linux-specific.

Quoted 4 lines

Further, just define the type of codec h/w. If linux can use its simple-codec driver for it, then add a match table entry for said codec. Then the DT is future proof when you decide the simple driver doesn't really work for that h/w.

The only potential issue with that approach is if the CODEC can be used in a "simple" mode where e.g. no control GPIOs, regulator manipulation, etc. are required, or in a more complex mode where such things are required, you may end up with the device-specific binding being written to the simple mode, and hence missing features required for the complex mode. Having a separate simple binding prevents the device-specific binding from being broken that way.

That said, it's probably better to simply get the device-specific binding completely fleshed out and representing all resources the first time around, then there's no issue either.

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#18 lore raw
Quoted 7 lines · Stephen Warren

The only potential issue with that approach is if the CODEC can be used in a "simple" mode where e.g. no control GPIOs, regulator manipulation, etc. are required, or in a more complex mode where such things are required, you may end up with the device-specific binding being written to the simple mode, and hence missing features required for the complex mode. Having a separate simple binding prevents the device-specific binding from being broken that way.

That would probably indicate a bug in the complex bindings since if the simple mode exists then usually that would mean that the bindings for the complex mode ought to be specifying things as optional, these things are typically just done by strapping pins instead of routing them to the CPU.