Re: azalia: save some power

2009-05-18 Thread Jacob Meuser
On Mon, May 18, 2009 at 10:50:15AM +0200, David Coppa wrote:
> On Tue, May 12, 2009 at 11:57 PM, Jacob Meuser 
> wrote:
> > here's a patch to power down unused widgets.  should be safe, but my
> > devices don't support this (about half of all azalia codecs support power
> > modes on the individual widgets) so please test that this doesn't somehow
> > break the ability to use your soundcard.
> 
> On my MSI Wind, audio works ok with this patch, but autosensing of
> headphones' plug does not work anymore.

thanks for testing.

I guess this patch is no good.  it wouldn't save much anyway, maybe
10 mA max.

-- 
jake...@sdf.lonestar.org
SDF Public Access UNIX System - http://sdf.lonestar.org



Re: azalia: save some power

2009-05-18 Thread David Coppa
On Tue, May 12, 2009 at 11:57 PM, Jacob Meuser 
wrote:
> here's a patch to power down unused widgets.  should be safe, but my
> devices don't support this (about half of all azalia codecs support power
> modes on the individual widgets) so please test that this doesn't somehow
> break the ability to use your soundcard.

On my MSI Wind, audio works ok with this patch, but autosensing of
headphones' plug does not work anymore.

cheers
david



Re: azalia: save some power

2009-05-14 Thread Dan Harnett
On Thu, May 14, 2009 at 04:10:02AM +, Jacob Meuser wrote:
> On Wed, May 13, 2009 at 07:02:32PM -0400, Dan Harnett wrote:
> > On Tue, May 12, 2009 at 09:57:33PM +, Jacob Meuser wrote:
> > > here's a patch to power down unused widgets.  should be safe, but my
> > > devices don't support this (about half of all azalia codecs support power
> > > modes on the individual widgets) so please test that this doesn't somehow
> > > break the ability to use your soundcard.
> > 
> > The sound on my ThinkPad X61s no longer seems to work with this patch.
> 
> there is nothing on either the speaker or the hp jack?

Correct.  I cannot hear any sound after the patch.  I was able to test
it on my ThinkPad T61 as well.  It does the same thing.  Sound stops
working after the patch.

=[ mixerctl -v ]=
outputs.dig-dac_source=hdaudio  [ hdaudio adc2 adc ]
inputs.dac=216,216 
inputs.dac2=216,216 
inputs.hp_source=sel6,sel5  { sel6 sel5 }
inputs.spkr_source=dac2,sel5  { dac2 sel5 }
record.adc2_source=mic2  [ mic mic2 ]
record.adc2_mute=off  [ off on ]
record.adc2=124,124 
record.adc_source=mic  [ mic mic2 ]
record.adc_mute=off  [ off on ]
record.adc=124,124 
inputs.sel3_source=dac  [ dac dac2 ]
inputs.sel4_source=dac  [ dac dac2 ]
inputs.beep_mute=off  [ off on ]
inputs.beep=119 
outputs.hp_mute=off  [ off on ]
outputs.hp_boost=off  [ off on ]
outputs.spkr_mute=off  [ off on ]
outputs.spkr_boost=off  [ off on ]
outputs.spkr_eapd=on  [ off on ]
inputs.mic=85,85 
outputs.mic_dir=input-vr80  [ none input input-vr0 input-vr50 input-vr80 
input-vr100 ]
inputs.mic2=85,85 
outputs.mic2_dir=input-vr80  [ none input input-vr0 input-vr50 input-vr80 
input-vr100 ]
outputs.SPDIF_source=dig-dac  [ dig-dac ]
outputs.SPDIF_mute=off  [ off on ]
outputs.SPDIF=126,126 
outputs.mic3_mute=off  [ off on ]
outputs.mic3_dir=input-vr80  [ none output input input-vr0 input-vr50 
input-vr80 input-vr100 ]
outputs.vendor_source=hp  [ hp spkr adc2 adc sel3 sel4 beep hp ]
inputs.mix4_source=sel3,sel5  { sel3 sel5 }
inputs.mix6_source=mic,mic2  { mic mic2 }
inputs.mix6_mic=120,120 
inputs.mix6_mic2=120,120 
inputs.sel5_source=mix6  [ mix6 ]
outputs.sel5_mute=off  [ off on ]
outputs.sel5=120,120 
inputs.sel6_source=dac  [ dac dac2 ]
inputs.sel7_source=dac  [ dac dac2 ]
inputs.mic3_source=sel7,sel5  { sel7 sel5 }
inputs.mic3=85,85 
outputs.vendor2_source=mic  [ mic mic2 mic3 ]
outputs.hp_sense=unplugged  [ unplugged plugged ]
outputs.mic_sense=unplugged  [ unplugged plugged ]
outputs.mic3_sense=unplugged  [ unplugged plugged ]
outputs.spkr_muters=hp,mic,mic3  { hp mic mic3 }
outputs.master=220,220 
outputs.master.mute=off  [ off on ]
outputs.master.slaves=dac,dac2,hp,spkr  { dac dac2 beep hp spkr SPDIF mic3 sel5 
mic3 }
record.volume=124,124 
record.volume.mute=off  [ off on ]
record.volume.slaves=adc2,adc  { adc2 adc mic mic2 }
inputs.usingdac=0304  [ 0304 02 ]

=[ GENERIC.MP w/ patch ]=
OpenBSD 4.5-current (GENERIC.MP) #4: Thu May 14 09:41:56 EDT 2009
d...@tyr.localdomain:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 2103115776 (2005MB)
avail mem = 2030034944 (1935MB)
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.4 @ 0xe0010 (73 entries)
bios0: vendor LENOVO version "7LETC4WW (2.24 )" date 08/15/2008
bios0: LENOVO 7658CTO
acpi0 at bios0: rev 2
acpi0: tables DSDT FACP SSDT ECDT TCPA APIC MCFG HPET SLIC BOOT ASF! SSDT SSDT 
SSDT SSDT
acpi0: wakeup devices LID_(S3) SLPB(S3) LURT(S3) DURT(S3) IGBE(S4) EXP0(S4) 
EXP1(S4) EXP2(S4) EXP3(S4) EXP4(S4) PCI1(S4) USB0(S3) USB1(S3) USB2(S3) 
USB3(S3) USB4(S3) EHC0(S3) EHC1(S3) HDEF(S4)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Core(TM)2 Duo CPU T8100 @ 2.10GHz, 2095.11 MHz
cpu0: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,SBF,SSE3,MWAIT,DS-CPL,VMX,EST,TM2,CX16,xTPR,NXE,LONG
cpu0: 3MB 64b/line 8-way L2 cache
cpu0: apic clock running at 199MHz
cpu1 at mainbus0: apid 1 (application processor)
cpu1: Intel(R) Core(TM)2 Duo CPU T8100 @ 2.10GHz, 2094.75 MHz
cpu1: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,SBF,SSE3,MWAIT,DS-CPL,VMX,EST,TM2,CX16,xTPR,NXE,LONG
cpu1: 3MB 64b/line 8-way L2 cache
ioapic0 at mainbus0 apid 1 pa 0xfec0, version 20, 24 pins
ioapic0: misconfigured as apic 2, remapped to apid 1
acpihpet0 at acpi0: 14318179 Hz
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus -1 (AGP_)
acpiprt2 at acpi0: bus 2 (EXP0)
acpiprt3 at acpi0: bus 3 (EXP1)
acpiprt4 at acpi0: bus 4 (EXP2)
acpiprt5 at acpi0: bus 5 (EXP3)
acpiprt6 at acpi0: bus 13 (EXP4)
acpiprt7 at acpi0: bus 21 (PCI1)
acpiec0 at acpi0
acpicpu0 at acpi0: C3, C2, C1, PSS
acpicpu1 at acpi0: C3, C2, C1, PSS
acpitz0 at acpi0: critical temperature 127 degC
acpitz1 at acpi0: critical temperature 100 degC
acpibtn0 at acpi0: LID_
acpibtn1 at acpi0: SLPB
acpibat0 at acpi0: BAT0 model "42

Re: azalia: save some power

2009-05-13 Thread Jacob Meuser
On Wed, May 13, 2009 at 07:02:32PM -0400, Dan Harnett wrote:
> On Tue, May 12, 2009 at 09:57:33PM +, Jacob Meuser wrote:
> > here's a patch to power down unused widgets.  should be safe, but my
> > devices don't support this (about half of all azalia codecs support power
> > modes on the individual widgets) so please test that this doesn't somehow
> > break the ability to use your soundcard.
> 
> The sound on my ThinkPad X61s no longer seems to work with this patch.

there is nothing on either the speaker or the hp jack?

-- 
jake...@sdf.lonestar.org
SDF Public Access UNIX System - http://sdf.lonestar.org



Re: azalia: save some power

2009-05-13 Thread Dan Harnett
On Tue, May 12, 2009 at 09:57:33PM +, Jacob Meuser wrote:
> here's a patch to power down unused widgets.  should be safe, but my
> devices don't support this (about half of all azalia codecs support power
> modes on the individual widgets) so please test that this doesn't somehow
> break the ability to use your soundcard.

The sound on my ThinkPad X61s no longer seems to work with this patch.

=[ mixerctl -v (same w/ and w/o patch) ]=
inputs.dac=186,186 
inputs.dac2=186,186 
inputs.hp_source=sel6,sel5  { sel6 sel5 }
inputs.spkr_source=dac2,sel5  { dac2 sel5 }
record.adc2_source=mic2  [ mic mic2 ]
record.adc2_mute=on  [ off on ]
record.adc2=124,124 
record.adc_source=mic  [ mic mic2 ]
record.adc_mute=on  [ off on ]
record.adc=124,124 
inputs.sel3_source=dac  [ dac dac2 ]
inputs.sel4_source=dac  [ dac dac2 ]
inputs.beep_mute=off  [ off on ]
inputs.beep=119 
outputs.hp_mute=off  [ off on ]
outputs.hp_boost=off  [ off on ]
outputs.spkr_mute=off  [ off on ]
outputs.spkr_boost=off  [ off on ]
outputs.spkr_eapd=on  [ off on ]
inputs.mic=85,85 
outputs.mic_dir=input-vr80  [ none input input-vr0 input-vr50 input-vr80 
input-vr100 ]
inputs.mic2=85,85 
outputs.mic2_dir=input-vr80  [ none input input-vr0 input-vr50 input-vr80 
input-vr100 ]
outputs.mic3_mute=on  [ off on ]
outputs.mic3_dir=input-vr80  [ none output input input-vr0 input-vr50 
input-vr80 input-vr100 ]
outputs.vendor_source=hp  [ hp spkr adc2 adc sel3 sel4 beep hp ]
inputs.mix4_source=sel3,sel5  { sel3 sel5 }
inputs.mix6_source=mic,mic2  { mic mic2 }
inputs.mix6_mic=120,120 
inputs.mix6_mic2=120,120 
inputs.sel5_source=mix6  [ mix6 ]
outputs.sel5_mute=on  [ off on ]
outputs.sel5=120,120 
inputs.sel6_source=dac  [ dac dac2 ]
inputs.sel7_source=dac  [ dac dac2 ]
inputs.mic3_source=sel7,sel5  { sel7 sel5 }
inputs.mic3=85,85 
outputs.vendor2_source=mic  [ mic mic2 mic3 ]
outputs.hp_sense=unplugged  [ unplugged plugged ]
outputs.mic_sense=unplugged  [ unplugged plugged ]
outputs.mic3_sense=unplugged  [ unplugged plugged ]
outputs.spkr_muters=hp,mic,mic3  { hp mic mic3 }
outputs.master=190,190 
outputs.master.mute=off  [ off on ]
outputs.master.slaves=dac,dac2,hp,spkr  { dac dac2 beep hp spkr mic3 sel5 mic3 }
record.volume=124,124 
record.volume.mute=on  [ off on ]
record.volume.slaves=adc2,adc  { adc2 adc mic mic2 }

=[ GENERIC.MP + patch + AZALIA_DEBUG ]=
OpenBSD 4.5-current (AZALIA.MP) #0: Wed May 13 18:54:27 EDT 2009
d...@ares.localdomain:/usr/src/sys/arch/amd64/compile/AZALIA.MP
real mem = 2119892992 (2021MB)
avail mem = 2046382080 (1951MB)
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.4 @ 0xe0010 (63 entries)
bios0: vendor LENOVO version "7NETB8WW (2.18 )" date 09/26/2008
bios0: LENOVO 7668CTO
acpi0 at bios0: rev 2
acpi0: tables DSDT FACP SSDT ECDT TCPA APIC MCFG HPET SLIC BOOT ASF! SSDT SSDT 
SSDT SSDT SSDT
acpi0: wakeup devices LID_(S3) SLPB(S3) DURT(S3) IGBE(S4) EXP0(S4) EXP1(S4) 
EXP2(S4) EXP3(S4) EXP4(S4) PCI1(S4) USB0(S3) USB1(S3) USB2(S3) USB3(S3) 
USB4(S3) EHC0(S3) EHC1(S3) HDEF(S4)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Core(TM)2 Duo CPU L7500 @ 1.60GHz, 1596.31 MHz
cpu0: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,SBF,SSE3,MWAIT,DS-CPL,VMX,EST,TM2,CX16,xTPR,NXE,LONG
cpu0: 4MB 64b/line 16-way L2 cache
cpu0: apic clock running at 199MHz
cpu1 at mainbus0: apid 1 (application processor)
cpu1: Intel(R) Core(TM)2 Duo CPU L7500 @ 1.60GHz, 1596.00 MHz
cpu1: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,SBF,SSE3,MWAIT,DS-CPL,VMX,EST,TM2,CX16,xTPR,NXE,LONG
cpu1: 4MB 64b/line 16-way L2 cache
ioapic0 at mainbus0 apid 1 pa 0xfec0, version 20, 24 pins
ioapic0: misconfigured as apic 2, remapped to apid 1
acpihpet0 at acpi0: 14318179 Hz
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus -1 (AGP_)
acpiprt2 at acpi0: bus 2 (EXP0)
acpiprt3 at acpi0: bus 3 (EXP1)
acpiprt4 at acpi0: bus -1 (EXP2)
acpiprt5 at acpi0: bus -1 (EXP3)
acpiprt6 at acpi0: bus -1 (EXP4)
acpiprt7 at acpi0: bus 5 (PCI1)
acpiec0 at acpi0
acpicpu0 at acpi0: C3, C2, C1, PSS
acpicpu1 at acpi0: C3, C2, C1, PSS
acpitz0 at acpi0: critical temperature 127 degC
acpitz1 at acpi0: critical temperature 99 degC
acpibtn0 at acpi0: LID_
acpibtn1 at acpi0: SLPB
acpibat0 at acpi0: BAT0 model "42T4631" serial  4147 type LION oem "SONY"
acpibat1 at acpi0: BAT1 not present
acpibat2 at acpi0: BAT2 not present
acpiac0 at acpi0: AC unit online
acpithinkpad0 at acpi0
acpidock at acpi0 not configured
acpivideo at acpi0 not configured
acpivideo at acpi0 not configured
cpu0: Enhanced SpeedStep 1596 MHz: speeds: 1601, 1600, 1200, 800 MHz
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 "Intel GM965 Host" rev 0x0c
vga1 at pci0 dev 2 function 0 "Intel GM965 Video" rev 0x0c
wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
wsdi

Re: azalia: save some power

2009-05-13 Thread Thomas Pfaff
On Tue, 12 May 2009 21:57:33 +
Jacob Meuser  wrote:

> here's a patch to power down unused widgets.  should be safe, but my
> devices don't support this (about half of all azalia codecs support power
> modes on the individual widgets) so please test that this doesn't somehow
> break the ability to use your soundcard.

Works fine for me on my workstation [1] and on my MSI Wind [2].

[1]
OpenBSD 4.5-current (GENERIC.MP) #17: Wed May 13 18:36:31 CEST 2009
tpf...@ws.tp76.info:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 3152609280 (3006MB)
avail mem = 3045064704 (2904MB)
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.4 @ 0xf06b0 (76 entries)
bios0: vendor American Megatrends Inc. version "1704" date 11/27/2007
bios0: ASUSTeK Computer INC. P5B-E
acpi0 at bios0: rev 2
acpi0: tables DSDT FACP APIC MCFG OEMB HPET
acpi0: wakeup devices P0P2(S4) P0P1(S4) UAR1(S4) PS2K(S4) PS2M(S4) EUSB(S4) 
USBE(S4) P0P4(S4) P0P5(S4) P0P6(S4) P0P7(S4) P0P8(S4) P0P9(S4) USB0(S4) 
USB1(S4) USB2(S4) USB3(S4) USB4(S4) USB5(S4)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Core(TM)2 CPU 6400 @ 2.13GHz, 2135.35 MHz
cpu0: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,SBF,SSE3,MWAIT,DS-CPL,VMX,EST,TM2,CX16,xTPR,NXE,LONG
cpu0: 2MB 64b/line 8-way L2 cache
cpu0: apic clock running at 266MHz
cpu1 at mainbus0: apid 1 (application processor)
cpu1: Intel(R) Core(TM)2 CPU 6400 @ 2.13GHz, 2135.04 MHz
cpu1: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,SBF,SSE3,MWAIT,DS-CPL,VMX,EST,TM2,CX16,xTPR,NXE,LONG
cpu1: 2MB 64b/line 8-way L2 cache
ioapic0 at mainbus0 apid 2 pa 0xfec0, version 20, 24 pins
acpihpet0 at acpi0: 14318179 Hz
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus 1 (P0P2)
acpiprt2 at acpi0: bus 5 (P0P1)
acpiprt3 at acpi0: bus 4 (P0P4)
acpiprt4 at acpi0: bus -1 (P0P5)
acpiprt5 at acpi0: bus -1 (P0P6)
acpiprt6 at acpi0: bus 3 (P0P7)
acpiprt7 at acpi0: bus 2 (P0P8)
acpicpu0 at acpi0
acpicpu1 at acpi0
acpibtn0 at acpi0: PWRB
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 "Intel 82G965 Host" rev 0x02
ppb0 at pci0 dev 1 function 0 "Intel 82G965 PCIE" rev 0x02: apic 2 int 16 (irq 
11)
pci1 at ppb0 bus 1
vga1 at pci1 dev 0 function 0 "NVIDIA GeForce 7600 GT" rev 0xa1
wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
uhci0 at pci0 dev 26 function 0 "Intel 82801H USB" rev 0x02: apic 2 int 16 (irq 
11)
uhci1 at pci0 dev 26 function 1 "Intel 82801H USB" rev 0x02: apic 2 int 17 (irq 
5)
ehci0 at pci0 dev 26 function 7 "Intel 82801H USB" rev 0x02: apic 2 int 18 (irq 
15)
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 "Intel EHCI root hub" rev 2.00/1.00 addr 1
azalia0 at pci0 dev 27 function 0 "Intel 82801H HD Audio" rev 0x02: apic 2 int 
22 (irq 3)
azalia0: codecs: Analog Devices AD1988A
audio0 at azalia0
ppb1 at pci0 dev 28 function 0 "Intel 82801H PCIE" rev 0x02: apic 2 int 16 (irq 
11)
pci2 at ppb1 bus 4
ppb2 at pci0 dev 28 function 3 "Intel 82801H PCIE" rev 0x02: apic 2 int 19 (irq 
10)
pci3 at ppb2 bus 3
age0 at pci3 dev 0 function 0 "Attansic Technology L1" rev 0xb0: apic 2 int 19 
(irq 10), address 00:18:f3:9d:7d:04
atphy0 at age0 phy 0: F1 10/100/1000 PHY, rev. 5
ppb3 at pci0 dev 28 function 4 "Intel 82801H PCIE" rev 0x02: apic 2 int 16 (irq 
11)
pci4 at ppb3 bus 2
jmb0 at pci4 dev 0 function 0 "JMicron JMB363 IDE/SATA" rev 0x02
ahci0 at jmb0: apic 2 int 16 (irq 11), AHCI 1.0
scsibus0 at ahci0: 32 targets
pciide0 at jmb0: DMA, channel 0 wired to native-PCI, channel 1 wired to 
native-PCI
pciide0: using apic 2 int 16 (irq 11) for native-PCI interrupt
atapiscsi0 at pciide0 channel 0 drive 0
scsibus1 at atapiscsi0: 2 targets
cd0 at scsibus1 targ 0 lun 0:  ATAPI 5/cdrom 
removable
cd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 2
pciide0: channel 1 disabled (no drives)
uhci2 at pci0 dev 29 function 0 "Intel 82801H USB" rev 0x02: apic 2 int 23 (irq 
7)
uhci3 at pci0 dev 29 function 1 "Intel 82801H USB" rev 0x02: apic 2 int 19 (irq 
10)
uhci4 at pci0 dev 29 function 2 "Intel 82801H USB" rev 0x02: apic 2 int 18 (irq 
15)
ehci1 at pci0 dev 29 function 7 "Intel 82801H USB" rev 0x02: apic 2 int 23 (irq 
7)
usb1 at ehci1: USB revision 2.0
uhub1 at usb1 "Intel EHCI root hub" rev 2.00/1.00 addr 1
ppb4 at pci0 dev 30 function 0 "Intel 82801BA Hub-to-PCI" rev 0xf2
pci5 at ppb4 bus 5
puc0 at pci5 dev 1 function 0 "NetMos Nm9835" rev 0x01: ports: 1 com
com2 at puc0 port 0 apic 2 int 22 (irq 3): ns16550a, 16 byte fifo
re0 at pci5 dev 2 function 0 "D-Link Systems DGE-528T" rev 0x10: RTL8169/8110SB 
(0x1000), apic 2 int 23 (irq 7), address 00:21:91:12:15:03
rgephy0 at re0 phy 7: RTL8169S/8110S PHY, rev. 3
pcib0 at pci0 dev 31 function 0 "Intel 82801H LPC" rev 0x02
pciide1 at pci0 dev 31 function 2 "Intel 82801H SATA" rev 0x02: D

azalia: save some power

2009-05-12 Thread Jacob Meuser
here's a patch to power down unused widgets.  should be safe, but my
devices don't support this (about half of all azalia codecs support power
modes on the individual widgets) so please test that this doesn't somehow
break the ability to use your soundcard.

-- 
jake...@sdf.lonestar.org
SDF Public Access UNIX System - http://sdf.lonestar.org

Index: azalia.c
===
RCS file: /cvs/src/sys/dev/pci/azalia.c,v
retrieving revision 1.131
diff -u azalia.c
--- azalia.c12 May 2009 09:32:28 -  1.131
+++ azalia.c12 May 2009 21:52:18 -
@@ -214,6 +214,7 @@
 intazalia_codec_select_micadc(codec_t *);
 intazalia_codec_select_spkrdac(codec_t *);
 intazalia_codec_find_inputmixer(codec_t *);
+intazalia_codec_pd_disabled(codec_t *);
 
 intazalia_widget_init(widget_t *, const codec_t *, int);
 intazalia_widget_label_widgets(codec_t *);
@@ -1391,6 +1392,10 @@
if (err)
return err;
 
+   err = azalia_codec_pd_disabled(this);
+   if (err)
+   return err;
+
return 0;
 }
 
@@ -2054,6 +2059,46 @@
 
return 0;
 }
+
+int
+azalia_codec_pd_disabled(codec_t *this)
+{
+   uint32_t result, state;
+   int nid, err;
+
+   FOR_EACH_WIDGET(this, nid) {
+   /* never power down a power widget */
+   if (this->w[nid].type == COP_AWTYPE_POWER)
+   continue;
+   if (this->w[nid].enable)
+   continue;
+   if (!(this->w[nid].widgetcap & COP_AWCAP_POWER))
+   continue;
+   err = this->comresp(this, nid, CORB_GET_PARAMETER,
+   COP_SUPPORTED_POWER_STATES, &result);
+   if (err)
+   continue;
+   state = CORB_PS_D3;
+   if (!(result & (1 << state))) {
+   state = CORB_PS_D2;
+   if (!(result & (1 << state))) {
+   state = CORB_PS_D1;
+   if (!(result & (1 << state))) {
+   continue;
+   }
+   }
+   }
+   err = this->comresp(this, nid, CORB_SET_POWER_STATE,
+   state, &result);
+   if (err) {
+   DPRINTF(("%s: error powering down 0x%2.2x\n",
+   XNAME(this->az), nid));
+   continue;
+   }
+   }
+   return(0);
+}
+
 
 int
 azalia_codec_delete(codec_t *this)