Configuring I2C and I2S in ALSA ASoC

5.8k Views Asked by At

I am working with a BeagleBoard running Linux 3.0.63, and I am trying to get the I2C and I2S interfaces to work, with the end goal of playing a .wav file on the beagleboard and having the I2C and I2S set up correctly.

I am currently stuck on setting the BeagleBoard to be the master clock for the I2S line. Or the slave clock could also work. In any case, I have no idea where the I2S stuff is set in the kernel code. I assumed in arch/arm/mach-omap3/board-omap3beagle.c, but I cannot find it.

Btw, is there hidden documentation on how to do this that I do not know about?

1

There are 1 best solutions below

3
On

Have a look at files sound/soc/omap/omap3beagle.c and include/sound/soc-dai.h:

First one has a function:

static int omap3beagle_hw_params(struct snd_pcm_substream *substream,
    struct snd_pcm_hw_params *params)
{
    /* couple of lines */
    switch (params_channels(params)) {
    case 2: /* Stereo I2S mode */
        fmt =   SND_SOC_DAIFMT_I2S |
            SND_SOC_DAIFMT_NB_NF |
            SND_SOC_DAIFMT_CBM_CFM;
        break;
    case 4: /* Four channel TDM mode */
        fmt =   SND_SOC_DAIFMT_DSP_A |
            SND_SOC_DAIFMT_IB_NF |
            SND_SOC_DAIFMT_CBM_CFM;
        break;
    default:
        return -EINVAL;
    }
    /* some stuff */
}

And the second one has macro-definitions:

/*
 * DAI hardware clock masters.
 *
 * This is wrt the codec, the inverse is true for the interface
 * i.e. if the codec is clk and FRM master then the interface is
 * clk and frame slave.
 */
#define SND_SOC_DAIFMT_CBM_CFM      (1 << 12) /* codec clk & FRM master */
#define SND_SOC_DAIFMT_CBS_CFM      (2 << 12) /* codec clk slave & FRM master */
#define SND_SOC_DAIFMT_CBM_CFS      (3 << 12) /* codec clk master & frame slave */
#define SND_SOC_DAIFMT_CBS_CFS      (4 << 12) /* codec clk & FRM slave */

So using them you can adjust I2S clocking for "Stereo I2S mode" as you need. There are a lot of other options but I guess these ones are the exactly what you need.

Some documentation can be found at Documentation/sound/alsa/soc.