]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - Documentation/DocBook/writing-an-alsa-driver.tmpl
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target...
[karo-tx-linux.git] / Documentation / DocBook / writing-an-alsa-driver.tmpl
index 784793df81ed12933ebbb76682d8ec39597603d8..84ef6a90131c2ea44410f9f3c53f6b56a499bfe5 100644 (file)
@@ -3657,6 +3657,29 @@ struct _snd_pcm_runtime {
           </informalexample>
         </para>
 
+        <para>
+         The above callback can be simplified with a helper function,
+         <function>snd_ctl_enum_info</function>.  The final code
+         looks like below.
+         (You can pass ARRAY_SIZE(texts) instead of 4 in the third
+          argument; it's a matter of taste.)
+
+          <informalexample>
+            <programlisting>
+<![CDATA[
+  static int snd_myctl_enum_info(struct snd_kcontrol *kcontrol,
+                          struct snd_ctl_elem_info *uinfo)
+  {
+          static char *texts[4] = {
+                  "First", "Second", "Third", "Fourth"
+          };
+          return snd_ctl_enum_info(uinfo, 1, 4, texts);
+  }
+]]>
+            </programlisting>
+          </informalexample>
+        </para>
+
         <para>
          Some common info callbacks are available for your convenience:
        <function>snd_ctl_boolean_mono_info()</function> and