Commit Graph

678 Commits

Author SHA1 Message Date
Sameer Pujar
39e4507117 ASoC: tegra: merge 'tegra' and 'tegra-alt' directories
Tegra210 and later audio drivers have been using 'tegra-alt' directory
from the beginning. As per the upstream roadmap, we plan to use the
same 'tegra' directory and place all the drivers under it. This patch
thus moves all the drivers to 'tegra' and renames the files accordingly.
The '_alt' suffix is removed from header and source files.

For some files still the '_alt' suffix is retained because 'tegra'
already has the corresponding files. Manual merge of following files is
needed and will be done in separate commits.
 * tegra_asoc_utils_alt.c and tegra_asoc_utils.c
 * tegra_asoc_utils_alt.h and tegra_asoc_utils.h
 * tegra_pcm_alt.c and tegra_pcm.c
 * tegra_pcm_alt.h and tegra_pcm.h
 * Corresponding Makefile and Kconfig files.
 * Source files related to ADSP audio, FPGA, bandwidth manager are not
   considered at the moment and will be tracked separately.

Bug 2845498

Change-Id: I51dae3971c72b58d921dc19f0553a83422fd3f9e
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
2022-09-29 15:30:21 +05:30
Mohan Kumar
da1da6911e ASoC: tegra-alt: Control AHUB rate from DT
AHUB clock currently uses pll_a_out0 derivative clock from plla source
but the max frequency for pll_a_out0 was limited to ~49MHz to derive
all possible clock rates for i2s sampling rates. This limits the AHUB
clock rate to be used at peak possible rate for ahub which can help in
some high bandwidth usecase. Considering this AHUB rate can be derived
from PLLP clock to support max possible rate for AHUB.

Making use of assigned-clock-rates and assigned-clock-parents to set the
desired settings as per dvfs table for a given platforms.

Bug 200537672

Change-Id: Ica556fc68456b52516c82b6601b54cae0b5d1b73
Signed-off-by: Mohan Kumar <mkumard@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2204283
(cherry picked from commit add574aa21b447b61391f51650fe52175190064b)

Signed-off-by: Mohan Kumar <mkumard@nvidia.com>
Change-Id: I655337be86d37b05843a9a9b4238001779653eeb
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2280448
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-09-29 15:30:21 +05:30
Sameer Pujar
f44cfefe5d ASoC: tegra-alt: use regmap macros for timeout
Following print is seen while using regmap_read_poll_timeout() macro
in snd_soc_dai_ops trigger() callback in ADMAIF driver,
 *** BUG: scheduling while atomic ***
and kernel panic happens there after. This happens because above macro
is not atomic safe and trigger() is called in atomic context.

Earlier this addressed by using readx_poll_timeout_atomic() macro.
Though this works fine driver needs to keep a reference to base address.
To avoid this new macro was pushed and is accepted in upstream and
following is the commit - https://lkml.org/lkml/2020/1/9/985

This patch makes use of regmap macros where there is a need of timeout
functionality. Following is the guideline that can be followed.
 * use regmap_read_poll_timeout_atomic() where the caller is in atomic
   context.
   ex: trigger() etc.,
 * use regmap_read_poll_timeout() when the caller is known to be running
   in non-atomic context.
   ex: hw_param(), prepare() etc.,

Based on this audio drivers are updated. ASRC and ARAD drivers will be
taken up in a separate change.

Bug 200566596

Change-Id: Iea88adc60de5919e456a36a30152212652a8ecd3
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2274874
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Sharad Gupta <sharadg@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
Sameer Pujar
27008c3e63 ASoC: tegra-alt: optimize XBAR MUX get/put() APIs
This patch optimizes following functions on the usage of local
variables and removal of redundant loops, thus making these
functions more readable.
 * tegra_xbar_get_value_enum()
 * tegra_xbar_put_value_enum()

Bug 200503387

Change-Id: I32989d0cf46ad50bf47a0127bac1eb7c1ed32ff2
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2268611
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Viswanath L <viswanathl@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
Sameer Pujar
49b09c95c7 ASoC: tegra-alt: remove S24_LE format
S24_LE is a 32-bit container with 24-bit data in LSBs, with zeroes in
most significant byte. S32_LE can act as 32-bit container for 24-bit
data where data is pushed to MSBs and zeroes are filled in least
significant byte. For example below is how the data is represented
for different containers, where 'abc' is 24-bit data.
  0abc (S24_LE)
  abc0 (S32_LE)

As per IAS, most significant bits are pushed first when data moves
in AHUB. For any down conversion LSBs are discarded, where as for any
up conversion, zeroes are filled in the LSBs. Hence extraction of
S24_LE results in data loss. Mentioned below are some of the examples
to illustrate this.

Consider for playback path, where data flow is from memory to AHUB and
its clients, where 'abc' is valid data and 'x' is to ignore.
  * S32_LE
    abc0 --> audio = 32, client = 32 --> abc0
    abc0 --> audio = 32, client = 24 --> abcx
    abc0 --> audio = 32, client = 16 --> abxx
  * S24_LE
    0abc --> audio = 32, client = 32 --> 0abc
    0abc --> audio = 32, client = 24 --> 0abx (data loss)
    0abc --> audio = 32, client = 16 --> 0axx (data loss)

Thus this patch removes S24_LE format from the drivers since Tegra audio
HW is not designed to support this. Also S24_LE is not a commonly used
format.

Bug 200568187

Change-Id: I778d2f70527c17f00728fce75fe152d902c5aaa0
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2264822
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Viswanath L <viswanathl@nvidia.com>
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
Sameer Pujar
df32a012ac ASoC: tegra-alt: re-organize XBAR code
XBAR related code is currently put under source files "tegra210_xbar_alt.c"
and "tegra210_xbar_utils_alt.c". For upstream we are planning to use a
single source file. Thus code in downstream is re-organized so that all
XBAR code is moved under a single file.

Following is the summary of changes,
 * All XBAR specific code is moved under,
   "tegra210_xbar_alt.c" and "tegra210_xbar_alt.h"
 * Only common code, which is required for other modules, remains in
   "tegra210_xbar_utils_alt.c"
 * unused macros or functions are removed

Bug 200503387

Change-Id: I11cb93d3cdc07e14ef2e0b3b23ba6a98020a0373
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2265584
GVS: Gerrit_Virtual_Submit
Reviewed-by: Dara Ramesh <dramesh@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
Sameer Pujar
6f6b01c660 ASoC: tegra-alt: remove i2s DT properties for "fsync-width" and "enable-cya"
Currently in downstream,
 * we pass FSYNC width from DT for LRCK and FSYNC modes. We also have a
   mixer control to override the width. If the property is missing a
   default width of "31" is set.
 * DT property, "enable-cya", is used on Tegra210 to enable pad controls
   for I2S4. This is not required for other instances of I2S on Tegra210
   and not required for any instance on Tegra186/Tegra194.

With current patch,
 * DT property "fsync-width" is removed
   - LRCK mode does not require FSYNC width to be configured.
   - Reset value (one-bit-clock wide) is what we are using for DSP modes.
   - If specific width needs to be configured, mixer control is already
     available. Generally for FSYNC modes, the width depends on the codec
     and in such cases mixer control is helpful.
 * DT property "enable-cya" is removed
   - By default the corresponding bit is enabled.
   - For other instances of I2S on Tegra210 and for any instance on
     Tegra186/Tegra194, this bit is unused.
 * updated the channel that needs to be used for CIF and I2S control.
   For example, for CIF configuration audio channels is used and
   for BCLK rate or channel bit count calculation, client channel is
   used.
 * helper function tegra210_i2s_set_timing_params() is added to program
   I2S clock and timing related registers.
 * I2S global enable is moved to default list. The enable status on TX/RX
   channel is controlled via DAPM widget.

Bug 200503387

Change-Id: Iafe62e8816f6d8702a325c8466d6b6fda5514d66
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2244478
GVS: Gerrit_Virtual_Submit
Reviewed-by: Dara Ramesh <dramesh@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
Sameer Pujar
c3c5ac4e23 ASoC: tegra-alt: remove channel hard coding for I2S and ADMAIF
Currently CIF channels are overridden based on mono/stereo settings.
This can be problematic for multi-channel use cases or the cases where
user is intentionally overriding channels through mixer control. In such
cases hard coding based on CIF mono/stereo settings can result in wrong
behavior.

Following are the changes in current patch,
 * Decouple CIF mono/stereo and CIF channel settings. It means that, user
   can override audio channels and CIF settings independently. Also these
   controls are provided for both playback and capture paths.
 * For ADMAIF, channel overrides are provided for both audio and client
   channels in both playback and capture paths.
 * For I2S, separate channel overrides for client channels is not needed
   in playback and capture paths. Hence a common client channel override
   control is provided. However for audio channels it is similar to the
   controls provided for ADMAIF.
 * Similar to channels, for I2S, audio bit format control is updated and
   provided separate controls in playback and capture paths.
 * "None" option is removed for mono/stereo to match HW register spec.
   Earlier channel was hard coded based on this.
 * For I2S, audio channels are used for CIF configuration and for the slot
   control client channels are used (earlier audio channels were getting
   used for slot control)
 * For upstream, we are standardizing mixer control names. For now, only
   relevant controls are updated. Going forward we need to take similar
   approach for all controls/modules. This needs to be reflected in
   test scripts and documentation as well.

Bug 200503387

Change-Id: I04df9a3bda41e028edc46e86ecd1d80966bc83e1
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2244477
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
f48397b648 ASoC: tegra-alt: warning print at disable timeout
ADMAIF may hit timeout in closing sequence, if some bits remain
unconsumed in FIFO, which may happen if the sink gets closed/blocked
ahead of source. As such the status register of ADMAIF remaining
uncleared is not a catastrophic error and the channel will be
available after reset, hence timeout merits a warning print.

Above issue gets hit in two test scripts:
 - tegra-audio-amx-to-adx.sh, where closing aplay at any one input
    port of AMX causes the module to block other substreams. This
    is a HW bug, fixed in T194 upwards.
 - tegra-audio-admaif-testsuite.sh, where running aplay and arecord
    without any flow control does not ensure that aplay always drains
    its bits.

The warning print here, in playback path, is whitelisted for GVS runs.

Bug 200569324

Change-Id: I12984d08c6f43f41f3b85bb066d42b6883249060
Signed-off-by: Viswanath L <viswanathl@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2258180
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@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
Sameer Pujar
9c3c3fbc35 ASoC: tegra-alt: remove dev.id parsing from DT
For AHUB modules instance number is passed with a DT property. For example,
"nvidia,ahub-i2s-id" property is used in I2S nodes. Similarly other modules
use "nvidia,ahub-<module>-id" property, where <module> is "dmic" or "dspk"
or other corresponding module names. With DAI links in DT now, this is not
required any more. Hence the parsing code for such properties is removed.

Bug 200503387

Change-Id: Ia372044ebecfe090668953b8da81028c63812a4f
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2146859
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Asha Talambedu
14ccf06582 ASoC: tegra-alt: ASRC_INT_CLEAR_WAR config cleanup
- CONFIG_TEGRA186_ASRC_INT_CLEAR_WAR is removed.

- Int clear war is disabled for platforms >= t194 as the related
  h/w issue is resolved with the help of compatible string match

Bug 200540133

Change-Id: I48677f17278f0451c67fa2b9232b9e960bf8a34f
Signed-off-by: Asha Talambedu <atalambedu@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2233940
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
7a56385cb5 ASoC: tegra-alt: remove overrides for device names
Currently we maintain auxdata structure for Tegra210 and Tegra186. This
is nothing but a lookup table used for device names and platform data.
It is used to override device names when creating devices from DT. Since
we have moved all DAI links to DT and no more we rely on device names,
automatically generated device names should be good enough. Hence this
patch removes auxdata table and dev_set_name() calls from XBAR, AMX
drivers.

Some of the embedded platforms are using older machine utility code,
which are using these names. Hence the utility code is also updated to
use automatically generated device names.

Bug 200503387

Change-Id: I80c4fb3a5927001f58a54ca90437ec67ed14bf54
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2258385
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Dara Ramesh <dramesh@nvidia.com>
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
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
Sameer Pujar
001188d41c ASoC: tegra-alt: parse machine widgets from DT
Machine DAPM widgets are currently defined in the driver and are used
to connect to DAPM input/output widgets of external codecs. This routing
map is exposed from DT. Since the machine driver is common to multiple
platforms, all widgets defined in the driver are not always required.
Instead of statically defining the widgets in the driver, these can be
exposed from DT. Any platform DT can then add required number of widgets
and can define a corresponding routing map.

This patch removes the static array for DAPM widgets and instead helper
function, snd_soc_of_parse_audio_simple_widgets(), is used to populate
given DAPM widgets for the sound card.

Bug 200503387

Change-Id: I8ff9f0d52e3c1cc10b6ab1682d05a7b7ef7e2684
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2257383
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Jonathan Hunter <jonathanh@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
Sameer Pujar
1f403897f1 ASoC: tegra-alt: move to DT based DAI links
Currently we are using static DAI links in machine-utils code and there
are some drawbacks associated with it.
 * All DAI links are enabled, even though if a platform does not require.
   For ex: ALSA ring buffers are allocated for all the ADMAIF PCM links.
   Some platforms might want to enable a very few links, which is not
   currently possible with static array in the driver code.
 * No way to disable specific modules from DT. For example if any of the
   module instances are disabled, sound card registration fails.
 * CPU and CODEC names are hard coded in the DAI link arrays. With this
   we need to pass instance-id properties from DT to identify or match
   the correct instance names.
 * One of the other concerns is about latency, where some platform want
   to optimize this by only enabling required links.

Above issues can be addressed with DT based DAI links and going ahead
plan is to use upstream style of DT binding. This patch includes following
changes.
 * Add new helper functions to parse all DAI links from DT. All code
   related to this is added in a new file.
 * Remove older helper functions for parsing. Please note that, not all
   functions can be removed since few machine drivers rely on them.
 * Common params structure is used for all codec-to-codec links. In machine
   driver hw_params() callback all DAI link params are updated. Hence it
   is not necessary to maintain separate structures.
 * By default card->dapm.idle_bias_off is set to true. This means, codec
   suspend() won't be called during STANDBY. The flag is set to true for
   Tegra210 as well, where earlier it was set to false. This further helps
   to remove soc_data structure.
 * Module specific checks are not needed to manage DAI links now.

Bug 200538260

Change-Id: I210b70c23a8878f5b1733dfa9d2010834ae4a85a
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2229358
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Asha Talambedu
e8f6236ef5 ASoC: tegra-alt: Unify machine driver config
-Avoided double compilation of machine driver as mobile
 platforms >= t210 have common machine driver, through a
 common config
-Removed SND_SOC_ASOC_MACHINE_ALT, SND_SOC_TEGRA_ALT_FORCE_CARD_REG
 config as its not being used

Bug 200540133

Change-Id: I57271888581d6494e771be77a8fd2fe5b5adb015
Signed-off-by: Asha Talambedu <atalambedu@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2233907
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
Reviewed-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@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
Sameer Pujar
5f8e73c6cf ASoC: tegra-alt: simplify timeout code for I2S and ADMAIF
For SW reset and register status polling timeout code is used in multiple
drivers. Since the logic is similar, the same code is duplicated at many
places. This can be avoided by relying on the kernel macro which provides
similar functionality, where sleep between polling and timeout can be
explicitly provided. For example, ADMA driver is using a similar kernel
macro and this can be used for Tegra ASoC drivers as well.

Currently this patch updates timeout code for ADMAIF and I2S to start with.
This helps for upstream as well. Other drivers will be taken care in a
separate patch. In doing so following changes are also needed,
 * Few functions are optimized to simplify the code during stream start or
   stop. This basically combines RX and TX handling in a single function
   and thus helps to avoid code duplication.
 * For ADMAIF, macros are used wherever register access for RX and TX paths
   are needed. Existing CH_REG() macro is updated to facilitate this. RX
   and TX paths can use CH_RX_REG() and CH_TX_REG() respectively to get
   proper register offset. Accordingly the access is updated in the driver.

Bug 200566596
Bug 200503387

Change-Id: I6d46518dba09a936ad84799943eba8976a261faa
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2241448
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Jonathan Hunter <jonathanh@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
5e32b94e91 ASoC: tegra-alt: Remove unsupported modes from I2S control
The I2S interfaces only support configurations where both the bit clock
and frame sync are master or are both slave. Therefore, remove support
for modes where the bit clock is master and frame sync is slave and
vice-versa from the 'I2Sx codec master mode' mixer controls.

Bug 2046053
Bug 2746555

Change-Id: I288a1a372fe200b5faf2eb0f3d7c481a34c1f545
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2230060
(cherry picked from commit 79a002b42a9c25cd26832c967f95f82e08935ca9)
Reviewed-on: https://git-master.nvidia.com/r/2237275
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
Asha Talambedu
3b9d9c345c ASoC: tegra-alt: Remove redundant configs
Removed redundant configs TEGRA210_AMX_MAP_READ
and TEGRA210_ADX_MAP_READ

Bug 200540133

Change-Id: I84404731dd277385d1432c5d235c36805f2da4f5
Signed-off-by: Asha Talambedu <atalambedu@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2233899
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@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
84cc33a1b6 ASoC: tegra-alt: Prevent I2S controls overwriting each other
Each I2S interface has a mixer control 'I2Sx codec master mode' to
set the master mode and 'I2Sx codec frame mode' to set the frame mode.
An issue with these mixer controls has been found where if the user
sets both of these, then whatever is set last will overwrite the other
resetting it back to its default value. For example, if 'I2Sx codec
master mode' configures the codec as the master, then set the 'I2Sx
codec frame mode' to say 'dsp-a', then setting the frame mode will
revert the master mode setting back to its default. Fix this by
ensuring the frame mode and master mode do not overwrite each other.

Bug 2046053
Bug 2746555

Change-Id: Ibd51a0462a4c02055075aee84808f7ddca0a9199
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2230059
(cherry picked from commit 70c45f196b76ce0d5e1e76153232cb3d35928262)
Reviewed-on: https://git-master.nvidia.com/r/2234917
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
0ac26664d6 ASoC: tegra-alt: move OPE2 to the end of dai array
This is a preparatory patch for moving all DAI links to DT. With DT based
DAI links, we need to index through the DAI array. There are differences
between Tegra210 and Tegra186, which are listed below.
 * OPE2 is removed in Tegra186
 * AMX and ADX instances are increased to 4
 * DSPK, ASRC and ARAD are added
 * DMIC instances are increased to 4
 * I2S instances are increased to 6
 * ADMAIF channels are increased to 20 each for Tx and Rx

Above makes us to have separate headers in DT, containing macro defines,
for Tegra210 and Tegra186. This can be avoided by re-ordering the DAI array
to list common DAIs in the beginning and push the differences at the end.
As we can see adding instances can be easily handled by just listing out
the new DAIs at the end. But problem is when we remove an instance and it
requires some intelligence encoded in header files for optimization. In the
current case, OPE2 is being removed from Tegra186 onwards and hence this is
pushed to the end of Tegra210 DAI array.

Bug 200538260

Change-Id: I8f976ce08d6526357ab4578fa462ab53113c674d
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2220276
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Mohan Kumar D <mkumard@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
Sameer Pujar
efee3b9c95 ASoC: tegra-alt: update dai order for DSPK
This is a preparatory patch for moving all DAI links to DT. With the DT
based DAI link approach, we need to index through the DSPK DAI array to
reference a particular interface. This patch re-orders DAI array to be
consistent with other drivers, where we always first list CIF DAI and
then followed by DAP and Dummy (wherever applicable). DT can use macros
for these indices and can be common if the same order is followed for
all modules.

Bug 200538260
Bug 200520821

Change-Id: Ib3ced6078b73bdf542891e28d8081e3dd38e1ab5
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2220275
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Mohan Kumar D <mkumard@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
Sameer Pujar
456a60cebe ASoC: tegra-alt: one dai array for ADMAIF and ADSP
This is a preparatory patch for moving all DAI links to DT. Currently
ADMAIF is registering both a component and a codec. Also it maintains
two DAI arrays, tegra210_admaif_codec_dais[]/tegra186_admaif_codec_dais[]
for codec and tegra_admaif_dais[] for component. With the DT based DAI
link approach, we need to index through the DAI array depending on the
"sound-dai" property that cpu/codec subnodes of the dai-link can expose.
The sound core is looking at *_codec_dais[] array while getting the DAI
name from index and does not consider component DAI array. Similarly this
is true for ADSP device as well.

This patch combines both DAI arrays and registers ADMAIF and ADSP as a
codec device alone. Later versions of kernel move from codec to component,
during that transition we can register ADMAIF device as component only.

Also, for ADSP, hard-coding of DAI ID is avoided which further helps to
index the required DAI from DT. The fe_reg/be_reg value calculation, which
depends on the DAI ID, is updated accordingly.

Bug 200538260

Change-Id: Ia65b6c52796d3da73850ce1de6bf332ac723b871
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2218928
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@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
Sameer Pujar
4ac7c86445 ASoC: tegra-alt: add dummy DAI for I/O modules
To allow loopbacks or dummy playback/capture from I/O modules to work
we have connected DAI links to spdif-dit dummy codecs, since generally
not all I/O modules have external codec connection. This helps to close
the DAPM path and audio path can be tested. The links or information
for these is exposed from DT.

In doing so, we require many instances of spdif-dit devices. For example,
for Tegra194 we have 6-I2S, 4-DMIC, 2-DSPK I/O modules. Hence we need
a maximum of 12 such spdif-dit codecs. This is populated in DT by exposing
entries for all these. Machine driver exposes routing paths for these with
random "prefix" naming.

Above can be easily avoided by doing following.
 * Expose dummy DAIs for I/O modules and routing path in module drivers.
 * Dummy speaker output and mic input DAPM widgets are added for path
   completion.
 * Routing path is added for connecting above.
 * By default for all the instances of I/O, connect the modules to dummy
   DAIs. This way we can make sure that the DAPM path is complete by
   default.

Bug 200516191
Bug 200520821
Bug 200503387

Change-Id: I3bb34ae6e62f61b5b3e693c746cac6c312775912
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2177821
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
e263ddd04d ASoC: tegra-alt: remove redundant drivers
- remove unused code
- update hypervisor check condition

Bug 200552920

Change-Id: Ie2ca3542d8dc50191f402c9d4c96d56e4c89db7a
Signed-off-by: Dipesh Gandhi <dipeshg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2200432
Reviewed-by: Uday Gupta <udayg@nvidia.com>
Tested-by: Uday Gupta <udayg@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@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
be22100ee2 ASoC: tegra-alt: Fix machine driver
ASRC config was enabled for all chip versions and this leads to
writing in the dai_links array for T210 platforms which is not
acceptable as there was no ASRC present on it. Fix this issue
by having extra runtime compatible check for t210.

Bug 200555164

Change-Id: I3714d4aed77b6cecc262db443219920f872c3e17
Signed-off-by: Mohan Kumar <mkumard@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2210518
(cherry picked from commit f9598cb45db19454a77fd78f680cc2b8db50cc7b)
Reviewed-on: https://git-master.nvidia.com/r/2210938
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Sameer Pujar <spujar@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
Jonathan Hunter
a1372cf4d0 ASoC: tegra-alt: Prevent ALSA restore overriding I2S DT settings
When booting L4T, the I2S configuration for DAI format is defined by
properties in device-tree for the DAI link. However, mixer controls
for controlling the 'codec master mode' and 'codec frame mode' have
been added to the Tegra ASoC machine driver to that the DAI format can
also be configured from userspace. The problem is that if the
device-tree blob is updated and reflashed, any new settings in
device-tree for the DAI format although are applied initially during
boot, they are overwritten by the ALSA restore service that restores
the previous settings. The mixer controls should not override the DT
settings by default unless the user has explicitly set them via the
mixer controls.

Fix this by storing the state of the 'codec master mode' and 'codec
frame mode' mixer controls in a separate variable from the actual DAI
link format data.

Bug 2665590

Change-Id: I1405b1e8a3bb67e619fb43c3f9142e8a050e04c6
Signed-off-by: Jonathan Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2190010
(cherry picked from commit f5cf6f5b3532deec65b01b2a26a5373614a11bf6)
Reviewed-on: https://git-master.nvidia.com/r/2193535
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
51d0fedb09 ASoC: tegra-alt: add i2s sync input clock
By default we are using plla_out0 as the clock source of I/O modules.
Similarly, these modules can use SYNC_CLK as the clock source. SYNC_CLK
is a MUX of I2Sx bit clocks and few other clocks. Hence it is possible
to use I2Sx bit clock as parent for I2Sy module or for any DMIC or DSPK
instance.

This patch adds SYNC_INPUT support for I2S bit clocks and set rate for
the same as per bit clock rate. If some I/O module wants to use this
bit clock as reference, then corresponding module can use assigned-clocks
DT bindings to setup proper clock relationships.

As an example, consider the case where I2S2 wants to use I2S1 bit clock as
reference. Clock relation looks like below(from clk_tree dump),
* i2s1_sync_input
    |__
       |
     i2s2_sync_clk
        |__
           |
         i2s2
DT binding to establish above relation is(Tegra194 taken as reference),
 i2s@2901100 {
     ...

     assigned-clocks = <&bpmp TEGRA194_CLK_I2S2>,
                       <&bpmp TEGRA194_CLK_SYNC_I2S2>;
     assigned-clock-parents = <&bpmp TEGRA194_CLK_SYNC_I2S2>,
                              <&bpmp TEGRA194_CLK_I2S1_SYNC_INPUT>;

     ...
 };

In default case, i2s2 clock relation is like below,
* pll_a
    |__
       |
     plla_out0
        |__
           |
         i2s2
And the corresponding DT binding is,
 i2s@2901100 {
     ...

     assigned-clocks = <&bpmp TEGRA194_CLK_I2S2>;
     assigned-clock-parents = <&bpmp TEGRA194_CLK_PLLA_OUT0>;

     ...
 };

Bug 200544085

Change-Id: I5d8d773616cecb4ccc43a5cf1f89845a68c861d4
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2189715
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Dipesh Gandhi <dipeshg@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
Asha Talambedu
d5be4c92a4 ASoC: tegra-alt: Fix MVC mute issue
MVC Mute Mixer ctrl setting is not reflecting correct
status as the mute ctrl register is not cached and therefore
getting reset to default in resume call that is being called
after reading the mixer ctrl.

To avoid this, MVC mute register is made non-volatile and
get_sync/put_sync is avoided for reading this cached register

Mute status reset in cache everytime after setting volume
for proper reflection of mute status in mixer controls. Note
that cached value will be synced to hardware on resume.

Bug 200532059

Change-Id: I9ee072d84c8103facdad22b2708113c4bcdda039
Signed-off-by: Asha Talambedu <atalambedu@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2165774
(cherry picked from commit 85badb30954b503121f139a66eba4dc02eb90068)
Reviewed-on: https://git-master.nvidia.com/r/2185120
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
aa1f1ad292 ASoC: tegra-alt: Remove on fly curve change support
on the fly curve type change needs hw soft reset or MVC disable
and enable programming sequence to be followed with re-programming
all the required register. Current driver code support is not
fully compliant with the IAS programming sequence. So to better
handling remove the on fly curve type support from the mvc driver.

Bug 200532059

Change-Id: I55a44134b07d1ddfebf103796d47930158ff770d
Signed-off-by: Mohan Kumar <mkumard@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2180060
(cherry picked from commit 608bcd2adf33b3f1daa5dad37441295351ea6e0c)
Reviewed-on: https://git-master.nvidia.com/r/2184303
GVS: Gerrit_Virtual_Submit
Reviewed-by: Asha Talambedu <atalambedu@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
Dipesh Gandhi
b6debbfd49 ASoC: tegra-alt: correct stale data clear logic
dmaengine_pcm_pointer return number of frames. Present clean
in drain state is incorrectly treating frames as bytes which
can lead to clear more than expected data.

This change make sure addition call byte_to_frames() is
not done.

Bug 200530292

Change-Id: I6daf696e14333cd914329e5c12b8052e4c7fdf4f
Signed-off-by: Dipesh Gandhi <dipeshg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2159316
(cherry picked from commit a86d579f9eaaf422e656b29965a2bc2371aefca4)
Reviewed-on: https://git-master.nvidia.com/r/2159286
Tested-by: Poojashree M S <pms@nvidia.com>
Reviewed-by: Uday Gupta <udayg@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Mohan Kumar D <mkumard@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
Asha Talambedu
fd7fd450b6 ASoC: tegra-alt: Modified ADSP config and prompts
a) Both ADSP audio driver and OS are compiled with the same
config setting. Therefore, defined a config to enable disablement
of ADSP audio driver.
b) In addition, removed prompts for symbols related
to tegra-alt module drivers as the drivers as dependencies are not
properly defined which can lead to illegal confgurations that might
result in runtime failures

Bug 200536088

Change-Id: I2a7e31d604cca6f86f9db47dc0a7f91e96c6605a
Signed-off-by: Asha Talambedu <atalambedu@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2159728
(cherry picked from commit 626e9724092aec5f0a39368cb51278a873cd7dfe)
Reviewed-on: https://git-master.nvidia.com/r/2176657
GVS: Gerrit_Virtual_Submit
Reviewed-by: Mohan Kumar D <mkumard@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
Sameer Pujar
a4107ebd5d ASoC: tegra-alt: remove nvidia,mclk-rate property
Currently MCLK rate depends on following DT properties,
 * 'mclk-fs' : This is a scaling factor depending on which MCLK rate
   is calculated at runtime [rate = scale * sample_rate]. Different
   codecs might expect different scale factors and hence DT property
   is useful here.
 * 'nvidia,mclk-rate' : This is used to provided fixed rate for MCLK.
   This overrides scale property, when specified.

Since the requirement is either to have fixed or dynamic rate for MCLK,
this can be managed with single property like below.
 * Use 'assigned-clocks' and 'assigned-clock-parents' to specify parent
   clock for MCLK.
 * Use preferred rate during initialization with 'assigned-clock-rates'
   DT binding. This can be the required fixed rate as well.
 * If dynamic scaling is required, then use 'mclk-fs' property.
   Otherwise system uses fixed rate.

Since rt565x audio codecs expect scaling factor of 256, all platforms
which use such codecs must be populated with "mclk-fs" property. This
is taken care in other patches in the series.

Bug 200542485
Bug 200516191
Bug 200503387

Change-Id: I1fc31626929bab9d4707d2a1b74c8f1749412ea4
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2173560
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
Reviewed-by: Ravindra Lokhande <rlokhande@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@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
c051f5fb23 ASoC: tegra-alt: remove function propotype defines
tegra_machine_driver_mobile.c declares function protoypes in the
beginning. This was done to avoid compiler build errors related
to unresolved symbols, when function is used before its definition.

With this patch, code is re-organised and these function prototypes
are no more needed.

Bug 200503387
Bug 200516191

Change-Id: I35519faf39059af5f0c9adf81712008ce61d8614
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2173559
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Mohan Kumar D <mkumard@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
Mohan Kumar
919e8b00bd ASoC: tegra-alt: Fix MVC gain issues
The Applied gain in dB never reflected in the output data with
the current driver code. There was few issues related to the
way we program the sequences. As a first step cleaning up the
driver to make sure the applied gain is proper in the output and
bitmatch works with multiple runs.

- Do MVC soft reset to clear the state in the hw_params before
processing the input data.
- Assign the init volume and target volume to the same value at
start of processing.
- Trigger the switch only after programming all the registers related
to Volume, duration and polynomial coefficients.

Bug 200532059

Change-Id: I2c77bd225284f31892ed8c2ff7c228dd19f8c63e
Signed-off-by: Mohan Kumar <mkumard@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2170333
(cherry picked from commit 6f56c3df3f2f6a55e33d9071cb5d05d0992a6b28)
Reviewed-on: https://git-master.nvidia.com/r/2173817
Reviewed-by: Automatic_Commit_Validation_User
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
Sameer Pujar
a4c55519f8 ASoC: tegra-alt: clock cleanup for AHUB drivers
Currently we pass module clocks and related parents from DT bindings. The
driver gets these clock handles and does enable/disable() or sets rate
or parents whenever required. But passing the parent clock is not necessary
always, unless we want to change the rate dynamically.

For example consider the case of i2s device. Possible parents of i2s are,
 * PLLA_OUT0, PLLA1_OUT1, SYNC_CLK, PLLP_OUT0, CLK_M
DT binding currently has entries for few of these clocks. This is not
needed, since we don't have requirement to set the parent dynamically.
Generally it is statically configured. Hence "assgigned-clocks" and
"assigned-clock-parents" DT binding can be used to specify the child and
parent relation.

In summary,
 * devm_clk_get() functions are removed for parent and sync clocks. Only
   for xbar, parent clock would be needed since we change the clock rate
   dynamically depending on playback/capture rate. In most of the cases
   only module clocks are sufficient and are retained.
 * sync clocks are currently not used for L4T/Android. It could be later
   required. Hence DT binding for it will be retained (mostly sync_input
   would be needed). Required driver support will be added later.
 * clk_set_parent() calls are removed, since DT clock binding takes care
   of this.
 * removed clk_ape and clk_apb2ape from xbar driver, since just enable
   or disable of these is performed in the driver, which is not really
   required. Because this is taken care in parent(ACONNECT) device node.
 * Few clock names are updated as below in devm_clk_get()
   * DSPK module clock --> "dspk"
   * I2S module clock  --> "i2s"
   * XBAR parent clock --> "parent"

Bug 200503387

Change-Id: I29b77e32cf1f950d9ea3bb66d27b4a8482bf9926
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2159592
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
2f0a260959 ASoC: tegra-alt: remove is_playback from DAI init
pcm_hw_params() and compr_set_params() functions set "is_playback" flag to
true for SNDRV_PCM_STREAM_PLAYBACK and SND_COMPRESS_PLAYBACK respectively.
The flag is then passed to tegra_machine_dai_init() function. However this
flag is not used by DAI init function and appears to be redundant.

Hence this patch removes is_playback argument from DAI init function and
cleans up pcm_hw_params() and compr_set_params() functions.

Bug 200516191
Bug 200503387

Change-Id: I759181a53fa2e599ca338b4004451183813a5fc5
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2172229
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
b4955d4ea6 ASoC: tegra-alt: remove shutdown handling
commit b4bc1cf56020("ASoC: tegra-alt: Avoid reg access after shutdown")
avoided device register access after shutdown() has been called. This
otherwise resulted in occasional SError and resulted in crash. The reason
for this was runtime PM does not work after shutdown and it was seen on
vK4.4

Looks like the issue has been fixed from vK4.5 onwards, where PM domain
detach is avoided during shutdown. Following is the upstream commmit.
"platform: Do not detach from PM domains on shutdown"

Bug 200503387

Change-Id: I5f3d18f05e434d5a1ed5b597362a39ec9a9f010b
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2161809
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-09-29 15:30:21 +05:30
Niranjan Dighe
3f3a331b56 Revert "ASoC: tegra-alt: add dma_set_mask parse"
This reverts commit 4ccb56ad195d811303051c067fd1c8915588767c.

Jira EMA-1251

Change-Id: I6997bb04ab801bf2c1de3bfe90bcdfc70c4c8c4a
Signed-off-by: Niranjan Dighe <ndighe@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2166540
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-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
Sameer Pujar
18c581a03e ASoC: tegra-alt: clock cleanup for machine driver
Highlights from current clock handling in machine driver(L4T/Android)
 * Tegra210 and Tegra186/194 have different approaches to update clock
   rates for pll_a, pll_a_out0, mclk and ahub.
   -> Tegra210 uses static method, where base pll_a rate is hardcoded
      in the driver.
   -> Tegra186/194 use DT driven approach, where sound node passes rates
      for above clocks. Two sets of rates are passed, one to support odd
      sample rates and one for even.
 * Some of the functions from tegra_asoc_utils_alt.c are unused
 * clock names are not really generic.

This patch has following updates.
 * Unify clock update approach. Use static array for base pll rates.
   This also helps to get rid of following sound node DT properties.
   "nvidia,num-rates"
   "nvidia,clk-rates"
 * Remove below unused functions.
   tegra_alt_asoc_utils_lock_clk_rate()
   tegra_alt_asoc_utils_register_ctls()
   tegra_alt_asoc_utils_tristate_dap()
 * clk_set_parent() functions are not needed. Instead the relationship
   can be set from DT through "assigned-clocks" binding.
 * update clock handle names to be more meaningful. However, clock names
   that are parsed in devm_clk_get() are not changed because these names
   are used in Automotive DT files under "sound_ref" node. Scope of
   current patch is limited to L4T/Android drivers and DT files.

Bug 200503387
Bug 200516191

Change-Id: Ideaf150e6e200ffbba4dcbdec4c49f1127ea25db
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2164482
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Ravindra Lokhande <rlokhande@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@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
Sameer Pujar
5a727dbebb ASoC: tegra-alt: remove DAI init for SFC
tegra_machine_sfc_init() is used to initialize input and output rates
for SFC module. In fact, this is done for only SFC1 instance. Machine
driver does this setup by calling snd_soc_dai_set_sysclk() for input
and output. SFC driver has a callback function implemented to take
care of this.

Above is not really required. By default srate_in and srate_out have
value 0 and hence SFC would operate in bypass mode. Already mixer
controls are exposed from the driver to set SFC input and output sample
rates and the same should be used for the required rate conversions.
Thus this patch removes following functions,
 * tegra_machine_sfc_init() from machine driver
 * tegra210_sfc_set_dai_sysclk() from SFC driver

Bug 200503387

Change-Id: Iada1b4748413debd0eb7d7f9a951069bda15af22
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2165143
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Mohan Kumar D <mkumard@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
Kwangwoo Lee
4f168be948 ASoC: tegra-alt: check the allocation of dai link
kzalloc() can be failed under low memory condition. In such a case, the
following memcpy() can cause a panic. Thus, the return value of
kzalloc() should be checked. If tegra_machine_get_dai_link_t18x() is
called, the return value should also be checked.

Bug 2647682

Change-Id: Ia200436a3b1877933932b9a086862f5507c8da54
Signed-off-by: Kwangwoo Lee <kwangwool@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2159959
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Sameer Pujar <spujar@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
Sameer Pujar
425bac4962 ASoC: tegra-alt: cleanup old DAI link related code
Machine driver has moved to newer versions of dai-link helpers. Unused
older functions now can be removed to simplify the code. Hence following
are removed.
 * dai_link_setup()
 * removed following callback functions from soc_data.
   (*get_dai_link)()
   (*get_codec_conf)()
   (*append_dai_link)()
   (*append_codec_conf)()
 * Machine driver probe() is cleaned up

Bug 200516191
Bug 200503387

Change-Id: Ia4e636f97e94cec51cd3b67ce27f1bec16caab09
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2151461
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Ravindra Lokhande <rlokhande@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
Sameer Pujar
7bed49cfba ASoC: tegra-alt: use new DAI link helpers
With this patch tegra_machine_driver_mobile.c uses newly exposed helper
for dai link setup, add_dai_links(). The soc_data is populated with dai
link and codec conf members to take care of t21x and t18x platforms.
Older function, dai_link_setup(), is marked as __maybe_unused. This will
be removed in subsequent patches in the series.

Bug 200516191
Bug 200503387

Change-Id: If7ae36acc932cc8c146d59c03fd3ab6732c7ff35
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2151460
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
c2a88a3b26 ASoC: tegra-alt: new helpers to manage DAI links
Idea is to expose dai links or codec confs via members of machine driver
structure. The 'struct tegra_asoc' is used to group dai link related
members, which would be included in the 'struct tegra_machine'. This helps
to simplify the code like mentioned below.
 * no need of having t21x or t18x specific helper functions
 * no need of having global variables. Currently we use few global members
   for t21x.
 * currently we have separate helpers to first pass DT dai-links and then
   append with the dai-links defined in machine-alt utility code. In the
   current patch new helper{tegra_asoc_populate_dai_links()} combines both
   of the operations. The same is true for codec conf helpers as well and
   tegra_asoc_populate_codec_confs() alone is sufficient.
 * machine driver codec_init() and set_dai_ops() for easy reading.

In summary,
 tegra_asoc_populate_dai_links() combines following.
   * tegra_machine_new_codec_links()
   * tegra_machine_append_dai_link()
   * tegra_machine_append_dai_link_t18x()

 tegra_asoc_populate_codec_confs() combines following.
   * tegra_machine_new_codec_conf()
   * tegra_machine_append_codec_conf()
   * tegra_machine_append_codec_conf_t18x()

 machine->asoc->dai_links/codec_confs replaces below helpers.
   * tegra_machine_get_dai_link()
   * tegra_machine_get_dai_link_t18x()
   * tegra_machine_get_codec_dai_link_idx_t18x()
   * tegra_machine_get_codec_conf()
   * tegra_machine_get_codec_conf_t18x()

Machine driver(tegra_machine_driver_mobile.c) exposes add_dai_links()
helper to setup dai links. This will be used in the subsequent patches in
the series. Few structures are moved to machine-alt header files for reuse
if needed by other machine drivers. Also release_asoc_phandles() is exposed
to balance refcounts, during error paths, by calling of_node_put() for DAI
links and codec conf.

Bug 200503387
Bug 200516191

Change-Id: I39c888068b8a1e8e0b1ca277270e9dd84044b150
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2151459
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Ravindra Lokhande <rlokhande@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
Mohan Kumar
807ca5b006 ASoC: tegra-alt: Fix MIXER1-7 codec dai name
The MIXER1-7 dai uses RX6 as codec dai which is wrong as it has
to use RX7, due to this RX7 path was never been used for t18x
and t19x platforms. Fix this issue by using RX7 as the codec
dai.

Bug 200534612

Change-Id: Ia0ad7ddf518ae4b113e2a0b095c3ee3893697064
Signed-off-by: Mohan Kumar <mkumard@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2155817
(cherry picked from commit f1890d288f2167055e3f32ef9ca61539c73a6c20)
Reviewed-on: https://git-master.nvidia.com/r/2158792
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
Mohan Kumar
5caff633f6 ASoC: tegra-alt: Remove pinctrl support in driver
Dynamic pinmux support through DT entries are no longer
supported for audio. This will make the pinctrl handling
in the audio drivers redundant and can be removed to be
inline with the policy followed for dynamic pinmux.

Bug 200533287

Change-Id: I37f958ab50afa88377ae4d6c50941241326dbbd3
Signed-off-by: Mohan Kumar <mkumard@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2151022
(cherry picked from commit 1b68ce5a60ae93de6f65d965570f091a7c10ac31)
Reviewed-on: https://git-master.nvidia.com/r/2153101
Reviewed-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Sharad Gupta <sharadg@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
Sameer Pujar
446bac0918 ASoC: tegra-alt: probe() cleanup for AHUB modules
Cleanup probe() functions for AHUB module drivers and following is the
summary of changes. This helps later in upstream too.
 * avoid unnecessary goto labels by updating return paths
 * removed following unused header files wherever applicable.
   linux/pinctrl/consumer.h
   linux/version.h
   linux/debugfs.h
   linux/slab.h
 * redundant pm_runtime_get/put removed in tegra186_xbar_registration()
 * Redundant error print during memory allocation failure is removed
 * runtime PM is enabled as late as possible and before the codec
   registration is done.
 * explicit calls to runtime_resume/suspend is avoided in probe(). For
   upstream, PM is enforced and the same can be done in downstream too.
   Hence no need to handle !PM case in driver probe()
   Ref: http://patchwork.ozlabs.org/patch/1048746/
 * IS_ERR() check is sufficient for error handling in case of
   devm_clk_get().

Bug 200520821
Bug 200503387

Change-Id: Ie4192036e72db161fa7d8ff4c6c0b28c17635793
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2153956
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Automatic_Commit_Validation_User
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
Sameer Pujar
87dc6dec32 ASoC: tegra-alt: cleanup resource ioremap
Currently drivers for resource ioremap does following explicit operations.
 * error check for platform_get_resource()
 * call devm_request_mem_region()
 * call devm_ioremap()

Instead of above explicit calls, devm_ioremap_resource() function can be
used, which covers all of the above. As per this scheme all drivers are
updated for memory region request and ioremapping.

Bug 200503387

Change-Id: I7b8df29742e8236d315369ef76aa57d47f47aac7
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2152456
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
b289cafe0e ASoC: tegra-alt: fix channel conversions for dmic
DMIC controller can be configured to receive data in both left and right
channels or in just the left channel or the right channel. Currently we
have dmic->ch_select to configure the same. There are few issues w.r.t
the way this is used.
  * dmic->ch_select overrides both client and audio channels of TX CIF.
  * channels in params_channels(params) is not used and hence requested
    number of channels in hw_param() callback is not considered.
  * stereo to mono conversion at TX CIF is not supported

This patch addresses all above issues with following
  * expose a mixer control, "Channel Select", for channel override for
    CIF channels.
  * dmic->ch_select is only used to override client channels.
  * by default ch_select is set to stereo and "None" option is removed
  * expose mixer control, "stereo to mono", for stere->mono conversion
    This can be used to select one of the following methods for conversion
      CH0 --> pick the first channel
      CH1 --> pick the second channel
      AVG --> (CH0 + CH1) / 2
  * "None" is not required for mono->stereo and hence removed and only
    below are sufficient.
      ZERO --> zero out the second channel
      COPY --> copy the first channel to the second channel
  * Replaced "TX" prefix for mixer controls with "Capture". This aligns
    with the policy we used for ADMAIF and I2S.
  * "Channel Select" control is replaced with "Controller Channel Select",
    as the control is related to DMIC controller and will be more
    meaningful.

Bug 200520821
Bug 200503387

Change-Id: I8a103f67dc75ca651ee3df3d8594971327364c84
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2151729
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Dara Ramesh <dramesh@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
Jonathan Hunter
e6d271554b ASoC: tegra-alt: Remove 'is_hs_supported' variable
Device-tree for all Tegra platforms has been updated to only populate
the link-name 'rt565x-playback' if the RT5658 codec is present. Note
that this is handled by the plug-in manager. Therefore, we no longer
need the additional test in the Tegra machine driver and we can
completely remove the variable 'is_hs_supported'.

Bug 200503387

Change-Id: I6070032f1d2f8d12245b1a2de5abcf60e97ec884
Signed-off-by: Jonathan Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2147460
(cherry picked from commit e987036cccf5a0a735bf3bc8e2c7147c89318cfa)
Reviewed-on: https://git-master.nvidia.com/r/2153227
Reviewed-by: Automatic_Commit_Validation_User
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