Skip to content

Commit 9b5365a

Browse files
committed
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>
1 parent e7098ee commit 9b5365a

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

include/sound/hda-sdw-bpt.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ int hda_sdw_bpt_wait(struct device *dev, struct hdac_ext_stream *bpt_tx_stream,
3030
int hda_sdw_bpt_close(struct device *dev, struct hdac_ext_stream *bpt_tx_stream,
3131
struct snd_dma_buffer *dmab_tx_bdl, struct hdac_ext_stream *bpt_rx_stream,
3232
struct snd_dma_buffer *dmab_rx_bdl);
33+
34+
unsigned int hda_sdw_bpt_get_buf_size_alignment(unsigned int dma_bandwidth);
3335
#else
3436
static inline int hda_sdw_bpt_open(struct device *dev, int link_id,
3537
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 *
6466
WARN_ONCE(1, "SoundWire BPT is disabled");
6567
return -EOPNOTSUPP;
6668
}
69+
70+
static inline unsigned int hda_sdw_bpt_get_buf_size_alignment(unsigned int dma_bandwidth)
71+
{
72+
return 0;
73+
}
6774
#endif
6875

6976
#endif /* __HDA_SDW_BPT_H */

sound/soc/sof/intel/hda-sdw-bpt.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* Hardware interface for SoundWire BPT support with HDA DMA
1111
*/
1212

13+
#include <linux/lcm.h>
1314
#include <sound/hdaudio_ext.h>
1415
#include <sound/hda-mlink.h>
1516
#include <sound/hda-sdw-bpt.h>
@@ -247,6 +248,18 @@ static int hda_sdw_bpt_dma_disable(struct device *dev, struct hdac_ext_stream *s
247248
return ret;
248249
}
249250

251+
#define FIFO_ALIGNMENT 64
252+
253+
unsigned int hda_sdw_bpt_get_buf_size_alignment(unsigned int dma_bandwidth)
254+
{
255+
unsigned int num_channels = DIV_ROUND_UP(dma_bandwidth, BPT_FREQUENCY * 32);
256+
unsigned int data_block = num_channels * 4;
257+
unsigned int alignment = lcm(data_block, FIFO_ALIGNMENT);
258+
259+
return alignment;
260+
}
261+
EXPORT_SYMBOL_NS(hda_sdw_bpt_get_buf_size_alignment, "SND_SOC_SOF_INTEL_HDA_SDW_BPT");
262+
250263
int hda_sdw_bpt_open(struct device *dev, int link_id, struct hdac_ext_stream **bpt_tx_stream,
251264
struct snd_dma_buffer *dmab_tx_bdl, u32 bpt_tx_num_bytes,
252265
u32 tx_dma_bandwidth, struct hdac_ext_stream **bpt_rx_stream,

0 commit comments

Comments
 (0)