This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TLV320ADC5140: TVL320ADC5140 master + Raspberry Pi model 5 TDM 4 channels ,16bit, 48Kbit, 12.288 Mhz

Part Number: TLV320ADC5140
Other Parts Discussed in Thread: TLV320ADC6140

Tool/software:

Hi here.

We are planing to use TLV320ADC5140 for our project. I'm fighting  whit TVL320ADC5140 master + Raspberry Pi model 5 ---- 6.12.20+rpt-rpi-2712 in slave mode  to get  4 TDM channels. What  i  get from them only one channel for recording.

All possible DTS configuration for dsp_a, I2S, tdm, left_j mode was tested, nothing except only one channel.

Here is my dts config:

:

/dts-v1/;
/plugin/;

/ {
//compatible = "brcm,bcm2712";
compatible = "brcm,bcm2712", "brcm,bcm2835";

// Enable I2C1 controller and connect the TLV320ADCx140
fragment@0 {
target = <&i2c1>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";

tlv320adcx140: tlv320adcx140@4c {
compatible = "ti,tlv320adc5140";
reg = <0x4c>;
#sound-dai-cells = <0>;
status = "okay";
// Optional reset line
// reset-gpios = <&gpio 4 0>;
};
};
};

// Enable I2S hardware block
fragment@1 {
target = <&i2s_clk_consumer>;
__overlay__ {
status = "okay";
};
};

// Define the virtual sound card
fragment@2 {
target = <&sound>;
__overlay__ {
compatible = "simple-audio-card";
status = "okay";

simple-audio-card,name = "TLV320ADC5140 Audio";
//simple-audio-card,format = "i2s";
simple-audio-card,format = "dsp_a";
//simple-audio-card,format = "left_j";
simple-audio-card,bitclock-master = <&codec_dai>;
simple-audio-card,frame-master = <&codec_dai>;

cpu_dai: simple-audio-card,cpu {
sound-dai = <&i2s_clk_consumer>;
dai-tdm-slot-num = <2>;
dai-tdm-slot-width = <32>;
//dai-tdm-slot-tx-mask = <1 1 1 1>;
//dai-tdm-slot-rx-mask = <1 1 1 1>;
};

codec_dai: simple-audio-card,codec {
sound-dai = <&tlv320adcx140>;
clocks = <&mclk_external>;
system-clock-direction-out = "out";
//system-clock-frequency = <12288000>;
//mclk-fs = <256>;
};
};
};
fragment@3 {
target-path = "/";
__overlay__ {
mclk_external: mclk_external {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <12288000>;
clock-output-names = "mclk";
};
};
};

fragment@4 {
target-path = "/";
__overlay__ {
debug;
linux,debug;
};
};



// Optional: enable i2s_clk_consumer
//fragment@3 {
// target-path = "/soc/i2s@7e203000";
// __overlay__ {
// status = "okay";
// };
// };

// Required overrides to resolve symbols
// __overrides__ {
// audio-codec = <&tlv320adcx140>,"reg";
// };
};

Alsa see the card and working with TVL320ADC5140, including changing value in  corresponding registers. Interested fact that in bookworm 6.12.20+rpt-rpi-2712  no  asound.conf and asoundrc files on corresponding folders.

Here is registry script  (i could not past it as code):

#!/bin/bash

# TLV320ADC5140 Master Mode Initialization Script

ADDR=0x4C
BUS=1
OPTS="-y -f $BUS $ADDR"

# Function to write a register value on a specific page
i2c_write() {
PAGE=$1
REG=$2
VAL=$3
sudo i2cset $OPTS 0x00 $PAGE # Set page
sudo i2cset $OPTS $REG $VAL # Write value
}

echo "Configuring TLV320ADC5140 on I2C bus $BUS..."

########################
# Reset & Wake
########################

i2c_write 0x00 0x01 0x01 # Reset
sleep 1
i2c_write 0x00 0x02 0x81 # Enable adaptive filter + wake
i2c_write 0x00 0x05 0x05 # Enable all analog blocks

########################
# Channel Configs (1–4)
########################

# Channel 1 configuration
i2c_write 0x00 0x3C 0x21 # 0d = Microphone input
i2c_write 0x00 0x3D 0xA8 # 0d = Channel gain is set to 0 dB A8---42 max
i2c_write 0x00 0x3E 0xC9 # 0d = Digital volume is muted FF
i2c_write 0x00 0x3F 0x00 # 0d = Gain calibration is set to –0.8 dB
i2c_write 0x00 0x40 0x00 # 0d = No phase calibration

# Channel 2 configuration
i2c_write 0x00 0x41 0x21 # 0d = Microphone input
i2c_write 0x00 0x42 0xA8 # 0d = Channel gain is set to 0 dB
i2c_write 0x00 0x43 0xC9 # 0d = Digital volume 
i2c_write 0x00 0x44 0x00 # 0d = Gain calibration is set to –0.8 dB
i2c_write 0x00 0x45 0x00 # 0d = No phase calibration

# Channel 3 configuration
i2c_write 0x00 0x46 0x21 # 0d = Microphone input
i2c_write 0x00 0x47 0xA8 # 0d = Channel gain is set to 0 dB
i2c_write 0x00 0x48 0xC9 # 0d = Digital volume 
i2c_write 0x00 0x49 0x00 # 0d = Gain calibration is set to –0.8 dB
i2c_write 0x00 0x4A 0x00 # 0d = No phase calibration

# Channel 4 configuration
i2c_write 0x00 0x4B 0x21 # 0d = Microphone input
i2c_write 0x00 0x4C 0xA8 # 0d = Channel gain is set to 0 dB
i2c_write 0x00 0x4D 0xC9 # 0d = Digital volume
i2c_write 0x00 0x4E 0x00 # 0d = Gain calibration is set to –0.8 dB
i2c_write 0x00 0x4F 0x00 # 0d = No phase calibration

########################
# AGC & Input Bias
########################

i2c_write 0x00 0x70 0x00 # AGC: -6 dB target
i2c_write 0x00 0x6C 0x08 # AGC: Default attack/release
i2c_write 0x00 0x3B 0x02 # MIC bias = VREF (typ 2.75V)

########################
# Clocking (Master Mode, 12.288 MHz MCLK)
########################

i2c_write 0x00 0x13 0x81 # BCLK, WCLK master B1 c1 81
i2c_write 0x00 0x14 0x42 # 48 kHz, 16bit
i2c_write 0x00 0x16 0x10 # PLL mode, 

########################
# GPIO Config (Optional)
########################

i2c_write 0x00 0x33 0x00 # GPIO1 as input (can be used for MCLK detection) A0

########################
# ASI & TDM Configuration
########################

i2c_write 0x00 0x07 0x00 # 0d = TDM mode 00 = 16 bits 40 - i2s 80 -lj mode
i2c_write 0x00 0x08 0x00
i2c_write 0x00 0x09 0x00

# Channel mapping: CH1–CH4 to slots 0–3
i2c_write 0x00 0x0B 0x00
i2c_write 0x00 0x0C 0x01
i2c_write 0x00 0x0D 0x02
i2c_write 0x00 0x0E 0x03

########################
# GPIO Config (Optional)
########################

i2c_write 0x00 0x21 0xA0 # GPIO1 as input (can be used for MCLK detection) A0

########################
# Input/Output Channel Enable
########################

i2c_write 0x00 0x73 0xC0 # Enable input channels 1–4
i2c_write 0x00 0x74 0xC0 # Enable ASI output channels 1–4


# added as additional internal PPL config
i2c_write 0x00 0x1A 0x00
i2c_write 0x00 0x1B 0x00
#i2c_write 0x00 0x1D 0x00
#i2c_write 0x00 0x1C 0x00

# added as additional N Divider Disabled
i2c_write 0x00 0x1E 0x00


# added as additional M Divider Disabled
i2c_write 0x00 0x1F 0x00

# added as additional BCLK/FSYNC dividers
i2c_write 0x00 0x17 0x00
i2c_write 0x00 0x18 0x00
i2c_write 0x00 0x19 0x00

# added as additional PDM Configuration
#i2c_write 0x00 0x1F 0x40
#i2c_write 0x00 0x20 0x00

# added as additional clock error disable/enable
#i2c_write 0x00 0x04 0x40

# added as additional GPO config
#i2c_write 0x00 0x22 0x00
#i2c_write 0x00 0x23 0x00
#i2c_write 0x00 0x24 0x00
#i2c_write 0x00 0x25 0x00
#i2c_write 0x00 0x29 0x00

# added as additional GPI Configuration
#i2c_write 0x00 0x2B 0x00
#i2c_write 0x00 0x2C 0x00
#i2c_write 0x00 0x32 0x00
#i2c_write 0x00 0x33 0xFF
#i2c_write 0x00 0x3B 0x60

#DSP configuration
#i2c_write 0x00 0x6B 0x01
#i2c_write 0x00 0x6C 0x48

# DRE configuration
#i2c_write 0x00 0x6D 0x7B
# AGC Configuration
#i2c_write 0x00 0x70 0xE7


########################
# Final Power-Up
########################

i2c_write 0x00 0x00 0x00 # Select page 0
i2c_write 0x00 0x75 0xC0 # Power up MICBIAS, PLL, all ADCs

# added as additional N Divider Disabled
#i2c_write 0x00 0x1E 0x82
# added as additional M Divider Disabled
#i2c_write 0x00 0x1F 0xC0

echo "TLV320ADC5140 configuration complete."

here is registry dump file 1) after scritp apply, during arecord command, after stop recording. Some registry changing value. For example reg 75 changing value  C0---60---00

root@pi:/home/pi/ad9850# sudo i2cdump -y -f 1 0x4c
No size specified (using byte-data access)
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
00: 00 00 81 00 00 05 00 00 00 00 00 00 01 02 03 04 ..?..?......????
10: 05 06 07 81 42 ff 10 00 00 00 00 00 00 00 00 00 ????B.?.........
20: 00 a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .?..............
30: 00 00 00 00 00 00 80 00 80 00 00 02 21 a8 c9 00 ......?.?..?!??.
40: 00 21 a8 c9 00 00 21 a8 c9 00 00 21 a8 c9 00 00 .!??..!??..!??..
50: 00 00 c9 80 00 00 00 c9 80 00 00 00 c9 80 00 00 ..??...??...??..
60: 00 c9 80 00 00 00 00 00 00 00 00 01 08 7b 00 00 .??........??{..
70: 00 00 00 c0 c0 c0 00 c0 00 00 ff 00 ff 8c 8c 00 ...???.?.....??.
80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
root@pi:/home/pi/ad9850# sudo i2cdump -y -f 1 0x4c
No size specified (using byte-data access)
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
00: 00 00 81 00 00 05 00 04 00 00 00 00 01 02 03 04 ..?..?.?....????
10: 05 06 07 81 42 42 10 00 00 00 00 00 00 00 00 00 ????BB?.........
20: 00 a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .?..............
30: 00 00 00 00 00 00 40 00 40 00 00 02 21 a8 c9 00 ......@.@..?!??.
40: 00 21 a8 c9 00 00 21 a8 c9 00 00 21 a8 c9 00 00 .!??..!??..!??..
50: 00 00 c9 80 00 00 00 c9 80 00 00 00 c9 80 00 00 ..??...??...??..
60: 00 c9 80 00 00 00 00 00 00 00 00 01 08 7b 00 00 .??........??{..
70: 00 00 00 f0 c0 60 f0 e0 00 00 ff 00 ff 8c a6 00 ...??`??.....??.
80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................

arecord -D hw:2,0 -f S16_LE -r 48000 -c 2 mastertest2ch_master_16_48.wav


root@pi:/home/pi/ad9850# sudo i2cdump -y -f 1 0x4c
No size specified (using byte-data access)
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
00: 00 00 81 00 00 05 00 04 00 00 00 00 01 02 03 04 ..?..?.?....????
10: 05 06 07 81 42 f2 10 00 00 00 00 00 00 00 00 00 ????B??.........
20: 00 a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .?..............
30: 00 00 00 00 00 00 80 00 80 00 00 02 21 a8 c9 00 ......?.?..?!??.
40: 00 21 a8 c9 00 00 21 a8 c9 00 00 21 a8 c9 00 00 .!??..!??..!??..
50: 00 00 c9 80 00 00 00 c9 80 00 00 00 c9 80 00 00 ..??...??...??..
60: 00 c9 80 00 00 00 00 00 00 00 00 01 08 7b 00 00 .??........??{..
70: 00 00 00 00 c0 00 00 c0 00 00 ff 00 ff 8c 8b 00 ....?..?.....??.
80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................

Please help me whit dts/registry configuration for recording 2 and 4 channels

Thank you for help.

  • Hi,

    One of the things to look out for in the dts file when using more than 1 channel is your dai-tdm-slot-num, which you have set to 2 in the dts file you posted so it should work for 2 channels. What do your clocks look like? Are you giving the ADC BCLK and WCLK, or providing it just MCLK? What frequencies are these clocks? Also, can you check your asound.state file (you can generate one by running "alsactl --file ~/.config/asound.state store")?

    Best,
    Mir

  • Hi. 

    still one channel(

    MLCK is configured on AD9850 for 12.288 and connected to GPIO1  i2c_write 0x00 0x21 0xA0.  BCLK and WCLK  generated from codec. BCLK 1.536 (2ch*16*48000) or 3.072(4ch*16*48000).  WCLK 48 kHz. BCLK  and WCLK  from codec looking good and clean.  BCLK  and WCLK generation started from codec  after applying arecord commands and disappeared  after stop of arecord. 

    here is asound.state. i do not know but alsactl --file ~/.config/asound.state store do not make file in this dir. i made it in temp

     i 

    root@pi:/tmp# cat asound.state
    state.vc4hdmi0 {
            control.1 {
                    iface CARD
                    name 'HDMI Jack'
                    value false
                    comment {
                            access read
                            type BOOLEAN
                            count 1
                    }
            }
            control.2 {
                    iface PCM
                    name 'Playback Channel Map'
                    value.0 0
                    value.1 0
                    value.2 0
                    value.3 0
                    value.4 0
                    value.5 0
                    value.6 0
                    value.7 0
                    comment {
                            access 'read volatile'
                            type INTEGER
                            count 8
                            range '0 - 36'
                    }
            }
            control.3 {
                    iface PCM
                    name 'IEC958 Playback Mask'
                    value ffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
                    comment {
                            access read
                            type IEC958
                            count 1
                    }
            }
            control.4 {
                    iface PCM
                    name 'IEC958 Playback Default'
                    value '0400000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
                    comment {
                            access 'read write'
                            type IEC958
                            count 1
                    }
            }
            control.5 {
                    iface PCM
                    name ELD
                    value '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
                    comment {
                            access 'read volatile'
                            type BYTES
                            count 128
                    }
            }
    }
    state.vc4hdmi1 {
            control.1 {
                    iface CARD
                    name 'HDMI Jack'
                    value false
                    comment {
                            access read
                            type BOOLEAN
                            count 1
                    }
            }
            control.2 {
                    iface PCM
                    name 'Playback Channel Map'
                    value.0 0
                    value.1 0
                    value.2 0
                    value.3 0
                    value.4 0
                    value.5 0
                    value.6 0
                    value.7 0
                    comment {
                            access 'read volatile'
                            type INTEGER
                            count 8
                            range '0 - 36'
                    }
            }
            control.3 {
                    iface PCM
                    name 'IEC958 Playback Mask'
                    value ffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
                    comment {
                            access read
                            type IEC958
                            count 1
                    }
            }
            control.4 {
                    iface PCM
                    name 'IEC958 Playback Default'
                    value '0400000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
                    comment {
                            access 'read write'
                            type IEC958
                            count 1
                    }
            }
            control.5 {
                    iface PCM
                    name ELD
                    value '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
                    comment {
                            access 'read volatile'
                            type BYTES
                            count 128
                    }
            }
    }
    state.TLV320ADC5140 {
            control.1 {
                    iface MIXER
                    name 'Analog CH1 Mic Gain Volume'
                    value 42
                    comment {
                            access 'read write'
                            type INTEGER
                            count 1
                            range '0 - 42'
                            dbmin 0
                            dbmax 4200
                            dbvalue.0 4200
                    }
            }
            control.2 {
                    iface MIXER
                    name 'Analog CH2 Mic Gain Volume'
                    value 42
                    comment {
                            access 'read write'
                            type INTEGER
                            count 1
                            range '0 - 42'
                            dbmin 0
                            dbmax 4200
                            dbvalue.0 4200
                    }
            }
            control.3 {
                    iface MIXER
                    name 'Analog CH3 Mic Gain Volume'
                    value 42
                    comment {
                            access 'read write'
                            type INTEGER
                            count 1
                            range '0 - 42'
                            dbmin 0
                            dbmax 4200
                            dbvalue.0 4200
                    }
            }
            control.4 {
                    iface MIXER
                    name 'Analog CH4 Mic Gain Volume'
                    value 42
                    comment {
                            access 'read write'
                            type INTEGER
                            count 1
                            range '0 - 42'
                            dbmin 0
                            dbmax 4200
                            dbvalue.0 4200
                    }
            }
            control.5 {
                    iface MIXER
                    name 'DRE Threshold'
                    value 0
                    comment {
                            access 'read write'
                            type INTEGER
                            count 1
                            range '0 - 9'
                            dbmin -6600
                            dbmax -5700
                            dbvalue.0 -6600
                    }
            }
            control.6 {
                    iface MIXER
                    name 'DRE Max Gain'
                    value 0
                    comment {
                            access 'read write'
                            type INTEGER
                            count 1
                            range '0 - 12'
                            dbmin 200
                            dbmax 2600
                            dbvalue.0 200
                    }
            }
            control.7 {
                    iface MIXER
                    name 'AGC Threshold'
                    value 6
                    comment {
                            access 'read write'
                            type INTEGER
                            count 1
                            range '0 - 15'
                            dbmin -3600
                            dbmax -600
                            dbvalue.0 -2400
                    }
            }
            control.8 {
                    iface MIXER
                    name 'AGC Max Gain'
                    value 5
                    comment {
                            access 'read write'
                            type INTEGER
                            count 1
                            range '0 - 13'
                            dbmin 300
                            dbmax 4200
                            dbvalue.0 1800
                    }
            }
            control.9 {
                    iface MIXER
                    name 'Digital CH1 Out Volume'
                    value 0
                    comment {
                            access 'read write'
                            type INTEGER
                            count 1
                            range '0 - 255'
                            dbmin -10050
                            dbmax 2700
                            dbvalue.0 -10050
                    }
            }
            control.10 {
                    iface MIXER
                    name 'Digital CH2 Out Volume'
                    value 0
                    comment {
                            access 'read write'
                            type INTEGER
                            count 1
                            range '0 - 255'
                            dbmin -10050
                            dbmax 2700
                            dbvalue.0 -10050
                    }
            }
            control.11 {
                    iface MIXER
                    name 'Digital CH3 Out Volume'
                    value 0
                    comment {
                            access 'read write'
                            type INTEGER
                            count 1
                            range '0 - 255'
                            dbmin -10050
                            dbmax 2700
                            dbvalue.0 -10050
                    }
            }
            control.12 {
                    iface MIXER
                    name 'Digital CH4 Out Volume'
                    value 28
                    comment {
                            access 'read write'
                            type INTEGER
                            count 1
                            range '0 - 255'
                            dbmin -10050
                            dbmax 2700
                            dbvalue.0 -8650
                    }
            }
            control.13 {
                    iface MIXER
                    name 'Digital CH5 Out Volume'
                    value 0
                    comment {
                            access 'read write'
                            type INTEGER
                            count 1
                            range '0 - 255'
                            dbmin -10050
                            dbmax 2700
                            dbvalue.0 -10050
                    }
            }
            control.14 {
                    iface MIXER
                    name 'Digital CH6 Out Volume'
                    value 0
                    comment {
                            access 'read write'
                            type INTEGER
                            count 1
                            range '0 - 255'
                            dbmin -10050
                            dbmax 2700
                            dbvalue.0 -10050
                    }
            }
            control.15 {
                    iface MIXER
                    name 'Digital CH7 Out Volume'
                    value 0
                    comment {
                            access 'read write'
                            type INTEGER
                            count 1
                            range '0 - 255'
                            dbmin -10050
                            dbmax 2700
                            dbvalue.0 -10050
                    }
            }
            control.16 {
                    iface MIXER
                    name 'Digital CH8 Out Volume'
                    value 0
                    comment {
                            access 'read write'
                            type INTEGER
                            count 1
                            range '0 - 255'
                            dbmin -10050
                            dbmax 2700
                            dbvalue.0 -10050
                    }
            }
            control.17 {
                    iface MIXER
                    name 'Phase Calibration Switch'
                    value false
                    comment {
                            access 'read write'
                            type BOOLEAN
                            count 1
                    }
            }
            control.18 {
                    iface MIXER
                    name 'MIC1P Input Mux'
                    value Analog
                    comment {
                            access 'read write'
                            type ENUMERATED
                            count 1
                            item.0 Analog
                            item.1 'Line In'
                            item.2 Digital
                    }
            }
            control.19 {
                    iface MIXER
                    name 'MIC2P Input Mux'
                    value Analog
                    comment {
                            access 'read write'
                            type ENUMERATED
                            count 1
                            item.0 Analog
                            item.1 'Line In'
                            item.2 Digital
                    }
            }
            control.20 {
                    iface MIXER
                    name 'MIC3P Input Mux'
                    value Analog
                    comment {
                            access 'read write'
                            type ENUMERATED
                            count 1
                            item.0 Analog
                            item.1 'Line In'
                            item.2 Digital
                    }
            }
            control.21 {
                    iface MIXER
                    name 'MIC4P Input Mux'
                    value Analog
                    comment {
                            access 'read write'
                            type ENUMERATED
                            count 1
                            item.0 Analog
                            item.1 'Line In'
                            item.2 Digital
                    }
            }
            control.22 {
                    iface MIXER
                    name 'MIC1 Analog Mux'
                    value Analog
                    comment {
                            access 'read write'
                            type ENUMERATED
                            count 1
                            item.0 Analog
                            item.1 'Line In'
                    }
            }
            control.23 {
                    iface MIXER
                    name 'MIC2 Analog Mux'
                    value Analog
                    comment {
                            access 'read write'
                            type ENUMERATED
                            count 1
                            item.0 Analog
                            item.1 'Line In'
                    }
            }
            control.24 {
                    iface MIXER
                    name 'MIC3 Analog Mux'
                    value Analog
                    comment {
                            access 'read write'
                            type ENUMERATED
                            count 1
                            item.0 Analog
                            item.1 'Line In'
                    }
            }
            control.25 {
                    iface MIXER
                    name 'MIC4 Analog Mux'
                    value Analog
                    comment {
                            access 'read write'
                            type ENUMERATED
                            count 1
                            item.0 Analog
                            item.1 'Line In'
                    }
            }
            control.26 {
                    iface MIXER
                    name 'MIC1M Input Mux'
                    value Analog
                    comment {
                            access 'read write'
                            type ENUMERATED
                            count 1
                            item.0 Analog
                            item.1 'Line In'
                            item.2 Digital
                    }
            }
            control.27 {
                    iface MIXER
                    name 'MIC2M Input Mux'
                    value Analog
                    comment {
                            access 'read write'
                            type ENUMERATED
                            count 1
                            item.0 Analog
                            item.1 'Line In'
                            item.2 Digital
                    }
            }
            control.28 {
                    iface MIXER
                    name 'MIC3M Input Mux'
                    value Analog
                    comment {
                            access 'read write'
                            type ENUMERATED
                            count 1
                            item.0 Analog
                            item.1 'Line In'
                            item.2 Digital
                    }
            }
            control.29 {
                    iface MIXER
                    name 'MIC4M Input Mux'
                    value Analog
                    comment {
                            access 'read write'
                            type ENUMERATED
                            count 1
                            item.0 Analog
                            item.1 'Line In'
                            item.2 Digital
                    }
            }
            control.30 {
                    iface MIXER
                    name 'CH1_ASI_EN Switch'
                    value true
                    comment {
                            access 'read write'
                            type BOOLEAN
                            count 1
                    }
            }
            control.31 {
                    iface MIXER
                    name 'CH2_ASI_EN Switch'
                    value true
                    comment {
                            access 'read write'
                            type BOOLEAN
                            count 1
                    }
            }
            control.32 {
                    iface MIXER
                    name 'CH3_ASI_EN Switch'
                    value true
                    comment {
                            access 'read write'
                            type BOOLEAN
                            count 1
                    }
            }
            control.33 {
                    iface MIXER
                    name 'CH4_ASI_EN Switch'
                    value true
                    comment {
                            access 'read write'
                            type BOOLEAN
                            count 1
                    }
            }
            control.34 {
                    iface MIXER
                    name 'CH5_ASI_EN Switch'
                    value false
                    comment {
                            access 'read write'
                            type BOOLEAN
                            count 1
                    }
            }
            control.35 {
                    iface MIXER
                    name 'CH6_ASI_EN Switch'
                    value false
                    comment {
                            access 'read write'
                            type BOOLEAN
                            count 1
                    }
            }
            control.36 {
                    iface MIXER
                    name 'CH7_ASI_EN Switch'
                    value false
                    comment {
                            access 'read write'
                            type BOOLEAN
                            count 1
                    }
            }
            control.37 {
                    iface MIXER
                    name 'CH8_ASI_EN Switch'
                    value false
                    comment {
                            access 'read write'
                            type BOOLEAN
                            count 1
                    }
            }
            control.38 {
                    iface MIXER
                    name 'DRE_ENABLE Switch'
                    value false
                    comment {
                            access 'read write'
                            type BOOLEAN
                            count 1
                    }
            }
            control.39 {
                    iface MIXER
                    name 'CH1_DRE_EN Switch'
                    value false
                    comment {
                            access 'read write'
                            type BOOLEAN
                            count 1
                    }
            }
            control.40 {
                    iface MIXER
                    name 'CH2_DRE_EN Switch'
                    value false
                    comment {
                            access 'read write'
                            type BOOLEAN
                            count 1
                    }
            }
            control.41 {
                    iface MIXER
                    name 'CH3_DRE_EN Switch'
                    value false
                    comment {
                            access 'read write'
                            type BOOLEAN
                            count 1
                    }
            }
            control.42 {
                    iface MIXER
                    name 'CH4_DRE_EN Switch'
                    value false
                    comment {
                            access 'read write'
                            type BOOLEAN
                            count 1
                    }
            }
            control.43 {
                    iface MIXER
                    name 'IN1 Analog Mic Resistor'
                    value '2.5 kOhm'
                    comment {
                            access 'read write'
                            type ENUMERATED
                            count 1
                            item.0 '2.5 kOhm'
                            item.1 '10 kOhm'
                            item.2 '20 kOhm'
                    }
            }
            control.44 {
                    iface MIXER
                    name 'IN2 Analog Mic Resistor'
                    value '2.5 kOhm'
                    comment {
                            access 'read write'
                            type ENUMERATED
                            count 1
                            item.0 '2.5 kOhm'
                            item.1 '10 kOhm'
                            item.2 '20 kOhm'
                    }
            }
            control.45 {
                    iface MIXER
                    name 'IN3 Analog Mic Resistor'
                    value '2.5 kOhm'
                    comment {
                            access 'read write'
                            type ENUMERATED
                            count 1
                            item.0 '2.5 kOhm'
                            item.1 '10 kOhm'
                            item.2 '20 kOhm'
                    }
            }
            control.46 {
                    iface MIXER
                    name 'IN4 Analog Mic Resistor'
                    value '2.5 kOhm'
                    comment {
                            access 'read write'
                            type ENUMERATED
                            count 1
                            item.0 '2.5 kOhm'
                            item.1 '10 kOhm'
                            item.2 '20 kOhm'
                    }
            }
            control.47 {
                    iface MIXER
                    name 'PDM Clk Div Select'
                    value '2.8224 MHz'
                    comment {
                            access 'read write'
                            type ENUMERATED
                            count 1
                            item.0 '2.8224 MHz'
                            item.1 '1.4112 MHz'
                            item.2 '705.6 kHz'
                            item.3 '5.6448 MHz'
                    }
            }
            control.48 {
                    iface MIXER
                    name 'Decimation Filter'
                    value 'Linear Phase'
                    comment {
                            access 'read write'
                            type ENUMERATED
                            count 1
                            item.0 'Linear Phase'
                            item.1 'Low Latency'
                            item.2 'Ultra-low Latency'
                    }
            }
    }

  • Hi.

    Some update. Somehow i switched on second channel

    i save config for all files for this case. if there is need i can show changes

  • Hi,

    Yes what changes did you make? Is this 2 channels simultaneously? Are you able to use 4 channels yet?

    -Mir

  • i lost this config(. what is done is total  working config  for RP4 for 2channels. i will try to move this config to rp5,

    /dts-v1/;
    /plugin/;
    
    / {
        compatible = "brcm,bcm2712", "brcm,bcm2711", "brcm,bcm2835";
        // compatible = "brcm,bcm2835";
    
        fragment@0 {
            target = <&i2s_clk_consumer>;
            __overlay__ {
                status = "okay";
                #sound-dai-cells = <0>;
                brcm,tx-channels = <4>;
                brcm,rx-channels = <4>;
            };
        };
    
    
        fragment@1 {
            target = <&i2c1>;
            __overlay__ {
                #address-cells = <1>; /* Single cell for I2C address */
                #size-cells = <0>;    /* No size cells for I2C devices */
                status = "okay";
    
                tlv320adc5140: tlv320adc5140@4c {
                    compatible = "ti,tlv320adc5140";
                    reg = <0x4C>;
                    #sound-dai-cells = <0>;
                    status = "okay";
    
                    clocks = <&mclk_external>;
                    clock-names = "mclk";
                    mclk-frequency = <12288000>;
    
                    // Debug properties (must precede subnodes)
                    debug;
                    linux,debug;
    
                };
            };
        };
    
        fragment@2 {
            target = <&sound>;
            __overlay__ {
                compatible = "simple-audio-card";
                i2s-controller = <&i2s_clk_consumer>;
                simple-audio-card,name = "TLV320ADC5140";
                //simple-audio-card,format = "i2s";
                simple-audio-card,format = "dsp_a";
                simple-audio-card,convert-rate = <48000>;
                simple-audio-card,mclk-fs = <256>;
    
                simple-audio-card,bitclock-master = <&snd_codec>;
                simple-audio-card,frame-master = <&snd_codec>;
                status = "okay";
    
                dailink0_master: simple-audio-card,cpu {
                    sound-dai = <&i2s_clk_consumer>;
                    dai-tdm-slot-num = <2>;
                    dai-tdm-slot-width = <32>;
                };
    
                snd_codec: simple-audio-card,codec {
                    sound-dai = <&tlv320adc5140>;
                    clocks = <&mclk_external>;
                    system-clock-direction-out = "out";
                    system-clock-frequency = <12288000>; //*** added LAX
                    mclk-fs = <256>; //*** added LAX
                };
            };
        };
    
        fragment@3 {
            target-path = "/";
            __overlay__ {
                mclk_external: mclk_external {
                    compatible = "fixed-clock";
                    #clock-cells = <0>;
                    clock-frequency = <12288000>; // 12.288 MHz
                    clock-output-names = "mclk";
                };
            };
        };
    };

    #!/bin/bash

    # TLV320ADC5140 Master Mode Initialization Script

    ADDR=0x4C
    BUS=1
    OPTS="-y -f $BUS $ADDR"

    # Function to write a register value on a specific page
    i2c_write() {
    PAGE=$1
    REG=$2
    VAL=$3
    sudo i2cset $OPTS 0x00 $PAGE # Set page
    sudo i2cset $OPTS $REG $VAL # Write value
    }

    echo "Configuring TLV320ADC5140 on I2C bus $BUS..."

    ########################
    # Reset & Wake
    ########################

    i2c_write 0x00 0x01 0x01 # Reset
    sleep 1
    i2c_write 0x00 0x02 0x81 # Enable adaptive filter + wake
    i2c_write 0x00 0x05 0x05 # Enable all analog blocks

    ########################
    # Channel Configs (1–4)
    ########################


    # Channel 1 configuration
    i2c_write 0x00 0x3C 0x21 # 0d = Microphone input
    i2c_write 0x00 0x3D 0x0C # 0d = Channel gain is set to 0 dB A8---42 max
    i2c_write 0x00 0x3E 0xFF # 0d = Digital volume is muted FF
    i2c_write 0x00 0x3F 0x00 # 0d = Gain calibration is set to –0.8 dB
    i2c_write 0x00 0x40 0x00 # 0d = No phase calibration

    # Channel 2 configuration
    i2c_write 0x00 0x41 0x21 # 0d = Microphone input
    i2c_write 0x00 0x42 0x0C # 0d = Channel gain is set to 0 dB
    i2c_write 0x00 0x43 0xFF # 0d = Digital volume is muted FF
    i2c_write 0x00 0x44 0x00 # 0d = Gain calibration is set to –0.8 dB
    i2c_write 0x00 0x45 0x00 # 0d = No phase calibration

    # Channel 3 configuration
    i2c_write 0x00 0x46 0x21 # 0d = Microphone input
    i2c_write 0x00 0x47 0x00 # 0d = Channel gain is set to 0 dB
    i2c_write 0x00 0x48 0xC9 # 0d = Digital volume is muted
    i2c_write 0x00 0x49 0x00 # 0d = Gain calibration is set to –0.8 dB
    i2c_write 0x00 0x4A 0x00 # 0d = No phase calibration

    # Channel 4 configuration
    i2c_write 0x00 0x4B 0x21 # 0d = Microphone input
    i2c_write 0x00 0x4C 0x00 # 0d = Channel gain is set to 0 dB
    i2c_write 0x00 0x4D 0xC9 # 0d = Digital volume is muted
    i2c_write 0x00 0x4E 0x00 # 0d = Gain calibration is set to –0.8 dB
    i2c_write 0x00 0x4F 0x00 # 0d = No phase calibration

    ########################
    # AGC & Input Bias
    ########################

    i2c_write 0x00 0x70 0x00 # AGC: -6 dB target
    i2c_write 0x00 0x6C 0x88 # AGC: Default attack/release
    i2c_write 0x00 0x3B 0x60 # MIC bias = VREF (typ 2.75V) 02 - good

    ########################
    # Clocking (Master Mode, 12.288 MHz MCLK)
    ########################

    #i2c_write 0x00 0x13 0xA0 # BCLK, WCLK master B1 c1 81
    #i2c_write 0x00 0x14 0x42 # 48 kHz, 64 BCLKs per FSYNC 44 58
    #i2c_write 0x00 0x16 0xC8 # PLL mode, MCLK ratio = 256 88 60 10//// C8

    ########################
    # Clocking (Master Mode, 12.288 MHz MCLK)
    ########################

    i2c_write 0x00 0x13 0x81 # BCLK, WCLK master B1 c1 81
    i2c_write 0x00 0x14 0x42 # 48 kHz, 64 BCLKs per FSYNC 44 58
    i2c_write 0x00 0x16 0x10 # PLL mode, MCLK ratio = 256 88 60 10


    ########################
    # GPIO Config (Optional)
    ########################

    i2c_write 0x00 0x33 0xC0 # interrupt masking

    ########################
    # ASI & TDM Configuration
    ########################

    i2c_write 0x00 0x07 0x00 # 0d = TDM mode 0d = 16 bits 40 - i2s 80 -lj mode 07 B0 30-ok
    i2c_write 0x00 0x08 0x00
    i2c_write 0x00 0x09 0x00

    # Channel mapping: CH1–CH4 to slots 0–3
    i2c_write 0x00 0x0B 0x00
    i2c_write 0x00 0x0C 0x01
    i2c_write 0x00 0x0D 0x02
    i2c_write 0x00 0x0E 0x03

    ########################
    # GPIO Config (Optional)
    ########################

    i2c_write 0x00 0x21 0xA0 # GPIO1 as input (can be used for MCLK detection) A0

    ########################
    # Input/Output Channel Enable
    ########################

    i2c_write 0x00 0x73 0xC0 # Enable input channels 1–4
    i2c_write 0x00 0x74 0xC0 # Enable ASI output channels 1–4


    # added as additional internal PPL config
    i2c_write 0x00 0x1A 0x00
    i2c_write 0x00 0x1B 0x00
    #i2c_write 0x00 0x1D 0x00
    #i2c_write 0x00 0x1C 0x00

    # added as additional N Divider Disabled
    i2c_write 0x00 0x1E 0x00


    # added as additional M Divider Disabled
    i2c_write 0x00 0x1F 0x00

    # added as additional BCLK/FSYNC dividers
    i2c_write 0x00 0x17 0x00
    i2c_write 0x00 0x18 0x00
    i2c_write 0x00 0x19 0x00


    ########################
    # Final Power-Up
    ########################

    i2c_write 0x00 0x00 0x00 # Select page 0
    i2c_write 0x00 0x75 0xC0 # Power up MICBIAS, PLL, all ADCs

    echo "TLV320ADC5140 configuration complete."

  • Ok, let me know if you need more help here.

    -Mir

  • hi Mir

    sure

    We need help. on RP5 we got only one ch working out of 2. and i need 4 channels

  • Man. look, wm8960 is perfectly working on rp5   

    there is initially was also problem with kernel/ i took this repo from this branch and it start to work 

    https://github.com/waveshareteam/WM8960-Audio-HAT/issues/68 

    looking here for 2/4 dts, asound.cofig, asound.state

  • Hi Valerii,

    Mir is out of office today. He will follow up with you tomorrow.

    Thanks for your patience,
    Jeff McPherson

  • hi Man.  here we got again that second channel switched on.  i saved config.

    dts was muted

    //simple-audio-card,convert-rate = <48000>;
    //simple-audio-card,mclk-fs = <256>;

    reg 

    i2c_write 0x00 0x13 0x81 # BCLK, WCLK master B1 c1 81
    i2c_write 0x00 0x14 0x42 # 48 kHz, 64 BCLKs per FSYNC 44 58
    i2c_write 0x00 0x16 0xCC # PLL mode, MCLK ratio = 256 88 60 10


    ########################
    # GPIO Config (Optional)
    ########################

    i2c_write 0x00 0x33 0xC0 # interrupt masking

    ########################
    # ASI & TDM Configuration
    ########################

    i2c_write 0x00 0x07 0x30 # 0d = TDM mode 0d = 16 bits 40 - i2s 80 -lj mode 07 - i2s32 B0 30-ok
    i2c_write 0x00 0x08 0x00
    i2c_write 0x00 0x09 0x00

  • Hi,

    I think you may have more luck asking on the RPI forums about how to enable more than 1 channel on the software side. From my end, I would check what the clocks coming in/out of the device are, and check on a scope if you are seeing stereo I2S data or just 0s on the second channel. Let me know what you find there, and maybe mention what you find in the RPI forums if you go there.

    Best,
    Mir

  • Hi Man. Sure i will ask them. can i ask you for a favor? can you configure me 2 cfg files for 2 and 4 channels? Codec master 16 bit, 48kHz, 12.288 Mhz MLCK, AGC on, bias ti on, single ended.

  • Hi,

    I can give you I2C config for this, but I can't make a RPI config if that is what you are looking for. Here is an I2C config that should apply these settings:

    w 98 73 f0 #4 channels enabled - to do 2, set to c0
    w 98 74 f0 #4 channels enabled on the ASI out - to do 2, set to c0
    w 98 6c 48 #agc enabled, default parameter values (will need to configure manually)
    w 98 3c a1 #power up agc ch1, single ended, line input
    w 98 41 a1 #agc ch2, single ended, line input
    w 98 46 a1 #agc ch3, single ended, line input
    w 98 4b a1 #agc ch4, single ended, line input
    
    w 98 07 00 #16 bit tdm
    w 98 13 81 #master mode (controller mode) with MCLK=12.288MHz, 48k fs
    
    w 98 75 c0 #mic bias powered up = avdd, power up all enabled adc channels
    

    Let me know if you are having problems with this.

    Best,
    Mir

  • Hi,

    In the following link you can find a stereo audio recorder for RPI5 made with the ADC TLV320ADC6140

    https://github.com/Mariano-Esteban/Ensor-384kHz-32bit/