Skip to content

Commit 0cbf1ec

Browse files
stephan-ghbroonie
authored andcommitted
ASoC: qcom: Fix building APQ8016 machine driver without SOUNDWIRE
Older Qualcomm platforms like APQ8016 do not have hardware support for SoundWire, so kernel configurations made specifically for those platforms will usually not have CONFIG_SOUNDWIRE enabled. Unfortunately commit 8d89cf6 ("ASoC: qcom: cleanup and fix dependency of QCOM_COMMON") breaks those kernel configurations, because SOUNDWIRE is now a required dependency for SND_SOC_QCOM_COMMON (and in turn also SND_SOC_APQ8016_SBC). Trying to migrate such a kernel config silently disables SND_SOC_APQ8016_SBC and breaks audio functionality. The soundwire helpers in common.c are only used by two of the Qualcomm audio machine drivers, so building and requiring CONFIG_SOUNDWIRE for all platforms is unnecessary. There is no need to stuff all common code into a single module. Fix the issue by moving the soundwire helpers to a separate SND_SOC_QCOM_SDW module/option that is selected only by the machine drivers that make use of them. This also allows reverting the imply/depends changes from the previous fix because both SM8250 and SC8280XP already depend on SOUNDWIRE, so the soundwire helpers will be only built if SOUNDWIRE is really enabled. Cc: Srinivas Kandagatla <[email protected]> Fixes: 8d89cf6 ("ASoC: qcom: cleanup and fix dependency of QCOM_COMMON") Signed-off-by: Stephan Gerhold <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent cdfa92e commit 0cbf1ec

File tree

8 files changed

+157
-133
lines changed

8 files changed

+157
-133
lines changed

sound/soc/qcom/Kconfig

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
menuconfig SND_SOC_QCOM
33
tristate "ASoC support for QCOM platforms"
44
depends on ARCH_QCOM || COMPILE_TEST
5-
imply SND_SOC_QCOM_COMMON
65
help
76
Say Y or M if you want to add support to use audio devices
87
in Qualcomm Technologies SOC-based platforms.
@@ -60,14 +59,16 @@ config SND_SOC_STORM
6059
config SND_SOC_APQ8016_SBC
6160
tristate "SoC Audio support for APQ8016 SBC platforms"
6261
select SND_SOC_LPASS_APQ8016
63-
depends on SND_SOC_QCOM_COMMON
62+
select SND_SOC_QCOM_COMMON
6463
help
6564
Support for Qualcomm Technologies LPASS audio block in
6665
APQ8016 SOC-based systems.
6766
Say Y if you want to use audio devices on MI2S.
6867

6968
config SND_SOC_QCOM_COMMON
70-
depends on SOUNDWIRE
69+
tristate
70+
71+
config SND_SOC_QCOM_SDW
7172
tristate
7273

7374
config SND_SOC_QDSP6_COMMON
@@ -144,7 +145,7 @@ config SND_SOC_MSM8996
144145
depends on QCOM_APR
145146
depends on COMMON_CLK
146147
select SND_SOC_QDSP6
147-
depends on SND_SOC_QCOM_COMMON
148+
select SND_SOC_QCOM_COMMON
148149
help
149150
Support for Qualcomm Technologies LPASS audio block in
150151
APQ8096 SoC-based systems.
@@ -155,7 +156,7 @@ config SND_SOC_SDM845
155156
depends on QCOM_APR && I2C && SOUNDWIRE
156157
depends on COMMON_CLK
157158
select SND_SOC_QDSP6
158-
depends on SND_SOC_QCOM_COMMON
159+
select SND_SOC_QCOM_COMMON
159160
select SND_SOC_RT5663
160161
select SND_SOC_MAX98927
161162
imply SND_SOC_CROS_EC_CODEC
@@ -169,7 +170,8 @@ config SND_SOC_SM8250
169170
depends on QCOM_APR && SOUNDWIRE
170171
depends on COMMON_CLK
171172
select SND_SOC_QDSP6
172-
depends on SND_SOC_QCOM_COMMON
173+
select SND_SOC_QCOM_COMMON
174+
select SND_SOC_QCOM_SDW
173175
help
174176
To add support for audio on Qualcomm Technologies Inc.
175177
SM8250 SoC-based systems.
@@ -180,7 +182,8 @@ config SND_SOC_SC8280XP
180182
depends on QCOM_APR && SOUNDWIRE
181183
depends on COMMON_CLK
182184
select SND_SOC_QDSP6
183-
depends on SND_SOC_QCOM_COMMON
185+
select SND_SOC_QCOM_COMMON
186+
select SND_SOC_QCOM_SDW
184187
help
185188
To add support for audio on Qualcomm Technologies Inc.
186189
SC8280XP SoC-based systems.
@@ -190,7 +193,7 @@ config SND_SOC_SC7180
190193
tristate "SoC Machine driver for SC7180 boards"
191194
depends on I2C && GPIOLIB
192195
depends on SOUNDWIRE || SOUNDWIRE=n
193-
depends on SND_SOC_QCOM_COMMON
196+
select SND_SOC_QCOM_COMMON
194197
select SND_SOC_LPASS_SC7180
195198
select SND_SOC_MAX98357A
196199
select SND_SOC_RT5682_I2C
@@ -204,7 +207,7 @@ config SND_SOC_SC7180
204207
config SND_SOC_SC7280
205208
tristate "SoC Machine driver for SC7280 boards"
206209
depends on I2C && SOUNDWIRE
207-
depends on SND_SOC_QCOM_COMMON
210+
select SND_SOC_QCOM_COMMON
208211
select SND_SOC_LPASS_SC7280
209212
select SND_SOC_MAX98357A
210213
select SND_SOC_WCD938X_SDW

sound/soc/qcom/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ snd-soc-sdm845-objs := sdm845.o
2828
snd-soc-sm8250-objs := sm8250.o
2929
snd-soc-sc8280xp-objs := sc8280xp.o
3030
snd-soc-qcom-common-objs := common.o
31+
snd-soc-qcom-sdw-objs := sdw.o
3132

3233
obj-$(CONFIG_SND_SOC_STORM) += snd-soc-storm.o
3334
obj-$(CONFIG_SND_SOC_APQ8016_SBC) += snd-soc-apq8016-sbc.o
@@ -38,6 +39,7 @@ obj-$(CONFIG_SND_SOC_SC8280XP) += snd-soc-sc8280xp.o
3839
obj-$(CONFIG_SND_SOC_SDM845) += snd-soc-sdm845.o
3940
obj-$(CONFIG_SND_SOC_SM8250) += snd-soc-sm8250.o
4041
obj-$(CONFIG_SND_SOC_QCOM_COMMON) += snd-soc-qcom-common.o
42+
obj-$(CONFIG_SND_SOC_QCOM_SDW) += snd-soc-qcom-sdw.o
4143

4244
#DSP lib
4345
obj-$(CONFIG_SND_SOC_QDSP6) += qdsp6/

sound/soc/qcom/common.c

Lines changed: 0 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -180,120 +180,6 @@ int qcom_snd_parse_of(struct snd_soc_card *card)
180180
}
181181
EXPORT_SYMBOL_GPL(qcom_snd_parse_of);
182182

183-
int qcom_snd_sdw_prepare(struct snd_pcm_substream *substream,
184-
struct sdw_stream_runtime *sruntime,
185-
bool *stream_prepared)
186-
{
187-
struct snd_soc_pcm_runtime *rtd = substream->private_data;
188-
struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
189-
int ret;
190-
191-
if (!sruntime)
192-
return 0;
193-
194-
switch (cpu_dai->id) {
195-
case WSA_CODEC_DMA_RX_0:
196-
case WSA_CODEC_DMA_RX_1:
197-
case RX_CODEC_DMA_RX_0:
198-
case RX_CODEC_DMA_RX_1:
199-
case TX_CODEC_DMA_TX_0:
200-
case TX_CODEC_DMA_TX_1:
201-
case TX_CODEC_DMA_TX_2:
202-
case TX_CODEC_DMA_TX_3:
203-
break;
204-
default:
205-
return 0;
206-
}
207-
208-
if (*stream_prepared) {
209-
sdw_disable_stream(sruntime);
210-
sdw_deprepare_stream(sruntime);
211-
*stream_prepared = false;
212-
}
213-
214-
ret = sdw_prepare_stream(sruntime);
215-
if (ret)
216-
return ret;
217-
218-
/**
219-
* NOTE: there is a strict hw requirement about the ordering of port
220-
* enables and actual WSA881x PA enable. PA enable should only happen
221-
* after soundwire ports are enabled if not DC on the line is
222-
* accumulated resulting in Click/Pop Noise
223-
* PA enable/mute are handled as part of codec DAPM and digital mute.
224-
*/
225-
226-
ret = sdw_enable_stream(sruntime);
227-
if (ret) {
228-
sdw_deprepare_stream(sruntime);
229-
return ret;
230-
}
231-
*stream_prepared = true;
232-
233-
return ret;
234-
}
235-
EXPORT_SYMBOL_GPL(qcom_snd_sdw_prepare);
236-
237-
int qcom_snd_sdw_hw_params(struct snd_pcm_substream *substream,
238-
struct snd_pcm_hw_params *params,
239-
struct sdw_stream_runtime **psruntime)
240-
{
241-
struct snd_soc_pcm_runtime *rtd = substream->private_data;
242-
struct snd_soc_dai *codec_dai;
243-
struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
244-
struct sdw_stream_runtime *sruntime;
245-
int i;
246-
247-
switch (cpu_dai->id) {
248-
case WSA_CODEC_DMA_RX_0:
249-
case RX_CODEC_DMA_RX_0:
250-
case RX_CODEC_DMA_RX_1:
251-
case TX_CODEC_DMA_TX_0:
252-
case TX_CODEC_DMA_TX_1:
253-
case TX_CODEC_DMA_TX_2:
254-
case TX_CODEC_DMA_TX_3:
255-
for_each_rtd_codec_dais(rtd, i, codec_dai) {
256-
sruntime = snd_soc_dai_get_stream(codec_dai, substream->stream);
257-
if (sruntime != ERR_PTR(-ENOTSUPP))
258-
*psruntime = sruntime;
259-
}
260-
break;
261-
}
262-
263-
return 0;
264-
265-
}
266-
EXPORT_SYMBOL_GPL(qcom_snd_sdw_hw_params);
267-
268-
int qcom_snd_sdw_hw_free(struct snd_pcm_substream *substream,
269-
struct sdw_stream_runtime *sruntime, bool *stream_prepared)
270-
{
271-
struct snd_soc_pcm_runtime *rtd = substream->private_data;
272-
struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
273-
274-
switch (cpu_dai->id) {
275-
case WSA_CODEC_DMA_RX_0:
276-
case WSA_CODEC_DMA_RX_1:
277-
case RX_CODEC_DMA_RX_0:
278-
case RX_CODEC_DMA_RX_1:
279-
case TX_CODEC_DMA_TX_0:
280-
case TX_CODEC_DMA_TX_1:
281-
case TX_CODEC_DMA_TX_2:
282-
case TX_CODEC_DMA_TX_3:
283-
if (sruntime && *stream_prepared) {
284-
sdw_disable_stream(sruntime);
285-
sdw_deprepare_stream(sruntime);
286-
*stream_prepared = false;
287-
}
288-
break;
289-
default:
290-
break;
291-
}
292-
293-
return 0;
294-
}
295-
EXPORT_SYMBOL_GPL(qcom_snd_sdw_hw_free);
296-
297183
int qcom_snd_wcd_jack_setup(struct snd_soc_pcm_runtime *rtd,
298184
struct snd_soc_jack *jack, bool *jack_setup)
299185
{

sound/soc/qcom/common.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,9 @@
55
#define __QCOM_SND_COMMON_H__
66

77
#include <sound/soc.h>
8-
#include <linux/soundwire/sdw.h>
98

109
int qcom_snd_parse_of(struct snd_soc_card *card);
1110
int qcom_snd_wcd_jack_setup(struct snd_soc_pcm_runtime *rtd,
1211
struct snd_soc_jack *jack, bool *jack_setup);
1312

14-
int qcom_snd_sdw_prepare(struct snd_pcm_substream *substream,
15-
struct sdw_stream_runtime *runtime,
16-
bool *stream_prepared);
17-
int qcom_snd_sdw_hw_params(struct snd_pcm_substream *substream,
18-
struct snd_pcm_hw_params *params,
19-
struct sdw_stream_runtime **psruntime);
20-
int qcom_snd_sdw_hw_free(struct snd_pcm_substream *substream,
21-
struct sdw_stream_runtime *sruntime,
22-
bool *stream_prepared);
2313
#endif

sound/soc/qcom/sc8280xp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/input-event-codes.h>
1313
#include "qdsp6/q6afe.h"
1414
#include "common.h"
15+
#include "sdw.h"
1516

1617
#define DRIVER_NAME "sc8280xp"
1718

sound/soc/qcom/sdw.c

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
// Copyright (c) 2018, Linaro Limited.
3+
// Copyright (c) 2018, The Linux Foundation. All rights reserved.
4+
5+
#include <linux/module.h>
6+
#include <sound/soc.h>
7+
#include "qdsp6/q6afe.h"
8+
#include "sdw.h"
9+
10+
int qcom_snd_sdw_prepare(struct snd_pcm_substream *substream,
11+
struct sdw_stream_runtime *sruntime,
12+
bool *stream_prepared)
13+
{
14+
struct snd_soc_pcm_runtime *rtd = substream->private_data;
15+
struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
16+
int ret;
17+
18+
if (!sruntime)
19+
return 0;
20+
21+
switch (cpu_dai->id) {
22+
case WSA_CODEC_DMA_RX_0:
23+
case WSA_CODEC_DMA_RX_1:
24+
case RX_CODEC_DMA_RX_0:
25+
case RX_CODEC_DMA_RX_1:
26+
case TX_CODEC_DMA_TX_0:
27+
case TX_CODEC_DMA_TX_1:
28+
case TX_CODEC_DMA_TX_2:
29+
case TX_CODEC_DMA_TX_3:
30+
break;
31+
default:
32+
return 0;
33+
}
34+
35+
if (*stream_prepared) {
36+
sdw_disable_stream(sruntime);
37+
sdw_deprepare_stream(sruntime);
38+
*stream_prepared = false;
39+
}
40+
41+
ret = sdw_prepare_stream(sruntime);
42+
if (ret)
43+
return ret;
44+
45+
/**
46+
* NOTE: there is a strict hw requirement about the ordering of port
47+
* enables and actual WSA881x PA enable. PA enable should only happen
48+
* after soundwire ports are enabled if not DC on the line is
49+
* accumulated resulting in Click/Pop Noise
50+
* PA enable/mute are handled as part of codec DAPM and digital mute.
51+
*/
52+
53+
ret = sdw_enable_stream(sruntime);
54+
if (ret) {
55+
sdw_deprepare_stream(sruntime);
56+
return ret;
57+
}
58+
*stream_prepared = true;
59+
60+
return ret;
61+
}
62+
EXPORT_SYMBOL_GPL(qcom_snd_sdw_prepare);
63+
64+
int qcom_snd_sdw_hw_params(struct snd_pcm_substream *substream,
65+
struct snd_pcm_hw_params *params,
66+
struct sdw_stream_runtime **psruntime)
67+
{
68+
struct snd_soc_pcm_runtime *rtd = substream->private_data;
69+
struct snd_soc_dai *codec_dai;
70+
struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
71+
struct sdw_stream_runtime *sruntime;
72+
int i;
73+
74+
switch (cpu_dai->id) {
75+
case WSA_CODEC_DMA_RX_0:
76+
case RX_CODEC_DMA_RX_0:
77+
case RX_CODEC_DMA_RX_1:
78+
case TX_CODEC_DMA_TX_0:
79+
case TX_CODEC_DMA_TX_1:
80+
case TX_CODEC_DMA_TX_2:
81+
case TX_CODEC_DMA_TX_3:
82+
for_each_rtd_codec_dais(rtd, i, codec_dai) {
83+
sruntime = snd_soc_dai_get_stream(codec_dai, substream->stream);
84+
if (sruntime != ERR_PTR(-ENOTSUPP))
85+
*psruntime = sruntime;
86+
}
87+
break;
88+
}
89+
90+
return 0;
91+
92+
}
93+
EXPORT_SYMBOL_GPL(qcom_snd_sdw_hw_params);
94+
95+
int qcom_snd_sdw_hw_free(struct snd_pcm_substream *substream,
96+
struct sdw_stream_runtime *sruntime, bool *stream_prepared)
97+
{
98+
struct snd_soc_pcm_runtime *rtd = substream->private_data;
99+
struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
100+
101+
switch (cpu_dai->id) {
102+
case WSA_CODEC_DMA_RX_0:
103+
case WSA_CODEC_DMA_RX_1:
104+
case RX_CODEC_DMA_RX_0:
105+
case RX_CODEC_DMA_RX_1:
106+
case TX_CODEC_DMA_TX_0:
107+
case TX_CODEC_DMA_TX_1:
108+
case TX_CODEC_DMA_TX_2:
109+
case TX_CODEC_DMA_TX_3:
110+
if (sruntime && *stream_prepared) {
111+
sdw_disable_stream(sruntime);
112+
sdw_deprepare_stream(sruntime);
113+
*stream_prepared = false;
114+
}
115+
break;
116+
default:
117+
break;
118+
}
119+
120+
return 0;
121+
}
122+
EXPORT_SYMBOL_GPL(qcom_snd_sdw_hw_free);
123+
MODULE_LICENSE("GPL v2");

sound/soc/qcom/sdw.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
// Copyright (c) 2018, The Linux Foundation. All rights reserved.
3+
4+
#ifndef __QCOM_SND_SDW_H__
5+
#define __QCOM_SND_SDW_H__
6+
7+
#include <linux/soundwire/sdw.h>
8+
9+
int qcom_snd_sdw_prepare(struct snd_pcm_substream *substream,
10+
struct sdw_stream_runtime *runtime,
11+
bool *stream_prepared);
12+
int qcom_snd_sdw_hw_params(struct snd_pcm_substream *substream,
13+
struct snd_pcm_hw_params *params,
14+
struct sdw_stream_runtime **psruntime);
15+
int qcom_snd_sdw_hw_free(struct snd_pcm_substream *substream,
16+
struct sdw_stream_runtime *sruntime,
17+
bool *stream_prepared);
18+
#endif

sound/soc/qcom/sm8250.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/input-event-codes.h>
1313
#include "qdsp6/q6afe.h"
1414
#include "common.h"
15+
#include "sdw.h"
1516

1617
#define DRIVER_NAME "sm8250"
1718
#define MI2S_BCLK_RATE 1536000

0 commit comments

Comments
 (0)