Previously, calling one quirk function first and another later
would make the latter one take priority, this is now changed
to make the former take priority.
By adding two special values for fixup_id we can also get rid of the
fixup_forced flag.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Pass the codec object so that we can replace all the rest of
snd_print*() usages with the proper device-specific print helpers.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The "fixup_forced" flag will indicate whether a specific fixup
(or nofixup) has been set by the user, to override the driver's
default.
This flag will help future patches.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Some sysfs attributes like init_pin_configs or vendor_name are really
basic and should be available no matter whether the codec driver is
re-configurable or not. Put them out of #ifdef
CONFIG_SND_HDA_RECONFIG and allow the read-only accesses.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
We have currently sysfs attributes for each hwdep, but basically these
should belong to the codec itself, per se. Let's add them to the
codec object while keeping them for hwdep as is for compatibility.
While we are at it, split the sysfs-related stuff into a separate
source file, hda_sysfs.c, and keep only the stuff necessary for hwdep
in hda_hwdep.c.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
As the HD-audio is treated individually in each codec driver, it's
more convenient to assign an own struct device to each codec object.
Then we'll be able to use dev_err() more easily for each codec, for
example.
For achieving it, this patch just creates an object "hdaudioCxDy".
It belongs to sound class instead of creating a new bus, just for
simplicity, at this stage. No pm ops is implemented in the device
struct level but currently it's merely a container. The PCM and hwdep
devices are now children of this codec device.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Processing coefficients are often a vital part of the codec's configuration,
so dumping them can be important. However, because they are undocumented and
secret, we do not want to enable this for all codecs by default.
Therefore instead add this as a debugging parameter.
I have prepared for codecs that want to enable this by default by the extra
dump_coef bitfield, but unsure if we want to do that as long as the
(unlikely, but still) race remains.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
So far, CONFIG_SND_HDA_CODEC_* kconfigs have been booleans due to
historical reasons. The major reason was that the automatic codec
driver probing wouldn't work if user sets a codec driver as a module
while the controller driver as a built-in. And, another reason was to
avoid exporting symbols of the helper codes when all drivers are built
in.
But, this sort of "kindness" rather confuses people in the end,
especially makes the config refinement via localmodconfig unhappy.
Also, a codec module would still work if you re-bind the controller
driver via sysfs (although it's no automatic loading), so there might
be a slight use case.
That said, better to let people fallen into a pitfall than being too
smart and restrict something. Let's make things straightforward: now
all CONFIG_SND_HDA_CODEC_* become tristate, and all symbols exported
unconditionally.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Since there are more HD-audio compatible codecs, move the definitions
of HD-audio verbs into common header location, include/sound, so that
it can be included cleanly from other drivers than HD-audio driver.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This patch adds 'depop_delay' to struct hda_codec, to indicate a depop delay
time in ms when power-down, in function set_power_state() to D3.
Default value is -1, for a default delay time.
Machine fixup can set a suitable value according to the codec chip and HW audio
design.
Signed-off-by: Mengdong Lin <mengdong.lin@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
To reduce driver resume time, this patch resumes the codecs in parallel
if there are multiple codecs on the bus.
- The PM workqueue of bus is also used to parallel resuming multiple codecs.
- The work item 'pm_work' is renamed to 'suspend_work' to parallel suspending
codecs.
- Add a work item 'resume_work' to parallel resuming codecs.
Signed-off-by: Mengdong Lin <mengdong.lin@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The time to suspend a single codec may be several hundreds of ms. When runtime
power saving is disabled, driver suspend time can be long especially when there
are more than one codec on the bus.
To reduce driver suspend time, this patch creates a work queue for the bus, and
suspends the codecs in parallel if there are multiple codecs on the bus.
[fixed cosmetic issues by tiwai]
Signed-off-by: Mengdong Lin <mengdong.lin@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
No functional change.
- codec->pm_down_notified flag is renamed to codec->pm_up_notified
flag (and takes the reversed meaning), which is managed solely in
hda_call_pm_notify() now.
- The explicit call of hda_call_pm_notify() is moved into
hda_keep_power_on().
- Removed a redundant call of hda_call_pm_notify() in
snd_hda_power_up(), as it's called in hda_call_codec_resume()
anyway.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Drop the hard dependency on the generic parser code and load / unload
the generic parser code dynamically if built as a module. This allows
us to avoid the generic parser if only HDMI/DP codecs are found.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Use bus->power_keep_link_on instead. The controller shouldn't go to
D3 when the link isn't reset, so essentially avoiding the link reset
means avoiding the runtime PM.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
When HP laptops with mute and mic-record LEDs go to runtime suspend,
these LEDs are turned on forcibly no matter whether GPIO pis are on or
off. This strange behavior seems triggered by resetting the HD-audio
bus link at azx_rutime_suspend(). So, just add a new hda_bus flag to
avoid the link reset at runtime suspend and set it for these HP
machines.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This patch adds two fields to unsolicited response, according to spec HDA040-A:
- Device Entry (bit 20:15)
- Inactive (bit 2)
and show the info in debug message.
Signed-off-by: Mengdong Lin <mengdong.lin@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This patch adds flags and routines to get device list & selection info on
a pin.
To support Display Port 1.2 multi-stream transport (MST) over single DP port,
a pin can support multiple devices. Please refer to HD-A spec Document Change
Notificaton HDA040-A.
A display audio codec can set flag "dp_mst" in its patch, indicating its pins
can support MST. But at runtime, a pin may not be multi-streaming capable and
report the device list is empty, depending on Gfx driver configuration.
Signed-off-by: Mengdong Lin <mengdong.lin@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
When a codec is powered off, some systems don't respond properly after
D3 FG transition, while the driver still expects the response and
tries to fall back to different modes (polling and single-cmd). When
the fallback happens, the driver stays in that mode, and falling back
to the single-cmd mode means it'll loose the unsol event handling,
too.
The unresponsiveness at D3 isn't too serious, thus this fallback is
mostly superfluous. We can gracefully ignore the error there so that
the driver keeps the normal operation mode.
This patch adds a new bit flag for codec read/write, set in the power
transition stage, which is notified to the controller driver via a new
bus->no_response_fallback flag.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
snd_hda_codec_read(), snd_hda_codec_write() & co take the argument
"direct" that indicates whether the given NID is a direct reference or
an indirect reference. However, the indirect reference is practically
unimplemented and never exists. And moreover, we don't need the
indication of indirect reference at this high level, as NID can be
represented in 16bit values at this point.
Meanwhile, there are some cases where it'd be nice to give some
operational options to these functions. So, we can reuse this
argument as a new bit flag! Pretty frugal, eh?
All callers so far pass zero to this argument, thus there is no
behavior change by this replacement.
The real usage of this new bit option will be added in the following
patches.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Add a new codec PCM ops, get_delay(), to obtain the codec/stream-
specific PCM delay count. When it's NULL, nothing changes.
This new feature was requested for CA0132, which has significant
delays in the path depending on the running DSP code.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The commit [dcda58061: ALSA: hda - Add workaround for conflicting
IEC958 controls] introduced a workaround for cards that have both
SPDIF and HDMI devices for giving device=1 to SPDIF control elements.
It turned out, however, that this workaround doesn't work well -
- The workaround checks only conflicts in a single codec, but SPDIF
and HDMI are provided by multiple codecs in many cases, and
- ALSA mixer abstraction doesn't care about the device number in ctl
elements, thus you'll get errors from amixer such as
% amixer scontrols -c 0
ALSA lib simple_none.c:1551:(simple_add1) helem (MIXER,'IEC958
Playback Switch',0,1,0) appears twice or more
amixer: Mixer hw:0 load error: Invalid argument
This patch fixes the previous broken workaround. Instead of changing
the device number of SPDIF ctl elements, shift the element indices of
such controls up to 16. Also, the conflict check is performed over
all codecs found on the bus.
HDMI devices will be put to dev=0,index=0 as before. Only the
conflicting SPDIF device is moved to a different place. The new place
of SPDIF device is supposed by the updated alsa-lib HDA-Intel.conf,
respectively.
Reported-by: Stephan Raue <stephan@openelec.tv>
Reported-by: Anssi Hannula <anssi.hannula@iki.fi>
Cc: <stable@vger.kernel.org> [v3.8]
Signed-off-by: Takashi Iwai <tiwai@suse.de>
A codec may allow software to hide some unused pin/cvt widgets.
Sometimes BIOS does not enable the hidden widgets properly although they are
needed for the board. Thus the driver need to enable them as a board-specific
fixup and the whole tree will change.
This patch implements a common code for rereading codec widgets. So the fixup
code can call it after enabling the hidden widgets.
Signed-off-by: Mengdong Lin <mengdong.lin@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Currently we set the max number of connections to be 32, but there
seems codec that gives longer connection lists like AD1988, and we see
errors in proc output and else. (Though, in the case of AD1988, it's
a list of all codecs connected to a single vendor widget, so this must
be something fishy, but it's still valid from the h/w design POV.)
This patch tries to remove this restriction. For efficiency, we still
use the fixed size array in the parser, but takes a dynamic array when
the size is reported to be greater than that.
Now the fixed array size is found only in patch_hdmi.c, but it should
be fine, as the codec itself can't support so many pins.
Reported-by: Raymond Yau <superquad.vortex2@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Add a hook to struct hda_codec for filtering the target power state of
each widget when powering up/down. The current hackish EAPD check is
implemented as the default hook pointer, too.
This allows codec drivers to implement own power filter. In the
upcoming changes, the generic parser will have the better power filter
based on the active paths.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Since both snd_hda_codec_flush_amp_cache() and
snd_hda_codec_flush_cmd_cache() are called usually at the same time,
we can simply combine them to a single function,
snd_hda_codec_flush_cache().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
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>
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>
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>
Yet another broken hardware workaround: there are hardware indicating
the inverted jack detection bit result.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
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>
Since the fixup code is used commonly, it's worth to move it to the
common place, struct hda_codec, instead of keeping in hda_gen_spec.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
For optimizing the verb executions, a new mechanism to cache the verbs
and amp update commands is introduced. With the new "write to cache
and flush" way, you can reduce the same verbs that have been written
multiple times.
When codec->cached_write flag is set, the further
snd_hda_codec_write_cache() and snd_hda_codec_amp_stereo() calls will
be performed only on the command or amp cache table, but not sent to
the hardware yet. Once after you call all commands and update amps,
call snd_hda_codec_resume_amp() and snd_hda_codec_resume_cache().
Then all cached writes and amp updates will be written to the
hardware, and the dirty flags are cleared.
In this implementation, the existing cache table is reused, so
actually no big code change is seen here. Each cache entry has a new
dirty flag now (so the cache key is now reduced to 31bit).
As a good side-effect by this change, snd_hda_codec_resume_*() will no
longer execute verbs that have been already issued during the resume
phase by checking the dirty flags.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Pass DMA buffer pointers in calls to setup_bdle().
Add DSP loader callback routines to controller.
Add new DSP loader switch to Kconfig to turn off DSP firmware.
Signed-off-by: Ian Minett <ian_minett@creativelabs.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
When the bus reset is performed during the suspend/resume (including
the power-saving too), it calls snd_hda_suspend() and
snd_hda_resume() again, and deadlocks eventually.
For avoiding the recursive call, add a new flag indicating that the PM
is being performed, and don't go to the bus reset mode when it's on.
Reported-and-tested-by: Julian Wollrath <jwollrath@web.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
When 2.1 speakers are detected, use the corresponding channel map
instead of the standard map with front+rear surrounds.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
When both an SPDIF and an HDMI device are created on the same card
instance, multiple IEC958 controls are created with indices=0, 1, ...
But the alsa-lib configuration can't know which index corresponds
actually to which PCM device, and both the SPDIF and the HDMI
configurations point to the first IEC958 control wrongly.
This patch introduces a (hackish and ugly) workaround: the IEC958
controls for the SPDIF device are re-labeled with device=1 when HDMI
coexists. The device=1 corresponds to the actual PCM device for
SPDIF, so it's anyway a better representation. In future, HDMI
controls should be moved with the corresponding PCM device number,
too.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Now that we have a generic unsol mechanism, we can implement a generic
poll loop, which can be used for debugging, or if a codec's unsol
mechanism is broken.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The purpose of this flag is unclear. If the problem is that some machines
have broken misc/NO_PRESENCE bits, they should be fixed by pin fixups.
In addition, this causes jack detection functionality to be flawed on
the M31EI, where there are two jacks without jack detection (which is
properly marked as NO_PRESENCE), but due to ignore_misc_bit, these
jacks are instead being reported as being present but always unplugged.
BugLink: https://bugs.launchpad.net/bugs/939161
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Although HD-audio allows pair-wise channel configurations, only the
fixed channel positions are used in this version. In future, this can
be changed and allow user to modify the channel positions.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The call of pm_notify callback in snd_hda_codec_free() should be with
the check of the current state whether pm_notify(false) is called or
not, instead of codec->power_on check.
For improving the code readability and fixing this inconsistency,
codec->d3_stop_clk_ok is renamed to codec->pm_down_notified, and this
flag is set only when runtime PM down is called. The new name reflects
to a more direct purpose of the flag.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
CONFIG_SND_HDA_POWER_SAVE is no longer an experimental feature and its
behavior can be well controlled via the default value and module
parameter. Let's just replace it with the standard CONFIG_PM.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
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>