When the HD-audio is removed, it leaves the refcounts when codecs are
powered up (usually yes) in the destructor. For fixing the unbalance,
and cleaning up the code mess, this patch changes the following:
- change pm_notify callback to take the explicit power on/off state,
- check of D3 stop-clock and keep_link_on flags is moved to the caller
side,
- call pm_notify callback in snd_hda_codec_new() and snd_hda_codec_free()
so that the refcounts are proprely updated.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
EPSS parameter should be static, so we can read it once and remember.
This also allows more easily to override the wrong EPSS capability
reported from a codec by changing the flag in the codec
initialization step.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Runtime PM can bring more power saving:
- When the controller is suspended, its parent device will also have a chance
to suspend.
- PCI subsystem can choose the lowest power state the controller can signal
wake up from. This state can be D3cold on platforms with ACPI PM support.
And runtime PM can provide a gerneral sysfs interface for a system policy
manager.
Runtime PM support is based on current HDA power saving implementation. The user
can enable runtime PM on platfroms that provide acceptable latency on transition
from D3 to D0.
Details:
- When both power saving and runtime PM are enabled:
-- If a codec supports 'stop-clock' in D3, it will request suspending the
controller after it enters D3 and request resuming the controller before
back to D0. Thus the controller will be suspended only when all codecs are
suspended and support stop-clock in D3.
-- User IO operations and HW wakeup signal can resume the controller back to
D0.
- If runtime PM is disabled, power saving just works as before.
- If power saving is disabled, the controller won't be suspended because the
power usage counter can never be 0.
More about 'stop-clock' feature:
If a codec can support targeted pass-through operations in D3 state when there
is no BCLK present on the link, it will set CLKSTOP flag in the supported power
states and report PS-ClkStopOk when entering D3 state. Please refer to HDA spec
section 7.3.3.10 Power state and 7.3.4.12 Supported Power State.
[Fixed CONFIG_PM_RUNTIME dependency in hda_intel.c by tiwai]
Signed-off-by: Mengdong Lin <mengdong.lin@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Added a new helper function snd_hda_power_sync() to trigger the
power-saving manually. It's an inline function call to
snd_hda_power_save() helper function.
Together with this addition, snd_hda_power_up*() and
snd_hda_power_down() functions are inlined to a call of the same
snd_hda_power_save() helper function.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This is a preliminary work for the deferred probing for
request_firmware() errors at init.
This patch moves the call of request_firmware() to hda_intel.c, and
call it in the earlier stage of probing rather than
azx_probe_continue().
Tested-by: Thierry Reding <thierry.reding@avionic-design.de>
Reviewed-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Introduced a new flag to set up the PCM stream format at first before
the stream_id and channel tag. Some codecs (e.g. CA0132) seem
preferring this over stream_id -> format order.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This merges the changes for converting to new PM ops for platform
and some other drivers.
Also move some header files to local places from the public
include/sound.
Straightforward conversion to the new pm_ops from the legacy
suspend/resume ops.
Since we change vx222, vx_core and vxpocket have to be converted,
too.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This addresses an issue encountered when a pcm is opened while
transitioning to low power state (codec->power_on == 1 &&
codec->power_transition == -1). Add snd_pcm_power_up_d3wait to
hda_codec. This function is used to power up from azx_open as opposed
to snd_hda_power_up used from codec_exec_verb. When powering up from
azx_open, wait for pending power downs to complete, avoiding the power
up continuing in parallel with the power down on the work queue.
The specific issue seen was with the CS4210 codec, it powers off the ADC
and DAC nid in its suspend handler. If it is re-opened before the
~100ms power down process completes, the ADC and DAC nid are initialized
while powered down and audio is lost until another suspend/resume cycle.
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
add more power states information:
- reset status
- clock stop ok
- power states error
Output like:
Power: setting=D0, actual=D0, Error, Clock-stop-OK, Setting-reset
Signed-off-by: Wang Xingchao <xingchao.wang@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)
iQIcBAABAgAGBQJPvzw3AAoJEGwxgFQ9KSmksMoP/i2gSvr4mCqFlFN1RbHLB7cg
SZ1bccn3SoX72n2zGFUoBiqvup8lwK1Bp9NMOiC2X1rhdPrEvmXP2f/6SoK/aGOM
K/dQ04KmwCNsYmuJMYTexEKOdWL2ufHRfNDfuIppUxHkl4IDSex0ggzDpnzYq4ba
Ufod7K1Cgjt/64ofo/1asLiE6nB0B9p7xafd2GDRipU9bbgO7KGsLMSn8guA711h
Ez1sAjHVOVgzI/D1G/zjqfNTeMrrDQIe5lbbv+1UlECIv9A5E/7CMoO8ofHGFy2K
BePS6rrMsN5xaADR4LyNjoSqGomnvI+fWvrraWU6sJGl0qzdUgBr8BG7aF5U6Qg1
9EokC9M3S+UKSEHhhqFNGIPEdBeDiK8LlcxtDNP3zyU6nEcouKt+1C/dUmNnJK2b
ZYV6JWEs/PhJB9z4LHp0lgDL51H3pNSKkRtZCPnulEGa64wNnqWUWkHQw4rDvbSZ
fscwNMHNXoXg2QfqCQaUBgxjpKqm9jMPOZbx5P4NoEOBYGXjOEDmQsknyh8zbilN
B4nOZyfexMgTaPSwRhMs4ttn2xDaJ//oUjQl6wCHT4S8C/mmFGYtWFzTMTtn0NGh
dFk1g0nv649gjtyitaWAXgDxee6Lgxu0YtvnrHecJcJyS1PYt4sh9vaOrURPlm+A
sj66LuFKtLOj8qkOY273
=to5n
-----END PGP SIGNATURE-----
Merge tag 'hda-switcheroo' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound
Pull VGA-switcheroo audio client support for HD-audio from Takashi Iwai.
This depended on the recent drm pull.
* tag 'hda-switcheroo' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound:
ALSA: hda - unlock on error in azx_interrupt()
ALSA: hda - Support VGA-switcheroo
ALSA: hda - Export snd_hda_lock_devices()
ALSA: hda - Check the dead HDMI audio controller by vga-switcheroo
Like the previous fixes for cache hash accesses, a protection over
accesses to the widget connection list array must be provided.
Together with this action, remove snd_hda_get_conn_list() which can be
always race, and replace it with either snd_hda_get_num_conns() or
snd_hda_get_connections() calls.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
It's a preliminary work for the vga-switcher support.
Export the function to do pseudo-lock for the sound card to be used
in other places.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The amp and caps hashes aren't protected properly for concurrent
accesses. Protect them via a new mutex now.
But it can't be so simple as originally thought: since the update of a
hash table entry itself might trigger the power-up sequence which
again accesses the hash table, we can't cover the whole function
simply via mutex. Thus the update part has to be split from the mutex
and revalidated.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Check the power_transition up/down state instead of boolean bit, so
that the power-up sequence can cancel the pending power-down work
properly. Also, by moving cancel_delayed_work_sync() before the
actual power-up sequence, make sure that the delayed power-down is
completed.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Since the recent commit, the resume procedure is always performed at
the resume time. This makes the pre_resume hack for VREF mute LED on
some HP laptops superfluous. As this is the only user of pre_resume
(and there is no user of post_suspend) ops, let's kill them again.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This is a fix for the problem in commit 785f857d1c, the pop noise
issue on some machines with ALC269. The problem was the uninitialized
state after the resume due to the delayed resume of the codec chips.
In that commit, we tried to fix by forcibly putting the codec to D3 at
suspend. But, this still also leaves the uninitialized state after
resume, and it _might_ be still problematic with some BIOS. Since the
commit turned out to regress another issues, we reverted it in the
end.
Now, in this fix, try to fix by turning on the codec immediately at
the resume path. We need to take care of the power-saving in this
case. When the device is woken up at the power-saved state, it should
go power-saving again after the resume.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The CX20549 has only one single input amp on it's input converter
widget. Fix printing of values in the codec file in /proc/asound.
Signed-off-by: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Some codecs don't supply the mute amp-capabilities although the lowest
volume gives the mute. It'd be handy if the parser provides the mute
mixers in such a case.
This patch adds an extension amp-cap bit (which is used only in the
driver) to represent the min volume = mute state. Also modified the
amp cache code to support the fake mute feature when this bit is set
but the real mute bit is unset.
In addition, conexant cx5051 parser uses this new feature to implement
the missing mute controls.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=42825
Cc: <stable@kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Add a new flag to indicate that the codec has no jack-detection cap.
This flag should be set for hardwares that have no jack-detect
implementation although the codec chip itself supports it.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
So far, the driver supports up to 10 streams. This is a restriction in
hda_intel.c and hda_codec.c: in the former, the fixed array size limits
the amount, and in the latter, the fixed device-number assignment table
(in get_empty_pcm_device()) limits the possibility.
This patch reduces the restriction by
- using linked list for managing PCM instances in hda_intel.c, and
- assigning non-fixed device numbers for the extra devices
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Introduce a table containing the pins and their jack-detection states
for avoiding the unnecessary verbs to check the pin status at each time.
When the unsol event is enabled via snd_hda_jack_detect_enable(), it
automatically adds the given NID to the table. Then the driver supposes
that the codec driver will set the dirty flag appropariately when an
unsolicited event is invoked for that pin.
The behavior for reading other pins that aren't registered in the table
doesn't change. Only the pins assigned to the table are cached, so far.
In near futre, this table can be extended to use the central place for
the unsolicited events of all pins, etc, and eventually include the
jack-detect kcontrols that replace the current input-jack stuff.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
We disabled the check of NO_PRESENCE bit of the default pin-config
in commit f4419172 temporarily. One problem was that the first
implementation was wrong -- the bit after the shift must be checked.
However, this would still give many regressions on machines with broken
BIOS. They set this bit wrongly even on active pins.
A workaround is to check whether all pins contain this bit. As far as
I've checked, broken BIOSen set this bit on all pins, no matter whether
active or not. In such a case, the driver should ignore this bit check.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The procedure for codec D-state change may have exceptional cases
depending on the codec chip, such as a longer delay or suppressing D3.
This patch adds a new codec ops, set_power_state() to override the system
default function. For ease of porting, snd_hda_codec_set_power_to_all()
helper function is extracted from the default set_power_state() function.
As an example, the Conexant codec-specific delay is removed from the
default routine but moved to patch_conexant.c.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Add a new ops, post_suspend(), which is called after suspend() ops is
performed. This is called only in the case of the real PM suspend, and
the codec driver can use this for further changing of D-state or
clearing the LED, etc.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
It makes little sense to enable power-saving without PM.
This removes SND_HDA_NEEDS_RESUME define so that we can use CONFIG_PM
in all places.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Codec state is not restored immediately on resume but on the first
access when power-save is enabled. That leads to an invalid mute led
state after resume until either sound is played or some control is
changed. This patch adds a possibility for a vendor specific patch to
restore codec state immediately after resume if required. And it adds
code to restore IDT codecs state immediately on resume on HP systems
with mute led support.
Signed-off-by: Vitaliy Kulikov <Vitaliy.Kulikov@idt.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
In the codec proc outputs, read the raw connections instead of the
cached connection list, i.e. proc files contain only raw values.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Add a function to add/modify the connection-list cache entry.
It'll be useful to fix a buggy hardware result.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Create snd_hda_get_conn_index() helper function for obtaining the
connection index of the widget. Replaced the similar codes used in
several codec-drivers with this common helper.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Use static inline for dummy function to fix the warnings like below
sound/pci/hda/patch_sigmatel.c: In function ‘stac92xx_init’:
sound/pci/hda/patch_sigmatel.c:4387:3: warning: statement with no effect
sound/pci/hda/patch_sigmatel.c: In function ‘stac92xx_resume’:
sound/pci/hda/patch_sigmatel.c:4927:3: warning: statement with no effect
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Add a new helper function snd_hda_get_conn_list().
Unlike snd_hda_get_connections(), this function doesn't copy the
connection-list but gives the raw pointer for the cached list.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The general concept of this change is to create a PCM device for each
pin widget instead of each converter widget. Whenever a PCM is opened,
a converter is dynamically selected to drive that pin based on those
available for muxing into the pin.
The one thing this model doesn't support is a single PCM/converter
sending audio to multiple pin widgets at once.
Note that this means that a struct hda_pcm_stream's nid variable is
set to 0 except between a stream's open and cleanup calls. The dynamic
de-assignment of converters to PCMs occurs within cleanup, not close,
in order for it to co-incide with when controller stream IDs are
cleaned up from converters.
While the PCM for a pin is not open, the pin is disabled (its widget
control's PIN_OUT bit is cleared) so that if the currently routed
converter is used to drive a different PCM/pin, that audio does not
leak out over a disabled pin.
We use the recently added SPDIF virtualization feature in order to
create SPDIF controls for each pin widget instead of each converter
widget, so that state is specific to a PCM.
In order to support this, a number of more mechanical changes are made:
* s/nid/pin_nid/ or s/nid/cvt_nid/ in many places in order to make it
clear exactly what the code is dealing with.
* We now have per_pin and per_cvt arrays in hdmi_spec to store relevant
data. In particular, we store a converter's capabilities in the per_cvt
entry, rather than relying on a combination of codec_pcm_pars and
the struct hda_pcm_stream.
* ELD-related workarounds were removed from hdmi_channel_allocation
into hdmi_instrinsic in order to simplifiy infoframe calculations and
remove HW dependencies.
* Various functions only apply to a single pin, since there is now
only 1 pin per PCM. For example, hdmi_setup_infoframe,
hdmi_setup_stream.
* hdmi_add_pin and hdmi_add_cvt are more oriented at pure codec parsing
and data retrieval, rather than determining which pins/converters
are to be used for creating PCMs.
This is quite a large change; it may be appropriate to simply read the
result of the patch rather than the diffs. Some small parts of the change
might be separable into different patches, but I think the bulk of the
change will probably always be one large patch. Hopefully the change
isn't too opaque!
This has been tested on:
* NVIDIA GeForce 400 series discrete graphics card. This model has the
classical 1:1:1 codec:converter:pcm widget model. Tested stereo PCM
audio to a PC monitor that supports audio.
* NVIDIA GeForce 520 discrete graphics card. This model is the new
1 codec n converters m pins m>n model. Tested stereo PCM audio to a
PC monitor that supports audio.
* NVIDIA GeForce 400 series laptop graphics chip. This model has the
classical 1:1:1 codec:converter:pcm widget model. Tested stereo PCM,
multi-channel PCM, and AC3 pass-through to an AV receiver.
* Intel Ibex Peak laptop. This model is the new 1 codec n converters m
pins m>n model. Tested stereo PCM, multi-channel PCM, and AC3 pass-
through to an AV receiver.
Note that I'm not familiar at all with AC3 pass-through. Hence, I may
not have covered all possible mechanisms that are applicable here. I do
know that my receiver definitely received AC3, not decoded PCM. I tested
with mplayer's "-afm hwac3" and/or "-af lavcac3enc" options, and alsa a
WAV file that I believe has AC3 content rather than PCM.
I also tested:
* Play a stream
* Mute while playing
* Stop stream
* Play some other streams to re-assign the converter to a different
pin, PCM, set of SPDIF controls, ... hence hopefully triggering
cleanup for the original PCM.
* Unmute original stream while not playing
* Play a stream on the original pin/PCM.
This was to test SPDIF control virtualization.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The SPDIF output controls apply to converter widgets. A future change
will create a PCM device per pin widget, and hence a set of SPDIF output
controls per pin widget, for certain HDMI codecs. To support this, we
need the ability to virtualize the SPDIF output controls. Specifically:
* Controls can be "unassigned" from real hardware when a converter is
not used for the PCM the control was created for.
* Control puts only write to hardware when they are assigned.
* Controls can be "assigned" to real hardware when a converter is picked
to support output for a particular PCM.
* When a converter is assigned, the hardware is updated to the cached
configuration.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Currently, the data that backs the kcontrols created by
snd_hda_create_spdif_out_ctls is stored directly in struct hda_codec. When
multiple sets of these controls are stored, they will all manipulate the
same data, causing confusion. Instead, store an array of this data, one
copy per converter, to isolate the controls.
This patch would cause a behavioural change in the case where
snd_hda_create_spdif_out_ctls was called multiple times for a single codec.
As best I can tell, this is never the case for any codec.
This will be relevant at least for some HDMI audio codecs, such as the
NVIDIA GeForce 520 and Intel Ibex Peak. A future change will modify the
driver's handling of those codecs to create multiple PCMs per codec. Note
that this issue isn't affected by whether one creates a PCM-per-converter
or PCM-per-pin; there are multiple of both within a single codec in both
of those codecs.
Note that those codecs don't currently create multiple PCMs for the codec
due to the default HW mux state of all pins being to point at the same
converter, hence there is only a single converter routed to any pin, and
hence only a single PCM.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The connection lists are static and we can reuse the previous results
instead of querying via verb at each time. This will reduce the I/O
in the runtime especially for some codec auto-parsers.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Since multiple codec drivers already use the input-jack stuff, let's
make common helper functions to reduce the duplicated codes.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The sticky PCM stream assignment introduced in 2.6.36 kernel seems
causing problems on AD codecs. At some time later, the streaming no
longer works by unknown reason. A simple workaround is to disable
sticky-assignment for these codecs.
Tested-by: Vasily Khoruzhick <anarsoul@gmail.com>
Cc: <stable@kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Replace the explicit ifdef check and call of check_power_status ops with
a new helper function, hda_call_check_power_status().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The new sticky PCM parameter introduced the delayed clean-ups of
stream- and channel-id tags. In the current implementation, this check
(adding dirty flag) and actual clean-ups are done only for the codec
chip. However, with HD-audio architecture, multiple codecs can be
on a single bus, and the controller assign stream- and channel-ids in
the bus-wide.
In this patch, the stream-id and channel-id are checked over all codecs
connected to the corresponding bus. Together with it, the mutex is
moved to struct hda_bus, as this becomes also bus-wide.
Reported-and-tested-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The commit eb541337b7
ALSA: hda - Make converter setups sticky
changes the semantics of snd_hda_codec_cleanup_stream() not to clean up
the stream at that moment but delay the action. This broke the codes
expecting that the clean-up is done immediately, such as dynamic ADC
changes in some codec drivers.
This patch fixes the issue by introducing a lower helper,
__snd_hda_codec_cleanup_stream(), to allow the immediate clean up.
The original snd_hda_codec_cleanup_stream() is kept as is now.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
So far, we reset the converter setups like the stream-tag, the
channel-id and format-id in prepare callbacks, and clear them in
cleanup callbacks. This often causes a silence of the digital
receiver for a couple of seconds.
This patch tries to delay the converter setup changes as much as
possible. The converter setups are cached and aren't reset as long
as the same values are used. At suspend/resume, they are cleared
to be recovered properly, too.
Signed-off-by: Takashi Iwai <tiwai@suse.de>