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-bye-due2AI
22.8k6 gold badges76 silver badges113 bronze badges
asked Nov 21, 2013 at 19:33

1 Answer 1

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.

answered Nov 21, 2013 at 19:53
Sign up to request clarification or add additional context in comments.

3 Comments

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 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.
@SwimBikeRun Also you can just use lxr.free-electrons.com or just google.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.