forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/sound/soc/dwc/dwc-pcm.c
....@@ -135,11 +135,12 @@
135135 dw_pcm_transfer(dev, false);
136136 }
137137
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)
139140 {
140141 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));
143144
144145 snd_soc_set_runtime_hwparams(substream, &dw_pcm_hardware);
145146 snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
....@@ -148,18 +149,19 @@
148149 return 0;
149150 }
150151
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)
152154 {
153155 synchronize_rcu();
154156 return 0;
155157 }
156158
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)
159162 {
160163 struct snd_pcm_runtime *runtime = substream->runtime;
161164 struct dw_i2s_dev *dev = runtime->private_data;
162
- int ret;
163165
164166 switch (params_channels(hw_params)) {
165167 case 2:
....@@ -184,20 +186,11 @@
184186 return -EINVAL;
185187 }
186188
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;
193190 }
194191
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)
201194 {
202195 struct snd_pcm_runtime *runtime = substream->runtime;
203196 struct dw_i2s_dev *dev = runtime->private_data;
....@@ -231,7 +224,8 @@
231224 return ret;
232225 }
233226
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)
235229 {
236230 struct snd_pcm_runtime *runtime = substream->runtime;
237231 struct dw_i2s_dev *dev = runtime->private_data;
....@@ -245,34 +239,24 @@
245239 return pos < runtime->buffer_size ? pos : 0;
246240 }
247241
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)
249244 {
250245 size_t size = dw_pcm_hardware.buffer_bytes_max;
251246
252
- return snd_pcm_lib_preallocate_pages_for_all(rtd->pcm,
247
+ snd_pcm_set_managed_buffer_all(rtd->pcm,
253248 SNDRV_DMA_TYPE_CONTINUOUS,
254
- snd_dma_continuous_data(GFP_KERNEL), size, size);
249
+ NULL, size, size);
250
+ return 0;
255251 }
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
-};
271252
272253 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,
276260 };
277261
278262 int dw_pcm_register(struct platform_device *pdev)