Skip to contentSkip to conversation

ALSA: hda: Transfer firmware in two chunks

PATCH Superseded Cezary Rojewski 2 participants 3 messages Jan 14, 2025 Sound

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 ALSA: hda: Transfer firmware in two chunks

As per specification, SDxLVI shall be at least 1 i.e.: two chunks to perform a valid transfer. This is true for the PCM transfer code but not firmware-transfer one.

Technical background:
- the LVI > 0 rule shall be obeyed in PCM transfer
- HW permits LVI == 0 when transfer is SW-controlled (SPIB)
- FW download is not a PCM transfer and is SW-controlled (SPIB)

The above is the fundament which AudioDSP firmware loading functions have been built upon and worked since 2016. The presented changes are to align the loading flows and avoid rising more questions in the future.

Achieve the goal by splitting snd_hdac_stream_setup_periods() into substream-dependent and -independent part. Let snd_hdac_dsp_prepare() utilize the latter so that both DSP-loading and PCM flows utilize same BLDE setup loop which already takes care of cutting the buffer based on azx_dev->period_bytes.

---
 include/sound/hdaudio.h |  2 ++
 sound/hda/hdac_stream.c | 64 ++++++++++++++++++++++++-----------------
 2 files changed, 40 insertions(+), 26 deletions(-)
include/sound/hdaudio.h +2 -0
index b098ceadbe74..3a3cfb832ddc 100644
@@ -577,6 +577,8 @@ struct hdac_stream *snd_hdac_get_stream(struct hdac_bus *bus,
 
 int snd_hdac_stream_setup(struct hdac_stream *azx_dev, bool code_loading);
 void snd_hdac_stream_cleanup(struct hdac_stream *azx_dev);
+int snd_hdac_stream_setup_bdle(struct hdac_stream *azx_dev, struct snd_dma_buffer *dmab,
+			       struct snd_pcm_runtime *runtime);
 int snd_hdac_stream_setup_periods(struct hdac_stream *azx_dev);
 int snd_hdac_stream_set_params(struct hdac_stream *azx_dev,
 				unsigned int format_val);
sound/hda/hdac_stream.c +38 -26

101 lines not on this page · raw message

Signature · 1 line
2.25.1
#1 lore raw

include/sound/hdaudio.h struct hdac_stream *snd_hdac_get_stream(struct hdac_bus *bus, · line 581

Quoted 8 lines · Cezary Rojewski
include/sound/hdaudio.h +2 -0
@@ -577,6 +577,8 @@ struct hdac_stream *snd_hdac_get_stream(struct hdac_bus *bus,
 
 int snd_hdac_stream_setup(struct hdac_stream *azx_dev, bool code_loading);
 void snd_hdac_stream_cleanup(struct hdac_stream *azx_dev);
+int snd_hdac_stream_setup_bdle(struct hdac_stream *azx_dev, struct snd_dma_buffer *dmab,
+			       struct snd_pcm_runtime *runtime);

Will you use this function by other driver in future? Otherwise it makes little sense to export this function.

thanks,

Takashi

#2 lore raw
Quoted 6 lines · Takashi Iwai
Quoted 4 lines · Cezary Rojewski
include/sound/hdaudio.h +0 -0
@@ -577,6 +577,8 @@ struct hdac_stream *snd_hdac_get_stream(struct hdac_bus *bus,
 
Quoted 7 lines

include/sound/hdaudio.h struct hdac_stream *snd_hdac_get_stream(struct hdac_bus *bus, · line 581

Quoted 4 lines
include/sound/hdaudio.h +2 -0
  int snd_hdac_stream_setup(struct hdac_stream *azx_dev, bool code_loading);
  void snd_hdac_stream_cleanup(struct hdac_stream *azx_dev);
+int snd_hdac_stream_setup_bdle(struct hdac_stream *azx_dev, struct snd_dma_buffer *dmab,
+			       struct snd_pcm_runtime *runtime);

Will you use this function by other driver in future? Otherwise it makes little sense to export this function.

While we do have some refactor-related plans for hdac_stream.c, I'm treating that as a separate subject and thus exporting the symbol should not be present here. Sending v4, thank you!

Czarek