aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/hda_codec.h
AgeCommit message (Collapse)Author
2019-03-01ALSA: hda - Serialize codec registrationsTakashi Iwai
commit 305a0ade180981686eec1f92aa6252a7c6ebb1cf upstream. In the current code, the codec registration may happen both at the codec bind time and the end of the controller probe time. In a rare occasion, they race with each other, leading to Oops due to the still uninitialized card device. This patch introduces a simple flag to prevent the codec registration at the codec bind time as long as the controller probe is going on. The controller probe invokes snd_card_register() that does the whole registration task, and we don't need to register each piece beforehand. Cc: <stable@vger.kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de> [PG: update paths for the header file content for older 4.18.x] Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2018-06-21ALSA: hda - Force to link down at runtime suspend on ATI/AMD HDMITakashi Iwai
Henning Kühn reported that the discrete AMD GPU on his hybrid graphics laptop no longer runtime-suspends due to the recent commit 07f4f97d7b4b ("vga_switcheroo: Use device link for HDA controller"). The root cause is that the HDMI codec on AMD GPU doesn't support CLKSTOP and EPSS, which are currently mandatory for powering down the HD-audio link at runtime suspend. Because the HD-audio link is still up, HD-audio controller driver blocks the transition to D3. For addressing the regression, this patch adds a new flag to indicate the forced link-down, and sets it for AMD HDMI codecs appropriately in the codec driver. Fixes: 07f4f97d7b4b ("vga_switcheroo: Use device link for HDA controller") Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106957 Reported-by: Lukas Wunner <lukas@wunner.de> Reported-and-tested-by: Henning Kühn <prg@cooco.de> Cc: <stable@vger.kernel.org> # v4.17+ Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-09-03ALSA: hda: Fix regression of hdmi eld control created based on invalid pcmWang YanQing
Commit fb087eaaef72 ("ALSA: hda - hdmi eld control created based on pcm") forget to filter out invalid pcm numbers, if there is only one invalid pcm number, then this issue causes we create eld control for invalid pcm silently, but when there are more than one invalid pcm numbers, then this issue bring probe error looks like below dmesg: " kernel: [ 1.647283] snd_hda_intel 0000:00:03.0: bound 0000:00:02.0 (ops 0xc2967540) kernel: [ 1.651192] snd_hda_intel 0000:00:03.0: Too many HDMI devices kernel: [ 1.651195] snd_hda_intel 0000:00:03.0: Consider building the kernel with CONFIG_SND_DYNAMIC_MINORS=y kernel: [ 1.651197] snd_hda_intel 0000:00:03.0: Too many HDMI devices kernel: [ 1.651199] snd_hda_intel 0000:00:03.0: Consider building the kernel with CONFIG_SND_DYNAMIC_MINORS=y kernel: [ 1.651201] snd_hda_intel 0000:00:03.0: Too many HDMI devices kernel: [ 1.651203] snd_hda_intel 0000:00:03.0: Consider building the kernel with CONFIG_SND_DYNAMIC_MINORS=y kernel: [ 1.651676] snd_hda_intel 0000:00:03.0: control 3:0:0:ELD:0 is already present kernel: [ 1.651787] snd_hda_codec_hdmi: probe of hdaudioC0D0 failed with error -16 " This patch add invalid pcm number filter before calling hdmi_create_eld_ctl. Fixes: fb087eaaef72 ("ALSA: hda - hdmi eld control created based on pcm") Signed-off-by: Wang YanQing <udknight@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-06-28ALSA: hda - Fix endless loop of codec configureTakashi Iwai
azx_codec_configure() loops over the codecs found on the given controller via a linked list. The code used to work in the past, but in the current version, this may lead to an endless loop when a codec binding returns an error. The culprit is that the snd_hda_codec_configure() unregisters the device upon error, and this eventually deletes the given codec object from the bus. Since the list is initialized via list_del_init(), the next object points to the same device itself. This behavior change was introduced at splitting the HD-audio code code, and forgotten to adapt it here. For fixing this bug, just use a *_safe() version of list iteration. Fixes: d068ebc25e6e ("ALSA: hda - Move some codes up to hdac_bus struct") Reported-by: Daniel Vetter <daniel.vetter@ffwll.ch> Cc: <stable@vger.kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-10ALSA: hda - A new flag to enforce prefix to each pinTakashi Iwai
This is a preliminary patch for a smooth multi-codec support, and it introduces a new flag, force_pin_prefix, to struct hda_codec. This flag is used to force to add the pin location prefix to each input pin. For example, when there is only one microphone pin, usually the auto-parser assigns the string "Mic". With this flag on, it'll be like "Front Mic". Also, the creation of "Master" or "PCM" playback volume for a single pin is suppressed, too. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=195305 Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-01-12ALSA: hda - add DP mst verb supportLibin Yang
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
2015-10-20Merge branch 'topic/hda-modalias' into for-nextTakashi Iwai
2015-10-20ALSA: hda - convert to hda_device_idTakashi Iwai
Finally we have a proper infrastructure to generate the modaliases automatically, let's move to hda_device_id from the legacy hda_codec_preset that contains basically the same information. The patch function hook is stored in driver_data field, which is long, and we need an explicit cast. Other than that, the conversion is mostly straightforward. Each entry is even simplified using a macro, and the lengthy (and error-prone) manual modaliases got removed. As a result, we achieved a quite good diet: 14 files changed, 407 insertions(+), 595 deletions(-) Reviewed-by: Vinod Koul <vinod.koul@intel.com> Tested-by: Subhransu S Prusty <subhransu.s.prusty@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-17ALSA: hda - Remove leftover snd_hda_bus() prototypeTakashi Iwai
It was forgotten to be removed. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-17ALSA: hda - Fix bogus codec address check for mixer name assignmentTakashi Iwai
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: 7fbe824a0f0e ('ALSA: hda - Update mixer name for the lower codec address') Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-15ALSA: hda - Update mixer name for the lower codec addressTakashi Iwai
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-15ALSA: hda - consolidate chip rename functionsTakashi Iwai
A few multiple codec drivers do renaming the chip_name string but all these are open-coded and some of them have even no error check. Let's make common helpers to do it properly. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-08ALSA: hda: make use of core codec fnsVinod Koul
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-08-17ALSA: hda - Make some helper functions localTakashi Iwai
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-06-09ALSA: hda: Intel: enable automatic runtime pm for HDMI codecs by defaultLu, Han
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-05-28ALSA: hda - Drop unused fields from struct hda_codec_presetTakashi Iwai
It's very unlikely that we'd need these fields out of sudden. Let's drop them. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-05-02Merge branch 'topic/jack' into for-nextTakashi Iwai
2015-05-02ALSA: jack: fix a randconfig build issueJie Yang
Building errors reported such as below when 'CONFIG_INPUT=m': ...undefined reference to `input_xxx'... Here change to enable SND_JACK selectively to fix the issue. Also remove the config 'SND_HDA_INPUT_JACK' which won't be used anymore. Signed-off-by: Jie Yang <yang.jie@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-16ALSA: hda - Replace hda_bus_ops with static bindingTakashi Iwai
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-16ALSA: hda - Move PCM format and rate handling code to core libraryTakashi Iwai
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-16ALSA: hda - Embed bus into controller objectTakashi Iwai
... 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-16ALSA: hda - Pass bus io_ops directly from the top-level driverTakashi Iwai
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-16ALSA: hda - Move send_cmd / get_response to hdac_bus_opsTakashi Iwai
One less redirection. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-14ALSA: hda - Handle error from get_response bus ops directlyTakashi Iwai
... 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-08ALSA: hda - Work around races of power up/down with runtime PMTakashi Iwai
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-04Merge branch 'topic/hda-regmap' into for-nextTakashi Iwai
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-03-25ALSA: hda - Remove superfluous hda_nid_t definition in hda_codec.hTakashi Iwai
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-23ALSA: hda - Use regmap for command verb caches, tooTakashi Iwai
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-23ALSA: hda - Use regmap for parameter caches, tooTakashi Iwai
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-23ALSA: hda - Use regmap for codec parameter readsTakashi Iwai
Let's start converting the access functions to regmap. The first one is the simplest, just converting the codec parameter read helper function snd_hda_param_read(). Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-23ALSA: hda - Add regmap supportTakashi Iwai
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-23ALSA: hda - Move generic array helpers to core libTakashi Iwai
This will be used by the regmap support. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-23ALSA: hda - Fix possible runtime PM refcount unbalanceTakashi Iwai
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-23ALSA: hda - Move a part of hda_codec stuff into hdac_deviceTakashi Iwai
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-23ALSA: hda - Move some codes up to hdac_bus structTakashi Iwai
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-23ALSA: hda - Make snd_hda_bus_type publicTakashi Iwai
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-20ALSA: hda - Rename power_mgmt flag with power_save_nodeTakashi Iwai
David suggested that the name "power_mgmt" is too ambiguous. Rename the flag with a bit clearer one "power_save_node". Also, add the corresponding description to HD-Audio.txt, too. Reported-by: David Henningsson <david.henningsson@canonical.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-18ALSA: hda - Support advanced power state controlsTakashi Iwai
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-13ALSA: hda - Use shutdown driver ops instead of reboot notifierTakashi Iwai
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-03ALSA: hda - Use standard workqueue for unsol and jack eventsTakashi Iwai
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-03ALSA: hda - Build PCMs and controls at codec driver probeTakashi Iwai
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-03ALSA: hda - Implement unbind more safelyTakashi Iwai
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-03ALSA: hda - Allocate hda_pcm objects dynamicallyTakashi Iwai
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-03ALSA: hda - Add card field to hda_codec structTakashi Iwai
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-03ALSA: hda - Split snd_hda_build_pcms()Takashi Iwai
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-02-26ALSA: hda - Replace bus pm_notify with the standard runtime PM frameworkTakashi Iwai
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-26ALSA: hda - Drop power_save value indirection in hda_busTakashi Iwai
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-23ALSA: hda - Use standard runtime PM for codec power-save controlTakashi Iwai
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-23ALSA: hda - Move codec suspend/resume to codec driverTakashi Iwai
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-23ALSA: hda - Bind codecs via standard busTakashi Iwai
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>