sound/soc/soc-ac97.c
Source file repositories/reference/linux-study-clean/sound/soc/soc-ac97.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/soc-ac97.c- Extension
.c- Size
- 10731 bytes
- Lines
- 405
- 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.
- 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/ctype.hlinux/delay.hlinux/export.hlinux/gpio/consumer.hlinux/gpio/driver.hlinux/init.hlinux/of.hlinux/pinctrl/consumer.hlinux/slab.hsound/ac97_codec.hsound/soc.h
Detected Declarations
struct snd_ac97_reset_cfgstruct snd_ac97_gpio_privfunction soc_ac97_device_releasefunction snd_soc_ac97_gpio_requestfunction snd_soc_ac97_gpio_direction_infunction snd_soc_ac97_gpio_getfunction snd_soc_ac97_gpio_setfunction snd_soc_ac97_gpio_direction_outfunction snd_soc_ac97_init_gpiofunction snd_soc_ac97_free_gpiofunction snd_soc_ac97_init_gpiofunction snd_soc_ac97_free_gpiofunction snd_soc_free_ac97_componentfunction snd_soc_ac97_warm_resetfunction snd_soc_ac97_resetfunction snd_soc_ac97_parse_pinctlfunction snd_soc_set_ac97_opsfunction snd_soc_set_ac97_ops_of_resetexport snd_soc_alloc_ac97_componentexport snd_soc_new_ac97_componentexport snd_soc_free_ac97_componentexport soc_ac97_opsexport snd_soc_set_ac97_opsexport snd_soc_set_ac97_ops_of_reset
Annotated Snippet
* it. The caller is responsible to either call device_add(&ac97->dev) to
* register the device, or to call put_device(&ac97->dev) to free the device.
*
* Returns: A snd_ac97 device or an ERR_PTR in case of an error.
*/
struct snd_ac97 *snd_soc_alloc_ac97_component(struct snd_soc_component *component)
{
struct snd_ac97 *ac97;
ac97 = kzalloc_obj(struct snd_ac97);
if (ac97 == NULL)
return ERR_PTR(-ENOMEM);
ac97->bus = &soc_ac97_bus;
ac97->num = 0;
ac97->dev.bus = &ac97_bus_type;
ac97->dev.parent = component->card->dev;
ac97->dev.release = soc_ac97_device_release;
dev_set_name(&ac97->dev, "%d-%d:%s",
component->card->snd_card->number, 0,
component->name);
device_initialize(&ac97->dev);
return ac97;
}
EXPORT_SYMBOL(snd_soc_alloc_ac97_component);
/**
* snd_soc_new_ac97_component - initailise AC97 device
* @component: audio component
* @id: The expected device ID
* @id_mask: Mask that is applied to the device ID before comparing with @id
*
* Initialises AC97 component resources for use by ad-hoc devices only.
*
* If @id is not 0 this function will reset the device, then read the ID from
* the device and check if it matches the expected ID. If it doesn't match an
* error will be returned and device will not be registered.
*
* Returns: An ERR_PTR on failure or a valid snd_ac97 struct on success.
*/
struct snd_ac97 *snd_soc_new_ac97_component(struct snd_soc_component *component,
unsigned int id, unsigned int id_mask)
{
struct snd_ac97 *ac97;
int ret;
ac97 = snd_soc_alloc_ac97_component(component);
if (IS_ERR(ac97))
return ac97;
if (id) {
ret = snd_ac97_reset(ac97, false, id, id_mask);
if (ret < 0) {
dev_err(component->dev, "Failed to reset AC97 device: %d\n",
ret);
goto err_put_device;
}
}
ret = device_add(&ac97->dev);
if (ret)
goto err_put_device;
ret = snd_soc_ac97_init_gpio(ac97, component);
if (ret)
goto err_put_device;
return ac97;
err_put_device:
put_device(&ac97->dev);
return ERR_PTR(ret);
}
EXPORT_SYMBOL_GPL(snd_soc_new_ac97_component);
/**
* snd_soc_free_ac97_component - free AC97 component device
* @ac97: snd_ac97 device to be freed
*
* Frees AC97 component device resources.
*/
void snd_soc_free_ac97_component(struct snd_ac97 *ac97)
{
snd_soc_ac97_free_gpio(ac97);
device_del(&ac97->dev);
ac97->bus = NULL;
Annotation
- Immediate include surface: `linux/ctype.h`, `linux/delay.h`, `linux/export.h`, `linux/gpio/consumer.h`, `linux/gpio/driver.h`, `linux/init.h`, `linux/of.h`, `linux/pinctrl/consumer.h`.
- Detected declarations: `struct snd_ac97_reset_cfg`, `struct snd_ac97_gpio_priv`, `function soc_ac97_device_release`, `function snd_soc_ac97_gpio_request`, `function snd_soc_ac97_gpio_direction_in`, `function snd_soc_ac97_gpio_get`, `function snd_soc_ac97_gpio_set`, `function snd_soc_ac97_gpio_direction_out`, `function snd_soc_ac97_init_gpio`, `function snd_soc_ac97_free_gpio`.
- 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.