sound/soc/samsung/snow.c
Source file repositories/reference/linux-study-clean/sound/soc/samsung/snow.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/samsung/snow.c- Extension
.c- Size
- 6033 bytes
- Lines
- 255
- Domain
- Driver Families
- Bucket
- sound/soc
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/clk.hlinux/module.hlinux/platform_device.hlinux/of.hsound/pcm_params.hsound/soc.hi2s.h
Detected Declarations
struct snow_privfunction snow_card_hw_paramsfunction snow_late_probefunction snow_probefunction snow_remove
Annotated Snippet
struct snow_priv {
struct snd_soc_dai_link dai_link;
struct clk *clk_i2s_bus;
};
static int snow_card_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
static const unsigned int pll_rate[] = {
73728000U, 67737602U, 49152000U, 45158401U, 32768001U
};
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
struct snow_priv *priv = snd_soc_card_get_drvdata(rtd->card);
int bfs, psr, rfs, bitwidth;
unsigned long int rclk;
long int freq = -EINVAL;
int ret, i;
bitwidth = snd_pcm_format_width(params_format(params));
if (bitwidth < 0) {
dev_err(rtd->card->dev, "Invalid bit-width: %d\n", bitwidth);
return bitwidth;
}
if (bitwidth != 16 && bitwidth != 24) {
dev_err(rtd->card->dev, "Unsupported bit-width: %d\n", bitwidth);
return -EINVAL;
}
bfs = 2 * bitwidth;
switch (params_rate(params)) {
case 16000:
case 22050:
case 24000:
case 32000:
case 44100:
case 48000:
case 88200:
case 96000:
rfs = 8 * bfs;
break;
case 64000:
rfs = 384;
break;
case 8000:
case 11025:
case 12000:
rfs = 16 * bfs;
break;
default:
return -EINVAL;
}
rclk = params_rate(params) * rfs;
for (psr = 8; psr > 0; psr /= 2) {
for (i = 0; i < ARRAY_SIZE(pll_rate); i++) {
if ((pll_rate[i] - rclk * psr) <= 2) {
freq = pll_rate[i];
break;
}
}
}
if (freq < 0) {
dev_err(rtd->card->dev, "Unsupported RCLK rate: %lu\n", rclk);
return -EINVAL;
}
ret = clk_set_rate(priv->clk_i2s_bus, freq);
if (ret < 0) {
dev_err(rtd->card->dev, "I2S bus clock rate set failed\n");
return ret;
}
return 0;
}
static const struct snd_soc_ops snow_card_ops = {
.hw_params = snow_card_hw_params,
};
static int snow_late_probe(struct snd_soc_card *card)
{
struct snd_soc_pcm_runtime *rtd;
struct snd_soc_dai *codec_dai;
rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]);
/* In the multi-codec case codec_dais 0 is MAX98095 and 1 is HDMI. */
Annotation
- Immediate include surface: `linux/clk.h`, `linux/module.h`, `linux/platform_device.h`, `linux/of.h`, `sound/pcm_params.h`, `sound/soc.h`, `i2s.h`.
- Detected declarations: `struct snow_priv`, `function snow_card_hw_params`, `function snow_late_probe`, `function snow_probe`, `function snow_remove`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: source 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.