forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 1f93a7dfd1f8d5ff7a5c53246c7534fe2332d6f4
kernel/sound/soc/rockchip/rockchip_multi_dais_pcm.c
....@@ -330,7 +330,8 @@
330330 }
331331 #endif
332332
333
-static int snd_dmaengine_mpcm_trigger(struct snd_pcm_substream *substream, int cmd)
333
+static int snd_dmaengine_mpcm_trigger(struct snd_soc_component *component,
334
+ struct snd_pcm_substream *substream, int cmd)
334335 {
335336 struct dmaengine_mpcm_runtime_data *prtd = substream_to_prtd(substream);
336337 struct snd_pcm_runtime *runtime = substream->runtime;
....@@ -377,12 +378,10 @@
377378 return 0;
378379 }
379380
380
-static int dmaengine_mpcm_hw_params(struct snd_pcm_substream *substream,
381
+static int dmaengine_mpcm_hw_params(struct snd_soc_component *component,
382
+ struct snd_pcm_substream *substream,
381383 struct snd_pcm_hw_params *params)
382384 {
383
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
384
- struct snd_soc_component *component =
385
- snd_soc_rtdcom_lookup(rtd, SND_DMAENGINE_MPCM_DRV_NAME);
386385 struct dmaengine_mpcm *pcm = soc_component_to_mpcm(component);
387386 struct dma_chan *chan;
388387 struct snd_dmaengine_dai_dma_data *dma_data;
....@@ -420,18 +419,22 @@
420419 sz = snd_pcm_format_size(format, maps[i]);
421420 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
422421 chan = pcm->tx_chans[i];
422
+#ifdef CONFIG_NO_GKI
423423 if (sz) {
424424 slave_config.src_interlace_size = frame_bytes - sz;
425425 if (slave_config.src_interlace_size)
426426 slave_config.dst_maxburst = sz / slave_config.dst_addr_width;
427427 }
428
+#endif
428429 } else {
429430 chan = pcm->rx_chans[i];
431
+#ifdef CONFIG_NO_GKI
430432 if (sz) {
431433 slave_config.dst_interlace_size = frame_bytes - sz;
432434 if (slave_config.dst_interlace_size)
433435 slave_config.src_maxburst = sz / slave_config.src_addr_width;
434436 }
437
+#endif
435438 }
436439 if (!chan)
437440 continue;
....@@ -515,11 +518,9 @@
515518 return snd_soc_set_runtime_hwparams(substream, &hw);
516519 }
517520
518
-static int dmaengine_mpcm_open(struct snd_pcm_substream *substream)
521
+static int dmaengine_mpcm_open(struct snd_soc_component *component,
522
+ struct snd_pcm_substream *substream)
519523 {
520
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
521
- struct snd_soc_component *component =
522
- snd_soc_rtdcom_lookup(rtd, SND_DMAENGINE_MPCM_DRV_NAME);
523524 struct dmaengine_mpcm *pcm = soc_component_to_mpcm(component);
524525 struct dmaengine_mpcm_runtime_data *prtd;
525526 int ret, i;
....@@ -554,16 +555,13 @@
554555 return 0;
555556 }
556557
557
-static int dmaengine_mpcm_new(struct snd_soc_pcm_runtime *rtd)
558
+static int dmaengine_mpcm_new(struct snd_soc_component *component, struct snd_soc_pcm_runtime *rtd)
558559 {
559
- struct snd_soc_component *component =
560
- snd_soc_rtdcom_lookup(rtd, SND_DMAENGINE_MPCM_DRV_NAME);
561560 struct dmaengine_mpcm *pcm = soc_component_to_mpcm(component);
562561 struct snd_pcm_substream *substream;
563562 size_t prealloc_buffer_size;
564563 size_t max_buffer_size;
565564 unsigned int i;
566
- int ret;
567565
568566 prealloc_buffer_size = 512 * 1024;
569567 max_buffer_size = SIZE_MAX;
....@@ -573,19 +571,18 @@
573571 if (!substream)
574572 continue;
575573
576
- ret = snd_pcm_lib_preallocate_pages(substream,
577
- SNDRV_DMA_TYPE_DEV_IRAM,
578
- dmaengine_dma_dev(pcm, substream),
579
- prealloc_buffer_size,
580
- max_buffer_size);
581
- if (ret)
582
- return ret;
574
+ snd_pcm_lib_preallocate_pages(substream,
575
+ SNDRV_DMA_TYPE_DEV_IRAM,
576
+ dmaengine_dma_dev(pcm, substream),
577
+ prealloc_buffer_size,
578
+ max_buffer_size);
583579 }
584580
585581 return 0;
586582 }
587583
588
-static snd_pcm_uframes_t dmaengine_mpcm_pointer(struct snd_pcm_substream *substream)
584
+static snd_pcm_uframes_t dmaengine_mpcm_pointer(struct snd_soc_component *component,
585
+ struct snd_pcm_substream *substream)
589586 {
590587 struct dmaengine_mpcm_runtime_data *prtd = substream_to_prtd(substream);
591588 struct snd_pcm_runtime *runtime = substream->runtime;
....@@ -601,6 +598,9 @@
601598 pos = buf_size - state.residue;
602599
603600 frames = bytes_to_frames(substream->runtime, pos);
601
+ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
602
+ return frames;
603
+
604604 #ifdef CONFIG_SND_SOC_ROCKCHIP_VAD
605605 if (prtd->vpos)
606606 frames = bytes_to_frames(substream->runtime, prtd->vpos);
....@@ -620,7 +620,21 @@
620620 return frames;
621621 }
622622
623
-static int dmaengine_mpcm_close(struct snd_pcm_substream *substream)
623
+static int dmaengine_mpcm_ioctl(struct snd_soc_component *component,
624
+ struct snd_pcm_substream *substream,
625
+ unsigned int cmd, void *arg)
626
+{
627
+ return snd_pcm_lib_ioctl(substream, cmd, arg);
628
+}
629
+
630
+static int dmaengine_mpcm_hw_free(struct snd_soc_component *component,
631
+ struct snd_pcm_substream *substream)
632
+{
633
+ return snd_pcm_lib_free_pages(substream);
634
+}
635
+
636
+static int dmaengine_mpcm_close(struct snd_soc_component *component,
637
+ struct snd_pcm_substream *substream)
624638 {
625639 struct dmaengine_mpcm_runtime_data *prtd = substream_to_prtd(substream);
626640
....@@ -629,21 +643,17 @@
629643 return 0;
630644 }
631645
632
-static const struct snd_pcm_ops dmaengine_mpcm_ops = {
633
- .open = dmaengine_mpcm_open,
634
- .close = dmaengine_mpcm_close,
635
- .ioctl = snd_pcm_lib_ioctl,
636
- .hw_params = dmaengine_mpcm_hw_params,
637
- .hw_free = snd_pcm_lib_free_pages,
638
- .trigger = snd_dmaengine_mpcm_trigger,
639
- .pointer = dmaengine_mpcm_pointer,
640
-};
641
-
642646 static const struct snd_soc_component_driver dmaengine_mpcm_platform = {
643647 .name = SND_DMAENGINE_MPCM_DRV_NAME,
644648 .probe_order = SND_SOC_COMP_ORDER_LATE,
645
- .ops = &dmaengine_mpcm_ops,
646
- .pcm_new = dmaengine_mpcm_new,
649
+ .pcm_construct = dmaengine_mpcm_new,
650
+ .open = dmaengine_mpcm_open,
651
+ .close = dmaengine_mpcm_close,
652
+ .ioctl = dmaengine_mpcm_ioctl,
653
+ .hw_params = dmaengine_mpcm_hw_params,
654
+ .hw_free = dmaengine_mpcm_hw_free,
655
+ .trigger = snd_dmaengine_mpcm_trigger,
656
+ .pointer = dmaengine_mpcm_pointer,
647657 };
648658
649659 static void dmaengine_mpcm_release_chan(struct dmaengine_mpcm *pcm)
....@@ -693,8 +703,12 @@
693703 }
694704 }
695705
696
- ret = snd_soc_add_component(dev, &pcm->component,
697
- &dmaengine_mpcm_platform, NULL, 0);
706
+ ret = snd_soc_component_initialize(&pcm->component, &dmaengine_mpcm_platform,
707
+ dev);
708
+ if (ret)
709
+ goto err_free_dma;
710
+
711
+ ret = snd_soc_add_component(&pcm->component, NULL, 0);
698712 if (ret)
699713 goto err_free_dma;
700714