[alsa-devel] snd-usb-audio: minimum period time as module option?

Klaus Schulz kls.schlz at googlemail.com
Tue Nov 25 14:59:44 CET 2008


Hi there.

I wrote a small  patch which introduces an usb-audio module option called
uperiod.

Changing to lower values will improve sound quality in some cases.

Please comment.

THX
Klaus




--- alsa-driver-1.0.18a/sound/usb/usbaudio.c.orig    2008-11-21
19:19:11.000000000 +0100
+++ alsa-driver-1.0.18a/sound/usb/usbaudio.c    2008-11-24
13:40:12.000000000 +0100
@@ -72,6 +72,7 @@ static int nrpacks = 8;        /* max. number
 static int async_unlink = 1;
 static int device_setup[SNDRV_CARDS]; /* device parameter for this card*/
 static int ignore_ctl_error;
+static int uperiod = 125;

 module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for the USB audio adapter.");
@@ -92,6 +93,8 @@ MODULE_PARM_DESC(device_setup, "Specific
 module_param(ignore_ctl_error, bool, 0444);
 MODULE_PARM_DESC(ignore_ctl_error,
          "Ignore errors from USB controller for mixer interfaces.");
+module_param(uperiod, int, 0644);
+MODULE_PARM_DESC(uperiod, "Max. size of period per URB.");

 /*
  * debug the h/w constraints
@@ -108,6 +111,8 @@ MODULE_PARM_DESC(ignore_ctl_error,
 #define MAX_URBS    8
 #define SYNC_URBS    4    /* always four urbs for sync */
 #define MIN_PACKS_URB    1    /* minimum 1 packet per urb */
+#define MAX_UPERIOD    1000
+#define MIN_UPERIOD    64

 struct audioformat {
     struct list_head list;
@@ -1919,7 +1924,7 @@ static int setup_hw_info(struct snd_pcm_
      * in the current code assume the 1ms period.
      */
     snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_TIME,
-                     1000 * MIN_PACKS_URB,
+                     uperiod * MIN_PACKS_URB,
                      /*(nrpacks * MAX_URBS) * 1000*/ UINT_MAX);

     err = check_hw_params_convention(subs);
@@ -3767,6 +3772,11 @@ static int __init snd_usb_audio_init(voi
         printk(KERN_WARNING "invalid nrpacks value.\n");
         return -EINVAL;
     }
+
+        if (uperiod < MIN_UPERIOD || uperiod > MAX_UPERIOD) {
+        printk(KERN_WARNING "invalid uperiod value.\n");
+        return -EINVAL;
+    }
     return usb_register(&usb_audio_driver);
 }


More information about the Alsa-devel mailing list