@@ -23,13 +23,12 @@ struct avs_dma_data {
2323 struct avs_tplg_path_template * template ;
2424 struct avs_path * path ;
2525 struct avs_dev * adev ;
26- /*
27- * link stream is stored within substream's runtime
28- * private_data to fulfill the needs of codec BE path
29- *
30- * host stream assigned
31- */
32- struct hdac_ext_stream * host_stream ;
26+
27+ /* LINK-stream utilized in BE operations while HOST in FE ones. */
28+ union {
29+ struct hdac_ext_stream * link_stream ;
30+ struct hdac_ext_stream * host_stream ;
31+ };
3332
3433 struct snd_pcm_substream * substream ;
3534};
@@ -263,6 +262,7 @@ static int avs_dai_hda_be_startup(struct snd_pcm_substream *substream, struct sn
263262{
264263 struct snd_soc_pcm_runtime * rtd = snd_soc_substream_to_rtd (substream );
265264 struct hdac_ext_stream * link_stream ;
265+ struct avs_dma_data * data ;
266266 struct hda_codec * codec ;
267267 int ret ;
268268
@@ -278,35 +278,32 @@ static int avs_dai_hda_be_startup(struct snd_pcm_substream *substream, struct sn
278278 return - EBUSY ;
279279 }
280280
281+ data = snd_soc_dai_get_dma_data (dai , substream );
282+ data -> link_stream = link_stream ;
281283 substream -> runtime -> private_data = link_stream ;
282284 return 0 ;
283285}
284286
285287static void avs_dai_hda_be_shutdown (struct snd_pcm_substream * substream , struct snd_soc_dai * dai )
286288{
287- struct hdac_ext_stream * link_stream ;
289+ struct avs_dma_data * data = snd_soc_dai_get_dma_data ( dai , substream ) ;
288290
289- link_stream = substream -> runtime -> private_data ;
290- snd_hdac_ext_stream_release (link_stream , HDAC_EXT_STREAM_TYPE_LINK );
291+ snd_hdac_ext_stream_release (data -> link_stream , HDAC_EXT_STREAM_TYPE_LINK );
291292 substream -> runtime -> private_data = NULL ;
292-
293293 avs_dai_shutdown (substream , dai );
294294}
295295
296296static int avs_dai_hda_be_hw_params (struct snd_pcm_substream * substream ,
297297 struct snd_pcm_hw_params * hw_params , struct snd_soc_dai * dai )
298298{
299299 struct avs_dma_data * data ;
300- struct hdac_ext_stream * link_stream ;
301300
302301 data = snd_soc_dai_get_dma_data (dai , substream );
303302 if (data -> path )
304303 return 0 ;
305304
306- link_stream = substream -> runtime -> private_data ;
307-
308305 return avs_dai_be_hw_params (substream , hw_params , dai ,
309- hdac_stream (link_stream )-> stream_tag - 1 );
306+ hdac_stream (data -> link_stream )-> stream_tag - 1 );
310307}
311308
312309static int avs_dai_hda_be_hw_free (struct snd_pcm_substream * substream , struct snd_soc_dai * dai )
@@ -323,7 +320,7 @@ static int avs_dai_hda_be_hw_free(struct snd_pcm_substream *substream, struct sn
323320 if (!data -> path )
324321 return 0 ;
325322
326- link_stream = substream -> runtime -> private_data ;
323+ link_stream = data -> link_stream ;
327324 link_stream -> link_prepared = false;
328325 avs_path_free (data -> path );
329326 data -> path = NULL ;
@@ -347,13 +344,16 @@ static int avs_dai_hda_be_prepare(struct snd_pcm_substream *substream, struct sn
347344 struct snd_soc_pcm_stream * stream_info ;
348345 struct hdac_ext_stream * link_stream ;
349346 struct hdac_ext_link * link ;
347+ struct avs_dma_data * data ;
350348 struct hda_codec * codec ;
351349 struct hdac_bus * bus ;
352350 unsigned int format_val ;
353351 unsigned int bits ;
354352 int ret ;
355353
356- link_stream = runtime -> private_data ;
354+ data = snd_soc_dai_get_dma_data (dai , substream );
355+ link_stream = data -> link_stream ;
356+
357357 if (link_stream -> link_prepared )
358358 return 0 ;
359359
@@ -387,14 +387,12 @@ static int avs_dai_hda_be_trigger(struct snd_pcm_substream *substream, int cmd,
387387 struct snd_soc_dai * dai )
388388{
389389 struct snd_soc_pcm_runtime * rtd = snd_soc_substream_to_rtd (substream );
390- struct hdac_ext_stream * link_stream ;
391390 struct avs_dma_data * data ;
392391 int ret = 0 ;
393392
394393 dev_dbg (dai -> dev , "entry %s cmd=%d\n" , __func__ , cmd );
395394
396395 data = snd_soc_dai_get_dma_data (dai , substream );
397- link_stream = substream -> runtime -> private_data ;
398396
399397 switch (cmd ) {
400398 case SNDRV_PCM_TRIGGER_RESUME :
@@ -403,7 +401,7 @@ static int avs_dai_hda_be_trigger(struct snd_pcm_substream *substream, int cmd,
403401 fallthrough ;
404402 case SNDRV_PCM_TRIGGER_START :
405403 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE :
406- snd_hdac_ext_stream_start (link_stream );
404+ snd_hdac_ext_stream_start (data -> link_stream );
407405
408406 ret = avs_path_pause (data -> path );
409407 if (ret < 0 ) {
@@ -426,7 +424,7 @@ static int avs_dai_hda_be_trigger(struct snd_pcm_substream *substream, int cmd,
426424 if (ret < 0 )
427425 dev_err (dai -> dev , "pause BE path failed: %d\n" , ret );
428426
429- snd_hdac_ext_stream_clear (link_stream );
427+ snd_hdac_ext_stream_clear (data -> link_stream );
430428
431429 ret = avs_path_reset (data -> path );
432430 if (ret < 0 )
0 commit comments