From: Takashi Iwai <tiwai@suse.de>
To: Nicolas Pitre <nico@cam.org>
Cc: alsa-devel@lists.sourceforge.net
Subject: Re: new ALSA driver for audio on the ARM PXA2xx platform
Date: Wed, 26 Jan 2005 11:36:31 +0100 [thread overview]
Message-ID: <s5hfz0o5vf4.wl@alsa2.suse.de> (raw)
In-Reply-To: <Pine.LNX.4.61.0501251624470.16341@localhost.localdomain>
Hi Nicolas,
At Tue, 25 Jan 2005 16:33:40 -0500 (EST),
Nicolas Pitre wrote:
>
>
> This patch adds two modules: one for generic PCM support on PXA2xx and
> another to interface with the AC97 link on the PXA2xx. Eventually
> additional modules could be written to use the PCM module with SSP or
> I2S audio ports.
>
> Signed-off-by: Nicolas Pitre <nico@cam.org>
Thanks, the code looks nice.
> +static int pxa2xx_ac97_pcm_startup(snd_pcm_substream_t *substream)
> +{
> + snd_pcm_runtime_t *runtime = substream->runtime;
> + pxa2xx_audio_ops_t *platform_ops;
> + int vra_mask;
> +
> + runtime->hw.channels_min = 2;
> + runtime->hw.channels_max = 2;
> +
> + vra_mask = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ?
> + AC97_EA_VRA : AC97_EA_VRM;
> + if (pxa2xx_ac97_ac97->regs[AC97_EXTENDED_STATUS] & vra_mask) {
> + runtime->hw.rates = SNDRV_PCM_RATE_8000_48000;
> + runtime->hw.rate_min = 8000;
> + runtime->hw.rate_max = 48000;
> + } else {
> + runtime->hw.rates = SNDRV_PCM_RATE_48000;
> + runtime->hw.rate_min = 48000;
> + runtime->hw.rate_max = 48000;
> + }
You can use ac97->rates[AC97_RATES_FRONT_DAC] and
ac97->rates[AC97_RATES_ADC] for rates bits, and call
snd_pcm_limit_hw_rates(runtime) to set rate_min/max automatically.
Some codecs don't support non-standard rate even VRA is set.
> +static int pxa2xx_ac97_probe(struct device *dev)
(snip)
> + snprintf(card->shortname, sizeof(card->shortname), "%s",
> + snd_ac97_get_short_name(pxa2xx_ac97_ac97));
Set longname, too. It will appear in /proc/asound/cards.
> Index: linux-2.6/sound/arm/pxa2xx-pcm.c
(snip)
> +static const snd_pcm_hardware_t pxa2xx_pcm_hardware = {
> + .info = SNDRV_PCM_INFO_MMAP |
> + SNDRV_PCM_INFO_MMAP_VALID |
> + SNDRV_PCM_INFO_INTERLEAVED |
> + SNDRV_PCM_INFO_PAUSE,
Don't forget SNDRV_PCM_INFO_RESUME if the driver supports PM.
> + .formats = SNDRV_PCM_FMTBIT_S16_LE,
> + .period_bytes_min = 32,
> + .period_bytes_max = 8192 - 32,
I suppose this 32 is fifo size? If so, you don't have to count it
here. The period size defines the size of DMA interrupt period.
(The fifo_size isn't used in the driver currently.)
> +static void pxa2xx_pcm_dma_irq(int dma_ch, void *dev_id, struct pt_regs *regs)
> +{
> + snd_pcm_substream_t *substream = dev_id;
> + struct pxa2xx_runtime_data *rtd = substream->runtime->private_data;
> + int dcsr;
> +
> + dcsr = DCSR(dma_ch);
> + DCSR(dma_ch) = dcsr & ~DCSR_STOPIRQEN;
> +
> + if (dcsr & DCSR_ENDINTR) {
> + snd_pcm_period_elapsed(substream);
> + } else {
> + printk( KERN_ERR "%s: DMA error on channel %d (DCSR=%#x)\n",
> + rtd->params->name, dma_ch, dcsr );
You can call here snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN) to
notify the buffer over/underrun.
> +static int
> +pxa2xx_pcm_mmap(snd_pcm_substream_t *substream, struct vm_area_struct *vma)
> +{
> + snd_pcm_runtime_t *runtime = substream->runtime;
> + return dma_mmap_writecombine(substream->pcm->card->dev, vma,
> + runtime->dma_area,
> + runtime->dma_addr,
> + runtime->dma_bytes);
> +}
> +
> +static snd_pcm_ops_t pxa2xx_pcm_ops = {
> + .open = pxa2xx_pcm_open,
> + .close = pxa2xx_pcm_close,
> + .ioctl = snd_pcm_lib_ioctl,
> + .hw_params = pxa2xx_pcm_hw_params,
> + .hw_free = pxa2xx_pcm_hw_free,
> + .prepare = pxa2xx_pcm_prepare,
> + .trigger = pxa2xx_pcm_trigger,
> + .pointer = pxa2xx_pcm_pointer,
> + .mmap = pxa2xx_pcm_mmap,
> +};
Heh, finally a right driver using mmap callback ;)
Takashi
-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
next prev parent reply other threads:[~2005-01-26 10:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-25 21:33 new ALSA driver for audio on the ARM PXA2xx platform Nicolas Pitre
2005-01-26 10:36 ` Takashi Iwai [this message]
2005-01-26 15:20 ` Nicolas Pitre
2005-01-27 3:05 ` Nicolas Pitre
2005-01-27 11:07 ` Takashi Iwai
2005-01-26 15:43 ` Liam Girdwood
2005-01-26 15:50 ` Nicolas Pitre
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=s5hfz0o5vf4.wl@alsa2.suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@lists.sourceforge.net \
--cc=nico@cam.org \
/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.