Skip to content

Commit 4a9ce6e

Browse files
crojewsk-intelbroonie
authored andcommitted
ASoC: SOF: Intel: Account for compress streams when servicing IRQs
Update stream irq handler definition to correctly set hdac_stream current position when servicing stream interrupts for compress streams. Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/20200218143924.10565-4-cezary.rojewski@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent b9759ef commit 4a9ce6e

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

‎include/sound/hdaudio.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@ struct hdac_stream {
513513
struct snd_pcm_substream *substream; /* assigned substream,
514514
* set in PCM open
515515
*/
516+
struct snd_compr_stream *cstream;
516517
unsigned int format_val; /* format value to be set in the
517518
* controller and the codec
518519
*/
@@ -527,6 +528,7 @@ struct hdac_stream {
527528
bool locked:1;
528529
bool stripe:1; /* apply stripe control */
529530

531+
u64 curr_pos;
530532
/* timestamp */
531533
unsigned long start_wallclk; /* start + minimum wallclk */
532534
unsigned long period_wallclk; /* wallclk for period */

‎sound/soc/sof/intel/hda-stream.c‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,22 @@ bool hda_dsp_check_stream_irq(struct snd_sof_dev *sdev)
571571
return ret;
572572
}
573573

574+
static void
575+
hda_dsp_set_bytes_transferred(struct hdac_stream *hstream, u64 buffer_size)
576+
{
577+
u64 prev_pos, pos, num_bytes;
578+
579+
div64_u64_rem(hstream->curr_pos, buffer_size, &prev_pos);
580+
pos = snd_hdac_stream_get_pos_posbuf(hstream);
581+
582+
if (pos < prev_pos)
583+
num_bytes = (buffer_size - prev_pos) + pos;
584+
else
585+
num_bytes = pos - prev_pos;
586+
587+
hstream->curr_pos += num_bytes;
588+
}
589+
574590
static bool hda_dsp_stream_check(struct hdac_bus *bus, u32 status)
575591
{
576592
struct sof_intel_hda_dev *sof_hda = bus_to_sof_hda(bus);
@@ -588,14 +604,19 @@ static bool hda_dsp_stream_check(struct hdac_bus *bus, u32 status)
588604
snd_hdac_stream_writeb(s, SD_STS, sd_status);
589605

590606
active = true;
591-
if (!s->substream ||
607+
if ((!s->substream && !s->cstream) ||
592608
!s->running ||
593609
(sd_status & SOF_HDA_CL_DMA_SD_INT_COMPLETE) == 0)
594610
continue;
595611

596612
/* Inform ALSA only in case not do that with IPC */
597-
if (sof_hda->no_ipc_position)
613+
if (s->substream && sof_hda->no_ipc_position) {
598614
snd_sof_pcm_period_elapsed(s->substream);
615+
} else if (s->cstream) {
616+
hda_dsp_set_bytes_transferred(s,
617+
s->cstream->runtime->buffer_size);
618+
snd_compr_fragment_elapsed(s->cstream);
619+
}
599620
}
600621
}
601622

0 commit comments

Comments
 (0)