[PATCH RESEND 5/7] ASoC: SOF: Intel: export hda_sdw_bpt_get_buf_size_aligment

Bard Liao posted 7 patches 1 month, 2 weeks ago
[PATCH RESEND 5/7] ASoC: SOF: Intel: export hda_sdw_bpt_get_buf_size_aligment
Posted by Bard Liao 1 month, 2 weeks ago
The dma buffer need to be a multiple of data block size and
the fifo size. Export a function to return the LCM of data
block size and the fifo size.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
---
 include/sound/hda-sdw-bpt.h       |  7 +++++++
 sound/soc/sof/intel/hda-sdw-bpt.c | 13 +++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/include/sound/hda-sdw-bpt.h b/include/sound/hda-sdw-bpt.h
index f649549b75d5..9b654c31829a 100644
--- a/include/sound/hda-sdw-bpt.h
+++ b/include/sound/hda-sdw-bpt.h
@@ -30,6 +30,8 @@ int hda_sdw_bpt_wait(struct device *dev, struct hdac_ext_stream *bpt_tx_stream,
 int hda_sdw_bpt_close(struct device *dev, struct hdac_ext_stream *bpt_tx_stream,
 		      struct snd_dma_buffer *dmab_tx_bdl, struct hdac_ext_stream *bpt_rx_stream,
 		      struct snd_dma_buffer *dmab_rx_bdl);
+
+unsigned int hda_sdw_bpt_get_buf_size_alignment(unsigned int dma_bandwidth);
 #else
 static inline int hda_sdw_bpt_open(struct device *dev, int link_id,
 				   struct hdac_ext_stream **bpt_tx_stream,
@@ -64,6 +66,11 @@ static inline int hda_sdw_bpt_close(struct device *dev, struct hdac_ext_stream *
 	WARN_ONCE(1, "SoundWire BPT is disabled");
 	return -EOPNOTSUPP;
 }
+
+static inline unsigned int hda_sdw_bpt_get_buf_size_alignment(unsigned int dma_bandwidth)
+{
+	return 0;
+}
 #endif
 
 #endif /* __HDA_SDW_BPT_H */
diff --git a/sound/soc/sof/intel/hda-sdw-bpt.c b/sound/soc/sof/intel/hda-sdw-bpt.c
index ff5abccf0d88..e45dd051ab8c 100644
--- a/sound/soc/sof/intel/hda-sdw-bpt.c
+++ b/sound/soc/sof/intel/hda-sdw-bpt.c
@@ -10,6 +10,7 @@
  * Hardware interface for SoundWire BPT support with HDA DMA
  */
 
+#include <linux/lcm.h>
 #include <sound/hdaudio_ext.h>
 #include <sound/hda-mlink.h>
 #include <sound/hda-sdw-bpt.h>
@@ -236,6 +237,18 @@ static int hda_sdw_bpt_dma_disable(struct device *dev, struct hdac_ext_stream *s
 	return ret;
 }
 
+#define FIFO_ALIGNMENT	64
+
+unsigned int hda_sdw_bpt_get_buf_size_alignment(unsigned int dma_bandwidth)
+{
+	unsigned int num_channels = DIV_ROUND_UP(dma_bandwidth, BPT_FREQUENCY * 32);
+	unsigned int data_block = num_channels * 4;
+	unsigned int alignment = lcm(data_block, FIFO_ALIGNMENT);
+
+	return alignment;
+}
+EXPORT_SYMBOL_NS(hda_sdw_bpt_get_buf_size_alignment, "SND_SOC_SOF_INTEL_HDA_SDW_BPT");
+
 int hda_sdw_bpt_open(struct device *dev, int link_id, struct hdac_ext_stream **bpt_tx_stream,
 		     struct snd_dma_buffer *dmab_tx_bdl, u32 bpt_tx_num_bytes,
 		     u32 tx_dma_bandwidth, struct hdac_ext_stream **bpt_rx_stream,
-- 
2.43.0
Re: [PATCH RESEND 5/7] ASoC: SOF: Intel: export hda_sdw_bpt_get_buf_size_aligment
Posted by Mark Brown 1 month, 2 weeks ago
On Thu, Oct 30, 2025 at 03:02:51PM +0800, Bard Liao wrote:

> +unsigned int hda_sdw_bpt_get_buf_size_alignment(unsigned int dma_bandwidth)
> +{
> +	unsigned int num_channels = DIV_ROUND_UP(dma_bandwidth, BPT_FREQUENCY * 32);
> +	unsigned int data_block = num_channels * 4;
> +	unsigned int alignment = lcm(data_block, FIFO_ALIGNMENT);
> +
> +	return alignment;
> +}
> +EXPORT_SYMBOL_NS(hda_sdw_bpt_get_buf_size_alignment, "SND_SOC_SOF_INTEL_HDA_SDW_BPT");

The rest of ASoC is _GPL?
RE: [PATCH RESEND 5/7] ASoC: SOF: Intel: export hda_sdw_bpt_get_buf_size_aligment
Posted by Liao, Bard 1 month, 2 weeks ago

> -----Original Message-----
> From: Mark Brown <broonie@kernel.org>
> Sent: Thursday, October 30, 2025 7:17 PM
> To: Bard Liao <yung-chuan.liao@linux.intel.com>
> Cc: linux-sound@vger.kernel.org; vkoul@kernel.org; tiwai@suse.de;
> vinod.koul@linaro.org; linux-kernel@vger.kernel.org; pierre-
> louis.bossart@linux.dev; Liao, Bard <bard.liao@intel.com>
> Subject: Re: [PATCH RESEND 5/7] ASoC: SOF: Intel: export
> hda_sdw_bpt_get_buf_size_aligment
> 
> On Thu, Oct 30, 2025 at 03:02:51PM +0800, Bard Liao wrote:
> 
> > +unsigned int hda_sdw_bpt_get_buf_size_alignment(unsigned int
> dma_bandwidth)
> > +{
> > +	unsigned int num_channels = DIV_ROUND_UP(dma_bandwidth,
> BPT_FREQUENCY * 32);
> > +	unsigned int data_block = num_channels * 4;
> > +	unsigned int alignment = lcm(data_block, FIFO_ALIGNMENT);
> > +
> > +	return alignment;
> > +}
> > +EXPORT_SYMBOL_NS(hda_sdw_bpt_get_buf_size_alignment,
> "SND_SOC_SOF_INTEL_HDA_SDW_BPT");
> 
> The rest of ASoC is _GPL?

All functions exported in hda-sdw-bpt.c are with EXPORT_SYMBOL_NS. 
I suppose it is ok?
Re: [PATCH RESEND 5/7] ASoC: SOF: Intel: export hda_sdw_bpt_get_buf_size_aligment
Posted by Mark Brown 1 month, 2 weeks ago
On Thu, Oct 30, 2025 at 12:05:23PM +0000, Liao, Bard wrote:

> > The rest of ASoC is _GPL?

> All functions exported in hda-sdw-bpt.c are with EXPORT_SYMBOL_NS. 
> I suppose it is ok?

OK, I guess that's fine.

Acked-by: Mark Brown <broone@kernel.org>