Commit graph

485 commits

Author SHA1 Message Date
Kuninori Morimoto
45b4878b03
ASoC: audio-graph-card.c: move audio_graph_parse_of()
Current audio-graph-card functions definition are like below

(A)'	static int graph_get_dais_count();

(B)	int audio_graph_parse_of(...)
	{
		...
(A)		ret = graph_get_dais_count();
		...
	}

(A)	static int graph_get_dais_count(...)
	{
		...
	}
(C)

We don't need to have (A)' definition if audio_graph_parse_of() (B) was
defined at (C). This patch moves (B) to (C).

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com
Link: https://lore.kernel.org/r/87r0ntmc3c.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org
2023-08-24 18:22:01 +01:00
Kuninori Morimoto
ea2cb26a98
ASoC: audio-graph-card2: add comment for format property
We don't need to have "format" property on DT any more if
CPU/Codec driver has .auto_selectable_formats settings
on snd_soc_dai_ops. The sample dtsi doesn't have it.
To avoid user confusion, this patch indicates it on comment.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87edjuzk2p.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-08-23 17:40:09 +01:00
Kuninori Morimoto
624fee4511
ASoC: soc-dai.h: merge DAI call back functions into ops
snd_soc_dai_driver has .ops for call back functions (A), but it also
has other call back functions (B). It is duplicated and confusable.

	struct snd_soc_dai_driver {
		...
 ^		int (*probe)(...);
 |		int (*remove)(...);
(B)		int (*compress_new)(...);
 |		int (*pcm_new)(...);
 v		...
(A)		const struct snd_soc_dai_ops *ops;
		...
	}

This patch merges (B) into (A).

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87v8dpb0w6.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-08-14 13:10:00 +01:00
Kuninori Morimoto
970dc991b2
ASoC: simple-card.c: enable multi Component support
If CPU/Codec driver keeps its DAI node, we can directly identify actual
DAI by using snd_soc_get_dai_via_args().
This means we can use multi Component.

This patch enables multi Component support for Simple Card

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/878rboo943.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-17 06:15:47 +01:00
Kuninori Morimoto
90de551c1b
ASoC: simple-card-utils.c: enable multi Component support
If CPU/Codec driver keeps its DAI node, we can directly identify actual
DAI by using snd_soc_get_dai_via_args().
This means we can use multi Component.

This patch enables multi Component support on Audio Graph Card/Card2.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87a5w4o949.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-17 06:15:47 +01:00
Kuninori Morimoto
988bad5ee4
ASoC: soc-core.c: add snd_soc_dlc_use_cpu_as_platform()
Current snd_soc_is_matching_component() checks "of_node" or "dai_args".
Thus coping "of_node" only is not enough to use CPU as Platform.
This patch adds snd_soc_dlc_use_cpu_as_platform() and help it.

This is helper function for multi Component support.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87cz10o94k.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-17 06:15:45 +01:00
Herve Codina
6d8ad35d11
ASoC: simple-card: Handle additional devices
An additional-devs subnode can be present in the simple-card top node.
This subnode is used to declared some "virtual" additional devices.

Create related devices from this subnode and avoid this subnode presence
to interfere with the already supported subnodes analysis.

Signed-off-by: Herve Codina <herve.codina@bootlin.com>
Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Link: https://lore.kernel.org/r/20230623085830.749991-14-herve.codina@bootlin.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-09 22:48:20 +01:00
Kuninori Morimoto
0baa2c3abc
ASoC: simple-card.c: use snd_soc_{of_}get_dlc()
Current ASoC has snd_soc_{of_}get_dai_name() to get DAI name
for dlc (snd_soc_dai_link_component).
But we now can use snd_soc_{of_}get_dlc() for it. Let's use it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87fs6mdgmc.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-06-20 12:49:29 +01:00
Kuninori Morimoto
3c8b586185
ASoC: soc-core.c: add index on snd_soc_of_get_dai_name()
Current snd_soc_of_get_dai_name() doesn't accept index
for #sound-dai-cells. It is not useful for user.
This patch adds it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87pm5qdgng.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-06-20 12:49:22 +01:00
Mark Brown
1a32b4b9a6
ASoC: Merge fixes due to dependencies
So we can apply the tlv320aic3xxx DT conversion.
2023-06-16 14:55:20 +01:00
Kuninori Morimoto
45b4ad53d4
ASoC: simple_card_utils: remove unused cpus/codecs/platforms from props
simple_dai_props has cpus/codecs/platforms. These pointer were used
for dai_link before, but are allocated today since
commit 050c7950fd ("ASoC: simple-card-utils: alloc dai_link
information for CPU/Codec/Platform").
We don't need to keep it anymore. This patch removes these.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87bkhhxpc6.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-06-15 12:08:41 +01:00
Kuninori Morimoto
fed4be313a
ASoC: simple-card-utils.c: share asoc_graph_parse_dai()
Current Audio Graph Card/Card2 implements asoc_simple_parse_dai()
on each driver, but these are same function.
This patch share it as asoc_graph_parse_dai().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87o7lihpvy.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-06-14 14:47:53 +01:00
Kuninori Morimoto
fd6f223639
ASoC: audio-graph-card2-custom-sample.dtsi: remove DT warning
Current audio-graph-card2-custom-sample.dtsi is missing
address-cells / size-cells / reg. Thus it get too many DT warnings.
This patch solved it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87a5x5qw3d.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-06-12 14:47:50 +01:00
Kuninori Morimoto
ca27441efe
ASoC: audio-graph-card2-custom-sample: add missing CPU:Codec = 1:N sample
It has CPU:Codec = 1:1 and N:N samples, but missing 1:N settings.
This patch adds it.

One note here is that because of registering timing, probing and
CPU/Codec numbering are mismatching.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87ilbx1kh3.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-06-09 10:44:41 +01:00
Robert Hancock
635071f5fe
ASoC: simple-card-utils: fix PCM constraint error check
The code in asoc_simple_startup was treating any non-zero return from
snd_pcm_hw_constraint_minmax as an error, when this can return 1 in some
normal cases and only negative values indicate an error.

When this happened, it caused asoc_simple_startup to disable the clocks
it just enabled and return 1, which was not treated as an error by the
calling code which only checks for negative return values. Then when the
PCM is eventually shut down, it causes the clock framework to complain
about disabling clocks that were not enabled.

Fix the check for snd_pcm_hw_constraint_minmax return value to only
treat negative values as an error.

Fixes: 5ca2ab4598 ("ASoC: simple-card-utils: Add new system-clock-fixed flag")
Signed-off-by: Robert Hancock <robert.hancock@calian.com>
Link: https://lore.kernel.org/r/20230602011936.231931-1-robert.hancock@calian.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-06-02 12:54:06 +01:00
Herve Codina
8938f75a5e
ASoC: simple-card: Add missing of_node_put() in case of error
In the error path, a of_node_put() for platform is missing.
Just add it.

Signed-off-by: Herve Codina <herve.codina@bootlin.com>
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/20230523151223.109551-9-herve.codina@bootlin.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-05-26 16:35:26 +01:00
Kuninori Morimoto
4d62611256
ASoC: simple_card_utils.c: use asoc_dummy_dlc
Now we can share asoc_dummy_dlc. This patch use it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com
Link: https://lore.kernel.org/r/87ttx6ypi3.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org
2023-05-08 08:47:14 +09:00
Kuninori Morimoto
a1cd7e8017
ASoC: audio-graph-card2: switch to use c2c_params instead of params
ASoC is now using c2c_params instead of params. This patch replace it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87mt3pc2la.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-04-05 12:16:37 +01:00
Kuninori Morimoto
ad58151fa0
ASoC: audio-graph-card2-custom-sample.dtsi: use card->name to avoid long name
Current Card2 Custom Sample will be too long Card name, and be error

	audio-graph-card2-custom-sample audio-graph-card2-custom-sample \
		ASoC: driver name too long \
		audio-graph-card2-custom-sample' -> 'audio-graph-car'

This patch uses short name to avoid it

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87bkke7qzf.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-03-27 13:09:49 +01:00
Kuninori Morimoto
92405802a7
ASoC: simple-card.c: add missing of_node_put()
It is missing of_node_put() for platform.
This patch fixup it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87ilerjcvr.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-03-24 12:15:23 +00:00
Kuninori Morimoto
dcf084247e
ASoC: simple-card: add comment to indicate don't remove platforms
Basically CPU and Platform are different Component, but if CPU is using
soc-generic-dmaengine-pcm, same dev will be shared between CPU and
Platform, and Simple Card had been supporting it.

When we focus to clean up Simple Card driver, we tend to remove platforms
if no Platform was selected, but it is wrong because of above reasons.

This patch adds comment why we shouldn't remove platforms.

In case of CPU is not using soc-generic-dmaengine-pcm, CPU and Platform
will be duplicated, but it will be ignored by snd_soc_rtd_add_component().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/875yattwqv.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-03-22 13:17:38 +00:00
Uwe Kleine-König
53946256cb
ASoC: generic: test-component: Convert to platform remove callback returning void
The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is (mostly) ignored
and this typically results in resource leaks. To improve here there is a
quest to make the remove callback return void. In the first step of this
quest all drivers are converted to .remove_new() which already returns
void.

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Takashi Iwai <tiwai@suse.de>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Link: https://lore.kernel.org/r/20230315150745.67084-86-u.kleine-koenig@pengutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-03-20 13:08:16 +00:00
Rob Herring
1e108e60a4
ASoC: Use of_property_present() for testing DT property presence
It is preferred to use typed property access functions (i.e.
of_property_read_<type> functions) rather than low-level
of_get_property/of_find_property functions for reading properties. As
part of this, convert of_get_property/of_find_property calls to the
recently added of_property_present() helper when we just want to test
for presence of a property and nothing more.

Signed-off-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20230310144732.1546328-1-robh@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-03-11 12:18:54 +00:00
Astrid Rost
9b271207ac
ASoC: simple-card-utils: create jack inputs for aux_devs
Add a generic way to create jack inputs for auxiliary jack detection
drivers (e.g. via i2c, spi), which are not part of any real codec.
The simple-card can be used as combining card driver to add the jacks,
no new one is required.

Create a jack (for input-events) for jack devices in the auxiliary
device list (aux_devs). A device which returns a valid value on
get_jack_type counts as jack device; set_jack is required
to add the jack to the device.

Signed-off-by: Astrid Rost <astrid.rost@axis.com>
Link: https://lore.kernel.org/r/20230123135913.2720991-3-astrid.rost@axis.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-01-27 12:20:55 +00:00
Wang Yufen
8ab2d12c72
ASoC: audio-graph-card: fix refcount leak of cpu_ep in __graph_for_each_link()
The of_get_next_child() returns a node with refcount incremented, and
decrements the refcount of prev. So in the error path of the while loop,
of_node_put() needs be called for cpu_ep.

Fixes: fce9b90c1a ("ASoC: audio-graph-card: cleanup DAI link loop method - step2")
Signed-off-by: Wang Yufen <wangyufen@huawei.com>
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/1670228127-13835-1-git-send-email-wangyufen@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-12-07 14:19:12 +00:00
Kuninori Morimoto
1985fa962a
ASoC: audio-graph-card2: remove Experimental announce
Audio Graph Card2 has been announcing "Audio Graph Card2 is
still under Experimental stage", but it is time to remove it.
This patch removes it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87k042nm6s.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-11-11 17:26:52 +00:00
Kuninori Morimoto
8f5979833b
ASoC: audio-graph-card2: check also dpcm node for convert-xxx
DPCM connection on Card2, its DT looks like below.
Current Card2 is checking (a)/(b) part only for convert-xxx settings.
But it is not useful. This patch enables its settings at (A)/(B) part
too. (A)/(B) settings will be overwritten (a)/(b) settings if it has.

<Image>		      (A)	(a)
	Card2 <--+--> FE <---> CPU
		 |
		 +--> BE <---> Codec
		      (B)	(b)

<DT>
	card2-sound {
		...
		links = <fe, be>; /* (A) (B) */
	};

	dpcm {
		/* FE */
		ports@0 {
			/* (A) */
			fe: port { fe_ep: endpoint { remote-endpoint = <&cpu_ep>; } };
		};
		/* BE */
		ports@1 {
			/* (B) */
			be: port {
				convert-rate = <44100>; /* This patch enables this */
				be_ep: endpoint { remote-endpoint = <&codec_ep>; }
			};
		};
	};

	cpu {
		/* CPU (a) */
		port { cpu_ep: endpoint { remote-endpoint = <&fe_ep>; } };
	};

	codec {
		/* Codec (b) */
		port {
			convert-rate = <48000>; /* (B) settings will be over written here */
			codec_ep: endpoint { remote-endpoint = <&be_ep>; }
		};
	};

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/871qqn8fst.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-11-07 13:58:07 +00:00
Kuninori Morimoto
2dc025aba7
ASoC: audio-graph-card2-custom-sample.dtsi: add convert-rate for DPCM (MIXer)
audio-graph-card2-custom-sample.dtsi is assuming that
DPCM sample is MIXer connection.

	FE		BE
	        ****
	CPU3 -- *  * -- Codec3
	CPU4 -- *  *
	        ****

CPU3/CPU4 need to convert rate in this case.
This patch adds missing "convert-rate" setting sample for it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/8735b38fta.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-11-07 13:58:06 +00:00
Kuninori Morimoto
5c065eaf44
ASoC: simple-card-utils: remove asoc_simple_convert_fixup()
No one is using asoc_simple_convert_fixup(), we don't need to
export its symbol. This patch removes it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/874jvj8ftp.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-11-07 13:58:05 +00:00
Aidan MacDonald
32def55d23
ASoC: simple-card: Fix up checks for HW param fixups
The "convert-xxx" properties only have an effect for DPCM DAI links.
A DAI link is only created as DPCM if the device tree requires it;
part of this involves checking for the use of "convert-xxx" properties.

When the convert-sample-format property was added, the checks got out
of sync. A DAI link that specified only convert-sample-format but did
not pass any of the other DPCM checks would not go into DPCM mode and
the convert-sample-format property would be silently ignored.

Fix this by adding a function to do the "convert-xxx" property checks,
instead of open-coding it in simple-card and audio-graph-card. And add
"convert-sample-format" to the check function so that DAI links using
it will be initialized correctly.

Fixes: 047a05366f ("ASoC: simple-card-utils: Fixup DAI sample format")
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>
Acked-by: Sameer Pujar <spujar@nvidia.com>
Link: https://lore.kernel.org/r/20221019012302.633830-1-aidanmacdonald.0x0@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-10-19 13:39:34 +01:00
Dmitry Torokhov
355beeed93
ASoC: simple-card-utils: switch to using gpiod API
This patch switches the driver away from legacy gpio/of_gpio API to
gpiod API, and removes use of of_get_named_gpio_flags() which I want to
make private to gpiolib.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/YxeaITtlJexygQo9@google.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-09-07 12:42:22 +01:00
Sameer Pujar
047a05366f
ASoC: simple-card-utils: Fixup DAI sample format
Parse "convert-sample-format" DT binding and fixup the sample format
as applicable. This is similar to the existing "convert-channels" and
"convert-rate" properties for channels and rate fixup respectively.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/1659936452-2254-4-git-send-email-spujar@nvidia.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-08-15 01:19:55 +01:00
Liang He
8ebc4dd825
ASoC: audio-graph-card2: Add of_node_put() in fail path
In asoc_simple_parse_dai(), we should call of_node_put() for the
reference returned by of_graph_get_port_parent() in fail path.

Fixes: 6e5f68fe3f ("ASoC: add Audio Graph Card2 driver")
Signed-off-by: Liang He <windhl@126.com>
Link: https://lore.kernel.org/r/20220722141801.1304854-1-windhl@126.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-07-22 21:27:55 +01:00
Liang He
65fb8e2ef3
ASoC: audio-graph-card: Add of_node_put() in fail path
In asoc_simple_parse_dai(), we should call of_node_put() for the
reference returned by of_graph_get_port_parent() in fail path.

Fixes: ae30a694da ("ASoC: simple-card-utils: add asoc_simple_card_parse_dai()")
Signed-off-by: Liang He <windhl@126.com>
Link: https://lore.kernel.org/r/20220721144308.1301587-1-windhl@126.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-07-21 23:25:54 +01:00
Liang He
eda26893da
ASoc: audio-graph-card2: Fix refcount leak bug in __graph_get_type()
We should call of_node_put() for the reference before its replacement
as it returned by of_get_parent() which has increased the refcount.
Besides, we should also call of_node_put() before return.

Fixes: c8c74939f7 ("ASoC: audio-graph-card2: add Multi CPU/Codec support")
Signed-off-by: Liang He <windhl@126.com>
Link: https://lore.kernel.org/r/20220713071200.366729-1-windhl@126.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-07-13 13:48:54 +01:00
Kuninori Morimoto
16b7ba9c0f
ASoC: simple-card-utils.c: care Codec2Codec vs DPCM:BE
Current asoc_simple_init_for_codec2codec() adds default Codec2Codec
settings if rtd was Codec only.
But DPCM:BE also judged as Codec only, because dummy-DAI doesn't have
"endianness" (which is key parameter to judge as Codec).

This patch ignores setup Codec2Codec settings if it was DPCM:BE case.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87a69ts950.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-07-08 11:51:46 +01:00
Kuninori Morimoto
75d1b39067
ASoC: simple-card-utils.c: ignore Codec2Codec setting if it already have
Audio Graph Card2 setups own Codec2Codec settings,
but current simple-card-utils.c will try to setup Codec2Codec default
settings if needed, it will overwirtes the settings.
This patch ignores default Codec2Codec settings if it already have.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87bku9s95b.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-07-08 11:51:45 +01:00
Kuninori Morimoto
d33083f941
ASoC: audio-graph-card2-custom-sample.dtsi: add verbose explanation
audio-graph-card2-custom-sample.dtsi will be used to test
Audio-Graph-Card2 behavior. But it is difficult to say that it is easy
to understand, because the comment/explanation are not so many.

This patch add verbose explanation to it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87czeps95h.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-07-08 11:51:44 +01:00
Kuninori Morimoto
6976ed0137
ASoC: audio-graph-card2.c: remove pre-alloced Codec2Codec space
Because Codec2Codec settings becomes optional, we don't need to keep
its parameter space when init time. This patch removes its default
memory allocation from simple-card-utils.c, and allocate it at
audio-graph-card2 ondemand.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87edz5s95o.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-07-08 11:51:43 +01:00
Kuninori Morimoto
c2ff7f15a4
ASoC: audio-graph-card2.c: make Codec2Codec settings optional
Current audio-graph-card2 can use Codec2Codec, and having its
original parameter (= rate) on DT is mandatory for now.

But simple-card-utils.c has asoc_simple_init_for_codec2codec() to
setup *default* Codec2Codec settings.

This patch makes Audio Graph Card2 Codec2Codec rate settings
optional.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87fsjls95u.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-07-08 11:51:42 +01:00
Kuninori Morimoto
817a62108d
ASoC: audio-graph-card2.c: use of_property_read_u32() for rate
Audio Graph Card2 is using of_get_property(), but it should use
of_property_read_u32() to getting rate. Otherwise the setting will be
strange value. This patch fixup it.

Fixes: c3a15c92a6 ("ASoC: audio-graph-card2: add Codec2Codec support")
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87h741s961.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-07-08 11:51:41 +01:00
Mark Brown
fc34ece41f
ASoC: Refactor non_legacy_dai_naming flag
Merge series from Charles Keepax <ckeepax@opensource.cirrus.com>:

Historically, the legacy DAI naming scheme was applied to platform
drivers and the newer scheme to CODEC drivers. During componentisation
the core lost the knowledge of if a driver was a CODEC or platform, they
were all now components. To continue to support the legacy naming on
older platform drivers a flag was added to the snd_soc_component_driver
structure, non_legacy_dai_naming, to indicate to use the new scheme and
this was applied to all CODECs as part of the migration.

However, a slight issue appears to be developing with respect to this
flag being opt in for the non-legacy scheme, which presumably we want to
be the primary scheme used. Many codec drivers appear to forget to
include this flag:

  grep -l -r "snd_soc_component_driver" sound/soc/codecs/*.c |
  xargs grep -L "non_legacy_dai_naming" | wc
     48      48    556

Whilst in many cases the configuration of the DAIs themselves will cause
the core to apply the new scheme anyway, it would seem more sensible to
change the flag to legacy_dai_naming making the new scheme opt out. This
patch series migrates across to such a scheme.
2022-06-29 16:58:08 +01:00
Mark Brown
b9566b1d1f
ASoC: Merge up fixes
Further development will need some of the fixes.
2022-06-27 18:27:03 +01:00
Charles Keepax
485c5924f2
ASoC: test-component: Remove now redundant non_legacy_dai_naming flag
The ASoC core has now been changed to default to the non-legacy DAI
naming, as such drivers using the new scheme no longer need to specify
the non_legacy_dai_naming flag.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220623125250.2355471-44-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-27 13:16:53 +01:00
Charles Keepax
d73130ba52
ASoC: test-component: Migrate to new style legacy DAI naming flag
Change the legacy DAI naming flag from opting in to the new scheme
(non_legacy_dai_naming), to opting out of it (legacy_dai_naming).
This driver appears to be on the CPU side of the DAI link and
currently uses the legacy naming, so add the new flag.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220623125250.2355471-26-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-27 13:16:37 +01:00
Sascha Hauer
e112c42eb3
ASoC: audio_graph_card2: Fix port numbers in example
The example in audio-graph-card2.c has multiple nodes with the same name
in it. Change the port numbers to get different names.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Link: https://lore.kernel.org/r/20220624092601.2445224-1-s.hauer@pengutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-24 16:27:24 +01:00
Mark Brown
d3d8feadcc
Specify clock provider directly to CPU DAIs
Merge series from Charles Keepax <ckeepax@opensource.cirrus.com>:

Currently the set_fmt callback always passes clock provider/consumer
with respect to the CODEC. This made sense when the framework was
directly broken down into platforms and CODECs. However, as things
are now broken down into components which can be connected as either
the CPU or CODEC side of a DAI link it simplifies things if each
side of the link is just told if it is provider or consumer of the
clocks. Making this change allows us to remove one of the last parts
of the ASoC core that needs to know if a driver is a CODEC driver,
where it flips the clock format specifier if a CODEC driver is used on
the CPU side of a DAI link, as well as just being conceptually more
consistent with componentisation.

The basic idea of this patch chain is to change the set_fmt callback
from specifying if the CODEC is provider/consumer into directly
specifying if the component is provider/consumer. To do this we add
some new defines, and then to preserve bisectability, the migration is
done by adding a new callback, converting over all existing CPU side
drivers, converting the core, and then finally reverting back to the
old callback.

Converting the platform drivers makes sense as the existing defines
are from the perspective of the CODEC and there are more CODEC drivers
than platform drivers.

Obviously a fair amount of this patch chain I was only able to build
test, so any testing that can be done would be greatly appreciated.
2022-06-09 11:56:32 +01:00
Uwe Kleine-König
e6f08af634
ASoC: simple-card-utils: Make asoc_simple_clean_reference() return void
asoc_simple_clean_reference() returns zero unconditionally. Letting it
return void instead makes it easier to see in the caller that there is no
error to handle.

This is a preparation for making platform remove callbacks return void.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20220605153537.26591-1-u.kleine-koenig@pengutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-07 12:00:43 +01:00
Kuninori Morimoto
ff31753fcb
ASoC: simple-card-utils: rename asoc_simple_init_dai_link_params() to asoc_simple_init_for_codec2codec()
commit 95cfc0a0aa ("ASoC: simple-card: Add support for
codec2codec DAI links") added the function
asoc_simple_init_dai_link_params() to initialize dai_link "params".
It is very straight naming, but difficult to noticed that it is for
Codec2Codec support. Handling Codec2Codec is one of very tricky part
on ALSA SoC, thus it is very important to clarify it. This patch
renames the function name.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87o7zflk3n.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-06 12:38:40 +01:00
Charles Keepax
28086d05ad
ASoC: simple-card-utils: Move snd_soc_component_is_codec to be local
The helper function snd_soc_component_is_codec is based off the
presence of the non_legacy_dai_naming flag. This isn't super robust
as CPU side components may also specify this flag, and indeed the
kernel already contains a couple that do. After componentisation there
isn't really a totally robust solution to identifying what is a CODEC
driver, without introducing a flag specifically for that purpose, and
really the desirable direction to move in is that the distinction
doesn't matter.

This patch does two things to try to mitigate these problems. Firstly,
now that all the other users of the helper function have been removed,
it makes the helper function local to the driver rather, than being
part of the core. This should help to discourage any new code from
being created that depends on the CODEC driver distinction. Secondly,
it updates the helper function itself to use the endianness flag
rather than the non_legacy_dai_naming flag. The endianness flag is
definitely invalid on a CPU side component, so it a more reliable
indicator that the device is definitely a CODEC. The vast majority of
buses require the CODEC to set the endianness flag, so the number of
corner cases should be fairly minimal. It is worth noting that CODECs
sending audio over SPI, or built into the CPU CODECs are potential
corner cases, however the hope is that in most cases those types of
devices do not consitute a simple audio card.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220519154318.2153729-57-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-06 12:34:22 +01:00