Commit graph

316 commits

Author SHA1 Message Date
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
Stephen Warren 7c93597627 ALSA: hda: Allow multple SPDIF controls per codec
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>
2011-06-06 12:48:59 +02:00
Takashi Iwai 0b6267376d ALSA: hda - Use snd_printd() in snd_hda_parse_pin_def_config()
Fixed the wrong usage of snd_printdd() for debug prints of input
entries.  It should be snd_printd() like others.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-05-26 14:10:44 +02:00
David Henningsson 07acecc111 ALSA: HDA: Add jack detection for HDMI
Just as for headphones and microphone jacks, this patch adds reporting
of HDMI jack status through the input layer.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-05-19 12:00:50 +02:00
Takashi Iwai dda144103c ALSA: hda - Constify some API function arguments
Also fixed the assignment of multiout.dac_nids to satisfy const.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-05-02 12:07:48 +02:00
Takashi Iwai 031024eea8 ALSA: hda - Constify some API function arguments
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-05-02 11:29:30 +02:00
Takashi Iwai a3ea8e8f24 Merge branch 'fix/hda' into topic/hda 2011-05-02 10:41:40 +02:00
Takashi Iwai c2de187e5b ALSA: hda - Show the line-out type in snd_hda_parse_pin_def_config()
Helpful for debugging.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-04-29 13:01:33 +02:00
Takashi Iwai 31d44b57c5 Merge branch 'fix/hda' into topic/hda 2011-04-26 15:05:39 +02:00
Takashi Iwai 6a9a6f233b Merge branch 'fix/hda' into for-linus 2011-04-21 12:44:38 +02:00
Mike Waychison 1c7276cfc0 ALSA: hda - Fix unused warnings when !SND_HDA_NEEDS_RESUME
When SND_HDA_NEEDS_RESUME is not defined, the compiler identifies that
the following symbols are static but not used:

 restore_shutup_pins
 hda_cleanup_all_streams

Fix warnings by adding SND_HDA_NEEDS_RESUME guards.

Signed-off-by: Mike Waychison <mikew@google.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-04-20 21:24:31 +02:00
Andrew Morton 5b17b077eb ALSA: hda - sound/pci/hda/hda_codec.c: fix warning
sound/pci/hda/hda_codec.c: In function 'snd_hda_get_connections':
sound/pci/hda/hda_codec.c:332: warning: unused variable 'j'

Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-04-15 08:41:22 +02:00
Takashi Iwai a12d3e1e1c ALSA: hda - Remember connection lists
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>
2011-04-07 15:55:15 +02:00
Lucas De Marchi 25985edced Fix common misspellings
Fixes generated by 'codespell' and manually reviewed.

Signed-off-by: Lucas De Marchi <lucas.demarchi@profusion.mobi>
2011-03-31 11:26:23 -03:00
Takashi Iwai cd372fb3be ALSA: hda - Make common input-jack helper functions
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>
2011-03-03 14:40:14 +01:00
Takashi Iwai ea73496324 ALSA: hda - consitify string arrays
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-01-18 07:43:17 +01:00
Takashi Iwai b2d0576055 ALSA: hda - Fix multi-headphone handling for Realtek codecs
When multiple headphone pins are defined without line-out pins, the
driver takes them as primary outputs.  But it forgot to set line_out_type
to HP by assuming there is some rest of HP pins.  This results in some
mis-handling of these pins for Realtek codec parser.  It takes as if
these are pure line-out jacks.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Cc: <stable@kernel.org>
2011-01-10 14:51:32 +01:00
Takashi Iwai 1afe206ab6 ALSA: hda - Try to find an empty control index when it's occupied
When a mixer control element was already created with the given name,
try to find another index for avoiding conflicts, instead of breaking
with an error.  This makes the driver more robust.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2010-12-23 10:22:55 +01:00
Takashi Iwai 0e7adbe263 ALSA: hda - Disable sticky PCM stream assignment for AD codecs
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>
2010-10-25 10:39:23 +02:00
Takashi Iwai 62b7e5e09b ALSA: hda - Add workarounds for CT-IBG controllers
Creative IBG controllers require the playback stream-tags to be started
from 1, instead of capture+1.  Otherwise the stream stalls.

Reported-by: Wai Yew CHAY <wychay@ctl.creative.com>
Cc: <stable@kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2010-10-22 17:15:47 +02:00
Takashi Iwai c08d91695b ALSA: tlv - Define numbers in sound/tlv.h
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2010-10-17 10:46:14 +02:00
Clemens Ladisch de8c85f784 ALSA: HDA: Sigmatel: work around incorrect master muting
The HDA specification does not allow for a codec to mute itself just
because the volume is reduced, so _of course_ somebody had to go and do
it.  This wouldn'\''t hurt too much when the volume is adjusted by hand,
but programs like PA that try to set the volume automatically could
inadvertently mute the output.

To work around this, change the TLV dB information for the Master volume
on all Sigmatel HDA codecs to indicate the the minimal volume setting
actually mutes.

Reported-by: Colin Guthrie <gmane@colin.guthr.ie>
Reported-by: "Alexander E. Patrakov" <patrakov@gmail.com>
Tested-by: Colin Guthrie <cguthrie@mandriva.org>
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2010-10-17 10:45:30 +02:00
Takashi Iwai 9e5341b92d ALSA: hda - Introduce hda_call_check_power_status() helper
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>
2010-09-21 10:00:03 +02:00
Takashi Iwai 99ae28bea9 ALSA: hda - Make snd_hda_get_input_pin_attr() helper
Make the helper function to give the input-pin attribute for jack
connectivity and location.  This simplifies checks of input-pin jacks
a bit in some places.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2010-09-17 14:42:34 +02:00
Takashi Iwai 41c89ef3aa ALSA: hda - Fix mic attribute check for internal mics
Now Windows claims that the BIOS sets pins for internal mics to be
BOTH connection instead of FIXED.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2010-09-17 10:28:20 +02:00
Takashi Iwai 4a4d4a6985 ALSA: hda - Sort input pins in snd_hda_parse_pin_def_config()
Sort inputs[] array in autocfg so that the codec parsers can filter out
easily per input pin types.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2010-09-09 22:22:02 +02:00
Takashi Iwai 990061c28a ALSA: hda - Add comments to new helper functions
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2010-09-09 22:08:44 +02:00
Takashi Iwai a1c9851583 ALSA: hda - Reduce redundant mic location prefix in input source labels
When the mic pins are assigned to the same location, we can omit the
redundant location prefix like "Front" or "Rear".

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2010-09-09 21:36:27 +02:00
Takashi Iwai 10a20af7c9 ALSA: hda - Improve the input source name labels
This patch improves the input-source label strings to be generated from
the pin information instead of fixed strings per AUTO_PIN_* type.
This gives more suitable labels, especially for mic and line-in pins.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2010-09-09 16:46:03 +02:00
Takashi Iwai 86e2959a10 ALSA: hda - Remove AUTO_PIN_FRONT_{MIC|LINE}
We can assign multiple pins to a single role now, let's reduce the
redundant FRONT_MIC and FRONT_LINE.  Also, autocfg->input_pins[] is
no longer used, so this is removed as well.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2010-09-09 16:46:01 +02:00
Takashi Iwai b5786e85cb ALSA: hda - Keep char arrays in input_mux items
Keep char array in the input_mux item itself instead of pointing to
an external string.  This is a preliminary work for improving the
input-mux name based on the pin role.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2010-09-09 16:45:58 +02:00
Takashi Iwai 03642c9a44 ALSA: hda - Clear left-over hp_pins in snd_hda_parse_pin_def_config()
In snd_hda_parse_def_config(), some unused values may remain in hp_pins[]
array during the headphone-reassignment workaround.  This patch clears
the unused array members.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2010-09-08 15:30:20 +02:00
Takashi Iwai eb7f80c179 Merge branch 'fix/hda' into topic/hda 2010-09-08 15:28:03 +02:00
Takashi Iwai 122661b678 ALSA: hda - Fix wrong HP pin detection in snd_hda_parse_pin_def_config()
snd_hda_parse_pin_def_config() has some workaround for re-assigning
some pins declared as headphones to line-outs.  This didn't work properly
for some cases because it used memmove() stupidly wrongly.

Reference: Novell bnc#637263
	https://bugzilla.novell.com/show_bug.cgi?id=637263

Cc: <stable@kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2010-09-08 14:59:26 +02:00