]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit
ASoC: bcm2835: Add support for TDM modes
authorMatthias Reichl <hias@horus.com>
Sun, 7 May 2017 09:34:26 +0000 (11:34 +0200)
committerKhalid Elmously <khalid.elmously@canonical.com>
Fri, 16 Feb 2018 22:11:48 +0000 (17:11 -0500)
commitc0153f97e8fc5d1e0292ab7248d6945fccf870c3
tree31f1e024555030f03697c9c46e2723644f18df2d
parenta4b113b4d9bce5d9049361199ff07865d6589346
ASoC: bcm2835: Add support for TDM modes

bcm2835 supports arbitrary positioning of channel data within
a frame and thus is capable of supporting TDM modes. Since
the driver is limited to 2-channel operations only TDM setups
with exactly 2 active slots are supported.

Logical TDM slot numbering follows the usual convention:

For I2S-like modes, with a 50% duty-cycle frame clock,
slots 0, 2, ... are transmitted in the first half of a frame,
slots 1, 3, ... are transmitted in the second half.

For DSP modes slot numbering is ascending: 0, 1, 2, 3, ...

Channel position calculation has been refactored to use
TDM info and moved out of hw_params.

set_tdm_slot, set_bclk_ratio and hw_params now check more
strictly if the configuration is valid. Illegal configurations
like odd number of slots in I2S mode, data lengths exceeding
slot width or frame sizes larger than the hardware limit of
1024 are rejected. Also hw_params now properly checks for
errors from clk_set_rate.

Allowed PCM formats are already guarded by stream constraints,
thus the formats check in hw_params has been removed and
data_length is now retrieved via params_width().

Also standard functions like snd_soc_params_to_bclk are now
being used instead of manual calculations to make the code
more readable.

Special care has been taken to ensure that set_bclk_ratio works
as before. The bclk ratio is mapped to a 2-channel TDM config
with a slot width of half the ratio. In order to support odd ratios,
which can't be expressed via a TDM config, the ratio (frame length)
is stored and used by hw_params.

Signed-off-by: Matthias Reichl <hias@horus.com>
sound/soc/bcm/bcm2835-i2s.c