Commit Graph

26 Commits

Author SHA1 Message Date
Jonathan Hunter
eabaeedaa6 ASoC: tegra-alt: Set device data before initialising RPM
The device data for a given driver must be set before enabling
runtime-pm otherwise this could results in a crash if the runtime-pm
callback is called before the device data is set where it is expected
that the device data has been initialised.

Furthermore, most drivers will directly call the runtime-pm callback
to power-up the device if runtime-pm is not enabled in the kernel
config and so many drivers would crash if runtime-pm is not enabled.

Fix this by setting the device data early in the driver probe.

Bug 2478690

Change-Id: I5beb1607aa4715651cf4b9ac8e8068e7f8e3a2a7
Signed-off-by: Jonathan Hunter <jonathanh@nvidia.com>
(cherry picked from commit 9d656fcc96e85d38d120a430f83f2b734e19fe07)
Reviewed-on: https://git-master.nvidia.com/r/1991204
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Bibek Basu <bbasu@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Sameer Pujar
0493b53a47 ASoC: tegra-alt: remove kernel version check
Version check is not required since 'struct component_driver' is
available on both kernel-4.4 and kernel-4.9. These checks are
earlier removed from t21x based module drivers. The same is done
now for t18x specific drivers.

Bug 200346429

Change-Id: Ie59600ed8fe4b6878ece58a055da522ce308300d
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1573625
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Ravindra Lokhande <rlokhande@nvidia.com>
2022-09-29 15:30:21 +05:30
Jon Hunter
f8c3f7a29e ASoC: tegra-alt: Fix system suspend handling
There are a couple issues with system suspend handling in the Tegra
ASoC codec drivers which are:

1. Most drivers the system suspend callback does nothing and this
   means that if the codec device is active when suspend occurs then
   the codec will not be suspended correctly. This has been seen to
   cause system crashes in the I2S driver when the system is suspended
   and resuming while audio playback is active.

2. The codec suspend handlers may be called twice when entering
   suspend. Suspend handlers should only be called once, but currently
   they are called twice; once by the PM core and once when the APE
   power-domain is turned off (if it is on when suspend occurs).

Fix the above two problems by:
a). Adding proper system suspend and resume handlers for all codec
    drivers, to suspend and resume the device if not runtime PM
    suspended on entering suspend.
b). Remove the code to call the PM callbacks from the APE power-domain
    code.

Finally, make the system suspend callbacks for these codec drivers
late suspend callbacks to ensure that the sound core has suspended
any on-going activity, before we attempt to suspend these codec
devices.

Bug 200275736

Change-Id: I7f43b8650d972356b0a529404792fe22125dde16
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: http://git-master/r/1488962
(cherry picked from commit 5a7f3ab3d1e6d9d136859b9263b91e3f6998366b)
Reviewed-on: https://git-master/r/1511033
GVS: Gerrit_Virtual_Submit
Reviewed-by: Bibek Basu <bbasu@nvidia.com>
2022-09-29 15:30:21 +05:30
Jon Hunter
a29581fc2e ASoC: tegra-alt: Fix parent runtime PM handling
Linux runtime PM automatically handles the runtime resuming and
suspending of a parent device and therefore, it is not necessary
for a child device to explicitly runtime resume or suspend the
parent.

The various Tegra ASoC codec drivers explicitly runtime resume
and suspend the parent device from within their runtime PM callback
handler. This should not be necessary.

Furthermore, currently the various Tegra ASoC codec drivers are
not suspended correctly if active when system suspend occurs. During
system suspend it is common to directly call the runtime PM callbacks
to suspend and resume the device if active from the system suspend
callbacks. However, the APIs, pm_runtime_get/put(), cannot be called
during system suspend and so the runtime PM callbacks for these codec
drivers cannot be called from the context of the system suspend
callbacks.

Remove the calls to runtime resume and suspend the parent device from
the runtime PM callbacks for the various Tegra ASoC drivers. This will
allow us to fix suspending and resuming of the Tegra ASoC drivers
across system suspend.

Bug 200275736

Change-Id: I9130d8e1c9f91a439651d279ffdf389474018f92
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: http://git-master/r/1488961
(cherry picked from commit 6ae92527f6948ff484af761c1aa1073f79e13a8a)
Reviewed-on: https://git-master/r/1511032
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Bibek Basu <bbasu@nvidia.com>
2022-09-29 15:30:21 +05:30
Mohan Kumar
85eae8d6ff ASoC: tegra-alt: Avoid reg access after shutdown
Below are the hypothetical scenarios
- Drivers are in suspend state while reboot and PCM Open call from
  userspace is received after driver shutdown [APE is power gated
  already]
- PM domain handling doesn't ensure proper functionality after driver
  shutdown is called

The change handles with the beloe fix
- ALSA PCM Open API first executes runtime resume of each driver.
  So need to prevent any reg access in runtime resume of drivers.
- ALSA PCM Open executes ADMAIF startup after runtime resume of
  each driver. If ADMAIF startup returns failure based on shutdown,
  PCM Open operation will fail, this will break PCM Open path and
  will ensure no further ALSA APIs/Callbacks are called.

Bug 200289815

Change-Id: I46060d74b3271a870a0bcfc727972c97e2a73931
Signed-off-by: Mohan Kumar <mkumard@nvidia.com>
Reviewed-on: http://git-master/r/1475216
Reviewed-on: http://git-master/r/1499116
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-by: Dipesh Gandhi <dipeshg@nvidia.com>
Reviewed-by: Ravindra Lokhande <rlokhande@nvidia.com>
Reviewed-on: http://git-master/r/1502050
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
Tested-by: Sachin Nikam <snikam@nvidia.com>
2022-09-29 15:30:21 +05:30
Ravindra Lokhande
06888682e6 ALSA: tegra-alt: fix kernel 4.9 build errors
This patch contains changes needed for kernel 4.9 compilation.
Kernel 4.9 has two changes, struct snd_soc_codec_driver is modified
and changed PCM runtime array to a list from struct snd_soc_card.

Bug 1856400

Change-Id: I5d22e7adfd3101cf8a90d02c998ff03fab7ecaa1
Signed-off-by: Ravindra Lokhande <rlokhande@nvidia.com>
Reviewed-on: http://git-master/r/1306168
Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Dipesh Gandhi <dipeshg@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
2022-09-29 15:30:21 +05:30
Dipesh Gandhi
e66ce07df1 ASoC: asrc: clear asrc interrupt twice
As per HW Bug 200208400 we need to clear asrc
interrupt twice to update interrupt status
register.

Bug 200219757

Change-Id: I741f27cca155e45f0112f505eed415852f13e219
Signed-off-by: Dipesh Gandhi <dipeshg@nvidia.com>
Reviewed-on: http://git-master/r/1233840
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Nitin Pai <npai@nvidia.com>
2022-09-29 15:30:21 +05:30
Ravindra Lokhande
a197f2b4d7 ASoC: tegra-alt: replace direct access to codec dapm
The dapm field of the struct snd_soc_codec is removed, to access
dapm field use snd_soc_codec_get_dapm()

Change-Id: I2bf7f89058bd65baf2d89ffa926af9fe1e418927
Signed-off-by: Ravindra Lokhande <rlokhande@nvidia.com>
Reviewed-on: http://git-master/r/1157272
GVS: Gerrit_Virtual_Submit
Reviewed-by: Viraj Karandikar <vkarandikar@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
2022-09-29 15:30:21 +05:30
Sidharth
eb411ec113 ASoC: tegra-alt: add asrc params configurability
Added ability to disable h/w compensation
Disabling h/w compensation would work well
with mem-to-io
Added ability to set WORD_CNT for input and
output thresholds

Bug 200194803

Change-Id: Iea8942105e61ce307ad394d75de59836796f3fbb
Signed-off-by: Sidharth <svarier@nvidia.com>
Reviewed-on: http://git-master/r/1135127
(cherry picked from commit 1b25a112a33b249696a87b8527afc1d132a9cbba)
Reviewed-on: http://git-master/r/1142696
GVS: Gerrit_Virtual_Submit
Reviewed-by: Nitin Pai <npai@nvidia.com>
2022-09-29 15:30:21 +05:30
Dipesh Gandhi
db23cd7e8a ASoC: tegra-alt: asrc frac part fix
Changing frac max to unsigned int as
mask for asrc frac is 0xffffffff.

Bug 200185841
Change-Id: Ic47896b47fa5e4a5e4eb7320a69d6b94747715a5
Signed-off-by: Dipesh Gandhi <dipeshg@nvidia.com>
Reviewed-on: http://git-master/r/1113391
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Nitin Pai <npai@nvidia.com>
2022-09-29 15:30:21 +05:30
Dipesh Gandhi
0f10c0cf2c tegra-alt: asrc: sw-reset asrc before disabling
To make sure last transaction on stream
was clean we soft reset the lane before
closing it.

Bug 1736992
Bug 200181219

Change-Id: I0df111d8d535a574e021a459b7d0c2c37a2c6345
Signed-off-by: Dipesh Gandhi <dipeshg@nvidia.com>
Reviewed-on: http://git-master/r/1112188
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Nor Cho <ncho@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Nitin Pai <npai@nvidia.com>
2022-09-29 15:30:21 +05:30
Amit Sharma
bf142c83e5 sound: soc: tegra-alt: fix sparse warnings
Fixed the following sparse warnings:
- warning: symbol 'tegra186_asrc_ahc_cb' was not declared.
           Should it be static?
- warning: symbol 'tegra186_arad_ahc_cb' was not declared.
           Should it be static?
- warning: Using plain integer as NULL pointer

Bug 200088648

Change-Id: I26ca06f95517269840248b703969fb79e2c43c91
Signed-off-by: Amit Sharma <amisharma@nvidia.com>
Reviewed-on: http://git-master/r/1011362
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Dipesh Gandhi <dipeshg@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
2022-09-29 15:30:21 +05:30
Uday Gupta
f2b5343db2 ASoC: tegra-alt: Move register store/restore
Move register store/restore from pm API's to
runtime API's for platforms, with CONFIG_PM_SLEEP
not enabled, to work.

Bug 200166409

Change-Id: I0c7cda13ebf7318bb9d27549fc856d20ebd41cdc
Signed-off-by: Uday Gupta <udayg@nvidia.com>
Reviewed-on: http://git-master/r/932646
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Nitin Pai <npai@nvidia.com>
2022-09-29 15:30:21 +05:30
Gaurav Tendolkar
d451956f83 tegra-alt: asrc: request ratio packet from arad
If ARAD lane gets locked before ASRC is enabled
the ASRC misses the ratio packet from ARAD and does
not lock. Requesting ratio packet again from ARAD
enables ASRC to lock in such cases.

Bug 200158741

Change-Id: I63841b46eec832f3f16be9fc78fa51d723d9e825
Signed-off-by: Gaurav Tendolkar <gtendolkar@nvidia.com>
(cherry-picked from commit 88eac6a1ffa5452c170756c1266eae388795689d)
Reviewed-on: http://git-master/r/842381
Tested-by: Dipesh Gandhi <dipeshg@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Nitin Pai <npai@nvidia.com>
2022-09-29 15:30:21 +05:30
Dipesh Gandhi
675497468f ASoC: tegra-alt: Mark lock register volatile
Marking ASRC_STREAM_LOCK_STATUS as volatile.
When asrc configured in HW mode, we want read
on ASRC_STREAM_LOCK_STATUS from hardware.

In SW mode we use ASRC_STREAM_LOCK_STATUS as
R/W register.

Bug Bug 200163397

Change-Id: I2960e9b7417c5c3017c87b4494b252e9668c4444
Signed-off-by: Dipesh Gandhi <dipeshg@nvidia.com>
Reviewed-on: http://git-master/r/926833
GVS: Gerrit_Virtual_Submit
Reviewed-by: Nitin Pai <npai@nvidia.com>
2022-09-29 15:30:21 +05:30
Dipesh Gandhi
eceb04d76a ASoC: tegra-alt: add check pointer before access
add check for context pointer before accessing
it in suspend for asrc and arad.

Bug 200160608

Change-Id: If549bf77e8d2a2ab66507127930bfa7c474ea782
Signed-off-by: Dipesh Gandhi <dipeshg@nvidia.com>
Reviewed-on: http://git-master/r/923558
GVS: Gerrit_Virtual_Submit
Reviewed-by: Ravindra Lokhande <rlokhande@nvidia.com>
Reviewed-by: Nitin Kumbhar <nkumbhar@nvidia.com>
2022-09-29 15:30:21 +05:30
Sidharth
21823baa4b ASoC: tegra-alt: Fix asrc sw ratio update steps
Fixed the procedure for sw ratio update
Removed the steps of setting of asrc in UNLOCK state
and waiting it to go in UNLOCK state.
In UNLOCK state asrc stops sending samples which was
leading to audio glitches.

Bug 200154554

Change-Id: Idf7fe685709afcf4f72c3aab95dd5ee812871b92
Signed-off-by: Sidharth <svarier@nvidia.com>
(cherry picked from commit adbe2553c993327edd44408544628e8a7864ad51)
Reviewed-on: http://git-master/r/838743
Reviewed-by: Automatic_Commit_Validation_User
Tested-by: Shashank Sinha <shsinha@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Nitin Pai <npai@nvidia.com>
2022-09-29 15:30:21 +05:30
Dipesh Gandhi
3c9d319ae3 ASoC: tegra-alt: arad dapm fixes
Adding fixes related to arad runtime
& dapm policy via xbar.

Bug 200133225
Bug 200150306

Change-Id: Ic5f0ef66ecadd18c64ea1d684f28eed2eacc2b39
Signed-off-by: Dipesh Gandhi <dipeshg@nvidia.com>
Reviewed-on: http://git-master/r/836450
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Nitin Pai <npai@nvidia.com>
2022-09-29 15:30:21 +05:30
Dipesh Gandhi
b74ed9932e tegra-alt: asrc: runtime pm fix
1) fixing asrc runtime pm.
2) moving scratch address and global
 enable mask to runtime_resume.

Bug 200150306
Bug 200124772
Change-Id: If0dfc3c93ee431b43e36a7b934498177caad6ddd
Signed-off-by: Dipesh Gandhi <dipeshg@nvidia.com>
Reviewed-on: http://git-master/r/829018
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Nitin Pai <npai@nvidia.com>
2022-09-29 15:30:21 +05:30
Asha T
8ca4925751 ASoC: tegra-alt: Fix sparse warning
This change fixes warnings highlighted
for unused variables and labels

Bug 200088648

Change-Id: I0db87d6b4f7ca9c6714610d15dfd93ef96a7a30a
Signed-off-by: Asha T <atalambedu@nvidia.com>
Reviewed-on: http://git-master/r/827396
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
2022-09-29 15:30:21 +05:30
Gaurav Tendolkar
11708b6d8b ASoC: tegra-alt: add ahub interrupt handling
Add interrupt handling for ARAD and ASRC

Change-Id: I5f6c8c0946604b6961554f2c1309f15dc4a6e58d
Signed-off-by: Gaurav Tendolkar <gtendolkar@nvidia.com>
Reviewed-on: http://git-master/r/812122
(cherry picked from commit 2c288b8a3b9af03ac591424715788c38396bc1cb)
Reviewed-on: http://git-master/r/824504
Reviewed-by: Nitin Pai <npai@nvidia.com>
2022-09-29 15:30:21 +05:30
Dipesh Gandhi
34b3cc18d3 ASoC: tegra-alt: audio fixes
fixes for:
a) asrc
b) arad
c) machine driver

List of CL's:
http://git-master/r/799350
http://git-master/r/799941
http://git-master/r/801101

Bug 200133225

Change-Id: Icbec3b988e134c47dc13cbf64bbef394bc31b0a6
Signed-off-by: Dipesh Gandhi <dipeshg@nvidia.com>
Reviewed-on: http://git-master/r/823283
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Nitin Pai <npai@nvidia.com>
2022-09-29 15:30:21 +05:30
Amit Sharma (SW-TEGRA)
e87333c909 isound: soc: tegra-alt: remove static storage class from definition
Fixed the following sparse warning:
- warning: useless storage class specifier in empty declaration

Instance variable may be a static, but the definition doesn't need
the static storage specifier attached to it.

Bug 200088648

Change-Id: Id709a1d205987d19d8c415a18c03b8e24eb9d7b8
Signed-off-by: Amit Sharma (SW-TEGRA) <amisharma@nvidia.com>
Reviewed-on: http://git-master/r/799165
GVS: Gerrit_Virtual_Submit
Reviewed-by: Dipesh Gandhi <dipeshg@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
2022-09-29 15:30:21 +05:30
Dipesh Gandhi
21c45bba08 ASoC: tegra-alt: WAR for ARAD/ASRC
Issue is seen with ARAD/ASRC when it goes to
UNLOCK->LOCK.
- ASRC may not check for buffer thresholds once it
restarts processing after an UNLOCK->LOCK.
- ARAD will not get locked after an unlock

Bug 200118889

Change-Id: Ia16187df6955e79f93f3a7cb9061ea64a61c1d36
Signed-off-by: Dipesh Gandhi <dipeshg@nvidia.com>
Reviewed-on: http://git-master/r/764096
Reviewed-by: Sumit Bhattacharya <sumitb@nvidia.com>
Tested-by: Sumit Bhattacharya <sumitb@nvidia.com>
2022-09-29 15:30:21 +05:30
Dipesh Gandhi
a23ad9f725 ASoC: tegra-alt: update ARAM address in asrc
ASRC requires 36KB of ARAM for intermediate data.
Updating the start address of ARAM as per
the partion reserved for ASRC and ADSP usage
of ARAM.

Bug 200092561

Change-Id: Ifd4b9b866d518bbe3f6f94cdb974eddc0d1ef1ac
Signed-off-by: Dipesh Gandhi <dipeshg@nvidia.com>
Reviewed-on: http://git-master/r/766620
Reviewed-by: Nitin Pai <npai@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Nitin Kumbhar <nkumbhar@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Sumit Bhattacharya <sumitb@nvidia.com>
2022-09-29 15:30:21 +05:30
Junghyun Kim
606239daf9 ASoC: tegra-alt: create the new drivers for T186
1. Create T186 machine driver
2. Create ASRC/ARAD codec driver
3. Create header files of ahub_unit_fpga_clock,
  machine utility, afc, xbar, admaif for T186
4. Create files for additional T186 features of
  machine utility, afc, xbar

Bug 1582514
Bug 1582510

Change-Id: I505e0af612c4399c675e39185879612ac1992768
Signed-off-by: Junghyun Kim <juskim@nvidia.com>
Reviewed-on: http://git-master/r/751592
Reviewed-by: Dipesh Gandhi <dipeshg@nvidia.com>
Reviewed-by: Alexander Van Brunt <avanbrunt@nvidia.com>
Reviewed-by: Arun Shamanna Lakshmi <aruns@nvidia.com>
2022-09-29 15:30:21 +05:30