From nobody@FreeBSD.org  Tue Sep 26 19:42:37 2006
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id A7AF916A407
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 26 Sep 2006 19:42:37 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 6CD7E43D70
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 26 Sep 2006 19:42:37 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id k8QJgbSC014991
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 26 Sep 2006 19:42:37 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id k8QJgb9b014989;
	Tue, 26 Sep 2006 19:42:37 GMT
	(envelope-from nobody)
Message-Id: <200609261942.k8QJgb9b014989@www.freebsd.org>
Date: Tue, 26 Sep 2006 19:42:37 GMT
From: Ales Katona <almindor@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Driver snd_es137x has broken defaults for DAC settings
X-Send-Pr-Version: www-2.3

>Number:         103692
>Category:       kern
>Synopsis:       [snd_es137x] Driver snd_es137x has broken defaults for DAC settings
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-multimedia
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Sep 26 19:50:18 GMT 2006
>Closed-Date:    Fri Oct 06 17:50:31 GMT 2006
>Last-Modified:  Fri Oct 06 17:50:31 GMT 2006
>Originator:     Ales Katona
>Release:        6.2-BETA1
>Organization:
>Environment:
FreeBSD XERXES 6.2-BETA1 FreeBSD 6.2-BETA1 #0: Mon Sep 18 17:47:02 UTC 2006 root@opus.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386

>Description:
I have a snd_es137x.ko sound card (some SB PCI 128). When I first started to use this driver I experience "stuttering" on sound output (more or less constant). I googled for this problem and found a solution in setting the

hint.pcm.0.dac="0"

This would all be nice and nifty if the default value used by the snd_es137x.ko module was set to "0". I couldn't figure out why it was set to "2" (meaning "use only DAC2) so I looked into the sources of the module.

I found this:

/*
 * DAC 1/2 configuration through kernel hint - hint.pcm.<unit>.dac="val"
 *
 * 0 = Enable both DACs - Default
 * 1 = Enable single DAC (DAC1)
 * 2 = Enable single DAC (DAC2)
 * 3 = Enable both DACs, swap position (DAC2 comes first instead of DAC1)
 */
#define ES_DEFAULT_DAC_CFG	2

Notice it's using "2" but the comment reports "0" as default. Setting "0" also fixed my problem. I also noticed that there are 2 branches of this driver in CVS, one with "0" and one with "2" as default.

Is there any reason for this?

If so could you please add some sort of detection mechanism?

Using only DAC2 completly breaks sound output on my card.
>How-To-Repeat:
Try using a sound card which uses the snd_es137x driver
>Fix:
Change

#define ES_DEFAULT_DAC_CFG	2

to

#define ES_DEFAULT_DAC_CFG	0

in /usr/src/sys/dev/sound/pci/es137x.c
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-multimedia 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Tue Sep 26 21:19:00 UTC 2006 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=103692 

From: Ales Katona <ales@chello.sk>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/103692: [snd_es137x] Driver snd_es137x has broken
	defaults for DAC settings
Date: Thu, 28 Sep 2006 18:05:19 +0200

 I would like to add that on 6.1 the default DAC2 only (2) is valid. On
 6.2 however it produces stuttering. This is exactly reverted on 6.1.
 
 If set dat to 0 in 6.1 I get the stuttering and vice versa.
 
 Ales
 

From: Ariff Abdullah <ariff@FreeBSD.org>
To: bug-followup@FreeBSD.org, almindor@gmail.com
Cc:  
Subject: Re: kern/103692: [snd_es137x] Driver snd_es137x has broken defaults
 for DAC settings
Date: Fri, 29 Sep 2006 03:14:23 +0800

 The real issue is not with DAC selection. This is rather PCI Latency
 Timer issue, which is too flexible for snd_es137x. Try to increase its
 latency timer value for pcm0 (128 is a good start) using pciconf(8),
 or this tool:
 
    http://people.freebsd.org/~ariff/utils/pcilattimer
 
 There is a hidden kernel hint for this, that is
 hint.pcm.<dev>.latency_timer . Set appropriately using kenv(8) and
 reload the driver or through /boot/device.hints (require reboot).
 
 --
 Ariff Abdullah
 FreeBSD
 
 ... Recording in stereo is obviously too advanced
     and confusing for us idiot ***** users :P ........
State-Changed-From-To: open->closed 
State-Changed-By: ariff 
State-Changed-When: Fri Oct 6 17:49:54 UTC 2006 
State-Changed-Why:  
The submitter agrees that this is no longer an issue after 
raising the PCI latency timer value. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=103692 
>Unformatted:
