Date:2012-01-15 01:02:17 (12 years 2 months ago)
Author:Lars C.
Commit:f43b447b96282892ca629fbe4d5592e2e6b6cae6
Message:ASoC: JZ4740: Enforce buffer size to be a multiple of period size

Neither the driver nor the hardware cope very well with buffer sizes not a
multiple of the period size and will cause auditable artifects. This patch adds
a integer constraint to the number of periods to enforce the buffer size to be a
multiple of the period size.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Files: sound/soc/jz4740/jz4740-pcm.c (3 diffs)

Change Details

sound/soc/jz4740/jz4740-pcm.c
6262static void jz4740_pcm_start_transfer(struct jz4740_runtime_data *prtd,
6363    struct snd_pcm_substream *substream)
6464{
65    unsigned long count;
66
6765    if (prtd->dma_pos == prtd->dma_end)
6866        prtd->dma_pos = prtd->dma_start;
6967
70    if (prtd->dma_pos + prtd->dma_period > prtd->dma_end)
71        count = prtd->dma_end - prtd->dma_pos;
72    else
73        count = prtd->dma_period;
74
7568    jz4740_dma_disable(prtd->dma);
7669
7770    if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
...... 
8275        jz4740_dma_set_dst_addr(prtd->dma, prtd->dma_pos);
8376    }
8477
85    jz4740_dma_set_transfer_count(prtd->dma, count);
78    jz4740_dma_set_transfer_count(prtd->dma, prtd->dma_period);
8679
87    prtd->dma_pos += count;
80    prtd->dma_pos += prtd->dma_period;
8881
8982    jz4740_dma_enable(prtd->dma);
9083}
...... 
214207{
215208    struct snd_pcm_runtime *runtime = substream->runtime;
216209    struct jz4740_runtime_data *prtd;
210    int ret;
217211
218212    prtd = kzalloc(sizeof(*prtd), GFP_KERNEL);
219213    if (prtd == NULL)
220214        return -ENOMEM;
221215
216    ret = snd_pcm_hw_constraint_integer(runtime,
217            SNDRV_PCM_HW_PARAM_PERIODS);
218    if (ret) {
219        kfree(prtd);
220        return ret;
221    }
222
222223    snd_soc_set_runtime_hwparams(substream, &jz4740_pcm_hardware);
223224
224225    runtime->private_data = prtd;

Archive Download the corresponding diff file



interactive