Codec drivers and alsa support for custom cape with sta321mp

Hi:

Thanks for your suggestions!

i’ve already commented that line, as i said in the mail when i isolated the problem to that function… the error persist but now in:

ret = snd_soc_dai_set_sysclk(cpu_dai, 0, sysclk, SND_SOC_CLOCK_OUT);
if (ret < 0)
return ret;

I’m using the linux-cross-reference, that’s how i find out what each parameter means, but perhaps i still dont quite understand what the function really does.

I’ve also read the mcasp section of the am335x datasheet when i was doing the PCB for the codec, but i should re-read it, as many things where not clear for me at that moment, and perhaps now they make a little more sense. Anyway, the problem and same error code persists, now in that other line…

Thanks for your help! i’ll post any progress i make

Hi Robin:

I realized that although i was commenting the line you said, i was using and old image of the compiled kernel, and that was why i kept getting the same error! My bad… Now that is working, but i have an error in the line:

ret = regmap_update_bits(priv->regmap, PCM3168_DAC_FMT_CONTROL, 0x0f, val);

on my pcm3168.c file… ret gets the value -128 (error code). I use this function to update some register on the codec… i suspected that my i2c connection is not working properly, so i commented this line (althoug i’m not sure if an error in i2c causes this function to crash) and finally the arecord command works gives no error, but records nothing :frowning:

That was somehow expected, as my codec is not geting it’s regmap updated… One of this days i will use an ozscope to see if the signals out of the i2c of the beaglebone are right… If you came up with some idea please tell me… you’ve been of great help…

P.D: have you got alsamixer working in your project?

Hi Pablo,

Any progress with your board ?

Also, to answer your question, I got the alsamixer working. You have to add a number of macros for predefined controls corresponding to register to update in the codec. You can see it directly in my code:

https://github.com/fakufaku/linux/blob/66e5bfa74df723ff64b48d2ae14f3543d6c47861/sound/soc/codecs/sta321mp.c#L74

static const DECLARE_TLV_DB_SCALE(mvol_tlv, -12700, 50, 1);
static const DECLARE_TLV_DB_SCALE(chvol_tlv, -7950, 50, 1);
static const struct snd_kcontrol_new sta321mp_snd_controls[] = {
SOC_SINGLE(“Master Switch”, STA321MP_MMUTE, 0, 1, 1),
SOC_SINGLE_TLV(“Master Volume”, STA321MP_MVOL, 0, 0xff, 1, mvol_tlv),
SOC_DOUBLE_R(“Ch1 Capture Switch”, STA321MP_C1VTMB, STA321MP_C2VTMB, 7, 1, 1),
SOC_DOUBLE_R(“Ch2 Capture Switch”, STA321MP_C3VTMB, STA321MP_C4VTMB, 7, 1, 1),
SOC_DOUBLE_R(“Ch3 Capture Switch”, STA321MP_C5VTMB, STA321MP_C6VTMB, 7, 1, 1),
SOC_DOUBLE_R_TLV(“Ch1 Capture Volume”, STA321MP_C1VOL, STA321MP_C2VOL, 0, 0xff, 1, chvol_tlv),
SOC_DOUBLE_R_TLV(“Ch2 Capture Volume”, STA321MP_C3VOL, STA321MP_C4VOL, 0, 0xff, 1, chvol_tlv),
SOC_DOUBLE_R_TLV(“Ch3 Capture Volume”, STA321MP_C5VOL, STA321MP_C6VOL, 0, 0xff, 1, chvol_tlv),
};

This implements volume control for all six capture channels, as well as mute switches.

Best,
Robin

Hi robin!

By this time, i was writting a guide to get a custom linux os to boot in the beaglebone… and i was quite busy with that…

In my project, the drivers seems to be working properly, although i can’t use regmap_update_bits function… i’m not sure, but i think it has something to do with the i2c communications that seems not to be working… If it has to update registers through i2c and this is not working, it makes sense that that functions returns error… i think that for that same reazon, alsamixer is not working… i’ve made the structures you told me, but i keep getting “input output error” when i try to “alsamixer”

Anyway, the university is closed till march here (we are on holydays) so i can’t get the equipmet to test the hardware, and i don’t own any right now (too expensive for me).

One main issue i’m having and that i can’t solve is that i can record only 4 channels with arecord…

I configured 2 serializers as input, and 4 tdm slots on each in the device tree… but if i “arecord -c 6” it says “no channel count avaliable”… i’m starting to think that arecord recors from only one serializer… i would need to record an arbitrary channel if it’s possible, and i think i should write an alsa application for this…

But more important right now seems to be this: Do you think is possible that alsamixer and regmap_update_bits are not working cause of i2c problem?

Thanks for everything

Pablo

Hi Robin:

After working hard, i’m sure that i’m having some hardware problems, cause driver seems to work but get no output. This led me to trying to communicate with the codec via i2c and i could not… So either my chip is dead or i’m having hardware trouble that i could not detect in the whole past week…

So i had the idea of using the same codec you did, to get something to work… if it’s not much trouble, could you share with me the schematics of your hardware? and could i use the drivers you wrote?

It’s very frustrating working so much and having hardware fails…

another thing i wanted to ask, do you know if alsamixer may not work if i2c communication is not possible? Cause i always get I/O error… although i wrote al needed (i think) structures

Thanks for everything

Pablo

Hi Pablo,

Sure, that should be no problem.

My files are actually already online. The license for it is CC-BY-SA (https://creativecommons.org/licenses/by-sa/4.0/legalcode). I need to update the readme to make this clear though. This means you’re free to use it, as long as proper attribution is done.

The repository is

https://github.com/LCAV/CompactSix

I used Eagle CAD to design the board.

Let me know if you have any question.

Cheers,
Robin