sound/soc/intel/boards/cht_bsw_nau8824.c
Source file repositories/reference/linux-study-clean/sound/soc/intel/boards/cht_bsw_nau8824.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/intel/boards/cht_bsw_nau8824.c- Extension
.c- Size
- 8570 bytes
- Lines
- 309
- 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/module.hlinux/platform_device.hlinux/slab.hsound/pcm.hsound/pcm_params.hsound/soc.hsound/soc-acpi.hsound/jack.hlinux/input.h../atom/sst-atom-controls.h../../codecs/nau8824.h
Detected Declarations
struct cht_mc_privatefunction cht_aif1_hw_paramsfunction cht_codec_initfunction cht_codec_fixupfunction cht_aif1_startupfunction snd_cht_mc_probe
Annotated Snippet
struct cht_mc_private {
struct snd_soc_jack jack;
};
static struct snd_soc_jack_pin cht_bsw_jack_pins[] = {
{
.pin = "Headphone",
.mask = SND_JACK_HEADPHONE,
},
{
.pin = "Headset Mic",
.mask = SND_JACK_MICROPHONE,
},
};
static const struct snd_soc_dapm_widget cht_dapm_widgets[] = {
SND_SOC_DAPM_HP("Headphone", NULL),
SND_SOC_DAPM_MIC("Headset Mic", NULL),
SND_SOC_DAPM_MIC("Int Mic", NULL),
SND_SOC_DAPM_SPK("Ext Spk", NULL),
};
static const struct snd_soc_dapm_route cht_audio_map[] = {
{"Ext Spk", NULL, "SPKOUTL"},
{"Ext Spk", NULL, "SPKOUTR"},
{"Headphone", NULL, "HPOL"},
{"Headphone", NULL, "HPOR"},
{"MIC1", NULL, "Int Mic"},
{"MIC2", NULL, "Int Mic"},
{"HSMIC1", NULL, "Headset Mic"},
{"HSMIC2", NULL, "Headset Mic"},
{"Playback", NULL, "ssp2 Tx"},
{"ssp2 Tx", NULL, "codec_out0"},
{"ssp2 Tx", NULL, "codec_out1"},
{"codec_in0", NULL, "ssp2 Rx" },
{"codec_in1", NULL, "ssp2 Rx" },
{"ssp2 Rx", NULL, "Capture"},
};
static const struct snd_kcontrol_new cht_mc_controls[] = {
SOC_DAPM_PIN_SWITCH("Headphone"),
SOC_DAPM_PIN_SWITCH("Headset Mic"),
SOC_DAPM_PIN_SWITCH("Int Mic"),
SOC_DAPM_PIN_SWITCH("Ext Spk"),
};
static int cht_aif1_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0);
int ret;
ret = snd_soc_dai_set_sysclk(codec_dai, NAU8824_CLK_FLL_FS, 0,
SND_SOC_CLOCK_IN);
if (ret < 0) {
dev_err(codec_dai->dev, "can't set FS clock %d\n", ret);
return ret;
}
ret = snd_soc_dai_set_pll(codec_dai, 0, 0, params_rate(params),
params_rate(params) * 256);
if (ret < 0) {
dev_err(codec_dai->dev, "can't set FLL: %d\n", ret);
return ret;
}
return 0;
}
static int cht_codec_init(struct snd_soc_pcm_runtime *runtime)
{
struct cht_mc_private *ctx = snd_soc_card_get_drvdata(runtime->card);
struct snd_soc_jack *jack = &ctx->jack;
struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(runtime, 0);
struct snd_soc_component *component = codec_dai->component;
int ret, jack_type;
/* NAU88L24 supports 4 buttons headset detection
* KEY_PLAYPAUSE
* KEY_VOICECOMMAND
* KEY_VOLUMEUP
* KEY_VOLUMEDOWN
*/
jack_type = SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 |
SND_JACK_BTN_2 | SND_JACK_BTN_3;
ret = snd_soc_card_jack_new_pins(runtime->card, "Headset", jack_type,
jack, cht_bsw_jack_pins, ARRAY_SIZE(cht_bsw_jack_pins));
if (ret) {
dev_err(runtime->dev,
"Headset Jack creation failed %d\n", ret);
Annotation
- Immediate include surface: `linux/module.h`, `linux/platform_device.h`, `linux/slab.h`, `sound/pcm.h`, `sound/pcm_params.h`, `sound/soc.h`, `sound/soc-acpi.h`, `sound/jack.h`.
- Detected declarations: `struct cht_mc_private`, `function cht_aif1_hw_params`, `function cht_codec_init`, `function cht_codec_fixup`, `function cht_aif1_startup`, `function snd_cht_mc_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.