Commit Graph

4323 Commits

Author SHA1 Message Date
Dipesh Gandhi
22fa30cd39 tegra-virt-alt: nvaudio_ivc_send_receive added
Currently exposed api's have limitations of receive
request getting processed out of order. Change make
sure to process ack/receive based message before
queueing other. Also removing unused api's as code
cleanup.

Bug 2403937

Change-Id: Ic3141aac53bc0904dfcad699d419b9ca8aaea155
Signed-off-by: Dipesh Gandhi <dipeshg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1927929
Signed-off-by: Dipesh Gandhi <dipeshg@nvidia.com>
(cherry picked from commit d6c592f7ada5ecbcd9af290149af01b52b89b8a3)
Reviewed-on: https://git-master.nvidia.com/r/1753352
GVS: Gerrit_Virtual_Submit
Reviewed-by: Viraj Karandikar <vkarandikar@nvidia.com>
Reviewed-by: Nitin Pai <npai@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
spujar
737cefc6e0 tegra-alt: adsp: release socket in device remove
Following error is seen during multiple unload/load of driver,
 Error creating socket
 tegra210-adsp: probe of tegra210-adsp failed with error -1
This is resulting in kernel panic and device reboot.

Following is the crash,
===============================================================================
Unable to handle kernel NULL pointer dereference at virtual address 00000010
Mem abort info:
 ESR = 0x96000005
 Exception class = DABT (current EL), IL = 32 bits
 SET = 0, FnV = 0
 EA = 0, S1PTW = 0
Data abort info:
 ISV = 0, ISS = 0x00000005
 CM = 0, WnR = 0
user pgtable: 4k pages, 39-bit VAs, pgd = ffffffc3e5a09000
[0000000000000010] *pgd=0000000000000000, *pud=0000000000000000
Internal error: Oops: 96000005 [#1] PREEMPT SMP
PC is at soc_probe_component+0x90/0x350
LR is at soc_probe_component+0x34/0x350
pc : [<ffffff8008d59fb0>] lr : [<ffffff8008d59f54>] pstate: 40400045
sp : ffffffc38bbab8c0
x29: ffffffc38bbab8c0 x28: 0000000000000000
x27: 0000000000000000 x26: ffffff80018f19b8
x25: ffffffc3e5acf800 x24: ffffffc3e8b44e00
x23: 00000000000000f8 x22: 0000000000000001
x21: ffffff80018f19b8 x20: ffffff800a067000
x19: ffffffc35b93aa50 x18: 000000003e48590c
x17: 00000022d6c5fcd0 x16: ffffff8008153de0
x15: 0000000300000000 x14: 0000000000000000
x13: 0000000000000003 x12: 0000000000000026
x11: 0000000000000005 x10: 0101010101010101
x9 : 0000000000000000 x8 : 7f7f7f7f7f7f7f7f
x7 : 2f30316071666473 x6 : 070b035f125d521d
x5 : 1d525d125f030b07 x4 : 0000000000000000
x3 : 6dcc85ae6dec65a0 x2 : 000000000000008c
x1 : ffffff80094aa810 x0 : 0000000000000000
Process insmod (pid: 5755, stack limit = 0xffffffc38bba8028)
Call trace:
[<ffffff8008d59fb0>] soc_probe_component+0x90/0x350
[<ffffff8008d5afc8>] snd_soc_instantiate_card+0x4d8/0xb58
[<ffffff8008d5b7a4>] snd_soc_register_card+0x15c/0x200
[<ffffff80018ed630>] tegra_machine_driver_probe+0x3d0/0x5a0
[<ffffff80087c3da0>] platform_drv_probe+0x60/0xc8
[<ffffff80087c1278>] driver_probe_device+0xd0/0x410
[<ffffff80087c16dc>] __driver_attach+0x124/0x128
[<ffffff80087beba8>] bus_for_each_dev+0x88/0xe8
[<ffffff80087c0a68>] driver_attach+0x30/0x40
[<ffffff80087c0438>] bus_add_driver+0x1f8/0x2b0
[<ffffff80087c2648>] driver_register+0x68/0x100
[<ffffff80087c3ce4>] __platform_driver_register+0x5c/0x68
[<ffffff8001276018>] tegra_asoc_machine_driver_init+0x18/0x30
[<ffffff80080832ac>] do_one_initcall+0x5c/0x170
[<ffffff80081ba740>] do_init_module+0x68/0x1b8
[<ffffff80081538dc>] load_module+0x1004/0x1320
[<ffffff8008153ef0>] SyS_finit_module+0x110/0x128
[<ffffff8008083040>] el0_svc_naked+0x34/0x38
---[ end trace 39fa2dd2a3c341ef ]---
===============================================================================

Fix info,
This patch releases the socket in device removal and adsp probe succeeds
Thus avoid above crash during sound card registration.

Bug 200453666

Change-Id: Idb113b9aca71f830cd33cd8f9c3d742ad86280bb
Signed-off-by: spujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1847927
Reviewed-by: Ravindra Lokhande <rlokhande@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
spujar
113a32d573 Revert "tegra-alt: adsp: disable remove() callback"
This reverts commit 7d761982ba0689d7d6c933dd17397624bc47a350.
(manual revert since there were conflicts)

Bug 200453666

Change-Id: I904f5d9b915de95f5b1256104d2473008252dd8a
Signed-off-by: spujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1847926
Reviewed-by: Ravindra Lokhande <rlokhande@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
dipeshg
92d1ab20d3 tegra-alt: adsp: ignore drain msg to audioserver
On drain trigger no special handling is required on
audioserver side. Change adds case to ignore drain
message to audioserver.

Bug 2117496

Change-Id: I575b895651ed21179c743a0aa0e5f63eea354a5a
Signed-off-by: dipeshg <dipeshg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1812302
Reviewed-by: Uday Gupta <udayg@nvidia.com>
Reviewed-by: Hariharan Sivaraman <hariharans@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Nitin Pai <npai@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
Dara Ramesh
0a22d4871d ASoC: tegra-alt: add dma_set_mask call
enable dma_set_mask_and_coherent call even
if CONFIG_SND_SOC_TEGRA210_ADSP_ALT
is not enabled, This will allow pcm
driver to start allocations start from the
specified address and downwards.

Bug 200423087

Change-Id: Ib1a2f2361f15d1191258fbb0ca4a620d1b2a7c8b
Signed-off-by: Dara Ramesh <dramesh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1809568
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Viswanath L
ffdbb9edcd tegra-alt: adsp: Add pcm_drain functionality
- TRIGGER_DRAIN support is added in pcm_trigger, which sends EOS
    message to ADSP; this is needed so that ADSP sends notification
    for last consumed buffer
 - DRAIN handling in pcm path is as per the implementation in native
    PCM driver

Bug 2117496

Change-Id: I530c16aaea3993569ecf2733f01d43b37df604c1
Signed-off-by: Viswanath L <viswanathl@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1792940
Reviewed-on: https://git-master.nvidia.com/r/1806327
GVS: Gerrit_Virtual_Submit
Reviewed-by: Sumit Bhattacharya <sumitb@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
Nicolin Chen
8b02cb388e ASoC: tegra-alt: Do not select all modules for T210REF_MOBILE_ALT
Not all platforms have to support modules such as AMX, ADX, MVC, and
etc, so selecting all the audio modules by default is wasting memory
for them.

This patch drops DMIC, AMX, ADX, AFC, MVC, OPE and ADSP from CONFIG
SND_SOC_TEGRA_T210REF_MOBILE_ALT, and keeps only essential ones. In
order not to break any exisiting use case, these CONFIGs will be set
to "def_tristate" so all platforms build them as usual. This means
anyone who does not need them will need to specifically disable them
in the defconfig.

Meanwhile, this patch adds IS_ENABLED() check at corresponding files.

Bug 2284925

Change-Id: I2e3853b5499046fc8de7256899c30d764160aebe
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1803446
Reviewed-by: Dara Ramesh <dramesh@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Ravindra Lokhande <rlokhande@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
Jon Hunter
85868d43dc ASoC: tegra-alt: Optimise suspend support
Suspending all the DAI links for Tegra on entering suspend is taking
between 1-2 seconds which is far too long. To ensure that any active
audio playback and/or capture resumes following suspend, it is only
necessary to suspend the DAI links for ADMAIF and it is safe to set
the '.ignore_suspend' flag for all the other DAI links.

With this change the min/ave/max time for executing the 'snd_soc_suspend()'
function is reduced from 419ms/1056ms/2021ms to 49ms/287ms/766ms. This is
measured using the ftrace function graph feature to measure the total time
for 'snd_soc_suspend()' to execute.

Bug 200390943

Change-Id: I498643eb069a1bc72d72b86930ab5b6e54e44b76
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1799943
GVS: Gerrit_Virtual_Submit
Reviewed-by: Sameer Pujar <spujar@nvidia.com>
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
Dipesh Gandhi
68f28205ff ASoC: tegra-alt: adsp_audio suspend/resume handling
Change adds suspend/resume to adsp_audio driver.
Also updating pcm_trigger to set FE to inactive state. Setting to
inactive state will make sure dma is paused and not stop when suspend
request is received.

Jira EMA-641

Change-Id: Iadf577266b8f7452acc72526f72f059cfd06ab49
Signed-off-by: Dipesh Gandhi <dipeshg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1689151
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Ravindra Lokhande <rlokhande@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@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
Dara Ramesh
99e73baabe ASoC: tegra-alt: remove legacy powergating
- remove legacy powergating code from
  i2s driver

- powergate for APE module is handle by
  acconect bus (genpd)

bug 200406253

Change-Id: If70ecb3dedbb9c2795add28808f1339a4195c72a
Signed-off-by: Dara Ramesh <dramesh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1790032
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Joseph Lo <josephl@nvidia.com>
Tested-by: Joseph Lo <josephl@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Ravindra Lokhande <rlokhande@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
Jon Hunter
eb75a4c48f ASoC: tegra-alt: Consolidate machine controls/widgets
The Tegra machine driver controls and widgets are generic and can be
used by any board that uses the generic machine driver. Therefore
consolidate the controls and widgets used for all boards.

This also fixes a problem for the Tegra194 Rey platform which does not
have an on-board RT5658 codec and so the generic controls and widgets
are not populated. These controls and widgets are still needed for
testing I2S, DMIC and DSPK.

Finally, to improve the readability don't use 'snd_soc_tegra_card' in
the function dai_link_setup() and just use the 'card' pointer instead.

Bug 200417361

Change-Id: I863a0d5c03a61fe5b9e36fdfd5356900aac9d456
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1775296
Reviewed-by: Sameer Pujar <spujar@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Dara Ramesh <dramesh@nvidia.com>
Reviewed-by: Bibek Basu <bbasu@nvidia.com>
Tested-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
Jon Hunter
c11cadfde1 ASoC: tegra-alt: Remove legacy unused platform data
The Tegra ASoC platform data is never used by any current audio machine
driver and so get rid of the platform data and the associated code.

Bug 200417361

Change-Id: I1ef8ce331b67c85aea95b4a143a6982a32fefe93
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1784822
Reviewed-by: Sameer Pujar <spujar@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Dara Ramesh <dramesh@nvidia.com>
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
Jon Hunter
dfc52a8512 ASoC: tegra-alt: Add device table for Tegra XBAR driver
The Tegra XBAR driver is not being automatically loaded when booting
with Linux kernel v4.14. Add the device table for this driver to fix
this.

Bug 200422801

Change-Id: Ie6171b7ac4750afb5b09920065d1ebff75870073
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1783951
GVS: Gerrit_Virtual_Submit
Reviewed-by: Dara Ramesh <dramesh@nvidia.com>
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
Gaurav Tendolkar
df31a96ba7 tegra-alt: adsp: add adsp fe switch support
Adding ADSP FE widget event which enables/disables
ADMA when using ADSP pcm device, pause the DMA on
path disconnect event. This prevents glitches
if another app starts writing on same ADMAIF
using another ADSP pcm device

Bug 200298756
Bug 2119806

Change-Id: I96f27be3b9616954f7b5acc12deb5935ba770180
Signed-off-by: Gaurav Tendolkar <gtendolkar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1462190
(cherry picked from commit 93eac105424234b082d7f13ee2ba443594604116)
Signed-off-by: Hariharan Sivaraman <hariharans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1732695
(cherry picked from commit 957029384bc4d51ab79b6e2bef2b9093819b54d5)
Signed-off-by: Hariharan Sivaraman <hariharans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1730254
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Jon Hunter
5da3305cdf ASoC: tegra-alt: Fix support for I2S mono playback
Mono playback via the RT5658 codec on the Jetson TX1/TX2/Xavier is
distorted. Although the RT5658 codec is configured for standard I2S
timings (implying 2 channels), the Tegra XBAR should convert the mono
audio track from one channel to two channels. The problem is caused
because the 'CHANNEL_BIT_CNT' field in the I2S Timing Register is
being configured incorrectly. For mono playback in I2S mode (or LRCK
mode) the CHANNEL_BIT_CNT is being set to 31 instead of 15 by fixing
this mono playback works as expected.

Please note that the 'bitcnt' value programmed into the I2S Timing
Register is verified to see that it is not bigger than the mask for
the CHANNEL_BIT_CNT field. However, this is done before we shift the
bitcnt by 1 for I2S mode. Therefore, ensure the bitcnt is shifted by
1 before we do the check.

Mono playback has been tested by playing the following audio clip ...

aplay -D hw:1,0 /usr/share/sounds/alsa/Front_Center.wav

Bug 2257806

Change-Id: I4d306ccef891282e96c300d90bad2a5b6efc9968
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1777096
Reviewed-by: Sameer Pujar <spujar@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
Hariharan Sivaraman
cb3d3637bf tegra-alt: adsp: update index for send bytes ctrl
Number of ADSP plugins were increased to 20. The
PLUGIN_SEND_BYTES_IDX macro should be updated to reflect
the same.

Bug 2048629

Change-Id: Ia02361600530f88b133eae1a67e440570e19dfb4
Signed-off-by: Hariharan Sivaraman <hariharans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1775907
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Uday Gupta <udayg@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: Uday Gupta <udayg@nvidia.com>
Reviewed-by: Nitin Pai <npai@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
Dipesh Gandhi
a143f333df nvadsp: prevent race in os_queue for app
Change add spinlock to nvadsp app start and init
functions for os_queue write protection. It make
sure only one app from different context can update
queue at given time.
Also added some debug info to adsp driver for providing
extra info for debugging purpose.

Bug 2060866

Signed-off-by: Dipesh Gandhi <dipeshg@nvidia.com>
Change-Id: If1bbfdb233d2af984f62bb02ed515eec1ab8a492
Reviewed-on: https://git-master.nvidia.com/r/1655974
(cherry picked from commit 7edeb242aba4cabc517b6e270b254777e3ea66ea)
Reviewed-on: https://git-master.nvidia.com/r/1775133
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Hariharan Sivaraman <hariharans@nvidia.com>
Reviewed-by: Viraj Karandikar <vkarandikar@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Nitin Pai <npai@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
Jon Hunter
ff4cc3116a ASoC: tegra-alt: Fix Tegra186 ARAD regmap
The Tegra186 ARAD driver lists the TEGRA186_ARAD_LANE_ENABLE register
as volatile implying that the register has status bits that may change
automatically. The ARAD Lane Enable register for both Tegra186 and
Tegra194 have 6 bits which are enable bits and no status bits.
Therefore, this register is not volatile and should not be listed as
volatile. Furthermore, during overnight stress testing, I sometimes see
one of the ARAD lanes become enabled randomly (by diff'ing the ALSA
state, as shown below, before and after running a test that is not using
ARAD). So far after making the ARAD Lane Enable register non-volatile
this has no longer been seen.
2022-09-29 15:30:21 +05:30
Dara Ramesh
155bf200a9 tegra-alt: adsp: include linux/clk.h
include linux/clk.h to fix build error
on T210 platform when compile ADSP without
enabling T210Ref machine driver for K4.14.

Bug 200406253

Change-Id: I3843962d303320e1f6322a578c9aa9add3ab8c9b
Signed-off-by: Dara Ramesh <dramesh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1764177
Reviewed-by: Joseph Lo <josephl@nvidia.com>
Tested-by: Joseph Lo <josephl@nvidia.com>
Reviewed-by: Ravindra Lokhande <rlokhande@nvidia.com>
Reviewed-by: Viraj Karandikar <vkarandikar@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Jon Hunter
c01285e57a ASoC: tegra-alt: Remove jack-detection WAR for RT565x
Now that jack-detection across suspend for the RT565x has been fixed in
the RT565x codec driver, we no longer need to call the
'trigger_jack_status_check' function from the Tegra machine driver.

Bug 2208756

Change-Id: I79961f9eb99c629eaace9ca35f8bb8a984c4dd38
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1758197
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Dara Ramesh
edd7311299 ASoC: tegra-alt: add dma_set_mask parse
Add dma-mask parsing in device tree for pcm
driver to start allocations start from the
specified address and downwards.

Bug 200385990
Bug 200406253

Change-Id: I0443f9535eab76f24437544c5e684d9bc63f4b85
Signed-off-by: Dara Ramesh <dramesh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1755673
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Dipesh Gandhi <dipeshg@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Ravindra Lokhande <rlokhande@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
Jon Hunter
ff20d62dc4 ASoC: tegra-alt: Add support for multiple jacks
For Tegra194 Galen there can be multiple RT565x codecs if the audio
supermodule is connected and therefore, the RT565x sound card can
have multiple jacks. Add support for multiple jacks by allocating
the jack structure dynamically and creating the jack mixer control
dynamically.

Bug 2187533

Change-Id: Ia17cf4ddb1bb971e0973ea5b03f0c2cd6d9b1d5e
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1748233
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
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
Jon Hunter
064224a173 ASoC: tegra-alt: Create jack mixer dynamically
For debug/testing purposes the Tegra audio machine driver creates a
'Jack-state' mixer control to allow the user to query/set the jack
state. Currently, the machine driver assumes that there is only one
jack, but on Galen there can be two jacks if the supermodule is used.
Therefore, add a helper function to create the 'Jack-state' mixer
control dynamically and append the codec prefix-name to the mixer
control name so that it has a unique name.

Bug 2187533

Change-Id: Iac4351c319944e3d2c01d053fce9ea390c3f8db1
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1748232
Reviewed-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
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
Jon Hunter
10e331ee60 ASoC: tegra-alt: Fix Galen/Rey jack status for supermodule
When using the supermodule on the Tegra194 Galen/Rey platforms the
jack status is not updated after resuming from suspend and so if the
jack status changed during suspend, this would not be seen.

Bug 2187533

Change-Id: I647d6d8ee72301003620857ba0885e45fe2e7466
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1748231
Reviewed-by: Sameer Pujar <spujar@nvidia.com>
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
Jon Hunter
3e1be09df1 ASoC: tegra-alt: Simplify RT565x codec init
The function 'tegra_machine_ext_codec_init()' is used for initialising
the RT565x codec. However, it is called even if the RT565x codec is not
present which is not necessary. Therefore, only call this function when
an RT565x is present and simplify the machine driver by moving the code
to set the jack detect to this function. Finally, update the name of
the function to be RT565x specific.

This change is required for supporting boards such as Galen that can
have multiple codecs and hence multiple jacks because it simplifies
the code for configuring the jack.

Bug 2187533

Change-Id: I43518f09a114678861ddface5a59861bb62dc2d9
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1748230
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Sameer Pujar <spujar@nvidia.com>
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
Jon Hunter
01681eb712 ASoC: tegra-alt: Simplify jack detection
Linux jack detection for the generic Tegra machine driver is handled via
the sound soc-jack framework which registers the jack as an input device
with the kernel. Jack events are communicated to userspace via the
'jack_switch_types' definitions in 'sound/core/jack.c'.

Given that we no longer use the switch interface for communicating jack
events, simplify the mixer control code for the 'Jack-state' by aligning
the jack states with the 'snd_jack_types' enum and removing references
to the SWITCH_STATE definitions. This also allow us to completely remove
the jack notifier because we no longer need to convert the jack state
definitions.

Tested on Tegra186 Jetson-TX2 and Tegra194 Galen.

Bug 2187533

Change-Id: I61fdd32d79a1ec345578ebad57faf705e57343bd
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1746207
Reviewed-by: Dara Ramesh <dramesh@nvidia.com>
Reviewed-by: Viswanath L <viswanathl@nvidia.com>
Reviewed-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
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
Jon Hunter
90c85d03df ASoC: tegra-alt: Fix supermodule support for T194 Rey
The supermodule is not currently working on the Tegra194 Rey board.
The supermodule is detected correctly by the plugin manager, but the
card controls and DAPM widgets are not being populated correctly. The
reason the card controls and DAPM widgets are not being populated is
because Rey does not have an on-board RT5658 codec and so the codec
link 'rt565x-playback' does not exist. The codec link for using the
supermodule on Rey is 'rt565x-codec-sysclk-bclk1' and so update the
Tegra machine driver to populated the card controls and DAPM widgets
if this codec link is present.

Bug 200417361

Change-Id: I558146d8252da583e1ec86544a61a50fb567d77d
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1735932
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Sameer Pujar <spujar@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
Viraj Karandikar
91f76fee05 tegra-alt: dmic: add start callback support
For mystique, after firmware is loaded on iM501, a message needs
to be sent to iM501 to enable hardware bypass mode when a raw
capture is required. This message should be sent after DMIC/PDM
clock is enabled and before actual capture starts (DMIC is enabled).

Since iM501 driver is a module, add a calllback function support.
iM501 driver registers a callback function on boot. DMIC driver
calls this function at the beginning of each capture session.

Bug 200404157

Change-Id: I49e81837232eec0393f4e8720f456a5d8137d945
Signed-off-by: Viraj Karandikar <vkarandikar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1725785
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Ravindra Lokhande <rlokhande@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Jon Hunter
f2d64a30f0 ASoC: tegra-alt: Fix xrun during playback/capture across suspend
If audio playback/capture is running when the system suspends, then an
xrun event is reported by the kernel on entering suspend.

The problem is that userspace tasks are frozen before the kernel space
sound core is suspended. This means that the DMA is still running after
userspace has been frozen and hence the CPU has stopped updating the DMA
audio buffer. Hence, when the DMA reaches the end of the buffer an XRUN
event occurs. Depending on the sample rate the length of time before
this XRUN event occurs will vary and the worse case would be around 5ms
(for 192kHz with 16 channels @ 16-bits). There is no way to ensure that
the sound core is stopped within 5ms of freezing userspace and so the
only solution is to ensure that the sound core is suspend before
userspace by calling snd_soc_suspend() from the Linux PM prepare
handler.

Bug 2113333

Change-Id: Ie9da77ee99f74fded4b34cb4ba665da26e9c5e94
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1719611
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Jon Hunter
3ef3ff7ab8 ASoC: tegra-alt: Add support for supermodule on Galen/Rey
Add support for the E2614 supermodule on the Tegra194 Galen and Rey
platforms. Note that on Galen and Rey, because the 'aud_mclk' is not
available on the 40-pin header and the clock available on the 40-pin
header, 'extperiph4', cannot generate the frequencies needed for the
various sampling rates supported, we use the I2S bit-clock to drive
the RT565x codec PLL. Hence, the name of the DAI link for the codec
is 'rt565x-codec-sysclk-bclk1' to indicate that we need to configure
the codec to use BCLK1 to drive the codec's internal PLL.

Bug 2101552

Change-Id: Idd3acb6b3276e5598365ec5e655e75afc3e0bbde
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1670425
Reviewed-by: Sameer Pujar <spujar@nvidia.com>
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
Mohan Kumar
501c3c024d ASoC: tegra-alt: fix dspk dapm path
DAPM path for dspk driver is broken for the second
playback dai.

Bug 200406443

Change-Id: Ib9bf12f4cce83c07da98b2f51f1ac56b3f93762d
Signed-off-by: Mohan Kumar <mkumard@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1697286
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Sharad Gupta <sharadg@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
Dara Ramesh
f7fafdc416 ASoc: tegra-alt: utils: fix kernel panic
Initialise snd_soc_dapm_update struct with NULL
to avoid kernel panic

Commit e411b0b5eb9b ("ASoC: dapm: Support second
register for DAPM control updates") introduced a
2nd register set into the snd_soc_dapm_update struct
and if the 'has_second_set' is not initialised
then it tries to access bogus register.

bug 200406253

Change-Id: Ic18ba2bb990c1c13f595305a05e4fc60a4b0baee
Signed-off-by: Dara Ramesh <dramesh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1697229
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Ravindra Lokhande <rlokhande@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
Hariharan Sivaraman
d2da4eb6b4 tegra-alt: adsp: add error event handling
Socket based messaging mechanism to send ADSP error
events to any userspace application listening for the
ADSP events

Bug 2015160

Change-Id: I0ed9ca4ed1ca491ad8211901fd87a7011ddb03c9
Signed-off-by: Hariharan Sivaraman <hariharans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1668119
Reviewed-by: Viraj Karandikar <vkarandikar@nvidia.com>
Reviewed-by: Uday Gupta <udayg@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Nitin Pai <npai@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
Mohan Kumar
e0b1e0193b ASoC: tegra-alt: support dynamic prod settings
Add driver support for DSPK/DMIC/I2S for dynamic prod
settings.

Bug 200388806

Change-Id: I0c7d77a36a7c5d213b707321605cbe41d5b182d9
Signed-off-by: Mohan Kumar <mkumard@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1691746
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Mohan Kumar
6451c05c89 ASoc: tegra-alt: support dmic parent rate control
Certain platform requirement needs all the dmic controller
clocks to be in phase due to external hardware requirement.So
keeping this in mind changing parent rate to dmic clk rate to make
sure there is not phase difference between dmic controller's output
clocks as the dmick controller divider value will be 1 and it's a bypass.

Bug 200373630

Change-Id: Ie0016fe01c130efe4c45132c50b0783e8ee6404b
Signed-off-by: Mohan Kumar <mkumard@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1686105
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Viraj Karandikar <vkarandikar@nvidia.com>
Tested-by: Viraj Karandikar <vkarandikar@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@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
Jon Hunter
65ddde1a01 ASoC: tegra-alt: Add kcontrols for testing I2S TDM modes
To validate I2S TDM modes (such as dsp-a and dsp-b) on the Jetson TX2
we can jumper wire the I2S1 interface to the I2S2 interface and use
one I2S interface as the master and one as the slave. However, to test
TDM modes we need to re-configure both the I2S framing mode (dsp-a,
dsp-b, etc) as well as the I2S bit-clock and frame-sync master/slave
settings from userspace. Add kcontrols for re-configuring the frame
mode and master mode settings for I2S1 and I2S2 on the Jetson TX2.

Bug 2046053
Bug 1993721
Bug 200356303

Change-Id: Ifab626e9c92bf8e80a1797ea8f0f56d2232e8073
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1676733
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Sameer Pujar <spujar@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
Viraj Karandikar
0be98410ad tegra-alt: dmic: add LR select control
Add LR select control to configure channel location

Bug 200373630

Change-Id: Iba8cbfac7908645a369b5167db68ddd8f991a5d5
Signed-off-by: Viraj Karandikar <vkarandikar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1691173
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Ravindra Lokhande <rlokhande@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
Dara Ramesh
3b5bfa8461 ASoC: tegra-alt: remove SWITCH API's
- remove SWITCH driver API's and instead
  use jack input events to report  HEADSET
  status.

Bug 200395440

Change-Id: I3fc3a645331d044bf3b2fd7b890cee33f2b28246
Signed-off-by: Dara Ramesh <dramesh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1671224
Reviewed-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Tested-by: Sameer Pujar <spujar@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Ravindra Lokhande <rlokhande@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
Jon Hunter
29defcb5da ASoC: tegra-alt: Fix restoration of PEQ settings
On Tegra194 the PEQ gain and shift settings are not maintained across
AUD powergate transitions. Simply by reading the gain/shift settings
from userspace via amixer/tinymix continuously causing the AUD powergate
to power cycle the settings can be seen to continuously change.

Commit bc4166782c07 ("tegra-alt: Enable ahubram prog. in hw_params")
partially fix the problem by re-configuring the gain/shift settings to
their default settings each time the PEQ is in-use, however, even with
this change, if the user changes the settings, they are not preserved.

On Tegra186 the PEQ gain and shift settings are not preserved after
transitioning to low power states such as SC7. There is a difference
between the PMC on Tegra186 and Tegra194, such that Tegra194 no longer
supports SRAM retention for the AUD powergate which explains why the
device behave slightly differently.

To ensure that the PEQ gain and shift settings are preserved for all
devices add save and restore helpers and invoke them from the OPE
runtime-pm handlers.

Bug 2072802
Bug 200375657

Change-Id: Ic867bcfd355a50eba8ba538a9471722b824df3c5
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1679636
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Asha Talambedu <atalambedu@nvidia.com>
Reviewed-by: Sameer Pujar <spujar@nvidia.com>
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
Jon Hunter
db9b7b3836 ASoC: tegra-alt: Fix restoration of ARAD mixer controls
When using the ALSA 'alsactl' tool to save and restore mixer settings
the following of errors are observed for the following ARAD mixer
controls ...

alsactl: set_control:1461: Cannot write control '2:0:0:Lane1 Ratio Int:0' : Operation not permitted
alsactl: set_control:1461: Cannot write control '2:0:0:Lane1 Ratio Frac:0' : Operation not permitted
alsactl: set_control:1461: Cannot write control '2:0:0:Lane2 Ratio Int:0' : Operation not permitted
alsactl: set_control:1461: Cannot write control '2:0:0:Lane2 Ratio Frac:0' : Operation not permitted
alsactl: set_control:1461: Cannot write control '2:0:0:Lane3 Ratio Int:0' : Operation not permitted
alsactl: set_control:1461: Cannot write control '2:0:0:Lane3 Ratio Frac:0' : Operation not permitted
alsactl: set_control:1461: Cannot write control '2:0:0:Lane4 Ratio Int:0' : Operation not permitted
alsactl: set_control:1461: Cannot write control '2:0:0:Lane4 Ratio Frac:0' : Operation not permitted
alsactl: set_control:1461: Cannot write control '2:0:0:Lane5 Ratio Int:0' : Operation not permitted
alsactl: set_control:1461: Cannot write control '2:0:0:Lane5 Ratio Frac:0' : Operation not permitted
alsactl: set_control:1461: Cannot write control '2:0:0:Lane6 Ratio Int:0' : Operation not permitted
alsactl: set_control:1461: Cannot write control '2:0:0:Lane6 Ratio Frac:0' : Operation not permitted

The problem is that these mixer controls are defined using the
SOC_SINGLE_EXT macro which does not defined the access type. If the
access is not defined then it is presumed to be READWRITE (see
snd_ctl_new1) but there is no 'put' handler specified for these
controls. Hence, when alsactl attempts to restore these mixer controls
is fails with permission denied. Fix this by making these mixer
controls read-only.

Bug 2058979

Change-Id: I0abd0604257510f13ac768ab6a954554cab14dd6
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1675099
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
Jon Hunter
f0ebf9d9c4 ASoC: tegra-alt: Fix restoration of mixer controls
When using the ALSA 'alsactl' tool to save and restore mixer settings
the following type of errors are observed ...

alsactl: set_control:1461: Cannot write control '2:0:0:ADMAIF1 Channels:0' : Invalid argument
...
alsactl: set_control:1461: Cannot write control '2:0:0:AMX1 Output Channels:0' : Invalid argument
...
alsactl: set_control:1461: Cannot write control '2:0:0:RX1 Channels:0' : Invalid argument
...
alsactl: set_control:1461: Cannot write control '2:0:0:TX1 Channels:0' : Invalid argument
...
alsactl: set_control:1461: Cannot write control '2:0:0:TX5 Channels:0' : Invalid argument
...
alsactl: set_control:1461: Cannot write control '2:0:0:SFC1 Channels:0' : Invalid argument
...
alsactl: set_control:1461: Cannot write control '2:0:0:MVC1 Bits:0' : Invalid argument

These are just a few examples but these errors are seen for all
instances of the devices. The problem is that the 'put' handler for
the above mixer controls treats '0' as an invalid setting and so if
the default value is '0', then when we try to restore the setting to
'0' it fails because this is consider an 'invalid argument'. However,
'0' is not a invalid argument, it simply means that we are not
overriding this setting from userspace.

Furthermore, if someone happens to set an of the above mixer controls
to a non-zero value, then it is not possible to set it back to '0'
again.

Fix this by allowing userspace to set the above mixer controls to '0'.

Bug 2058979

Change-Id: Icd543c2ea956cb0690238d9a1f184c144a572029
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1675098
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
Jon Hunter
04f1ad23f1 ASoC: tegra-alt: Fix DMIC boost gain upper limit
The Tegra DMIC 'Boost Gain' control shows an upper limit of '25600'.

nvidia@tegra-ubuntu:~$ amixer -c 1 sget "DMIC3 Boost Gain"
 Simple mixer control 'DMIC3 Boost Gain',0
 Capabilities: volume volume-joined
 Playback channels: Mono
 Capture channels: Mono
 Limits: 0 - 25600
 Mono: 0 [0%]

However, if a user attempts to set it to this the following error is
seen ...

 [  314.961362] tegra210-dmic tegra210-dmic.2: Boost Gain overflow
 [  314.970917] tegra210-dmic tegra210-dmic.2: Boost Gain overflow

Software only allows a max value of '25599' to be written to this
control and so fix this.

Bug 2069481

Change-Id: Ibdfa6f2c43e3855c72d2ec6fed6848f1395ccef8
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1673437
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-by: Viswanath L <viswanathl@nvidia.com>
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
Mohan Kumar
9216eec344 ASoC: tegra_alt: add DMIC enable/disable functions
Add functions to enable/disable DMIC and export them.
These are needed in case where DMIC clock needs to be
enabled without any capture use case.

Bug 200391366

Change-Id: Ia35f897de4e1ffa1b78e04c5c26004c867fa1d0d
Signed-off-by: Mohan Kumar <mkumard@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1661680
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Viraj Karandikar <vkarandikar@nvidia.com>
Tested-by: Viraj Karandikar <vkarandikar@nvidia.com>
Reviewed-by: Ravindra Lokhande <rlokhande@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
Jon Hunter
03857bc5e4 ASoC: tegra-alt: Fix device name for RT565x machine driver
Overriding the device name for the Tegra RT565x machine driver is
preventing UDEV rules for Systemd and L4T from detecting the sound
card. The sysfs path for the sound card is
'/sys/devices/sound/sound/card1' but by changing the device name
the systemd-udev service is looking for the sound card under
'/sys/devices/tegra-snd-t186ref-mobile-rt565x/sound/card1' which
does not exist. This is seen by checking the systemd log ...

 ubuntu@tegra-ubuntu:~$ sudo journalctl -b | grep rt565x
 ...
 Feb 28 16:30:22 tegra-ubuntu systemd-udevd[2934]: error opening \
 ATTR{/sys/devices/tegra-snd-t186ref-mobile-rt565x/sound/card1/controlC1/../uevent} \
 for writing: No such file or directory

This prevents ...
1. The systemd udev rule '/lib/udev/rules.d/78-sound-card.rules'
   from detecting the card and setting the udev enviroment variable
   'SOUND_INITIALIZED' for the card. This in turn prevents pulseaudio
   from seeing the card.
2. The L4T udev rule '/etc/udev/rules.d/90-alsa-asound-tegra.rules'
   from detecting the card and setting the initial state of the
   sound card.

Fix this by removing the code that overrides the device name for
the Tegra RT565x machine driver.

Bug 2019300
Bug 2067653
Bug 2067087
Bug 200382657

Change-Id: Ie371c1b3211cc4742d2e35c8e6976b01e1c23c31
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1666573
Reviewed-by: Sameer Pujar <spujar@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
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
Hariharan Sivaraman
540f5ece2c tegra-adsp-alt: increase num of plugins
Increase number of supported plugins by ADSP
from 10 to 20

Bug 2048629

Change-Id: I44410252635fafb4b4d484ce75e642286e954ab2
Signed-off-by: Hariharan Sivaraman <hariharans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1664190
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Dipesh Gandhi
a6c5cba8dd tegra-alt: apm stack size from dt
Change add support to pass apm thread
stack size from device tree using property
"apmX-stack-size = <N>"

Bug 200389033

Change-Id: Id09703bfc5a3edfa55ec9c389d62660fdf8b6b62
Signed-off-by: Dipesh Gandhi <dipeshg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1662846
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Uday Gupta <udayg@nvidia.com>
Reviewed-by: Viraj Karandikar <vkarandikar@nvidia.com>
Reviewed-by: Nitin Pai <npai@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
Jon Hunter
3b6209c985 ASoC: tegra-alt: Fix support for I2S DSP-B mode
The Tegra sound machine driver only set the TDM slots for DSP-A mode.
The TDM slots also need to be set for DSP-B mode so update the
machine driver to set the slots for DSP-B mode as well.

The 'tx_mask' and 'rx_mask' for for TDM modes is the same and will
always be the same. So simplify the code by having a single mask
variable.

Finally, remove unnecessary initialisation of 'err'.

Bug 2025176

Change-Id: I98630772432c2083bf4b4cf37bdfaf2f4c4514e5
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1656600
GVS: Gerrit_Virtual_Submit
Reviewed-by: Sameer Pujar <spujar@nvidia.com>
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
Jon Hunter
2cae54a567 ASoC: tegra-alt: Add support for overriding the bclk ratio
To test internal loopback on any I2S interface using various different
sampling frequencies, it is necessary to be able to override the bit
clock ratio. However, rather than adding a kcontrol for each audio
link supported by the machine driver, add a global kcontrol that when
set will control the bit clock ratio for all I2S links.

Bug 2025176

Change-Id: I46ec949d36f0fe34967b9ed718d2189b539a1a37
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1602528
(cherry picked from commit 08afde21c1041db7d926b094cc9822402b73524f)
Reviewed-on: https://git-master.nvidia.com/r/1655983
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Jon Hunter
6191131ae7 ASoC: tegra-alt: Fix return type for getting the bclk ratio
The functions tegra_machine_get_bclk_ratio() and
tegra_machine_get_bclk_ratio_t18x() have a return type of unsigned int
but can return a negative error code on failure. This may cause users
of this function to get a very large bit clock ratio. Although it is
improbable that the bit clock ratio will ever be large enough to
overflow a signed integer, it is best to avoid changing the type of
the bit clock ratio variable. Therefore, return the bit clock ratio
via a pointer passed to the functions tegra_machine_get_bclk_ratio()
and tegra_machine_get_bclk_ratio_t18x().

Bug 2025176

Change-Id: Ia6e9a1ef68f53ebb594746f812de65a18269925f
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1655982
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Jon Hunter
baa66924d1 ASoC: tegra-alt: Return error if tegra_machine_set_params() fails
If setting the bit-clock ratio or number of TDM slots fails, then
return the error and fail.

Bug 2025176

Change-Id: I3301c5182db0f6f8aab0cf16798211b938df1750
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1655981
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30