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.

Driving an ads1278 as an audio device using modified ads117x.c codec source (ALSA)

Other Parts Discussed in Thread: ADS1278

Hi

I'm trying to use an ads1278 (dasy-chained 16ch) as an audio device using modified ads117.c codec source out of the linux-3.2-psp04.06.00.07.sdk (ti-sdk-am335x-evm).

My system is a beaglebone running angstrom_v2012_05.
Since this codec is not a part of angstrom, I built the source using a custom .bb recipe and loaded it as a module on the target system. This works, I hope it is the right way so far.

Now, I'm struggling with a few tasks since I could not find a detailed ALSA documentation concerning ASoC.
How to load the generated codec module?
How to select IO's/SPI interface?

This would help a lot, thanks in advance.
Hitsch 

  • ...here's the source:

    #include <linux/kernel.h>
    #include <linux/slab.h>
    #include <linux/init.h>
    #include <linux/device.h>
    #include <linux/module.h>
    #include <sound/core.h>
    #include <sound/pcm.h>
    #include <sound/initval.h>
    #include <sound/soc.h>

    #define ADS127X_RATES (SNDRV_PCM_RATE_8000_48000)
    #define ADS127X_FORMATS (SNDRV_PCM_FMTBIT_S24_LE)

    static struct snd_soc_dai_driver ads127x_dai = {
    /* ADC */
    .name = "ads127x-hifi",
    .capture = {
    .stream_name = "Capture",
    .channels_min = 1,
    .channels_max = 16,
    .rates = ADS127X_RATES,
    .formats = ADS127X_FORMATS,},
    };

    static struct snd_soc_codec_driver soc_codec_dev_ads127x;

    static __devinit int ads127x_probe(struct platform_device *pdev)
    {
    return snd_soc_register_codec(&pdev->dev,
    &soc_codec_dev_ads127x, &ads127x_dai, 1);
    }

    static int __devexit ads127x_remove(struct platform_device *pdev)
    {
    printk("ADS127, remove audio driver\n");
    snd_soc_unregister_codec(&pdev->dev);
    return 0;
    }

    static struct platform_driver ads127x_codec_driver = {
    .driver = {
    .name = "ads127x-codec",
    .owner = THIS_MODULE,
    },

    .probe = ads127x_probe,
    .remove = __devexit_p(ads127x_remove),
    };

    static int __init ads127x_init(void)
    {
    printk("ADS127x, load audio driver\n");
    return platform_driver_register(&ads127x_codec_driver);
    }
    module_init(ads127x_init);

    static void __exit ads127x_exit(void)
    {
    platform_driver_unregister(&ads127x_codec_driver);
    }
    module_exit(ads127x_exit);

  • I assume that it is probably the best to use the davinci-pcm-audio platform driver. Is that right?
    I modified following:

    Index: git/arch/arm/mach-omap2/devices.c
    ===================================================================
    --- git.orig/arch/arm/mach-omap2/devices.c    2012-07-20 16:22:26.324602816 +0200
    +++ git/arch/arm/mach-omap2/devices.c          2012-07-26 13:20:17.124821103 +0200
    @@ -231,10 +231,16 @@
                   .id                          = -1,
    };
     
    +struct platform_device ads117x_codec= {
    +             .name                  = "ads117x-codec",
    +             .id                          = -1,
    +};
    +
    static void am33xx_init_pcm(void)
    {
    -              printk("cape: pcm register");
    +             printk("Multisensor cape: pcm register");
                   platform_device_register(&am33xx_pcm_device);
    +             platform_device_register(&ads117x_codec);
    }
     
     #else
     
    After this changes, I can find codec and dai in /sys/kernel/debug/asoc:
    root@beaglebone:/sys/kernel/debug/asoc# cat codecs
    tlv320aic3x-codec.3-001b
    ads117x-codec
    root@beaglebone:/sys/kernel/debug/asoc# cat dais
    davinci-mcasp.1
    davinci-mcasp.0
    tlv320aic3x-hifi
    ads117x-hifi
    root@beaglebone:/sys/kernel/debug/asoc# cat platforms
    davinci-pcm-audio
    snd-soc-dummy
    root@beaglebone:/sys/kernel/debug/asoc#
     
    If I now try to add this to snd_soc_dai_link, the kernel panics while booting:
    {
                                   .name = "ADS117X",
                                   .stream_name = "ADS117X",
                                   .cpu_dai_name = "davinci-mcasp.0",
                                   .codec_dai_name = "ads117x-hifi",
                                   .codec_name = "ads117x-codec",
                                   .platform_name = "davinci-pcm-audio",
                                   .init = evm_adsadc_init,
                                   .ops = &evm_adc_ops,
    }
     
    Does anybody have an idea how it comes to this?
     
    Another thing I don’t understand is, why do we register a platform in ads117.c?
    static int __init ads117x_init(void)
    {
                   return platform_driver_register(&ads117x_codec_driver);
    }
     
    The old version used to register a snd_soc_dai_driver:
    static int __init ads117x_modinit(void)
    {
                    return snd_soc_register_dai(&ads117x_dai);
    }

    An other way to solve this problem which I was thinking about: Is it possible to use the davinci-pcm-audio platform driver without a codec driver? The ADC doesn't have a control interface, so we probably could configure the mcasp and set a dummy codec?

  • Hi chrigima,

    were you able to make the ADC work properly? Can you share the code?

    Thanks a lot.