All of lore.kernel.org
 help / color / mirror / Atom feed
From: Liam Girdwood <lrg@slimlogic.co.uk>
To: Rodolfo Giometti <giometti@enneenne.com>
Cc: alsa-devel@alsa-project.org
Subject: Re: SoC on PXA27x with two codecs
Date: Tue, 02 Feb 2010 10:37:01 +0000	[thread overview]
Message-ID: <1265107021.4194.33.camel@odin> (raw)
In-Reply-To: <20100202095818.GH1854@enneenne.com>

On Tue, 2010-02-02 at 10:58 +0100, Rodolfo Giometti wrote:
> Hello,
> 
> on my custom board I have a PXA27x CPU and 2 codecs: one connected as
> primary codec and one connected as secondary codec.
> 
> I modify the SoC support in order to allow defining two audio cards,
> one to manage the first codec and one to manage the second one.
> 
> Here the SoC schema:
> 
>    static struct snd_soc_dai_link bt270p_dai[] = {
>            {
>                    .name = "AC97 HiFi",
>                    .stream_name = "audio out",
>                    .cpu_dai = &pxa_ac97_dai[PXA2XX_DAI_AC97_HIFI],
>                    .codec_dai = &cs4299_dai[CS4299_DAI_AC97_HIFI],
>                    .init = bt270_ac97_init,
>                    .ops = &bt270_ops,
>            },
>            {
>                    .name = "AC97 Aux",
>                    .stream_name = "AC97 Aux",
>                    .cpu_dai = &pxa_ac97_dai[PXA2XX_DAI_AC97_AUX],
>                    .codec_dai = &cs4299_dai[CS4299_DAI_AC97_AUX],
>                    .init = bt270_ac97_init,
>                    .ops = &bt270_ops,
>            },
>    };
> 
>    static struct snd_soc_dai_link bt270s_dai[] = {
>            {
>                    .name = "AC97 HiFi",
>                    .stream_name = "speakers",
>                    .cpu_dai = &pxa_ac97_dai[PXA2XX_DAI_AC97_HIFI],
>                    .codec_dai = &cs4299_dai[CS4299_DAI_AC97_HIFI],
>                    .init = bt270_ac97_init,
>                    .ops = &bt270_ops,
>            },
>    };
> 
>    static struct snd_soc_card bt270_asoc[] = {
>            {
>                    .name = "BT270 primary",
>                    .platform = &pxa2xx_soc_platform,
>                    .dai_link = bt270p_dai,
>                    .num_links = ARRAY_SIZE(bt270p_dai),
>            },
>            {
>                    .name = "BT270 secondary",
>                    .platform = &pxa2xx_soc_platform,
>                    .dai_link = bt270s_dai,
>                    .num_links = ARRAY_SIZE(bt270s_dai),
>            },
>    };
> 
>    static struct cs4299_data cs4299_data[] = {
>            {
>                    .ac97_line = 0,
>            },
>            {
>                    .ac97_line = 1,
>            },
>    };
> 
>    static struct snd_soc_device bt270_snd_devdata[2] = {
>            {
>                    .card = &bt270_asoc[0],
>                    .codec_dev = &soc_codec_dev_cs4299,
>                    .codec_data = &cs4299_data[0],
>            },
>            {
>                    .card = &bt270_asoc[1],
>                    .codec_dev = &soc_codec_dev_cs4299,
>                    .codec_data = &cs4299_data[1],
>            },
>    };
> 
>    static struct platform_device *bt270_snd_device[2];
> 
> I'm using the ac97_line parameters into codec's code in order to
> select the primary and the second codecs as follow:
> 
>    static int cs4299_soc_probe(struct platform_device *pdev)
>    {
>            struct snd_soc_device *socdev = platform_get_drvdata(pdev);
>            struct cs4299_data *data = (struct cs4299_data *) socdev->codec_data;
>            struct snd_soc_codec *codec;
>            int ac97_line;
>            int ret = 0;
> 
>            printk(KERN_INFO "CS4299 SoC Audio Codec %s\n", CS4299_VERSION);
> 
>            /* Check specific codec data or set default if not defined */
>            ac97_line = 0;
>            if (data)
>                    ac97_line = data->ac97_line;
> 
>            socdev->card->codec = kzalloc(sizeof(struct snd_soc_codec),
>                                          GFP_KERNEL);
>            if (socdev->card->codec == NULL)
>                    return -ENOMEM;
>            codec = socdev->card->codec;
>            mutex_init(&codec->mutex);
> 
>            codec->reg_cache = kmemdup(cs4299_reg, sizeof(cs4299_reg), GFP_KERNEL);
> 
>            if (codec->reg_cache == NULL) {
>                    ret = -ENOMEM;
>                    goto cache_err;
>            }
>            codec->reg_cache_size = sizeof(cs4299_reg);
>            codec->reg_cache_step = 2;
> 
>            codec->name = "CS4299";
>            codec->id = ac97_line;
>            codec->owner = THIS_MODULE;
>            codec->dai = cs4299_dai;
>            codec->num_dai = ARRAY_SIZE(cs4299_dai);
>            codec->write = ac97_write;
>            codec->read = ac97_read;
>            INIT_LIST_HEAD(&codec->dapm_widgets);
>            INIT_LIST_HEAD(&codec->dapm_paths);
> 
>            ret = snd_soc_new_ac97_codec(codec, &soc_ac97_ops, ac97_line);
>            if (ret < 0) {
>                    printk(KERN_ERR "cs4299: failed to register AC97
>    		codec\n");
>                    goto codec_err;
>            }
> 
>            /* register pcms */
>            ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
>            if (ret < 0)
>                    goto pcm_err;
> 
>            ret = cs4299_reset(codec, 0);
>            if (ret < 0) {
>                    printk(KERN_ERR "Failed to reset CS4299: AC97 link
>    		error\n");
>                    goto reset_err;
>            }
> 
>            snd_soc_add_controls(codec, cs4299_snd_ac97_controls,
>                                    ARRAY_SIZE(cs4299_snd_ac97_controls));
>            cs4299_add_widgets(codec);
>            ret = snd_soc_init_card(socdev);
>            if (ret < 0) {
>                    printk(KERN_ERR "cs4299: failed to register card\n");
>                    goto reset_err;
>            }
> 
>            return 0;
> 
> Everything is working ok but the PCM play/record. In fact I can manage
> both codecs' registers by using:
> 
>    alsamixer -c 0   and
>    alsamixer -c 1
> 
> but when I try to play an MP3 file I can hear the music only on the
> second codec no matter which audio card I select for playing.
> 
> I tested the hardware by defining just one codec at time, and doing in
> this manner the music goes to the right codec.
> 
> Any suggeston? :)

What about the debug output from the DMA configuration (wrt AC97 slot
FIFOs) I suggested yesterday ? 

We really need to confirm the AC97 slots being used and whether each
codec is listening on these slots.

Liam


-- 
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk

      reply	other threads:[~2010-02-02 10:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-02  9:58 SoC on PXA27x with two codecs Rodolfo Giometti
2010-02-02 10:37 ` Liam Girdwood [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1265107021.4194.33.camel@odin \
    --to=lrg@slimlogic.co.uk \
    --cc=alsa-devel@alsa-project.org \
    --cc=giometti@enneenne.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.