2

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?

artless noise
  • 21,212
  • 6
  • 68
  • 105
SwimBikeRun
  • 4,192
  • 11
  • 49
  • 85

1 Answers1

1

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.

Michael
  • 1,505
  • 14
  • 26
  • When you are in the omap3beagle.c and see SND_SOC_DAIFMT_CBM_CFM, how do you locate where this macro is defined? (my current method is a grep that takes 9 minutes... haha) I am using Eclipse but F3 does not take me to the macro definition like it would take me to a function definition. (edit: what you provided was helpful, but I'm asking what if you hadn't told me where to find SND_SOC_DAIFMT_CBM_CFM. For instance, where is SND_SOC_DAIFMT_I2S? – SwimBikeRun Nov 22 '13 at 00:53
  • @SwimBikeRun I use ctags/utags and generate tags for all the necessary folders. Then use vim for this tag file and just steps through any funcion/macro etc. For instance SND_SOC_DAIFMT_I2S is in the soc-dai.h at line 27 in my kernel. – Michael Nov 22 '13 at 05:17
  • @SwimBikeRun Also you can just use http://lxr.free-electrons.com/ or just google. – Michael Nov 22 '13 at 06:24