.. | .. |
---|
115 | 115 | snd_pcm_period_elapsed(cam->rx_ss); |
---|
116 | 116 | } |
---|
117 | 117 | |
---|
118 | | -static int camelot_pcm_open(struct snd_pcm_substream *substream) |
---|
| 118 | +static int camelot_pcm_open(struct snd_soc_component *component, |
---|
| 119 | + struct snd_pcm_substream *substream) |
---|
119 | 120 | { |
---|
120 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
---|
121 | | - struct camelot_pcm *cam = &cam_pcm_data[rtd->cpu_dai->id]; |
---|
| 121 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
---|
| 122 | + struct camelot_pcm *cam = &cam_pcm_data[asoc_rtd_to_cpu(rtd, 0)->id]; |
---|
122 | 123 | int recv = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0:1; |
---|
123 | 124 | int ret, dmairq; |
---|
124 | 125 | |
---|
.. | .. |
---|
131 | 132 | ret = dmabrg_request_irq(dmairq, camelot_rxdma, cam); |
---|
132 | 133 | if (unlikely(ret)) { |
---|
133 | 134 | pr_debug("audio unit %d irqs already taken!\n", |
---|
134 | | - rtd->cpu_dai->id); |
---|
| 135 | + asoc_rtd_to_cpu(rtd, 0)->id); |
---|
135 | 136 | return -EBUSY; |
---|
136 | 137 | } |
---|
137 | 138 | (void)dmabrg_request_irq(dmairq + 1,camelot_rxdma, cam); |
---|
.. | .. |
---|
140 | 141 | ret = dmabrg_request_irq(dmairq, camelot_txdma, cam); |
---|
141 | 142 | if (unlikely(ret)) { |
---|
142 | 143 | pr_debug("audio unit %d irqs already taken!\n", |
---|
143 | | - rtd->cpu_dai->id); |
---|
| 144 | + asoc_rtd_to_cpu(rtd, 0)->id); |
---|
144 | 145 | return -EBUSY; |
---|
145 | 146 | } |
---|
146 | 147 | (void)dmabrg_request_irq(dmairq + 1, camelot_txdma, cam); |
---|
.. | .. |
---|
148 | 149 | return 0; |
---|
149 | 150 | } |
---|
150 | 151 | |
---|
151 | | -static int camelot_pcm_close(struct snd_pcm_substream *substream) |
---|
| 152 | +static int camelot_pcm_close(struct snd_soc_component *component, |
---|
| 153 | + struct snd_pcm_substream *substream) |
---|
152 | 154 | { |
---|
153 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
---|
154 | | - struct camelot_pcm *cam = &cam_pcm_data[rtd->cpu_dai->id]; |
---|
| 155 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
---|
| 156 | + struct camelot_pcm *cam = &cam_pcm_data[asoc_rtd_to_cpu(rtd, 0)->id]; |
---|
155 | 157 | int recv = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0:1; |
---|
156 | 158 | int dmairq; |
---|
157 | 159 | |
---|
.. | .. |
---|
168 | 170 | return 0; |
---|
169 | 171 | } |
---|
170 | 172 | |
---|
171 | | -static int camelot_hw_params(struct snd_pcm_substream *substream, |
---|
| 173 | +static int camelot_hw_params(struct snd_soc_component *component, |
---|
| 174 | + struct snd_pcm_substream *substream, |
---|
172 | 175 | struct snd_pcm_hw_params *hw_params) |
---|
173 | 176 | { |
---|
174 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
---|
175 | | - struct camelot_pcm *cam = &cam_pcm_data[rtd->cpu_dai->id]; |
---|
| 177 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
---|
| 178 | + struct camelot_pcm *cam = &cam_pcm_data[asoc_rtd_to_cpu(rtd, 0)->id]; |
---|
176 | 179 | int recv = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0:1; |
---|
177 | 180 | int ret; |
---|
178 | | - |
---|
179 | | - ret = snd_pcm_lib_malloc_pages(substream, |
---|
180 | | - params_buffer_bytes(hw_params)); |
---|
181 | | - if (ret < 0) |
---|
182 | | - return ret; |
---|
183 | 181 | |
---|
184 | 182 | if (recv) { |
---|
185 | 183 | cam->rx_period_size = params_period_bytes(hw_params); |
---|
.. | .. |
---|
191 | 189 | return 0; |
---|
192 | 190 | } |
---|
193 | 191 | |
---|
194 | | -static int camelot_hw_free(struct snd_pcm_substream *substream) |
---|
195 | | -{ |
---|
196 | | - return snd_pcm_lib_free_pages(substream); |
---|
197 | | -} |
---|
198 | | - |
---|
199 | | -static int camelot_prepare(struct snd_pcm_substream *substream) |
---|
| 192 | +static int camelot_prepare(struct snd_soc_component *component, |
---|
| 193 | + struct snd_pcm_substream *substream) |
---|
200 | 194 | { |
---|
201 | 195 | struct snd_pcm_runtime *runtime = substream->runtime; |
---|
202 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
---|
203 | | - struct camelot_pcm *cam = &cam_pcm_data[rtd->cpu_dai->id]; |
---|
| 196 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
---|
| 197 | + struct camelot_pcm *cam = &cam_pcm_data[asoc_rtd_to_cpu(rtd, 0)->id]; |
---|
204 | 198 | |
---|
205 | | - pr_debug("PCM data: addr 0x%08ulx len %d\n", |
---|
| 199 | + pr_debug("PCM data: addr 0x%08lx len %d\n", |
---|
206 | 200 | (u32)runtime->dma_addr, runtime->dma_bytes); |
---|
207 | 201 | |
---|
208 | 202 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { |
---|
.. | .. |
---|
244 | 238 | BRGREG(BRGACR) = acr | ACR_RDS; |
---|
245 | 239 | } |
---|
246 | 240 | |
---|
247 | | -static int camelot_trigger(struct snd_pcm_substream *substream, int cmd) |
---|
| 241 | +static int camelot_trigger(struct snd_soc_component *component, |
---|
| 242 | + struct snd_pcm_substream *substream, int cmd) |
---|
248 | 243 | { |
---|
249 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
---|
250 | | - struct camelot_pcm *cam = &cam_pcm_data[rtd->cpu_dai->id]; |
---|
| 244 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
---|
| 245 | + struct camelot_pcm *cam = &cam_pcm_data[asoc_rtd_to_cpu(rtd, 0)->id]; |
---|
251 | 246 | int recv = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0:1; |
---|
252 | 247 | |
---|
253 | 248 | switch (cmd) { |
---|
.. | .. |
---|
270 | 265 | return 0; |
---|
271 | 266 | } |
---|
272 | 267 | |
---|
273 | | -static snd_pcm_uframes_t camelot_pos(struct snd_pcm_substream *substream) |
---|
| 268 | +static snd_pcm_uframes_t camelot_pos(struct snd_soc_component *component, |
---|
| 269 | + struct snd_pcm_substream *substream) |
---|
274 | 270 | { |
---|
275 | 271 | struct snd_pcm_runtime *runtime = substream->runtime; |
---|
276 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
---|
277 | | - struct camelot_pcm *cam = &cam_pcm_data[rtd->cpu_dai->id]; |
---|
| 272 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
---|
| 273 | + struct camelot_pcm *cam = &cam_pcm_data[asoc_rtd_to_cpu(rtd, 0)->id]; |
---|
278 | 274 | int recv = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0:1; |
---|
279 | 275 | unsigned long pos; |
---|
280 | 276 | |
---|
.. | .. |
---|
292 | 288 | return bytes_to_frames(runtime, pos); |
---|
293 | 289 | } |
---|
294 | 290 | |
---|
295 | | -static const struct snd_pcm_ops camelot_pcm_ops = { |
---|
296 | | - .open = camelot_pcm_open, |
---|
297 | | - .close = camelot_pcm_close, |
---|
298 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
299 | | - .hw_params = camelot_hw_params, |
---|
300 | | - .hw_free = camelot_hw_free, |
---|
301 | | - .prepare = camelot_prepare, |
---|
302 | | - .trigger = camelot_trigger, |
---|
303 | | - .pointer = camelot_pos, |
---|
304 | | -}; |
---|
305 | | - |
---|
306 | | -static int camelot_pcm_new(struct snd_soc_pcm_runtime *rtd) |
---|
| 291 | +static int camelot_pcm_new(struct snd_soc_component *component, |
---|
| 292 | + struct snd_soc_pcm_runtime *rtd) |
---|
307 | 293 | { |
---|
308 | 294 | struct snd_pcm *pcm = rtd->pcm; |
---|
309 | 295 | |
---|
310 | 296 | /* dont use SNDRV_DMA_TYPE_DEV, since it will oops the SH kernel |
---|
311 | 297 | * in MMAP mode (i.e. aplay -M) |
---|
312 | 298 | */ |
---|
313 | | - snd_pcm_lib_preallocate_pages_for_all(pcm, |
---|
| 299 | + snd_pcm_set_managed_buffer_all(pcm, |
---|
314 | 300 | SNDRV_DMA_TYPE_CONTINUOUS, |
---|
315 | | - snd_dma_continuous_data(GFP_KERNEL), |
---|
| 301 | + NULL, |
---|
316 | 302 | DMABRG_PREALLOC_BUFFER, DMABRG_PREALLOC_BUFFER_MAX); |
---|
317 | 303 | |
---|
318 | 304 | return 0; |
---|
319 | 305 | } |
---|
320 | 306 | |
---|
321 | 307 | static const struct snd_soc_component_driver sh7760_soc_component = { |
---|
322 | | - .ops = &camelot_pcm_ops, |
---|
323 | | - .pcm_new = camelot_pcm_new, |
---|
| 308 | + .open = camelot_pcm_open, |
---|
| 309 | + .close = camelot_pcm_close, |
---|
| 310 | + .hw_params = camelot_hw_params, |
---|
| 311 | + .prepare = camelot_prepare, |
---|
| 312 | + .trigger = camelot_trigger, |
---|
| 313 | + .pointer = camelot_pos, |
---|
| 314 | + .pcm_construct = camelot_pcm_new, |
---|
324 | 315 | }; |
---|
325 | 316 | |
---|
326 | 317 | static int sh7760_soc_platform_probe(struct platform_device *pdev) |
---|