summaryrefslogtreecommitdiffstats
path: root/sound/hda/hdac_device.c
AgeCommit message (Collapse)AuthorFilesLines
2022-06-08ALSA: hda/realtek - Add HW8326 supporthuangwenhui1-0/+1
Added the support of new Huawei codec HW8326. The HW8326 is developed by Huawei with Realtek's IP Core, and it's compatible with ALC256. Signed-off-by: huangwenhui <huangwenhuia@uniontech.com> Link: https://lore.kernel.org/r/20220608082357.26898-1-huangwenhuia@uniontech.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-09-02ALSA: hda: fix a runtime pm issue in SOF when integrated GPU is disabledRander Wang1-0/+2
In snd_hdac_device_init pm_runtime_set_active is called to increase child_count in parent device. But when it is failed to build connection with GPU for one case that integrated graphic gpu is disabled, snd_hdac_ext_bus_device_exit will be invoked to clean up a HD-audio extended codec base device. At this time the child_count of parent is not decreased, which makes parent device can't get suspended. This patch calls pm_runtime_set_suspended to decrease child_count in parent device in snd_hdac_device_exit to match with snd_hdac_device_init. pm_runtime_set_suspended can make sure that it will not decrease child_count if the device is already suspended. Signed-off-by: Rander Wang <rander.wang@intel.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com> Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Link: https://lore.kernel.org/r/20200902154218.1440441-1-kai.vehmanen@linux.intel.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-05-05ALSA: hda: Use dev_to_hdac_dev macroKai-Heng Feng1-1/+1
Use dev_to_hdac_dev() instead of container_of(). No functional change intended. Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com> Link: https://lore.kernel.org/r/20200505030357.28004-1-kai.heng.feng@canonical.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-03-13ALSA: hda: Use scnprintf() for string truncationTakashi Iwai1-1/+1
snd_hdac_codec_modalias() truncates the string to the given size and returns its size, but it returned a wrong size from snprintf(). snprintf() returns the would-be-output size, not the actual size. Use scnprintf() instead to return the correct size. Link: https://lore.kernel.org/r/20200313130241.8970-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-01-14ALSA: hda: Update kernel-doc function parameter descriptionsKeyon Jie1-4/+8
Make W=1 throws a lot of warnings, with multiple misalignments between function params and their descriptions. Signed-off-by: Keyon Jie <yang.jie@linux.intel.com> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/20200113205638.27338-1-pierre-louis.bossart@linux.intel.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-01-13ALSA: hda: Manage concurrent reg access more properlyTakashi Iwai1-0/+1
In the commit 8e85def5723e ("ALSA: hda: enable regmap internal locking"), we re-enabled the regmap lock due to the reported regression that showed the possible concurrent accesses. It was a temporary workaround, and there are still a few opened races even after the revert. In this patch, we cover those still opened windows with a proper mutex lock and disable the regmap internal lock again. First off, the patch introduces a new snd_hdac_device.regmap_lock mutex that is applied for each snd_hdac_regmap_*() call, including read, write and update helpers. The mutex is applied carefully so that it won't block the self-power-up procedure in the helper function. Also, this assures the protection for the accesses without regmap, too. The snd_hdac_regmap_update_raw() is refactored to use the standard regmap_update_bits_check() function instead of the open-code. The non-regmap case is still open-coded but it's an easy part. The all read and write operations are in the single mutex protection, so it's now race-free. In addition, a couple of new helper functions are added: snd_hdac_regmap_update_raw_once() and snd_hdac_regmap_sync(). Both are called from HD-audio legacy driver. The former is to initialize the given verb bits but only once when it's not initialized yet. Due to this condition, the function invokes regcache_cache_only(), and it's now performed inside the regmap_lock (formerly it was racy) too. The latter function is for simply invoking regcache_sync() inside the regmap_lock, which is called from the codec resume call path. Along with that, the HD-audio codec driver code is slightly modified / simplified to adapt those new functions. And finally, snd_hdac_regmap_read_raw(), *_write_raw(), etc are rewritten with the helper macro. It's just for simplification because the code logic is identical among all those functions. Tested-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Link: https://lore.kernel.org/r/20200109090104.26073-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-01-05ALSA: hda: More constificationsTakashi Iwai1-2/+2
Apply const prefix to the remaining possible places: the string tables, the rate tables, the verb tables, the index tables, etc. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-10-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-08-15Revert "ALSA: hda: Add codec on bus address table lately"Takashi Iwai1-12/+9
This reverts commit ee5f85d9290f ("ALSA: hda: Add codec on bus address table lately"). The commit caused several regression since I've overlooked that the function doesn't manage only the caddr_tbl but also the codec linked list that is referred indirectly in the other drivers. Revert for now to make everything back to work. Fixes: ee5f85d9290f ("ALSA: hda: Add codec on bus address table lately") Reported-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-08-14ALSA: hda: Unexport a few more stuffTakashi Iwai1-4/+2
Drop EXPORT_SYMBOL*() from a few more stuff in HD-audio core that aren't used outside. Particular the unsol event handler can be staticized now because the recent change removed all external callers. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-08-14ALSA: hda: Add codec on bus address table latelyTakashi Iwai1-9/+12
The call of snd_hdac_bus_add_device() is needed only for registering the codec onto the bus caddr_tbl[] that is referred essentially only in the unsol event handler. That is, the reason of this call and the release by the counter-part function snd_hdac_bus_remove_device() is just to assure that the unsol event gets notified to the codec. But the current implementation of the unsol notification wouldn't work properly when the codec is still in a premature init state. So this patch tries to work around it by delaying the caddr_tbl[] registration at the point of snd_hdac_device_register(). Also, the order of snd_hdac_bus_remove_device() and device_del() calls are shuffled to make sure that the unsol event is masked before deleting the device. BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=204565 Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-07-08Merge tag 'asoc-v5.3' of ↵Takashi Iwai1-0/+1
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-linus ASoC: Updates for v5.3 This is a very big update, mainly thanks to Morimoto-san's refactoring work and some fairly large new drivers. - Lots more work on moving towards a component based framework from Morimoto-san. - Support for force disconnecting muxes from Jerome Brunet. - New drivers for Cirrus Logic CS47L35, CS47L85 and CS47L90, Conexant CX2072X, Realtek RT1011 and RT1308. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-07-05ALSA: hda: Simplify snd_hdac_refresh_widgets()Takashi Iwai1-8/+5
Along with the recent fix for the races of snd_hdac_refresh_widgets() it turned out that the instantiation of widgets sysfs at snd_hdac_sysfs_reinit() could cause a race. The race itself was already covered later by extending the mutex protection range, the commit 98482377dc72 ("ALSA: hda: Fix widget_mutex incomplete protection"), but this also indicated that the call of *_reinit() is basically superfluous, as the widgets shall be created sooner or later from snd_hdac_device_register(). This patch removes the redundant call of snd_hdac_sysfs_reinit() at first. By this removal, the sysfs argument itself in snd_hdac_refresh_widgets() becomes superfluous, too, because the only case sysfs=false is always with codec->widgets=NULL. So, we drop this redundant argument as well. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-07-01ALSA: hda: Fix widget_mutex incomplete protectionEvan Green1-6/+12
The widget_mutex was introduced to serialize callers to hda_widget_sysfs_{re}init. However, its protection of the sysfs widget array is incomplete. For example, it is acquired around the call to hda_widget_sysfs_reinit(), which actually creates the new array, but isn't still acquired when codec->num_nodes and codec->start_nid is updated. So the lock ensures one thread sets up the new array at a time, but doesn't ensure which thread's value will end up in codec->num_nodes. If a larger num_nodes wins but a smaller array was set up, the next call to refresh_widgets() will touch free memory as it iterates over codec->num_nodes that aren't there. The widget_lock really protects both the tree as well as codec->num_nodes, start_nid, and end_nid, so make sure it's held across that update. It should also be held during snd_hdac_get_sub_nodes(), so that a very old read from that function doesn't end up clobbering a later update. Fixes: ed180abba7f1 ("ALSA: hda: Fix race between creating and refreshing sysfs entries") Signed-off-by: Evan Green <evgreen@chromium.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-05-21treewide: Add SPDX license identifier for missed filesThomas Gleixner1-0/+1
Add SPDX license identifiers to all files which: - Have no license information of any form - Have EXPORT_.*_SYMBOL_GPL inside which was used in the initial scan/conversion to ignore the file These files fall under the project license, GPL v2 only. The resulting SPDX license identifier is: GPL-2.0-only Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-13ALSA: hda: Fix race between creating and refreshing sysfs entriesAmadeusz Sławiński1-0/+7
hda_widget_sysfs_reinit() can free underlying codec->widgets structure on which widget_tree_create() operates. Add locking to prevent such issues from happening. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110382 Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2018-12-11ALSA: hda: Refactor display power managementTakashi Iwai1-17/+0
The current HD-audio code manages the DRM audio power via too complex redirections, and this seems even still unbalanced in a corner case as Intel DRM CI has been intermittently reporting. This patch is a big surgery for addressing the complexity and the possible unbalance. Basically the patch changes the display PM in the following ways: - Both HD-audio controller and codec drivers call a single helper, snd_hdac_display_power(). (Formerly, the display power control from a codec was done indirectly via link_power bus ops.) - snd_hdac_display_power() receives the codec address index. For turning on/off from the controller, pass HDA_CODEC_IDX_CONTROLLER. - snd_hdac_display_power() doesn't manage refcounts any longer, but keeps the power status in bitmap. If any of controller or codecs is turned on, the function updates the DRM power state via get_power() or put_power(). Also this refactor allows us more cleanup: - The link_power bus ops is dropped, so there is no longer indirect management, as mentioned in the above. - hdac_device link_power_control flag is moved to hda_codec display_power_control flag, as it's only for HDA legacy. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106525 Signed-off-by: Takashi Iwai <tiwai@suse.de>
2018-07-27ALSA: hda: Fix implicit PCM format type conversionTakashi Iwai1-1/+1
The PCM format type is defined with __bitwise, hence it can't be passed as integer but needs an explicit cast. In this patch, instead of the messy cast flood, define the format argument of snd_hdac_calc_stream_format() to be the proper snd_pcm_format_t type. This fixes sparse warnings like: sound/hda/hdac_device.c:760:38: warning: incorrect type in argument 1 (different base types) Signed-off-by: Takashi Iwai <tiwai@suse.de>
2018-02-12ALSA: hda: Copying sync power state helper to coreAbhijeet Kumar1-0/+35
The current sync_power_state is local to hda code, moving it core so that other users apart from hda legacy can use it. The helper function ensures the actual state reaches the target state. Signed-off-by: Abhijeet Kumar <abhijeet.kumar@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-10-19ALSA: hda: Avoid racy recreation of widget kobjectsTakashi Iwai1-33/+10
The refresh of HD-audio widget sysfs kobjects via snd_hdac_refresh_widget_sysfs() is slightly racy. The driver recreates the whole tree from scratch after deleting the whole. When CONFIG_DEBUG_KOBJECT_RELEASE option is used, kobject release doesn't happen immediately but delayed, while the re-creation of the same named kobject happens soon after invoking kobject_put(). This may end up with the conflicts of duplicated kobjects, as found in the bug report below. In this patch, we take another approach to refresh the tree: instead of recreating the whole tree, just add the new nodes and delete the non-existing nodes. Since the refresh happens only once at initialization, no longer race would happen. Along with the code change, merge snd_hdac_refresh_widget_sysfs() with the existing snd_hdac_refresh_widgets() with an additional bool flag for simplifying the code. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=197307 Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-06-20ALSA: hda: Fix potential race at unregistration and unsol eventsTakashi Iwai1-0/+1
When the codec device is unregistered / freed, it may release the resource while being used in an unsolicited event like the jack detection work. This leads to use-after-free. The fix here is to unregister the device at first, i.e. removing the codec from the list, then flushing the pending works to assure that all unsol events are gone. After this point, we're free from accessing the codec via unsol events, thus can release the resources gracefully. The issue was spotted originally by Intel CI, but it couldn't be reproduced reliably by its nature. So let's hope this fix really addresses the whole issues. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=196045 Reported-by: Martin Peres <martin.peres@free.fr> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-04-21ALSA: hda - Fix possible race on regmap bypass flipTakashi Iwai1-6/+4
HD-audio driver uses regmap cache bypass feature for reading a raw value without the cache. But this is racy since both the cached and the uncached reads may occur concurrently. The former is done via the normal control API access while the latter comes from the proc file read. Even though the regmap itself has the protection against the concurrent accesses, the flag set/reset is done without the protection, so it may lead to inconsistent state of bypass flag that doesn't match with the current read and occasionally result in a kernel WARNING like: WARNING: CPU: 3 PID: 2731 at drivers/base/regmap/regcache.c:499 regcache_cache_only+0x78/0x93 One way to work around such a problem is to wrap with a mutex. But in this case, the solution is simpler: for the uncached read, we just skip the regmap and directly calls its accessor. The verb execution there is protected by itself, so basically it's safe to call individually. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=116171 Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-03-08ALSA: hda - Fix unexpected resume through regmap code pathTakashi Iwai1-0/+16
HD-audio driver has a mechanism to trigger the runtime resume automatically at accessing the verbs. This auto-resume, however, causes the mutex deadlock when invoked from the regmap handler since the regmap keeps the mutex while auto-resuming. For avoiding that, there is some tricky check in the HDA regmap handler to return -EAGAIN error to back-off when the codec is powered down. Then the caller of regmap r/w will retry after properly turning on the codec power. This works in most cases, but there seems a slight race between the codec power check and the actual on-demand auto-resume trigger. This resulted in the lockdep splat, eventually leading to a real deadlock. This patch tries to address the race window by getting the runtime PM refcount at the check time using pm_runtime_get_if_in_use(). With this call, we can keep the power on only when the codec has been already turned on, and back off if not. For keeping the code consistency, the code touching the runtime PM is stored in hdac_device.c although it's used only locally in hdac_regmap.c. Reported-by: Jiri Slaby <jslaby@suse.cz> Cc: <stable@vger.kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-28ALSA: hda - Add / fix kernel doc commentsTakashi Iwai1-4/+6
Give some readable comment in kernel doc style for each exported function, as I promised in the previous meetings. While we're at it, fix the wrong comments, too. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-20ALSA: hda - Add a common helper to give the codec modalias stringTakashi Iwai1-0/+15
This patch provide a new common helper function, snd_hdac_codec_modalias(), to give the codec modalias name string. This function will be used by multiple places in the later patches. 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-15ALSA: hda - consolidate chip rename functionsTakashi Iwai1-0/+22
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: hdac: Copy codec helpers to coreSubhransu S. Prusty1-0/+81
The current codec helpers are local to hda code and needs to be moved to core so that other users can use it. The helpers to read/write the codec and to check the power state of widgets is copied Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com> Signed-off-by: Vinod Koul <vinod.koul@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-08-26ALSA: hda - Fix widget sysfs tree corruption after refreshTakashi Iwai1-6/+8
When snd_hdac_refresh_widget_sysfs() is called before the first hda_widget_sysfs_init(), the next call overrides and eventually fails. This results in unexpected Oops, something like: BUG: unable to handle kernel NULL pointer dereference at 00000000000000c8 IP: [<ffffffff8180e2a3>] hdmi_chmap_ctl_info+0x23/0x40 The fix is to add a check of the existing sysfs tree. Also, for more safety, this patch adds the checks of device_is_registered() in snd-hdac_refresh_wdiget_sysfs(), too. Fixes: fa4f18b4f402 ('ALSA: hda - Refresh widgets sysfs at probing Haswell+ HDMI codecs') Bugizlla: https://bugzilla.kernel.org/show_bug.cgi?id=103431 Reported-by: Andreas Reis <andreas.reis@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-08-21ALSA: hdac: add snd_hdac_refresh_widget_sysfs()Vinod Koul1-0/+28
Some codecs like Intel HDMI by default do not show up all the pins, they have to be manually enabled, so we need to refresh the codec widgets and then recreate the sysfs tree. So add new API snd_hdac_refresh_widget_sysfs() to do this. It should be be used by codec driver after sending magic verbs to codec Signed-off-by: Vinod Koul <vinod.koul@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-07-17ALSA: hda - Check the return value from pm_runtime_get/put*()Takashi Iwai1-8/+18
This patch changes the return type of snd_hdac_power_up/down() and variants to pass the error code from the underlying pm_runtime_get/put() calls. Currently they are ignored, but in most places, these should be handled properly. As an example, the regmap handler is updated to check the return value and accesses the register only when the wakeup succeeds. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-29ALSA: hda - allow a codec to control the link powerMengdong Lin1-0/+15
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-16ALSA: hda - Move PCM format and rate handling code to core libraryTakashi Iwai1-0/+300
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-13ALSA: hda - Fix another race in runtime PM refcountingTakashi Iwai1-0/+30
Although some races in runtime PM refcount was fixed by the commit [664c715573c2: ALSA: hda - Work around races of power up/down with runtime PM], there is still a race in the following case: CPU0: CPU1 : runtime suspend: codec->in_pm = 1 snd_hdac_power_up_pm(): pm_runtime_get_sync() skipped suspend finished: codec->in_pm = 0 snd_hdac_power_down_pm(): pm_runtime_put_*() is called! For avoiding this situation, increment in_pm flag atomically when it's non-zero, and decrement accordingly, to ensure that in_pm is set consistently for the whole concurrent operations. Also, since atomic_inc_not_zero() and atomic_dec_if_positive() are lengthy inline functions, move snd_hdac_power_up_pm() and _down_pm() to sound/hda/hdac_device.c as no inline functions. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-08ALSA: hda - Work around races of power up/down with runtime PMTakashi Iwai1-9/+7
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 Iwai1-6/+50
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-04ALSA: hda - Fix subsystem ID read regressionDavid Henningsson1-1/+1
A regression was introduced in 7639a06c23c7d4cda3: if AC_PAR_SUBSYSTEM_ID reads as zero, one should retry using AC_VERB_GET_SUBSYSTEM_ID. This seems to hit many codecs (my own laptop included), and causes quirks for some machines not to apply correctly. Reported-by: TienFu Chen <tienfu.chen@canonical.com> Signed-off-by: David Henningsson <david.henningsson@canonical.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-23ALSA: hda - Use regmap for parameter caches, tooTakashi Iwai1-0/+23
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 - Implement uncached version of parameter readsTakashi Iwai1-1/+25
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-23ALSA: hda - Use regmap for codec parameter readsTakashi Iwai1-12/+9
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 - Fix possible runtime PM refcount unbalanceTakashi Iwai1-2/+1
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 - Support indirect execution of verbsTakashi Iwai1-1/+23
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-23ALSA: hda - Add widget sysfs treeTakashi Iwai1-0/+35
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-23ALSA: hda - Move a part of hda_codec stuff into hdac_deviceTakashi Iwai1-0/+471
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>