hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/sound/soc/dwc/dwc-i2s.c
....@@ -132,13 +132,13 @@
132132
133133 /* Error Handling: TX */
134134 if (isr[i] & ISR_TXFO) {
135
- dev_err(dev->dev, "TX overrun (ch_id=%d)\n", i);
135
+ dev_err_ratelimited(dev->dev, "TX overrun (ch_id=%d)\n", i);
136136 irq_valid = true;
137137 }
138138
139139 /* Error Handling: TX */
140140 if (isr[i] & ISR_RXFO) {
141
- dev_err(dev->dev, "RX overrun (ch_id=%d)\n", i);
141
+ dev_err_ratelimited(dev->dev, "RX overrun (ch_id=%d)\n", i);
142142 irq_valid = true;
143143 }
144144 }
....@@ -181,30 +181,6 @@
181181 i2s_write_reg(dev->i2s_base, CER, 0);
182182 i2s_write_reg(dev->i2s_base, IER, 0);
183183 }
184
-}
185
-
186
-static int dw_i2s_startup(struct snd_pcm_substream *substream,
187
- struct snd_soc_dai *cpu_dai)
188
-{
189
- struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(cpu_dai);
190
- union dw_i2s_snd_dma_data *dma_data = NULL;
191
-
192
- if (!(dev->capability & DWC_I2S_RECORD) &&
193
- (substream->stream == SNDRV_PCM_STREAM_CAPTURE))
194
- return -EINVAL;
195
-
196
- if (!(dev->capability & DWC_I2S_PLAY) &&
197
- (substream->stream == SNDRV_PCM_STREAM_PLAYBACK))
198
- return -EINVAL;
199
-
200
- if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
201
- dma_data = &dev->play_dma_data;
202
- else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
203
- dma_data = &dev->capture_dma_data;
204
-
205
- snd_soc_dai_set_dma_data(cpu_dai, substream, (void *)dma_data);
206
-
207
- return 0;
208184 }
209185
210186 static void dw_i2s_config(struct dw_i2s_dev *dev, int stream)
....@@ -305,12 +281,6 @@
305281 return 0;
306282 }
307283
308
-static void dw_i2s_shutdown(struct snd_pcm_substream *substream,
309
- struct snd_soc_dai *dai)
310
-{
311
- snd_soc_dai_set_dma_data(dai, substream, NULL);
312
-}
313
-
314284 static int dw_i2s_prepare(struct snd_pcm_substream *substream,
315285 struct snd_soc_dai *dai)
316286 {
....@@ -382,16 +352,10 @@
382352 }
383353
384354 static const struct snd_soc_dai_ops dw_i2s_dai_ops = {
385
- .startup = dw_i2s_startup,
386
- .shutdown = dw_i2s_shutdown,
387355 .hw_params = dw_i2s_hw_params,
388356 .prepare = dw_i2s_prepare,
389357 .trigger = dw_i2s_trigger,
390358 .set_fmt = dw_i2s_set_fmt,
391
-};
392
-
393
-static const struct snd_soc_component_driver dw_i2s_component = {
394
- .name = "dw-i2s",
395359 };
396360
397361 #ifdef CONFIG_PM
....@@ -407,32 +371,43 @@
407371 static int dw_i2s_runtime_resume(struct device *dev)
408372 {
409373 struct dw_i2s_dev *dw_dev = dev_get_drvdata(dev);
374
+ int ret;
410375
411
- if (dw_dev->capability & DW_I2S_MASTER)
412
- clk_enable(dw_dev->clk);
376
+ if (dw_dev->capability & DW_I2S_MASTER) {
377
+ ret = clk_enable(dw_dev->clk);
378
+ if (ret)
379
+ return ret;
380
+ }
413381 return 0;
414382 }
415383
416
-static int dw_i2s_suspend(struct snd_soc_dai *dai)
384
+static int dw_i2s_suspend(struct snd_soc_component *component)
417385 {
418
- struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(dai);
386
+ struct dw_i2s_dev *dev = snd_soc_component_get_drvdata(component);
419387
420388 if (dev->capability & DW_I2S_MASTER)
421389 clk_disable(dev->clk);
422390 return 0;
423391 }
424392
425
-static int dw_i2s_resume(struct snd_soc_dai *dai)
393
+static int dw_i2s_resume(struct snd_soc_component *component)
426394 {
427
- struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(dai);
395
+ struct dw_i2s_dev *dev = snd_soc_component_get_drvdata(component);
396
+ struct snd_soc_dai *dai;
397
+ int stream, ret;
428398
429
- if (dev->capability & DW_I2S_MASTER)
430
- clk_enable(dev->clk);
399
+ if (dev->capability & DW_I2S_MASTER) {
400
+ ret = clk_enable(dev->clk);
401
+ if (ret)
402
+ return ret;
403
+ }
431404
432
- if (dai->playback_active)
433
- dw_i2s_config(dev, SNDRV_PCM_STREAM_PLAYBACK);
434
- if (dai->capture_active)
435
- dw_i2s_config(dev, SNDRV_PCM_STREAM_CAPTURE);
405
+ for_each_component_dais(component, dai) {
406
+ for_each_pcm_streams(stream)
407
+ if (snd_soc_dai_stream_active(dai, stream))
408
+ dw_i2s_config(dev, stream);
409
+ }
410
+
436411 return 0;
437412 }
438413
....@@ -440,6 +415,12 @@
440415 #define dw_i2s_suspend NULL
441416 #define dw_i2s_resume NULL
442417 #endif
418
+
419
+static const struct snd_soc_component_driver dw_i2s_component = {
420
+ .name = "dw-i2s",
421
+ .suspend = dw_i2s_suspend,
422
+ .resume = dw_i2s_resume,
423
+};
443424
444425 /*
445426 * The following tables allow a direct lookup of various parameters
....@@ -611,6 +592,14 @@
611592
612593 }
613594
595
+static int dw_i2s_dai_probe(struct snd_soc_dai *dai)
596
+{
597
+ struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(dai);
598
+
599
+ snd_soc_dai_init_dma_data(dai, &dev->play_dma_data, &dev->capture_dma_data);
600
+ return 0;
601
+}
602
+
614603 static int dw_i2s_probe(struct platform_device *pdev)
615604 {
616605 const struct i2s_platform_data *pdata = pdev->dev.platform_data;
....@@ -629,8 +618,7 @@
629618 return -ENOMEM;
630619
631620 dw_i2s_dai->ops = &dw_i2s_dai_ops;
632
- dw_i2s_dai->suspend = dw_i2s_suspend;
633
- dw_i2s_dai->resume = dw_i2s_resume;
621
+ dw_i2s_dai->probe = dw_i2s_dai_probe;
634622
635623 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
636624 dev->i2s_base = devm_ioremap_resource(&pdev->dev, res);