sound/soc/soc-card.c
Source file repositories/reference/linux-study-clean/sound/soc/soc-card.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/soc-card.c- Extension
.c- Size
- 6213 bytes
- Lines
- 262
- 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/lockdep.hlinux/rwsem.hsound/soc.hsound/jack.h
Detected Declarations
function _soc_card_retfunction jack_newfunction snd_soc_card_jack_new_pinsfunction snd_soc_card_jack_newfunction snd_soc_card_suspend_prefunction snd_soc_card_suspend_postfunction snd_soc_card_resume_prefunction snd_soc_card_resume_postfunction snd_soc_card_probefunction snd_soc_card_late_probefunction snd_soc_card_fixup_controlsfunction snd_soc_card_removefunction snd_soc_card_set_bias_levelfunction snd_soc_card_set_bias_level_postfunction snd_soc_card_add_dai_linkfunction snd_soc_card_remove_dai_linkfunction snd_soc_card_set_topology_nameexport snd_soc_card_get_kcontrolexport snd_soc_card_jack_newexport snd_soc_card_jack_new_pinsexport snd_soc_card_add_dai_linkexport snd_soc_card_remove_dai_linkexport snd_soc_card_set_topology_name
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
//
// soc-card.c
//
// Copyright (C) 2019 Renesas Electronics Corp.
// Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
//
#include <linux/lockdep.h>
#include <linux/rwsem.h>
#include <sound/soc.h>
#include <sound/jack.h>
#define soc_card_ret(dai, ret) _soc_card_ret(dai, __func__, ret)
static inline int _soc_card_ret(struct snd_soc_card *card,
const char *func, int ret)
{
return snd_soc_ret(card->dev, ret,
"at %s() on %s\n", func, card->name);
}
struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card,
const char *name)
{
if (unlikely(!name))
return NULL;
return snd_ctl_find_id_mixer(soc_card->snd_card, name);
}
EXPORT_SYMBOL_GPL(snd_soc_card_get_kcontrol);
static int jack_new(struct snd_soc_card *card, const char *id, int type,
struct snd_soc_jack *jack, bool initial_kctl)
{
mutex_init(&jack->mutex);
jack->card = card;
INIT_LIST_HEAD(&jack->pins);
INIT_LIST_HEAD(&jack->jack_zones);
BLOCKING_INIT_NOTIFIER_HEAD(&jack->notifier);
return snd_jack_new(card->snd_card, id, type, &jack->jack, initial_kctl, false);
}
/**
* snd_soc_card_jack_new - Create a new jack without pins
* @card: ASoC card
* @id: an identifying string for this jack
* @type: a bitmask of enum snd_jack_type values that can be detected by
* this jack
* @jack: structure to use for the jack
*
* Creates a new jack object without pins. If adding pins later,
* snd_soc_card_jack_new_pins() should be used instead with 0 as num_pins
* argument.
*
* Returns zero if successful, or a negative error code on failure.
* On success jack will be initialised.
*/
int snd_soc_card_jack_new(struct snd_soc_card *card, const char *id, int type,
struct snd_soc_jack *jack)
{
return soc_card_ret(card, jack_new(card, id, type, jack, true));
}
EXPORT_SYMBOL_GPL(snd_soc_card_jack_new);
/**
* snd_soc_card_jack_new_pins - Create a new jack with pins
* @card: ASoC card
* @id: an identifying string for this jack
* @type: a bitmask of enum snd_jack_type values that can be detected by
* this jack
* @jack: structure to use for the jack
* @pins: Array of jack pins to be added to the jack or NULL
* @num_pins: Number of elements in the @pins array
*
* Creates a new jack object with pins. If not adding pins,
* snd_soc_card_jack_new() should be used instead.
*
* Returns zero if successful, or a negative error code on failure.
* On success jack will be initialised.
*/
int snd_soc_card_jack_new_pins(struct snd_soc_card *card, const char *id,
int type, struct snd_soc_jack *jack,
struct snd_soc_jack_pin *pins,
unsigned int num_pins)
{
int ret;
ret = jack_new(card, id, type, jack, false);
if (ret)
Annotation
- Immediate include surface: `linux/lockdep.h`, `linux/rwsem.h`, `sound/soc.h`, `sound/jack.h`.
- Detected declarations: `function _soc_card_ret`, `function jack_new`, `function snd_soc_card_jack_new_pins`, `function snd_soc_card_jack_new`, `function snd_soc_card_suspend_pre`, `function snd_soc_card_suspend_post`, `function snd_soc_card_resume_pre`, `function snd_soc_card_resume_post`, `function snd_soc_card_probe`, `function snd_soc_card_late_probe`.
- 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.