Skip to content

ASoC: rk817: re-enable I2S after digital clock restarts - #401

Open
einars-soundtrack wants to merge 1 commit into
rockchip-linux:develop-6.12from
einars-soundtrack:fix-rk817-i2s-reenable
Open

einars-soundtrack wants to merge 1 commit into
rockchip-linux:develop-6.12from
einars-soundtrack:fix-rk817-i2s-reenable

Conversation

@einars-soundtrack

Copy link
Copy Markdown

Changing 'Playback Path' from OFF while a stream is already running leaves the RK817/RK809 codec silent until the stream is prepared again; with this patch the audio comes up, with left and right in the right order.

  • DAC_DIG_CLK_MASK and ADC_DIG_CLK_MASK cover I2SRX_EN and I2STX_EN, so every digital clock restart and path power-up clears them, and only mute_stream(mute=0) from PCM prepare sets them again.
  • The driver now remembers whether each direction is unmuted and sets its I2S enable again at the end of each digital clock restart.
  • With the path set before prepare, the register writes are unchanged.
  • Capture gets the same change; it was not tested on hardware.

DAC_DIG_CLK_MASK and ADC_DIG_CLK_MASK cover the whole nibble of
RK817_CODEC_DTOP_DIGEN_CLKE, so every DAC or ADC digital clock restart
and every path power-up also clears I2SRX_EN (bit 0) or I2STX_EN
(bit 4). Only mute_stream(mute=0) sets them again, and it runs from PCM
prepare.

Changing 'Playback Path' from OFF after the PCM was prepared therefore
leaves the codec ignoring the I2S data: ALSA reports RUNNING and the
output is silent until the stream is prepared again. The same holds for
'Capture MIC Path' and I2STX_EN.

Clearing the enable during the restart is wanted. Narrowing the masks
so that I2SRX_EN stays set across the restart restores the audio, but
left and right then come up swapped at random, as the I2S receiver must
only be enabled once its clocks run.

Fix this by tracking, for playback and for capture, whether the stream
is currently unmuted. At the end of every digital clock restart, set
I2SRX_EN or I2STX_EN again if it is.

The usual sequences are not affected. When the path is selected before
the stream is prepared, or when hw_params runs again after hw_free, the
stream is still muted during the restart, so nothing is re-enabled and
the register writes are the same as before.

Tested on an RK3562 board with an RK809 (chip id 0x8090), playback
through dmix with a 500 Hz / 1 kHz left/right test signal on an
oscilloscope: 20 switches of 'Playback Path' OFF -> HP under a running
stream and 5 runs of stream first, path second, all kept the channel
order. With narrowed masks the same test swapped the channels on about
every second switch. Capture is changed the same way but was not run on
hardware.

Fixes: 4a68fd5 ("ASoC: rk817: Fix L/R channel order")
Signed-off-by: Einārs Netlis-Galejs <einars@soundtrack.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant