sound/soc/soc-utils.c
Source file repositories/reference/linux-study-clean/sound/soc/soc-utils.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/soc-utils.c- Extension
.c- Size
- 8019 bytes
- Lines
- 307
- Domain
- Driver Families
- Bucket
- sound/soc
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/device/faux.hlinux/export.hlinux/math.hsound/core.hsound/pcm.hsound/pcm_params.hsound/soc.h
Detected Declarations
function snd_soc_retfunction snd_soc_calc_frame_sizefunction snd_soc_params_to_frame_sizefunction snd_soc_calc_bclkfunction snd_soc_params_to_bclkfunction snd_soc_params_to_bclkfunction dummy_dma_openfunction snd_soc_dai_is_dummyfunction snd_soc_component_is_dummyfunction snd_soc_dlc_is_dummyfunction snd_soc_dummy_probefunction snd_soc_util_initfunction snd_soc_util_exitexport snd_soc_retexport snd_soc_calc_frame_sizeexport snd_soc_params_to_frame_sizeexport snd_soc_calc_bclkexport snd_soc_params_to_bclkexport snd_soc_tdm_params_to_bclkexport snd_soc_dai_is_dummyexport snd_soc_dummy_dlcexport snd_soc_dlc_is_dummy
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
//
// soc-util.c -- ALSA SoC Audio Layer utility functions
//
// Copyright 2009 Wolfson Microelectronics PLC.
//
// Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
// Liam Girdwood <lrg@slimlogic.co.uk>
#include <linux/device/faux.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_ret(const struct device *dev, int ret, const char *fmt, ...)
{
struct va_format vaf;
va_list args;
/* Positive, Zero values are not errors */
if (ret >= 0)
return ret;
/* Negative values might be errors */
switch (ret) {
case -EPROBE_DEFER:
case -ENOTSUPP:
case -EOPNOTSUPP:
break;
default:
va_start(args, fmt);
vaf.fmt = fmt;
vaf.va = &args;
dev_err(dev, "ASoC error (%d): %pV", ret, &vaf);
va_end(args);
}
return ret;
}
EXPORT_SYMBOL_GPL(snd_soc_ret);
int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots)
{
return sample_size * channels * tdm_slots;
}
EXPORT_SYMBOL_GPL(snd_soc_calc_frame_size);
int snd_soc_params_to_frame_size(const struct snd_pcm_hw_params *params)
{
int sample_size;
sample_size = snd_pcm_format_width(params_format(params));
if (sample_size < 0)
return sample_size;
return snd_soc_calc_frame_size(sample_size, params_channels(params),
1);
}
EXPORT_SYMBOL_GPL(snd_soc_params_to_frame_size);
int snd_soc_calc_bclk(int fs, int sample_size, int channels, int tdm_slots)
{
return fs * snd_soc_calc_frame_size(sample_size, channels, tdm_slots);
}
EXPORT_SYMBOL_GPL(snd_soc_calc_bclk);
int snd_soc_params_to_bclk(const struct snd_pcm_hw_params *params)
{
int ret;
ret = snd_soc_params_to_frame_size(params);
if (ret > 0)
return ret * params_rate(params);
else
return ret;
}
EXPORT_SYMBOL_GPL(snd_soc_params_to_bclk);
/**
* 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.
*
Annotation
- Immediate include surface: `linux/device/faux.h`, `linux/export.h`, `linux/math.h`, `sound/core.h`, `sound/pcm.h`, `sound/pcm_params.h`, `sound/soc.h`.
- Detected declarations: `function snd_soc_ret`, `function snd_soc_calc_frame_size`, `function snd_soc_params_to_frame_size`, `function snd_soc_calc_bclk`, `function snd_soc_params_to_bclk`, `function snd_soc_params_to_bclk`, `function dummy_dma_open`, `function snd_soc_dai_is_dummy`, `function snd_soc_component_is_dummy`, `function snd_soc_dlc_is_dummy`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.