.. | .. |
---|
135 | 135 | dw_pcm_transfer(dev, false); |
---|
136 | 136 | } |
---|
137 | 137 | |
---|
138 | | -static int dw_pcm_open(struct snd_pcm_substream *substream) |
---|
| 138 | +static int dw_pcm_open(struct snd_soc_component *component, |
---|
| 139 | + struct snd_pcm_substream *substream) |
---|
139 | 140 | { |
---|
140 | 141 | struct snd_pcm_runtime *runtime = substream->runtime; |
---|
141 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
---|
142 | | - struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(rtd->cpu_dai); |
---|
| 142 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
---|
| 143 | + struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd, 0)); |
---|
143 | 144 | |
---|
144 | 145 | snd_soc_set_runtime_hwparams(substream, &dw_pcm_hardware); |
---|
145 | 146 | snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); |
---|
.. | .. |
---|
148 | 149 | return 0; |
---|
149 | 150 | } |
---|
150 | 151 | |
---|
151 | | -static int dw_pcm_close(struct snd_pcm_substream *substream) |
---|
| 152 | +static int dw_pcm_close(struct snd_soc_component *component, |
---|
| 153 | + struct snd_pcm_substream *substream) |
---|
152 | 154 | { |
---|
153 | 155 | synchronize_rcu(); |
---|
154 | 156 | return 0; |
---|
155 | 157 | } |
---|
156 | 158 | |
---|
157 | | -static int dw_pcm_hw_params(struct snd_pcm_substream *substream, |
---|
158 | | - struct snd_pcm_hw_params *hw_params) |
---|
| 159 | +static int dw_pcm_hw_params(struct snd_soc_component *component, |
---|
| 160 | + struct snd_pcm_substream *substream, |
---|
| 161 | + struct snd_pcm_hw_params *hw_params) |
---|
159 | 162 | { |
---|
160 | 163 | struct snd_pcm_runtime *runtime = substream->runtime; |
---|
161 | 164 | struct dw_i2s_dev *dev = runtime->private_data; |
---|
162 | | - int ret; |
---|
163 | 165 | |
---|
164 | 166 | switch (params_channels(hw_params)) { |
---|
165 | 167 | case 2: |
---|
.. | .. |
---|
184 | 186 | return -EINVAL; |
---|
185 | 187 | } |
---|
186 | 188 | |
---|
187 | | - ret = snd_pcm_lib_malloc_pages(substream, |
---|
188 | | - params_buffer_bytes(hw_params)); |
---|
189 | | - if (ret < 0) |
---|
190 | | - return ret; |
---|
191 | | - else |
---|
192 | | - return 0; |
---|
| 189 | + return 0; |
---|
193 | 190 | } |
---|
194 | 191 | |
---|
195 | | -static int dw_pcm_hw_free(struct snd_pcm_substream *substream) |
---|
196 | | -{ |
---|
197 | | - return snd_pcm_lib_free_pages(substream); |
---|
198 | | -} |
---|
199 | | - |
---|
200 | | -static int dw_pcm_trigger(struct snd_pcm_substream *substream, int cmd) |
---|
| 192 | +static int dw_pcm_trigger(struct snd_soc_component *component, |
---|
| 193 | + struct snd_pcm_substream *substream, int cmd) |
---|
201 | 194 | { |
---|
202 | 195 | struct snd_pcm_runtime *runtime = substream->runtime; |
---|
203 | 196 | struct dw_i2s_dev *dev = runtime->private_data; |
---|
.. | .. |
---|
231 | 224 | return ret; |
---|
232 | 225 | } |
---|
233 | 226 | |
---|
234 | | -static snd_pcm_uframes_t dw_pcm_pointer(struct snd_pcm_substream *substream) |
---|
| 227 | +static snd_pcm_uframes_t dw_pcm_pointer(struct snd_soc_component *component, |
---|
| 228 | + struct snd_pcm_substream *substream) |
---|
235 | 229 | { |
---|
236 | 230 | struct snd_pcm_runtime *runtime = substream->runtime; |
---|
237 | 231 | struct dw_i2s_dev *dev = runtime->private_data; |
---|
.. | .. |
---|
245 | 239 | return pos < runtime->buffer_size ? pos : 0; |
---|
246 | 240 | } |
---|
247 | 241 | |
---|
248 | | -static int dw_pcm_new(struct snd_soc_pcm_runtime *rtd) |
---|
| 242 | +static int dw_pcm_new(struct snd_soc_component *component, |
---|
| 243 | + struct snd_soc_pcm_runtime *rtd) |
---|
249 | 244 | { |
---|
250 | 245 | size_t size = dw_pcm_hardware.buffer_bytes_max; |
---|
251 | 246 | |
---|
252 | | - return snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, |
---|
| 247 | + snd_pcm_set_managed_buffer_all(rtd->pcm, |
---|
253 | 248 | SNDRV_DMA_TYPE_CONTINUOUS, |
---|
254 | | - snd_dma_continuous_data(GFP_KERNEL), size, size); |
---|
| 249 | + NULL, size, size); |
---|
| 250 | + return 0; |
---|
255 | 251 | } |
---|
256 | | - |
---|
257 | | -static void dw_pcm_free(struct snd_pcm *pcm) |
---|
258 | | -{ |
---|
259 | | - snd_pcm_lib_preallocate_free_for_all(pcm); |
---|
260 | | -} |
---|
261 | | - |
---|
262 | | -static const struct snd_pcm_ops dw_pcm_ops = { |
---|
263 | | - .open = dw_pcm_open, |
---|
264 | | - .close = dw_pcm_close, |
---|
265 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
266 | | - .hw_params = dw_pcm_hw_params, |
---|
267 | | - .hw_free = dw_pcm_hw_free, |
---|
268 | | - .trigger = dw_pcm_trigger, |
---|
269 | | - .pointer = dw_pcm_pointer, |
---|
270 | | -}; |
---|
271 | 252 | |
---|
272 | 253 | static const struct snd_soc_component_driver dw_pcm_component = { |
---|
273 | | - .pcm_new = dw_pcm_new, |
---|
274 | | - .pcm_free = dw_pcm_free, |
---|
275 | | - .ops = &dw_pcm_ops, |
---|
| 254 | + .open = dw_pcm_open, |
---|
| 255 | + .close = dw_pcm_close, |
---|
| 256 | + .hw_params = dw_pcm_hw_params, |
---|
| 257 | + .trigger = dw_pcm_trigger, |
---|
| 258 | + .pointer = dw_pcm_pointer, |
---|
| 259 | + .pcm_construct = dw_pcm_new, |
---|
276 | 260 | }; |
---|
277 | 261 | |
---|
278 | 262 | int dw_pcm_register(struct platform_device *pdev) |
---|