| .. | .. |
|---|
| 93 | 93 | return ret; |
|---|
| 94 | 94 | } |
|---|
| 95 | 95 | |
|---|
| 96 | | -static int uniphier_aiodma_open(struct snd_pcm_substream *substream) |
|---|
| 96 | +static int uniphier_aiodma_open(struct snd_soc_component *component, |
|---|
| 97 | + struct snd_pcm_substream *substream) |
|---|
| 97 | 98 | { |
|---|
| 98 | 99 | struct snd_pcm_runtime *runtime = substream->runtime; |
|---|
| 99 | 100 | |
|---|
| .. | .. |
|---|
| 103 | 104 | SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 256); |
|---|
| 104 | 105 | } |
|---|
| 105 | 106 | |
|---|
| 106 | | -static int uniphier_aiodma_hw_params(struct snd_pcm_substream *substream, |
|---|
| 107 | | - struct snd_pcm_hw_params *params) |
|---|
| 108 | | -{ |
|---|
| 109 | | - snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); |
|---|
| 110 | | - substream->runtime->dma_bytes = params_buffer_bytes(params); |
|---|
| 111 | | - |
|---|
| 112 | | - return 0; |
|---|
| 113 | | -} |
|---|
| 114 | | - |
|---|
| 115 | | -static int uniphier_aiodma_hw_free(struct snd_pcm_substream *substream) |
|---|
| 116 | | -{ |
|---|
| 117 | | - snd_pcm_set_runtime_buffer(substream, NULL); |
|---|
| 118 | | - substream->runtime->dma_bytes = 0; |
|---|
| 119 | | - |
|---|
| 120 | | - return 0; |
|---|
| 121 | | -} |
|---|
| 122 | | - |
|---|
| 123 | | -static int uniphier_aiodma_prepare(struct snd_pcm_substream *substream) |
|---|
| 107 | +static int uniphier_aiodma_prepare(struct snd_soc_component *component, |
|---|
| 108 | + struct snd_pcm_substream *substream) |
|---|
| 124 | 109 | { |
|---|
| 125 | 110 | struct snd_pcm_runtime *runtime = substream->runtime; |
|---|
| 126 | | - struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream); |
|---|
| 127 | | - struct uniphier_aio *aio = uniphier_priv(rtd->cpu_dai); |
|---|
| 111 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
|---|
| 112 | + struct uniphier_aio *aio = uniphier_priv(asoc_rtd_to_cpu(rtd, 0)); |
|---|
| 128 | 113 | struct uniphier_aio_sub *sub = &aio->sub[substream->stream]; |
|---|
| 129 | 114 | int bytes = runtime->period_size * |
|---|
| 130 | 115 | runtime->channels * samples_to_bytes(runtime, 1); |
|---|
| .. | .. |
|---|
| 146 | 131 | return 0; |
|---|
| 147 | 132 | } |
|---|
| 148 | 133 | |
|---|
| 149 | | -static int uniphier_aiodma_trigger(struct snd_pcm_substream *substream, int cmd) |
|---|
| 134 | +static int uniphier_aiodma_trigger(struct snd_soc_component *component, |
|---|
| 135 | + struct snd_pcm_substream *substream, int cmd) |
|---|
| 150 | 136 | { |
|---|
| 151 | 137 | struct snd_pcm_runtime *runtime = substream->runtime; |
|---|
| 152 | | - struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream); |
|---|
| 153 | | - struct uniphier_aio *aio = uniphier_priv(rtd->cpu_dai); |
|---|
| 138 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
|---|
| 139 | + struct uniphier_aio *aio = uniphier_priv(asoc_rtd_to_cpu(rtd, 0)); |
|---|
| 154 | 140 | struct uniphier_aio_sub *sub = &aio->sub[substream->stream]; |
|---|
| 155 | 141 | struct device *dev = &aio->chip->pdev->dev; |
|---|
| 156 | 142 | int bytes = runtime->period_size * |
|---|
| .. | .. |
|---|
| 181 | 167 | } |
|---|
| 182 | 168 | |
|---|
| 183 | 169 | static snd_pcm_uframes_t uniphier_aiodma_pointer( |
|---|
| 170 | + struct snd_soc_component *component, |
|---|
| 184 | 171 | struct snd_pcm_substream *substream) |
|---|
| 185 | 172 | { |
|---|
| 186 | 173 | struct snd_pcm_runtime *runtime = substream->runtime; |
|---|
| 187 | | - struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream); |
|---|
| 188 | | - struct uniphier_aio *aio = uniphier_priv(rtd->cpu_dai); |
|---|
| 174 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
|---|
| 175 | + struct uniphier_aio *aio = uniphier_priv(asoc_rtd_to_cpu(rtd, 0)); |
|---|
| 189 | 176 | struct uniphier_aio_sub *sub = &aio->sub[substream->stream]; |
|---|
| 190 | 177 | int bytes = runtime->period_size * |
|---|
| 191 | 178 | runtime->channels * samples_to_bytes(runtime, 1); |
|---|
| .. | .. |
|---|
| 204 | 191 | return pos; |
|---|
| 205 | 192 | } |
|---|
| 206 | 193 | |
|---|
| 207 | | -static int uniphier_aiodma_mmap(struct snd_pcm_substream *substream, |
|---|
| 194 | +static int uniphier_aiodma_mmap(struct snd_soc_component *component, |
|---|
| 195 | + struct snd_pcm_substream *substream, |
|---|
| 208 | 196 | struct vm_area_struct *vma) |
|---|
| 209 | 197 | { |
|---|
| 210 | 198 | vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); |
|---|
| 211 | 199 | |
|---|
| 212 | 200 | return remap_pfn_range(vma, vma->vm_start, |
|---|
| 213 | | - substream->dma_buffer.addr >> PAGE_SHIFT, |
|---|
| 201 | + substream->runtime->dma_addr >> PAGE_SHIFT, |
|---|
| 214 | 202 | vma->vm_end - vma->vm_start, vma->vm_page_prot); |
|---|
| 215 | 203 | } |
|---|
| 216 | 204 | |
|---|
| 217 | | -static const struct snd_pcm_ops uniphier_aiodma_ops = { |
|---|
| 218 | | - .open = uniphier_aiodma_open, |
|---|
| 219 | | - .ioctl = snd_pcm_lib_ioctl, |
|---|
| 220 | | - .hw_params = uniphier_aiodma_hw_params, |
|---|
| 221 | | - .hw_free = uniphier_aiodma_hw_free, |
|---|
| 222 | | - .prepare = uniphier_aiodma_prepare, |
|---|
| 223 | | - .trigger = uniphier_aiodma_trigger, |
|---|
| 224 | | - .pointer = uniphier_aiodma_pointer, |
|---|
| 225 | | - .mmap = uniphier_aiodma_mmap, |
|---|
| 226 | | -}; |
|---|
| 227 | | - |
|---|
| 228 | | -static int uniphier_aiodma_new(struct snd_soc_pcm_runtime *rtd) |
|---|
| 205 | +static int uniphier_aiodma_new(struct snd_soc_component *component, |
|---|
| 206 | + struct snd_soc_pcm_runtime *rtd) |
|---|
| 229 | 207 | { |
|---|
| 230 | 208 | struct device *dev = rtd->card->snd_card->dev; |
|---|
| 231 | 209 | struct snd_pcm *pcm = rtd->pcm; |
|---|
| .. | .. |
|---|
| 235 | 213 | if (ret) |
|---|
| 236 | 214 | return ret; |
|---|
| 237 | 215 | |
|---|
| 238 | | - return snd_pcm_lib_preallocate_pages_for_all(pcm, |
|---|
| 216 | + snd_pcm_set_managed_buffer_all(pcm, |
|---|
| 239 | 217 | SNDRV_DMA_TYPE_DEV, dev, |
|---|
| 240 | 218 | uniphier_aiodma_hw.buffer_bytes_max, |
|---|
| 241 | 219 | uniphier_aiodma_hw.buffer_bytes_max); |
|---|
| 242 | | -} |
|---|
| 243 | | - |
|---|
| 244 | | -static void uniphier_aiodma_free(struct snd_pcm *pcm) |
|---|
| 245 | | -{ |
|---|
| 246 | | - snd_pcm_lib_preallocate_free_for_all(pcm); |
|---|
| 220 | + return 0; |
|---|
| 247 | 221 | } |
|---|
| 248 | 222 | |
|---|
| 249 | 223 | static const struct snd_soc_component_driver uniphier_soc_platform = { |
|---|
| 250 | | - .pcm_new = uniphier_aiodma_new, |
|---|
| 251 | | - .pcm_free = uniphier_aiodma_free, |
|---|
| 252 | | - .ops = &uniphier_aiodma_ops, |
|---|
| 253 | | - .compr_ops = &uniphier_aio_compr_ops, |
|---|
| 224 | + .open = uniphier_aiodma_open, |
|---|
| 225 | + .prepare = uniphier_aiodma_prepare, |
|---|
| 226 | + .trigger = uniphier_aiodma_trigger, |
|---|
| 227 | + .pointer = uniphier_aiodma_pointer, |
|---|
| 228 | + .mmap = uniphier_aiodma_mmap, |
|---|
| 229 | + .pcm_construct = uniphier_aiodma_new, |
|---|
| 230 | + .compress_ops = &uniphier_aio_compress_ops, |
|---|
| 254 | 231 | }; |
|---|
| 255 | 232 | |
|---|
| 256 | 233 | static const struct regmap_config aiodma_regmap_config = { |
|---|
| .. | .. |
|---|
| 275 | 252 | { |
|---|
| 276 | 253 | struct uniphier_aio_chip *chip = platform_get_drvdata(pdev); |
|---|
| 277 | 254 | struct device *dev = &pdev->dev; |
|---|
| 278 | | - struct resource *res; |
|---|
| 279 | 255 | void __iomem *preg; |
|---|
| 280 | 256 | int irq, ret; |
|---|
| 281 | 257 | |
|---|
| 282 | | - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
|---|
| 283 | | - preg = devm_ioremap_resource(dev, res); |
|---|
| 258 | + preg = devm_platform_ioremap_resource(pdev, 0); |
|---|
| 284 | 259 | if (IS_ERR(preg)) |
|---|
| 285 | 260 | return PTR_ERR(preg); |
|---|
| 286 | 261 | |
|---|
| .. | .. |
|---|
| 290 | 265 | return PTR_ERR(chip->regmap); |
|---|
| 291 | 266 | |
|---|
| 292 | 267 | irq = platform_get_irq(pdev, 0); |
|---|
| 293 | | - if (irq < 0) { |
|---|
| 294 | | - dev_err(dev, "Could not get irq.\n"); |
|---|
| 268 | + if (irq < 0) |
|---|
| 295 | 269 | return irq; |
|---|
| 296 | | - } |
|---|
| 297 | 270 | |
|---|
| 298 | 271 | ret = devm_request_irq(dev, irq, aiodma_irq, |
|---|
| 299 | 272 | IRQF_SHARED, dev_name(dev), pdev); |
|---|