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.

TLV320AIC3262: Setting audiocodec as master

Part Number: TLV320AIC3262

In order to configure the audiocodec as master we modified the DTS but still no sound is coming after playing sound recorded from arecord command :- arecord -r 16000 test

The is the previous DTS node entries for the 3262 audiocodec device when SOC is master (In this aplay command is able to play sound recorded from arecord command above):-

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
sound0: sound0 {
compatible = "simple-audio-card";
simple-audio-card,name = "BeagleBoard-X15";
simple-audio-card,format = "dsp_b";
simple-audio-card,bitclock-master = <&cpu_dai>;
simple-audio-card,frame-master = <&cpu_dai>;
simple-audio-card,bitclock-inversion;
cpu_dai: simple-audio-card,cpu {
sound-dai = <&mcasp3>;
clocks = <&clkout2_clk>;
system-clock-id = <MCASP_CLK_HCLK_AUXCLK>;
};
sound0_master: simple-audio-card,codec {
sound-dai = <&tlv320aic3262>;
clocks = <&clkout2_clk>;
};
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


This is the modified DTS entry as below:-

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
sound0: sound0 {
compatible = "simple-audio-card";
simple-audio-card,name = "BeagleBoard-X15";
simple-audio-card,format = "dsp_b";
simple-audio-card,bitclock-master = <&sound0_master>;
simple-audio-card,frame-master = <&sound0_master>;
simple-audio-card,bitclock-inversion;
cpu_dai: simple-audio-card,cpu {
sound-dai = <&mcasp3>;
clocks = <&clkout2_clk>;
system-clock-id = <MCASP_CLK_HCLK_AUXCLK>;
};
sound0_master: simple-audio-card,codec {
sound-dai = <&tlv320aic3262>;
clocks = <&clkout2_clk>;
system-clock-frequency=<22579200>;
system-clock-direction-out;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

What else are we missing ?

  • Hi Guy

    Where will you get the aic3262 driver code?

    Would you be so kind and share the run-time log?

    I have a question on you new dts setting: since aic3262 has been already set as master:

    simple-audio-card,bitclock-master = <&sound0_master>;
    simple-audio-card,frame-master = <&sound0_master>;

    Why still clocks and system-clock-id for cpu_dai: simple-audio-card,cpu?

    Hope following links can help you.

    (+) TLV320AIC3262: Configuration of TLV320AIC3262 as Master mode - Audio forum - Audio - TI E2E support forums

    (+) TLV320AIC3262: AIC3262 I2S configuration problem - Audio forum - Audio - TI E2E support forums

  • Hi,

    1. The driver code from github is ported to be used. The source link is, as below:-

    https://github.com/bigbiff/kernel_asus_tf700t/blob/master/sound/soc/codecs/tlv320aic326x.h

    https://github.com/bigbiff/kernel_asus_tf700t/blob/master/sound/soc/codecs/tlv320aic326x.c

    2. The output of dmesg upon inserting the device driver is as below .

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    [ 121.410195] #aic3x_i2c_probe: Entered
    [ 121.414464] #aic3x_i2c_probe: Done ret 0
    [ 121.419382] of_get_named_gpiod_flags: can't parse 'simple-audio-card,hp-det-gpio' property of node '/sound0[0]'
    [ 121.419396] of_get_named_gpiod_flags: can't parse 'simple-audio-card,mic-det-gpio' property of node '/sound0[0]'
    [ 121.419452] #aic3262_probe: Invoked..
    [ 121.423133] #reg_def_conf: Invoked..
    [ 121.457930] #reg_def_conf: Done..
    [ 121.461506] #aic3262_probe: I2C IRQ Configuration is Wrong. Please check it..
    [ 121.469032] #aic3262_asi_default_config: Invoked. Will Config ASI Registers to Defaults..
    [ 121.477374] #aic3262_set_bias_level: Codec Active 0[0]
    [ 121.483177] aic3262_add_controls++
    [ 121.486814] #Completed adding new dapm widget controls size=40
    [ 121.492795] aic3262-codec 3-0018: Control not supported for path IN1L -> [IN1L Route] -> Left ADC
    [ 121.501726] aic3262-codec 3-0018: ASoC: no dapm match for IN1L --> IN1L Route --> Left ADC
    [ 121.510091] aic3262-codec 3-0018: ASoC: Failed to add route IN1L -> IN1L Route -> Left ADC
    [ 121.518617] aic3262-codec 3-0018: Control not supported for path IN2L -> [IN2L Route] -> Left ADC
    [ 121.527604] aic3262-codec 3-0018: ASoC: no dapm match for IN2L --> IN2L Route --> Left ADC
    [ 121.535935] aic3262-codec 3-0018: ASoC: Failed to add route IN2L -> IN2L Route -> Left ADC
    [ 121.544441] aic3262-codec 3-0018: Control not supported for path IN3L -> [IN3L Route] -> Left ADC
    [ 121.553420] aic3262-codec 3-0018: ASoC: no dapm match for IN3L --> IN3L Route --> Left ADC
    [ 121.561780] aic3262-codec 3-0018: ASoC: Failed to add route IN3L -> IN3L Route -> Left ADC
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    3. DTS CHANGES ARE AS MENTIONED IN MY PREV POST. Apart from these, the driver changes, as suggested in our another related query : https://e2e.ti.com/support/audio-group/audio/f/audio-forum/1356927/tlv320aic3262-configure-wclk/5175612#5175612 by  , are also incorporated as below:- 

    diff --git a/sound/soc/codecs/tlv320aic326x.c b/sound/soc/codecs/tlv320aic326x.c
    index 1ca2dd1..3183432 100644
    --- a/sound/soc/codecs/tlv320aic326x.c
    +++ b/sound/soc/codecs/tlv320aic326x.c
    @@ -1235,7 +1235,7 @@ static const struct aic3262_rate_divs aic3262_divs[] = {
    {{0, 60, 1}, {0, 61, 1} } },
    {15000000, 11025, 1, 4, 96, 128, 8, 6, 128, 8, 6, 4,
    {{0, 60, 1}, {0, 61, 1} } },
    - {22579200, 11025, 1, 3, 7632, 128, 4, 4, 128, 4, 4, 4,
    + {22579200, 11025, 1, 6, 5307, 128, 3, 12, 128, 3, 12, 4,
    {{0, 60, 1}, {0, 61, 1} } },
    {11289600, 11025, 1, 3, 7632, 128, 4, 2, 128, 4, 2, 4,
    {{0, 60, 1}, {0, 61, 1} } },
    @@ -1254,7 +1254,8 @@ static const struct aic3262_rate_divs aic3262_divs[] = {
    {10000000, 16000, 1, 4, 96, 128, 8, 6, 128, 8, 6, 4,
    {{0, 60, 1}, {0, 61, 1} } },

    -
    + {22579200, 16000, 1, 6, 5307, 128, 3, 12, 128, 3, 12, 4,
    + {{0, 60, 1}, {0, 61, 1} } },
    {15000000, 16000, 1, 4, 96, 128, 8, 6, 128, 8, 6, 4,
    {{0, 60, 1}, {0, 61, 1} } },

    @@ -2307,6 +2308,8 @@ static int aic3262_multi_i2s_hw_params(struct snd_pcm_substream *substream,

    i = aic3262_get_divs(aic3262->sysclk, params_rate(params));

    i2c_verify_book0(component);

    @@ -2828,7 +2831,10 @@ static const struct aic3262_configs aic3262_reg_init[] = {
    {0, REF_PWR_DLY, 0x01},

    //Clock Initialize
    - {0, DAC_ADC_CLKIN_REG, 0x00}, /*DAC ADC CLKIN*/
    + //{0, DAC_ADC_CLKIN_REG, 0x00}, /*DAC ADC CLKIN*/
    + {0, DAC_ADC_CLKIN_REG, 0x33}, /*DAC ADC CLKIN*/
    + {0, PLL_CKIN_DIV, 0x02}, /*PLL_CLKIN Divider*/
    +

    4. AUDIOCODEC REGISTER SETTING :

    4.1 The following registers were set before recording from the mic.

    #ASI config
    /usr/sbin/i2cset -f -y 3 0x18 0x00 0x04

    /usr/sbin/i2cset -f -y 3 0x18 0x0a 0x24

    4.2 The following registers were set while recording from the mic.

    /usr/sbin/i2cset -f -y 3 0x18 0x00 0x00
    /usr/sbin/i2cset -f -y 3 0x18 0x0c 0x8c
    /usr/sbin/i2cset -f -y 3 0x18 0x00 0x04
    /usr/sbin/i2cset -f -y 3 0x18 0x0c 0x88

    5. CLOCKING VERIFICATION BY OSCILLOSCOPE: -

    After the registers mentioned in 4.1 and 4.2 were set both WCLK and BCLK were probed. Their values came out to be 16Khz and 256Khz 
    respectively. As per our understanding these seem to be ok for recording audio at 16Khz sampling rate using command mentioned in 6:-

     

    6. ARECORD TO VERIFY THE MICROPHONE : command used to record  is:-

    arecord -r 16000 -f S16_LE test16

    Then upon playing the test16 using aplay the playback happens at a lower tempo(speed) than the actual tempo(speed). How can this be resolved?

    The command used to play the recorded file is:-

    aplay -r 16000 -f S16_LE test16

     

    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Why still clocks and system-clock-id for cpu_dai: simple-audio-card,cpu?

    Even after removing these (clocks and system-clock-id) entries from dts, the same behaviour is observed as mentioned in point 6 above.

  • What's the kernel version and kindly dump all the registers.

    Kindly also upload the recorded audio clip here. I will check the bitstream.