* [alsa-devel] [PATCH v2 1/2] ALSA: core: add snd_pcm_format_by_name()
@ 2019-12-05 9:21 Daniel Mack
2019-12-05 9:21 ` [alsa-devel] [PATCH v2 2/2] ASoC: simple-card: add support for codec-to-codec links Daniel Mack
2019-12-08 6:39 ` kbuild test robot
0 siblings, 2 replies; 6+ messages in thread
From: Daniel Mack @ 2019-12-05 9:21 UTC (permalink / raw)
To: alsa-devel; +Cc: tiwai, broonie, Daniel Mack
Add a new function to look up PCM format codes by name. This can be used
by ASoC drivers to look up formats through device-tree properties, for
instance.
Signed-off-by: Daniel Mack <daniel@zonque.org>
---
include/sound/pcm.h | 1 +
sound/core/pcm.c | 23 +++++++++++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index 8a89fa6fdd5e..1bfde6f2f180 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -1339,6 +1339,7 @@ static inline void snd_pcm_limit_isa_dma_size(int dma, size_t *max)
(IEC958_AES3_CON_FS_48000<<24))
const char *snd_pcm_format_name(snd_pcm_format_t format);
+int snd_pcm_format_by_name(const char *name, snd_pcm_format_t *format);
/**
* snd_pcm_stream_str - Get a string naming the direction of a stream
diff --git a/sound/core/pcm.c b/sound/core/pcm.c
index 9a72d641743d..c02d8df4f92b 100644
--- a/sound/core/pcm.c
+++ b/sound/core/pcm.c
@@ -225,6 +225,29 @@ const char *snd_pcm_format_name(snd_pcm_format_t format)
}
EXPORT_SYMBOL_GPL(snd_pcm_format_name);
+/**
+ * snd_pcm_format_by_name - Return the PCM format code for the given name
+ * @name: PCM format name ('S16_LE', 'S24_3LE', ...)
+ * @format: Pointer to returned PCM format code
+ *
+ * The string comparison is done in a case-insensitive way.
+ *
+ * Return: 0 on success, or -ENOENT if the given format is not valid.
+ */
+int snd_pcm_format_by_name(const char *name, snd_pcm_format_t *format)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(snd_pcm_format_names); i++)
+ if (strcasecmp(name, snd_pcm_format_names[i]) == 0) {
+ *format = i;
+ return 0;
+ }
+
+ return -ENOENT;
+}
+EXPORT_SYMBOL_GPL(snd_pcm_format_by_name);
+
#ifdef CONFIG_SND_VERBOSE_PROCFS
#define STATE(v) [SNDRV_PCM_STATE_##v] = #v
--
2.23.0
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [alsa-devel] [PATCH v2 2/2] ASoC: simple-card: add support for codec-to-codec links
2019-12-05 9:21 [alsa-devel] [PATCH v2 1/2] ALSA: core: add snd_pcm_format_by_name() Daniel Mack
@ 2019-12-05 9:21 ` Daniel Mack
2019-12-08 9:49 ` kbuild test robot
2019-12-08 6:39 ` kbuild test robot
1 sibling, 1 reply; 6+ messages in thread
From: Daniel Mack @ 2019-12-05 9:21 UTC (permalink / raw)
To: alsa-devel; +Cc: tiwai, broonie, Daniel Mack
DAI links in ASoC can be turned into codec-to-codec links by populating
the .params field. This patch adds support for this to the simple-card
driver and exposes the feature via three new device-tree properties that
configure the pcm format, the sampling rate and the channel count.
Signed-off-by: Daniel Mack <daniel@zonque.org>
---
.../devicetree/bindings/sound/simple-card.txt | 10 ++++++
include/sound/simple_card_utils.h | 6 +++-
sound/soc/generic/simple-card-utils.c | 34 +++++++++++++++++++
sound/soc/generic/simple-card.c | 19 +++++++++++
4 files changed, 68 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/sound/simple-card.txt b/Documentation/devicetree/bindings/sound/simple-card.txt
index 79954cd6e37b..13f0c0da8b53 100644
--- a/Documentation/devicetree/bindings/sound/simple-card.txt
+++ b/Documentation/devicetree/bindings/sound/simple-card.txt
@@ -27,6 +27,16 @@ Optional properties:
- simple-audio-card,pin-switches : List of strings containing the widget names for
which pin switches must be created.
+Optional dai-link properies for CODEC-to-CODEC links:
+
+- codec-to-codec-format : Format to configure
+ "s16_le"; "s24_le", "s32_le", ...
+- codec-to-codec-rate : Sample rate to configure
+- codec-to-codec-channels : Number of channels to configure
+
+Note that for a CODEC-to-CODEC link to be activated, you also need to provide a
+valid DAPM path that connects the two components.
+
Optional subnodes:
- simple-audio-card,dai-link : Container for dai-link level
diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h
index bbdd1542d6f1..a170f0656c1f 100644
--- a/include/sound/simple_card_utils.h
+++ b/include/sound/simple_card_utils.h
@@ -48,6 +48,7 @@ struct asoc_simple_priv {
struct snd_soc_dai_link_component platforms;
struct asoc_simple_data adata;
struct snd_soc_codec_conf *codec_conf;
+ struct snd_soc_pcm_stream c2c_params;
unsigned int mclk_fs;
} *dai_props;
struct asoc_simple_jack hp_jack;
@@ -121,7 +122,10 @@ void asoc_simple_convert_fixup(struct asoc_simple_data *data,
void asoc_simple_parse_convert(struct device *dev,
struct device_node *np, char *prefix,
struct asoc_simple_data *data);
-
+void asoc_simple_parse_c2c_params(struct device *dev,
+ struct device_node *np,
+ char *prefix,
+ struct snd_soc_pcm_stream *dest);
int asoc_simple_parse_routing(struct snd_soc_card *card,
char *prefix);
int asoc_simple_parse_widgets(struct snd_soc_card *card,
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index 9b794775df53..73e09b790040 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -52,6 +52,40 @@ void asoc_simple_parse_convert(struct device *dev,
}
EXPORT_SYMBOL_GPL(asoc_simple_parse_convert);
+void asoc_simple_parse_c2c_params(struct device *dev,
+ struct device_node *np,
+ char *prefix,
+ struct snd_soc_pcm_stream *dest)
+{
+ unsigned int rate, channels;
+ const char *format_string;
+ snd_pcm_format_t format;
+ char prop[128];
+ int ret;
+
+ if (!prefix)
+ prefix = "";
+
+ snprintf(prop, sizeof(prop), "%s%s", prefix, "codec-to-codec-rate");
+ of_property_read_u32(np, prop, &rate);
+
+ snprintf(prop, sizeof(prop), "%s%s", prefix, "codec-to-codec-channels");
+ of_property_read_u32(np, prop, &channels);
+
+ snprintf(prop, sizeof(prop), "%s%s", prefix, "codec-to-codec-format");
+ if (!of_property_read_string(np, prop, &format_string)) {
+ ret = snd_pcm_format_by_name(format_string, &format);
+ if (ret == 0) {
+ dest->formats = 1ULL << format;
+ dest->channels_min = dest->channels_max = channels;
+ dest->rate_min = dest->rate_max = rate;
+ } else {
+ dev_err(dev, "unknown dai format %s\n", format_string);
+ }
+ }
+}
+EXPORT_SYMBOL_GPL(asoc_simple_parse_c2c_params);
+
int asoc_simple_parse_daifmt(struct device *dev,
struct device_node *node,
struct device_node *codec,
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index cbda6455d9c7..2aab1c9ebc4a 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -94,6 +94,21 @@ static void simple_parse_convert(struct device *dev,
of_node_put(node);
}
+static void simple_parse_c2c_params(struct device *dev,
+ struct device_node *np,
+ struct snd_soc_pcm_stream *dest)
+{
+ struct device_node *top = dev->of_node;
+ struct device_node *node = of_get_parent(np);
+
+ asoc_simple_parse_c2c_params(dev, top, PREFIX, dest);
+ asoc_simple_parse_c2c_params(dev, node, PREFIX, dest);
+ asoc_simple_parse_c2c_params(dev, node, NULL, dest);
+ asoc_simple_parse_c2c_params(dev, np, NULL, dest);
+
+ of_node_put(node);
+}
+
static void simple_parse_mclk_fs(struct device_node *top,
struct device_node *cpu,
struct device_node *codec,
@@ -334,6 +349,10 @@ static int simple_dai_link_of(struct asoc_simple_priv *priv,
dai_link->ops = &simple_ops;
dai_link->init = asoc_simple_dai_init;
+ simple_parse_c2c_params(dev, node, &dai_props->c2c_params);
+ if (dai_props->c2c_params.formats != 0)
+ dai_link->params = &dai_props->c2c_params;
+
asoc_simple_canonicalize_cpu(dai_link, single_cpu);
asoc_simple_canonicalize_platform(dai_link);
--
2.23.0
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [alsa-devel] [PATCH v2 1/2] ALSA: core: add snd_pcm_format_by_name()
2019-12-05 9:21 [alsa-devel] [PATCH v2 1/2] ALSA: core: add snd_pcm_format_by_name() Daniel Mack
@ 2019-12-08 6:39 ` kbuild test robot
2019-12-08 6:39 ` kbuild test robot
1 sibling, 0 replies; 6+ messages in thread
From: kbuild test robot @ 2019-12-08 6:39 UTC (permalink / raw)
To: Daniel Mack; +Cc: tiwai, alsa-devel, broonie, kbuild-all, Daniel Mack
Hi Daniel,
I love your patch! Perhaps something to improve:
[auto build test WARNING on sound/for-next]
[also build test WARNING on asoc/for-next v5.4 next-20191207]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Daniel-Mack/ALSA-core-add-snd_pcm_format_by_name/20191207-084912
base: https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
reproduce:
# apt-get install sparse
# sparse version: v0.6.1-91-g817270f-dirty
make ARCH=x86_64 allmodconfig
make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
>> sound/core/pcm.c:243:33: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted snd_pcm_format_t [usertype] @@ got t_t [usertype] @@
>> sound/core/pcm.c:243:33: sparse: expected restricted snd_pcm_format_t [usertype]
>> sound/core/pcm.c:243:33: sparse: got int [assigned] i
sound/core/pcm.c:1022:9: sparse: sparse: context imbalance in 'snd_pcm_detach_substream' - different lock contexts for basic block
vim +243 sound/core/pcm.c
227
228 /**
229 * snd_pcm_format_by_name - Return the PCM format code for the given name
230 * @name: PCM format name ('S16_LE', 'S24_3LE', ...)
231 * @format: Pointer to returned PCM format code
232 *
233 * The string comparison is done in a case-insensitive way.
234 *
235 * Return: 0 on success, or -ENOENT if the given format is not valid.
236 */
237 int snd_pcm_format_by_name(const char *name, snd_pcm_format_t *format)
238 {
239 int i;
240
241 for (i = 0; i < ARRAY_SIZE(snd_pcm_format_names); i++)
242 if (strcasecmp(name, snd_pcm_format_names[i]) == 0) {
> 243 *format = i;
244 return 0;
245 }
246
247 return -ENOENT;
248 }
249 EXPORT_SYMBOL_GPL(snd_pcm_format_by_name);
250
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org Intel Corporation
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [alsa-devel] [PATCH v2 1/2] ALSA: core: add snd_pcm_format_by_name()
@ 2019-12-08 6:39 ` kbuild test robot
0 siblings, 0 replies; 6+ messages in thread
From: kbuild test robot @ 2019-12-08 6:39 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 2425 bytes --]
Hi Daniel,
I love your patch! Perhaps something to improve:
[auto build test WARNING on sound/for-next]
[also build test WARNING on asoc/for-next v5.4 next-20191207]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Daniel-Mack/ALSA-core-add-snd_pcm_format_by_name/20191207-084912
base: https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
reproduce:
# apt-get install sparse
# sparse version: v0.6.1-91-g817270f-dirty
make ARCH=x86_64 allmodconfig
make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
>> sound/core/pcm.c:243:33: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted snd_pcm_format_t [usertype] @@ got t_t [usertype] @@
>> sound/core/pcm.c:243:33: sparse: expected restricted snd_pcm_format_t [usertype]
>> sound/core/pcm.c:243:33: sparse: got int [assigned] i
sound/core/pcm.c:1022:9: sparse: sparse: context imbalance in 'snd_pcm_detach_substream' - different lock contexts for basic block
vim +243 sound/core/pcm.c
227
228 /**
229 * snd_pcm_format_by_name - Return the PCM format code for the given name
230 * @name: PCM format name ('S16_LE', 'S24_3LE', ...)
231 * @format: Pointer to returned PCM format code
232 *
233 * The string comparison is done in a case-insensitive way.
234 *
235 * Return: 0 on success, or -ENOENT if the given format is not valid.
236 */
237 int snd_pcm_format_by_name(const char *name, snd_pcm_format_t *format)
238 {
239 int i;
240
241 for (i = 0; i < ARRAY_SIZE(snd_pcm_format_names); i++)
242 if (strcasecmp(name, snd_pcm_format_names[i]) == 0) {
> 243 *format = i;
244 return 0;
245 }
246
247 return -ENOENT;
248 }
249 EXPORT_SYMBOL_GPL(snd_pcm_format_by_name);
250
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corporation
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [alsa-devel] [PATCH v2 2/2] ASoC: simple-card: add support for codec-to-codec links
2019-12-05 9:21 ` [alsa-devel] [PATCH v2 2/2] ASoC: simple-card: add support for codec-to-codec links Daniel Mack
@ 2019-12-08 9:49 ` kbuild test robot
0 siblings, 0 replies; 6+ messages in thread
From: kbuild test robot @ 2019-12-08 9:49 UTC (permalink / raw)
To: Daniel Mack; +Cc: tiwai, alsa-devel, broonie, kbuild-all, Daniel Mack
Hi Daniel,
I love your patch! Perhaps something to improve:
[auto build test WARNING on sound/for-next]
[also build test WARNING on asoc/for-next v5.4 next-20191208]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Daniel-Mack/ALSA-core-add-snd_pcm_format_by_name/20191207-084912
base: https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
reproduce:
# apt-get install sparse
# sparse version: v0.6.1-91-g817270f-dirty
make ARCH=x86_64 allmodconfig
make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
>> sound/soc/generic/simple-card-utils.c:79:49: sparse: sparse: restricted snd_pcm_format_t degrades to integer
vim +79 sound/soc/generic/simple-card-utils.c
54
55 void asoc_simple_parse_c2c_params(struct device *dev,
56 struct device_node *np,
57 char *prefix,
58 struct snd_soc_pcm_stream *dest)
59 {
60 unsigned int rate, channels;
61 const char *format_string;
62 snd_pcm_format_t format;
63 char prop[128];
64 int ret;
65
66 if (!prefix)
67 prefix = "";
68
69 snprintf(prop, sizeof(prop), "%s%s", prefix, "codec-to-codec-rate");
70 of_property_read_u32(np, prop, &rate);
71
72 snprintf(prop, sizeof(prop), "%s%s", prefix, "codec-to-codec-channels");
73 of_property_read_u32(np, prop, &channels);
74
75 snprintf(prop, sizeof(prop), "%s%s", prefix, "codec-to-codec-format");
76 if (!of_property_read_string(np, prop, &format_string)) {
77 ret = snd_pcm_format_by_name(format_string, &format);
78 if (ret == 0) {
> 79 dest->formats = 1ULL << format;
80 dest->channels_min = dest->channels_max = channels;
81 dest->rate_min = dest->rate_max = rate;
82 } else {
83 dev_err(dev, "unknown dai format %s\n", format_string);
84 }
85 }
86 }
87 EXPORT_SYMBOL_GPL(asoc_simple_parse_c2c_params);
88
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org Intel Corporation
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [alsa-devel] [PATCH v2 2/2] ASoC: simple-card: add support for codec-to-codec links
@ 2019-12-08 9:49 ` kbuild test robot
0 siblings, 0 replies; 6+ messages in thread
From: kbuild test robot @ 2019-12-08 9:49 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 2557 bytes --]
Hi Daniel,
I love your patch! Perhaps something to improve:
[auto build test WARNING on sound/for-next]
[also build test WARNING on asoc/for-next v5.4 next-20191208]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Daniel-Mack/ALSA-core-add-snd_pcm_format_by_name/20191207-084912
base: https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
reproduce:
# apt-get install sparse
# sparse version: v0.6.1-91-g817270f-dirty
make ARCH=x86_64 allmodconfig
make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
>> sound/soc/generic/simple-card-utils.c:79:49: sparse: sparse: restricted snd_pcm_format_t degrades to integer
vim +79 sound/soc/generic/simple-card-utils.c
54
55 void asoc_simple_parse_c2c_params(struct device *dev,
56 struct device_node *np,
57 char *prefix,
58 struct snd_soc_pcm_stream *dest)
59 {
60 unsigned int rate, channels;
61 const char *format_string;
62 snd_pcm_format_t format;
63 char prop[128];
64 int ret;
65
66 if (!prefix)
67 prefix = "";
68
69 snprintf(prop, sizeof(prop), "%s%s", prefix, "codec-to-codec-rate");
70 of_property_read_u32(np, prop, &rate);
71
72 snprintf(prop, sizeof(prop), "%s%s", prefix, "codec-to-codec-channels");
73 of_property_read_u32(np, prop, &channels);
74
75 snprintf(prop, sizeof(prop), "%s%s", prefix, "codec-to-codec-format");
76 if (!of_property_read_string(np, prop, &format_string)) {
77 ret = snd_pcm_format_by_name(format_string, &format);
78 if (ret == 0) {
> 79 dest->formats = 1ULL << format;
80 dest->channels_min = dest->channels_max = channels;
81 dest->rate_min = dest->rate_max = rate;
82 } else {
83 dev_err(dev, "unknown dai format %s\n", format_string);
84 }
85 }
86 }
87 EXPORT_SYMBOL_GPL(asoc_simple_parse_c2c_params);
88
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corporation
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-12-08 9:50 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-05 9:21 [alsa-devel] [PATCH v2 1/2] ALSA: core: add snd_pcm_format_by_name() Daniel Mack
2019-12-05 9:21 ` [alsa-devel] [PATCH v2 2/2] ASoC: simple-card: add support for codec-to-codec links Daniel Mack
2019-12-08 9:49 ` kbuild test robot
2019-12-08 9:49 ` kbuild test robot
2019-12-08 6:39 ` [alsa-devel] [PATCH v2 1/2] ALSA: core: add snd_pcm_format_by_name() kbuild test robot
2019-12-08 6:39 ` kbuild test robot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.