Chapter 3. Management of Cards and Components

Table of Contents

Card Instance
Components
Chip-Specific Data
1. Allocating via snd_card_new().
2. Allocating an extra device.
Registration and Release

Card Instance

For each soundcard, a card record must be allocated.

A card record is the headquarters of the soundcard. It manages the whole list of devices (components) on the soundcard, such as PCM, mixers, MIDI, synthesizer, and so on. Also, the card record holds the ID and the name strings of the card, manages the root of proc files, and controls the power-management states and hotplug disconnections. The component list on the card record is used to manage the correct release of resources at destruction.

As mentioned above, to create a card instance, call snd_card_new().


  struct snd_card *card;
  int err;
  err = snd_card_new(&pci->dev, index, id, module, extra_size, &card);

          

The function takes six arguments: the parent device pointer, the card-index number, the id string, the module pointer (usually THIS_MODULE), the size of extra-data space, and the pointer to return the card instance. The extra_size argument is used to allocate card->private_data for the chip-specific data. Note that these data are allocated by snd_card_new().

The first argument, the pointer of struct device, specifies the parent device. For PCI devices, typically &pci-> is passed there.