Commit Graph

45 Commits

Author SHA1 Message Date
Takashi Iwai
967303dabc ALSA: hda - Add the generic Headphone Mic feature
This patch improves the generic parser code to allow to set up the
headphone jack as a mic input.  User can enable this feature by giving
hp_mic hint string.

The former shared hp/mic feature for the single built-in mic is still
retained.  This detection can be disabled now via hp_mic_detect hint
string, too.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-03-07 18:29:52 +01:00
Takashi Iwai
0186f4f4f2 ALSA: hda - Use generic array for loopback list management
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-02-07 10:45:11 +01:00
Takashi Iwai
46a144818a ALSA: hda - Enable loopback accounts for CONFIG_PM=n, too
The loopback list is referred by the VIA codec driver no matter
whether CONFIG_PM is set or not, thus we need to enable it always.
Otherwise it gets compile errors.

Reported-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-02-07 09:59:26 +01:00
Takashi Iwai
55196fffc9 ALSA: hda - Implement path-based power filter to the generic parser
This patch adds a better power filter hook for powering down unused
widgets in the generic parser.

The feature is enabled by setting hda_gen_spec.power_down_unused
flag.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-24 17:55:52 +01:00
Takashi Iwai
e4a395e781 ALSA: hda - Fix missing path between aamix and outputs in AD codecs
AD1988 family and AD1882 codecs have another mixer widget (0x21)
between the analog-loopback mixer widget (0x20) and the actual
outputs.  Due to this hole, the analog-loopbacks aren't sent properly
to the output pins.

As a band-aid fix, introduce another fields holding the aamix merge
path, and activate it.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-23 17:00:31 +01:00
Takashi Iwai
a607148ff3 ALSA: hda - Set individual name to secondary analog PCM stream
It'd be better to give another name to the secondary (alt) analog PCM
stream, which is dedicated for the independent HP out and extra
inputs.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-22 14:12:40 +01:00
Takashi Iwai
a1e908edcc ALSA: hda - Fix conflicts between Loopback Mixing and Independent HP
This patch eventually fixes two issues:
- Handle the case where the primary output is a headphone and can have
  independent HP mode;
  so far we checked only the case where the headphone is the secondary
  output.

- Fix the conflict of HP independent mode and aamix mode;
  when switched to aamix mode, the DAC might be also switched to
  another widget shared with other outputs.  Then even if we disable
  the DAC for the original output, it doesn't change -- because the
  active route is from another (shared) DAC to HP pin through aamix.
  So, in such a case, we have to prohibit the switch to aamix for HP
  routes.

This fixes issues appearing on VT codecs.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-21 15:11:25 +01:00
Takashi Iwai
cf799aa300 ALSA: hda - Correct more array rooms in hda_gen_spec
Looking through the whole definitions, some fields have inappropriate
array sizes, especially about the capture.  The array assigned to each
input (pin) should have HDA_MAX_NUM_INPUTS entries while the array
assigned to each ADC should have AUTO_CFG_MAX_INS entries.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-18 16:38:08 +01:00
David Henningsson
d3d982f744 ALSA: hda - make sure there are enough input labels and paths
I found a codec configuration which had six inputs, so the max of
five was not appropriate.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-18 15:48:13 +01:00
Takashi Iwai
a90229e051 ALSA: hda - Consolidate cap_sync_hook and capture_switch_hook
Two hooks in hda_gen_spec, cap_sync_hook and capture_switch_hook, play
very similar roles.  The only differences are that the former is
called more often (e.g. at init or switching capsrc) while the latter
can take an on/off argument.

As a more generic implementation, consolidate these two hooks, and
pass snd_ctl_elem_value pointer as the second argument.  If the
secondary argument is non-NULL, it can take the on/off value, so the
caller handles it like the former capture_switch_hook.  If it's NULL,
it's called in the init or capsrc switch case.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-18 14:34:22 +01:00
Takashi Iwai
c970042c12 ALSA: hda - Unify input label creations in generic parser
There are a few places creating the labels and indices of kctls for
each input pin in the current generic parser code.  This is redundant
and makes harder to maintain.  Let's create the labels and indices at
once and keep them in hda_gen_spec.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-18 10:17:30 +01:00
Takashi Iwai
ac2e87366c ALSA: hda - Add PCM capture hook to hda_gen_spec
Not only PCM playback, a hook for PCM capture would be required for
power controls in codec drivers.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-17 15:57:10 +01:00
Takashi Iwai
0ffd534eb1 ALSA: hda - Record all detected ADCs in hda_gen_spec
Since the generic parser reduces the ADC list, copy the list of the
all detected ADCs and keep it.

This list can be later referred by the codec driver for finer power
controls.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-17 15:53:29 +01:00
Takashi Iwai
7a71bbf310 ALSA: hda - Move vmaster TLV parsing to snd_hda_gen_parse_auto_config()
Add vmaster_tlv[] to hda_gen_spec and store the suggested TLV data
in snd_hda_gen_parse_auto_config().  This allows the codec driver to
correct the TLV data (e.g. mute capability) before actually creating
vmaster instance.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-17 10:25:15 +01:00
Takashi Iwai
29476558de ALSA: hda - Add input jack mode enum controls to generic parser
Just like the jack mode enum ctls for output jacks, add the support
for similar enum ctls for input pins to control the bias Vref.
The new controls will be added when spec->add_in_jack_modes is set
either by the codec driver or by a hint string.

Note that ground and 100% vrefs are excluded from the list for
simplicity, currently.  We may add a new flag to allow them, too.
But I guess it's easier to put a value override in the pinfix in such
a case.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-17 09:55:21 +01:00
Takashi Iwai
acc47aafcf ALSA: hda - Give more comments to hda_gen_spec flags
Since we have many bit flags in hda_gen_spec, rearrange in sections
and give more comments there.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-16 18:28:38 +01:00
Takashi Iwai
f72706be35 ALSA: hda - Add suppress_auto_mute flag to hda_gen_spec
A new flag to skip the auto-mute handling in the generic parser, just
like suppress_auto_mic flag.  It has to be set before calling
snd_hda_gen_parse_auto_config().

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-16 18:22:37 +01:00
Takashi Iwai
47b9ddb83b ALSA: hda - Record the current speaker / LO mute status in hda_gen_spec
... to be referred by the codec driver.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-16 18:19:50 +01:00
Takashi Iwai
ea46c3c87c 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>
2013-01-15 18:45:53 +01:00
Takashi Iwai
ae177c3fd0 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>
2013-01-14 12:13:06 +01:00
Takashi Iwai
978e77e78c 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>
2013-01-12 08:44:38 +01:00
Takashi Iwai
f3fc0b0b1f 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>
2013-01-12 08:44:21 +01:00
Takashi Iwai
d12daf6f41 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>
2013-01-12 08:44:15 +01:00
Takashi Iwai
3ca529d339 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>
2013-01-12 08:44:11 +01:00
Takashi Iwai
c697b71685 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>
2013-01-12 08:44:09 +01:00
Takashi Iwai
a07a949be6 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>
2013-01-12 08:44:08 +01:00
Takashi Iwai
fce52a3bb1 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>
2013-01-12 08:43:56 +01:00
Takashi Iwai
e6b85f3c9d 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>
2013-01-12 08:43:52 +01:00
Takashi Iwai
c2c803830a 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>
2013-01-12 08:43:51 +01:00
Takashi Iwai
c30aa7b242 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>
2013-01-12 08:43:42 +01:00
Takashi Iwai
2430d7b78b 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>
2013-01-12 08:43:38 +01:00
Takashi Iwai
196c176680 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>
2013-01-12 08:43:37 +01:00
Takashi Iwai
f5172a7ed9 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>
2013-01-12 08:43:31 +01:00
Takashi Iwai
2e03e9528d 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>
2013-01-12 08:43:24 +01:00
Takashi Iwai
38cf6f1a41 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>
2013-01-12 08:42:56 +01:00
Takashi Iwai
4ac0eefa76 ALSA: hda - Define HDA_PARSE_* for snd_hda_parse_nid_path() argument
... instead of numbers.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-12 08:34:28 +01:00
Takashi Iwai
545502de54 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>
2013-01-12 08:34:24 +01:00
Takashi Iwai
fd25a97a97 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>
2013-01-12 08:34:12 +01:00
Takashi Iwai
406b285da3 ALSA: hda - Begin HDA_GEN_* event tag from 1
... to distinguish from the invalid event type.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-12 08:34:11 +01:00
Takashi Iwai
d94ddd85b1 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>
2013-01-12 08:34:09 +01:00
Takashi Iwai
5d550e15be 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>
2013-01-12 08:31:01 +01:00
Takashi Iwai
9eb413e5e4 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>
2013-01-12 08:30:58 +01:00
Takashi Iwai
12c93df60c 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>
2013-01-12 08:30:56 +01:00
Takashi Iwai
731dc3019c 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>
2013-01-12 08:30:55 +01:00
Takashi Iwai
352f7f914e 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>
2013-01-12 08:30:53 +01:00