Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: qcom: sdw: remove redundant code

remove redundant code and pointers to handle sdw_stream_runtime by
making use of qcom_snd_sdw_get_stream(). This removes need of machine
specific shutdown and hw_params sdw callbacks and also need to store
sdw_stream_runtime pointers in machine drivers.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
Tested-by: Steev Klimaszewski <threeway@gmail.com> # Thinkpad X13s
Link: https://patch.msgid.link/20251022143349.1081513-3-srinivas.kandagatla@oss.qualcomm.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Srinivas Kandagatla and committed by
Mark Brown
d0246031 bcba1727

+22 -107
+3 -30
sound/soc/qcom/sc8280xp.c
··· 18 18 struct sc8280xp_snd_data { 19 19 bool stream_prepared[AFE_PORT_MAX]; 20 20 struct snd_soc_card *card; 21 - struct sdw_stream_runtime *sruntime[AFE_PORT_MAX]; 22 21 struct snd_soc_jack jack; 23 22 struct snd_soc_jack dp_jack[8]; 24 23 bool jack_setup; ··· 67 68 return qcom_snd_wcd_jack_setup(rtd, &data->jack, &data->jack_setup); 68 69 } 69 70 70 - static void sc8280xp_snd_shutdown(struct snd_pcm_substream *substream) 71 - { 72 - struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); 73 - struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); 74 - struct sc8280xp_snd_data *pdata = snd_soc_card_get_drvdata(rtd->card); 75 - struct sdw_stream_runtime *sruntime = qcom_snd_sdw_get_stream(substream); 76 - 77 - pdata->sruntime[cpu_dai->id] = NULL; 78 - sdw_release_stream(sruntime); 79 - } 80 - 81 71 static int sc8280xp_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, 82 72 struct snd_pcm_hw_params *params) 83 73 { ··· 96 108 return 0; 97 109 } 98 110 99 - static int sc8280xp_snd_hw_params(struct snd_pcm_substream *substream, 100 - struct snd_pcm_hw_params *params) 101 - { 102 - struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); 103 - struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); 104 - struct sc8280xp_snd_data *pdata = snd_soc_card_get_drvdata(rtd->card); 105 - 106 - return qcom_snd_sdw_hw_params(substream, params, &pdata->sruntime[cpu_dai->id]); 107 - } 108 - 109 111 static int sc8280xp_snd_prepare(struct snd_pcm_substream *substream) 110 112 { 111 113 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); 112 114 struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); 113 115 struct sc8280xp_snd_data *data = snd_soc_card_get_drvdata(rtd->card); 114 - struct sdw_stream_runtime *sruntime = data->sruntime[cpu_dai->id]; 115 116 116 - return qcom_snd_sdw_prepare(substream, sruntime, 117 - &data->stream_prepared[cpu_dai->id]); 117 + return qcom_snd_sdw_prepare(substream, &data->stream_prepared[cpu_dai->id]); 118 118 } 119 119 120 120 static int sc8280xp_snd_hw_free(struct snd_pcm_substream *substream) ··· 110 134 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); 111 135 struct sc8280xp_snd_data *data = snd_soc_card_get_drvdata(rtd->card); 112 136 struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); 113 - struct sdw_stream_runtime *sruntime = data->sruntime[cpu_dai->id]; 114 137 115 - return qcom_snd_sdw_hw_free(substream, sruntime, 116 - &data->stream_prepared[cpu_dai->id]); 138 + return qcom_snd_sdw_hw_free(substream, &data->stream_prepared[cpu_dai->id]); 117 139 } 118 140 119 141 static const struct snd_soc_ops sc8280xp_be_ops = { 120 142 .startup = qcom_snd_sdw_startup, 121 - .shutdown = sc8280xp_snd_shutdown, 122 - .hw_params = sc8280xp_snd_hw_params, 143 + .shutdown = qcom_snd_sdw_shutdown, 123 144 .hw_free = sc8280xp_snd_hw_free, 124 145 .prepare = sc8280xp_snd_prepare, 125 146 };
+12 -12
sound/soc/qcom/sdw.c
··· 113 113 EXPORT_SYMBOL_GPL(qcom_snd_sdw_startup); 114 114 115 115 int qcom_snd_sdw_prepare(struct snd_pcm_substream *substream, 116 - struct sdw_stream_runtime *sruntime, 117 116 bool *stream_prepared) 118 117 { 119 118 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); 120 119 struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); 120 + struct sdw_stream_runtime *sruntime; 121 121 int ret; 122 122 123 - if (!sruntime) 124 - return 0; 125 123 126 124 if (!qcom_snd_is_sdw_dai(cpu_dai->id)) 125 + return 0; 126 + 127 + sruntime = qcom_snd_sdw_get_stream(substream); 128 + if (!sruntime) 127 129 return 0; 128 130 129 131 if (*stream_prepared) ··· 174 172 } 175 173 EXPORT_SYMBOL_GPL(qcom_snd_sdw_get_stream); 176 174 177 - int qcom_snd_sdw_hw_params(struct snd_pcm_substream *substream, 178 - struct snd_pcm_hw_params *params, 179 - struct sdw_stream_runtime **psruntime) 175 + void qcom_snd_sdw_shutdown(struct snd_pcm_substream *substream) 180 176 { 181 - *psruntime = qcom_snd_sdw_get_stream(substream); 177 + struct sdw_stream_runtime *sruntime = qcom_snd_sdw_get_stream(substream); 182 178 183 - return 0; 184 - 179 + sdw_release_stream(sruntime); 185 180 } 186 - EXPORT_SYMBOL_GPL(qcom_snd_sdw_hw_params); 181 + EXPORT_SYMBOL_GPL(qcom_snd_sdw_shutdown); 187 182 188 - int qcom_snd_sdw_hw_free(struct snd_pcm_substream *substream, 189 - struct sdw_stream_runtime *sruntime, bool *stream_prepared) 183 + int qcom_snd_sdw_hw_free(struct snd_pcm_substream *substream, bool *stream_prepared) 190 184 { 191 185 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); 192 186 struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); 187 + struct sdw_stream_runtime *sruntime; 193 188 194 189 if (!qcom_snd_is_sdw_dai(cpu_dai->id)) 195 190 return 0; 196 191 192 + sruntime = qcom_snd_sdw_get_stream(substream); 197 193 if (sruntime && *stream_prepared) { 198 194 sdw_disable_stream(sruntime); 199 195 sdw_deprepare_stream(sruntime);
+1 -5
sound/soc/qcom/sdw.h
··· 7 7 #include <linux/soundwire/sdw.h> 8 8 9 9 int qcom_snd_sdw_startup(struct snd_pcm_substream *substream); 10 + void qcom_snd_sdw_shutdown(struct snd_pcm_substream *substream); 10 11 int qcom_snd_sdw_prepare(struct snd_pcm_substream *substream, 11 - struct sdw_stream_runtime *runtime, 12 12 bool *stream_prepared); 13 13 struct sdw_stream_runtime *qcom_snd_sdw_get_stream(struct snd_pcm_substream *stream); 14 - int qcom_snd_sdw_hw_params(struct snd_pcm_substream *substream, 15 - struct snd_pcm_hw_params *params, 16 - struct sdw_stream_runtime **psruntime); 17 14 int qcom_snd_sdw_hw_free(struct snd_pcm_substream *substream, 18 - struct sdw_stream_runtime *sruntime, 19 15 bool *stream_prepared); 20 16 #endif
+3 -30
sound/soc/qcom/sm8250.c
··· 21 21 struct sm8250_snd_data { 22 22 bool stream_prepared[AFE_PORT_MAX]; 23 23 struct snd_soc_card *card; 24 - struct sdw_stream_runtime *sruntime[AFE_PORT_MAX]; 25 24 struct snd_soc_jack jack; 26 25 struct snd_soc_jack usb_offload_jack; 27 26 bool usb_offload_jack_setup; ··· 111 112 return qcom_snd_sdw_startup(substream); 112 113 } 113 114 114 - static void sm8250_snd_shutdown(struct snd_pcm_substream *substream) 115 - { 116 - struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); 117 - struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); 118 - struct sm8250_snd_data *data = snd_soc_card_get_drvdata(rtd->card); 119 - struct sdw_stream_runtime *sruntime = qcom_snd_sdw_get_stream(substream); 120 - 121 - data->sruntime[cpu_dai->id] = NULL; 122 - sdw_release_stream(sruntime); 123 - } 124 - 125 - static int sm8250_snd_hw_params(struct snd_pcm_substream *substream, 126 - struct snd_pcm_hw_params *params) 127 - { 128 - struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); 129 - struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); 130 - struct sm8250_snd_data *pdata = snd_soc_card_get_drvdata(rtd->card); 131 - 132 - return qcom_snd_sdw_hw_params(substream, params, &pdata->sruntime[cpu_dai->id]); 133 - } 134 - 135 115 static int sm8250_snd_prepare(struct snd_pcm_substream *substream) 136 116 { 137 117 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); 138 118 struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); 139 119 struct sm8250_snd_data *data = snd_soc_card_get_drvdata(rtd->card); 140 - struct sdw_stream_runtime *sruntime = data->sruntime[cpu_dai->id]; 141 120 142 - return qcom_snd_sdw_prepare(substream, sruntime, 143 - &data->stream_prepared[cpu_dai->id]); 121 + return qcom_snd_sdw_prepare(substream, &data->stream_prepared[cpu_dai->id]); 144 122 } 145 123 146 124 static int sm8250_snd_hw_free(struct snd_pcm_substream *substream) ··· 125 149 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); 126 150 struct sm8250_snd_data *data = snd_soc_card_get_drvdata(rtd->card); 127 151 struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); 128 - struct sdw_stream_runtime *sruntime = data->sruntime[cpu_dai->id]; 129 152 130 - return qcom_snd_sdw_hw_free(substream, sruntime, 131 - &data->stream_prepared[cpu_dai->id]); 153 + return qcom_snd_sdw_hw_free(substream, &data->stream_prepared[cpu_dai->id]); 132 154 } 133 155 134 156 static const struct snd_soc_ops sm8250_be_ops = { 135 157 .startup = sm8250_snd_startup, 136 - .shutdown = sm8250_snd_shutdown, 137 - .hw_params = sm8250_snd_hw_params, 158 + .shutdown = qcom_snd_sdw_shutdown, 138 159 .hw_free = sm8250_snd_hw_free, 139 160 .prepare = sm8250_snd_prepare, 140 161 };
+3 -30
sound/soc/qcom/x1e80100.c
··· 18 18 struct x1e80100_snd_data { 19 19 bool stream_prepared[AFE_PORT_MAX]; 20 20 struct snd_soc_card *card; 21 - struct sdw_stream_runtime *sruntime[AFE_PORT_MAX]; 22 21 struct snd_soc_jack jack; 23 22 struct snd_soc_jack dp_jack[8]; 24 23 bool jack_setup; ··· 49 50 return qcom_snd_wcd_jack_setup(rtd, &data->jack, &data->jack_setup); 50 51 } 51 52 52 - static void x1e80100_snd_shutdown(struct snd_pcm_substream *substream) 53 - { 54 - struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); 55 - struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); 56 - struct x1e80100_snd_data *data = snd_soc_card_get_drvdata(rtd->card); 57 - struct sdw_stream_runtime *sruntime = qcom_snd_sdw_get_stream(substream); 58 - 59 - data->sruntime[cpu_dai->id] = NULL; 60 - sdw_release_stream(sruntime); 61 - } 62 - 63 53 static int x1e80100_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, 64 54 struct snd_pcm_hw_params *params) 65 55 { ··· 71 83 } 72 84 73 85 return 0; 74 - } 75 - 76 - static int x1e80100_snd_hw_params(struct snd_pcm_substream *substream, 77 - struct snd_pcm_hw_params *params) 78 - { 79 - struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); 80 - struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); 81 - struct x1e80100_snd_data *data = snd_soc_card_get_drvdata(rtd->card); 82 - 83 - return qcom_snd_sdw_hw_params(substream, params, &data->sruntime[cpu_dai->id]); 84 86 } 85 87 86 88 static int x1e80100_snd_hw_map_channels(unsigned int *ch_map, int num) ··· 106 128 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); 107 129 struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); 108 130 struct x1e80100_snd_data *data = snd_soc_card_get_drvdata(rtd->card); 109 - struct sdw_stream_runtime *sruntime = data->sruntime[cpu_dai->id]; 110 131 unsigned int channels = substream->runtime->channels; 111 132 unsigned int rx_slot[4]; 112 133 int ret; ··· 126 149 break; 127 150 } 128 151 129 - return qcom_snd_sdw_prepare(substream, sruntime, 130 - &data->stream_prepared[cpu_dai->id]); 152 + return qcom_snd_sdw_prepare(substream, &data->stream_prepared[cpu_dai->id]); 131 153 } 132 154 133 155 static int x1e80100_snd_hw_free(struct snd_pcm_substream *substream) ··· 134 158 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); 135 159 struct x1e80100_snd_data *data = snd_soc_card_get_drvdata(rtd->card); 136 160 struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); 137 - struct sdw_stream_runtime *sruntime = data->sruntime[cpu_dai->id]; 138 161 139 - return qcom_snd_sdw_hw_free(substream, sruntime, 140 - &data->stream_prepared[cpu_dai->id]); 162 + return qcom_snd_sdw_hw_free(substream, &data->stream_prepared[cpu_dai->id]); 141 163 } 142 164 143 165 static const struct snd_soc_ops x1e80100_be_ops = { 144 166 .startup = qcom_snd_sdw_startup, 145 - .shutdown = x1e80100_snd_shutdown, 146 - .hw_params = x1e80100_snd_hw_params, 167 + .shutdown = qcom_snd_sdw_shutdown, 147 168 .hw_free = x1e80100_snd_hw_free, 148 169 .prepare = x1e80100_snd_prepare, 149 170 };