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.

Can't get sound from TLV320DAC3100 codec on Linux

Other Parts Discussed in Thread: TLV320DAC3100, AM3356, TPS65910, TLC59108, TPS65217, TLV320DAC3101

We have a new board design based on the AM335x EVM. We're using the TLV320DAC3100 codec connected to McASP1 of the AM3356 CPU and using clkout1 as the MCLK input to the codec.

I know it's connected correctly because the TI demo app in sitara-hw-apps-evmskam335x-diag.zip works and it plays sound. I've used the driver in sound/soc/codecs/tlv320aic3x.c file in our 3.2 Linux kernel and have muxed the McASP1 and clkout1 pins in the arch/arm/mach-omap2/board-am335xevm.c file.

The driver seems to install using the i2c interface and address 0x1b (although the datasheet said it is 0x18).

#
# ls /dev/snd/
by-path  controlC0  pcmC0D0c  pcmC0D0p  timer


# cat /proc/asound/card0/pcm0p/info
card: 0
device: 0
subdevice: 0
stream: PLAYBACK
id: AIC3X tlv320aic3x-hifi-0
name:
subname: subdevice #0
class: 0
subclass: 0
subdevices_count: 1
subdevices_avail: 1

# ls /sys/bus/i2c/devices/
2-001b  i2c-2
# ls /sys/bus/i2c/devices/2-001b/
driver                            microamps_requested_2-001b-IOVDD  subsystem
microamps_requested_2-001b-AVDD   modalias                          uevent
microamps_requested_2-001b-DRVDD  name
microamps_requested_2-001b-DVDD   power
# ls /sys/bus/i2c/drivers
at24   ir-kbd-i2c     lm75      tlv320aic3x-codec  tps65910  twl
dummy  lis3lv02d_i2c  tlc59108  tps65217           tsl2550

I got the alsa utils and lib, and then copied some wav files from ti-sdk-am335x-evm-06.00.00.00 to my fs and then tried to play audio with aplay, but there's nothing at all coming out or playing. Common amixer commands I've found on this forum also don't seem to be recognised.

# aplay -f cd Noise.wav
Playing WAVE 'Noise.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono

I have probed the MCLK and can see that there's a 24MHz clock present. However, when I try to play audio with aplay neither DIN, WCLK nor BCLK have any signal present.

Am I missing some amixer setup to play audio?

  • Hi, Adri,

    Unfortunately, we really don't support these types of issues here. You can try posting in the AM335 forum, or you can try contacting your local TI sales office for more assistance.

    -d2

  • ok, thank you. Would you or an admin be able to move the thread into the AM335x forum, please?

  • Thank you for moving the thread.

    I have managed to copy over tlv320aic31xx driver files instead of tlv320aic3x, associate them with our board instance and build them in my kernel. The device is now correctly on i2c address 0x18. I've also built tlv320aic31xx_fw_v1.bin firmware for the codec. It seems to load at boot-time but I still can't get any sound out with this driver.

    The codec reg_init.cfg and pll_48kHz.cfg files are configured to enable the BCLK and WCLK as output. Are there amixer cset commands that need to be run to unmute something?

  • Hello,


    Just to be sure--you have the AIC31xx set as clock master for bclk and wclk, correct?  Do you see the codec generating those clocks, and are you sure they are getting to the proper McASP pin on AM335x?

    There could be some amixer commands needed to enable some of the audio data paths.  One thing you can do is use the "alsamixer" command to get a visual command line tool that you can play around with to adjust volume and such.

    Otherwise, here are some examples of amixer commands that you might be able to use (you'd have to substitute some elements for those that are specific to your board, though): http://processors.wiki.ti.com/index.php/Linux_Core_Audio_User%27s_Guide#AM43x-EPOS-EVM


    Regards,

    Josh

  • Thank you for the suggestions, I'll try those settings when I have it working again...

    I had the BCLK and WCLK settings as output in the FW. However, since I'm not 100% sure that the firmware is loaded and working correctly with our codec, I can't be sure that the settings are being applied as I think they should.

    I double checked my mux settings in arch/arm/mach-omap2/board-am335xevm.c, and they look right I think. clkout1 is output, fsx and aclkx are input from wclk and bclk, and axr0 is the DIN output.

    /* Module pin mux for mcasp1/audio pins */
    static struct pinmux_config mcasp1_pin_mux[] = {
        {"mcasp0_aclkr.mcasp1_aclkx",   OMAP_MUX_MODE3 | AM33XX_INPUT_EN},      /* AUDIO_BCLK */
        {"mcasp0_fsr.mcasp1_fsx",       OMAP_MUX_MODE3 | AM33XX_INPUT_EN},      /* AUDIO_WCLK */
        {"mcasp0_axr1.mcasp1_axr0",     OMAP_MUX_MODE3 | AM33XX_PIN_OUTPUT},    /* AUDIO_DIN */
        {NULL, 0},
    };

    /* Module pin mux for clkout1/audio pins */
    static struct pinmux_config clkout1_pin_mux[] = {
        {"xdma_event_intr0.clkout1",    OMAP_MUX_MODE3 | AM33XX_PIN_OUTPUT},    /* AUDIO_MCLK */
        {NULL, 0},
    };

    I probed the MCLK line and it's 24MHz, but the bclk and wclk were oddly jittery. I could see a very low voltage Sine/square wave signal appearing and disappearing so was hard to get a freq reading. Since it wasn't constant I don't know whether it's working, as with the Sitara diagnostics app both lines had a constant frequency output on them, 1.4MHz and 44kHz approximately.

    I had followed instructions on https://gitorious.org/ti-codecs/pages/CodecDriverAIC31xx to download ti-codecs from git://gitorious.org/ti-codecs/ti-codecs.git and transferred a number of files to my kernel src directory:

    sound/soc/codecs/tlv320aic31xx_default_fw.h
    sound/soc/codecs/tlv320aic31xx.c
    sound/soc/codecs/tlv320aic31xx.h

    sound/soc/codecs/aic3xxx/aic3xxx_cfw.h
    sound/soc/codecs/aic3xxx/aic3xxx_cfw_ops.c
    sound/soc/codecs/aic3xxx/aic3xxx_cfw_ops.h

    including a Multifunction AIC3XXX driver (looked like it was needed from the given menuconfig options):

    drivers/mfd/tlv320aic3xxx-i2c.c
    drivers/mfd/tlv320aic3xxx-core.c
    drivers/mfd/tlv320aic3xxx-irq.c

    include/linux/mfd/tlv320aic3xxx-registers.h
    include/linux/mfd/tlv320aic31xx-registers.h
    include/linux/mfd/tlv320aic3xxx-core.h

    I replaced my sound/soc/davinci/davinci-evm.c with sound/soc/davinci/davinci-aic31xx.c and added

    static struct snd_soc_dai_link am335x_evm_dai = {
        .name = "TLV320AIC31X",
        .stream_name = "AIC3X",
        .cpu_dai_name = "davinci-mcasp.1",
        .codec_dai_name = "tlv320aic31xx-MM_EXT",
        .codec_name = "tlv320aic31xx-codec",
        .platform_name = "davinci-pcm-audio",
        .init = evm_aic3x_init,
        .ops = &evm_ops,
    };

    plus the Kconfig and Makefile changes required. I think this new file has the definition of the EVM sound card using the tlv320aic31xx driver instead of the tlv320aic3x driver.

    I got in touch with our suppliers and they suggested a tlv320aic31xx driver from https://gitorious.org/ti-codecs/ti-codecs/commit/2a6df0d6bb1c270aba57018fad5d3cde221e4d4f, which has just the one C file and looks completely different from the other implementation above. This one looks like it contains the codec register commands and does not require to load separate .bin firmware files, so it gets around the issue of building from cfg and pfw files myself. However, since it's on a much newer kernel than my 3.2 version I had to do quite a bit of backporting of regmap to get it to compile.

    Now though, I'm back to square one as the new driver does not seem to install during boot-up as the last one did so there is no device in /dev/snd/ :(

    I've tried building it as a module and it loads fine, but then I don't know how to get ALSA to rescan the I2C interface and find the device and install the EVM sound card. Argh.... frustrating day.

  • I've taken out all those file again now and just have tlv320aic31xx.c and .h files, which I got off Alex on the forum at http://e2e.ti.com/support/data_converters/audio_converters/f/64/t/298507.aspx.

    The driver is installing again after a few naming changes. It's not able to even attempt to play audio files now though due to some hw_params error:

    bash-4.2# aplay Noise.wav
    Playing WAVE 'Noise.wav' : Signed 16 bit Little [ 1364.978542] asoc: machine hw_params failed
    Endian, Rate 48000 Hz, Mono
    aplay: set_params:1145: Unable to install hw params:
    ACCESS:  RW_INTERLEAVED
    FORMAT:  S16_LE
    SUBFORMAT:  STD
    SAMPLE_BITS: 16
    FRAME_BITS: 16
    CHANNELS: 1
    RATE: 48000
    PERIOD_TIME: (42666 42667)
    PERIOD_SIZE: 2048
    PERIOD_BYTES: 4096
    PERIODS: 16
    BUFFER_TIME: (682666 682667)
    BUFFER_SIZE: 32768
    BUFFER_BYTES: 65536
    TICK_TIME: 0


    Anyone have any idea what that error means?

  • Hi Adri,

    Can you try doing the following:

    aplay Noise.wav -D plughw:0

    The reasoning is that we want to make sure any parameters that aren't supported in hardware are being accounted for in software.

    Secondly, can you try playing a stereo file rather than mono?

    Regards,

    Josh

  • I tracked down exactly where the error was being generated in the evm_hw_params() file for the davinci codec/board file.

    I did a diff between the sound/soc/davinci/davinci-aic31xx.c that I'd copied from https://gitorious.org/ti-codecs/ti-codecs/commit/a8e9dc847e683318810693ff9e3c0d95fc0d0f85 and the native sound/soc/davinci/davinci-evm.c and noticed in evm_hw_params() funciton that it was using

    ret = snd_soc_dai_set_pll(codec_dai, 0, AIC31XX_PLL_CLKIN_MCLK, 24000000, params_rate(params));

    instead of:
    ret = snd_soc_dai_set_sysclk(codec_dai, 0, sysclk, SND_SOC_CLOCK_OUT);

    That's what was returning the error EINVAL. I changed the line back to using snd_soc_dai_set_sysclk and it worked!

  • While we got sound initially working, after a few runs of aplay, the sound suddenly stops working and I can only hear static through the speakers.

    I'm going through the driver settings again. I realised that I don't really know what the N divisor should be for setting BCLK. What is the desired BLCK output supposed to be set to?

    I have the PLL settings set for getting the fs, but am not sure what to do about BCLK.

  • You can calculate bit clock based on the formula on this page.  Note how you can make this a function that computes your bclk for a specific sampling rate/format whenever the audio device is used.

  • Thank you!

    I didn't realise BCLK was part of the I2S sound interface. I looked up I2S on wiki and it's fairly well explained there as well.

    I've now recalculated the N divisor and as far as I can tell all the sounds play without noise and keep playing fine and consistently. I had completely wrong values for it, so would explain the deterioration of sound over time.

  • Hi Adri,

     

        Would you please post your files here?

  • Hi Adri,

    Would you please help us. If possible, can you please post your TLV320DAC3101 driver files.

    Thanks.