Constructor

When everything is ready, finally we can create a new control. To create a control, there are two functions to be called, snd_ctl_new1() and snd_ctl_add().

In the simplest way, you can do like this:


  err = snd_ctl_add(card, snd_ctl_new1(&my_control, chip));
  if (err < 0)
          return err;

          

where my_control is the struct snd_kcontrol_new object defined above, and chip is the object pointer to be passed to kcontrol->private_data which can be referred to in callbacks.

snd_ctl_new1() allocates a new snd_kcontrol instance (that's why the definition of my_control can be with the __devinitdata prefix), and snd_ctl_add assigns the given control component to the card.