Limit total playback channels to just 1, for ALi M5451. The reliability
authorHasso Tepper <hasso@dragonflybsd.org>
Fri, 30 Nov 2007 08:03:17 +0000 (08:03 +0000)
committerHasso Tepper <hasso@dragonflybsd.org>
Fri, 30 Nov 2007 08:03:17 +0000 (08:03 +0000)
of it's multi DAC / playback channels is not that good. Enabling vchans
make the bug more visible since playback allocation will look for possible
free hardware channels first (i.e: the next DAC, the very first has been
consumed by vchan mixer) which in this case has been proven faulty.

Obtained-from: FreeBSD

sys/dev/sound/pci/t4dwave.c

index bd47139..f830eaf 100644 (file)
@@ -23,8 +23,8 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THEPOSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/dev/sound/pci/t4dwave.c,v 1.48 2005/03/01 08:58:05 imp Exp $
- * $DragonFly: src/sys/dev/sound/pci/t4dwave.c,v 1.10 2007/06/16 20:07:19 dillon Exp $
+ * $FreeBSD: src/sys/dev/sound/pci/t4dwave.c,v 1.48.2.1 2007/11/15 16:59:54 ariff Exp $
+ * $DragonFly: src/sys/dev/sound/pci/t4dwave.c,v 1.11 2007/11/30 08:03:17 hasso Exp $
  */
 
 #include <dev/sound/pcm/sound.h>
@@ -34,7 +34,7 @@
 #include <bus/pci/pcireg.h>
 #include <bus/pci/pcivar.h>
 
-SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/t4dwave.c,v 1.10 2007/06/16 20:07:19 dillon Exp $");
+SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/t4dwave.c,v 1.11 2007/11/30 08:03:17 hasso Exp $");
 
 /* -------------------------------------------------------------------- */
 
@@ -814,7 +814,7 @@ tr_pci_attach(device_t dev)
        u_int32_t       data;
        struct tr_info *tr;
        struct ac97_info *codec = 0;
-       int             i;
+       int             i, dacn;
        char            status[SND_STATUSLEN];
 
        if ((tr = kmalloc(sizeof(*tr), M_DEVBUF, M_NOWAIT | M_ZERO)) == NULL) {
@@ -826,6 +826,25 @@ tr_pci_attach(device_t dev)
        tr->rev = pci_get_revid(dev);
        tr->lock = snd_mtxcreate(device_get_nameunit(dev), "sound softc");
 
+       if (resource_int_value(device_get_name(dev), device_get_unit(dev),
+           "dac", &i) == 0) {
+               if (i < 1)
+                       dacn = 1;
+               else if (i > TR_MAXPLAYCH)
+                       dacn = TR_MAXPLAYCH;
+               else
+                       dacn = i;
+       } else {
+               switch (tr->type) {
+               case ALI_PCI_ID:
+                       dacn = 1;
+                       break;
+               default:
+                       dacn = TR_MAXPLAYCH;
+                       break;
+               }
+       }
+
        data = pci_read_config(dev, PCIR_COMMAND, 2);
        data |= (PCIM_CMD_PORTEN|PCIM_CMD_MEMEN|PCIM_CMD_BUSMASTEREN);
        pci_write_config(dev, PCIR_COMMAND, data, 2);
@@ -877,9 +896,10 @@ tr_pci_attach(device_t dev)
        ksnprintf(status, 64, "at io 0x%lx irq %ld %s",
                 rman_get_start(tr->reg), rman_get_start(tr->irq),PCM_KLDSTRING(snd_t4dwave));
 
-       if (pcm_register(dev, tr, TR_MAXPLAYCH, 1)) goto bad;
+       if (pcm_register(dev, tr, dacn, 1))
+               goto bad;
        pcm_addchan(dev, PCMDIR_REC, &trrchan_class, tr);
-       for (i = 0; i < TR_MAXPLAYCH; i++)
+       for (i = 0; i < dacn; i++)
                pcm_addchan(dev, PCMDIR_PLAY, &trpchan_class, tr);
        pcm_setstatus(dev, status);