Commit Graph

3364 Commits

Author SHA1 Message Date
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
76a19c69d9 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>
2013-01-12 08:43:54 +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
d4156930b2 ALSA: hda - Drop unneeded pin argument from set_output_and_unmute()
Just a minor refactoring.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-12 08:43:49 +01:00
Takashi Iwai
ee79c69ac7 ALSA: hda - Add missing slave names for Speaker Surround, etc
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-12 08:43:47 +01:00
Takashi Iwai
7385df6134 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>
2013-01-12 08:43:45 +01:00
Takashi Iwai
5abd4888f6 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>
2013-01-12 08:43:44 +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
117688a9c1 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>
2013-01-12 08:43:40 +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
05453b7e97 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>
2013-01-12 08:43:35 +01:00
Takashi Iwai
e22aab7dcf 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>
2013-01-12 08:43:33 +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
1e0b528696 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>
2013-01-12 08:43:30 +01:00
Takashi Iwai
e1284af730 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>
2013-01-12 08:43:28 +01:00
Takashi Iwai
985803ca91 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>
2013-01-12 08:43:26 +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
ee8e765b0b 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>
2013-01-12 08:43:23 +01:00
Takashi Iwai
9cc159c664 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>
2013-01-12 08:43:21 +01:00
Takashi Iwai
ecac3ed174 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>
2013-01-12 08:43:19 +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
b3a8c74522 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>
2013-01-12 08:34:30 +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
708122e836 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>
2013-01-12 08:34:27 +01:00
Takashi Iwai
0c8c0f56e6 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>
2013-01-12 08:34:25 +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
f873e536b6 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>
2013-01-12 08:34:22 +01:00
Takashi Iwai
7594aa3396 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>
2013-01-12 08:34:20 +01:00
Takashi Iwai
d5a9f1bb38 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>
2013-01-12 08:34:19 +01:00
Takashi Iwai
64049c81df 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>
2013-01-12 08:34:17 +01:00
Takashi Iwai
db23fd193d 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>
2013-01-12 08:34:16 +01:00
Takashi Iwai
973e4972f9 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>
2013-01-12 08:34:14 +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
2ce4886abc 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>
2013-01-12 08:34:07 +01:00
Takashi Iwai
8565f052c5 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>
2013-01-12 08:34:06 +01:00
Takashi Iwai
3bbcd274c2 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>
2013-01-12 08:34:04 +01:00
Takashi Iwai
47d46abba2 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>
2013-01-12 08:34:02 +01:00
Takashi Iwai
84e3908dc8 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>
2013-01-12 08:34:01 +01:00
Takashi Iwai
0c3d47b007 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>
2013-01-12 08:33:59 +01:00
Takashi Iwai
c4f3ebed3c 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>
2013-01-12 08:33:57 +01:00
Takashi Iwai
3bcce5c0d9 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>
2013-01-12 08:33:56 +01:00
Takashi Iwai
aa88a3553e 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>
2013-01-12 08:33:54 +01:00
Takashi Iwai
de1e37b7d0 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>
2013-01-12 08:33:43 +01:00
Takashi Iwai
5fdaecdb0d 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>
2013-01-12 08:31:06 +01:00
Takashi Iwai
624d914d09 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>
2013-01-12 08:31:04 +01:00
Takashi Iwai
08c189f2c5 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>
2013-01-12 08:31:03 +01:00