ALSA: hda: Prepare for compress stream support
Before introducing compress specific changes, adjust BDL and parameters setup functions so these are not tightly coupled with PCM streams. Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Acked-by: Takashi Iwai <tiwai@suse.de> Link: https://lore.kernel.org/r/20221202152841.672536-3-cezary.rojewski@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
97d73d9782
commit
f6b1254664
|
@ -487,11 +487,15 @@ int snd_hdac_stream_setup_periods(struct hdac_stream *azx_dev)
|
|||
{
|
||||
struct hdac_bus *bus = azx_dev->bus;
|
||||
struct snd_pcm_substream *substream = azx_dev->substream;
|
||||
struct snd_pcm_runtime *runtime = substream->runtime;
|
||||
struct snd_pcm_runtime *runtime;
|
||||
struct snd_dma_buffer *dmab;
|
||||
__le32 *bdl;
|
||||
int i, ofs, periods, period_bytes;
|
||||
int pos_adj, pos_align;
|
||||
|
||||
runtime = substream->runtime;
|
||||
dmab = snd_pcm_get_dma_buf(substream);
|
||||
|
||||
/* reset BDL address */
|
||||
snd_hdac_stream_writel(azx_dev, SD_BDLPL, 0);
|
||||
snd_hdac_stream_writel(azx_dev, SD_BDLPU, 0);
|
||||
|
@ -505,7 +509,7 @@ int snd_hdac_stream_setup_periods(struct hdac_stream *azx_dev)
|
|||
azx_dev->frags = 0;
|
||||
|
||||
pos_adj = bus->bdl_pos_adj;
|
||||
if (!azx_dev->no_period_wakeup && pos_adj > 0) {
|
||||
if (runtime && !azx_dev->no_period_wakeup && pos_adj > 0) {
|
||||
pos_align = pos_adj;
|
||||
pos_adj = DIV_ROUND_UP(pos_adj * runtime->rate, 48000);
|
||||
if (!pos_adj)
|
||||
|
@ -518,8 +522,7 @@ int snd_hdac_stream_setup_periods(struct hdac_stream *azx_dev)
|
|||
pos_adj);
|
||||
pos_adj = 0;
|
||||
} else {
|
||||
ofs = setup_bdle(bus, snd_pcm_get_dma_buf(substream),
|
||||
azx_dev,
|
||||
ofs = setup_bdle(bus, dmab, azx_dev,
|
||||
&bdl, ofs, pos_adj, true);
|
||||
if (ofs < 0)
|
||||
goto error;
|
||||
|
@ -529,13 +532,11 @@ int snd_hdac_stream_setup_periods(struct hdac_stream *azx_dev)
|
|||
|
||||
for (i = 0; i < periods; i++) {
|
||||
if (i == periods - 1 && pos_adj)
|
||||
ofs = setup_bdle(bus, snd_pcm_get_dma_buf(substream),
|
||||
azx_dev, &bdl, ofs,
|
||||
period_bytes - pos_adj, 0);
|
||||
ofs = setup_bdle(bus, dmab, azx_dev,
|
||||
&bdl, ofs, period_bytes - pos_adj, 0);
|
||||
else
|
||||
ofs = setup_bdle(bus, snd_pcm_get_dma_buf(substream),
|
||||
azx_dev, &bdl, ofs,
|
||||
period_bytes,
|
||||
ofs = setup_bdle(bus, dmab, azx_dev,
|
||||
&bdl, ofs, period_bytes,
|
||||
!azx_dev->no_period_wakeup);
|
||||
if (ofs < 0)
|
||||
goto error;
|
||||
|
@ -560,26 +561,25 @@ EXPORT_SYMBOL_GPL(snd_hdac_stream_setup_periods);
|
|||
int snd_hdac_stream_set_params(struct hdac_stream *azx_dev,
|
||||
unsigned int format_val)
|
||||
{
|
||||
|
||||
unsigned int bufsize, period_bytes;
|
||||
struct snd_pcm_substream *substream = azx_dev->substream;
|
||||
struct snd_pcm_runtime *runtime;
|
||||
unsigned int bufsize, period_bytes;
|
||||
unsigned int no_period_wakeup;
|
||||
int err;
|
||||
|
||||
if (!substream)
|
||||
return -EINVAL;
|
||||
runtime = substream->runtime;
|
||||
bufsize = snd_pcm_lib_buffer_bytes(substream);
|
||||
period_bytes = snd_pcm_lib_period_bytes(substream);
|
||||
no_period_wakeup = substream->runtime->no_period_wakeup;
|
||||
|
||||
if (bufsize != azx_dev->bufsize ||
|
||||
period_bytes != azx_dev->period_bytes ||
|
||||
format_val != azx_dev->format_val ||
|
||||
runtime->no_period_wakeup != azx_dev->no_period_wakeup) {
|
||||
no_period_wakeup != azx_dev->no_period_wakeup) {
|
||||
azx_dev->bufsize = bufsize;
|
||||
azx_dev->period_bytes = period_bytes;
|
||||
azx_dev->format_val = format_val;
|
||||
azx_dev->no_period_wakeup = runtime->no_period_wakeup;
|
||||
azx_dev->no_period_wakeup = no_period_wakeup;
|
||||
err = snd_hdac_stream_setup_periods(azx_dev);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
|
Loading…
Reference in New Issue