diff options
author | Takashi Iwai <tiwai@suse.de> | 2009-05-15 09:38:26 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-05-15 09:38:26 -0400 |
commit | 60befb97f5ab11037f1ae7563ca7137878a7bd46 (patch) | |
tree | 135fd84011d6f75eccbb7647c9b03957a800ed99 /sound/soc/davinci/davinci-pcm.c | |
parent | a3d2b755c0e8f301c079d8aa5a761622259400fe (diff) | |
parent | f492ec9f02908579353e31949855f86909a5af14 (diff) |
Merge branch 'fix/asoc' into for-linus
* fix/asoc:
ASoC: DaVinci EVM board support buildfixes
ASoC: DaVinci I2S updates
ASoC: davinci-pcm buildfixes
pxa2xx-ac97: fix reset gpio mode setting
ASoC: soc-core: fix crash when removing not instantiated card
Diffstat (limited to 'sound/soc/davinci/davinci-pcm.c')
-rw-r--r-- | sound/soc/davinci/davinci-pcm.c | 71 |
1 files changed, 42 insertions, 29 deletions
diff --git a/sound/soc/davinci/davinci-pcm.c b/sound/soc/davinci/davinci-pcm.c index 7af3b5b3a53d..a05996588489 100644 --- a/sound/soc/davinci/davinci-pcm.c +++ b/sound/soc/davinci/davinci-pcm.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <sound/soc.h> | 22 | #include <sound/soc.h> |
23 | 23 | ||
24 | #include <asm/dma.h> | 24 | #include <asm/dma.h> |
25 | #include <mach/edma.h> | ||
25 | 26 | ||
26 | #include "davinci-pcm.h" | 27 | #include "davinci-pcm.h" |
27 | 28 | ||
@@ -51,7 +52,7 @@ struct davinci_runtime_data { | |||
51 | spinlock_t lock; | 52 | spinlock_t lock; |
52 | int period; /* current DMA period */ | 53 | int period; /* current DMA period */ |
53 | int master_lch; /* Master DMA channel */ | 54 | int master_lch; /* Master DMA channel */ |
54 | int slave_lch; /* Slave DMA channel */ | 55 | int slave_lch; /* linked parameter RAM reload slot */ |
55 | struct davinci_pcm_dma_params *params; /* DMA params */ | 56 | struct davinci_pcm_dma_params *params; /* DMA params */ |
56 | }; | 57 | }; |
57 | 58 | ||
@@ -90,18 +91,18 @@ static void davinci_pcm_enqueue_dma(struct snd_pcm_substream *substream) | |||
90 | dst_bidx = data_type; | 91 | dst_bidx = data_type; |
91 | } | 92 | } |
92 | 93 | ||
93 | davinci_set_dma_src_params(lch, src, INCR, W8BIT); | 94 | edma_set_src(lch, src, INCR, W8BIT); |
94 | davinci_set_dma_dest_params(lch, dst, INCR, W8BIT); | 95 | edma_set_dest(lch, dst, INCR, W8BIT); |
95 | davinci_set_dma_src_index(lch, src_bidx, 0); | 96 | edma_set_src_index(lch, src_bidx, 0); |
96 | davinci_set_dma_dest_index(lch, dst_bidx, 0); | 97 | edma_set_dest_index(lch, dst_bidx, 0); |
97 | davinci_set_dma_transfer_params(lch, data_type, count, 1, 0, ASYNC); | 98 | edma_set_transfer_params(lch, data_type, count, 1, 0, ASYNC); |
98 | 99 | ||
99 | prtd->period++; | 100 | prtd->period++; |
100 | if (unlikely(prtd->period >= runtime->periods)) | 101 | if (unlikely(prtd->period >= runtime->periods)) |
101 | prtd->period = 0; | 102 | prtd->period = 0; |
102 | } | 103 | } |
103 | 104 | ||
104 | static void davinci_pcm_dma_irq(int lch, u16 ch_status, void *data) | 105 | static void davinci_pcm_dma_irq(unsigned lch, u16 ch_status, void *data) |
105 | { | 106 | { |
106 | struct snd_pcm_substream *substream = data; | 107 | struct snd_pcm_substream *substream = data; |
107 | struct davinci_runtime_data *prtd = substream->runtime->private_data; | 108 | struct davinci_runtime_data *prtd = substream->runtime->private_data; |
@@ -125,7 +126,7 @@ static int davinci_pcm_dma_request(struct snd_pcm_substream *substream) | |||
125 | struct davinci_runtime_data *prtd = substream->runtime->private_data; | 126 | struct davinci_runtime_data *prtd = substream->runtime->private_data; |
126 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 127 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
127 | struct davinci_pcm_dma_params *dma_data = rtd->dai->cpu_dai->dma_data; | 128 | struct davinci_pcm_dma_params *dma_data = rtd->dai->cpu_dai->dma_data; |
128 | int tcc = TCC_ANY; | 129 | struct edmacc_param p_ram; |
129 | int ret; | 130 | int ret; |
130 | 131 | ||
131 | if (!dma_data) | 132 | if (!dma_data) |
@@ -134,22 +135,34 @@ static int davinci_pcm_dma_request(struct snd_pcm_substream *substream) | |||
134 | prtd->params = dma_data; | 135 | prtd->params = dma_data; |
135 | 136 | ||
136 | /* Request master DMA channel */ | 137 | /* Request master DMA channel */ |
137 | ret = davinci_request_dma(prtd->params->channel, prtd->params->name, | 138 | ret = edma_alloc_channel(prtd->params->channel, |
138 | davinci_pcm_dma_irq, substream, | 139 | davinci_pcm_dma_irq, substream, |
139 | &prtd->master_lch, &tcc, EVENTQ_0); | 140 | EVENTQ_0); |
140 | if (ret) | 141 | if (ret < 0) |
141 | return ret; | 142 | return ret; |
143 | prtd->master_lch = ret; | ||
142 | 144 | ||
143 | /* Request slave DMA channel */ | 145 | /* Request parameter RAM reload slot */ |
144 | ret = davinci_request_dma(PARAM_ANY, "Link", | 146 | ret = edma_alloc_slot(EDMA_SLOT_ANY); |
145 | NULL, NULL, &prtd->slave_lch, &tcc, EVENTQ_0); | 147 | if (ret < 0) { |
146 | if (ret) { | 148 | edma_free_channel(prtd->master_lch); |
147 | davinci_free_dma(prtd->master_lch); | ||
148 | return ret; | 149 | return ret; |
149 | } | 150 | } |
150 | 151 | prtd->slave_lch = ret; | |
151 | /* Link slave DMA channel in loopback */ | 152 | |
152 | davinci_dma_link_lch(prtd->slave_lch, prtd->slave_lch); | 153 | /* Issue transfer completion IRQ when the channel completes a |
154 | * transfer, then always reload from the same slot (by a kind | ||
155 | * of loopback link). The completion IRQ handler will update | ||
156 | * the reload slot with a new buffer. | ||
157 | * | ||
158 | * REVISIT save p_ram here after setting up everything except | ||
159 | * the buffer and its length (ccnt) ... use it as a template | ||
160 | * so davinci_pcm_enqueue_dma() takes less time in IRQ. | ||
161 | */ | ||
162 | edma_read_slot(prtd->slave_lch, &p_ram); | ||
163 | p_ram.opt |= TCINTEN | EDMA_TCC(prtd->master_lch); | ||
164 | p_ram.link_bcntrld = prtd->slave_lch << 5; | ||
165 | edma_write_slot(prtd->slave_lch, &p_ram); | ||
153 | 166 | ||
154 | return 0; | 167 | return 0; |
155 | } | 168 | } |
@@ -165,12 +178,12 @@ static int davinci_pcm_trigger(struct snd_pcm_substream *substream, int cmd) | |||
165 | case SNDRV_PCM_TRIGGER_START: | 178 | case SNDRV_PCM_TRIGGER_START: |
166 | case SNDRV_PCM_TRIGGER_RESUME: | 179 | case SNDRV_PCM_TRIGGER_RESUME: |
167 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | 180 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: |
168 | davinci_start_dma(prtd->master_lch); | 181 | edma_start(prtd->master_lch); |
169 | break; | 182 | break; |
170 | case SNDRV_PCM_TRIGGER_STOP: | 183 | case SNDRV_PCM_TRIGGER_STOP: |
171 | case SNDRV_PCM_TRIGGER_SUSPEND: | 184 | case SNDRV_PCM_TRIGGER_SUSPEND: |
172 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | 185 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: |
173 | davinci_stop_dma(prtd->master_lch); | 186 | edma_stop(prtd->master_lch); |
174 | break; | 187 | break; |
175 | default: | 188 | default: |
176 | ret = -EINVAL; | 189 | ret = -EINVAL; |
@@ -185,14 +198,14 @@ static int davinci_pcm_trigger(struct snd_pcm_substream *substream, int cmd) | |||
185 | static int davinci_pcm_prepare(struct snd_pcm_substream *substream) | 198 | static int davinci_pcm_prepare(struct snd_pcm_substream *substream) |
186 | { | 199 | { |
187 | struct davinci_runtime_data *prtd = substream->runtime->private_data; | 200 | struct davinci_runtime_data *prtd = substream->runtime->private_data; |
188 | struct paramentry_descriptor temp; | 201 | struct edmacc_param temp; |
189 | 202 | ||
190 | prtd->period = 0; | 203 | prtd->period = 0; |
191 | davinci_pcm_enqueue_dma(substream); | 204 | davinci_pcm_enqueue_dma(substream); |
192 | 205 | ||
193 | /* Get slave channel dma params for master channel startup */ | 206 | /* Copy self-linked parameter RAM entry into master channel */ |
194 | davinci_get_dma_params(prtd->slave_lch, &temp); | 207 | edma_read_slot(prtd->slave_lch, &temp); |
195 | davinci_set_dma_params(prtd->master_lch, &temp); | 208 | edma_write_slot(prtd->master_lch, &temp); |
196 | 209 | ||
197 | return 0; | 210 | return 0; |
198 | } | 211 | } |
@@ -208,7 +221,7 @@ davinci_pcm_pointer(struct snd_pcm_substream *substream) | |||
208 | 221 | ||
209 | spin_lock(&prtd->lock); | 222 | spin_lock(&prtd->lock); |
210 | 223 | ||
211 | davinci_dma_getposition(prtd->master_lch, &src, &dst); | 224 | edma_get_position(prtd->master_lch, &src, &dst); |
212 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | 225 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
213 | count = src - runtime->dma_addr; | 226 | count = src - runtime->dma_addr; |
214 | else | 227 | else |
@@ -253,10 +266,10 @@ static int davinci_pcm_close(struct snd_pcm_substream *substream) | |||
253 | struct snd_pcm_runtime *runtime = substream->runtime; | 266 | struct snd_pcm_runtime *runtime = substream->runtime; |
254 | struct davinci_runtime_data *prtd = runtime->private_data; | 267 | struct davinci_runtime_data *prtd = runtime->private_data; |
255 | 268 | ||
256 | davinci_dma_unlink_lch(prtd->slave_lch, prtd->slave_lch); | 269 | edma_unlink(prtd->slave_lch); |
257 | 270 | ||
258 | davinci_free_dma(prtd->slave_lch); | 271 | edma_free_slot(prtd->slave_lch); |
259 | davinci_free_dma(prtd->master_lch); | 272 | edma_free_channel(prtd->master_lch); |
260 | 273 | ||
261 | kfree(prtd); | 274 | kfree(prtd); |
262 | 275 | ||