]> git.karo-electronics.de Git - karo-tx-linux.git/log
karo-tx-linux.git
11 years agoALSA: hda - force different capture controls if amp caps differ
David Henningsson [Wed, 16 Jan 2013 14:58:44 +0000 (15:58 +0100)]
ALSA: hda - force different capture controls if amp caps differ

Otherwise setting the capture volume for amps will be weird and
inconsistent (it will try to set values outside the range of the
second amp based on capabilities of the first amp).

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - do not add non-existing Mic boost controls
David Henningsson [Wed, 16 Jan 2013 14:58:43 +0000 (15:58 +0100)]
ALSA: hda - do not add non-existing Mic boost controls

If the input node does not have any volume capable input amp,
don't add such a control.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - initialize channel counts correctly
David Henningsson [Wed, 16 Jan 2013 10:45:37 +0000 (11:45 +0100)]
ALSA: hda - initialize channel counts correctly

Even a single DAC can output two channels, so the channel count
is twice the number of DACs.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - fix wrong adc_idx in generic parser
David Henningsson [Wed, 16 Jan 2013 10:45:36 +0000 (11:45 +0100)]
ALSA: hda - fix wrong adc_idx in generic parser

We use knew->index for adc_idx when we create "Capture Volume" and
"Capture Switch", so use the same to retrieve adc_idx.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Check array bounds in get_input_path
David Henningsson [Wed, 16 Jan 2013 10:45:35 +0000 (11:45 +0100)]
ALSA: hda - Check array bounds in get_input_path

This gives us some additional safety.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Add prefer_hp_amp flag to hda_gen_spec
Takashi Iwai [Tue, 15 Jan 2013 17:45:53 +0000 (18:45 +0100)]
ALSA: hda - Add prefer_hp_amp flag to hda_gen_spec

Add a new flag to indicate whether HP amp is turned on as default for
speaker or line-outs, and enable this for ALC260 codec, as many
machines with this codec require the HP amp even for speakers.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - fix OOPS in hda_mark_cmd_cache_dirty
David Henningsson [Tue, 15 Jan 2013 14:27:19 +0000 (15:27 +0100)]
ALSA: hda - fix OOPS in hda_mark_cmd_cache_dirty

Obvious copy-paste error.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Check pincap while parsing the configuration
Takashi Iwai [Tue, 15 Jan 2013 07:45:33 +0000 (08:45 +0100)]
ALSA: hda - Check pincap while parsing the configuration

Sometimes (or rather often) BIOS sets the pin default configurations
obviously wrongly.  Looking through these failures, one common pattern
is to enable some dead pins that are usually marked as speaker pins.
In such a case, we can skip them if the pins don't have the output
capability.

In this patch, add a check for the valid pin cap bit for each parsed
pin, and filter out when it's invalid.

The fix was originally suggested by Raymond Yau.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Add capture_switch_hook to generic parser
Takashi Iwai [Mon, 14 Jan 2013 11:13:06 +0000 (12:13 +0100)]
ALSA: hda - Add capture_switch_hook to generic parser

Add a hook for the capture mixer switch.  This will be used by IDT
codecs for controlling the mic-mute LED.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Use generic parser for CA0110 codec
Takashi Iwai [Wed, 19 Dec 2012 17:04:37 +0000 (18:04 +0100)]
ALSA: hda - Use generic parser for CA0110 codec

CA0110 codec is a fairly straightforward hardware implementation,
and we can use the generic parser almost as is.
Just set spec->multi_cap_vol flag to follow the current behavior.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Use generic codec parser for C-Media codecs
Takashi Iwai [Wed, 19 Dec 2012 16:35:47 +0000 (17:35 +0100)]
ALSA: hda - Use generic codec parser for C-Media codecs

Replace the old parser code for C-Media auto-parser with the latest
generic parser.  For compatibility reason, the static bindings are
still left, but they could be cleaned up in future.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Remove superfluous kconfig depends
Takashi Iwai [Wed, 19 Dec 2012 16:37:12 +0000 (17:37 +0100)]
ALSA: hda - Remove superfluous kconfig depends

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Allow user to give hints for codec parser behavior
Takashi Iwai [Fri, 11 Jan 2013 16:48:22 +0000 (17:48 +0100)]
ALSA: hda - Allow user to give hints for codec parser behavior

Through the hints via sysfs or patch, user can set specific behavior
flags for the generic parser now.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Add snd_hda_get_int_hint() helper function
Takashi Iwai [Fri, 11 Jan 2013 16:40:31 +0000 (17:40 +0100)]
ALSA: hda - Add snd_hda_get_int_hint() helper function

It'll be used in hda_generic.c, too.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Protect user-defined arrays via mutex
Takashi Iwai [Thu, 10 Jan 2013 17:21:56 +0000 (18:21 +0100)]
ALSA: hda - Protect user-defined arrays via mutex

The pincfgs, init_verbs and hints set by sysfs or patch might be
changed dynamically on the fly, thus we need to protect it.
Add a simple protection via a mutex.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda/realtek - Generic mute LED implementation for HP laptops
Takashi Iwai [Thu, 10 Jan 2013 16:33:58 +0000 (17:33 +0100)]
ALSA: hda/realtek - Generic mute LED implementation for HP laptops

As David Henningsson recently suggested, some HP laptops use an unused
mic pin for controlling a mute LED, and this information is provided
via DMI string "HP_Mute_LED_X_Y" string.  This patch adds the generic
support for such cases, as we've already done in patch_sigmatel.c.
This is applied generically to all devices with ID 0x103c.

But as we don't know whether the device 103c:1586 really contains
HP_Mute_LED_X_Y DMI string, still keep the static setup for this
device using the mic2 pin 0x19.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda/realtek - Fix the timing for some fixups
Takashi Iwai [Thu, 10 Jan 2013 16:14:29 +0000 (17:14 +0100)]
ALSA: hda/realtek - Fix the timing for some fixups

Some fixups such as setting the flags influencing on the parser
behavior should be applied before actually parsing the tree.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda/realtek - Add a fixup for FSC S7020 laptop
Takashi Iwai [Thu, 10 Jan 2013 16:10:40 +0000 (17:10 +0100)]
ALSA: hda/realtek - Add a fixup for FSC S7020 laptop

Try to recover from the regression: set the HP amp for the speaker and
add the hp jack mode enum as default.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Add output jack mode enum controls
Takashi Iwai [Thu, 10 Jan 2013 15:57:58 +0000 (16:57 +0100)]
ALSA: hda - Add output jack mode enum controls

Add the enum controls for changing the headphone amp bits of output
jacks, such as "Headphone Jack Mode".  This feature isn't enabled as
default, so far, unless spec->add_out_jack_modes flag is set.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Update automute / automic upon jack retasking
Takashi Iwai [Thu, 10 Jan 2013 15:10:06 +0000 (16:10 +0100)]
ALSA: hda - Update automute / automic upon jack retasking

When a multi-io jack is switched to another direction, call the
automute and autoswitch update functions, as this jack won't be used
as the headphone or the mic jack that may turn off others.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Add a new fixup type to override pinctl values
Takashi Iwai [Thu, 10 Jan 2013 09:18:14 +0000 (10:18 +0100)]
ALSA: hda - Add a new fixup type to override pinctl values

Add a new fixup type, HDA_FIXUP_PINCTLS, for overriding the pinctl
values of the given pins.  It takes the same array of struct pintbl
like HDA_FIXUP_PINS, but each entry contains the pinctl value instead
of the pin default config value.

This patch also replaces the corresponding codes in patch_realtek.c.
Without this change, the direct call of verbs may be overridden again
by the later call of pinctl restoration by the driver.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda/realtek - Read the cached pinctl value in fixups
Takashi Iwai [Thu, 10 Jan 2013 09:12:22 +0000 (10:12 +0100)]
ALSA: hda/realtek - Read the cached pinctl value in fixups

... instead of reading the value from the codec at each time.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda/realtek - Drop aliases for old fixups
Takashi Iwai [Thu, 10 Jan 2013 08:52:52 +0000 (09:52 +0100)]
ALSA: hda/realtek - Drop aliases for old fixups

Now the whole codebase has been changed from the earlier kernels, it
makes little sense to keep these aliases.  Simply replace with the
official names.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Avoid auto-mute or auto-mic of retasked jacks
Takashi Iwai [Thu, 10 Jan 2013 08:45:13 +0000 (09:45 +0100)]
ALSA: hda - Avoid auto-mute or auto-mic of retasked jacks

When a jack is retasked as a different direction (e.g. a mic jack is
used as a CLFE output), such a jack shouldn't be counted as the target
for the automatic jack switching.  Skip the automute or the autoswitch
when the current pinctl direction is different from what we suppose.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Manage current pinctl values in generic parser
Takashi Iwai [Thu, 10 Jan 2013 08:33:29 +0000 (09:33 +0100)]
ALSA: hda - Manage current pinctl values in generic parser

Use the new pin target accessors for managing the current pinctl
values in the generic parser.  The pinctl values of all active pins
are once determined at the initialization phase, and stored via
snd_hda_codec_set_pin_target().  This will be referred again in the
codec init or resume phase to set the actual pinctl.

This value is kept while the auto-mute.  When a line-out or a speaker
pin is muted by auto-mute, the driver simply disables the pin, but it
doesn't touch the cached pinctl target value.  Upon unmute, this value
is used to restore the original pinctl in return.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - More strict correction of invalid pinctl bits
Takashi Iwai [Thu, 10 Jan 2013 07:56:46 +0000 (08:56 +0100)]
ALSA: hda - More strict correction of invalid pinctl bits

Check more strictly about the validity of pinctl values in
snd_hda_set_pin_ctl() and correct the wrong bits automatically.
Also provide the helper function to correct pinctl bits to codec
drivers.

This automatically fixes the invalid pinctl writes that are found in
a few Realtek fixups for NID 0x0f amp like ASUS A6Rp.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Add helper functions to cache the current pinctl target
Takashi Iwai [Thu, 10 Jan 2013 07:38:04 +0000 (08:38 +0100)]
ALSA: hda - Add helper functions to cache the current pinctl target

We already have the list of whole pin widgets and there is an unused
space in the list; let's use it for caching the current pinctl value.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Clear the dropped paths properly
Takashi Iwai [Wed, 9 Jan 2013 08:28:20 +0000 (09:28 +0100)]
ALSA: hda - Clear the dropped paths properly

When a DAC is reassigned from surrounds to front or ADCs are reduced
due to incomplete imux, we clear the path indices but the path
instances remain as is.  Since the paths might be still referred
through the whole path list parsing (e.g. is_active_nid()), we should
clear these path instances as well.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Allow aamix as a capture source
Takashi Iwai [Wed, 9 Jan 2013 08:14:23 +0000 (09:14 +0100)]
ALSA: hda - Allow aamix as a capture source

Since some codecs can choose the aamix as a capture source, we should
support it as well.  When spec->add_stereo_mix_input flag is set, the
parser checks the availability of aamix as the input source, and adds
the paths automatically when possible.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Fix inconsistent input_paths after ADC reduction
Takashi Iwai [Wed, 9 Jan 2013 08:06:18 +0000 (09:06 +0100)]
ALSA: hda - Fix inconsistent input_paths after ADC reduction

In the current parser code, the input_paths[] may become inconsistent
when some of detected ADCs are dropped due to incomplete inputs, since
the driver rearranges only adc_nids[] but doesn't touch input_paths[].

This patch fixes the issue, and also it optimizes the reachability
checks by simply referring to the parsed input_paths[] instead of
calling is_reachable() again for each connection.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Return "Headphone Mic" from hda_get_autocfg_input_label()
Takashi Iwai [Wed, 9 Jan 2013 07:46:34 +0000 (08:46 +0100)]
ALSA: hda - Return "Headphone Mic" from hda_get_autocfg_input_label()

Instead of handling special cases in the caller side, give a proper
name string "Headphone Mic" from hda_get_autocfg_input_label() when
the headhpone jack pin is specified as an input.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Exclude aamix from capture paths
Takashi Iwai [Wed, 9 Jan 2013 07:41:41 +0000 (08:41 +0100)]
ALSA: hda - Exclude aamix from capture paths

The capture paths shouldn't contain the analog loopback mixer.
Pass a proper argument to exclude the aamix NID.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Add a flag to suppress mic auto-switch
Takashi Iwai [Mon, 7 Jan 2013 15:32:11 +0000 (16:32 +0100)]
ALSA: hda - Add a flag to suppress mic auto-switch

Add a new flag spec->suppress_mic_auto_switch for codecs that don't
support unsol events properly like VT1708.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Handle BOTH jack port as a fixed output
Takashi Iwai [Mon, 7 Jan 2013 17:21:47 +0000 (18:21 +0100)]
ALSA: hda - Handle BOTH jack port as a fixed output

When the default config value shows the connection AC_JACK_PORT_BOTH,
it's better to handle it as a speaker pin.  This makes the behavior
consistent in snd_hda_get_pin_label() and snd_hda_parse_pin_defcfg().

There are only few old machines showing this attribute, and all of
them are actually fixed speaker pins, as far as I know.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Re-define snd_hda_parse_nid_path()
Takashi Iwai [Mon, 7 Jan 2013 16:25:08 +0000 (17:25 +0100)]
ALSA: hda - Re-define snd_hda_parse_nid_path()

This commit modifies the definition of snd_hda_parse_nid_path()
slightly, now with_aa_mix argument is changed to anchor_nid, so that
it can handle any NID generically as an anchor point to include or
exclude.

The with_aa_mix field in struct nid_path is removed again by this
change.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Manage input paths via path indices
Takashi Iwai [Mon, 7 Jan 2013 16:09:26 +0000 (17:09 +0100)]
ALSA: hda - Manage input paths via path indices

... like we did for output and loopback paths.
It makes the code slightly easier.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Fix multi-io channel mode management
Takashi Iwai [Mon, 7 Jan 2013 15:44:06 +0000 (16:44 +0100)]
ALSA: hda - Fix multi-io channel mode management

The multi-io channels can vary not only from 1 to 6 but also may vary
from 6 to 8 or such.  At the same time, there are more speaker pins
available than the primary output pins.  So, we need three variables
to check: the minimum channel counts for primary outputs, the current
channel counts for primary outputs, and the minimum channel counts for
all outputs.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Don't set up active streams twice
Takashi Iwai [Mon, 7 Jan 2013 14:36:45 +0000 (15:36 +0100)]
ALSA: hda - Don't set up active streams twice

We don't have to set up a stream that has been already set up
previously.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Remove unused dac reference in create_multi_out_ctls()
Takashi Iwai [Mon, 7 Jan 2013 14:14:00 +0000 (15:14 +0100)]
ALSA: hda - Remove unused dac reference in create_multi_out_ctls()

Remove useless code.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Use direct path reference in assign_out_path_ctls()
Takashi Iwai [Mon, 7 Jan 2013 14:11:44 +0000 (15:11 +0100)]
ALSA: hda - Use direct path reference in assign_out_path_ctls()

Instead of looking through paths with the dac -> pin connection at
each time, just pass the already parsed path index to
assign_out_path_ctls().  This simplifies the code a bit.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Clear path indices properly at each re-evaluation
Takashi Iwai [Mon, 7 Jan 2013 14:07:00 +0000 (15:07 +0100)]
ALSA: hda - Clear path indices properly at each re-evaluation

The path indices must be reset at each evaluation of DAC assignment.
Otherwise the badness value will be wrongly calculated and mixers may
be inconsistently assigned.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Add brief comments to exported snd_hda_gen_*_() functions
Takashi Iwai [Mon, 7 Jan 2013 11:52:16 +0000 (12:52 +0100)]
ALSA: hda - Add brief comments to exported snd_hda_gen_*_() functions

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Remove dead HDA_CTL_BIND_VOL and HDA_CTL_BIND_SW codes
Takashi Iwai [Mon, 7 Jan 2013 11:47:04 +0000 (12:47 +0100)]
ALSA: hda - Remove dead HDA_CTL_BIND_VOL and HDA_CTL_BIND_SW codes

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Add snd_hda_gen_free() and snd_hda_gen_check_power_status()
Takashi Iwai [Mon, 7 Jan 2013 11:42:48 +0000 (12:42 +0100)]
ALSA: hda - Add snd_hda_gen_free() and snd_hda_gen_check_power_status()

Just to remove duplicated codes.
Also fixed EXPORT_SYMBOL() in hda_generic.c.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Allow jack detection when polling is enabled
Takashi Iwai [Mon, 7 Jan 2013 11:11:33 +0000 (12:11 +0100)]
ALSA: hda - Allow jack detection when polling is enabled

Let is_jack_detectable() return true when the jack polling is enabled
for the codec.  VT1708 uses the polling explicitly so we need to allow
it.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Add pcm_playback_hook to hda_gen_spec
Takashi Iwai [Mon, 7 Jan 2013 10:54:34 +0000 (11:54 +0100)]
ALSA: hda - Add pcm_playback_hook to hda_gen_spec

The new hook which is called at each PCM playback ops.
It can be used to control the codec-specific power-saving feature in
each codec driver.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Drop bind-volume workaround
Takashi Iwai [Mon, 7 Jan 2013 09:33:57 +0000 (10:33 +0100)]
ALSA: hda - Drop bind-volume workaround

The bind-volume workaround was introduced for simplifying the mixer
abstraction in the case where one or more pins of multiple outputs
lack of individual volume controls.  This was essentially the case
like Acer Aspire 5935, which has 5.1 speakers and 5.1 (multi-io)
jacks although there are 5 DACs, so some of them must share a DAC.

However, the recent code rewrite changed the DAC assignment policy to
share with the same channel instead of binding to the front, thus
binding the volumes for all channels makes little sense now, rather
it's confusing.  So in this patch, the ugly workaround is finally
dropped and simply create the volume control corresponding to the
parsed path position.

For dual headphones or 2.1 speakers with a shared volume control, it's
anyway bound to the same DAC if needed, so this change shouldn't bring
any practical difference.

And, as a good bonus, we can cut off the whole code handling the bind
volume elements.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Drop unneeded pin argument from set_output_and_unmute()
Takashi Iwai [Mon, 7 Jan 2013 09:08:02 +0000 (10:08 +0100)]
ALSA: hda - Drop unneeded pin argument from set_output_and_unmute()

Just a minor refactoring.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Add missing slave names for Speaker Surround, etc
Takashi Iwai [Mon, 7 Jan 2013 08:57:42 +0000 (09:57 +0100)]
ALSA: hda - Add missing slave names for Speaker Surround, etc

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Prefer binding the primary CLFE output
Takashi Iwai [Mon, 7 Jan 2013 08:50:52 +0000 (09:50 +0100)]
ALSA: hda - Prefer binding the primary CLFE output

When 5.1 or more multiple speakers with found but not enough DACs are
available, it's better to bind such pins to the DACs of the primary
outputs with the same channels rather than binding to the first DAC
(i.e. the front channel).  For the cases with two speaker pins, it's
rather regarded as front + bass combination, thus it's more practical
to still bind to the front, though.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Fix truncated control names
Takashi Iwai [Mon, 7 Jan 2013 08:43:18 +0000 (09:43 +0100)]
ALSA: hda - Fix truncated control names

... like "Speaker Surround Playback Switch".
This fix had been already applied to patch_conexant.c but was
forgotten in other places, then migrated to hda_generic.c.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Add Loopback Mixing control
Takashi Iwai [Fri, 4 Jan 2013 15:42:48 +0000 (16:42 +0100)]
ALSA: hda - Add Loopback Mixing control

For codecs that have individual routes going through a loopback mixer
(like VIA codecs), we need to provide an explicit switch to choose
whether the output goes through mixer or directly from DAC.

This patch adds the check for such paths and creates "Loopback Mixing"
enum control when available.

It won't influence on codecs like Realtek or others where the loopback
mixer is connected independently from the primary output routes.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Correct aamix output paths
Takashi Iwai [Fri, 4 Jan 2013 14:41:41 +0000 (15:41 +0100)]
ALSA: hda - Correct aamix output paths

The output paths including aamix should be parsed only for the first
output.  The surround paths including aamix must be wrong, since it
would mix all streams, i.e. all channels would be mixed into a single
and multiplexed again.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Initialize digital-input path properly
Takashi Iwai [Fri, 4 Jan 2013 14:09:42 +0000 (15:09 +0100)]
ALSA: hda - Initialize digital-input path properly

Call the path activation for the digital input pin properly, not only
setting the pin control.  Also add spec->digin_path for keeping the
path index.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Manage using output/loopback path indices
Takashi Iwai [Fri, 4 Jan 2013 14:01:40 +0000 (15:01 +0100)]
ALSA: hda - Manage using output/loopback path indices

Instead of search for the path with the certain route at each time,
keep the path index for each output and loopback, and just use it when
referred.

In this implementation, the path index number begins with one, not
zero (although I've been writing in C over decades).  It's just to
make the check for uninitialized values easier.

So far, the input paths aren't handled with indices yet, but still
picked up via snd_hda_get_nid_path() at each time.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Fix multi-io pin assignment in create_multi_out_ctls()
Takashi Iwai [Fri, 4 Jan 2013 14:00:02 +0000 (15:00 +0100)]
ALSA: hda - Fix multi-io pin assignment in create_multi_out_ctls()

The multi-io pins are calculated with a blind assumption of
cfg->line_outs = 1.  This isn't always true.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Simplify the multi-io assignment with multi speakers
Takashi Iwai [Fri, 4 Jan 2013 13:50:04 +0000 (14:50 +0100)]
ALSA: hda - Simplify the multi-io assignment with multi speakers

When speakers are chosen as the the primary output during evaluation,
we did some tricks to assign the possible multi-io jacks with a
certain offset value to multi_out dacs.  This was a workaround for the
case with multiple speakers like Acer Aspire.  But this is quite ugly
at the same time and the resultant code is hard to understand.  More
badly, it works wrongly for 2.1 speakers like Apple iMac91.

In this patch, instead of fiddling with the offset to multi_out dacs,
simply add a certain badness number if headphone(s) + multi-ios are
possible.  This simplify the code a bit, and it's more robust.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Check the existing path in snd_hda_add_new_path()
Takashi Iwai [Fri, 4 Jan 2013 12:19:55 +0000 (13:19 +0100)]
ALSA: hda - Check the existing path in snd_hda_add_new_path()

If the requested path has been already added, return the existing path
instance instead of adding a duplicated instance.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Avoid duplicated path creations
Takashi Iwai [Fri, 4 Jan 2013 11:56:52 +0000 (12:56 +0100)]
ALSA: hda - Avoid duplicated path creations

When the paths are created in map_singles(), we don't have to
re-create new paths in try_assign_dacs().  Just evaluate the badness
and skip to the next item.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Initialize output paths with current active states
Takashi Iwai [Thu, 3 Jan 2013 15:33:02 +0000 (16:33 +0100)]
ALSA: hda - Initialize output paths with current active states

Set path->active flag at the path creation time and let the paths
initialized according to the current path->active state in
set_output_and_unmute().  This allows to modify the active flag of
some output paths dynamically, e.g. switching the front output route
with or without aamix like patch_via.c.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Don't skip amp init for activated paths
Takashi Iwai [Thu, 3 Jan 2013 15:30:04 +0000 (16:30 +0100)]
ALSA: hda - Don't skip amp init for activated paths

activate_amp() in the generic parser checks whether the given NID is
included in any active paths and skips it if found.  This was a
workaround for avoiding disabling the widgets in the active paths when
one path is disabled, thus it shouldn't be applied to the case for
path activation.  Due to this wrong check, some analog loopback paths
haven't been initialized correctly.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Add hooks for HP/line/mic auto switching
Takashi Iwai [Thu, 3 Jan 2013 14:55:06 +0000 (15:55 +0100)]
ALSA: hda - Add hooks for HP/line/mic auto switching

... as a preliminary work for migrating patch_sigmatel.c.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Revive snd_hda_get_conn_list()
Takashi Iwai [Thu, 3 Jan 2013 14:25:11 +0000 (15:25 +0100)]
ALSA: hda - Revive snd_hda_get_conn_list()

Manage the connection list cache using linked lists instead of
snd_array, and revive snd_hda_get_conn_list() again, so that we don't
have to keep the expanded values locally.
This will reduce the stack usage by recursive call of
snd_hda_get_conn_index() or parse_nid_path() of the generic parser.

The list management doesn't include any mutex protection, thus the
caller needs to take care of race appropriately.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Add codec->inv_jack_detect flag
Takashi Iwai [Fri, 21 Dec 2012 14:31:41 +0000 (15:31 +0100)]
ALSA: hda - Add codec->inv_jack_detect flag

Yet another broken hardware workaround: there are hardware indicating
the inverted jack detection bit result.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Add inv_eapd flag to struct hda_codec
Takashi Iwai [Fri, 21 Dec 2012 14:23:01 +0000 (15:23 +0100)]
ALSA: hda - Add inv_eapd flag to struct hda_codec

Add the new flag, codec->inv_eapd, indicating that the EAPD
implementation is inverted.

There are always broken hardware in the world.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Implement independent HP control
Takashi Iwai [Fri, 21 Dec 2012 13:09:42 +0000 (14:09 +0100)]
ALSA: hda - Implement independent HP control

Similar like the implementation in patch_analog.c and patch_via.c,
the generic parser can provide the independent HP PCM stream now.
It's enabled when spec->indep_hp is set by the caller while parsing.

Currently no dynamic PCM switching as in patch_via.c is implemented
yet.  The control returns -EBUSY when the value is changed during PCM
operations.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Allow aamix in the primary output path
Takashi Iwai [Thu, 20 Dec 2012 17:29:16 +0000 (18:29 +0100)]
ALSA: hda - Allow aamix in the primary output path

Allow the path including the loopback mixer widget in the primary
output channel as an alternative in the generic codec parser.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Define HDA_PARSE_* for snd_hda_parse_nid_path() argument
Takashi Iwai [Thu, 20 Dec 2012 17:10:51 +0000 (18:10 +0100)]
ALSA: hda - Define HDA_PARSE_* for snd_hda_parse_nid_path() argument

... instead of numbers.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Fix typos in debug_show_configs()
Takashi Iwai [Thu, 20 Dec 2012 16:56:57 +0000 (17:56 +0100)]
ALSA: hda - Fix typos in debug_show_configs()

It never showed the 4th line out and headphone pins since quite ago.
Oh well.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Add more debug prints about new paths
Takashi Iwai [Thu, 20 Dec 2012 16:54:22 +0000 (17:54 +0100)]
ALSA: hda - Add more debug prints about new paths

Add a better debug print code to show the new assigned paths in
generic parser.  It appears only with CONFIG_SND_DEBUG_VERBOSE=y.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Drop spec->channel_mode field from hda_gen_spec
Takashi Iwai [Thu, 20 Dec 2012 16:05:20 +0000 (17:05 +0100)]
ALSA: hda - Drop spec->channel_mode field from hda_gen_spec

It's never used in the generic parser.  It was there from the old
Realtek code, which has been dropped quite ago, too.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Fix PCM name string for generic parser
Takashi Iwai [Thu, 20 Dec 2012 15:58:39 +0000 (16:58 +0100)]
ALSA: hda - Fix PCM name string for generic parser

When a PCM name string is generated from the chip name, it might
become strange like "CX20549 (Venice) Analog".  In this patch, the
parser tries to drop the invalid words like "(Venice)" in the PCM name
string.  Also, when the name string is given beforehand by the caller,
respect it and use it as is.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Use cached version for changing pins in hda_generic.c
Takashi Iwai [Thu, 20 Dec 2012 14:38:40 +0000 (15:38 +0100)]
ALSA: hda - Use cached version for changing pins in hda_generic.c

There is no reason to avoid snd_hda_set_pin_ctl_cache() there.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Dynamically turn on/off EAPD in generic codec driver
Takashi Iwai [Thu, 20 Dec 2012 14:36:30 +0000 (15:36 +0100)]
ALSA: hda - Dynamically turn on/off EAPD in generic codec driver

When spec->own_eapd_ctl isn't set, try to turn on/off EAPD on demand
for each pin.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Fix initialization of primary outputs in hda_generic.c
Takashi Iwai [Thu, 20 Dec 2012 14:29:21 +0000 (15:29 +0100)]
ALSA: hda - Fix initialization of primary outputs in hda_generic.c

There were some old codes that look not stable enough, which was
derived from the old Realtek code.  The initialization for primary
output in init_multi_out() needs to consider the case of shared DAC.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Refactor init_extra_out() in hda_generic.c
Takashi Iwai [Thu, 20 Dec 2012 14:27:24 +0000 (15:27 +0100)]
ALSA: hda - Refactor init_extra_out() in hda_generic.c

Just a small clean up by splitting a function.
No functional changes at all.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Clear unsol enable bits on unused pins in generic parser
Takashi Iwai [Thu, 20 Dec 2012 14:16:09 +0000 (15:16 +0100)]
ALSA: hda - Clear unsol enable bits on unused pins in generic parser

For preliminary works to migrate the generic parser for Conexant
codecs: the same function is ported to hda_generic.c.
But now it looks through the jack detect table so that it can cover
better.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Add spec->vmaster_mute_enum flag to generic parser
Takashi Iwai [Thu, 20 Dec 2012 13:57:18 +0000 (14:57 +0100)]
ALSA: hda - Add spec->vmaster_mute_enum flag to generic parser

Add a flag to indicate whether the vmaster mute hook enum is exposed
or not.  Conexant codecs may want not to expose the control depending
on the model.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Begin HDA_GEN_* event tag from 1
Takashi Iwai [Thu, 20 Dec 2012 13:46:57 +0000 (14:46 +0100)]
ALSA: hda - Begin HDA_GEN_* event tag from 1

... to distinguish from the invalid event type.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Increase the max depth of widget connections
Takashi Iwai [Thu, 20 Dec 2012 13:42:42 +0000 (14:42 +0100)]
ALSA: hda - Increase the max depth of widget connections

Old codecs like AD1986A tend to have long paths as they were just made
to be the way like AC97.  The current max depth 5 can be too short for
such devices.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Avoid access of amp cache element outside mutex
Takashi Iwai [Thu, 20 Dec 2012 11:58:12 +0000 (12:58 +0100)]
ALSA: hda - Avoid access of amp cache element outside mutex

The access to a cache array element could be invalid outside the
mutex, so copy locally for the later references.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Fix wrong dirty check in snd_hda_codec_resume_amp()
Takashi Iwai [Thu, 20 Dec 2012 11:54:18 +0000 (12:54 +0100)]
ALSA: hda - Fix wrong dirty check in snd_hda_codec_resume_amp()

The dirty entry has to be checked at the beginning in the loop, not in
the inner loop for channels.  This caused a regression that the right
channel isn't properly written.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Do sequential writes in snd_hda_gen_init()
Takashi Iwai [Thu, 20 Dec 2012 10:50:58 +0000 (11:50 +0100)]
ALSA: hda - Do sequential writes in snd_hda_gen_init()

This would reduce the number of actually executed verbs.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Add / fix comments about capture vol/sw controls in hda_generic.c
Takashi Iwai [Thu, 20 Dec 2012 10:48:54 +0000 (11:48 +0100)]
ALSA: hda - Add / fix comments about capture vol/sw controls in hda_generic.c

A bit of details won't hurt.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Add missing amp cache flush for bound capture vol/sw ctls
Takashi Iwai [Thu, 20 Dec 2012 10:43:47 +0000 (11:43 +0100)]
ALSA: hda - Add missing amp cache flush for bound capture vol/sw ctls

The bound capture volume and switch controls use the cached amp
updates, but it's missing the flushing at the end.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Add snd_hda_codec_flush_*_cache() aliases
Takashi Iwai [Thu, 20 Dec 2012 10:41:54 +0000 (11:41 +0100)]
ALSA: hda - Add snd_hda_codec_flush_*_cache() aliases

It makes easier to understand although these are identical with
snd_hda_codec_resume_*() functions.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Flush dirty amp caches before writing inv_dmic fix
Takashi Iwai [Thu, 20 Dec 2012 10:33:20 +0000 (11:33 +0100)]
ALSA: hda - Flush dirty amp caches before writing inv_dmic fix

The inverted dmic fix overwrites the right channel amp value, but it
would work only when the amp values have been already actually
written.  Put snd_hda_codec_resume_amp() before the amp write for
flushing caches.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Check CORB overflow
Takashi Iwai [Thu, 20 Dec 2012 10:17:17 +0000 (11:17 +0100)]
ALSA: hda - Check CORB overflow

Add an overflow check of CORB in HD-audio controller and codec drivers
so that flood of sequential writes would work properly.
In the controller side, add a check of CORB read-pointer to make
returning -EAGAIN when it's full.  Meanwhile in the codec side, when
-EAGAIN error is received, it retries the write after flushing the
pending verbs (calling get_response() essentially does it).

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Clear cached_write flag in snd_hda_codec_resume_*()
Takashi Iwai [Thu, 20 Dec 2012 10:02:00 +0000 (11:02 +0100)]
ALSA: hda - Clear cached_write flag in snd_hda_codec_resume_*()

These functions are supposed to be called at finishing the cached
sequential writes, so clear the flag properly for lazy developers who
often forget details.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Clear dirty flag upon cache write
Takashi Iwai [Thu, 20 Dec 2012 10:00:21 +0000 (11:00 +0100)]
ALSA: hda - Clear dirty flag upon cache write

When verbs or amps are actually written to the hardware, we can clear
dirty flag so that the later snd_hda_codec_resume_*() calls can skip
these verbs / amps.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Allow one chance for zero NID in connection list
Takashi Iwai [Thu, 20 Dec 2012 09:45:55 +0000 (10:45 +0100)]
ALSA: hda - Allow one chance for zero NID in connection list

The commit [2e9bf24: ALSA: hda_codec: Check for invalid zero
connections] trims the whole connection list when an invalid value is
reported by the hardware.  But some codecs (at least AD1986A) may give
a zero NID in the middle of the connection list, so dropping the whole
list isn't good for such cases.

In this patch, as a workaround, allow a single zero NID in the read
connection list.  If it hits zero twice, it's handled as an error, so
that we can avoid "too many connections" errors.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Use "Capture Source" for single sources
Takashi Iwai [Wed, 19 Dec 2012 16:41:52 +0000 (17:41 +0100)]
ALSA: hda - Use "Capture Source" for single sources

In general we prefer "Capture Source" to "Input Source".
The latter was chosen in many places just because "Capture Source"
label doesn't work well with the current alsa-lib mixer abstraction
when multiple instances are present.  But when we know that there is a
single input-source element, we can safely choose "Capture Source"
label.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Use generic parser codes for Realtek driver
Takashi Iwai [Wed, 19 Dec 2012 14:22:24 +0000 (15:22 +0100)]
ALSA: hda - Use generic parser codes for Realtek driver

The next migration step is to use the common code in generic driver
for Realtek driver.  This is no drastic change and there should be no
real functional changes, as the generic parser code comes from Realtek
driver originally.

As Realtek driver requires the generic parser code, it needs a
reverse-selection of CONFIG_SND_HDA_GENERIC kconfig.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Export standard jack event handlers for generic parser
Takashi Iwai [Wed, 19 Dec 2012 14:16:44 +0000 (15:16 +0100)]
ALSA: hda - Export standard jack event handlers for generic parser

These handlers are supposed to be called externally from the codec
drivers once when they need to handle own jack events.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Fix NULL dereference in snd_hda_gen_build_controls()
Takashi Iwai [Wed, 19 Dec 2012 14:15:10 +0000 (15:15 +0100)]
ALSA: hda - Fix NULL dereference in snd_hda_gen_build_controls()

When no controls are assigned in the parser (e.g. no analog path),
spec->kctls.list is still NULL.  We need to check it before passing to
snd_hda_add_new_ctls().

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Move the call of snd_hda_parse_pin_defcfg() from snd_hda_gen_parse_auto_c...
Takashi Iwai [Wed, 19 Dec 2012 13:41:21 +0000 (14:41 +0100)]
ALSA: hda - Move the call of snd_hda_parse_pin_defcfg() from snd_hda_gen_parse_auto_config()

In some cases, we want to manipulate the auto_pin_cfg table before
passing to snd_hda_gen_parse_auto_config() (e.g. Realtek SSID check
code fiddles with the headphone pin).   Also passing ignore_pins just
for snd_hda_parse_pin_defcfg() isn't good.

In this patch, snd_hda_gen_parse_auto_config() is changed to receive
the auto_pin_cfg table to be parsed.  The passed auto_pin_cfg table
must have been initialized (typically by calling
snd_hda_gen_parse_auto_config()) beforehand by the caller.

Also together with this change, spec->parse_flags is also removed.
Since this was referred only at the place calling
snd_hda_parse_pin_defcfg(), no longer needed to be kept in spec.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Export snd_hda_gen_add_kctl()
Takashi Iwai [Wed, 19 Dec 2012 13:38:33 +0000 (14:38 +0100)]
ALSA: hda - Export snd_hda_gen_add_kctl()

It may be used in other codec drivers, so let it free.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Add EAPD control to generic parser
Takashi Iwai [Wed, 19 Dec 2012 12:01:54 +0000 (13:01 +0100)]
ALSA: hda - Add EAPD control to generic parser

Enable EAPD in output path initializations automatically unless the
new flag spec->own_eapd_ctl is set.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda - Merge Realtek parser code to generic parser
Takashi Iwai [Wed, 19 Dec 2012 11:52:06 +0000 (12:52 +0100)]
ALSA: hda - Merge Realtek parser code to generic parser

Finally the whole generic parser code in Realtek driver is moved into
hda_generic.c so that it can be used for generic codec driver.
The old dumb generic driver is replaced.  Yay.

The future plan is to adapt this generic parser for other codecs,
i.e. the codec driver calls the exported functions in generic driver
but adds some codec-specific fixes and setups.

As of this commit, the complete driver code is still duplicated in
Realtek codec driver.  The big code reduction will come from now on.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
11 years agoALSA: hda/realtek - Remove redundant argument from alc_mux_select()
Takashi Iwai [Wed, 19 Dec 2012 11:24:03 +0000 (12:24 +0100)]
ALSA: hda/realtek - Remove redundant argument from alc_mux_select()

The argument "force" is always false in the recent code.

Signed-off-by: Takashi Iwai <tiwai@suse.de>