Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ALSA: doc: Recommend the use of snd_ctl_elem_info()

Instead of the open code for the info call back of enum elements,
recommend the use of snd_ctl_elem_info(), which will reduce lots of
codes.

Signed-off-by: Takashi Iwai <tiwai@suse.de>

+23
+23
Documentation/DocBook/writing-an-alsa-driver.tmpl
··· 3658 3658 </para> 3659 3659 3660 3660 <para> 3661 + The above callback can be simplified with a helper function, 3662 + <function>snd_ctl_enum_info</function>. The final code 3663 + looks like below. 3664 + (You can pass ARRAY_SIZE(texts) instead of 4 in the third 3665 + argument; it's a matter of taste.) 3666 + 3667 + <informalexample> 3668 + <programlisting> 3669 + <![CDATA[ 3670 + static int snd_myctl_enum_info(struct snd_kcontrol *kcontrol, 3671 + struct snd_ctl_elem_info *uinfo) 3672 + { 3673 + static char *texts[4] = { 3674 + "First", "Second", "Third", "Fourth" 3675 + }; 3676 + return snd_ctl_enum_info(uinfo, 1, 4, texts); 3677 + } 3678 + ]]> 3679 + </programlisting> 3680 + </informalexample> 3681 + </para> 3682 + 3683 + <para> 3661 3684 Some common info callbacks are available for your convenience: 3662 3685 <function>snd_ctl_boolean_mono_info()</function> and 3663 3686 <function>snd_ctl_boolean_stereo_info()</function>.