summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorBard Liao <yung-chuan.liao@linux.intel.com>2025-10-14 11:14:48 +0800
committerVinod Koul <vkoul@kernel.org>2025-12-08 12:37:26 +0530
commit167efc6dfd621494c6a7e47115dc829dcc0e502c (patch)
tree50fccbc9c416b5e04c138860424cdf9162694cf8 /sound
parent57b3a7b27e0b72df4ccee89719de12719aa9d547 (diff)
ASoC: SOF: Intel: export hda_sdw_bpt_get_buf_size_aligment
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> Link: https://patch.msgid.link/20251014031450.3781789-6-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/sof/intel/hda-sdw-bpt.c13
1 files changed, 13 insertions, 0 deletions
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,