Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: WM8960 Audio Codec Support for Radxa Zero 2 Pro #396

Open
rajeshpachaikani opened this issue Mar 2, 2025 · 5 comments
Open
Assignees

Comments

@rajeshpachaikani
Copy link

WM8960 is a popular and well-supported codec with good Linux driver support. Radxa Zero 2 pro board have 3 TDM (I2S) Interfaces but no software support for one of the widely available (and cheapest) audio codec out there. Can anyone from the the radxa team write the dts overlay and driver for the wm8960 board?

  1. Hardware:

    • Radxa Zero 2 Pro (A311D SoC)
    • WM8960 audio codec (I2C addr: 0x1a)
  2. DTS Overlay Requirements:

    • Configure i2c for codec control
    • Configure tdm interface for I2S communication
    • Set up audio routing for headphone/speaker/mic
    • Clock config: 12.288MHz MCLK
  3. Implementation using simple-audio-card binding:

    • Format: i2s
    • Include proper audio routing paths for WM8960
    • Support standard WM8960 widgets (HP, SPK, MIC)
    • ALSA Configuration
@rajeshpachaikani
Copy link
Author

rajeshpachaikani commented Mar 2, 2025

I tried to create an overlay, connected the hardware and tested it. I am able to see the card recognized but the audio is not working. I am not sure what is causing the problem and I'd appreciate any help on resolving/debugging the problem. I have added my findings in a radxa forum post. ( https://forum.radxa.com/t/where-is-the-documentation-on-i2s-support-in-radxa-zero-2-pro/25939/4?u=rajesh ). Please take a look at it and let me know what else can I try. The following is the latest dts overlay I tried which is adapted from the raspberry pi dts source for wm8960.

/dts-v1/;
/plugin/;

/ {
    metadata {
        title = "Enable WM8960 Audio Codec on TDM B";
        compatible = "radxa,zero2", "amlogic,a311d", "amlogic,g12b";
        category = "audio";
        description = "Enable WM8960 Audio Codec on TDM B interface";
        exclusive = "tdmif_b";
    };

    fragment@0 {
        target = <&tdmif_b>;
        __overlay__ {
            status = "okay";
        };
    };

    fragment@1 {
        target-path = "/";
        __overlay__ {
            wm8960_mclk: wm8960_mclk {
                compatible = "fixed-clock";
                #clock-cells = <0>;
                clock-frequency = <12288000>;
            };
        };
    };

    fragment@2 {
        target = <&i2c3>;  // Use i2c3 as this is the one we specified in the previous overlay
        __overlay__ {
            #address-cells = <1>;
            #size-cells = <0>;
            status = "okay";

            wm8960: wm8960 {
                compatible = "wlf,wm8960";
                reg = <0x1a>;
                #sound-dai-cells = <0>;
                AVDD-supply = <&ao_5v>;
                DVDD-supply = <&vcc_3v3>;
            };
        };
    };

    // Create a new sound card node instead of modifying the existing one
    fragment@3 {
        target-path = "/";
        __overlay__ {
            wm8960_card: wm8960_sound {
                compatible = "simple-audio-card";
                simple-audio-card,format = "i2s";
                simple-audio-card,name = "wm8960-soundcard";
                status = "okay";
                
                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",
                    "LINPUT1", "Mic Jack",
                    "LINPUT3", "Mic Jack",
                    "RINPUT1", "Mic Jack",
                    "RINPUT2", "Mic Jack";
                
                simple-audio-card,cpu {
                    sound-dai = <&tdmif_b>;
                    // Amlogic specific TDM settings if needed
                    dai-tdm-slot-num = <2>;
                    dai-tdm-slot-width = <32>;
                };
                
                simple-audio-card,codec {
                    sound-dai = <&wm8960>;
                    clocks = <&wm8960_mclk>;
                    clock-names = "mclk";
                    // Set as bitclock and frame master if needed
                    // bitclock-master;
                    // frame-master;
                };
            };
        };
    };

    __overrides__ {
        alsaname = <&wm8960_card>,"simple-audio-card,name";
        compatible = <&wm8960>,"compatible";
        // The master override syntax needs to be adjusted for this design
        master = <&wm8960_card>,"simple-audio-card,bitclock-master!simple-audio-card,frame-master";
    };
};

@CodeChenL
Copy link
Contributor

amlogic's i2s node is not supported in simple-audio-card

@RadxaYuntian
Copy link
Member

Also __overrides__ is Raspberry Pi only stuff. We do not support this. You should just put your modification in the main nodes.

@rajeshpachaikani
Copy link
Author

Image

I am trying to connect and use TDMC. The pins are a little ambiguous. What is the LRCLK pin of the TDMC port. GPIOA13 or GPIOA15 ?

@rajeshpachaikani
Copy link
Author

amlogic's i2s node is not supported in simple-audio-card

Thank you. I see wm8960.c and wm8960.h in the Linux kernel source and assumed getting the WM8960 to work with Radxa Zero 2 Pro using simple-audio-card would be easy. Since Amlogic's I2S node isn’t supported in simple-audio-card, can the Amlogic AXG sound card work with the WM8960? If it’s incompatible or requires major driver changes, I’ll look for other options. Are there any docs or code samples I can refer to for making WM8960 work with Radxa Zero 2 Pro?

 sound {
        compatible = "amlogic,axg-sound-card";
        model = "AXG-S420";
        audio-aux-devs = <&tdmin_a>, <&tdmout_c>;
        audio-widgets = "Line", "Lineout",
                        "Line", "Linein",
                        "Speaker", "Speaker1 Left",
                        "Speaker", "Speaker1 Right",
                        "Speaker", "Speaker2 Left",
                        "Speaker", "Speaker2 Right";
        audio-routing = "TDMOUT_C IN 0", "FRDDR_A OUT 2",
                        "SPDIFOUT IN 0", "FRDDR_A OUT 3",
                        "TDM_C Playback", "TDMOUT_C OUT",
                        "TDMIN_A IN 2", "TDM_C Capture",
                        "TDMIN_A IN 5", "TDM_C Loopback",
                        "TODDR_A IN 0", "TDMIN_A OUT",
                        "Lineout", "Lineout AOUTL",
                        "Lineout", "Lineout AOUTR",
                        "Speaker1 Left", "SPK1 OUT_A",
                        "Speaker2 Left", "SPK2 OUT_A",
                        "Speaker1 Right", "SPK1 OUT_B",
                        "Speaker2 Right", "SPK2 OUT_B",
                        "Linein AINL", "Linein",
                        "Linein AINR", "Linein";

        dai-link-0 {
            sound-dai = <&frddr_a>;
        };

        dai-link-1 {
            sound-dai = <&toddr_a>;
        };

        dai-link-2 {
            sound-dai = <&tdmif_c>;
            dai-format = "i2s";
            dai-tdm-slot-tx-mask-2 = <1 1>;
            dai-tdm-slot-tx-mask-3 = <1 1>;
            dai-tdm-slot-rx-mask-1 = <1 1>;
            mclk-fs = <256>;

            codec-0 {
                sound-dai = <&lineout>;
            };

            codec-1 {
                sound-dai = <&speaker_amp1>;
            };

            codec-2 {
                sound-dai = <&speaker_amp2>;
            };

            codec-3 {
                sound-dai = <&linein>;
            };
        };

        dai-link-3 {
            sound-dai = <&spdifout>;

            codec {
                sound-dai = <&spdif_dit>;
            };
        };
    };

This is a shot in the dark but I would like to know if I can modify this sample AXG sound interface dts file to include the support for WM8960. If yes, please let me know where to look for the relevant docs.

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

No branches or pull requests

3 participants