@@ -23,13 +23,12 @@ struct avs_dma_data {
23
23
struct avs_tplg_path_template * template ;
24
24
struct avs_path * path ;
25
25
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
+ };
33
32
34
33
struct snd_pcm_substream * substream ;
35
34
};
@@ -263,6 +262,7 @@ static int avs_dai_hda_be_startup(struct snd_pcm_substream *substream, struct sn
263
262
{
264
263
struct snd_soc_pcm_runtime * rtd = snd_soc_substream_to_rtd (substream );
265
264
struct hdac_ext_stream * link_stream ;
265
+ struct avs_dma_data * data ;
266
266
struct hda_codec * codec ;
267
267
int ret ;
268
268
@@ -278,35 +278,32 @@ static int avs_dai_hda_be_startup(struct snd_pcm_substream *substream, struct sn
278
278
return - EBUSY ;
279
279
}
280
280
281
+ data = snd_soc_dai_get_dma_data (dai , substream );
282
+ data -> link_stream = link_stream ;
281
283
substream -> runtime -> private_data = link_stream ;
282
284
return 0 ;
283
285
}
284
286
285
287
static void avs_dai_hda_be_shutdown (struct snd_pcm_substream * substream , struct snd_soc_dai * dai )
286
288
{
287
- struct hdac_ext_stream * link_stream ;
289
+ struct avs_dma_data * data = snd_soc_dai_get_dma_data ( dai , substream ) ;
288
290
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 );
291
292
substream -> runtime -> private_data = NULL ;
292
-
293
293
avs_dai_shutdown (substream , dai );
294
294
}
295
295
296
296
static int avs_dai_hda_be_hw_params (struct snd_pcm_substream * substream ,
297
297
struct snd_pcm_hw_params * hw_params , struct snd_soc_dai * dai )
298
298
{
299
299
struct avs_dma_data * data ;
300
- struct hdac_ext_stream * link_stream ;
301
300
302
301
data = snd_soc_dai_get_dma_data (dai , substream );
303
302
if (data -> path )
304
303
return 0 ;
305
304
306
- link_stream = substream -> runtime -> private_data ;
307
-
308
305
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 );
310
307
}
311
308
312
309
static 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
323
320
if (!data -> path )
324
321
return 0 ;
325
322
326
- link_stream = substream -> runtime -> private_data ;
323
+ link_stream = data -> link_stream ;
327
324
link_stream -> link_prepared = false;
328
325
avs_path_free (data -> path );
329
326
data -> path = NULL ;
@@ -347,13 +344,16 @@ static int avs_dai_hda_be_prepare(struct snd_pcm_substream *substream, struct sn
347
344
struct snd_soc_pcm_stream * stream_info ;
348
345
struct hdac_ext_stream * link_stream ;
349
346
struct hdac_ext_link * link ;
347
+ struct avs_dma_data * data ;
350
348
struct hda_codec * codec ;
351
349
struct hdac_bus * bus ;
352
350
unsigned int format_val ;
353
351
unsigned int bits ;
354
352
int ret ;
355
353
356
- link_stream = runtime -> private_data ;
354
+ data = snd_soc_dai_get_dma_data (dai , substream );
355
+ link_stream = data -> link_stream ;
356
+
357
357
if (link_stream -> link_prepared )
358
358
return 0 ;
359
359
@@ -387,14 +387,12 @@ static int avs_dai_hda_be_trigger(struct snd_pcm_substream *substream, int cmd,
387
387
struct snd_soc_dai * dai )
388
388
{
389
389
struct snd_soc_pcm_runtime * rtd = snd_soc_substream_to_rtd (substream );
390
- struct hdac_ext_stream * link_stream ;
391
390
struct avs_dma_data * data ;
392
391
int ret = 0 ;
393
392
394
393
dev_dbg (dai -> dev , "entry %s cmd=%d\n" , __func__ , cmd );
395
394
396
395
data = snd_soc_dai_get_dma_data (dai , substream );
397
- link_stream = substream -> runtime -> private_data ;
398
396
399
397
switch (cmd ) {
400
398
case SNDRV_PCM_TRIGGER_RESUME :
@@ -403,7 +401,7 @@ static int avs_dai_hda_be_trigger(struct snd_pcm_substream *substream, int cmd,
403
401
fallthrough ;
404
402
case SNDRV_PCM_TRIGGER_START :
405
403
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE :
406
- snd_hdac_ext_stream_start (link_stream );
404
+ snd_hdac_ext_stream_start (data -> link_stream );
407
405
408
406
ret = avs_path_pause (data -> path );
409
407
if (ret < 0 ) {
@@ -426,7 +424,7 @@ static int avs_dai_hda_be_trigger(struct snd_pcm_substream *substream, int cmd,
426
424
if (ret < 0 )
427
425
dev_err (dai -> dev , "pause BE path failed: %d\n" , ret );
428
426
429
- snd_hdac_ext_stream_clear (link_stream );
427
+ snd_hdac_ext_stream_clear (data -> link_stream );
430
428
431
429
ret = avs_path_reset (data -> path );
432
430
if (ret < 0 )
0 commit comments