From: Takashi Iwai Subject: Re: [PATCH 1/8] ASoC pxa2xx DMA support Date: Tue, 10 Oct 2006 19:04:48 +0200 Message-ID: References: <1160496702.24436.110.camel@localhost.localdomain> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1160496702.24436.110.camel@localhost.localdomain> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@lists.sourceforge.net Errors-To: alsa-devel-bounces@lists.sourceforge.net To: Liam Girdwood Cc: Nicolas Pitre , alsa-devel List-Id: alsa-devel@alsa-project.org At Tue, 10 Oct 2006 17:11:42 +0100, Liam Girdwood wrote: > > +static int > +pxa2xx_pcm_hw_rule_mult32(struct snd_pcm_hw_params *params, > + struct snd_pcm_hw_rule *rule) > +{ > + struct snd_interval *i = hw_param_interval(params, rule->var); > + int changed = 0; > + > + if (i->min & 31) { > + i->min = (i->min & ~31) + 32; > + i->openmin = 0; > + changed = 1; > + } > + > + if (i->max & 31) { > + i->max &= ~31; > + i->openmax = 0; > + changed = 1; > + } > + > + return changed; > +} > + > +static int pxa2xx_pcm_open(struct snd_pcm_substream *substream) > +{ > + struct snd_pcm_runtime *runtime = substream->runtime; > + struct pxa2xx_runtime_data *prtd; > + int ret; > + > + snd_soc_set_runtime_hwparams(substream, &pxa2xx_pcm_hardware); > + > + /* > + * For mysterious reasons (and despite what the manual says) > + * playback samples are lost if the DMA count is not a multiple > + * of the DMA burst size. Let's add a rule to enforce that. > + */ > + ret = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, > + pxa2xx_pcm_hw_rule_mult32, NULL, > + SNDRV_PCM_HW_PARAM_PERIOD_BYTES, -1); How about to use snd_pcm_hw_constraint_step()? > + if (ret) > + goto out; > + > + ret = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, > + pxa2xx_pcm_hw_rule_mult32, NULL, > + SNDRV_PCM_HW_PARAM_BUFFER_BYTES, -1); > + if (ret) > + goto out; > + > + prtd = kzalloc(sizeof(struct pxa2xx_runtime_data), GFP_KERNEL); > + if (prtd == NULL) { > + ret = -ENOMEM; > + goto out; > + } > + > + prtd->dma_desc_array = > + dma_alloc_writecombine(substream->pcm->card->dev, PAGE_SIZE, > + &prtd->dma_desc_array_phys, GFP_KERNEL); > + if (!prtd->dma_desc_array) > + goto err1; You have to set "ret = -EXXX" here. > +static u64 pxa2xx_pcm_dmamask = 0xffffffff; Use DMA_32BIT_MASK. > + > +int pxa2xx_pcm_new(struct snd_card *card, struct snd_soc_codec_dai *dai, > + struct snd_pcm *pcm) > +{ > + int ret = 0; > + > + if (!card->dev->dma_mask) > + card->dev->dma_mask = &pxa2xx_pcm_dmamask; > + if (!card->dev->coherent_dma_mask) > + card->dev->coherent_dma_mask = 0xffffffff; Ditto. Takashi ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV