summaryrefslogtreecommitdiff
path: root/sound/pci/hda/hda_tegra.c
AgeCommit message (Collapse)AuthorFilesLines
2023-08-08ALSA: hda/tegra: refactor deprecated strncpyJustin Stitt1-2/+2
`strncpy` is deprecated for use on NUL-terminated destination strings [1]. A suitable replacement is `strscpy` [2] due to the fact that it guarantees NUL-termination on its destination buffer argument which is _not_ the case for `strncpy`! It should be noted that the current implementation is unlikely to have a bug because `drv_name` is a string literal with a size of 9 while `card->driver` has a size of 16. However, it is probably worthwhile to switch to a more robust and less ambiguous interface. [1]: www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [2]: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html Link: https://github.com/KSPP/linux/issues/90 Cc: linux-hardening@vger.kernel.org Signed-off-by: Justin Stitt <justinstitt@google.com> Link: https://lore.kernel.org/r/20230807-sound-pci-hda-v1-1-6d9cdcd085ca@google.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-07-16ALSA: Explicitly include correct DT includesRob Herring1-1/+2
The DT of_device.h and of_platform.h date back to the separate of_platform_bus_type before it as merged into the regular platform bus. As part of that merge prepping Arm DT support 13 years ago, they "temporarily" include each other. They also include platform_device.h and of.h. As a result, there's a pretty much random mix of those include files used throughout the tree. In order to detangle these headers and replace the implicit includes with struct declarations, users need to explicitly include the correct includes. Signed-off-by: Rob Herring <robh@kernel.org> Link: https://lore.kernel.org/r/20230714175109.4066599-1-robh@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-03-20ALSA: hda/tegra: Convert to platform remove callback returning voidUwe Kleine-König1-4/+2
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is (mostly) ignored and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new() which already returns void. Trivially convert this driver from always returning zero in the remove callback to the void returning variant. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Acked-by: Takashi Iwai <tiwai@suse.de> Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com> Link: https://lore.kernel.org/r/20230315150745.67084-10-u.kleine-koenig@pengutronix.de Signed-off-by: Mark Brown <broonie@kernel.org>
2023-02-08ALSA: core: Make snd_card_free() return voidUwe Kleine-König1-4/+2
The function returns 0 unconditionally. Make it return void instead and simplify all callers accordingly. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Jaroslav Kysela <perex@perex.cz> Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Acked-by: Geoff Levand <geoff@infradead.org> Acked-by: Thierry Reding <treding@nvidia.com> Link: https://lore.kernel.org/r/20230207191907.467756-4-u.kleine-koenig@pengutronix.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2022-09-06ALSA: hda/tegra: Align BDL entry to 4KB boundaryMohan Kumar1-1/+2
AZA HW may send a burst read/write request crossing 4K memory boundary. The 4KB boundary is not guaranteed by Tegra HDA HW. Make SW change to include the flag AZX_DCAPS_4K_BDLE_BOUNDARY to align BDLE to 4K boundary. Signed-off-by: Mohan Kumar <mkumard@nvidia.com> Link: https://lore.kernel.org/r/20220905172420.3801-1-mkumard@nvidia.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
2022-04-12ALSA: hda/tegra: Enable Jack poll for tegraMohan Kumar1-0/+2
Enable HDA Jack polling for the tegra platforms as Jack detection logic doesn't work when the HDACODEC in runtime suspended state as unsol event won't be triggered during D3 state. This will help the userspace audio setting controls to correctly show available audio devices in gui. Signed-off-by: Mohan Kumar <mkumard@nvidia.com> Link: https://lore.kernel.org/r/20220411073210.23445-3-mkumard@nvidia.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
2022-02-21ALSA: hda/tegra: Hardcode GCAP ISS value on T234Mohan Kumar1-0/+12
The GCAP register on Tegra234 implies no Input Streams(ISS) supported, but the HW output stream descriptor programming should start with offset 0x20*4 from base stream descriptor address. This will be a problem while calculating the offset for output stream descriptor which will be considering input stream also. So here output stream starts with offset 0 which is wrong as HW register for output stream offset starts with 4. So hardcode the input stream numbers to 4 to avoid the issue in offset calculation. Signed-off-by: Mohan Kumar <mkumard@nvidia.com> Link: https://lore.kernel.org/r/20220216092240.26464-3-mkumard@nvidia.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
2022-02-21ALSA: hda/tegra: Add Tegra234 hda driver supportMohan Kumar1-2/+19
Add hda driver support for the Tegra234 chip. The hdacodec on this chip now supports DP MST feature, HDA block contains azalia controller and one hda-codec instance by supporting 4 independent output streams over DP MST mode. There is no input stream support. Signed-off-by: Mohan Kumar <mkumard@nvidia.com> Link: https://lore.kernel.org/r/20220216092240.26464-2-mkumard@nvidia.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
2022-01-01ALSA: hda/tegra: Fix Tegra194 HDA reset failureSameer Pujar1-9/+34
HDA regression is recently reported on Tegra194 based platforms. This happens because "hda2codec_2x" reset does not really exist in Tegra194 and it causes probe failure. All the HDA based audio tests fail at the moment. This underlying issue is exposed by commit c045ceb5a145 ("reset: tegra-bpmp: Handle errors in BPMP response") which now checks return code of BPMP command response. Fix this issue by skipping unavailable reset on Tegra194. Cc: stable@vger.kernel.org Signed-off-by: Sameer Pujar <spujar@nvidia.com> Reviewed-by: Dmitry Osipenko <digetx@gmail.com> Link: https://lore.kernel.org/r/1640260431-11613-2-git-send-email-spujar@nvidia.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-06-22ALSA: hda: Add IRQ check for platform_get_irq()Jiajun Cao1-0/+3
The function hda_tegra_first_init() neglects to check the return value after executing platform_get_irq(). hda_tegra_first_init() should check the return value (if negative error number) for errors so as to not pass a negative value to the devm_request_irq(). Fix it by adding a check for the return value irq_id. Signed-off-by: Jiajun Cao <jjcao20@fudan.edu.cn> Signed-off-by: Xin Tan <tanxin.ctf@gmail.com> Reviewed-by: Thierry Reding <treding@nvidia.com> Link: https://lore.kernel.org/r/20210622131947.94346-1-jjcao20@fudan.edu.cn Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-06-12ALSA: hda/tegra: Use devm_platform_get_and_ioremap_resource()Yang Yingliang1-3/+1
Use devm_platform_get_and_ioremap_resource() to simplify code. Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Link: https://lore.kernel.org/r/20210610131922.134788-1-yangyingliang@huawei.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-01-26ALSA: hda/tegra: Remove unnecessary null-check from hda_tegra_runtime_resume()Dmitry Osipenko1-1/+1
The "chip" can't be NULL in hda_tegra_runtime_resume() because code would crash otherwise. Let's remove the unnecessary check in order to clean up code a tad. Tested-by: Peter Geis <pgwipeout@gmail.com> # Ouya T30 audio works Tested-by: Matt Merhar <mattmerhar@protonmail.com> # Ouya T30 boot-tested Suggested-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Link: https://lore.kernel.org/r/20210120003154.26749-4-digetx@gmail.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-01-26ALSA: hda/tegra: Reset hardwareDmitry Osipenko1-0/+20
Reset hardware on RPM-resume in order to bring it into a predictable state. Tested-by: Peter Geis <pgwipeout@gmail.com> # Ouya T30 audio works Tested-by: Matt Merhar <mattmerhar@protonmail.com> # Ouya T30 boot-tested Tested-by: Nicolas Chauvet <kwizart@gmail.com> # TK1 boot-tested Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Link: https://lore.kernel.org/r/20210120003154.26749-3-digetx@gmail.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-01-26ALSA: hda/tegra: Use clk_bulk helpersDmitry Osipenko1-59/+9
Use clk_bulk helpers to make code cleaner. Note that this patch changed the order in which clocks are enabled to make code look nicer, but this doesn't matter in terms of hardware. Tested-by: Peter Geis <pgwipeout@gmail.com> # Ouya T30 audio works Tested-by: Matt Merhar <mattmerhar@protonmail.com> # Ouya T30 boot-tested Tested-by: Nicolas Chauvet <kwizart@gmail.com> # TK1 boot-tested Acked-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Link: https://lore.kernel.org/r/20210120003154.26749-2-digetx@gmail.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-01-12ALSA: hda/tegra: fix tegra-hda on tegra30 socPeter Geis1-1/+1
Currently hda on tegra30 fails to open a stream with an input/output error. For example: speaker-test -Dhw:0,3 -c 2 speaker-test 1.2.2 Playback device is hw:0,3 Stream parameters are 48000Hz, S16_LE, 2 channels Using 16 octaves of pink noise Rate set to 48000Hz (requested 48000Hz) Buffer size range from 64 to 16384 Period size range from 32 to 8192 Using max buffer size 16384 Periods = 4 was set period_size = 4096 was set buffer_size = 16384 0 - Front Left Write error: -5,Input/output error xrun_recovery failed: -5,Input/output error Transfer failed: Input/output error The tegra-hda device was introduced in tegra30 but only utilized in tegra124 until recent chips. Tegra210/186 work only due to a hardware change. For this reason it is unknown when this issue first manifested. Discussions with the hardware team show this applies to all current tegra chips. It has been resolved in the tegra234, which does not have hda support at this time. The explanation from the hardware team is this: Below is the striping formula referenced from HD audio spec. { ((num_channels * bits_per_sample) / number of SDOs) >= 8 } The current issue is seen because Tegra HW has a problem with boundary condition (= 8) for striping. The reason why it is not seen on Tegra210/Tegra186 is because it uses max 2SDO lines. Max SDO lines is read from GCAP register. For the given stream (channels = 2, bps = 16); ratio = (channels * bps) / NSDO = 32 / NSDO; On Tegra30, ratio = 32/4 = 8 (FAIL) On Tegra210/186, ratio = 32/2 = 16 (PASS) On Tegra194, ratio = 32/4 = 8 (FAIL) ==> Earlier workaround was applied for it If Tegra210/186 is forced to use 4SDO, it fails there as well. So the behavior is consistent across all these chips. Applying the fix in [1] universally resolves this issue on tegra30-hda. Tested on the Ouya game console and the tf201 tablet. [1] commit 60019d8c650d ("ALSA: hda/tegra: workaround playback failure on Tegra194") Reviewed-by: Jon Hunter <jonathanh@nvidia.com> Tested-by: Ion Agorria <ion@agorria.com> Reviewed-by: Sameer Pujar <spujar@nvidia.com> Acked-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Peter Geis <pgwipeout@gmail.com> Link: https://lore.kernel.org/r/20210108135913.2421585-3-pgwipeout@gmail.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-08-25ALSA: hda/tegra: Program WAKEEN register for TegraMohan Kumar1-0/+7
The WAKEEN bits are used to indicate which bits in the STATESTS register may cause wake event during the codec state change request. Configure the WAKEEN register for the Tegra to detect the wake events. Signed-off-by: Mohan Kumar <mkumard@nvidia.com> Acked-by: Sameer Pujar <spujar@nvidia.com> Link: https://lore.kernel.org/r/20200825052415.20626-3-mkumard@nvidia.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-08-05ALSA: hda/tegra: Add 100us dma stop delayMohan Kumar1-0/+1
Tegra HDA has audio data buffer for upto tens of frames, this buffer can help to avoid underflow. HW will keep issuing new data fetch request when buffers are not full and current BDL is not done. When SW disable DMA RUN bit for a stream, HW can't cancel the already issued data fetch request and hence it can't stop DMA. HW has to wait for all issued data fetch request get data returned before it stops DMA. This HW behavior is not in sync with HDA spec which says DMA RUN bit should be cleared within 1 audio frame. For Tegra, DMA RUN bit was active for more than one audio frame, due to this the timeout in snd_hdac_stream_sync function is not helping. When Stream reset set and clear happens during DMA RUN bit active state it results in Memory Decode error. Unfortunately, there is no way to detect when these data accesses have completed, but testing has shown that a 100us delay between Stream reset set and clear operation for Tegra avoids the memory decode error. Therefore, adding a 100us dma stop delay. Signed-off-by: Mohan Kumar <mkumard@nvidia.com> Link: https://lore.kernel.org/r/20200805095221.5476-4-mkumard@nvidia.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-08-05ASoC: hda/tegra: Set buffer alignment to 128 bytesMohan Kumar1-0/+2
Set chip->align_buffer_size to 1 for Tegra platforms to make the buffer alignment to be multiple of 128 bytes. This fix is applied as gstreamer alsasink gets stuck with the default buffer-time and latency-time parameters with 4 byte buffer alignment. Signed-off-by: Mohan Kumar <mkumard@nvidia.com> Link: https://lore.kernel.org/r/20200805095221.5476-2-mkumard@nvidia.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-07-14ALSA: hda/tegra: Disable sync-write operationJon Hunter1-0/+1
Commit f34a4c9dd4ca ("ALSA: hda: Enable sync-write operation as default for all controllers") enabled sync-write for all controllers and this is causing audio playback on the Tegra186 HDA device to fail. For now, disable sync-write support for Tegra to fix this. Fixes: f34a4c9dd4ca ("ALSA: hda: Enable sync-write operation as default for all controllers") Signed-off-by: Jon Hunter <jonathanh@nvidia.com> Link: https://lore.kernel.org/r/20200714160841.2293-1-jonathanh@nvidia.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-05-04ALSA: hda/tegra: workaround playback failure on Tegra194Sameer Pujar1-0/+17
Tegra194 has 4 SDO lines and with this configuration playback fails for 44.1K/48K, 2-channel and 16-bps. It results in below print, "aplay: pcm_write:2011: write error: Input/output error" Below relation is used to derive stripe control and is referenced from HD Audio Specification: Revision 1.0a. { ((num_channels * bits_per_sample) / number of SDOs) >= 8 } Due to a legacy HW design problem, playback issue is hit while using a stripe value resulting from above formula when ratio is '8'. Thus it is recommended that the ratio must be greater than '8'. Since the number of SDO lines is in powers of 2, next available ratio '16' is used as a limiting factor on Tegra194 to workaround the problem. Signed-off-by: Sameer Pujar <spujar@nvidia.com> Link: https://lore.kernel.org/r/1588580176-2801-4-git-send-email-spujar@nvidia.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-05-04ALSA: hda/tegra: correct number of SDO lines for Tegra194Sameer Pujar1-0/+33
Tegra194 supports 4 SDO lines but GCAP register indicates 2 lines. Thus it does not reflect the true capability of the HW. This patch presents a workaround by updating NSDO value accordingly in T_AZA_DBG_CFG_2 register. Signed-off-by: Sameer Pujar <spujar@nvidia.com> Link: https://lore.kernel.org/r/1588580176-2801-2-git-send-email-spujar@nvidia.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-01-20Merge branch 'for-linus' into for-nextTakashi Iwai1-0/+1
Resolved the merge conflict in HD-audio Tegra driver. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-01-20ALSA: hda: Apply aligned MMIO access only conditionallyTakashi Iwai1-0/+1
It turned out that the recent simplification of HD-audio bus access helpers caused a regression on the virtual HD-audio device on QEMU with ARM platforms. The driver got a CORB/RIRB timeout and couldn't probe any codecs. The essential difference that caused a problem was the enforced aligned MMIO accesses by simplification. Since snd-hda-tegra driver is enabled on ARM, it enables CONFIG_SND_HDA_ALIGNED_MMIO, which makes the all HD-audio drivers using the aligned MMIO accesses. While this is mandatory for snd-hda-tegra, it seems that snd-hda-intel on ARM gets broken by this access pattern. For addressing the regression, this patch introduces a new flag, aligned_mmio, to hdac_bus object, and applies the aligned MMIO only when this flag is set. This change affects only platforms with CONFIG_SND_HDA_ALIGNED_MMIO set, i.e. mostly only for ARM platforms. Unfortunately the patch became a big bigger than it should be, just because the former calls didn't take hdac_bus object in the argument, hence we had to extend the call patterns. Fixes: 19abfefd4c76 ("ALSA: hda: Direct MMIO accesses") BugLink: https://bugzilla.opensuse.org/show_bug.cgi?id=1161152 Cc: <stable@vger.kernel.org> Link: https://lore.kernel.org/r/20200120104127.28985-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-01-03ALSA: hda: Constify snd_device_ops definitionsTakashi Iwai1-1/+1
Now we may declare const for snd_device_ops definitions, so let's do it for optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-9-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-13ALSA: hda: Unify get_response handlingTakashi Iwai1-1/+1
Now most of the get_response handling became quite similar between HDA-core and legacy drivers, and the only differences are: - the handling of extra-long polling delay for some codecs - the debug message for the stalled communication and both are worth to share in the common code. This patch unifies the code into snd_hdac_bus_get_response(), and use this from the legacy get_response callback. It results in a good amount of code reduction in the end. Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Link: https://lore.kernel.org/r/20191212191101.19517-3-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-12ALSA: hda: tegra: Fix unused variable compile warningTakashi Iwai1-1/+0
Forgot to remove the variable declaration as well in the last commit. sound/pci/hda/hda_tegra.c: In function 'hda_tegra_runtime_suspend': sound/pci/hda/hda_tegra.c:169:19: warning: unused variable 'bus' [-Wunused-variable] Fixes: f36da9406e66 ("ALSA: hda: Support PCM sync_stop") Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> Link: https://lore.kernel.org/r/20191212080518.6522-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-11ALSA: hda: Support PCM sync_stopTakashi Iwai1-3/+1
The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. It's cleared and reset dynamically at IRQ re-acquiring for the PM resume, too. Link: https://lore.kernel.org/r/20191210063454.31603-22-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-08-08ALSA: hda: Direct MMIO accessesTakashi Iwai1-67/+1
HD-audio drivers access to the mmio registers indirectly via the corresponding bus->io_ops callbacks. This is because some platform (notably Tegra SoC) requires the word-aligned access. But it's rather a rare case, and other platforms suffer from the penalties by indirect calls unnecessarily. This patch is an attempt to optimize and cleanup for this situation. Now the special aligned access is used only when a new kconfig CONFIG_SND_HDA_ALIGNED_MMIO is set. And the HD-audio core itself provides the aligned MMIO access helpers instead of the driver side. If Kconfig isn't set (as default), the standard helpers like readl() or writel() are used directly. A couple of places in ASoC Intel drivers have the access via io_ops reg_writel(), and they are replaced with the direct writel() calls. And now with this patch, the whole bus->io_ops becomes empty, so it's dropped completely. The bus initialization functions are changed accordingly as well to drop the whole bus->io_ops. Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-08-08ALSA: hda: Remove page allocation redirectionTakashi Iwai1-16/+0
The HD-audio core allocates and releases pages via driver's specific dma_alloc_pages and dma_free_pages ops defined in bus->io_ops. This was because some platforms require the uncached pages and the handling of page flags had to be done locally in the driver code. Since the recent change in ALSA core memory allocator, we can simply pass SNDRV_DMA_TYPE_DEV_UC for the uncached pages, and the only difference became about this type to be passed to the core allocator. That is, it's good time for cleaning up the mess. This patch changes the allocation code in HD-audio core to call the core allocator directly so that we get rid of dma_alloc_pages and dma_free_pages io_ops. If a driver needs the uncached pages, it has to set bus->dma_type right after the bus initialization. This is merely a code refactoring and shouldn't bring any behavior changes. Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-05-30treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 201Thomas Gleixner1-13/+1
Based on 1 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms and conditions of the gnu general public license version 2 as published by the free software foundation this program is distributed in the hope it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details you should have received a copy of the gnu general public license along with this program if not see http www gnu org licenses extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference in 228 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Allison Randal <allison@lohutok.net> Reviewed-by: Steve Winslow <swinslow@gmail.com> Reviewed-by: Richard Fontana <rfontana@redhat.com> Reviewed-by: Alexios Zavras <alexios.zavras@intel.com> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190528171438.107155473@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-03-13ALSA: hda/tegra: avoid build error without CONFIG_PMArnd Bergmann1-8/+4
The #ifdef protection around the PM functions is wrong, leading to a failed reference in some configurations: sound/pci/hda/hda_tegra.c: In function 'hda_tegra_runtime_suspend': sound/pci/hda/hda_tegra.c:273:2: error: implicit declaration of function 'hda_tegra_disable_clocks'; did you mean 'hda_tegra_enable_clocks'? [-Werror=implicit-function-declaration] Better remove the #ifdefs entirely and rely on the compiler silently dropping unused functions marked __maybe_unused. Fixes: 707e0759f2f4 ("ALSA: hda/tegra: implement runtime suspend/resume") Acked-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-02-22ALSA: hda/tegra: sound card name from device treeSameer Pujar1-12/+6
A platform can have multiple sound cards for different audio paths. Following is the print seen duirng device boot for jetson-xavier, ALSA device list: #0: nvidia,p2972-0000 at 0x3518000 irq 17 By looking at above, it is not very clear if the sound card is for HDA. It becomes confusing when platform has registered multiple cards, and platform model name is used for card. This patch uses "nvidia,model" property mentioned in hda device tree to get the card name. Since property is optional, legacy boards will continue to use "tegra-hda". Custom name can be passed wherever needed. This naming convention is conistent with the way sound cards are named in general. Signed-off-by: Sameer Pujar <spujar@nvidia.com> Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-01-22ALSA: hda/tegra: add driver flag for runtime PMSameer Pujar1-1/+2
AZX_DCAPS_PM_RUNTIME flag is added to indicate support for runtime PM. azx_has_pm_runtime() is used to check if above is enabled and thus forbid runtime PM calls if needed. Signed-off-by: Sameer Pujar <spujar@nvidia.com> Reviewed-by: Ravindra Lokhande <rlokhande@nvidia.com> Reviewed-by: Mohan Kumar D <mkumard@nvidia.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-01-22ALSA: hda/tegra: implement runtime suspend/resumeSameer Pujar1-16/+33
This patch moves clock enable/disable from system resume/suspend to runtime resume/suspend respectively. Along with this hda controller chip init or stop is also moved. System resume/suspend can invoke runtime callbacks and do necessary setup. chip->running can be used to check for probe completion and device access during runtime_resume or runtime_suspend can be avoided if probe is not yet finished. This helps to avoid kernel panic during boot where runtime PM callbacks can happen from system PM. Signed-off-by: Sameer Pujar <spujar@nvidia.com> Reviewed-by: Ravindra Lokhande <rlokhande@nvidia.com> Reviewed-by: Mohan Kumar D <mkumard@nvidia.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-01-22ALSA: hda/tegra: remove redundant clock enable APISameer Pujar1-7/+0
Explicit clock enable is not required during probe, as this would be managed by runtime PM calls. Clock can be enabled/disabled in runtime resume/suspend. This way it is easier to balance clock enable/disable counts. Signed-off-by: Sameer Pujar <spujar@nvidia.com> Reviewed-by: Ravindra Lokhande <rlokhande@nvidia.com> Reviewed-by: Mohan Kumar D <mkumard@nvidia.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-01-22ALSA: hda/tegra: add runtime PM callbacksSameer Pujar1-0/+15
This patch adds skeleton of runtime suspend and resume callbacks. Signed-off-by: Sameer Pujar <spujar@nvidia.com> Reviewed-by: Ravindra Lokhande <rlokhande@nvidia.com> Reviewed-by: Mohan Kumar D <mkumard@nvidia.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-01-22ALSA: hda/tegra: get clock handles early in probeSameer Pujar1-16/+27
Moved devm_clk_get() API calls to a separate function and the same can be called early in the probe. This is done before runtime PM for the device is enabled. The runtime resume/suspend callbacks can later enable/disable clocks respectively(the support would be added in subsequent patches). Clock handles should be available by the time runtime suspend/resume calls can happen. Signed-off-by: Sameer Pujar <spujar@nvidia.com> Reviewed-by: Ravindra Lokhande <rlokhande@nvidia.com> Reviewed-by: Mohan Kumar D <mkumard@nvidia.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-01-22ALSA: hda/tegra: runtime power management supportSameer Pujar1-1/+14
This patch enables runtime power management(runtime PM) support for hda. pm_runtime_enable() and pm_runtime_disable() are added during device probe and remove respectively. The runtime PM callbacks will be forbidden if hda controller does not have support for runtime PM. pm_runtime_get_sync() and pm_runtime_put() are added for hda register access. The callbacks for above will be added in subsequent patches. Signed-off-by: Sameer Pujar <spujar@nvidia.com> Reviewed-by: Ravindra Lokhande <rlokhande@nvidia.com> Reviewed-by: Mohan Kumar D <mkumard@nvidia.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-01-01ALSA: hda/tegra: clear pending irq handlersSameer Pujar1-0/+2
Even after disabling interrupts on the module, it could be possible that irq handlers are still running. System hang is seen during suspend path. It was found that, there were pending writes on the HDA bus and clock was disabled by that time. Above mentioned issue is fixed by clearing any pending irq handlers before disabling clocks and returning from hda suspend. Suggested-by: Mohan Kumar <mkumard@nvidia.com> Suggested-by: Dara Ramesh <dramesh@nvidia.com> Signed-off-by: Sameer Pujar <spujar@nvidia.com> Cc: <stable@vger.kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2018-12-03ALSA: hda/tegra - Probe up to 8 codecsThierry Reding1-1/+1
Recent devices support more than the 4 codecs that the AZX core will probe by default. Probe up to 8 codecs to make sure all of them are enumerated. Suggested-by: Sameer Pujar <spujar@nvidia.com> Signed-off-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2018-11-29ALSA: hda/tegra: compatible string as shortnameSameer Pujar1-1/+19
By default HDA sound card is registered with shortname "tegra-hda". Same driver is used across tegra platforms and it is necessary to distinguish between platforms to use platform specific settings from userspace. One such example is, hdmi port on different platforms use different alsa pcm device ID. For hdmi playback to work it should open correct pcm device depending on the platform. This patch applies shortname from first compatible string provided in root node of device tree. Userspace then can use this card name to apply specific settings. Signed-off-by: Sameer Pujar <spujar@nvidia.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2018-08-30Merge tag 'hda-codec-h-move' of ↵Takashi Iwai1-1/+1
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-next ALSA: Move hda_codec.h to include/sound For easier sharing with ASoC.
2018-08-30ALSA: hda: move hda_codec.h to include/soundPierre-Louis Bossart1-1/+1
As suggested by Takashi, move this header file to make it easier to include from e.g. the Intel Skylake driver in follow-up patches Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2018-08-28ALSA: hda: Remove substream allocation/free opsTakashi Iwai1-17/+1
Since we dropped the memory page fiddling in the own allocators in hda_intel.c, the substream allocation and free ops in both hda_intel.c and hda_tegra.c became nothing but the simple calls of the standard snd_pcm_lib helpers. As both are identical, there is no longer need for indirect calls via ops; it's a good opportunity for removing ops and simplifying the codes. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-06-22ALSA: hda/tegra: iomem fixups for sparse warningsBen Dooks1-10/+10
The readl/writel are not being passed __iomem annotated variables, so fix the following sparse warnings by adding __iomem in: sound/pci/hda/hda_tegra.c:120:9: warning: incorrect type in argument 2 (different address spaces) sound/pci/hda/hda_tegra.c:120:9: expected void volatile [noderef] <asn:2>*addr sound/pci/hda/hda_tegra.c:120:9: got unsigned int [usertype] *addr sound/pci/hda/hda_tegra.c:125:16: warning: incorrect type in argument 1 (different address spaces) sound/pci/hda/hda_tegra.c:125:16: expected void const volatile [noderef] <asn:2>*addr sound/pci/hda/hda_tegra.c:125:16: got unsigned int [usertype] *addr sound/pci/hda/hda_tegra.c:134:13: warning: incorrect type in argument 1 (different address spaces) sound/pci/hda/hda_tegra.c:134:13: expected void const volatile [noderef] <asn:2>*addr sound/pci/hda/hda_tegra.c:134:13: got void *dword_addr sound/pci/hda/hda_tegra.c:137:9: warning: incorrect type in argument 2 (different address spaces) sound/pci/hda/hda_tegra.c:137:9: expected void volatile [noderef] <asn:2>*addr sound/pci/hda/hda_tegra.c:137:9: got void *dword_addr sound/pci/hda/hda_tegra.c:146:13: warning: incorrect type in argument 1 (different address spaces) sound/pci/hda/hda_tegra.c:146:13: expected void const volatile [noderef] <asn:2>*addr sound/pci/hda/hda_tegra.c:146:13: got void *dword_addr sound/pci/hda/hda_tegra.c:156:13: warning: incorrect type in argument 1 (different address spaces) sound/pci/hda/hda_tegra.c:156:13: expected void const volatile [noderef] <asn:2>*addr sound/pci/hda/hda_tegra.c:156:13: got void *dword_addr sound/pci/hda/hda_tegra.c:159:9: warning: incorrect type in argument 2 (different address spaces) sound/pci/hda/hda_tegra.c:159:9: expected void volatile [noderef] <asn:2>*addr sound/pci/hda/hda_tegra.c:159:9: got void *dword_addr sound/pci/hda/hda_tegra.c:168:13: warning: incorrect type in argument 1 (different address spaces) sound/pci/hda/hda_tegra.c:168:13: expected void const volatile [noderef] <asn:2>*addr sound/pci/hda/hda_tegra.c:168:13: got void *dword_addr sound/pci/hda/hda_tegra.c:173:23: warning: incorrect type in initializer (incompatible argument 2 (different address spaces)) sound/pci/hda/hda_tegra.c:173:23: expected void ( *reg_writel )( ... ) sound/pci/hda/hda_tegra.c:173:23: got void ( static [toplevel] *<noident> )( ... ) sound/pci/hda/hda_tegra.c:174:22: warning: incorrect type in initializer (incompatible argument 1 (different address spaces)) sound/pci/hda/hda_tegra.c:174:22: expected unsigned int ( *reg_readl )( ... ) sound/pci/hda/hda_tegra.c:174:22: got unsigned int ( static [toplevel] *<noident> )( ... ) sound/pci/hda/hda_tegra.c:175:23: warning: incorrect type in initializer (incompatible argument 2 (different address spaces)) sound/pci/hda/hda_tegra.c:175:23: expected void ( *reg_writew )( ... ) sound/pci/hda/hda_tegra.c:175:23: got void ( static [toplevel] *<noident> )( ... ) sound/pci/hda/hda_tegra.c:176:22: warning: incorrect type in initializer (incompatible argument 1 (different address spaces)) sound/pci/hda/hda_tegra.c:176:22: expected unsigned short ( *reg_readw )( ... ) sound/pci/hda/hda_tegra.c:176:22: got unsigned short ( static [toplevel] *<noident> )( ... ) sound/pci/hda/hda_tegra.c:177:23: warning: incorrect type in initializer (incompatible argument 2 (different address spaces)) sound/pci/hda/hda_tegra.c:177:23: expected void ( *reg_writeb )( ... ) sound/pci/hda/hda_tegra.c:177:23: got void ( static [toplevel] *<noident> )( ... ) sound/pci/hda/hda_tegra.c:178:22: warning: incorrect type in initializer (incompatible argument 1 (different address spaces)) sound/pci/hda/hda_tegra.c:178:22: expected unsigned char ( *reg_readb )( ... ) sound/pci/hda/hda_tegra.c:178:22: got unsigned char ( static [toplevel] *<noident> )( ... ) Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk> Acked-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-12-17ALSA: hda - Raise AZX_DCAPS_RIRB_DELAY handling into top driversTakashi Iwai1-2/+3
AZX_DCAPS_RIRB_DELAY is dedicated only for Nvidia and its purpose is just to set a flag in bus. So it's better to be set in the toplevel driver, either hda_intel.c or hda_tegra.c, instead of the common hda_controller.c. This also allows us to strip this flag from dcaps, so save one more bit there. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-09-24ALSA: hda/tegra - async probe for avoiding module loading deadlockTakashi Iwai1-5/+25
The Tegra HD-audio controller driver causes deadlocks when loaded as a module since the driver invokes request_module() at binding with the codec driver. This patch works around it by deferring the probe in a work like Intel HD-audio controller driver does. Although hovering the codec probe stuff into udev would be a better solution, it may cause other regressions, so let's try this band-aid fix until the more proper solution gets landed. Reported-by: Thierry Reding <treding@nvidia.com> Tested-by: Thierry Reding <treding@nvidia.com> Cc: <stable@vger.kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-05-18ALSA: hda/tegra - Improve error reportingThierry Reding1-6/+19
When probing, provide accurate error messages to help with debugging failures. Signed-off-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-05-18ALSA: hda/tegra - Set CORBRP self-clear flagThierry Reding1-1/+2
This is set for the MCP variants of the NVIDIA HDA controller, which the Tegra variant was derived from. This fixes the following warning at boot time: [ 2.486610] tegra-hda 70030000.hda: CORB reset timeout#1, CORBRP = 0 Signed-off-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-05-05ALSA: hda/tegra - Fix oopsThierry Reding1-4/+4
Commit a41d122449be ("ALSA: hda - Embed bus into controller object") introduced a regression in the Tegra HDA driver that causes the following oops during boot: [ 2.333458] Unable to handle kernel NULL pointer dereference at virtual address 000004c4 [ 2.341537] pgd = c0004000 [ 2.344312] [000004c4] *pgd=00000000 [ 2.347898] Internal error: Oops: 5 [#1] PREEMPT SMP ARM [ 2.353200] Modules linked in: [ 2.356264] CPU: 0 PID: 1 Comm: swapper/0 Tainted: G W 4.1.0-rc2-next-20150505-00344-g8577890defbf #79 [ 2.366682] Hardware name: NVIDIA Tegra SoC (Flattened Device Tree) [ 2.372939] task: ee0d8b40 ti: ee0da000 task.ti: ee0da000 [ 2.378336] PC is at azx_bus_init+0x18/0xf4 [ 2.382516] LR is at hda_tegra_probe+0x6c/0x478 [ 2.387043] pc : [<c06156c4>] lr : [<c061cf00>] psr: 60000113 [ 2.387043] sp : ee0dbe38 ip : 00000000 fp : 00000000 [ 2.398501] r10: ed874c00 r9 : 000000fd r8 : 00000000 [ 2.403717] r7 : ed874c10 r6 : 00000000 r5 : 00000000 r4 : ed016810 [ 2.410232] r3 : c08a2ad4 r2 : c08a1ea0 r1 : 00000000 r0 : ed016810 [ 2.416750] Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel [ 2.424046] Control: 10c5387d Table: 8000406a DAC: 00000015 [ 2.429783] Process swapper/0 (pid: 1, stack limit = 0xee0da210) [ 2.435778] Stack: (0xee0dbe38 to 0xee0dc000) [ 2.440129] be20: 00000000 ed016810 [ 2.448297] be40: 00000000 c061cf00 00000000 ee0dbe5c ed8735d0 c0a7bc48 ed02fd50 ed016000 [ 2.456462] be60: c1250164 ed874c10 c0c66bf8 fffffdfb 00000000 000000fd c0b8dc98 c046664c [ 2.464628] be80: c0466608 c1250164 ed874c10 00000000 c0c66bf8 c0464eb4 ed874c10 c0c66bf8 [ 2.472793] bea0: ed874c44 c0c43458 00000000 c04650d0 00000000 c0c66bf8 c046503c c04633b4 [ 2.480959] bec0: ee11bea4 ed85f390 c0c66bf8 ed017ac0 00000000 c0464634 c0ab2b7c c0c66bf8 [ 2.489125] bee0: c0bfde20 c0c66bf8 c0bfde20 ed01ce40 c0b7b414 c04656e8 c04665b0 c0bfde20 [ 2.497291] bf00: c0bfde20 c0009770 ee0d8b40 c0c02488 60000113 00000000 00000000 00000003 [ 2.505458] bf20: 00000000 c0c02488 60000113 00000000 c0b54598 c0b16a90 ef7fcc57 c0041228 [ 2.513624] bf40: c0a9150c ef7fcc5f 00000006 00000006 00000000 c0bf1fa8 c0bf2354 00000006 [ 2.521790] bf60: c0b8dc90 c0c7c000 c0c7c000 c0b8dc98 00000000 c0b54dd8 00000006 00000006 [ 2.529956] bf80: c0b54598 00000000 00000000 c07ff08c 00000000 00000000 00000000 00000000 [ 2.538122] bfa0: 00000000 c07ff094 00000000 c000f5a0 00000000 00000000 00000000 00000000 [ 2.546286] bfc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 2.554451] bfe0: 00000000 00000000 00000000 00000000 00000013 00000000 fffff7ff c013f264 [ 2.562624] [<c06156c4>] (azx_bus_init) from [<c061cf00>] (hda_tegra_probe+0x6c/0x478) [ 2.570535] [<c061cf00>] (hda_tegra_probe) from [<c046664c>] (platform_drv_probe+0x44/0xa4) [ 2.578879] [<c046664c>] (platform_drv_probe) from [<c0464eb4>] (driver_probe_device+0x174/0x2b8) [ 2.587739] [<c0464eb4>] (driver_probe_device) from [<c04650d0>] (__driver_attach+0x94/0x98) [ 2.596172] [<c04650d0>] (__driver_attach) from [<c04633b4>] (bus_for_each_dev+0x6c/0xa0) [ 2.604342] [<c04633b4>] (bus_for_each_dev) from [<c0464634>] (bus_add_driver+0x148/0x1f0) [ 2.612597] [<c0464634>] (bus_add_driver) from [<c04656e8>] (driver_register+0x78/0xf8) [ 2.620593] [<c04656e8>] (driver_register) from [<c0009770>] (do_one_initcall+0x8c/0x1d4) [ 2.628765] [<c0009770>] (do_one_initcall) from [<c0b54dd8>] (kernel_init_freeable+0x144/0x1e4) [ 2.637459] [<c0b54dd8>] (kernel_init_freeable) from [<c07ff094>] (kernel_init+0x8/0xe8) [ 2.645543] [<c07ff094>] (kernel_init) from [<c000f5a0>] (ret_from_fork+0x14/0x34) This is caused by azx_bus_init() trying to dereference chip->card, which for the Tegra driver doesn't get initialized until sometime later during the call to hda_tegra_create(). Fix this by mimicking the behaviour of the Intel driver and defer HDA bus initialization until right before the call to snd_device_new(). Fixes: a41d122449be ('ALSA: hda - Embed bus into controller object') Signed-off-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>