@@ -109,20 +109,17 @@ hda_dai_get_ops(struct snd_pcm_substream *substream, struct snd_soc_dai *cpu_dai
109109
110110static int hda_link_dma_cleanup (struct snd_pcm_substream * substream ,
111111 struct hdac_ext_stream * hext_stream ,
112- struct snd_soc_dai * cpu_dai ,
113- struct snd_soc_dai * codec_dai )
112+ struct snd_soc_dai * cpu_dai )
114113{
115114 const struct hda_dai_widget_dma_ops * ops = hda_dai_get_ops (substream , cpu_dai );
116- struct hdac_stream * hstream = & hext_stream -> hstream ;
117- struct hdac_bus * bus = hstream -> bus ;
118115 struct sof_intel_hda_stream * hda_stream ;
119116 struct hdac_ext_link * hlink ;
120117 struct snd_sof_dev * sdev ;
121118 int stream_tag ;
122119
123120 sdev = dai_to_sdev (substream , cpu_dai );
124121
125- hlink = snd_hdac_ext_bus_get_hlink_by_name ( bus , codec_dai -> component -> name );
122+ hlink = ops -> get_hlink ( sdev , substream );
126123 if (!hlink )
127124 return - EINVAL ;
128125
@@ -147,19 +144,15 @@ static int hda_link_dma_hw_params(struct snd_pcm_substream *substream,
147144 struct snd_pcm_hw_params * params , struct snd_soc_dai * cpu_dai )
148145{
149146 const struct hda_dai_widget_dma_ops * ops = hda_dai_get_ops (substream , cpu_dai );
150- struct snd_soc_pcm_runtime * rtd = asoc_substream_to_rtd (substream );
151- struct snd_soc_dai * codec_dai = asoc_rtd_to_codec (rtd , 0 );
152147 struct hdac_ext_stream * hext_stream ;
153148 struct hdac_stream * hstream ;
154149 struct hdac_ext_link * hlink ;
155150 struct snd_sof_dev * sdev ;
156- struct hdac_bus * bus ;
157151 int stream_tag ;
158152
159153 sdev = dai_to_sdev (substream , cpu_dai );
160- bus = sof_to_bus (sdev );
161154
162- hlink = snd_hdac_ext_bus_get_hlink_by_name ( bus , codec_dai -> component -> name );
155+ hlink = ops -> get_hlink ( sdev , substream );
163156 if (!hlink )
164157 return - EINVAL ;
165158
@@ -200,8 +193,6 @@ static int hda_link_dma_hw_params(struct snd_pcm_substream *substream,
200193static int hda_dai_hw_free (struct snd_pcm_substream * substream , struct snd_soc_dai * cpu_dai )
201194{
202195 const struct hda_dai_widget_dma_ops * ops = hda_dai_get_ops (substream , cpu_dai );
203- struct snd_soc_pcm_runtime * rtd = asoc_substream_to_rtd (substream );
204- struct snd_soc_dai * codec_dai = asoc_rtd_to_codec (rtd , 0 );
205196 struct hdac_ext_stream * hext_stream ;
206197 struct snd_sof_dev * sdev = dai_to_sdev (substream , cpu_dai );
207198
@@ -214,7 +205,7 @@ static int hda_dai_hw_free(struct snd_pcm_substream *substream, struct snd_soc_d
214205 if (!hext_stream )
215206 return 0 ;
216207
217- return hda_link_dma_cleanup (substream , hext_stream , cpu_dai , codec_dai );
208+ return hda_link_dma_cleanup (substream , hext_stream , cpu_dai );
218209}
219210
220211static int hda_dai_hw_params (struct snd_pcm_substream * substream ,
@@ -266,8 +257,6 @@ static int hda_dai_trigger(struct snd_pcm_substream *substream, int cmd, struct
266257{
267258 const struct hda_dai_widget_dma_ops * ops = hda_dai_get_ops (substream , dai );
268259 struct hdac_ext_stream * hext_stream ;
269- struct snd_soc_pcm_runtime * rtd ;
270- struct snd_soc_dai * codec_dai ;
271260 struct snd_sof_dev * sdev ;
272261 int ret ;
273262
@@ -280,9 +269,6 @@ static int hda_dai_trigger(struct snd_pcm_substream *substream, int cmd, struct
280269 if (!hext_stream )
281270 return - EINVAL ;
282271
283- rtd = asoc_substream_to_rtd (substream );
284- codec_dai = asoc_rtd_to_codec (rtd , 0 );
285-
286272 if (ops -> pre_trigger ) {
287273 ret = ops -> pre_trigger (sdev , dai , substream , cmd );
288274 if (ret < 0 )
@@ -304,7 +290,7 @@ static int hda_dai_trigger(struct snd_pcm_substream *substream, int cmd, struct
304290 switch (cmd ) {
305291 case SNDRV_PCM_TRIGGER_SUSPEND :
306292 case SNDRV_PCM_TRIGGER_STOP :
307- ret = hda_link_dma_cleanup (substream , hext_stream , dai , codec_dai );
293+ ret = hda_link_dma_cleanup (substream , hext_stream , dai );
308294 if (ret < 0 ) {
309295 dev_err (sdev -> dev , "%s: failed to clean up link DMA\n" , __func__ );
310296 return ret ;
@@ -346,14 +332,12 @@ static int hda_dai_suspend(struct hdac_bus *bus)
346332 const struct hda_dai_widget_dma_ops * ops ;
347333 struct snd_sof_widget * swidget ;
348334 struct snd_soc_dapm_widget * w ;
349- struct snd_soc_dai * codec_dai ;
350335 struct snd_soc_dai * cpu_dai ;
351336 struct snd_sof_dev * sdev ;
352337 struct snd_sof_dai * sdai ;
353338
354339 rtd = asoc_substream_to_rtd (hext_stream -> link_substream );
355340 cpu_dai = asoc_rtd_to_cpu (rtd , 0 );
356- codec_dai = asoc_rtd_to_codec (rtd , 0 );
357341 w = snd_soc_dai_get_widget (cpu_dai , hdac_stream (hext_stream )-> direction );
358342 swidget = w -> dobj .private ;
359343 sdev = widget_to_sdev (w );
@@ -362,7 +346,7 @@ static int hda_dai_suspend(struct hdac_bus *bus)
362346
363347 ret = hda_link_dma_cleanup (hext_stream -> link_substream ,
364348 hext_stream ,
365- cpu_dai , codec_dai );
349+ cpu_dai );
366350 if (ret < 0 )
367351 return ret ;
368352
0 commit comments