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.

Beaglebone Black device tree configuration for PCM3168 and some alsa problems

Other Parts Discussed in Thread: PCM3168

Hi:

I'm trying to build an multichannel audio cape for beaglebone black using PCM3168... Finally i finished studing so i can get more time for this project.

My first question is about device tree; on it i've written:

&mcasp0 {
    pinctrl-names = "default";
    pinctrl-0 = <&mcasp0_pins>;

    status = "okay";

    op-mode = <0>;          /* MCASP_TDM_MODE */
    tdm-slots = <4>;
    num-serializer = <4>;
    serial-dir = <  /* 0: INACTIVE, 1: TX, 2: RX */
    1 1 2 2        
    >;
    tx-num-evt = <1>;
    rx-num-evt = <1>;
};

My intention is to use 4 channels out of each pin of the PCM3168 (left justified TDM mode), so i don't need to use both mcasp in the am335x, and that's why i use tdm-slots = <4>. But when i give the command:

arecord -D hw:0,0 -d 10 -f S24_LE -c 6 -r 96 -t wav test1.wav

i get the error:

Recording WAVE 'test1.wav' : Signed 24 bit Little Endian, Rate 96000 Hz, Channels 6
arecord: set_params:1239: Channels count non available

I supposed that the tdm-slots specified the number of slots per serializer... am i right?

If i use

arecord -D hw:0,0 -d 10 -f S24_LE -c 4 -r 96 -t wav test1.wav

it seems to be recording, indeed it creates the file test1.wav, but i get:

[   32.600895] davinci-mcasp 48038000.mcasp: Sample-rate is off by -348958 PPM
overrun!!! (at least 859.940 ms long)

I located the Sample-rate message in davinci_mcasp_calc_clk_div in davinci-mcasp.c file, but i dont understand that error, nor why i'm getting overrun

Also, if after having "recorded" i try to play the file with aplay or record anotherone with arecord i get messages like this:

ALSA lib pcm_params.c:2162:(snd1_pcm_hw_refine_slave) Slave PCM not usable
aplay: set_params:1204: Broken configuration for this PCM: no configurations available

Any suggestion? i can attach my files if needed

  • Please direct your questions about Beaglebone Black on the community forum: beagleboard.org/.../Forums
  • Hi:

    Thanks for your suggestion! I've asked questions in beaglebone forums and got no answer...

    Anyway, i've seen similar questions on this forum that got answered... isn't it forum available for this subjetcts anymore? My problem is not really beaglebone black specific, but more like an embeeded linux problem for the am335x, and how to use the processor mcasp with linux...

    I thought i could ask questions here, not only cause i've seen other similar posts (but not the same) but also because there is a ti guide for interfacing beaglebone with a DAC. i've read that guide fully and helped me a lot... but now i need to achieve 2 input serializers and 2 output serializers, each with 4 tdm channels on it..

    I also asked this question in a post that was not the same, but in one of the comments a similar issue was presented, and i was told to start a new post..
    Thanks

  • Hi,

    You are correct the tdm-slots parameter provides the number of slots used by serializer. The settings you've shared seem correct.
    Can you check your bootlog (or dmesg) to see if the sound codec is initialized properly?
    Also run aplay -l and cat /proc/asound/cards to see if alsa & kernel see your audio device.

    Can you share your mcasp0_pins dts node?

    Best Regards,
    Yordan
  • Hi: Thanks for your answer!

    dmesg gives me this related to soundcard (i can send the rest of the dmesg output if needed, but it didn't seem relevant for this subject):

    [    0.290833] omap_i2c 4802a000.i2c: could not find pctldev for node /ocp/l4_wkup@44c00000/scm@210000/pinmux@800/i2c1_pins, deferring probe

    ...

    [    1.245818] davinci_evm sound: ASoC: CODEC DAI pcm3168-hifi not registered
    [    1.252832] davinci_evm sound: snd_soc_register_card failed (-517)

    ...


    [    1.398194] davinci_evm sound: pcm3168-hifi <-> 48038000.mcasp mapping ok

    ...

    [  121.701535] ALSA device list:
    [  121.704551]   #0: TI PCM3168

    aplay -l gives me this:

    # aplay -l
    **** List of PLAYBACK Hardware Devices ****
    card 0: PCM3168 [TI PCM3168], device 0: PCM3168 card pcm3168-hifi-0 []
      Subdevices: 1/1
      Subdevice #0: subdevice #0

    cat /proc/asound/cards gives me this:

    # cat /proc/asound/cards
     0 [PCM3168        ]: TI_PCM3168 - TI PCM3168
                          TI PCM3168

    Is there anything not ok? I find the i2c message and the 2 following lines of dmesg suspicious... And why cat /proc/asound/cards gives me so many TI PCM3168...

    I've already solved the problem that i couldn't use aplay or arecord twice, the clock divider was not properly set in the alsa machine layer, but i still cannot use arecord -c 6 for recording 6 channels...

    Another question... is there a way to specify an arbitrary channel for recording? for example if i want to record from input 6... that way i could see if that channel is working or not...

    Here is my complete device tree mcasp0_pinx:

        mcasp0_pins: mcasp0_pins {
                  pinctrl-single,pins = <
                0X1ac 0x20  /* mcasp0_ahclkx.mcasp0_ahclkx, INPUT | PULLDOWN | MODE0*/
                    0x190 0x00  /* mcasp0_aclkx.mcasp0_aclkx, OUTPUT | PULLDOWN | MODE0 */
                    0x194 0x00  /* mcasp0_fsx.mcasp0_fsx,  OUTPUT | PULLDOWN | MODE 0*/
                    0x198 0x00  /* mcasp0_axr0.mcasp0_axr0, OUTPUT | PULLDOWN | MODE0 */
                    0x1a8 0x00  /* mcasp0_axr1.mcasp0_axr1, OUTPUT | PULLDOWN | MODE0 */
                0x19c 0x22  /* mcasp0_ahclkr.mcasp0_axr2 , INPUT | PULLDOWN | MODE2*/
                0X1a4 0X22  /* mcasp0_fsr.mcasp0_axr3 , INPUT | PULLDOWN | MODE2*/            
                  >;
        };

    And the i2c that i intend to use with the codec:


        i2c1_pins: i2c1_pins {
                    pinctrl-single,pins = <
                        0x158 0x72     /* I2C1_SDA, SLEWCTRL_SLOW | INPUT_PULLUP | MODE2 */
                        0x15C 0x72    /* I2C1_SCL, SLEWCTRL_SLOW | INPUT_PULLUP | MODE2 */
                    >;
                };
    };

    ...

    &i2c1 {

        pinctrl-names = "default";

        pinctrl-0 = <&i2c1_pins>;

        status = "okay";

        clock-frequency = <100000>;

        pcm3168: pcm3168@44 {

            compatible = "ti,pcm3168";

            reg = <0x44>;

            status = "okay";

        };

    };


    &mcasp0 {
        pinctrl-names = "default";
        pinctrl-0 = <&mcasp0_pins>;

        status = "okay";

        op-mode = <0>;          /* MCASP_TDM_MODE */
        tdm-slots = <4>;
        num-serializer = <16>;
        serial-dir = <  /* 0: INACTIVE, 1: TX, 2: RX */
        1 1 2 2    
        0 0 0 0
        0 0 0 0
        0 0 0 0    
        >;
        tx-num-evt = <1>;
        rx-num-evt = <1>;
    };

    Thanks!

    Pablo

  • Hi,

    I refer to TI SDK 2.0, kernel 4.1.6
    By default mcasp0 pins are muxed in other dts pinmux nodes, i.e. pinmux_mmc1_pins, etc.. Can you verify, that you've cleaned those entries. Same applies for i2c1 pins.

    Best Regards,
    Yordan
  • Hi:
    Thanks for your answer. This is my full device tree:

    /*
    * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
    *
    * This program is free software; you can redistribute it and/or modify
    * it under the terms of the GNU General Public License version 2 as
    * published by the Free Software Foundation.
    */
    /dts-v1/;

    #include "am33xx.dtsi"
    #include "am335x-bone-common.dtsi"

    / {
    model = "TI AM335x BeagleBone Black";
    compatible = "ti,am335x-bone-black", "ti,am335x-bone", "ti,am33xx";
    };

    &ldo3_reg {
    regulator-min-microvolt = <1800000>;
    regulator-max-microvolt = <1800000>;
    regulator-always-on;
    };

    &mmc1 {
    vmmc-supply = <&vmmcsd_fixed>;
    };

    &mmc2 {
    vmmc-supply = <&vmmcsd_fixed>;
    pinctrl-names = "default";
    pinctrl-0 = <&emmc_pins>;
    bus-width = <8>;
    status = "okay";
    };

    &am33xx_pinmux {
    nxp_hdmi_bonelt_pins: nxp_hdmi_bonelt_pins {
    pinctrl-single,pins = <
    0x1b0 0x03 /* xdma_event_intr0, OMAP_MUX_MODE3 | AM33XX_PIN_OUTPUT */
    0xa0 0x08 /* lcd_data0.lcd_data0, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
    0xa4 0x08 /* lcd_data1.lcd_data1, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
    0xa8 0x08 /* lcd_data2.lcd_data2, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
    0xac 0x08 /* lcd_data3.lcd_data3, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
    0xb0 0x08 /* lcd_data4.lcd_data4, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
    0xb4 0x08 /* lcd_data5.lcd_data5, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
    0xb8 0x08 /* lcd_data6.lcd_data6, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
    0xbc 0x08 /* lcd_data7.lcd_data7, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
    0xc0 0x08 /* lcd_data8.lcd_data8, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
    0xc4 0x08 /* lcd_data9.lcd_data9, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
    0xc8 0x08 /* lcd_data10.lcd_data10, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
    0xcc 0x08 /* lcd_data11.lcd_data11, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
    0xd0 0x08 /* lcd_data12.lcd_data12, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
    0xd4 0x08 /* lcd_data13.lcd_data13, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
    0xd8 0x08 /* lcd_data14.lcd_data14, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
    0xdc 0x08 /* lcd_data15.lcd_data15, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA */
    0xe0 0x00 /* lcd_vsync.lcd_vsync, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT */
    0xe4 0x00 /* lcd_hsync.lcd_hsync, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT */
    0xe8 0x00 /* lcd_pclk.lcd_pclk, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT */
    0xec 0x00 /* lcd_ac_bias_en.lcd_ac_bias_en, OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT */
    >;
    };
    nxp_hdmi_bonelt_off_pins: nxp_hdmi_bonelt_off_pins {
    pinctrl-single,pins = <
    0x1b0 0x03 /* xdma_event_intr0, OMAP_MUX_MODE3 | AM33XX_PIN_OUTPUT */
    >;
    };

    mcasp0_pins: mcasp0_pins {
    pinctrl-single,pins = <
    0X1ac 0x20 /* mcasp0_ahclkx.mcasp0_ahclkx, INPUT | PULLDOWN | MODE0*/
    0x190 0x00 /* mcasp0_aclkx.mcasp0_aclkx, OUTPUT | PULLDOWN | MODE0 */
    0x194 0x00 /* mcasp0_fsx.mcasp0_fsx, OUTPUT | PULLDOWN | MODE 0*/
    0x198 0x00 /* mcasp0_axr0.mcasp0_axr0, OUTPUT | PULLDOWN | MODE0 */
    0x1a8 0x00 /* mcasp0_axr1.mcasp0_axr1, OUTPUT | PULLDOWN | MODE0 */
    0x19c 0x22 /* mcasp0_ahclkr.mcasp0_axr2 , INPUT | PULLDOWN | MODE2*/
    0X1a4 0X22 /* mcasp0_fsr.mcasp0_axr3 , INPUT | PULLDOWN | MODE2*/
    >;
    };
    i2c1_pins: i2c1_pins {
    pinctrl-single,pins = <
    0x158 0x72 /* I2C1_SDA, SLEWCTRL_SLOW | INPUT_PULLUP | MODE2 */
    0x15C 0x72 /* I2C1_SCL, SLEWCTRL_SLOW | INPUT_PULLUP | MODE2 */
    >;
    };
    };

    &lcdc {
    status = "okay";
    };

    &i2c1 {

    pinctrl-names = "default";

    pinctrl-0 = <&i2c1_pins>;

    status = "okay";

    clock-frequency = <100000>;

    pcm3168: pcm3168@44 {

    compatible = "ti,pcm3168";

    reg = <0x44>;

    status = "okay";

    };

    };


    &mcasp0 {
    pinctrl-names = "default";
    pinctrl-0 = <&mcasp0_pins>;

    status = "okay";

    op-mode = <0>; /* MCASP_TDM_MODE */
    tdm-slots = <4>;
    num-serializer = <16>;
    serial-dir = < /* 0: INACTIVE, 1: TX, 2: RX */
    1 1 2 2
    0 0 0 0
    0 0 0 0
    0 0 0 0
    >;
    tx-num-evt = <1>;
    rx-num-evt = <1>;
    };

    / {
    hdmi {
    compatible = "ti,tilcdc,slave";
    i2c = <&i2c0>;
    pinctrl-names = "default", "off";
    pinctrl-0 = <&nxp_hdmi_bonelt_pins>;
    pinctrl-1 = <&nxp_hdmi_bonelt_off_pins>;
    status = "okay";
    };

    sound {
    compatible = "ti,pcm3168-evm-audio";
    ti,model = "TI PCM3168";
    ti,audio-codec = <&pcm3168>;
    ti,mcasp-controller = <&mcasp0>;
    ti,codec-clock-rate = <24000000>;
    };
    };

    &rtc {
    system-power-controller;
    };

    I found though that i2c0 and i2c2 were already muxed in am335x-bone-common.dtsi, but no i2c1_pins nor mcasp0_pins...
    I also realized that the function regmap_update_bits(priv->regmap, PCM3168_DAC_FMT_CONTROL, 0x0f, val) fails in the driver... could it be somehow related to the i2c? i looked for it in lxr... but i think that if im using it to update codec registers, it can be affected by i2c... am i wrong?
  • Hi:

    Anyone has any hints on this? i still can't solve my problem

    regards