Skip to content

Commit 4b73a4c

Browse files
committed
ASoC: Cleanup MediaTek soundcard machine drivers
Merge series from AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>: Changes in v5: - Cleaned up MT8186 soundcard migration commit which erroneously had leftovers from development - Changed the mtk_pcm_constraints_data structure to hold pointers to snd_pcm_hw_constraint_list, as to really reuse the const data - Tested again on all of the listed MTK platforms. Changes in v4: - Rebased over next-20240409 - Dropped the first 4 patches from v3 as were already picked by Mark - Fixed W=1 build issue Changes in v3: - Added audio-routing names in enum in all yaml files - Added mention of disallowing old and new properties together in commit message of bindings patches - Fixed validation errors with sound-card-common.yaml inclusion due to missing model property in examples - Removed `else` enforcing headset-codec/speaker-codecs requirement if xxx-dai-link not present to avoid future commit noise as the deprecated statement will disallow deprecated properties as required Changes in v2: - Bindings: Changed link-name/codec/clk-provider to remove `items` and leave just the enum - Moved .*-dai-link pattern additionalProperties after `type: object` - Added ref to sound-card-common.yaml - Fixed dai-link-xxx -> xxx-dai-link typo in example comment This series performs a cleanup of most of the MediaTek AFE drivers and soundcard machine drivers, reducing code duplication and setting a base to be consistent with their devicetree bindings, as many of those are using different properties and nodes for no good reason. Summarizing: - Commonizes functions and ops where possible - Adds a common probe mechanism, increasing maintainability of soundcard drivers for older MediaTek SoCs - Migrates all drivers to support the new bindings - Obviously retains compatibility with old device trees - Reduces machine-specific parameters hardcoding in drivers - Can now set machine-specific params in device tree - Uses the `audio-routing` and `dai-link` nodes like some other non-MediaTek SoC sound drivers - Imposes consistency between MediaTek ASoC machine soundcard drivers bindings - Reduces code size and greatly reduces the amount of code that will be required for newer drivers (retaining compatibility with the old bindings was costly in terms of code size, otherwise this series would've removed ~1000 more lines, or something along that line). This series was (manually) tested on MT8173, MT8192, MT8195 and MT8186 Chromebooks. AngeloGioacchino Del Regno (18): ASoC: mediatek: Add common machine soundcard driver probe mechanism ASoC: mediatek: common: Constify struct mtk_sof_priv ASoC: mediatek: mt8188: Migrate to mtk_soundcard_common_probe ASoC: mediatek: mt8195: Migrate to mtk_soundcard_common_probe ASoC: mediatek: mt8192: Migrate to mtk_soundcard_common_probe ASoC: mediatek: mt8186: Migrate to mtk_soundcard_common_probe ASoC: mediatek: Add common snd_soc_ops .startup() callback ASoC: mediatek: mt8195: Migrate to the common mtk_soundcard_startup ASoC: mediatek: mt8192: Migrate to the common mtk_soundcard_startup ASoC: mediatek: mt8186-rt1019: Migrate to the common mtk_soundcard_startup ASoC: mediatek: Add common mtk_afe_component_probe callback ASoC: mediatek: Use common mtk_afe_pcm_platform with common probe cb ASoC: mediatek: mt8186: Unify mt8186-mt6366 machine drivers ASoC: dt-bindings: mt8195: Document audio-routing and dai-link subnode ASoC: dt-bindings: mt8192: Document audio-routing and dai-link subnode ASoC: dt-bindings: mt8186: Document audio-routing and dai-link subnode arm64: dts: mediatek: mt8195-cherry: Specify sound DAI links and routing arm64: dts: mediatek: mt8186-corsola: Specify sound DAI links and routing .../sound/mt8186-mt6366-da7219-max98357.yaml | 131 +- .../sound/mt8186-mt6366-rt1019-rt5682s.yaml | 120 +- .../sound/mt8192-mt6359-rt1015-rt5682.yaml | 139 +- .../bindings/sound/mt8195-mt6359.yaml | 134 ++ .../boot/dts/mediatek/mt8186-corsola.dtsi | 42 +- .../boot/dts/mediatek/mt8195-cherry.dtsi | 45 + sound/soc/mediatek/Kconfig | 24 +- .../mediatek/common/mtk-afe-platform-driver.c | 18 + .../soc/mediatek/common/mtk-dsp-sof-common.c | 15 +- .../soc/mediatek/common/mtk-dsp-sof-common.h | 1 - sound/soc/mediatek/common/mtk-soc-card.h | 7 +- .../mediatek/common/mtk-soundcard-driver.c | 199 +++ .../mediatek/common/mtk-soundcard-driver.h | 42 + sound/soc/mediatek/mt6797/mt6797-afe-pcm.c | 14 +- sound/soc/mediatek/mt7986/mt7986-afe-pcm.c | 14 +- sound/soc/mediatek/mt8183/mt8183-afe-pcm.c | 14 +- sound/soc/mediatek/mt8186/Makefile | 3 +- .../mt8186/mt8186-mt6366-da7219-max98357.c | 1189 ----------------- ...t6366-rt1019-rt5682s.c => mt8186-mt6366.c} | 578 ++++---- sound/soc/mediatek/mt8188/mt8188-afe-pcm.c | 21 +- sound/soc/mediatek/mt8188/mt8188-mt6359.c | 203 +-- sound/soc/mediatek/mt8192/mt8192-afe-pcm.c | 25 +- .../mt8192/mt8192-mt6359-rt1015-rt5682.c | 301 ++--- sound/soc/mediatek/mt8195/mt8195-afe-pcm.c | 21 +- sound/soc/mediatek/mt8195/mt8195-mt6359.c | 487 +++---- 25 files changed, 1597 insertions(+), 2190 deletions(-) delete mode 100644 sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.c rename sound/soc/mediatek/mt8186/{mt8186-mt6366-rt1019-rt5682s.c => mt8186-mt6366.c} (72%) -- 2.44.0
2 parents 58300f8 + 787f190 commit 4b73a4c

23 files changed

Lines changed: 1515 additions & 2185 deletions

Documentation/devicetree/bindings/sound/mt8186-mt6366-da7219-max98357.yaml

Lines changed: 122 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,46 @@ maintainers:
1212
description:
1313
This binding describes the MT8186 sound card.
1414

15+
allOf:
16+
- $ref: sound-card-common.yaml#
17+
1518
properties:
1619
compatible:
1720
enum:
1821
- mediatek,mt8186-mt6366-da7219-max98357-sound
1922

23+
audio-routing:
24+
$ref: /schemas/types.yaml#/definitions/non-unique-string-array
25+
description:
26+
A list of the connections between audio components. Each entry is a
27+
pair of strings, the first being the connection's sink, the second
28+
being the connection's source.
29+
Valid names could be the input or output widgets of audio components,
30+
power supplies, MicBias of codec and the software switch.
31+
minItems: 2
32+
items:
33+
enum:
34+
# Sinks
35+
- HDMI1
36+
- Headphones
37+
- Line Out
38+
- MIC
39+
- Speakers
40+
41+
# Sources
42+
- Headset Mic
43+
- HPL
44+
- HPR
45+
- Speaker
46+
- TX
47+
2048
mediatek,platform:
2149
$ref: /schemas/types.yaml#/definitions/phandle
2250
description: The phandle of MT8186 ASoC platform.
2351

2452
headset-codec:
2553
type: object
54+
deprecated: true
2655
additionalProperties: false
2756
properties:
2857
sound-dai:
@@ -32,6 +61,7 @@ properties:
3261

3362
playback-codecs:
3463
type: object
64+
deprecated: true
3565
additionalProperties: false
3666
properties:
3767
sound-dai:
@@ -53,32 +83,115 @@ properties:
5383
A list of the desired dai-links in the sound card. Each entry is a
5484
name defined in the machine driver.
5585

56-
additionalProperties: false
86+
patternProperties:
87+
".*-dai-link$":
88+
type: object
89+
additionalProperties: false
90+
description:
91+
Container for dai-link level properties and CODEC sub-nodes.
92+
93+
properties:
94+
link-name:
95+
description: Indicates dai-link name and PCM stream name
96+
items:
97+
enum:
98+
- I2S0
99+
- I2S1
100+
- I2S2
101+
- I2S3
102+
103+
codec:
104+
description: Holds subnode which indicates codec dai.
105+
type: object
106+
additionalProperties: false
107+
properties:
108+
sound-dai:
109+
minItems: 1
110+
maxItems: 2
111+
required:
112+
- sound-dai
113+
114+
dai-format:
115+
description: audio format
116+
items:
117+
enum:
118+
- i2s
119+
- right_j
120+
- left_j
121+
- dsp_a
122+
- dsp_b
123+
124+
mediatek,clk-provider:
125+
$ref: /schemas/types.yaml#/definitions/string
126+
description: Indicates dai-link clock master.
127+
items:
128+
enum:
129+
- cpu
130+
- codec
131+
132+
required:
133+
- link-name
134+
135+
unevaluatedProperties: false
57136

58137
required:
59138
- compatible
60139
- mediatek,platform
61-
- headset-codec
62-
- playback-codecs
140+
141+
# Disallow legacy properties if xxx-dai-link nodes are specified
142+
if:
143+
not:
144+
patternProperties:
145+
".*-dai-link$": false
146+
then:
147+
properties:
148+
headset-codec: false
149+
speaker-codecs: false
63150

64151
examples:
65152
- |
66153
67154
sound: mt8186-sound {
68155
compatible = "mediatek,mt8186-mt6366-da7219-max98357-sound";
69-
mediatek,platform = <&afe>;
156+
model = "mt8186_da7219_m98357";
70157
pinctrl-names = "aud_clk_mosi_off",
71158
"aud_clk_mosi_on";
72159
pinctrl-0 = <&aud_clk_mosi_off>;
73160
pinctrl-1 = <&aud_clk_mosi_on>;
161+
mediatek,platform = <&afe>;
162+
163+
audio-routing =
164+
"Headphones", "HPL",
165+
"Headphones", "HPR",
166+
"MIC", "Headset Mic",
167+
"Speakers", "Speaker",
168+
"HDMI1", "TX";
169+
170+
hs-playback-dai-link {
171+
link-name = "I2S0";
172+
dai-format = "i2s";
173+
mediatek,clk-provider = "cpu";
174+
codec {
175+
sound-dai = <&da7219>;
176+
};
177+
};
74178
75-
headset-codec {
76-
sound-dai = <&da7219>;
179+
hs-capture-dai-link {
180+
link-name = "I2S1";
181+
dai-format = "i2s";
182+
mediatek,clk-provider = "cpu";
183+
codec {
184+
sound-dai = <&da7219>;
185+
};
77186
};
78187
79-
playback-codecs {
80-
sound-dai = <&anx_bridge_dp>,
81-
<&max98357a>;
188+
spk-dp-playback-dai-link {
189+
link-name = "I2S3";
190+
dai-format = "i2s";
191+
mediatek,clk-provider = "cpu";
192+
codec {
193+
sound-dai = <&anx_bridge_dp>, <&max98357a>;
194+
};
82195
};
83196
};
84197

Documentation/devicetree/bindings/sound/mt8186-mt6366-rt1019-rt5682s.yaml

Lines changed: 111 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,44 @@ maintainers:
1212
description:
1313
This binding describes the MT8186 sound card.
1414

15+
allOf:
16+
- $ref: sound-card-common.yaml#
17+
1518
properties:
1619
compatible:
1720
enum:
1821
- mediatek,mt8186-mt6366-rt1019-rt5682s-sound
1922
- mediatek,mt8186-mt6366-rt5682s-max98360-sound
2023
- mediatek,mt8186-mt6366-rt5650-sound
2124

25+
audio-routing:
26+
$ref: /schemas/types.yaml#/definitions/non-unique-string-array
27+
description:
28+
A list of the connections between audio components. Each entry is a
29+
pair of strings, the first being the connection's sink, the second
30+
being the connection's source.
31+
Valid names could be the input or output widgets of audio components,
32+
power supplies, MicBias of codec and the software switch.
33+
minItems: 2
34+
items:
35+
enum:
36+
# Sinks
37+
- HDMI1
38+
- Headphone
39+
- IN1P
40+
- IN1N
41+
- Line Out
42+
- Speakers
43+
44+
# Sources
45+
- Headset Mic
46+
- HPOL
47+
- HPOR
48+
- Speaker
49+
- SPOL
50+
- SPOR
51+
- TX
52+
2253
mediatek,platform:
2354
$ref: /schemas/types.yaml#/definitions/phandle
2455
description: The phandle of MT8186 ASoC platform.
@@ -32,6 +63,7 @@ properties:
3263

3364
headset-codec:
3465
type: object
66+
deprecated: true
3567
additionalProperties: false
3668
properties:
3769
sound-dai:
@@ -41,6 +73,7 @@ properties:
4173

4274
playback-codecs:
4375
type: object
76+
deprecated: true
4477
additionalProperties: false
4578
properties:
4679
sound-dai:
@@ -62,37 +95,106 @@ properties:
6295
A list of the desired dai-links in the sound card. Each entry is a
6396
name defined in the machine driver.
6497

65-
additionalProperties: false
98+
patternProperties:
99+
".*-dai-link$":
100+
type: object
101+
additionalProperties: false
102+
description:
103+
Container for dai-link level properties and CODEC sub-nodes.
104+
105+
properties:
106+
link-name:
107+
description: Indicates dai-link name and PCM stream name
108+
enum: [ I2S0, I2S1, I2S2, I2S3 ]
109+
110+
codec:
111+
description: Holds subnode which indicates codec dai.
112+
type: object
113+
additionalProperties: false
114+
properties:
115+
sound-dai:
116+
minItems: 1
117+
maxItems: 2
118+
required:
119+
- sound-dai
120+
121+
dai-format:
122+
description: audio format
123+
enum: [ i2s, right_j, left_j, dsp_a, dsp_b ]
124+
125+
mediatek,clk-provider:
126+
$ref: /schemas/types.yaml#/definitions/string
127+
description: Indicates dai-link clock master.
128+
enum: [ cpu, codec ]
129+
130+
required:
131+
- link-name
132+
133+
unevaluatedProperties: false
66134

67135
required:
68136
- compatible
69137
- mediatek,platform
70-
- headset-codec
71-
- playback-codecs
138+
139+
# Disallow legacy properties if xxx-dai-link nodes are specified
140+
if:
141+
not:
142+
patternProperties:
143+
".*-dai-link$": false
144+
then:
145+
properties:
146+
headset-codec: false
147+
speaker-codecs: false
72148

73149
examples:
74150
- |
75151
#include <dt-bindings/gpio/gpio.h>
76152
77153
sound: mt8186-sound {
78154
compatible = "mediatek,mt8186-mt6366-rt1019-rt5682s-sound";
79-
mediatek,platform = <&afe>;
155+
model = "mt8186_rt1019_rt5682s";
80156
pinctrl-names = "aud_clk_mosi_off",
81157
"aud_clk_mosi_on",
82158
"aud_gpio_dmic_sec";
83159
pinctrl-0 = <&aud_clk_mosi_off>;
84160
pinctrl-1 = <&aud_clk_mosi_on>;
85161
pinctrl-2 = <&aud_gpio_dmic_sec>;
162+
mediatek,platform = <&afe>;
86163
87164
dmic-gpios = <&pio 23 GPIO_ACTIVE_HIGH>;
88165
89-
headset-codec {
90-
sound-dai = <&rt5682s>;
166+
audio-routing =
167+
"Headphone", "HPOL",
168+
"Headphone", "HPOR",
169+
"IN1P", "Headset Mic",
170+
"Speakers", "Speaker",
171+
"HDMI1", "TX";
172+
173+
hs-playback-dai-link {
174+
link-name = "I2S0";
175+
dai-format = "i2s";
176+
mediatek,clk-provider = "cpu";
177+
codec {
178+
sound-dai = <&rt5682s 0>;
179+
};
180+
};
181+
182+
hs-capture-dai-link {
183+
link-name = "I2S1";
184+
dai-format = "i2s";
185+
mediatek,clk-provider = "cpu";
186+
codec {
187+
sound-dai = <&rt5682s 0>;
188+
};
91189
};
92190
93-
playback-codecs {
94-
sound-dai = <&it6505dptx>,
95-
<&rt1019p>;
191+
spk-hdmi-playback-dai-link {
192+
link-name = "I2S3";
193+
dai-format = "i2s";
194+
mediatek,clk-provider = "cpu";
195+
codec {
196+
sound-dai = <&it6505dptx>, <&rt1019p>;
197+
};
96198
};
97199
};
98200

0 commit comments

Comments
 (0)