Commit graph

4418 commits

Author SHA1 Message Date
Mengdong Lin
2bd1f73f42 ALSA: hda - remove controller dependency on i915 power well for Baytrail/Braswell
For Baytrail (Valleyview) and Braswell (Cherryview), only the HDMI codec is
in the display power well while the HD-A controller isn't. So the controller
flag 'need_i915_power' is not set to release the display power after probe,
and the codec flag 'link_power_control" is set to request/release the display
power via bus link_power ops.

Signed-off-by: Mengdong Lin <mengdong.lin@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-29 12:27:54 +02:00
Mengdong Lin
795614dde4 ALSA: hda - divide controller and codec dependency on i915 gfx power well
This patch can improve power saving for Intel platforms on which only the
display audio codec is in the shared i915 power well:

- Add a flag "need_i915_power" to indicate whether the controller needs the
  i915 power well.

- The driver will always request the i915 power when probing the controller
  and codecs if AZX_DCAPS_I915_POWERWELL is set (either the controller or a
  codec needs this power).

- If the controller needs the i915 power, the power will be held after probe
  until the controller is runtime suspended or S3. If the controller doesn't
  need the power, the power will be released the after probe, and a codec
  that needs the power can request/release the power via bus link_power ops.

Background:
- For Haswell/Broadwell, which has a separate HD-A controller for display audio,
  both the controller and the display codec are in the i915 power well.

- For Baytrail/Braswell, the display and analog audio share the same HDA
  controller and link, and only the display codec is in the i915 power well.

- For Skylake, the display and analog audio share the same HDA controller but
  use separate links. Only the display codec is in the i915 power well. And in
  legacy mode we take the two links as one. So it can follow Baytrail/Braswell.

Signed-off-by: Mengdong Lin <mengdong.lin@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-29 12:27:53 +02:00
Mengdong Lin
17eccb27fc ALSA: hda - implement link_power ops for i915 display power control
This patch implements the bus link_power ops to request/release i915 display
power well. It can be used by the display codec which shares this power well
with GPU on Intel platforms.

Signed-off-by: Mengdong Lin <mengdong.lin@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-29 12:27:53 +02:00
Mengdong Lin
a5e7e07c26 ALSA: hda - allow a codec to control the link power
A flag "link_power_control" is added to indicate whether a codec needs to
control the link power.  And a new bus ops link_power() is defined for the
codec to request to enable/disable the link power.

Signed-off-by: Mengdong Lin <mengdong.lin@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-29 12:27:52 +02:00
Mengdong Lin
d4b7b13e19 ALSA: hda - implement a refcount for i915 power well switch
This is to check the refcount of audio driver and reduce calling to i915.

Signed-off-by: Mengdong Lin <mengdong.lin@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-29 12:27:52 +02:00
Takashi Iwai
0dd76f36ef ALSA: hda - Replace open codes with snd_hdac_stream_set_params()
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-18 09:59:38 +02:00
Takashi Iwai
6d23c8f544 ALSA: hda - Move prepared flag into struct hdac_stream
This flag seems used commonly, so deserves to be located there.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-17 13:34:30 +02:00
Takashi Iwai
0a50575b64 ALSA: hda - Replace hda_bus_ops with static binding
Originally hda_bus takes its own ops (hda_bus_ops) to allow different
controller drivers giving individual implementations of PCM
attachment, etc.  But this never happened and we finally merged both
codec and controller helper codes.  Thus there is no merit to keep the
indirect accesses to functions via hda_bus_ops.

This patch replaces these calls with the direct local function calls
for simplification.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-16 23:40:09 +02:00
Takashi Iwai
1604eeee88 ALSA: hda - Drop azx_sd_read*/write*() macros
They are no longer used (only one place which can be replaced with a
proper helper function).  Let's drop.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-16 12:14:17 +02:00
Takashi Iwai
4cfe99c7f9 ALSA: hda/tegra - Fix build error and warning
I seem to have failed to run the build test properly...
   sound/pci/hda/hda_tegra.c: In function 'hda_tegra_dev_free':
   sound/pci/hda/hda_tegra.c:310:20: error: 'bus' undeclared (first use in this function)
         snd_hdac_bus_exit(bus);

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-16 12:07:24 +02:00
Takashi Iwai
43db4a59ce ALSA: hda - Reenable tracepoints for controller
After correcting the fields to point the right members, tracepoints
can be reenabled again for the legacy controller code.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-16 11:45:26 +02:00
Takashi Iwai
b7d023e114 ALSA: hda - Move PCM format and rate handling code to core library
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-16 08:47:28 +02:00
Takashi Iwai
602518a21b ALSA: hda - Minor refactoring
Move the small portion of the common sequence in hda_intel.c and
hda_tegra.c into hda_controller.c.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-16 08:47:28 +02:00
Takashi Iwai
a41d122449 ALSA: hda - Embed bus into controller object
... and replace with the existing hda-core helper codes.
This reduces lots of lines, finally.

Since struct hda_bus is now embedded into struct azx,
snd_hda_bus_new() is moved and expanded from hda_codec.c to
hda_controller.c, accordingly.  Also private_free bus ops and
private_data field are removed because we no longer need to point azx
object from bus (we can use container_of())

The spin locks are consolidated into the single one, bus->reg_lock.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-16 08:47:22 +02:00
Takashi Iwai
ccc98865aa ALSA: hda - Migrate more hdac_stream codes
... including dsp loader helpers.  Lots of codes removed.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-16 07:37:02 +02:00
Takashi Iwai
7833c3f85b ALSA: hda - Migrate hdac_stream into legacy driver
Embed hdac_stream object into azx_dev, and use a few basic helper
functions.  The most of helper codes for hdac_stream aren't still used
yet.

Also this commit disables the tracepoints temporarily due to build
problems.  It'll be enabled again later.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-16 07:36:16 +02:00
Takashi Iwai
a43ff5baa5 ALSA: hda - Pass bus io_ops directly from the top-level driver
One less redirection again.  This also requires the change of the call
order in the toplevel divers.  Namely, the bus has to be created at
first before other initializations since the memory allocation ops are
called through bus object now.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-16 07:31:48 +02:00
Takashi Iwai
7e8be1b309 ALSA: hda - Move send_cmd / get_response to hdac_bus_ops
One less redirection.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-16 07:31:41 +02:00
Takashi Iwai
fb3b07c289 ALSA: hda - Merge codec and controller helpers
There is no much merit to keep the HD-audio codec and controller
helper codes in separate modules any longer.  Let's merge them into a
single helper module.

This patch just changes Makefile entries to merge two individual
modules to one.  The only code change is the removal of superfluous
MODULE_*() macros in one side.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-16 07:31:31 +02:00
Takashi Iwai
8f3f600b52 ALSA: hda - Add DSP loader to core library code
Copied from the legacy driver code, no transition done yet.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-16 07:28:27 +02:00
Takashi Iwai
1475241272 ALSA: hda - Add the controller helper codes to hda-core module
This patch adds the controller helper codes to hda-core library.
The I/O access ops are added to the bus ops.  The CORB/RIRB, the basic
attributes like irq# and iomap address, some locks and the list of
streams are added to the bus object, together with the stream object
and its helpers.

Currently the codes are just copied from the legacy driver, so you can
find duplicated codes in both directories.  Only constants are removed
from the original hda_controller.h.  More integration work will follow
in the later patches.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-16 07:27:58 +02:00
Takashi Iwai
cad372f1be ALSA: hda - Handle error from get_response bus ops directly
... and drop bus->rirb_error flag.  This makes the code simpler.

We treat -EAGAIN from get_response ops as a special meaning: it allows
the caller to retry after bus reset.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-14 14:54:57 +02:00
Jo-Philipp Wich
f2aa111041 ALSA: hda/realtek - Enable the ALC292 dock fixup on the Thinkpad T450
The Lenovo Thinkpad T450 requires the ALC292_FIXUP_TPT440_DOCK as well in
order to get working sound output on the docking stations headphone jack.

Patch tested on a Thinkpad T450 (20BVCTO1WW) using kernel 4.0-rc7 in
conjunction with a ThinkPad Ultradock.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-13 13:23:40 +02:00
Takashi Iwai
9a4f35865f Merge branch 'for-next' into for-linus 2015-04-13 10:23:18 +02:00
Yves-Alexis Perez
c0278669fb ALSA: hda - Add dock support for ThinkPad X250 (17aa:2226)
This model uses the same dock port as the previous generation.

Signed-off-by: Yves-Alexis Perez <corsac@debian.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-11 17:25:37 +02:00
Takashi Iwai
f4d3129c2b ALSA: hda/realtek - Fix a typo
A comma was used instead of a semicolon, which may lead to a build
error.

Fixes: cffd396681 ('ALSA: hda/realtek - Fix the regression by widget power-saving')
Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-10 09:53:04 +02:00
Takashi Iwai
cfd3113e7c ALSA: hda/via - Add missing stream_pm ops setup
Similar like the case for Realtek, VIA codec driver needs this ops as
well for making the widget power-save working.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-09 15:23:59 +02:00
Takashi Iwai
cffd396681 ALSA: hda/realtek - Fix the regression by widget power-saving
While enabling the widget power-saving for ALC269 & co, the important
setup was forgotten -- stream_pm ops.  Without this setup, the paths
for PCM won't be powered up at all.

Also, the power_filter callbacks used in ALC269 & co need to chain to
the default snd_hda_gen_path_power_filter().

Tested-by: Hui Wang <hui.wang@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-09 12:09:57 +02:00
Takashi Iwai
24fef9022a ALSA: hda/generic - Don't override power_filter when power_save_node is set
Currently the generic parser sets codec->power_filter when
power_save_node flag is set.  But this overrides the existing filter
that has been already set by the codec driver, thus it looses some
features.  Instead, set the default power_filter only when it's not
set yet.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-09 10:34:00 +02:00
Takashi Iwai
b6c09b3c7b ALSA: hda/generic - Make snd_hda_gen_path_power_filter() always applicable
Add the check of power_save_node flag at the beginning of the function
so that it skips the rest if the flag isn't set.  In this way, we can
call this function safely no matter whether the widget power-saving is
really used or not.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-09 10:33:53 +02:00
Takashi Iwai
d5ac0100a9 ALSA: hda/generic - Fix wrong initial power state for fixed pins
When the widget power-saving is enabled, the first automute hook
invocation checks through the whole pins and it also tries to
synchronize the power state.  However, this results in a wrong state
because it calls unconditionally snd_hda_jack_detect_state().
This patch adds a check of jack detectability before the actual jack
detection call.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-09 10:33:44 +02:00
Takashi Iwai
2206dc9492 ALSA: hda/generic - Check power state cap at updating the widget power
The new widget power-saving tries to apply the power change no matter
whether the node has a power cap or not.  It's bad (although most of
codecs chip just ignore it).  Check the capability properly
beforehand.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-09 10:33:16 +02:00
Takashi Iwai
cc7016ab1a ALSA: hda - Fix headphone pin config for Lifebook T731
Some BIOS version of Fujitsu Lifebook T731 seems to set up the
headphone pin (0x21) without the assoc number 0x0f while it's set only
to the output on the docking port (0x1a).  With the recent commit
[03ad6a8c93: ALSA: hda - Fix "PCM" name being used on one DAC when
 there are two DACs], this resulted in the weird mixer element
mapping where the headphone on the laptop is assigned as a shared
volume with the speaker and the docking port is assigned as an
individual headphone.

This patch improves the situation by correcting the headphone pin
config to the more appropriate value.

Reported-and-tested-by: Taylor Smock <smocktaylor@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-08 20:52:52 +02:00
Takashi Iwai
664c715573 ALSA: hda - Work around races of power up/down with runtime PM
Currently, snd_hdac_power_up()/down() helpers checks whether the codec
is being in pm (suspend/resume), and skips the call of runtime get/put
during it.  This is needed as there are lots of power up/down
sequences called in the paths that are also used in the PM itself.  An
example is found in hda_codec.c::codec_exec_verb(), where this can
power up the codec while it may be called again in its power up
sequence, too.

The above works in most cases, but sometimes we really want to wait
for the real power up.  For example, the control element get/put may
want explicit power up so that the value change is assured to reach to
the hardware.   Using the current snd_hdac_power_up(), however,
results in a race, e.g. when it's called during the runtime suspend is
being performed.  In the worst case, as found in patch_ca0132.c, it
can even lead to the deadlock because the code assumes the power up
while it was skipped due to the check above.

For dealing with such cases, this patch makes snd_hdac_power_up() and
_down() to two variants: with and without in_pm flag check.  The
version with pm flag check is named as snd_hdac_power_up_pm() while
the version without pm flag check is still kept as
snd_hdac_power_up().  (Just because the usage of the former is fewer.)

Then finally, the patch replaces each call potentially done in PM with
the new _pm() variant.

In theory, we can implement a unified version -- if we can distinguish
the current context whether it's in the pm path.  But such an
implementation is cumbersome, so leave the code like this a bit messy
way for now...

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=96271
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-08 13:50:42 +02:00
Kailang Yang
e1e62b98eb ALSA: hda/realtek - Support Dell headset mode for ALC288
Dell create new platform with ALC288 codec.
This patch will enable headset mode for Dino platform.

[slight code refactoring and compile fix by tiwai]

Signed-off-by: Kailang Yang <kailang@realtek.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-08 11:37:51 +02:00
Kailang Yang
f3b7033265 ALSA: hda/realtek - Support headset mode for ALC286/288
Support headset mode for ALC286 and ALC288 platforms.

Signed-off-by: Kailang Yang <kailang@realtek.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-08 11:30:59 +02:00
Takashi Iwai
0a59983873 Merge branch 'for-linus' into for-next
Back merge HD-audio quirks to for-next branch, so that we can apply
a couple of more quirks.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-08 11:30:49 +02:00
Kailang Yang
a59d7199f6 ALSA: hda/realtek - Make more stable to get pin sense for ALC283
Pin sense will active when power pin is wake up.
Power pin will not wake up immediately during resume state.
Add some delay to wait for power pin activated.

Signed-off-by: Kailang Yang <kailang@realtek.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-08 11:29:45 +02:00
Libin Yang
2d846c7402 ALSA: hda_intel: add AZX_DCAPS_I915_POWERWELL for SKL and BSW
HDMI/DP codec on SKL/BSW is in the power well.
The power well must be turned on before probing the
HDMI/DP codec.

This is a temporary patch, which will power on the
powerwell by adding AZX_DCAPS_I915_POWERWELL for SKL
and BSW. After restructuring and new flag is added,
this patch will be reverted.

Signed-off-by: Libin Yang <libin.yang@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-07 14:51:35 +02:00
Sudip Mukherjee
751e221689 ALSA: hda: fix possible null dereference
we are dereferencing pcm first then checking pcm. instead now lets put
them in same if condition so that pcm is checked first.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-04 14:32:16 +02:00
Kailang Yang
7081adf3f9 ALSA: hda/realtek - Support Dell headset mode for ALC256
Dell new platform of ALC256 audio codec.
Support headset mode for Dell ALC256 platform.

Signed-off-by: Kailang Yang <kailang@realtek.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-04 12:53:23 +02:00
Takashi Iwai
382fd7becc ALSA: hda - Enable widget power saving for Realtek codecs
Recent Realtek codecs support the finer power state control on each
widget.  Let's enable the new feature.

Tested-by: Hui Wang <hui.wang@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-04 12:24:00 +02:00
Takashi Iwai
d545a57c5f ALSA: hda - Sync node attributes at resume from widget power saving
So far we assumed that the node attributes like amp values remain
during the power state transition of the node itself.  While this is
true for IDT/STAC codecs I've tested, but some other codecs don't seem
behaving in that way.

This patch implements a partial sync mechanism specific to the given
widget node.  Now we've merged the regmap support, and it can be
easily written with regcache_sync_region().

Tested-by: Hui Wang <hui.wang@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-04 12:22:52 +02:00
Takashi Iwai
664bc5c559 Merge branch 'topic/hda-regmap' into for-next
This merges the support of regmap in HD-audio infrastructure.
Many in-house cache codes in HD-audio driver are relaced with the
more standard regmap base now.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-04 12:16:30 +02:00
Hui Wang
af95b41426 ALSA: hda - Add one more node in the EAPD supporting candidate list
We have a HP machine which use the codec node 0x17 connecting the
internal speaker, and from the node capability, we saw the EAPD,
if we don't set the EAPD on for this node, the internal speaker
can't output any sound.

Cc: <stable@vger.kernel.org>
BugLink: https://bugs.launchpad.net/bugs/1436745
Signed-off-by: Hui Wang <hui.wang@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-26 11:04:30 +01:00
Libin Yang
db48abf436 ALSA: hda_intel: apply the Seperate stream_tag for Sunrise Point
The total stream number of Sunrise Point's input and output stream
exceeds 15, which will cause some streams do not work because
of the overflow on SDxCTL.STRM field if using the legacy
stream tag allocation method.

This patch uses the new stream tag allocation method by add
the flag AZX_DCAPS_SEPARATE_STREAM_TAG for Skylake platform.

Signed-off-by: Libin Yang <libin.yang@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-26 07:30:13 +01:00
W. Trevor King
4738465c37 ALSA: hda/via - Add beep controls to VIA codecs
My codec has a beep-generating node:

  $ cat /proc/asound/card1/codec#0
  Codec: VIA VT1802
  ...
  Vendor Id: 0x11068446
  Subsystem Id: 0x15587410
  Revision Id: 0x100000
  ...
  Node 0x22 [Beep Generator Widget] wcaps 0x70040c: Mono Amp-Out
    Amp-Out caps: ofs=0x0a, nsteps=0x12, stepsize=0x05, mute=1
    Amp-Out vals:  [0x0a]
    Power states:  D0 D1 D2 D3
    Power: setting=D0, actual=D0
  ...

But I was missing the:

  Control: name=...

entries that I need to manage this widget from alsamixer.  With this
patch (based on the similar Mono Amp-Out handling in
patch_conexant.c), I get a new:

  input: HDA Digital PCBeep as /devices/pci0000:00/0000:00:1b.0/sound/card1/hdaudioC1D0/input15

entry in dmesg and controls to manage that beep:

  $ cat /proc/asound/card1/codec#0 | grep -A5 Beep
  Node 0x22 [Beep Generator Widget] wcaps 0x70040c: Mono Amp-Out
    Control: name="Beep Playback Volume", index=0, device=0
      ControlAmp: chs=1, dir=Out, idx=0, ofs=0
    Control: name="Beep Playback Switch", index=0, device=0
      ControlAmp: chs=1, dir=Out, idx=0, ofs=0
    Amp-Out caps: ofs=0x0a, nsteps=0x12, stepsize=0x05, mute=1
    Amp-Out vals:  [0x12]
    Power states:  D0 D1 D2 D3
    Power: setting=D0, actual=D0

[rebased and modified for the latest tree by tiwai]

Signed-off-by: W. Trevor King <wking@tremily.us>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-25 08:59:00 +01:00
Takashi Iwai
44e39b9853 ALSA: hda - Remove superfluous hda_nid_t definition in hda_codec.h
Just forgotten to remove.  It's now in sound/hdaudio.h.

Reported-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-25 07:44:21 +01:00
Sebastian Wicki
80b311d311 ALSA: hda - Add dock support for Thinkpad T450s (17aa:5036)
This model uses the same dock port as the previous generation.

Signed-off-by: Sebastian Wicki <gandro@gmx.net>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-23 17:39:20 +01:00
Takashi Iwai
a551d91473 ALSA: hda - Use regmap for command verb caches, too
Like the previous patches, this patch converts also to the regmap, at
this time, the cached verb writes are the target.  But this conversion
needs a bit more caution than before.

- In the old code, we just record any verbs as is, and restore them at
  resume.  For the regmap scheme, this doesn't work, since a few verbs
  like AMP or DIGI_CONVERT are asymmetrical.  Such verbs are converted
  either to the dedicated function (snd_hda_regmap_xxx_amp()) or
  changed to the unified verb.

- Some verbs have to be declared as vendor-specific ones before
  accessing via regmap.

Also, the minor optimization with codec->cached_write flag is dropped
in a few places, as this would confuse the operation.  Further
optimizations will be brought in the later patches, if any.

This conversion ends up with a drop of significant amount of codes,
mostly the helper codes that are no longer used.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-23 13:19:41 +01:00