@@ -32,6 +32,7 @@ struct avs_dma_data {
32
32
};
33
33
34
34
struct work_struct period_elapsed_work ;
35
+ struct hdac_ext_link * link ;
35
36
struct snd_pcm_substream * substream ;
36
37
};
37
38
@@ -278,32 +279,75 @@ static const struct snd_soc_dai_ops avs_dai_nonhda_be_ops = {
278
279
.trigger = avs_dai_nonhda_be_trigger ,
279
280
};
280
281
281
- static int avs_dai_hda_be_startup (struct snd_pcm_substream * substream , struct snd_soc_dai * dai )
282
+ static int __avs_dai_hda_be_startup (struct snd_pcm_substream * substream , struct snd_soc_dai * dai ,
283
+ struct hdac_ext_link * link )
282
284
{
283
- struct snd_soc_pcm_runtime * rtd = snd_soc_substream_to_rtd (substream );
284
285
struct hdac_ext_stream * link_stream ;
285
286
struct avs_dma_data * data ;
286
- struct hda_codec * codec ;
287
287
int ret ;
288
288
289
289
ret = avs_dai_startup (substream , dai );
290
290
if (ret )
291
291
return ret ;
292
292
293
- codec = dev_to_hda_codec ( snd_soc_rtd_to_codec ( rtd , 0 ) -> dev );
294
- link_stream = snd_hdac_ext_stream_assign (& codec -> bus -> core , substream ,
293
+ data = snd_soc_dai_get_dma_data ( dai , substream );
294
+ link_stream = snd_hdac_ext_stream_assign (& data -> adev -> base . core , substream ,
295
295
HDAC_EXT_STREAM_TYPE_LINK );
296
296
if (!link_stream ) {
297
297
avs_dai_shutdown (substream , dai );
298
298
return - EBUSY ;
299
299
}
300
300
301
- data = snd_soc_dai_get_dma_data (dai , substream );
302
301
data -> link_stream = link_stream ;
303
- substream -> runtime -> private_data = link_stream ;
302
+ data -> link = link ;
304
303
return 0 ;
305
304
}
306
305
306
+ static int avs_dai_hda_be_startup (struct snd_pcm_substream * substream , struct snd_soc_dai * dai )
307
+ {
308
+ struct snd_soc_pcm_runtime * rtd = snd_soc_substream_to_rtd (substream );
309
+ struct hdac_ext_link * link ;
310
+ struct avs_dma_data * data ;
311
+ struct hda_codec * codec ;
312
+ int ret ;
313
+
314
+ codec = dev_to_hda_codec (snd_soc_rtd_to_codec (rtd , 0 )-> dev );
315
+
316
+ link = snd_hdac_ext_bus_get_hlink_by_addr (& codec -> bus -> core , codec -> core .addr );
317
+ if (!link )
318
+ return - EINVAL ;
319
+
320
+ ret = __avs_dai_hda_be_startup (substream , dai , link );
321
+ if (!ret ) {
322
+ data = snd_soc_dai_get_dma_data (dai , substream );
323
+ substream -> runtime -> private_data = data -> link_stream ;
324
+ }
325
+
326
+ return ret ;
327
+ }
328
+
329
+ static int avs_dai_i2shda_be_startup (struct snd_pcm_substream * substream , struct snd_soc_dai * dai )
330
+ {
331
+ struct avs_dev * adev = to_avs_dev (dai -> component -> dev );
332
+ struct hdac_ext_link * link ;
333
+
334
+ link = snd_hdac_ext_bus_get_hlink_by_id (& adev -> base .core , AZX_REG_ML_LEPTR_ID_INTEL_SSP );
335
+ if (!link )
336
+ return - EINVAL ;
337
+ return __avs_dai_hda_be_startup (substream , dai , link );
338
+ }
339
+
340
+ static int avs_dai_dmichda_be_startup (struct snd_pcm_substream * substream , struct snd_soc_dai * dai )
341
+ {
342
+ struct avs_dev * adev = to_avs_dev (dai -> component -> dev );
343
+ struct hdac_ext_link * link ;
344
+
345
+ link = snd_hdac_ext_bus_get_hlink_by_id (& adev -> base .core , AZX_REG_ML_LEPTR_ID_INTEL_DMIC );
346
+ if (!link )
347
+ return - EINVAL ;
348
+ return __avs_dai_hda_be_startup (substream , dai , link );
349
+ }
350
+
307
351
static void avs_dai_hda_be_shutdown (struct snd_pcm_substream * substream , struct snd_soc_dai * dai )
308
352
{
309
353
struct avs_dma_data * data = snd_soc_dai_get_dma_data (dai , substream );
@@ -313,6 +357,14 @@ static void avs_dai_hda_be_shutdown(struct snd_pcm_substream *substream, struct
313
357
avs_dai_shutdown (substream , dai );
314
358
}
315
359
360
+ static void avs_dai_althda_be_shutdown (struct snd_pcm_substream * substream , struct snd_soc_dai * dai )
361
+ {
362
+ struct avs_dma_data * data = snd_soc_dai_get_dma_data (dai , substream );
363
+
364
+ snd_hdac_ext_stream_release (data -> link_stream , HDAC_EXT_STREAM_TYPE_LINK );
365
+ avs_dai_shutdown (substream , dai );
366
+ }
367
+
316
368
static int avs_dai_hda_be_hw_params (struct snd_pcm_substream * substream ,
317
369
struct snd_pcm_hw_params * hw_params , struct snd_soc_dai * dai )
318
370
{
@@ -328,13 +380,8 @@ static int avs_dai_hda_be_hw_params(struct snd_pcm_substream *substream,
328
380
329
381
static int avs_dai_hda_be_hw_free (struct snd_pcm_substream * substream , struct snd_soc_dai * dai )
330
382
{
331
- struct avs_dma_data * data ;
332
- struct snd_soc_pcm_runtime * rtd = snd_soc_substream_to_rtd (substream );
333
383
struct hdac_ext_stream * link_stream ;
334
- struct hdac_ext_link * link ;
335
- struct hda_codec * codec ;
336
-
337
- dev_dbg (dai -> dev , "%s: %s\n" , __func__ , dai -> name );
384
+ struct avs_dma_data * data ;
338
385
339
386
data = snd_soc_dai_get_dma_data (dai , substream );
340
387
if (!data -> path )
@@ -346,27 +393,19 @@ static int avs_dai_hda_be_hw_free(struct snd_pcm_substream *substream, struct sn
346
393
data -> path = NULL ;
347
394
348
395
/* clear link <-> stream mapping */
349
- codec = dev_to_hda_codec (snd_soc_rtd_to_codec (rtd , 0 )-> dev );
350
- link = snd_hdac_ext_bus_get_hlink_by_addr (& codec -> bus -> core , codec -> core .addr );
351
- if (!link )
352
- return - EINVAL ;
353
-
354
396
if (substream -> stream == SNDRV_PCM_STREAM_PLAYBACK )
355
- snd_hdac_ext_bus_link_clear_stream_id (link , hdac_stream (link_stream )-> stream_tag );
397
+ snd_hdac_ext_bus_link_clear_stream_id (data -> link ,
398
+ hdac_stream (link_stream )-> stream_tag );
356
399
357
400
return 0 ;
358
401
}
359
402
360
403
static int avs_dai_hda_be_prepare (struct snd_pcm_substream * substream , struct snd_soc_dai * dai )
361
404
{
362
- struct snd_soc_pcm_runtime * rtd = snd_soc_substream_to_rtd (substream );
363
405
struct snd_pcm_runtime * runtime = substream -> runtime ;
364
406
const struct snd_soc_pcm_stream * stream_info ;
365
407
struct hdac_ext_stream * link_stream ;
366
- struct hdac_ext_link * link ;
367
408
struct avs_dma_data * data ;
368
- struct hda_codec * codec ;
369
- struct hdac_bus * bus ;
370
409
unsigned int format_val ;
371
410
unsigned int bits ;
372
411
int ret ;
@@ -377,23 +416,18 @@ static int avs_dai_hda_be_prepare(struct snd_pcm_substream *substream, struct sn
377
416
if (link_stream -> link_prepared )
378
417
return 0 ;
379
418
380
- codec = dev_to_hda_codec (snd_soc_rtd_to_codec (rtd , 0 )-> dev );
381
- bus = & codec -> bus -> core ;
382
419
stream_info = snd_soc_dai_get_pcm_stream (dai , substream -> stream );
383
420
bits = snd_hdac_stream_format_bits (runtime -> format , runtime -> subformat ,
384
421
stream_info -> sig_bits );
385
422
format_val = snd_hdac_stream_format (runtime -> channels , bits , runtime -> rate );
386
423
387
- snd_hdac_ext_stream_decouple (bus , link_stream , true);
424
+ snd_hdac_ext_stream_decouple (& data -> adev -> base . core , link_stream , true);
388
425
snd_hdac_ext_stream_reset (link_stream );
389
426
snd_hdac_ext_stream_setup (link_stream , format_val );
390
427
391
- link = snd_hdac_ext_bus_get_hlink_by_addr (bus , codec -> core .addr );
392
- if (!link )
393
- return - EINVAL ;
394
-
395
428
if (substream -> stream == SNDRV_PCM_STREAM_PLAYBACK )
396
- snd_hdac_ext_bus_link_set_stream_id (link , hdac_stream (link_stream )-> stream_tag );
429
+ snd_hdac_ext_bus_link_set_stream_id (data -> link ,
430
+ hdac_stream (link_stream )-> stream_tag );
397
431
398
432
ret = avs_dai_prepare (substream , dai );
399
433
if (ret )
@@ -468,6 +502,26 @@ static const struct snd_soc_dai_ops avs_dai_hda_be_ops = {
468
502
.trigger = avs_dai_hda_be_trigger ,
469
503
};
470
504
505
+ __maybe_unused
506
+ static const struct snd_soc_dai_ops avs_dai_i2shda_be_ops = {
507
+ .startup = avs_dai_i2shda_be_startup ,
508
+ .shutdown = avs_dai_althda_be_shutdown ,
509
+ .hw_params = avs_dai_hda_be_hw_params ,
510
+ .hw_free = avs_dai_hda_be_hw_free ,
511
+ .prepare = avs_dai_hda_be_prepare ,
512
+ .trigger = avs_dai_hda_be_trigger ,
513
+ };
514
+
515
+ __maybe_unused
516
+ static const struct snd_soc_dai_ops avs_dai_dmichda_be_ops = {
517
+ .startup = avs_dai_dmichda_be_startup ,
518
+ .shutdown = avs_dai_althda_be_shutdown ,
519
+ .hw_params = avs_dai_hda_be_hw_params ,
520
+ .hw_free = avs_dai_hda_be_hw_free ,
521
+ .prepare = avs_dai_hda_be_prepare ,
522
+ .trigger = avs_dai_hda_be_trigger ,
523
+ };
524
+
471
525
static int hw_rule_param_size (struct snd_pcm_hw_params * params , struct snd_pcm_hw_rule * rule )
472
526
{
473
527
struct snd_interval * interval = hw_param_interval (params , rule -> var );
0 commit comments