Commit Graph

161 Commits

Author SHA1 Message Date
David Henningsson f5662e1cbf ALSA: hda - Refactor quirk picking and change quirk priority
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>
2014-07-22 14:26:50 +02:00
Takashi Iwai 7e9c2eb626 Merge branch 'for-linus' into for-next 2014-06-26 15:49:20 +02:00
Takashi Iwai 6194b99de9 ALSA: hda - Kill the rest of snd_print*() usages
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>
2014-06-25 14:51:23 +02:00
Takashi Iwai 79514d473b ALSA: hda - Kill snd_printd*() in HDMI debug / info prints
Pass codec instance to each function that still prints info and debug
outputs via snd_printd*().

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-06-25 14:51:23 +02:00
David Henningsson a2d2fa02b2 ALSA: hda - Make a SND_HDA_PIN_QUIRK macro
This is cosmetical - it makes the new pin quirk table look better.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-06-24 14:48:31 +02:00
David Henningsson 20531415ad ALSA: hda - Add a new quirk match based on default pin configuration
Normally, we match on pci ssid only. This works but needs new code
for every machine. To catch more machines in the same quirk, let's add
a new type of quirk, where we match on
 1) PCI Subvendor ID (i e, not device, just vendor)
 2) Codec ID
 3) Pin configuration default

If all these three match, we could be reasonably certain that the
quirk should apply to the machine even though it might not be the
exact same device.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-05-26 11:03:53 +02:00
Takashi Iwai 4e76a8833f ALSA: hda - Replace with standard printk
Use dev_err() and co for messages from HD-audio controller and codec
drivers.  The codec drivers are mostly bound with codec objects, so
some helper macros, codec_err(), codec_info(), etc, are provided.
They merely wrap the corresponding dev_xxx().

There are a few places still calling snd_printk() and its variants
as they are called without the codec or device context.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-02-25 12:27:32 +01:00
Takashi Iwai 648a8d276e ALSA: hda - Add sysfs to codec object, too
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>
2014-02-25 12:12:54 +01:00
Takashi Iwai caa751bad4 ALSA: Create sysfs attribute files via groups
Instead of calling each time device_create_file(), create the groups
of sysfs attribute files at once in a normal way.  Add a new helper
function, snd_get_device(), to return the associated device object,
so that we can handle the sysfs addition locally.

Since the sysfs file addition is done differently now,
snd_add_device_sysfs_file() helper function is removed.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-02-25 12:12:49 +01:00
Takashi Iwai f0639272d6 ALSA: hda - Bind with HDMI codec parser automatically
If a codec contains only the digital outputs, it's very likely a
HDMI/DP codec, which isn't supported by the generic parser but via
HDMI codec parser code.  Detect such a case and bind with the proper
parser object if available.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-11-26 13:42:38 +01:00
Takashi Iwai b21bdd0d34 ALSA: hda - Split the generic parser as an individual module
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>
2013-11-26 13:42:38 +01:00
Anssi Hannula 89250f8464 ALSA: hda - hdmi: Add ELD emulation for ATI/AMD codecs
ATI/AMD HDMI/DP codecs do not include standard HDA ELD (EDID-like data)
support.

In place of providing access to an ELD buffer, various vendor-specific
verbs are provided to provide the relevant information. Revision ID 3
and later (0x100300 as reported by procfs codec#X) have support for
providing more information than the previous revisions (but only if
supported by the display driver).

Generate ELD from the information provided by the vendor-specific verbs
on ATI/AMD codecs.

The specification is available at:
http://www.x.org/docs/AMD/AMD_HDA_verbs_v2.pdf

v2: moved code to hda_eld.c and cleaned it up
v3: adapted to hdmi_ops infrastructure

Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
Tested-by: Peter Frühberger <fritsch@xbmc.org> # v2
Tested-by: Olivier Langlois <olivier@trillion01.com> # v2
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-10-24 22:54:13 +02:00
Takashi Iwai a4e9a38b40 ALSA: hda - Move mutex from hda_eld to per_pin in HDMI codec driver
Since the lock is used primarily in patch_hdmi.c, it's better to move
it in the local struct instead of exporting in hda_eld.  The only
functions requiring the lock in hda_eld.c are proc accessors.  So in
this patch, the proc entry and its creation/deletion/accessors are
moved into patch_hdmi.c, together with the mutex lock to pin_spec
struct.

The former proc info functions are exported so that they can be called
from patch_hdmi.c.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-10-17 19:23:45 +02:00
David Henningsson 360fec281e ALSA: hda - add HDA_FIXUP_ACT_FREE action
A fixup which should be called before codec being freed will come
to use in the next patch.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-10-17 14:38:54 +02:00
Takashi Iwai d045c5dc43 ALSA: hda - Fix missing Mic Boost controls for VIA codecs
Some VIA codecs like VT1708S have Mic boost amps in the mic pins but
they aren't exposed in the capability bits.  In the past driver code,
we override the pin caps and create mic boost controls forcibly.
While transition to the generic parser, we lost the mic boost controls
although the pin caps are still overridden, because the generic parser
code checks the widget caps, too.

So this patch adds a new helper function to allow the override of the
given widget capability bits, and makes VIA codecs driver to add the
missing input-amp capability bit.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=59861
Cc: <stable@vger.kernel.org> [v3.9+]
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-06-19 07:54:09 +02:00
Takashi Iwai 06ec56d3c6 ALSA: hda - Fix return value of snd_hda_check_power_state()
The refactoring by commit 9040d102 introduced the new function
snd_hda_check_power_state().  This function is supposed to return true
if the state already reached to the target state, but it actually
returns false for that.  An utterly stupid typo while copy & paste.

Fortunately this didn't influence on much behavior because powering up
AFG usually powers up the child widgets, too.  But the finer power
control must have been broken by this bug.

Cc: <stable@vger.kernel.org> [v3.9+]
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-06-18 07:59:43 +02:00
Takashi Iwai ba615b86d6 ALSA: hda - Don't apply EAPD power filter as default
So far, the driver doesn't power down the widget at going down to D3
when the widget node has an EAPD capability and EAPD is actually set
on all codecs unless codec->power_filter is set explicitly.
This caused a problem on some Conexant codecs, leading to click
noises, and we set it as NULL there.  But it is very unlikely that the
problem hits only these codecs.

Looking back at the development history, this workaround for EAPD was
introduced just for some laptops with STAC9200 codec, then we applied
it blindly for all.  Now, since it's revealed to have an ill effect,
we should disable this workaround per default and apply only for the
known requiring systems.

The EAPD workaround is implemented now as snd_hda_codec_eapd_power_filter(),
and this has to be set explicitly by the codec driver when needed.
As of now, only patch_stac9200() sets this one.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-03-13 18:07:05 +01:00
David Henningsson 4bd038f9d8 ALSA: hda - hdmi: Protect ELD buffer
Because the eld buffer can be simultaneously accessed from both
workqueue context (updating) and process context (kcontrol read),
we need to protect it with a mutex to guarantee consistency.

To avoid holding the mutex while reading the ELD info from the
codec, we introduce a temporary eld buffer.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-02-19 18:28:30 +01:00
David Henningsson 1613d6b46b ALSA: hda - hdmi: Refactor hdmi_eld into parsed_hdmi_eld
For better readability, the information that is parsed out of the
ELD data is now put into a separate parsed_hdmi_eld struct.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-02-19 18:28:22 +01:00
Takashi Iwai 9040d102da ALSA: hda - Add snd_hda_check_power_state() helper function
... for small refactoring.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-24 17:47:17 +01:00
Takashi Iwai 1f57825077 ALSA: hda - Add chained_before flag to the fixup entry
Sometimes we want to call a fixup after applying other existing
fixups, but currently the fixup chain mechanism allows only the call
the others after the target fixup.  This patch adds a new flag,
chained_before, to struct hda_fixup, for allowing the chained call
before the current execution.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-23 18:10:10 +01:00
Takashi Iwai dc870f38e9 ALSA: hda - Combine snd_hda_codec_flush_*_cache() to a single function
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>
2013-01-22 15:25:25 +01:00
Takashi Iwai bc759721fb 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>
2013-01-12 08:44:47 +01:00
Takashi Iwai fd1082159d 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>
2013-01-12 08:44:35 +01:00
Takashi Iwai 62f3a2f718 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>
2013-01-12 08:44:27 +01:00
Takashi Iwai d7fdc00ae5 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>
2013-01-12 08:44:25 +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 c9ce6b260b ALSA: hda - Move fixup code into struct hda_codec
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>
2013-01-12 08:30:45 +01:00
Takashi Iwai 130e5f0642 ALSA: hda/realtek - Add path active flag
... and rewrite the initialization of output paths as a generic
function that is applicable for both i/o directions.

The new flag, active, is introduced to each nid_path entry.  This
indicates whether the given path is active, and it's used for checking
whether a certain widget can be turned off or changed when a path is
no longer used or newly enabled.

It's still used only in the output paths.  More wider adaption for
input and loopback paths will be achieved in the later patch.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-12 08:30:05 +01:00
Takashi Iwai 280e57d544 ALSA: hda - Introduce snd_hda_codec_amp_init*()
The new function snd_hda_codec_amp_init() (and the stereo variant)
initializes the amp value only once at the first access.  If the amp
was already initialized or updated, this won't do anything more.

It's useful for initializing the input amps that are in the part of
the path but never used.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-12 08:30:02 +01:00
Takashi Iwai c370dd6e9f ALSA: hda - Introduce cache & flush cmd / amp writes
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>
2013-01-12 08:29:17 +01:00
Takashi Iwai dda415d418 ALSA: hda - Add a helper function for simple enum kcontrols
The same type of code is being used in multiple places in various
codec drivers, so put it as a core library.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-11-30 18:34:38 +01:00
Takashi Iwai dcda580616 ALSA: hda - Add workaround for conflicting IEC958 controls
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>
2012-10-17 08:42:00 +02:00
Takashi Iwai 83012a7ccb ALSA: hda - Clean up CONFIG_SND_HDA_POWER_SAVE
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>
2012-08-30 07:50:13 -07:00
Takashi Iwai 0401e8548e ALSA: hda - Move beep helper functions to hda_beep.c
Move snd_hda_mixer_amp_switch_put_beep() to hda_beep.c as a clean up
to remove one more ifdef.

Also add the corresponding get callback to return consistently the
digital beep state independently from the mixer amp value.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-07-03 18:31:36 +02:00
Takashi Iwai 128bc4ba8c ALSA: hda - Move BIOS pin-parser code to hda_auto_parser.c
Just code shuffles.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-05-08 18:01:33 +02:00
Takashi Iwai 4740860b53 ALSA: hda - Add snd_hda_get_default_vref() helper function
Add a new helper function to guess the default VREF pin control bits
for mic in.  This can be used to set the pin control value safely
matching with the actual pin capabilities.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-04-20 13:06:53 +02:00
Takashi Iwai cdd03cedc5 ALSA: hda - Introduce snd_hda_set_pin_ctl*() helper functions
For setting the pin-control values more safely to match with the
actual pin capability bits, a copule of new helper functions,
snd_hda_set_pin_ctl() and snd_hda_set_pin_ctl_cache(), are
introduced.  These are simple replacement of the codec verb write with
AC_VERB_SET_PIN_WIDGET but do more sanity checks and filter out
superfluous pin-control bits if they don't fit with the corresponding
pin capabilities.

Some codecs are screwed up or ignore the command when such a wrong bit
is set.  These helpers will avoid such secret errors.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-04-20 12:38:48 +02:00
Takashi Iwai f29735cbef ALSA: hda - Add expose_enum_ctl flag to snd_hda_add_vmaster_hook()
Since it's not always safe to assume that the vmaster hook is purely the
mute-LED control, add the flag indicating whether to expose the mute-LED
enum control or not.  Currently, conexant codec sets this off for non-HP
laptops where EAPD may be used really as EAPD.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-03-13 07:55:10 +01:00
Takashi Iwai d2f344b5e0 ALSA: hda - Add "Mute-LED Mode" enum control
Create snd_hda_add_vmaster_hook() and snd_hda_sync_vmaster_hook()
helper functions to handle the mute-LED in vmaster hook more
commonly.  In the former function, a new enum control "Mute-LED Mode"
is added.  This provides user to choose whether the mute-LED should be
turned on/off explicitly or to follow the master-mute status.

Reviewed-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-03-13 07:46:50 +01:00
Takashi Iwai 29e5853d61 ALSA: hda - Return the created kcontrol in __snd_hda_add_vmaster()
It'll be used for adding hooks in later patches.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-03-12 14:52:28 +01:00
Takashi Iwai 18478e8b62 ALSA: hda - Initialize vmaster slave volumes
When the driver is changed to use vmaster or a new slave element is
added by the improvement of the parser code, user may face often the
silent output because of the muted slave mixer although Master volume
is properly set.  And they complain.  And I get upset.

Although such a mixer element should be initialized via "alsactl init",
it'd be more user-friendly if the known output slaves are unmuted and
set to 0dB so that user can control the volume only with Master as
default.  Since Master is still set muted as default even with this
change, no risk of the speaker blow up, too.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-03-09 17:55:30 +01:00
Takashi Iwai 9322ca5497 ALSA: hda - Add suffix argument to snd_hda_add_vmaster()
In most cases, the slave strings for vmaster are identical between
volumes and switches except for "xxx Volume" and "xxx Switch" suffix.
Now snd_hda_add_vmaster() takes the optional suffix argument so that
each string can be composed with the given suffix, and we can share the
slave name strings in both volume and switch calls nicely.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-02-03 14:28:01 +01:00
Takashi Iwai 3a90274de3 ALSA: hda - Return the error from get_wcaps_type() for invalid NIDs
When an invalid NID is given, get_wcaps() returns zero as the error,
but get_wcaps_type() takes it as the normal value and returns a bogus
AC_WID_AUD_OUT value.  This confuses the parser.

With this patch, get_wcaps_type() returns -1 when value 0 is given,
i.e. an invalid NID is passed to get_wcaps().

Bugzilla: https://bugzilla.novell.com/show_bug.cgi?id=740118

Cc: <stable@kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-01-10 12:41:22 +01:00
Takashi Iwai 31ef225793 ALSA: hda - Integrate input-jack stuff into kctl-jack
Instead of managing input-jack stuff separately, call all stuff inside
the kctl-jack creation, deletion and report.  The caller no longer needs
to care about input-jack.

The better integration between input-jack and kctl-jack should be done
in the upper layer in near future, but for now, it's implemented locally
for more tests.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-12-01 17:47:54 +01:00
Takashi Iwai 201e06ffa9 ALSA: hda - Give more unique names by snd_hda_get_pin_label()
The function now gives more unique names for the output pins by adding
some prefix and suffix for the location and the channels.  Otherwise, it
can pass the index number.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-11-16 15:48:23 +01:00
Takashi Iwai aad37dbd56 ALSA: hda - Merge input-jack helpers to hda_jack.c
We can use the very same table in hda_jack.c for managing the list for
input-jack elements, too.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-11-16 11:14:04 +01:00
Takashi Iwai 1835a0f9a2 ALSA: hda - Cache the jack-detection value
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>
2011-11-16 11:11:15 +01:00
Takashi Iwai 04f5ade6af ALSA: hda - Introduce snd_hda_get_pin_label()
Create a new helper function snd_hda_get_pin_label() for getting a label
string for both input and output pins.  hda_get_input_pin_label() is
obsoleted by this function, and the callers are replaced appropriately
now by this patch.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-11-16 11:10:16 +01:00
Wu Fengguang b95d68b817 ALSA: hda - fix ELD memory leak
memset(eld) clears eld->proc_entry which will leak the struct
snd_info_entry when unloading module.

Fix it by
- memset only the fields before eld->eld_buffer
- set eld->eld_valid to true _after_ all eld fields have been filled

Cc: <stable@kernel.org>
Cc: Pierre-louis Bossart <pierre-louis.bossart@intel.com>
Acked-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-11-16 10:44:21 +01:00