On Thu, 2010-03-11 at 09:32 -0600, miguel.aguilar@xxxxxxxxxxxx wrote: > From: Miguel Aguilar <miguel.aguilar@xxxxxxxxxxxx> > > This patch adds the support for the interface needed by the DaVinci > Voice Codec CQ93VC. > > Signed-off-by: Miguel Aguilar <miguel.aguilar@xxxxxxxxxxxx> > --- snip > + > +static int davinci_vcif_hw_params(struct snd_pcm_substream *substream, > + struct snd_pcm_hw_params *params, > + struct snd_soc_dai *dai) > +{ > + struct davinci_vcif_dev *davinci_vcif_dev = dai->private_data; > + struct davinci_vc *davinci_vc = davinci_vcif_dev->davinci_vc; > + struct davinci_pcm_dma_params *dma_params = > + &davinci_vcif_dev->dma_params[substream->stream]; > + u32 w; > + > + /* Restart the codec before setup */ > + davinci_vcif_stop(substream); > + davinci_vcif_start(substream); > + > + /* General line settings */ > + writel(DAVINCI_VC_CTRL_MASK, davinci_vc->base + DAVINCI_VC_CTRL); > + > + writel(DAVINCI_VC_INT_MASK, davinci_vc->base + DAVINCI_VC_INTCLR); > + > + writel(DAVINCI_VC_INT_MASK, davinci_vc->base + DAVINCI_VC_INTEN); > + > + w = readl(davinci_vc->base + DAVINCI_VC_CTRL); > + > + /* Determine xfer data type */ > + switch (params_format(params)) { > + case SNDRV_PCM_FORMAT_U8: > + dma_params->data_type = 0; > + > + MOD_REG_BIT(w, DAVINCI_VC_CTRL_RD_BITS_8 | > + DAVINCI_VC_CTRL_RD_UNSIGNED | > + DAVINCI_VC_CTRL_WD_BITS_8 | > + DAVINCI_VC_CTRL_WD_UNSIGNED, 1); > + break; > + case SNDRV_PCM_FORMAT_S8: > + dma_params->data_type = 1; > + > + MOD_REG_BIT(w, DAVINCI_VC_CTRL_RD_BITS_8 | > + DAVINCI_VC_CTRL_WD_BITS_8, 1); > + > + MOD_REG_BIT(w, DAVINCI_VC_CTRL_RD_UNSIGNED | > + DAVINCI_VC_CTRL_WD_UNSIGNED, 0); > + break; > + case SNDRV_PCM_FORMAT_S16_LE: > + dma_params->data_type = 2; > + > + MOD_REG_BIT(w, DAVINCI_VC_CTRL_RD_BITS_8 | > + DAVINCI_VC_CTRL_RD_UNSIGNED | > + DAVINCI_VC_CTRL_WD_BITS_8 | > + DAVINCI_VC_CTRL_WD_UNSIGNED, 0); > + break; > + default: > + printk(KERN_WARNING "davinci-vcif: unsupported PCM format"); > + return -EINVAL; > + } > + > + dma_params->acnt = dma_params->data_type; > + > + writel(w, davinci_vc->base + DAVINCI_VC_CTRL); > + > + return 0; > +} > + > +static int davinci_vcif_trigger(struct snd_pcm_substream *substream, int cmd, > + struct snd_soc_dai *dai) > +{ > + int ret = 0; > + > + switch (cmd) { > + case SNDRV_PCM_TRIGGER_START: > + case SNDRV_PCM_TRIGGER_RESUME: > + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: > + davinci_vcif_start(substream); > + case SNDRV_PCM_TRIGGER_STOP: > + case SNDRV_PCM_TRIGGER_SUSPEND: > + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: > + davinci_vcif_stop(substream); > + break; > + default: > + ret = -EINVAL; > + } > + > + return ret; > +} > + > +#define DAVINCI_VCIF_RATES SNDRV_PCM_RATE_8000_48000 > + > +static struct snd_soc_dai_ops davinci_vcif_dai_ops = { > + .trigger = davinci_vcif_trigger, > + .hw_params = davinci_vcif_hw_params, > +}; > + > +struct snd_soc_dai davinci_vcif_dai = { > + .name = "davinci-vcif", > + .playback = { > + .channels_min = 1, > + .channels_max = 2, > + .rates = DAVINCI_VCIF_RATES, > + .formats = SNDRV_PCM_FMTBIT_S16_LE,}, > + .capture = { > + .channels_min = 1, > + .channels_max = 2, > + .rates = DAVINCI_VCIF_RATES, > + .formats = SNDRV_PCM_FMTBIT_S16_LE,}, Your hw_params() supports more formats than just this one. Liam -- Freelance Developer, SlimLogic Ltd ASoC and Voltage Regulator Maintainer. http://www.slimlogic.co.uk _______________________________________________ Alsa-devel mailing list Alsa-devel@xxxxxxxxxxxxxxxx http://mailman.alsa-project.org/mailman/listinfo/alsa-devel