redchenjs / mt762x-wm8960

MT762X WM8960 ALSA SoC machine driver
GNU General Public License v2.0
27 stars 22 forks source link

No sound after installing drivers #13

Open kmickz opened 1 year ago

kmickz commented 1 year ago

Hii

i have mt7628evb board with wm8960 codec openwrt version is 21.02. mt762x-wm8960 driver version is 5.4 the device is registered but when i play any wav file there is no sound.

logs:--

[ 14.834064] kmodloader: loading kernel modules from /etc/modules.d/* [ 14.981660] i2c /dev entries driver [ 15.000940] ralink_gdma: module is from the staging directory, the quality is unknown, you have been warned. [ 15.039663] gdma-rt2880 10002800.gdma: revision: 3, channels: 16 [ 15.116108] i2c-mt7621 10000900.i2c: clock 100 kHz [ 15.140496] ralink-i2s 10000a00.i2s: mclk 480MHz [ 15.205956] mt762x-wm8960 sound: wm8960-hifi <-> 10000a00.i2s mapping ok [ 15.261825] urngd: v1.0.2 started. [ 15.340943] Loading modules backported from Linux version v5.10.157-0-gf4245f05389c

### aplay -l output :-

root@OpenWrt:/# aplay -l List of PLAYBACK Hardware Devices card 0: Card [MT762X WM8960 ASoC Card], device 0: wm8960-hifi wm8960-hifi-0 [wm8960-hifi wm8960-hifi-0] Subdevices: 1/1 Subdevice #0: subdevice #0

root@OpenWrt:/# aplay -L null Discard all samples (playback) or generate zero samples (capture) default:CARD=Card MT762X WM8960 ASoC Card, wm8960-hifi wm8960-hifi-0 Default Audio Device sysdefault:CARD=Card MT762X WM8960 ASoC Card, wm8960-hifi wm8960-hifi-0 Default Audio Device

commands given to amixer :--

amixer sset "Headphone" 90 mixer sset "Speaker" 90Simple mixer control 'Headphone',0 Capabilities: pvolume Playback channels: Front Left - Front Right Limits: Playback 0 - 127 Mono: Front Left: Playback 90 [71%] [-31.00dB] Front Right: Playback 90 [71%] [-31.00dB] root@OpenWrt:/# amixer sset "Speaker" 90 Simple mixer control 'Speaker',0 Capabilities: pvolume Playback channels: Front Left - Front Right Limits: Playback 0 - 127 Mono: Front Left: Playback 90 [71%] [-31.00dB] Front Right: Playback 90 [71%] [-31.00dB] root@OpenWrt:/# root@OpenWrt:/# root@OpenWrt:/# root@OpenWrt:/# root@OpenWrt:/# amixer sset "Left Output Mixer PCM" on ixer sset "Right Output Mixer PCM" onSimple mixer control 'Left Output Mixer PCM',0 Capabilities: pswitch pswitch-joined Playback channels: Mono Mono: Playback [on] root@OpenWrt:/# amixer sset "Right Output Mixer PCM" on Simple mixer control 'Right Output Mixer PCM',0 Capabilities: pswitch pswitch-joined Playback channels: Mono Mono: Playback [on]

aplay sampl music play****

aplay -vv preamble10.wav Playing WAVE 'preamble10.wav' : Signed 16 bit Little Endian, Rate 22050 Hz, Mono Plug PCM: Route conversion PCM (sformat=S16_LE) Transformation table: 0 <- 0 1 <- 0 Its setup is: stream : PLAYBACK access : RW_INTERLEAVED format : S16_LE subformat : STD channels : 1 rate : 22050 exact rate : 22050 (22050/1) msbits : 16 buffer_size : 10240 period_size : 2048 period_time : 92879 tstamp_mode : NONE tstamp_type : MONOTONIC period_step : 1 avail_min : 2048 period_event : 0 start_threshold : 10240 stop_threshold : 10240 silence_threshold: 0 silence_size : 0 boundary : 1342177280 Slave: Hardware PCM card 0 'MT762X WM8960 ASoC Card' device 0 subdevice 0 Its setup is: stream : PLAYBACK access : MMAP_INTERLEAVED format : S16_LE subformat : STD channels : 2 rate : 22050 exact rate : 22050 (22050/1) msbits : 16 buffer_size : 10240 period_size : 2048 period_time : 92879 tstamp_mode : NONE tstamp_type : MONOTONIC period_step : 1 avail_min : 2048 period_event : 0 start_threshold : 10240 stop_threshold : 10240 silence_threshold: 0 silence_size : 0 boundary : 1342177280 appl_ptr : 0 hw_ptr : 0

redchenjs commented 1 year ago

Hi @kmickz , can you provide the image file you are using? Not all audio formats are supported by the driver.

redchenjs commented 1 year ago

Have you tried playing stereo audio?

kmickz commented 1 year ago

can you provide me supported audio file link

kmickz commented 1 year ago

hey @redchenjs i tried all formats but still there is no sound please can you suggest me what i am doing wrong also tried both mono and stereo audio but still make no difference

root@OpenWrt:~# aplay -vv pcm1608s.wav Playing WAVE 'pcm1608s.wav' : Signed 16 bit Little Endian, Rate 8000 Hz, Stereo Plug PCM: Hardware PCM card 0 'MT762X WM8960 ASoC Card' device 0 subdevice 0 Its setup is: stream : PLAYBACK access : RW_INTERLEAVED format : S16_LE subformat : STD channels : 2 rate : 8000 exact rate : 8000 (8000/1) msbits : 16 buffer_size : 4096 period_size : 1024 period_time : 128000 tstamp_mode : NONE tstamp_type : MONOTONIC period_step : 1 avail_min : 1024 period_event : 0 start_threshold : 4096 stop_threshold : 4096 silence_threshold: 0 silence_size : 0 boundary : 1073741824 appl_ptr : 0 hw_ptr : 0

+ | 00%

redchenjs commented 1 year ago

Hi @kmickz, have you checked the REFCLK pin of the WM8960 and the device tree file you used? Maybe we can take a look at the schematic for the audio part.

kmickz commented 1 year ago

@redchenjs , yes i check REFCLK pin it continuously generating 12Mhz clock(cross-check with CRO) here is my dts file configuration for better understating of problem

include "mt7628an.dtsi"

include <dt-bindings/gpio/gpio.h>

include <dt-bindings/input/input.h>

/ { compatible = "mediatek,mt7628an-eval-board", "mediatek,mt7628an-soc"; model = "Mediatek MT7628AN evaluation board";

};

&state_default { gpio { groups = "gpio"; function = "gpio"; };

refclk {
    groups = "refclk";
    function = "refclk";
};

i2s {
    groups = "i2s";
    function = "i2s";
};

};

&wmac { status = "okay"; };

&spi0 { status = "okay";

flash@0 {
    compatible = "jedec,spi-nor";
    reg = <0>;
    spi-max-frequency = <10000000>;

    partitions {
        compatible = "fixed-partitions";
        #address-cells = <1>;
        #size-cells = <1>;

        partition@0 {
            label = "u-boot";
            reg = <0x0 0x30000>;
            read-only;
        };

        partition@30000 {
            label = "u-boot-env";
            reg = <0x30000 0x10000>;
            read-only;
        };

        factory: partition@40000 {
            label = "factory";
            reg = <0x40000 0x10000>;
            read-only;
        };

        partition@50000 {
            compatible = "denx,uimage";
            label = "firmware";
            reg = <0x50000 0x7b0000>;
        };
    };
};

};

&i2c { status = "okay";

codec: wm8960@1a {
    compatible = "wlf,wm8960";
    reg = <0x1a>;
    wlf,shared-lrclk;
};

};

&i2s { status = "okay"; };

&gdma { status = "okay"; };

/ { sound { compatible = "mediatek,mt762x-wm8960-machine"; mediatek,platform = <&i2s>; mediatek,audio-codec = <&codec>; audio-routing = "Headphone", "HP_L", "Headphone", "HP_R", "Ext Spk", "SPK_LN", "Ext Spk", "SPK_LP", "Ext Spk", "SPK_RN", "Ext Spk", "SPK_RP", "Mic", "MICB", "LINPUT1", "Mic", "LINPUT2", "Line In", "RINPUT2", "Line In"; }; };

kmickz commented 1 year ago

following is circuit i am using

Screenshot from 2023-04-10 17-44-31

redchenjs commented 1 year ago

@kmickz The refclk in the dts file is not needed, the board has an external crystal oscillator for WM8960.

kmickz commented 1 year ago

@redchenjs removing refclk from dts file make no difference

redchenjs commented 1 year ago

微信截图_20230417204942

@kmickz I use the LinkIt Smart 7688 board with Breakout for LinkIt Smart 7688 v2.0. The WM8960 configuration is almost the same, except for the audio input part. Breakout_for_LinkIt_Smart_7688_v2.0_schematic_files.zip

I tested the wav file and mp3 file using the following commands: test.wav.zip test.mp3.zip

WAV file:
aplay /tmp/test.wav

MP3 file:
madplay /tmp/test.mp3

The playback is fine, and the capture works as well:

arecord -f cd | aplay

My build environment is as follows:

OpenWrt 21.02-SNAPSHOT, r16827-23ad680a345 Kernel 5.4.231
Driver source: https://github.com/redchenjs/mt762x-wm8960/tree/linux-5.4
DTS file: https://github.com/redchenjs/mt762x-wm8960/blob/linux-5.4/examples/mt7628an_mediatek_linkit-smart-7688.dts
kmickz commented 1 year ago

hii @redchenjs i was trying to fix this problem can not find solution yet can you please provide me some details regarding your linux 5.4.231

it looks like my DAC is in off state here is some logs which i get

root@OpenWrt:/sys/kernel/debug/asoc/MT762X WM8960 ASoC Card/wm8960.0-001a/dapm# cat Left\ DAC Left DAC: Off in 0 out 4 - R26(0x1a) mask 0x100 stream Playback inactive out "PCM Playback Switch" "Left Output Mixer" in "static" "Playback"