snd_card_new(9)
π snd_card_new(9) β Kernel API Manual π
okay bestie, welcome to the Kernel API Manual, and today's main character is snd_card_new(9) π
like literally the function that brings a soundcard into existence. no cap, it's giving creation energy.
β¨ NAME β¨
snd_card_new β create and initialize a soundcard structure π«Ά
πΈ SYNOPSIS πΈ
int snd_card_new (struct device *parent , int idx , const char *xid ,
struct module *module , int extra_size , struct snd_card **card_ret );
like, that's the whole vibe. six args, one soundcard, zero regrets β¨
π¦ ARGUMENTS π¦
parentβ the parent device object, aka who's your daddy device πidxβ the card index (address), and the range is literally[0 ... (SNDRV_CARDS-1)], don't push it π«xidβ the card identification, and it's an ASCII string bestie, keep it simple πmoduleβ the top level module, for locking πextra_sizeβ allocate this extra size after the main soundcard structure, so your driver has room to be free and do its thing πcard_retβ the pointer to store the created card instance, that's where the baby goes πΌ
π DESCRIPTION π
so the function allocates the snd_card instance via kzalloc with the given space for the driver to use freely β yes, freely, it's your playground π and the allocated struct is stored in the given card_ret pointer. iconic behaviour, honestly.
π₯ RETURN π₯
Zero if successful, or a negative error code π so like, check it. fr fr.
π SEE ALSO π
Kernel file ./sound/core/init.c and the whole friend group:
snd_device_alloc(9)snd_devm_card_new(9)snd_card_free_on_error(9)snd_card_ref(9)snd_card_disconnect(9)snd_card_disconnect_sync(9)snd_card_free_when_closed(9)snd_card_free(9)snd_card_set_id(9)snd_card_add_dev_attr(9)snd_card_register(9)snd_component_add(9)snd_card_file_add(9)snd_card_file_remove(9)snd_power_ref_and_wait(9)snd_power_wait(9)
ngl bestie, that's a lot of SEE ALSOs, but you got this πͺ go read 'em, iykyk.
okay that's the page!! this one's from ./sound/core, dated October 2026, and it's literally snd_card_new(9) β mwah, slay, go make some soundcards π
πβ¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms