sound/soc/codecs/si476x.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/si476x.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/si476x.c- Extension
.c- Size
- 6389 bytes
- Lines
- 264
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/slab.hsound/pcm.hsound/pcm_params.hlinux/regmap.hsound/soc.hsound/initval.hlinux/i2c.hlinux/mfd/si476x-core.h
Detected Declarations
enum si476x_audio_registersenum si476x_digital_io_output_formatenum si476x_daudio_formatsenum si476x_pcm_formatfunction si476x_codec_set_dai_fmtfunction si476x_codec_hw_paramsfunction si476x_probefunction si476x_platform_probe
Annotated Snippet
switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
case SND_SOC_DAIFMT_NB_NF:
break;
case SND_SOC_DAIFMT_IB_NF:
format |= SI476X_DAUDIO_MODE_IB;
break;
default:
return -EINVAL;
}
break;
case SND_SOC_DAIFMT_I2S:
case SND_SOC_DAIFMT_RIGHT_J:
case SND_SOC_DAIFMT_LEFT_J:
switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
case SND_SOC_DAIFMT_NB_NF:
break;
case SND_SOC_DAIFMT_IB_IF:
format |= SI476X_DAUDIO_MODE_IB |
SI476X_DAUDIO_MODE_IF;
break;
case SND_SOC_DAIFMT_IB_NF:
format |= SI476X_DAUDIO_MODE_IB;
break;
case SND_SOC_DAIFMT_NB_IF:
format |= SI476X_DAUDIO_MODE_IF;
break;
default:
return -EINVAL;
}
break;
default:
return -EINVAL;
}
si476x_core_lock(core);
err = snd_soc_component_update_bits(codec_dai->component, SI476X_DIGITAL_IO_OUTPUT_FORMAT,
SI476X_DIGITAL_IO_OUTPUT_FORMAT_MASK,
format);
si476x_core_unlock(core);
if (err < 0) {
dev_err(codec_dai->component->dev, "Failed to set output format\n");
return err;
}
return 0;
}
static int si476x_codec_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{
struct si476x_core *core = i2c_mfd_cell_to_core(dai->dev);
int rate, width, err;
rate = params_rate(params);
if (rate < 32000 || rate > 48000) {
dev_err(dai->component->dev, "Rate: %d is not supported\n", rate);
return -EINVAL;
}
switch (params_width(params)) {
case 8:
width = SI476X_PCM_FORMAT_S8;
break;
case 16:
width = SI476X_PCM_FORMAT_S16_LE;
break;
case 20:
width = SI476X_PCM_FORMAT_S20_3LE;
break;
case 24:
width = SI476X_PCM_FORMAT_S24_LE;
break;
default:
return -EINVAL;
}
si476x_core_lock(core);
err = snd_soc_component_write(dai->component, SI476X_DIGITAL_IO_OUTPUT_SAMPLE_RATE,
rate);
if (err < 0) {
dev_err(dai->component->dev, "Failed to set sample rate\n");
goto out;
}
err = snd_soc_component_update_bits(dai->component, SI476X_DIGITAL_IO_OUTPUT_FORMAT,
Annotation
- Immediate include surface: `linux/module.h`, `linux/slab.h`, `sound/pcm.h`, `sound/pcm_params.h`, `linux/regmap.h`, `sound/soc.h`, `sound/initval.h`, `linux/i2c.h`.
- Detected declarations: `enum si476x_audio_registers`, `enum si476x_digital_io_output_format`, `enum si476x_daudio_formats`, `enum si476x_pcm_format`, `function si476x_codec_set_dai_fmt`, `function si476x_codec_hw_params`, `function si476x_probe`, `function si476x_platform_probe`.
- 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.