• Jerome Brunet's avatar
    ASoC: meson: axg-tdm-formatter: fix channel slot allocation · c1f848f1
    Jerome Brunet authored
    When the tdm lane mask is computed, the driver currently fills the 1st lane
    before moving on to the next. If the stream has less channels than the
    lanes can accommodate, slots will be disabled on the last lanes.
    
    Unfortunately, the HW distribute channels in a different way. It distribute
    channels in pair on each lanes before moving on the next slots.
    
    This difference leads to problems if a device has an interface with more
    than 1 lane and with more than 2 slots per lane.
    
    For example: a playback interface with 2 lanes and 4 slots each (total 8
    slots - zero based numbering)
    - Playing a 8ch stream:
      - All slots activated by the driver
      - channel #2 will be played on lane #1 - slot #0 following HW placement
    - Playing a 4ch stream:
      - Lane #1 disabled by the driver
      - channel #2 will be played on lane #0 - slot #2
    
    This behaviour is obviously not desirable.
    
    Change the way slots are activated on the TDM lanes to follow what the HW
    does and make sure each channel always get mapped to the same slot/lane.
    
    Fixes: 1a11d88f ("ASoC: meson: add tdm formatter base driver")
    Signed-off-by: default avatarJerome Brunet <jbrunet@baylibre.com>
    Link: https://lore.kernel.org/r/20230809171931.1244502-1-jbrunet@baylibre.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
    c1f848f1
axg-tdm-formatter.c 10.2 KB