WM8960 Codec with Android Audio HAL

Problem with Android audio through WM8960 codec.

Audio card was successfully probed and mapped (showed in dmesg logs).
I have tried to play audio from adb shell using following command:

tinyplay /data/test.wav -D 0 -d 0

No errors is printed and no sound from speaker. Then I have tried standard Android audio player and logcat contains errors.

2020-05-17 13:52:46.579 259-1568/? D/AudioHardwareTiny: AudioData write  error , keep slience! ret = -1
2020-05-17 13:52:46.591 259-1568/? W/StreamHAL: Error from HAL stream in function get_presentation_position: Operation not permitted

What is the changes I should to do with tinyalsa to make wm8960 codec working ?

Does the simaple-audio-card have ingratiation with tinyalsa?

Is there any documentation regarding adding codec to Android?

Installation steps described below

In the Android source code I have found codec source code (kernel/sound/soc/codecs/wm8960.c) and enabled it through menuconfig.
(Also HDMI audio was disabled to remove sound cards from the list. Only wm8960_sound is exist in the list)
I have updated DTS configuration for android (kernel/arch/arm64/boot/dts/rockchip/rk3399-khadas-edge-android.dts):

Added sound card to root node

	wm8960_sound {
        compatible = "simple-audio-card";
        simple-audio-card,format = "i2s";
        simple-audio-card,name = "RKWM8960";
        status = "okay";
 	    // pinctrl-names = "default";
        simple-audio-card,mclk-fs = <256>;
        // simple-audio-card,hp-det-gpio = <&gpio1 0 GPIO_ACTIVE_HIGH>;
        simple-audio-card,widgets =
            "Microphone", "Mic Jack",
            "Line", "Line In",
            "Line", "Line Out",
            "Speaker", "Speaker",
            "Headphone", "Headphone Jack";
        simple-audio-card,routing =
            "Headphone Jack", "HP_L",
            "Headphone Jack", "HP_R",
            "Speaker", "SPK_LP",
            "Speaker", "SPK_LN",
			"Speaker", "SPK_RP",
            "Speaker", "SPK_RN",
            "LINPUT1", "Mic Jack",
            "LINPUT3", "Mic Jack",
            "RINPUT1", "Mic Jack",
            "RINPUT2", "Mic Jack";
        simple-audio-card,cpu {
            sound-dai = <&i2s0>;
   	    simple-audio-card,codec {
          sound-dai = <&wm8960>;

Enabled i2s0

&i2s0 {
      status = "okay";
      rockchip,playback-channels = <2>;
      #sound-dai-cells = <0>;

Added driver to i2c0

&i2c0 {
    status = "okay";
    i2c-scl-rising-time-ns = <600>;
    i2c-scl-falling-time-ns = <20>;

    wm8960: wm8960@1a {
        compatible = "wlf,wm8960";
        reg = <0x1a>;
        #sound-dai-cells = <0>;
        /* MCLK source is a stand-alone oscillator */
        clock-frequency = <12288000>;
        clocks = <&cru SCLK_I2S_8CH_OUT>;
        clock-names = "mclk";
        pinctrl-names = "default";
        pinctrl-0 = <&i2s_8ch_mclk>;
        status = "okay";
        //  wlf,capless;

Khadas Edge-V
WM8960 Audio HAT


Audio problem was resolved by modification of hardware/rockchip/audio/tinyalsa_hal/audio_hw.c file.