77#include <linux/delay.h>
88#include <linux/export.h>
99#include <linux/clocksource.h>
10+ #include <sound/compress_driver.h>
1011#include <sound/core.h>
1112#include <sound/pcm.h>
1213#include <sound/hdaudio.h>
@@ -487,11 +488,20 @@ int snd_hdac_stream_setup_periods(struct hdac_stream *azx_dev)
487488{
488489 struct hdac_bus * bus = azx_dev -> bus ;
489490 struct snd_pcm_substream * substream = azx_dev -> substream ;
490- struct snd_pcm_runtime * runtime = substream -> runtime ;
491+ struct snd_compr_stream * cstream = azx_dev -> cstream ;
492+ struct snd_pcm_runtime * runtime = NULL ;
493+ struct snd_dma_buffer * dmab ;
491494 __le32 * bdl ;
492495 int i , ofs , periods , period_bytes ;
493496 int pos_adj , pos_align ;
494497
498+ if (substream ) {
499+ runtime = substream -> runtime ;
500+ dmab = snd_pcm_get_dma_buf (substream );
501+ } else if (cstream ) {
502+ dmab = snd_pcm_get_dma_buf (cstream );
503+ }
504+
495505 /* reset BDL address */
496506 snd_hdac_stream_writel (azx_dev , SD_BDLPL , 0 );
497507 snd_hdac_stream_writel (azx_dev , SD_BDLPU , 0 );
@@ -505,7 +515,7 @@ int snd_hdac_stream_setup_periods(struct hdac_stream *azx_dev)
505515 azx_dev -> frags = 0 ;
506516
507517 pos_adj = bus -> bdl_pos_adj ;
508- if (!azx_dev -> no_period_wakeup && pos_adj > 0 ) {
518+ if (runtime && !azx_dev -> no_period_wakeup && pos_adj > 0 ) {
509519 pos_align = pos_adj ;
510520 pos_adj = DIV_ROUND_UP (pos_adj * runtime -> rate , 48000 );
511521 if (!pos_adj )
@@ -518,8 +528,7 @@ int snd_hdac_stream_setup_periods(struct hdac_stream *azx_dev)
518528 pos_adj );
519529 pos_adj = 0 ;
520530 } else {
521- ofs = setup_bdle (bus , snd_pcm_get_dma_buf (substream ),
522- azx_dev ,
531+ ofs = setup_bdle (bus , dmab , azx_dev ,
523532 & bdl , ofs , pos_adj , true);
524533 if (ofs < 0 )
525534 goto error ;
@@ -529,13 +538,11 @@ int snd_hdac_stream_setup_periods(struct hdac_stream *azx_dev)
529538
530539 for (i = 0 ; i < periods ; i ++ ) {
531540 if (i == periods - 1 && pos_adj )
532- ofs = setup_bdle (bus , snd_pcm_get_dma_buf (substream ),
533- azx_dev , & bdl , ofs ,
534- period_bytes - pos_adj , 0 );
541+ ofs = setup_bdle (bus , dmab , azx_dev ,
542+ & bdl , ofs , period_bytes - pos_adj , 0 );
535543 else
536- ofs = setup_bdle (bus , snd_pcm_get_dma_buf (substream ),
537- azx_dev , & bdl , ofs ,
538- period_bytes ,
544+ ofs = setup_bdle (bus , dmab , azx_dev ,
545+ & bdl , ofs , period_bytes ,
539546 !azx_dev -> no_period_wakeup );
540547 if (ofs < 0 )
541548 goto error ;
@@ -560,26 +567,32 @@ EXPORT_SYMBOL_GPL(snd_hdac_stream_setup_periods);
560567int snd_hdac_stream_set_params (struct hdac_stream * azx_dev ,
561568 unsigned int format_val )
562569{
563-
564- unsigned int bufsize , period_bytes ;
565570 struct snd_pcm_substream * substream = azx_dev -> substream ;
566- struct snd_pcm_runtime * runtime ;
571+ struct snd_compr_stream * cstream = azx_dev -> cstream ;
572+ unsigned int bufsize , period_bytes ;
573+ unsigned int no_period_wakeup ;
567574 int err ;
568575
569- if (!substream )
576+ if (substream ) {
577+ bufsize = snd_pcm_lib_buffer_bytes (substream );
578+ period_bytes = snd_pcm_lib_period_bytes (substream );
579+ no_period_wakeup = substream -> runtime -> no_period_wakeup ;
580+ } else if (cstream ) {
581+ bufsize = cstream -> runtime -> buffer_size ;
582+ period_bytes = cstream -> runtime -> fragment_size ;
583+ no_period_wakeup = 0 ;
584+ } else {
570585 return - EINVAL ;
571- runtime = substream -> runtime ;
572- bufsize = snd_pcm_lib_buffer_bytes (substream );
573- period_bytes = snd_pcm_lib_period_bytes (substream );
586+ }
574587
575588 if (bufsize != azx_dev -> bufsize ||
576589 period_bytes != azx_dev -> period_bytes ||
577590 format_val != azx_dev -> format_val ||
578- runtime -> no_period_wakeup != azx_dev -> no_period_wakeup ) {
591+ no_period_wakeup != azx_dev -> no_period_wakeup ) {
579592 azx_dev -> bufsize = bufsize ;
580593 azx_dev -> period_bytes = period_bytes ;
581594 azx_dev -> format_val = format_val ;
582- azx_dev -> no_period_wakeup = runtime -> no_period_wakeup ;
595+ azx_dev -> no_period_wakeup = no_period_wakeup ;
583596 err = snd_hdac_stream_setup_periods (azx_dev );
584597 if (err < 0 )
585598 return err ;
0 commit comments