Commit graph

349 commits

Author SHA1 Message Date
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 785f857d1c ALSA: hda - Set codec to D3 forcibly even if not used
We've seen a problem with a pop-noise at suspend/resume on a HP
machine with ALC269, and it turned out to be an issue that the
controller going to D3 while the codec is unused.

When the device is once suspended and resumed and kept unused, the
driver doesn't initialize the codecs.  Instead, the codec chips are
set up dynamically at the first usage.  Now, suppose the device going
to suspend again before the codec is set up.  The controller is turned
off to D3 while the codec chips are untouched.  This caused a pop
noise because the codec chip might have been turned on implicitly by
the hardware.

As a workaround, the codec chip needs to be set to D3 when going to
suspend no matter whether it was used or not.  Also, for making it
happening, the controller has to be always set up in the resume path.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-03-07 11:52:50 +01:00
Takashi Iwai 7c589750a7 Merge branch 'fix/hda' into topic/hda
Speaker-Out renames are merged.

Conflicts:
	sound/pci/hda/patch_realtek.c
2012-03-02 09:00:33 +01:00
Takashi Iwai e49a3434f1 ALSA: hda - Kill hyphenated names
Kill hyphens from "Line-Out" name strings, as suggested by Mark Brown.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-03-02 08:59:23 +01:00
Takashi Iwai 3868137ea4 ALSA: hda - Add a fake mute feature
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>
2012-02-29 17:32:38 +01:00
Takashi Iwai fc9e5c6f42 ALSA: hda - Remove a debug print in vmaster code
Wrongly slipped in from the commit 9322ca54.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-02-06 14:46:01 +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
David Henningsson 54c2a89f60 ALSA: HDA: Fix duplicated output to more than one codec
This typo caused the wrong codec's nid to be checked for wcaps type.
As a result, sometimes speakers would duplicate the output sent to
HDMI output.

Cc: stable@kernel.org
BugLink: https://bugs.launchpad.net/bugs/924320
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-02-01 12:13:16 +01:00
Takashi Iwai 78c058df6a Merge branch 'test/hda-jack' into topic/hda
Conflicts:
	sound/pci/hda/patch_hdmi.c
	sound/pci/hda/patch_via.c
2011-12-20 15:42:57 +01:00
Takashi Iwai 01b65bfb4f ALSA: hda - Supports more audio streams
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>
2011-11-26 10:19:44 +01:00
Takashi Iwai e2301a4de2 ALSA: hda - Check subdevice mask in snd_hda_check_board_codec_sid_config()
In snd_hda_check_board_codec_sid_config(), not only comparing with the
exact value but allow the bit-mask comparison for vendor-only, etc.

Tested-by: Linus Torvalds <torvalds@linux-foundation.org>
Tested-by: Dirk Hohndel <hohndel@infradead.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-11-23 07:31:36 +01:00
Takashi Iwai 358b6e62b8 ALSA: hda - Don't add channel suffix for headphone pin labels
The multiple headphone pins are usually handled as copied from the same
source, not as individual channels like front and surround.  Thus it'd
be more correct to avoid the channel suffix for "Headphone" pin labels
in snd_hda_get_pin_label() but give an index number instead.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-11-21 14:34:20 +01:00
Takashi Iwai d6018bb566 ALSA: hda - Fix a typo
Reported-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-11-21 14:19:00 +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
Takashi Iwai 2f451d2a2a ALSA: hda - Re-enable the check NO_PRESENCE misc bit
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>
2011-11-10 12:36:46 +01:00
Takashi Iwai aeb4b88ec0 ALSA: hda - Don't add elements of other codecs to vmaster slave
When a virtual mater control is created, the driver looks for slave
elements from the assigned card instance.  But this may include the
elements of other codecs when multiple codecs are on the same HD-audio
bus.  This works at the first time, but it'll give Oops when it's once
freed and re-created via reconfig sysfs.

This patch changes the element-look-up strategy to limit only to the
mixer elements of the same codec.

Reported-by: David Henningsson <david.henningsson@canonical.com>
Cc: <stable@kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-11-10 12:32:08 +01:00
Paul Gortmaker da155d5b40 sound: Add module.h to the previously silent sound users
Lots of sound drivers were getting module.h via the implicit presence
of it in <linux/device.h> but we are going to clean that up.  So
fix up those users now.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2011-10-31 19:31:21 -04:00
Takashi Iwai 8fa7ab48ac ALSA: hda - Fix surround/CLFE headphone and speaker pins order
When 5.1 or more headphone or speaker pins are provided, the parser still
takes as is without fixing the order of channel mapping, which leads in
the unexpected strange channel order by surround outputs.

This patch fixes the issue by applying the same fix-up not only to
line_out_pins[] but also hp_pins[] and speaker_pins[].

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-10-26 16:26:18 +02:00
Takashi Iwai f71ff0d713 ALSA: hda - Moved snd_print_pcm_rates() back into hda_proc.c
Since hda_proc.c is now the only user of snd_print_pcm_rates(), better to
put it back locally to hda_proc.c and revert to the old style.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-10-06 08:21:15 +02:00
Pierre-Louis Bossart af65cbf296 ALSA: hdmi: fix printout of SAD sampling rates
SAD sampling rate information reported in
/proc/asound/cardX/eldX is incorrect due to a mismatch
between HDA and HDMI frequencies. Add new routine to provide
relevant values.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-10-06 08:08:53 +02:00
David Henningsson 7c2f8e4009 ALSA: jack - Add "Line In" input jack constants
Similar to Line Out, these constants form the base for future
patches enabling input jack reporting for Line in jacks.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-10-05 17:22:04 +02:00
Takashi Iwai 218264ae9a ALSA: hda - Avoid unnecessary verbs to clear PCM formats
Since really_cleanup_stream() is called from both purity_inactive_streams()
and hda_cleanup_all_streams(), the verbs to clear the PCM channel and
format may be called multiple times unnecessarily.

This patch adds checks to skip these unneeded verbs.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-09-27 17:33:45 +02:00
Takashi Iwai 290b421f69 Merge branch 'fix/hda' into topic/hda 2011-09-20 09:14:04 +02:00
Takashi Iwai 99e14c9d41 ALSA: hda - Terminate the recursive connection search properly
The recursive search of widget connections in snd_hda_get_conn_index()
must be terminated at the pin and the audio-out widgets.  Otherwise
you'll get "too deep connection" warnings unnecessarily.

Reported-by: Francis Moreau <francis.moro@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-09-13 10:33:16 +02:00
Takashi Iwai a06dbfc2cf ALSA: hda - Add multi-headphone NIDs in multiout struct
For supporting both the multiple headphones and the multiple speakers,
add the new field in struct hda_multi_out, and evaluate in the standard
setup functions.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-08-23 18:16:13 +02:00
Takashi Iwai d025febcd8 ALSA: hda - Rename to snd_hda_parse_pin_defcfg()
... and add a new bit-flags argument to specify the behavior of the
function.  The older function is kept as is (as a wrapper).

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-08-23 15:24:39 +02:00
Takashi Iwai 965f1b2e19 ALSA: hda - Allow different assoc numbers for multiple speakers
In snd_hda_parse_pin_def_config(), we checked the associated number
of speaker pins and accepts only one number exclusively.  But many BIOS
seem to give different assoc number for surround speakers, thus we'd
better to accept all speaker pins no matter which assoc number, and sort
like done for the headphone pins.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-08-19 09:10:29 +02:00
Takashi Iwai f57c25650b ALSA: hda - Add snd_hda_override_pin_caps() helper function
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-08-15 12:49:07 +02:00
Takashi Iwai ecf726f541 ALSA: hda - Add tracepoint for unsolicited events
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-08-09 14:24:17 +02:00
Takashi Iwai d66fee5d65 ALSA: hda - Add basic tracepoints
Add a few tracepoints to HD-audio driver.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-08-04 17:02:37 +02:00
Takashi Iwai 4d7fbdbcb1 ALSA: hda - Allow codec-specific set_power_state ops
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>
2011-07-26 17:21:24 +02:00
Takashi Iwai e581f3dba5 ALSA: hda - Add post_suspend patch ops
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>
2011-07-26 17:21:23 +02:00
Takashi Iwai 2a43952a99 ALSA: hda - Make CONFIG_SND_HDA_POWER_SAVE depending on CONFIG_PM
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>
2011-07-26 17:21:18 +02:00
Vitaliy Kulikov d02667e620 ALSA: hda - Fix invalid mute led state on resume of IDT codecs
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>
2011-07-26 09:38:36 +02:00
Takashi Iwai 76531d4166 Merge branch 'topic/hda' into for-linus 2011-07-22 08:43:27 +02:00
Takashi Iwai 00ef9610ac ALSA: hda - Fix krealloc() replacement in hda_codec.c
It was obviously wrong, grr....

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-07-14 15:58:02 +02:00
Takashi Iwai 3101ba035c ALSA: Use krealloc() in possible places
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-07-12 08:05:16 +02:00
Takashi Iwai 9e7717c9eb ALSA: hda - Always read raw connections for proc output
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>
2011-07-12 07:45:01 +02:00
Takashi Iwai b2f934a0df ALSA: hda - Add snd_hda_override_conn_list() helper function
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>
2011-07-12 07:44:46 +02:00
Takashi Iwai 8d087c7600 ALSA: hda - Create snd_hda_get_conn_index() helper function
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>
2011-06-29 08:01:46 +02:00
Takashi Iwai dce2079b89 ALSA: hda - Add snd_hda_get_conn_list() helper function
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>
2011-06-25 09:19:49 +02:00
Takashi Iwai 1af7c5f0d4 ALSA: hda - Add a workaround for invalid line-out setups
Some BIOS set up the pin config wrongly as line-out although it's
supposed to be a speaker out.  In most cases, though, we can judge
the validity by checking the connection type -- when it's FIXED,
mostly it's an invalid line-out but a speaker.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-06-24 10:43:03 +02:00
Greg Thelen 9857edfd4d ALSA: hda: check make_exec_verb() return value
If given a -1 cmd parameter then make_exec_verb() returns -1 without
setting the res output value.

Prior to this change snd_hda_codec_read() assumed that make_exec_verb()
unconditionally set res regardless of the cmd value.

This change explicitly checks the make_exec_verb() return value before
consuming the potentially unset res value.

Signed-off-by: Greg Thelen <gthelen@google.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-06-13 17:52:06 +02:00
Stephen Warren 384a48d715 ALSA: hda: HDMI: Support codecs with fewer cvts than pins
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>
2011-06-06 12:58:14 +02:00
Stephen Warren 74b654c957 ALSA: hda: Virtualize SPDIF out controls
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>
2011-06-06 12:51:59 +02:00