// SPDX-License-Identifier: GPL-2.0+ // // soc-util.c -- ALSA SoC Audio Layer utility functions // // Copyright 2009 Wolfson Microelectronics PLC. // // Author: Mark Brown <[email protected]> // Liam Girdwood <[email protected]> #include <linux/platform_device.h> #include <linux/export.h> #include <linux/math.h> #include <sound/core.h> #include <sound/pcm.h> #include <sound/pcm_params.h> #include <sound/soc.h> int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots) { … } EXPORT_SYMBOL_GPL(…); int snd_soc_params_to_frame_size(const struct snd_pcm_hw_params *params) { … } EXPORT_SYMBOL_GPL(…); int snd_soc_calc_bclk(int fs, int sample_size, int channels, int tdm_slots) { … } EXPORT_SYMBOL_GPL(…); int snd_soc_params_to_bclk(const struct snd_pcm_hw_params *params) { … } EXPORT_SYMBOL_GPL(…); /** * snd_soc_tdm_params_to_bclk - calculate bclk from params and tdm slot info. * * Calculate the bclk from the params sample rate, the tdm slot count and the * tdm slot width. Optionally round-up the slot count to a given multiple. * Either or both of tdm_width and tdm_slots can be 0. * * If tdm_width == 0: use params_width() as the slot width. * If tdm_slots == 0: use params_channels() as the slot count. * * If slot_multiple > 1 the slot count (or params_channels() if tdm_slots == 0) * will be rounded up to a multiple of slot_multiple. This is mainly useful for * I2S mode, which has a left and right phase so the number of slots is always * a multiple of 2. * * If tdm_width == 0 && tdm_slots == 0 && slot_multiple < 2, this is equivalent * to calling snd_soc_params_to_bclk(). * * @params: Pointer to struct_pcm_hw_params. * @tdm_width: Width in bits of the tdm slots. Must be >= 0. * @tdm_slots: Number of tdm slots per frame. Must be >= 0. * @slot_multiple: If >1 roundup slot count to a multiple of this value. * * Return: bclk frequency in Hz, else a negative error code if params format * is invalid. */ int snd_soc_tdm_params_to_bclk(const struct snd_pcm_hw_params *params, int tdm_width, int tdm_slots, int slot_multiple) { … } EXPORT_SYMBOL_GPL(…); static const struct snd_pcm_hardware dummy_dma_hardware = …; static const struct snd_soc_component_driver dummy_platform; static int dummy_dma_open(struct snd_soc_component *component, struct snd_pcm_substream *substream) { … } static const struct snd_soc_component_driver dummy_platform = …; static const struct snd_soc_component_driver dummy_codec = …; #define STUB_FORMATS … /* * Select these from Sound Card Manually * SND_SOC_POSSIBLE_DAIFMT_CBP_CFP * SND_SOC_POSSIBLE_DAIFMT_CBP_CFC * SND_SOC_POSSIBLE_DAIFMT_CBC_CFP * SND_SOC_POSSIBLE_DAIFMT_CBC_CFC */ static const u64 dummy_dai_formats = …; static const struct snd_soc_dai_ops dummy_dai_ops = …; /* * The dummy CODEC is only meant to be used in situations where there is no * actual hardware. * * If there is actual hardware even if it does not have a control bus * the hardware will still have constraints like supported samplerates, etc. * which should be modelled. And the data flow graph also should be modelled * using DAPM. */ static struct snd_soc_dai_driver dummy_dai = …; int snd_soc_dai_is_dummy(const struct snd_soc_dai *dai) { … } EXPORT_SYMBOL_GPL(…); int snd_soc_component_is_dummy(struct snd_soc_component *component) { … } struct snd_soc_dai_link_component snd_soc_dummy_dlc = …; EXPORT_SYMBOL_GPL(…); static int snd_soc_dummy_probe(struct platform_device *pdev) { … } static struct platform_driver soc_dummy_driver = …; static struct platform_device *soc_dummy_dev; int __init snd_soc_util_init(void) { … } void snd_soc_util_exit(void) { … }