1
0
Fork 0
Commit Graph

623 Commits (2da836c42ff36d624039f0a1fd8500af6217b2c2)

Author SHA1 Message Date
Libin Yang 9152085def ALSA: hda - add DP MST audio support
This patch adds the DP MST audio support on i915 platform and
it will enable dyn_pcm_assign feature.

DP MST supports several device entry on the same port and each
device entry can map to one pcm stream. For example, on i915,
there are 3 pins, and each pin has 3 device entries. This means
there should be 3x3 pcms. However, there is only 3 pipe lines in
i915. This means 3 pcms are actived at most at the same moment.
We will create 5 pcms (pin number + dev entry num - 1) in this case.
For the details, please refer commit a76056f2e5
("ALSA: hda - hdmi dynamically bind PCM to pin when monitor hotplug")

Each device entry is a virtual pin. It is described by pin_nid and dev_id
in struct hdmi_spec_per_pin.

Reviewed-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Libin Yang <libin.yang@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1484208294-8637-3-git-send-email-libin.yang@intel.com
2017-01-12 10:06:47 +01:00
Libin Yang 13800f397e ALSA: hda - add DP mst verb support
Add snd_hda_get_dev_select() and snd_hda_set_dev_select() functions
for DP MST audio support.

Reviewed-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Libin Yang <libin.yang@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1484208294-8637-2-git-send-email-libin.yang@intel.com
2017-01-12 10:06:47 +01:00
Libin Yang 960a581e22 ALSA: hda: fix some klockwork scan warnings
This patch fixes some warnings from klockwork.

These warnings are not the real issues. The patch
adds the sanity check.

Signed-off-by: Libin Yang <libin.yang@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-06-16 10:10:12 +02:00
Takashi Iwai d82ad8e0c0 ASoC: Updates for v4.4
Not much core work here, a few small tweaks to interfaces but mainly the
 changes here are driver ones.  Highlights include:
 
  - Updates to the topology userspace interface
  - Big updates to the Renesas support from Morimoto-san
  - Most of the support for Intel Sky Lake systems.
  - New drivers for Asahi Kasei Microdevices AK4613, Allwinnner A10,
    Cirrus Logic WM8998, Dialog DA7219, Nuvoton NAU8825 and Rockchip
    S/PDIF.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQEcBAABAgAGBQJWLbbGAAoJECTWi3JdVIfQH7oH/1VdN2ozP9A03p24aC5qso1F
 VWOBnG4pkw1G6J5qK2lemMDeJdRdTfreICUAa9Tw9kOSfTIb6F3X8kCw8tbwlw0I
 4phgmyo23P53OfLZFMkQi/RCfwItnE0sszqhvoumUg0ryjYxg2JT+gTMgwvVo7Pq
 hf6m6a3we5pxLIIYP4wlQgOKwUJe4B4nC37ExySf24Dlo/DzmWDtfQbGvmyluFzb
 MB1qzEvAc/KC3LZFkIFmhfg2/caNRhcQrzkUCYrLR3t+oz9P1zCpYTII7VDdMg7L
 SM2VoL+ynEAdBqa38Ozwxvd/mpHwinlAeiikuwz1PyxVOqZvZqqiWzD8eUJkhZk=
 =/F/Q
 -----END PGP SIGNATURE-----

Merge tag 'asoc-v4.3-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-next

ASoC: Updates for v4.4

Not much core work here, a few small tweaks to interfaces but mainly the
changes here are driver ones.  Highlights include:

 - Updates to the topology userspace interface
 - Big updates to the Renesas support from Morimoto-san
 - Most of the support for Intel Sky Lake systems.
 - New drivers for Asahi Kasei Microdevices AK4613, Allwinnner A10,
   Cirrus Logic WM8998, Dialog DA7219, Nuvoton NAU8825 and Rockchip
   S/PDIF.
 - A new driver for the Atmel Class D speaker drivers
2015-10-26 12:14:49 +01:00
Takashi Iwai d289619a21 ALSA: hda - Fix deadlock at error in building PCM
The HDA codec driver issues snd_hda_codec_reset() at the error path of
PCM build.  This was needed in the earlier code base, but the recent
rewrite to use the standard bus binding made this a deadlock:
 modprobe        D 0000000000000005     0   720    716 0x00000080
 Call Trace:
  [<ffffffff816a5dbe>] schedule+0x3e/0x90
  [<ffffffff816a61a5>] schedule_preempt_disabled+0x15/0x20
  [<ffffffff816a7ae5>] __mutex_lock_slowpath+0xb5/0x120
  [<ffffffff816a7b6b>] mutex_lock+0x1b/0x30
  [<ffffffff8148656b>] device_release_driver+0x1b/0x30
  [<ffffffff81485c15>] bus_remove_device+0x105/0x180
  [<ffffffff814822b9>] device_del+0x139/0x260
  [<ffffffffa05e0ec5>] snd_hdac_device_unregister+0x25/0x30 [snd_hda_core]
  [<ffffffffa074fa6a>] snd_hda_codec_reset+0x2a/0x70 [snd_hda_codec]
  [<ffffffffa075007b>] snd_hda_codec_build_pcms+0x18b/0x1b0 [snd_hda_codec]
  [<ffffffffa074a44e>] hda_codec_driver_probe+0xbe/0x140 [snd_hda_codec]
  [<ffffffff81486ac4>] driver_probe_device+0x1f4/0x460
  [<ffffffff81486dc0>] __driver_attach+0x90/0xa0
  [<ffffffff81484844>] bus_for_each_dev+0x64/0xa0
  [<ffffffff814862de>] driver_attach+0x1e/0x20
  [<ffffffff81485e7b>] bus_add_driver+0x1eb/0x280
  [<ffffffff81487680>] driver_register+0x60/0xe0
  [<ffffffffa074a0da>] __hda_codec_driver_register+0x5a/0x60 [snd_hda_codec]
  [<ffffffffa070a01e>] realtek_driver_init+0x1e/0x1000 [snd_hda_codec_realtek]
  [<ffffffff810002f3>] do_one_initcall+0xb3/0x200
  [<ffffffff816a1fc5>] do_init_module+0x60/0x1f8
  [<ffffffff810ee5c3>] load_module+0x1653/0x1bd0
  [<ffffffff810eed48>] SYSC_finit_module+0x98/0xc0
  [<ffffffff810eed8e>] SyS_finit_module+0xe/0x10
  [<ffffffff816aa032>] entry_SYSCALL_64_fastpath+0x16/0x75

The simple fix is just to remove this call, since we don't need to
think about unbinding at there any longer.

Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=948758
Cc: <stable@vger.kernel.org> # v4.1+
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-20 16:31:34 +02:00
Takashi Iwai 2f0eaad910 ALSA: hda - Fix bogus codec address check for mixer name assignment
The recent commit [7fbe824a0f0e: ALSA: hda - Update mixer name for the
lower codec address] tried to improve the mixer chip name assignment
in the order of codec address.  However, this fix was utterly bogus;
it checks the field set in each codec, thus this value is reset at
each codec creation, of course.  For really handling this priority,
the assignment has to be remembered in the common place, namely in
hda_bus, instead of hda_codec.

Fixes: 7fbe824a0f ('ALSA: hda - Update mixer name for the lower codec address')
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-17 18:34:18 +02:00
Takashi Iwai 7fbe824a0f ALSA: hda - Update mixer name for the lower codec address
In most cases, we prefer the onboard codec as the primary device, thus
it's better to set it as the mixer name.  Currently, however, the
mixer name is updated per the device instantiation order, and user
gets often HDMI/DP or other seen as a mixer chip name.  Also, if a
codec name is renamed by the driver, the old chip name might be left
still as the mixer name.

This patch addresses these issues by remembering the chip address that
was referred as the mixer name.  When a codec with the same or lower
address gives its name, renew the mixer name accordingly, as it's
either the update of the codec name or we get likely the more
appropriate chip as the reference.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-15 14:10:25 +02:00
Vinod Koul 70b4891cc8 ALSA: hda: make use of core codec fns
Now that we have introduced the core fns we should make hda use these
helpers

Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-08 19:09:36 +02:00
Takashi Iwai b25cf30a01 ALSA: hda - Remove superfluous pcm NULL check
The variable pcm can be never NULL since it was rewritten with
list_for_each_entry().

Suggested-by: Markus Osterhoff <linux-kernel@k-raum.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-08-26 14:21:14 +02:00
Takashi Iwai 9dcc144b1f ALSA: hda - Refresh sysfs at snd_hda_codec_update_widgets()
In the commit [fa4f18b4f402: ALSA: hda - Refresh widgets sysfs at
probing Haswell+ HDMI codecs], snd_hdac_refresh_widget_sysfs() is
explicitly called in the codec driver.  But this results in refreshing
twice, as snd_hdac_refresh_widget_sysfs() itself calls
snd_hdac_refresh_widgets() function.

Instead, we can replace the call in snd_hda_codec_update_widgets()
with snd_hdac_refresh_widget_sysfs().  This also fixes the missing
sysfs update for ca0132, too.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-08-25 08:52:55 +02:00
Takashi Iwai c4a91e173a Merge branch 'for-linus' into for-next 2015-08-25 08:01:41 +02:00
Markus Osterhoff c7e69ae6b4 ALSA: hda: fix possible NULL dereference
After a for-loop was replaced by list_for_each_entry, see
Commit bbbc7e8502 ("ALSA: hda - Allocate hda_pcm objects dynamically"),
Commit 751e221689 ("ALSA: hda: fix possible null dereference"),
a possible NULL pointer dereference has been introduced; this patch adds
the NULL check on pcm->pcm, while leaving a potentially superfluous
check on pcm itself untouched.

Signed-off-by: Markus Osterhoff <linux-kernel@k-raum.org>
Cc: <stable@vger.kernel.org> #v4.1+
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-08-24 15:02:03 +02:00
Takashi Iwai d2c6b63df5 ALSA: hda - Make some helper functions local
A few helper functions to convert the pin information to strings have
been exported with assumption that they were used by other drivers.
But they are referred only in the proc interface in the end.

Let's make them local so that we can get rid of a few exports.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-08-17 15:10:15 +02:00
Heloise NH 6986a0e255 ALSA: hda: fix kstrdup return value
In kstrdup we should return -ENOMEM when it reports an
memory allocation failure, while the -ENODEV is referred
to a failure in finding the cpu node in the device tree.

Signed-off-by: Heloise NH <kernelpatch_update@163.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-07-17 14:56:19 +02:00
Takashi Iwai cc1b76ed32 Merge branch 'for-linus' into for-next
Yet another non-trivial conflicts resolution for the recent HD-audio fix.

Conflicts:
	sound/pci/hda/hda_intel.c

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-06-12 08:10:20 +02:00
Takashi Iwai a457782a1c ALSA: hda - Fix link power unbalance at device removal
snd_hdac_link_power() has to be called after unregistering the codec
device.  Otherwise the device might be already runtime-suspended, thus
the refcount goes under zero, triggering a warning like:

  WARNING: CPU: 7 PID: 2014 at sound/hda/hdac_i915.c:63 snd_hdac_display_power+0x106/0x120 [snd_hda_core]()
  CPU: 7 PID: 2014 Comm: modprobe Not tainted 4.1.0-rc7-test+ #1
  Call Trace:
   [<ffffffff81697fe3>] dump_stack+0x4c/0x6e
   [<ffffffff810696da>] warn_slowpath_common+0x8a/0xc0
   [<ffffffff810697ca>] warn_slowpath_null+0x1a/0x20
   [<ffffffffa02dd526>] snd_hdac_display_power+0x106/0x120 [snd_hda_core]
   [<ffffffffa030b422>] azx_intel_link_power+0x12/0x20 [snd_hda_intel]
   [<ffffffffa037139f>] azx_link_power+0x1f/0x30 [snd_hda_codec]
   [<ffffffffa02d89fe>] snd_hdac_link_power+0x2e/0x40 [snd_hda_core]
   [<ffffffffa0368524>] snd_hda_codec_dev_free+0x34/0x50 [snd_hda_codec]
   [<ffffffffa0252061>] __snd_device_free+0x51/0xa0 [snd]
   .....

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-06-11 14:02:49 +02:00
Takashi Iwai a686ec4c5f ALSA: hda - Re-add the lost fake mute support
Yet another regression by the transition to regmap cache; for better
usability, we had the fake mute control using the zero amp value for
Conexant codecs, and this was forgotten in the new hda core code.

Since the bits 4-7 are unused for the amp registers (as we follow the
syntax of AMP_GET verb), the bit 4 is now used to indicate the fake
mute.  For setting this flag, snd_hda_codec_amp_update() becomes a
function from a simple macro.  The bonus is that it gained a proper
function description.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-06-11 11:55:48 +02:00
Lu, Han 2377c3c388 ALSA: hda: Intel: enable automatic runtime pm for HDMI codecs by default
Enable runtime PM of the HDMI audio codec on the latest Intel platforms.
So the HD-A controller or HDMI codec can suspend when idle timeout by
default and release the GFX power well.
The patch influences HSW/BDW/BYT/BSW/SKL. Eariler platforms and third
party analog codecs will not be influenced.

Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-06-09 11:58:37 +02:00
Takashi Iwai 8654844cf5 Merge branch 'for-linus' into for-next
Resolve the non-trivial conflict due to the hdac regmap API changes.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-06-09 07:22:26 +02:00
Dave Airlie 132bd96bc5 ALSA: hda - fix number of devices query on hotplug
The new regmap code seems to cache this, which isn't helpful
for the hotplug dock situation where this gets updated.

Use the uncached query for this.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-06-09 07:15:29 +02:00
Takashi Iwai 85abf3ec5f Merge branch 'topic/hda' into for-next 2015-04-29 12:28:52 +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
Takashi Iwai f1a77547c2 Merge branch 'for-4.2' into for-next 2015-04-27 16:42:45 +02:00
Takashi Iwai 30e5f003ff ALSA: hda - Fix missing va_end() call in snd_hda_codec_pcm_new()
Reported by coverity CID 1296024.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-27 16:39:19 +02:00
Takashi Iwai ee52e56e7b ALSA: hda - Fix mute-LED fixed mode
The mute-LED mode control has the fixed on/off states that are
supposed to remain on/off regardless of the master switch.  However,
this doesn't work actually because the vmaster hook is called in the
vmaster code itself.

This patch fixes it by calling the hook indirectly after checking the
mute LED mode.

Reported-and-tested-by: Pali Rohár <pali.rohar@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-27 10:48:37 +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 7d4b5e978a ALSA: hda - Fix regression for slave SPDIF setups
The commit [a551d91473e5: ALSA: hda - Use regmap for command verb
caches, too] introduced a regression due to a typo in the conversion;
the IEC958 status bits of slave digital devices aren't updated
correctly.  This patch corrects it.

Fixes: a551d91473 ('ALSA: hda - Use regmap for command verb caches, too')
Reported-and-tested-by: Markus Trippelsdorf <markus@trippelsdorf.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-16 15:51:59 +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 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 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 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
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
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
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
Takashi Iwai faa75f8a2e ALSA: hda - Use regmap for parameter caches, too
The amp hash table was used for recording the cached reads of some
capability values like pin caps or amp caps.  Now all these are moved
to regmap as well.

One addition to the regmap helper is codec->caps_overwriting flag.
This is set in snd_hdac_override_parm(), and the regmap helper accepts
any register while this flag is set, so that it can overwrite even the
read-only verb like AC_VERB_PARAMETERS.  The flag is cleared
immediately in snd_hdac_override_parm(), as it's a once-off flag.

Along with these changes, the no longer needed amp hash and relevant
fields are removed from hda_codec struct now.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-23 13:19:40 +01:00
Takashi Iwai eeecd9d10d ALSA: hda - Use regmap for amp accesses
This patch converts the amp access functions to the regmap helpers.
The amp values were formerly cached in the own hash table.  Now it's
dropped by the regmap's cache.

The only tricky conversion is snd_hda_codec_amp_init().  This function
shouldn't do anything if the amp was already initialized.  For
achieving this behavior, a value is read once at first temporarily in
the cache-only mode.  Only if it returns an error,  i.e. the item
still doesn't exist in the cache, it proceeds to the update.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-23 13:19:39 +01:00
Takashi Iwai 9ba17b4d13 ALSA: hda - Implement uncached version of parameter reads
Sometimes we need the uncached reads, e.g. for refreshing the tree.
This patch provides the helper function for that and uses it for
refreshing widgets, reading subtrees and the whole proc reads.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-23 13:19:38 +01:00
Takashi Iwai 4d75faa044 ALSA: hda - Add regmap support
This patch adds an infrastructure to support regmap-based verb
accesses.  Because o the asymmetric nature of HD-audio verbs,
especially the amp verbs, we need to translate the verbs as a sort of
pseudo registers to be mapped uniquely in regmap.

In this patch, a pseudo register is built from the NID, the
AC_VERB_GET_* and 8bit parameters, i.e. almost in the form to be sent
to HD-audio bus but without codec address field.  OTOH, for writing,
the same pseudo register is translated to AC_VERB_SET_* automatically.
The AC_VERB_SET_AMP_* verb is re-encoded from the corresponding
AC_VERB_GET_AMP_* verb and parameter at writing.

Some verbs has a single command for read but multiple for writes.  A
write for such a verb is split automatically to multiple verbs.

The patch provides also a few handy helper functions.  They are
designed to be accessible even without regmap.  When no regmap is set
up (e.g. before the codec device instantiation), the direct hardware
access is used.  Also, it tries to avoid the unnecessary power-up.
The power up/down sequence is performed only on demand.

The codec driver needs to call snd_hdac_regmap_exit() and
snd_hdac_regmap_exit() at probe and remove if it wants the regmap
access.

There is one flag added to hdac_device.  When the flag lazy_cache is
set, regmap helper ignores a write for a suspended device and returns
as if it was actually written.  It reduces the hardware access pretty
much, e.g. when adjusting the mixer volume while in idle.  This
assumes that the driver will sync the cache later at resume properly,
so use it carefully.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-23 13:19:36 +01:00
Takashi Iwai 71fc4c7ef5 ALSA: hda - Move generic array helpers to core lib
This will be used by the regmap support.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-23 13:19:35 +01:00
Takashi Iwai c4c2533f80 ALSA: hda - Fix possible runtime PM refcount unbalance
When the driver is unloaded before the codec is bound, it still keeps
the runtime PM refcount up, and results in the unbalance.  This patch
covers these cases by introducing a flag indicating the runtime PM
initialization and handling the codec registration procedure more
properly.  It also fixes the missing input beep device as a gratis,
too.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-23 13:17:48 +01:00
Takashi Iwai 0585244869 ALSA: hda - Support indirect execution of verbs
Add an overriding exec_verb op to struct hdac_device so that the call
via snd_hdac_exec_verb() can switch to a different route depending on
the setup.  The codec driver sets this field so that it can handle the
errors or applying quirks appropriately.  Furthermore, this mechanism
will be used for smooth transition for the regmap support in later
patches.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-23 13:17:37 +01:00
Takashi Iwai 3256be6537 ALSA: hda - Add widget sysfs tree
This patch changes the sysfs files assigned to the codec device on the
bus which were formerly identical with hwdep sysfs files.  Now it
shows only a few core parameter, vendor_id, subsystem_id, revision_id,
afg, mfg, vendor_name and chip_name.

In addition, now a widget tree is added to the bus device sysfs
directory for showing the widget topology and attributes.  It's just a
flat tree consisting of subdirectories named as the widget NID
including various attributes like widget capability bits.  The AFG
(usually NID 0x01) is always found there, and it contains always
amp_in_caps, amp_out_caps and power_caps files.  Each of these
attributes show a single value.  The rest are the widget nodes
belonging to that AFG.  Note that the child node might not start from
0x02 but from another value like 0x0a.

Each child node may contain caps, pin_caps, amp_in_caps, amp_out_caps,
power_caps and connections files.  The caps (representing the widget
capability bits) always contain a value.  The rest may contain
value(s) if the attribute exists on the node.  Only connections file
show multiple values while other attributes have zero or one single
value.

An example of ls -R output is like below:
% ls -R /sys/bus/hdaudio/devices/hdaudioC0D0/
/sys/bus/hdaudio/devices/hdaudioC0D0/widgets/:
01/  04/  07/  0a/  0d/  10/  13/  16/  19/  1c/  1f/  22/
02/  05/  08/  0b/  0e/  11/  14/  17/  1a/  1d/  20/  23/
03/  06/  09/  0c/  0f/  12/  15/  18/  1b/  1e/  21/

/sys/bus/hdaudio/devices/hdaudioC0D0/widgets/01:
amp_in_caps  amp_out_caps  power_caps

/sys/bus/hdaudio/devices/hdaudioC0D0/widgets/02:
amp_in_caps  amp_out_caps  caps  connections  pin_caps  pin_cfg
power_caps

/sys/bus/hdaudio/devices/hdaudioC0D0/widgets/03:
.....

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-23 13:17:27 +01:00
Takashi Iwai 7639a06c23 ALSA: hda - Move a part of hda_codec stuff into hdac_device
Now some codes and functionalities of hda_codec struct are moved to
hdac_device struct.  A few basic attributes like the codec address,
vendor ID number, FG numbers, etc are moved to hdac_device, and they
are accessed like codec->core.addr.  The basic verb exec functions are
moved, too.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-23 13:17:17 +01:00
Takashi Iwai d068ebc25e ALSA: hda - Move some codes up to hdac_bus struct
A few basic codes for communicating over HD-audio bus are moved to
struct hdac_bus now.  It has only command and get_response ops in
addition to the unsolicited event handling.

Note that the codec-side tracing support is disabled temporarily
during this transition due to the code shuffling.  It will be
re-enabled later once when all pieces are settled down.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-23 13:17:02 +01:00
Takashi Iwai e3d280fc6d ALSA: hda - Make snd_hda_bus_type public
Define the common hd-audio driver and device types to bind over
snd_hda_bus_type publicly.  This allows to implement other type of
device and driver code over hd-audio bus.

Now both struct hda_codec and struct hda_codec_driver inherit these
new struct hdac_device and struct hdac_driver, respectively.

The bus registration is done in subsys_initcall() to assure it
before any other driver registrations.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-23 13:15:51 +01:00
Takashi Iwai e6feb5d085 ALSA: hda - Support advanced power state controls
This patch enables the finer power state control of each widget
depending on the jack plug state and streaming state in addition to
the existing power_down_unused power optimization.  The new feature is
enabled only when codec->power_mgmt flag is set.

Two new flags, pin_enabled and stream_enabled, are introduced in
nid_path struct for marking the two individual power states: the pin
plug/unplug and DAC/ADC stream, respectively.  They can be set
statically in case they are static routes (e.g. some mixer paths),
too.

The power up and down events for each pin are triggered via the
standard hda_jack table.  The call order is hard-coded, relying on the
current implementation of jack event chain (a la FILO/stack order).

One point to be dealt carefully is that DAC/ADC cannot be powered
on/off while streaming.  They are pinned as long as the stream is
running.  For controlling the power of DAC/ADC, a new patch_ops is
added.  The generic parser provides the default callback for that.

As of this patch, only IDT/Sigmatel codec driver enables the flag.
The support on other codecs will follow.

An assumption we made in this code is that the widget state (e.g. amp,
pinctl, connections) remains after the widget power transition (not
about FG power transition).  This is true for IDT codecs, at least.
But if the widget state is lost at widget power transition, we'd need
to implement additional code to sync the cached amp/verbs for the
specific NID.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-18 09:22:28 +01:00
Takashi Iwai b2a0bafa75 ALSA: hda - Use shutdown driver ops instead of reboot notifier
The driver shutdown ops is simpler than registering reboot notifier
manually.  There should be no functional change by this -- the codec
driver calls its own callback while the bus driver just calls
azx_stop() like before.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-13 15:28:58 +01:00
Takashi Iwai d56db741b8 ALSA: hda - Release resources in device release callback
Move the destructor code to device release callback for the codec
object instead.  This is a safer place to release the resources than
dev_free callback in general.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-03 11:48:46 +01:00
Takashi Iwai 2f35c630f7 ALSA: hda - Use standard workqueue for unsol and jack events
The events that are handled by HD-audio drivers are no frequent and
urgent ones, so we can use the standard workqueue without any problem
nowadays.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-03 11:37:57 +01:00
Takashi Iwai bcd96557bd ALSA: hda - Build PCMs and controls at codec driver probe
This makes the code flow easier -- instead of the controller driver
calling snd_hda_build_pcms() and snd_hda_build_controls() explicitly,
the codec driver itself builds PCMs and controls at probe time.  Then
the controller driver only needs to call snd_card_register().

Also, this allows us the full bind/unbind control, too.  Even when a
codec driver is bound later, it automatically registers the new PCM
and controls by itself.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-03 11:28:36 +01:00
Takashi Iwai 9a6246ff78 ALSA: hda - Implement unbind more safely
Now we have all pieces ready, and put them into places:
- add the hda_pcm refcount to azx_pcm_open() and azx_pcm_close(),
- call the most of cleanup code in hda_codec_reset() from the codec
  driver remove,
- call the same code also from the hda_codec object free.

Then the codec driver can be unbound more safely now.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-03 11:28:12 +01:00
Takashi Iwai 61ca4107a1 ALSA: hda - Don't assume non-NULL PCM ops
The PCM ops might be set NULL, or cleared to NULL when the driver is
unbound.  Give a proper NULL check at each place to be more robust.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-03 11:26:27 +01:00
Takashi Iwai bbbc7e8502 ALSA: hda - Allocate hda_pcm objects dynamically
So far, the hda_codec object kept the hda_pcm list in an array, and
the codec driver was expected to assign the array.  However, this
makes the object life cycle management harder, because the assigned
array is freed at the codec driver detach while it might be still
accessed by the opened streams.

In this patch, we allocate each hda_pcm object dynamically and manage
it as a linked list.  Each object has a kref refcount, and both the
codec driver binder and the PCM open/close touches it, so that the
object won't be freed while in use.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-03 11:26:24 +01:00
Takashi Iwai f4de8fe6cf ALSA: hda - Remove superfluous memory allocation error messages
The memory allocators should have already given the kernel warning
messages, thus we don't have to annoy again.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-03 11:25:17 +01:00
Takashi Iwai 6efdd8513f ALSA: hda - Add card field to hda_codec struct
Allow the codec object to have an individual card pointer.  Not only
this simplifies the redirections in many places, also this will allow
us to make each codec assigned to a different card object.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-03 11:25:16 +01:00
Takashi Iwai 1a4ba30cce ALSA: hda - Split snd_hda_build_pcms()
snd_hda_build_pcms() does actually three things: let the codec driver
build up hda_pcm list, set the PCM default values, and call the
attach_pcm bus ops for each hda_pcm instance.  The former two are
basically independent from the bus implementation, so it'd make the
code a bit more readable.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-03 11:25:15 +01:00
Takashi Iwai 7e40b80da4 ALSA: hda - Remove channel mode helper functions
They are no longer used, let's kill them.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-02-26 15:37:10 +01:00
Takashi Iwai 709949fbe9 ALSA: hda - Power down codec automatically at registration
So far, we let the controller driver power down the all codecs at the
end of probe.  But this can be done better in the codec's dev_register
callback.  This results in the reduction of duplicated codes in each
control driver.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-02-26 15:37:08 +01:00
Takashi Iwai 55ed9cd1fe ALSA: hda - Replace bus pm_notify with the standard runtime PM framework
Now the final bit of runtime PM cleanup: instead of manual
notification of the power up/down of the codec via hda_bus pm_notify
ops, use the standard runtime PM feature.

The child codec device will kick off the runtime PM of the parent
(PCI) device upon suspend/resume automatically.  For managing whether
the link can be really turned off, we use the bit flags
bus->codec_powered instead of the earlier bus->power_keep_link_on.
flag.  Each codec driver is responsible to set/clear the bit flag, and
the controller device can be turned off only when all these bits are
cleared.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-02-26 15:37:02 +01:00
Takashi Iwai bb573928e1 ALSA: hda - Drop power_save value indirection in hda_bus
We used to pass the power_save option value to hda_bus via a given
pointer.  This was needed to refer to the value from the HD-audio core
side.  However, after the transition to the runtime PM, this is no
longer needed.

This patch drops the power_save value indirection in hda_bus above,
and let the controller driver reprograms the autosuspend value
explicitly by a new helper, snd_hda_set_power_save().  Without this
call, the HD-audio core doesn't set up the autosuspend and flip the
runtime PM.  (User may still be able to set up via sysfs, though.)

Along with this change, the pointer argument of azx_bus_create() is
dropped as well.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-02-26 15:36:52 +01:00
Takashi Iwai cc72da7d4d ALSA: hda - Use standard runtime PM for codec power-save control
Like the previous transition of suspend/resume, now move the
power-save code to the standard runtime PM.  As usual for runtime PM,
it's a bit tricky, but this simplified codes a lot in the end.

For keeping the usage compatibility, power_save module option still
controls the whole power-saving behavior on all codecs.  The value is
translated to pm_runtime_*_autosuspend() and pm_runtime_allow() /
pm_runtime_forbid() calls.

snd_hda_power_up() and snd_hda_power_down() are translated to
pm_runtime_get_sync() and pm_runtime_put_autosuspend(), respectively.
Since we can do call pm_runtime_get_sync() more reliably, the sync
version is used always and snd_hda_power_up_d3wait() is dropped.
Another slight difference is that snd_hda_power_up()/down() don't call
runtime_pm code during the suspend/resume transition phase.  Calling
them there isn't safe unlike our own code, resulted in unexpected
behavior (endless wakeups).

The hda_power_count tracepoint was removed, as it doesn't match well
with the new code.

Last but not least, we need to set ignore_children flag in the parent
dev.power field so that the runtime PM of the controller chip won't
get confused.  The notification is still done in the bus pm_notify
callback.  We'll get rid of this hack in the later patch.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-02-23 09:16:07 +01:00
Takashi Iwai 59ed1eade1 ALSA: hda - Move codec suspend/resume to codec driver
This patch moves the suspend/resume mechanisms down to each codec
driver level, as we have a proper codec driver bound on the bus now.
Then we get the asynchronous PM gratis without fiddling much in the
driver level.

As a soft-landing transition, implement the common suspend/resume pm
ops for hda_codec_driver and keep the each codec driver intact.  Only
the callers of suspend/resume in the controller side (azx_suspend()
and azx_resume()) are removed.

Another involved place is azx_bus_reset() calling the temporary
suspend and resume as a hackish method of bus reset.  The HD-audio
core provide a helper function snd_hda_bus_reset() instead.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-02-23 09:16:07 +01:00
Takashi Iwai d8a766a16e ALSA: hda - Bind codecs via standard bus
Now we create the standard HD-audio bus (/sys/bus/hdaudio), and bind
the codec driver with the codec device over there.  This is the first
step of the whole transition so that the changes to each codec driver
are kept as minimal as possible.

Each codec driver needs to register hda_codec_driver struct containing
the currently existing preset via the new helper macro
module_hda_codec_driver().  The old hda_codec_preset_list is replaced
with this infrastructure.  The generic parsers (for HDMI and other)
are also included in the preset with the special IDs to bind
uniquely.

In HD-audio core side, the device binding code is split to
hda_bind.c.  It provides the snd_hda_bus_type implementation to match
the codec driver with the given codec vendor ID.  It also manages the
module auto-loading by itself like before: when the matching isn't
found, it tries to probe the corresponding codec modules, and finally
falls back to the generic drivers.  (The special ID mentioned above is
set at this stage.)

The only visible change to outside is that the hdaudio sysfs entry now
appears in /sys/bus/devices, not as a sound class device.

More works to move the suspend/resume and remove ops will be
(hopefully) done in later patches.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-02-23 09:16:06 +01:00
Takashi Iwai 781c7b9615 ALSA: hda - Avoid unnecessary power-up at mixer amp changes
When the mixer amp is touched by control elements, we don't have to
power up always; if the codec was suspended at the time, we can just
update the amp cache and it's reflected to the hardware upon resume.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-02-20 10:37:48 +01:00
Takashi Iwai 922c88a836 ALSA: hda - Embed struct hda_bus_unsolicited into struct hda_bus
There is no big merit to handle hda_bus_unsolicited object
individually, as it's tightly coupled with the hda_bus object itself.
Embedding it makes the code simpler in the end.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-02-17 14:46:40 +01:00
Takashi Iwai ef7449780e ALSA: hda - Drop hda_bus_template for snd_hda_bus_new()
Instead of copying from the given template, let the caller fills the
fields after creation.  This simplifies the code after all.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-02-17 14:23:57 +01:00
Dan Carpenter 69eba10e60 ALSA: hda - using uninitialized data
In olden times the snd_hda_param_read() function always set "*start_id"
but in 2007 we introduced a new return and it causes uninitialized data
bugs in a couple of the callers: print_codec_info() and
hdmi_parse_codec().

Fixes: e8a7f136f5 ('[ALSA] hda-intel - Improve HD-audio codec probing robustness')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-11-27 09:34:41 +01:00
Markus Elfring f0acd28c87 ALSA: hda: Deletion of unnecessary checks before two function calls
The functions kfree() and release_firmware() test whether their argument
is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-11-17 13:45:23 +01:00
Takashi Iwai 95a962c36f ALSA: hda - More kerneldoc comments
Put more kerneldoc comments to the exported functions.
Still the generic parser code and the HD-audio controller code aren't
covered yet, though.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-10-29 16:03:58 +01:00
Takashi Iwai a11e9b1686 ALSA: hda - Correct kerneldoc comments
Complete the missing parameters and fix anything wrong there.
Just comment changes.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-10-29 15:06:54 +01:00
Takashi Iwai 66797f36fd ALSA: hda - Pass printf argument directly to request_module()
request_module() handles the printf style arguments, so we don't have
to render strings in the caller side.  Not only it reduces the
unnecessary temporary string buffer, it's even safer from the security
POV.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-10-27 15:17:54 +01:00
Takashi Iwai 3ff7221932 ALSA: hda: Use snd_ctl_enum_info()
... and reduce the open codes.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-10-21 09:00:49 +02:00
David Henningsson 861a04ed15 ALSA: hda - Move the function "check_amp_caps" to hda_codec.c
The next patch will use it, so make it visible across modules.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-09-23 15:57:28 +02:00
Takashi Iwai e9bd0224c1 ALSA: hda - Remove obsoleted snd_hda_check_board_config() & co
The helper functions snd_hda_check_board_config() and
snd_hda_check_board_codec_sid_config() are no longer used since the
transition to the generic parser and all quirks have been replaced
with fixups.  Let's kill these dead codes.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-08-19 08:04:28 +02:00
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 e8750940ce ALSA: hda - Fix invalid function call in snd_hda_add_vmaster()
The recent commit [6194b99d: ALSA: hda - Kill the rest of snd_print*()
usages] changed the callback map_slaves(), but one call was forgotten
to be replaced due to the cast, which leads to kernel Oops due to
invalid function.  This patch replaces it with a proper function.

Fixes: 6194b99de9 ('ALSA: hda - Kill the rest of snd_print*() usages')
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-06-30 14:05:17 +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 d604b39908 ALSA: hda - Fix registration of beep input device
The beep input device is registered via input_register_device(), but
this is called in snd_hda_attach_beep_device() where the sound devices
aren't registered yet.  This leads to the binding to non-existing
object, thus results in failure.  And, even if the binding worked
(against the PCI object), it's still racy; the input device appears
before the sound objects.

For fixing this, register the input device properly at dev_register
ops of the codec object it's bound with.  Also, call
snd_hda_detach_beep_device() at dev_disconnection so that it's
detached at the right timing.  As a bonus, since it's called in the
codec's ops, we can get rid of the further call from the other codec
drivers.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-02-28 14:02:21 +01: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 13aeaf6801 ALSA: hda - Create own device struct for each codec
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>
2014-02-25 12:12:54 +01:00
Takashi Iwai 2565c89908 ALSA: hda - Manage each codec instance individually
Now each snd_hda_codec instance is managed via the device chain, the
registration and release are done by its callback instead of calling
from bus.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-02-25 12:12:53 +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 dff86f86d4 ALSA: hda - Add QEMU codec vendor ID
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-02-19 11:11:20 +01:00
Takashi Iwai 1f85a0f0cc ALSA: hda - Remove superfluous inclusion of linux/pci.h
Some codec drivers still have it since using PCI_VENDOR_ID_*.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-02-15 10:12:12 +01:00
Takashi Iwai ef8e39b51f ALSA: hda - Fix undefined symbol due to builtin/module mixup
Even after the fix for leftover kconfig handling (commit f8f1becf),
the current code still doesn't handle properly the builtin/module
mixup case between the core snd-hda-codec and other codec drivers.
For example, when CONFIG_SND_HDA_INTEL=y and
CONFIG_SND_HDA_CODEC_HDMI=m, it'll end up with an unresolved symbol
snd_hda_parse_hdmi_codec.  This patch fixes the issue.

Now codec->parser points to the parser object *only* when a module
(either generic or HDMI parser) is loaded and bound.  When a builtin
symbol is used, codec->parser still points to NULL.  This is the
difference from the previous versions.

Fixes: f8f1becfa4 ('ALSA: hda - Fix leftover ifdef checks after modularization')
Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-02-10 11:50:01 +01:00
Takashi Iwai f8f1becfa4 ALSA: hda - Fix leftover ifdef checks after modularization
Since the commit [595fe1b702c3: ALSA: hda - Make
CONFIG_SND_HDA_CODEC_* tristate], the kconfig variables for the
generic parser and codec drivers can be "m" instead of boolean, but
some codes are left unchanged to check only #ifdef
CONFIG_SND_HDA_CODEC_XXX, which is no longer true for modules.
This patch fixes them by replacing with IS_ENABLED() macros.

Fixes: 595fe1b702 ('ALSA: hda - Make CONFIG_SND_HDA_CODEC_* tristate')
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=70161
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-02-07 12:13:25 +01:00
Takashi Iwai dfc6e469b6 ALSA: hda - Apply codec power_filter to FG nodes
Apply the codec->power_filter to the FG nodes in general for reducing
hackish set_power_state ops override in patch_sigmatel.c.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-01-13 16:30:15 +01:00
Takashi Iwai 2698ea9805 ALSA: hda - Kill EXPORT_SYMBOL_HDA()
Replace all with the standard EXPORT_SYMBOL_GPL().

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-12-19 14:36:19 +01:00
Takashi Iwai f4d6a55d7b ALSA: hda - Clean up async codec PM using standard async infrastructure
This simplifies lots of codes indeed.

Tested-by: Mengdong Lin <mengdong.lin@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-12-06 08:51:51 +01:00
Mengdong Lin 7f13292743 ALSA: hda - allow a codec to define its own depop delay time
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>
2013-11-29 14:47:46 +01:00
Mengdong Lin 12edb89308 ALSA: hda - resume codecs in parallel
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>
2013-11-27 12:37:07 +01:00
Mengdong Lin 0e24dbb7f4 ALSA: hda - suspend codecs in parallel
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>
2013-11-27 12:16:32 +01:00
Takashi Iwai 3e9bc58fef ALSA: hda - Disable runtime PM when EPSS is unavailable
According to Mengdong, we shouldn't enable runtime PM when a codec
doesn't support EPSS, based on the experiences on Windows.
We have already this check in HDMI codec drivers, but now apply it in
general in hda_codec.c.

Credit goes to Mengdong Lin <mengdong.lin@intel.com>

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-11-26 13:43:02 +01:00
Takashi Iwai a40e0a880b ALSA: hda - Refactor pm notification in hda_codec.c
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>
2013-11-26 13:42:38 +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
Takashi Iwai 0fc28fc030 ALSA: hda - Fix unbalanced runtime PM notification at resume
When a codec is resumed, it keeps the power on while the resuming
phase via hda_keep_power_on(), then turns down via
snd_hda_power_down().  At that point, snd_hda_power_down() notifies
the power down to the controller, and this may confuse the refcount if
the codec was already powered up before the resume.

In the end result, the controller goes to runtime suspend even before
the codec is kicked off to the power save, and the communication
stalls happens.

The fix is to add the power-up notification together with
hda_keep_power_on(), and clears the flag appropriately.

Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-11-20 16:39:14 +01:00