#
# Default ALSA volume levels and setting when initialization database fails.
#
# Basic rules are:
#  - keep volumes at minimal level, but sound should be hearable
#  - enable just main speakers for playback and main microphone for recording
#

# **************************************************************************
# playback
# **************************************************************************

ENV{ppercent}:="75%"
ENV{cpercent}:="75%"
ENV{pvolume}:="-20dB"
ENV{cvolume}:="12dB"
ENV{has_pmaster_vol}:="false"

CTL{reset}="mixer"
CTL{name}="Playback Volume",CTL{do_search}=="1", \
  CTL{write}!="$env{pvolume}",CTL{values}="$env{ppercent}"
CTL{name}="Playback Switch",CTL{do_search}=="1", \
  CTL{values}="on"

CTL{reset}="mixer"
CTL{name}="Master Playback Volume",CTL{do_search}=="1", \
  ENV{has_pmaster_vol}:="true", \
  CTL{write}!="$env{pvolume}",CTL{values}="$env{ppercent}"
CTL{name}="Master Playback Switch",CTL{do_search}=="1", \
  CTL{values}="on"

CTL{reset}="mixer"
CTL{name}="Master Front Playback Volume",CTL{do_search}=="1", \
  ENV{has_pmaster_vol}:="true", \
  CTL{write}!="$env{pvolume}",CTL{values}="$env{ppercent}"
CTL{name}="Master Front Playback Switch",CTL{do_search}=="1", \
  CTL{values}="on"

CTL{reset}="mixer"
CTL{name}="Master Digital Playback Volume",CTL{do_search}=="1", \
  CTL{write}!="$env{pvolume}",CTL{values}="$env{ppercent}"
CTL{name}="Master Digital Playback Switch",CTL{do_search}=="1", \
  CTL{values}="on"

CTL{reset}="mixer"
CTL{name}="Front Playback Volume",PROGRAM!="__ctl_search",GOTO=""
# if master volume control is present, turn front volume to max
ENV{has_pmaster_vol}=="true",CTL{write}=="0dB",GOTO=""
ENV{has_pmaster_vol}=="true",CTL{write}=="100%",GOTO=""
CTL{write}!="$env{pvolume}",CTL{values}="$env{ppercent}"
LABEL=""
CTL{name}="Front Playback Switch",CTL{do_search}=="1", \
  CTL{values}="on"

CTL{reset}="mixer"
CTL{name}="Surround Playback Volume",PROGRAM!="__ctl_search",GOTO=""
# if master volume control is present, turn front volume to max
ENV{has_pmaster_vol}=="true",CTL{write}=="0dB",GOTO=""
ENV{has_pmaster_vol}=="true",CTL{write}=="100%",GOTO=""
CTL{write}!="$env{pvolume}",CTL{values}="$env{ppercent}"
LABEL=""
CTL{name}="Surround Playback Switch",CTL{do_search}=="1", \
  CTL{values}="on"

CTL{reset}="mixer"
CTL{name}="Center Playback Volume",PROGRAM!="__ctl_search",GOTO=""
# if master volume control is present, turn front volume to max
ENV{has_pmaster_vol}=="true",CTL{write}=="0dB",GOTO=""
ENV{has_pmaster_vol}=="true",CTL{write}=="100%",GOTO=""
CTL{write}!="$env{pvolume}",CTL{values}="$env{ppercent}"
LABEL=""
CTL{name}="Center Playback Switch",CTL{do_search}=="1", \
  CTL{values}="on"

CTL{reset}="mixer"
CTL{name}="LFE Playback Volume",PROGRAM!="__ctl_search",GOTO=""
# if master volume control is present, turn front volume to max
ENV{has_pmaster_vol}=="true",CTL{write}=="0dB",GOTO=""
ENV{has_pmaster_vol}=="true",CTL{write}=="100%",GOTO=""
CTL{write}!="$env{pvolume}",CTL{values}="$env{ppercent}"
LABEL=""
CTL{name}="LFE Playback Switch",CTL{do_search}=="1", \
  CTL{values}="on"

CTL{reset}="mixer"
CTL{name}="Headphone Playback Volume",PROGRAM!="__ctl_search",GOTO=""
# if master volume control is present, turn headphone volume to max
ENV{has_pmaster_vol}=="true",CTL{write}=="0dB",GOTO=""
ENV{has_pmaster_vol}=="true",CTL{write}=="100%",GOTO=""
CTL{write}!="$env{pvolume}",CTL{values}="$env{ppercent}"
LABEL=""
CTL{name}="Headphone Playback Switch",CTL{do_search}=="1", \
  CTL{values}="on"

CTL{reset}="mixer"
CTL{name}="Headphone Playback Volume",CTL{index}="1",PROGRAM!="__ctl_search",\
  GOTO=""
# if master volume control is present, turn headphone volume to max
ENV{has_pmaster_vol}=="true",CTL{write}=="0dB",GOTO=""
ENV{has_pmaster_vol}=="true",CTL{write}=="100%",GOTO=""
CTL{write}!="$env{pvolume}",CTL{values}="$env{ppercent}"
LABEL=""
CTL{name}="Headphone Playback Switch",CTL{index}="1",CTL{do_search}=="1", \
  CTL{values}="on"

CTL{reset}="mixer"
CTL{name}="Speaker Playback Volume",PROGRAM!="__ctl_search",GOTO=""
# if master volume control is present, turn speaker volume to max
ENV{has_pmaster_vol}=="true",CTL{write}=="0dB",GOTO=""
ENV{has_pmaster_vol}=="true",CTL{write}=="100%",GOTO=""
CTL{write}!="$env{pvolume}",CTL{values}="$env{ppercent}"
LABEL=""
CTL{name}="Speaker Playback Switch",CTL{do_search}=="1", \
  CTL{values}="on"

CTL{reset}="mixer"
CTL{name}="Front Speaker Playback Volume",PROGRAM!="__ctl_search",GOTO=""
# if master volume control is present, turn speaker volume to max
ENV{has_pmaster_vol}=="true",CTL{write}=="0dB",GOTO=""
ENV{has_pmaster_vol}=="true",CTL{write}=="100%",GOTO=""
CTL{write}!="$env{pvolume}",CTL{values}="$env{ppercent}"
LABEL=""
CTL{name}="Front Speaker Playback Switch",CTL{do_search}=="1", \
  CTL{values}="on"

CTL{reset}="mixer"
CTL{name}="Surround Speaker Playback Volume",PROGRAM!="__ctl_search",GOTO=""
# if master volume control is present, turn speaker volume to max
ENV{has_pmaster_vol}=="true",CTL{write}=="0dB",GOTO=""
ENV{has_pmaster_vol}=="true",CTL{write}=="100%",GOTO=""
CTL{write}!="$env{pvolume}",CTL{values}="$env{ppercent}"
LABEL=""
CTL{name}="Surround Speaker Playback Switch",CTL{do_search}=="1", \
  CTL{values}="on"

CTL{reset}="mixer"
CTL{name}="Center Speaker Playback Volume",PROGRAM!="__ctl_search",GOTO=""
# if master volume control is present, turn speaker volume to max
ENV{has_pmaster_vol}=="true",CTL{write}=="0dB",GOTO=""
ENV{has_pmaster_vol}=="true",CTL{write}=="100%",GOTO=""
CTL{write}!="$env{pvolume}",CTL{values}="$env{ppercent}"
LABEL=""
CTL{name}="Center Speaker Playback Switch",CTL{do_search}=="1", \
  CTL{values}="on"

CTL{reset}="mixer"
CTL{name}="LFE Speaker Playback Volume",PROGRAM!="__ctl_search",GOTO=""
# if master volume control is present, turn speaker volume to max
ENV{has_pmaster_vol}=="true",CTL{write}=="0dB",GOTO=""
ENV{has_pmaster_vol}=="true",CTL{write}=="100%",GOTO=""
CTL{write}!="$env{pvolume}",CTL{values}="$env{ppercent}"
LABEL=""
CTL{name}="LFE Speaker Playback Switch",CTL{do_search}=="1", \
  CTL{values}="on"

CTL{reset}="mixer"
CTL{name}="PC Speaker Playback Volume",CTL{do_search}=="1", \
  CTL{values}="$env{pvolume}",RESULT!="0",CTL{values}="$env{ppercent}"
CTL{name}="PC Speaker Playback Switch",CTL{do_search}=="1", \
  CTL{values}="on"

CTL{reset}="mixer"
CTL{name}="PCM Playback Volume",PROGRAM!="__ctl_search", \
 CTL{name}="PCM Volume",PROGRAM!="__ctl_search", GOTO=""
# if master volume control is present, turn PCM volume to max
ENV{has_pmaster_vol}=="true",CTL{write}=="0dB",GOTO=""
ENV{has_pmaster_vol}=="true",CTL{write}=="100%",GOTO=""
# exception - some HDA codecs have shifted dB range
CTL{dBmin}=="-34.50dB",CTL{dBmax}=="12.00dB",CTL{write}=="0dB",GOTO=""
CTL{dBmin}=="-30.00dB",CTL{dBmax}=="0dB",CTL{write}=="0dB",GOTO=""
CTL{write}!="$env{pvolume}",CTL{values}="75%"
LABEL=""
CTL{name}="PCM Playback Switch",CTL{do_search}=="1", CTL{values}="on"
CTL{name}="PCM Switch",CTL{do_search}=="1",CTL{values}="on"

CTL{reset}="mixer"
CTL{name}="PCM Playback Volume",CTL{index}="1",PROGRAM!="__ctl_search", \
  CTL{name}="PCM Volume",PROGRAM!="__ctl_search",GOTO=""
# if master volume control is present, turn PCM volume to max
ENV{has_pmaster_vol}=="true",CTL{write}=="0dB",GOTO=""
ENV{has_pmaster_vol}=="true",CTL{write}=="100%",GOTO=""
# exception - some HDA codecs have shifted dB range
CTL{dBmin}=="-34.50dB",CTL{dBmax}=="12.00dB",CTL{write}=="0dB",GOTO=""
CTL{dBmin}=="-30.00dB",CTL{dBmax}=="0dB",CTL{write}=="0dB",GOTO=""
CTL{write}!="$env{pvolume}",CTL{values}="75%"
LABEL=""
CTL{name}="PCM Playback Switch",CTL{index}="1",CTL{do_search}=="1", \
  CTL{values}="on"
CTL{name}="PCM Switch",CTL{index}="1",CTL{do_search}=="1", \
  CTL{values}="on"

CTL{reset}="mixer"
CTL{name}="DAC Playback Volume",CTL{do_search}=="1", \
  CTL{values}="$env{pvolume}",RESULT!="0",CTL{values}="$env{ppercent}"
CTL{name}="DAC Playback Switch",CTL{do_search}=="1", \
  CTL{values}="on"

CTL{reset}="mixer"
CTL{name}="Synth Playback Volume",CTL{do_search}=="1", \
  CTL{values}="$env{pvolume}",RESULT!="0",CTL{values}="$env{ppercent}"
CTL{name}="Synth Playback Switch",CTL{do_search}=="1", \
  CTL{values}="on"

CTL{reset}="mixer"
CTL{name}="Wave Playback Volume",CTL{do_search}=="1", \
  CTL{values}="100%"
CTL{name}="Wave Playback Switch",CTL{do_search}=="1", \
  CTL{values}="on"

CTL{reset}="mixer"
CTL{name}="Music Playback Volume",CTL{do_search}=="1", \
  CTL{values}="100%"
CTL{name}="Music Playback Switch",CTL{do_search}=="1", \
  CTL{values}="on"

CTL{reset}="mixer"
CTL{name}="CD Playback Volume",CTL{do_search}=="1", \
  CTL{values}="0%"
CTL{name}="CD Playback Switch",CTL{do_search}=="1", \
  CTL{values}="off"

CTL{reset}="mixer"
CTL{name}="Mono Playback Volume",CTL{do_search}=="1", \
  CTL{values}="$env{pvolume}",RESULT!="0",CTL{values}="$env{ppercent}"
CTL{name}="Mono Playback Switch",CTL{do_search}=="1", \
  CTL{values}="on"

CTL{reset}="mixer"
CTL{name}="Master Mono Playback Volume",CTL{do_search}=="1", \
  CTL{values}="$env{pvolume}",RESULT!="0",CTL{values}="$env{ppercent}"
CTL{name}="Master Mono Playback Switch",CTL{do_search}=="1", \
  CTL{values}="on"

CTL{reset}="mixer"
CTL{name}="AC97 Playback Volume",CTL{do_search}=="1", \
  CTL{values}="100%"
CTL{name}="AC97 Playback Switch",CTL{do_search}=="1", \
  CTL{values}="on"

#
# Powermacs
#

CTL{reset}="mixer"
CTL{name}="DRC Range",CTL{do_search}=="1", \
  CTL{write}!="$env{pvolume}",CTL{values}="$env{ppercent}"

# **************************************************************************
# capture
# **************************************************************************

CTL{reset}="mixer"
CTL{name}="Capture Volume",CTL{do_search}=="1", \
  CTL{write}!="$env{cvolume}",CTL{values}="$env{cpercent}"
CTL{name}="Capture Switch",CTL{do_search}=="1", \
  CTL{values}="on"

CTL{name}="Capture Source",PROGRAM!="__ctl_search", GOTO=""
CTL{enums}=="*|Internal Mic|*",CTL{values}="Internal Mic", GOTO=""
CTL{enums}=="*|Mic|*",CTL{values}="Mic"
LABEL=""

CTL{name}="Input Source",PROGRAM!="__ctl_search", GOTO=""
CTL{enums}=="*|Internal Mic|*",CTL{values}="Internal Mic", GOTO=""
CTL{enums}=="*|Mic|*",CTL{values}="Mic"
LABEL=""

CTL{name}="Digital Input Source",PROGRAM!="__ctl_search", GOTO=""
CTL{enums}=="*|Digital Mic 1|*",CTL{values}="Digital Mic 1", GOTO=""
CTL{enums}=="*|Mic|*",CTL{values}="Mic"
LABEL=""

CTL{name}="Mic Boost",CTL{do_search}=="1", CTL{values}="on"
CTL{name}="Internal Mic Boost",CTL{do_search}=="1", CTL{values}="on"
