After the card is created, you can attach the components
(devices) to the card instance. On ALSA driver, a component is
represented as a struct snd_device object.
A component can be a PCM instance, a control interface, a raw
MIDI interface, etc. Each of such instances has one component
entry.
A component can be created via
snd_device_new() function.
This takes the card pointer, the device-level
(SNDRV_DEV_XXX), the data pointer, and the
callback pointers (&ops). The
device-level defines the type of components and the order of
registration and de-registration. For most of components, the
device-level is already defined. For a user-defined component,
you can use SNDRV_DEV_LOWLEVEL.
This function itself doesn't allocate the data space. The data
must be allocated manually beforehand, and its pointer is passed
as the argument. This pointer is used as the identifier
(chip in the above example) for the
instance.
Each ALSA pre-defined component such as ac97 or pcm calls
snd_device_new() inside its
constructor. The destructor for each component is defined in the
callback pointers. Hence, you don't need to take care of
calling a destructor for such a component.
If you would like to create your own component, you need to
set the destructor function to dev_free callback in
ops, so that it can be released
automatically via snd_card_free(). The
example will be shown later as an implementation of a
chip-specific data.