Brooklyn/sound/soc/sof/compress.c

52 lines
1.3 KiB
C
Raw Normal View History

// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
//
2022-04-02 17:10:17 +05:00
// Copyright 2021 NXP
//
2022-04-02 17:10:17 +05:00
// Author: Daniel Baluta <daniel.baluta@nxp.com>
#include <sound/soc.h>
2022-04-02 17:10:17 +05:00
#include <sound/sof.h>
#include <sound/compress_driver.h>
#include "sof-audio.h"
#include "sof-priv.h"
2022-04-02 17:10:17 +05:00
static void snd_sof_compr_fragment_elapsed_work(struct work_struct *work)
{
2022-04-02 17:10:17 +05:00
struct snd_sof_pcm_stream *sps =
container_of(work, struct snd_sof_pcm_stream,
period_elapsed_work);
2022-04-02 17:10:17 +05:00
snd_compr_fragment_elapsed(sps->cstream);
}
2022-04-02 17:10:17 +05:00
void snd_sof_compr_init_elapsed_work(struct work_struct *work)
{
2022-04-02 17:10:17 +05:00
INIT_WORK(work, snd_sof_compr_fragment_elapsed_work);
}
2022-04-02 17:10:17 +05:00
/*
* sof compr fragment elapse, this could be called in irq thread context
*/
void snd_sof_compr_fragment_elapsed(struct snd_compr_stream *cstream)
{
2022-04-02 17:10:17 +05:00
struct snd_soc_component *component;
struct snd_soc_pcm_runtime *rtd;
struct snd_sof_pcm *spcm;
2022-04-02 17:10:17 +05:00
if (!cstream)
return;
2022-04-02 17:10:17 +05:00
rtd = cstream->private_data;
component = snd_soc_rtdcom_lookup(rtd, SOF_AUDIO_PCM_DRV_NAME);
2022-04-02 17:10:17 +05:00
spcm = snd_sof_find_spcm_dai(component, rtd);
if (!spcm) {
dev_err(component->dev,
"fragment elapsed called for unknown stream!\n");
return;
}
2022-04-02 17:10:17 +05:00
/* use the same workqueue-based solution as for PCM, cf. snd_sof_pcm_elapsed */
schedule_work(&spcm->stream[cstream->direction].period_elapsed_work);
}