Date:2012-06-16 20:03:28 (10 years 3 months ago)
Author:Paul Cercueil
Commit:5d267d626cc872b61c21dcd15f4a4ec91dc6cca7
Message:ASoC: JZ4740: Use msleep() to wait before enabling the DAC.

This fixes commit ef84c71ff3983379d031ec1eedf2ebb7567a43aa
which used a non-standard and ugly way to delay execution.
Files: sound/soc/codecs/jz4740.c (5 diffs)

Change Details

sound/soc/codecs/jz4740.c
1818#include <linux/io.h>
1919
2020#include <linux/delay.h>
21#include <linux/completion.h>
2221
2322#include <sound/core.h>
2423#include <sound/pcm.h>
...... 
7574struct jz4740_codec {
7675    void __iomem *base;
7776    struct resource *mem;
78
79    struct snd_soc_codec *codec;
80    struct delayed_work dma_work;
81    struct completion completion;
8277};
8378
8479static unsigned int jz4740_codec_read(struct snd_soc_codec *codec,
...... 
252247        jz4740_codec_write(codec, i, cache[i]);
253248}
254249
255static void jz4740_dma_work(struct work_struct *work)
256{
257    struct jz4740_codec *jz4740_codec =
258      container_of(work, struct jz4740_codec, dma_work.work);
259
260    unsigned int mask = JZ4740_CODEC_1_VREF_DISABLE |
261      JZ4740_CODEC_1_VREF_AMP_DISABLE;
262    snd_soc_update_bits(jz4740_codec->codec,
263                JZ4740_REG_CODEC_1, mask, 0);
264    complete_all(&jz4740_codec->completion);
265}
266
267250static int jz4740_codec_set_bias_level(struct snd_soc_codec *codec,
268251    enum snd_soc_bias_level level)
269252{
270253    unsigned int mask;
271254    unsigned int value;
272    struct jz4740_codec *jz4740_codec = snd_soc_codec_get_drvdata(codec);
273255
274256    switch (level) {
275257    case SND_SOC_BIAS_ON:
...... 
279261        value = 0;
280262        snd_soc_update_bits(codec, JZ4740_REG_CODEC_1, mask, value);
281263
282        INIT_COMPLETION(jz4740_codec->completion);
283        schedule_delayed_work(&jz4740_codec->dma_work, HZ / 2);
284        wait_for_completion_interruptible(&jz4740_codec->completion);
264        msleep(500);
265        mask = JZ4740_CODEC_1_VREF_DISABLE |
266                        JZ4740_CODEC_1_VREF_AMP_DISABLE;
267        snd_soc_update_bits(codec, JZ4740_REG_CODEC_1, mask, 0);
285268        break;
286269    case SND_SOC_BIAS_STANDBY:
287270        /* The only way to clear the suspend flag is to reset the codec */
...... 
314297
315298static int jz4740_codec_dev_probe(struct snd_soc_codec *codec)
316299{
317    struct jz4740_codec *jz4740_codec = snd_soc_codec_get_drvdata(codec);
318
319    jz4740_codec->codec = codec;
320    init_completion(&jz4740_codec->completion);
321    INIT_DELAYED_WORK(&jz4740_codec->dma_work, jz4740_dma_work);
322
323300    snd_soc_update_bits(codec, JZ4740_REG_CODEC_1,
324301            JZ4740_CODEC_1_SW2_ENABLE, JZ4740_CODEC_1_SW2_ENABLE);
325302

Archive Download the corresponding diff file



interactive