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.

TLV320AIC3100: CLOCK Frequency issue

Part Number: TLV320AIC3100
Other Parts Discussed in Thread: TLV320AIC3104

HI Team 

We are using tlv320aic3100 Internal codec.

facing issue related to MCLK.

Changes:

sound-tlv320aic31xx {
compatible = "simple-audio-card";
simple-audio-card,name = "tlv320aic31xx-Codec";
simple-audio-card,format = "i2s";
simple-audio-card,frame-master = <&cpudai2>;
simple-audio-card,bitclock-master = <&cpudai2>;

simple-audio-card,widgets =
"Speaker", "Speaker Jack";
simple-audio-card,routing =
"Speaker Jack", "SPK";

cpudai2: simple-audio-card,cpu {
sound-dai = <&sai1>;
};

simple-audio-card,codec {
sound-dai = <&tlv320aic31xx>;
clocks = <&clk IMX8MM_CLK_SAI1_ROOT>;
};
};

tlv320aic31xx: codec@18 {
compatible = "ti,tlv320aic3100";
reg = <0x18>;
pinctrl-0 = <&pinctrl_audio_reset_31xx>;
reset-gpios = <&gpio4 1 GPIO_ACTIVE_LOW>;
#sound-dai-cells = <0>;
ai31xx-micbias-vg = <MICBIAS_2_0V>;
HPVDD-supply = <&reg_3p3v>;
SPRVDD-supply = <&reg_3p3v>;
SPLVDD-supply = <&reg_3p3v>;
AVDD-supply = <&reg_3p3v>;
IOVDD-supply = <&reg_3p3v>;
DVDD-supply = <&reg_1p8v>;
};

&sai1 {
pinctrl-names = "default", "dsd";
pinctrl-0 = <&pinctrl_sai1>;
pinctrl-1 = <&pinctrl_sai1_dsd>;
assigned-clocks = <&clk IMX8MM_CLK_SAI1>;
assigned-clock-parents = <&clk IMX8MM_AUDIO_PLL1_OUT>;
assigned-clock-rates = <12500000>;
status = "okay";
};

pinctrl_sai1: sai1grp {
fsl,pins = <
MX8MM_IOMUXC_SAI1_MCLK_SAI1_MCLK 0xd6 /*MCLK*/
MX8MM_IOMUXC_SAI1_TXFS_SAI1_TX_SYNC 0xd6 /*WCLK*/
MX8MM_IOMUXC_SAI1_TXC_SAI1_TX_BCLK 0xd6 /*BCLK*/
MX8MM_IOMUXC_SAI1_TXD0_SAI1_TX_DATA0 0xd6 /*DIN*/
MX8MM_IOMUXC_SAI1_RXD0_SAI1_RX_DATA0 0xd6 /*DOUT*/
>;
};

LOGS:

Line 406: 04-18 19:45:59.438 0 0 E tlv320aic31xx-codec 1-0018: aic31xx_set_dai_sysclk: Unsupported frequency 24576000
Line 407: 04-18 19:45:59.447 0 0 E tlv320aic31xx-codec 1-0018: ASoC: error at snd_soc_dai_set_sysclk on tlv320aic31xx-hifi: -22
Line 407: 04-18 19:45:59.447 0 0 E tlv320aic31xx-codec 1-0018: ASoC: error at snd_soc_dai_set_sysclk on tlv320aic31xx-hifi: -22
Line 408: 04-18 19:45:59.456 0 0 E tlv320aic31xx-codec 1-0018: simple-card: set_sysclk error
Line 409: 04-18 19:45:59.462 0 0 E 30010000.sai-tlv320aic31xx-hifi: ASoC: error at snd_soc_link_init on 30010000.sai-tlv320aic31xx-hifi: -22
Line 409: 04-18 19:45:59.462 0 0 E 30010000.sai-tlv320aic31xx-hifi: ASoC: error at snd_soc_link_init on 30010000.sai-tlv320aic31xx-hifi: -22
Line 410: 04-18 19:45:59.473 0 0 W asoc-simple-card: probe of sound-tlv320aic31xx failed with error -22

Thanks

Divyesh.

  • Share your amixer commands and register dump during playback. Thanks.

  • Hi shen,

    dump when not playing audio:

    Sound controls : 

    tinymix 1 1

    tinymix 4 1

    tinymix 5 2

    tinymix 6 10

    tinymix 22 1

    tinymix 25 1

    tinymix 27 1

    These controls should be controlled by audio driver right?

    Looks like not even single control is controlled by driver .

    Shen, need your promt support to resolve this issue. 

  • tinymix command should be called by audio framework, for example, in Android system, audio routing is created by audio abstract layer.

    APIs as following

    mixer = mixer_open(CARD);
    if (!mixer) {
    ret = -1;
    goto EXIT;
    }

    //Step3: Set the environment for audio playback on TAS256X and start GREG Check
    mixer_ctrl_new = mixer_get_ctl_by_name(mixer, "TAS256x Profile id");
    if (!mixer_ctrl_new) {
    v_printf(1, "TI-SmartPA: %s: Could not get ctl for mixer cmd: TAS256x Profile id",
    __func__);
    ret = -1;
    goto EXIT;
    } else {
    ret = mixer_ctl_set_value(mixer_ctrl_new, 0, 0);
    if (ret) {
    v_printf(1, "Error running mixer command TAS256x Profile id = %d\n", ret);
    goto EXIT;
    }
    }

    ret = mixer_ctl_set_enum_by_string(mixer_ctrl_new, enum_val);

    if(mixer) mixer_close(mixer);

  • Understood shen.

    To enable these sound control, I have added one json file.

    Filename: common/audio-json/tlv320aic31xx_config.json

    {
    "driver_name": "tlv320aic31xx-Codec",
    "supported_out_devices": ["speaker"],
    "support_lpa": 1,

    "init_ctl": [
    {"name": "DAC Playback Volume", "type": "int", "val": 100},
    {"name": "ADC Capture Switch", "type": "int", "val": 1},
    {"name": "Speaker Driver Playback Switch", "type": "int", "val": 1},
    {"name": "Speaker Driver Playback Volume", "type": "int", "val": 2},
    {"name": "Speaker Analog Playback Volume", "type": "int", "val": 100},
    {"name": "Output Left From Left DAC", "type": "int", "val": 1},
    {"name": "Output Right From Right DAC", "type": "int", "val": 1},
    {"name": "Speaker Switch", "type": "int", "val": 1}
    ],

    "out_volume_min": 172,
    "out_volume_max": 225,
    "out_volume_ctl": [
    "DAC Playback Volume"
    ]
    }

    The controls in back bold I have added today only. Could you please verify once the changes?

    NOTE: refer this Source of readme.txt - device-fsl - PHYTEC BitBucket (Stash)

  • Hi Shen,

    Yes these changes are working.

    I can play audio file without any command.

    But noise is there.

    Need your help to fix noise issues.

    Please check logcat:

    5707.logcat.txt

    I2Cdump without playing audio:

    PAGE 0-

    Page 0 -

    While playing audio:

    Page 0 -

    page 1 -

      

    Measured clocks : MCLK = 12.28 MHz, BCLK = 1.536  MHz, WCLK = 47.99 KHz

    changes in driver file : 

    LOGS:

    tlv pll 8.0000/1 dosr 32 n 1 m 8 aosr 32 n 1 m 8 bclk_n 8

    OUTPUT:

    AUDIO + NOISE

  • Divyesh,

    Sorry for the delay. Jeff has been driving this, but has been out of office the past week and will return tomorrow.

    Brian

  • Hi brian and Jeff,

    Response from the NXP vendor - 

    "if the clocks output from i.mx are correct, there is no reason for data corrupt. So I would like you to double confirm with the codec vendor about 12.288Mhz mclk support." 

    Could you please share your thought on above comment ?

  • Yes, 12.288MHz MCLK is supported as long as it's synchronous and an integer multiple of the other clocks (BCLK, LRCLK)

  • to support 12.228MHz.. What are the changes need to be done.

    I have done only below changes , apart from these, Do I need to make any changes.:

    +++ b/sound/soc/codecs/tlv320aic31xx.c
    @@ -197,7 +197,10 @@ struct aic31xx_rate_divs {
    /* 11.025k rate */
    {12000000, 11025, 7, 5264, 128, 32, 2, 128, 32, 2},
    {12000000, 11025, 8, 4672, 128, 24, 3, 128, 24, 3},
    + {12288000, 11025, 8, 0, 32, 1, 32, 32, 1, 32},
    {12500000, 11025, 7, 2253, 128, 32, 2, 128, 32, 2},
    + /* 12k rate */
    + {12288000, 12000, 8, 0, 32, 1, 32, 32, 1, 32},
    /* 16k rate */
    {12000000, 16000, 8, 1920, 128, 24, 2, 128, 24, 2},
    {12000000, 16000, 8, 1920, 128, 16, 3, 128, 16, 3},
    @@ -205,7 +208,10 @@ struct aic31xx_rate_divs {
    /* 22.05k rate */
    {12000000, 22050, 7, 5264, 128, 16, 2, 128, 16, 2},
    {12000000, 22050, 8, 4672, 128, 12, 3, 128, 12, 3},
    + {12288000, 22050, 8, 0, 32, 1, 16, 32, 1, 16},
    {12500000, 22050, 7, 2253, 128, 16, 2, 128, 16, 2},
    + /* 24k rate */
    + {12288000, 24000, 8, 0, 32, 1, 16, 32, 1, 16},
    /* 32k rate */
    {12000000, 32000, 8, 1920, 128, 12, 2, 128, 12, 2},
    {12000000, 32000, 8, 1920, 128, 8, 3, 128, 8, 3},
    @@ -213,10 +219,12 @@ struct aic31xx_rate_divs {
    /* 44.1k rate */
    {12000000, 44100, 7, 5264, 128, 8, 2, 128, 8, 2},
    {12000000, 44100, 8, 4672, 128, 6, 3, 128, 6, 3},
    + {12288000, 44100, 1, 8, 32, 1, 8, 32, 1, 8},
    {12500000, 44100, 7, 2253, 128, 8, 2, 128, 8, 2},
    /* 48k rate */
    {12000000, 48000, 8, 1920, 128, 8, 2, 128, 8, 2},
    {12000000, 48000, 7, 6800, 96, 5, 4, 96, 5, 4},
    + {12288000, 48000, 8, 0, 32, 1, 8, 32, 1, 8},
    {12500000, 48000, 7, 8643, 128, 8, 2, 128, 8, 2},
    /* 88.2k rate */
    {12000000, 88200, 7, 5264, 64, 8, 2, 64, 8, 2},

    With 12.28Mhz Im facing noise issues.

    Please review above commect which is having changes + i2cdump data.

  • ok thanks,

    For now we are getting little bit noise as we increase the volume.

    PFA original and captured audio.

  • Are you able to perform any testing using an audio precision where the I2S data is put in directly to eliminate any possible issue from the host?

    We might be able to setup a EVM here and give a register dump.

  • No Brian, We dont have that setup.

    Yes please, please provide working I2C dump and amixer/tinymix output here.

    Could please brief what are these values in : clk.xlsx . Excel sheet provided by shen before to support 12.288MHz freq

    Are these values causing noise issue? Looks like MCLK is causing an issues.. 

    Thanks

    Divyesh.

  • Hi Team,

    Any update?

    We compared the speaker quality. It looks fine with other audio codec. So we can ignore speaker quality as well.

    If you need any data to solve this issues, please let me know..

    Thanks

    Divyesh.

  • With Below changes noise is reduced:

    +++ b/sound/soc/codecs/tlv320aic31xx.c
    @@ -193,11 +193,15 @@ struct aic31xx_rate_divs {
    /* 8k rate */
    {12000000, 8000, 8, 1920, 128, 48, 2, 128, 48, 2},
    {12000000, 8000, 8, 1920, 128, 32, 3, 128, 32, 3},
    + {12288000, 8000, 8, 1920, 128, 48, 2, 128, 48, 2},
    {12500000, 8000, 7, 8643, 128, 48, 2, 128, 48, 2},
    /* 11.025k rate */
    {12000000, 11025, 7, 5264, 128, 32, 2, 128, 32, 2},
    {12000000, 11025, 8, 4672, 128, 24, 3, 128, 24, 3},
    + {12288000, 11025, 7, 5264, 128, 32, 2, 128, 32, 2},
    {12500000, 11025, 7, 2253, 128, 32, 2, 128, 32, 2},
    + /* 12k rate */
    + {12288000, 12000, 8, 0, 32, 1, 32, 32, 1, 32},
    /* 16k rate */
    {12000000, 16000, 8, 1920, 128, 24, 2, 128, 24, 2},
    {12000000, 16000, 8, 1920, 128, 16, 3, 128, 16, 3},
    @@ -205,7 +209,10 @@ struct aic31xx_rate_divs {
    /* 22.05k rate */
    {12000000, 22050, 7, 5264, 128, 16, 2, 128, 16, 2},
    {12000000, 22050, 8, 4672, 128, 12, 3, 128, 12, 3},
    + {12288000, 22050, 7, 5264, 128, 16, 2, 128, 16, 2},
    {12500000, 22050, 7, 2253, 128, 16, 2, 128, 16, 2},
    + /* 24k rate */
    + {12288000, 24000, 8, 0, 32, 1, 16, 32, 1, 16},
    /* 32k rate */
    {12000000, 32000, 8, 1920, 128, 12, 2, 128, 12, 2},
    {12000000, 32000, 8, 1920, 128, 8, 3, 128, 8, 3},
    @@ -213,10 +220,12 @@ struct aic31xx_rate_divs {
    /* 44.1k rate */
    {12000000, 44100, 7, 5264, 128, 8, 2, 128, 8, 2},
    {12000000, 44100, 8, 4672, 128, 6, 3, 128, 6, 3},
    + {12288000, 44100, 7, 5264, 128, 8, 2, 128, 8, 2},
    {12500000, 44100, 7, 2253, 128, 8, 2, 128, 8, 2},
    /* 48k rate */
    {12000000, 48000, 8, 1920, 128, 8, 2, 128, 8, 2},
    {12000000, 48000, 7, 6800, 96, 5, 4, 96, 5, 4},
    + {12288000, 48000, 8, 1920, 128, 8, 2, 128, 8, 2},
    {12500000, 48000, 7, 8643, 128, 8, 2, 128, 8, 2},
    /* 88.2k rate */
    {12000000, 88200, 7, 5264, 64, 8, 2, 64, 8, 2},
    @@ -225,14 +234,17 @@ struct aic31xx_rate_divs {
    /* 96k rate */
    {12000000, 96000, 8, 1920, 64, 8, 2, 64, 8, 2},
    {12000000, 96000, 7, 6800, 48, 5, 4, 48, 5, 4},
    + {12288000, 96000, 8, 1920, 64, 8, 2, 64, 8, 2},
    {12500000, 96000, 7, 8643, 64, 8, 2, 64, 8, 2},
    /* 176.4k rate */
    {12000000, 176400, 7, 5264, 32, 8, 2, 32, 8, 2},
    {12000000, 176400, 8, 4672, 32, 6, 3, 32, 6, 3},
    + {12288000, 176400, 7, 5264, 32, 8, 2, 32, 8, 2},
    {12500000, 176400, 7, 2253, 32, 8, 2, 32, 8, 2},
    /* 192k rate */
    {12000000, 192000, 8, 1920, 32, 8, 2, 32, 8, 2},
    {12000000, 192000, 7, 6800, 24, 5, 4, 24, 5, 4},
    + {12288000, 192000, 8, 1920, 32, 8, 2, 32, 8, 2},
    {12500000, 192000, 7, 8643, 32, 8, 2, 32, 8, 2},
    };

  • Divyesh,

    Which sample rate are you using from above? When you say noise is reduced then it is OK or still some noise?

    Brian

  • we are using 48Khz.. yes noise is reduced.. looks like no noise anymore.

    But we are facing another issue:

    We are integrating two codecs with IMX8MM in android 11 code base.

    As per the requirement, We have two audio codec in our design

    1)TLV320AIC3104 and 2) TLV320AIC3100 .

    Both the codecs are up and running separately.

    If I integrate two codecs together, I'm getting output from only one TLV320AIC3104 audio codec.

    As per the design, second codec which is TLV320AIC3100 > 0.8W codec is going to use for only ALARM and notification.

    Need your help implement above feature so that imx8mm can support both the codec at a same time. but second should work for only Alarm.

    What are changes need to be done ?

    We have two codecs connected to IMX8MM with 2 different SAI node. We are giving separate SAI interface to both the codec.

    IMX8MM <<---->>> SAI3 & I2C4 <<---->> TLV320AIC3104

    ...

     

    IMX8MM <<---->>> SAI1 & I2C2 <<---->> TLV320AIC3100

    ...

    As per the requirement, Both the codec should work at the same time.

    Thanks

    Divyesh.

  • I'll close this case since the issue is fixed and use the other for the 2 codecs issue.

  • 3100 is not working when I integrate Other codec, why so?

  • You have raised this in the other e2e post. Please use that and not duplicating it.