forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/sound/soc/sh/fsi.c
....@@ -406,9 +406,9 @@
406406
407407 static struct snd_soc_dai *fsi_get_dai(struct snd_pcm_substream *substream)
408408 {
409
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
409
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
410410
411
- return rtd->cpu_dai;
411
+ return asoc_rtd_to_cpu(rtd, 0);
412412 }
413413
414414 static struct fsi_priv *fsi_get_priv_frm_dai(struct snd_soc_dai *dai)
....@@ -780,7 +780,7 @@
780780 return -EINVAL;
781781 }
782782 if (clock->div == clock->own) {
783
- dev_err(dev, "cpu doens't support div clock\n");
783
+ dev_err(dev, "cpu doesn't support div clock\n");
784784 return -EINVAL;
785785 }
786786 }
....@@ -816,13 +816,26 @@
816816 return ret;
817817 }
818818
819
- clk_enable(clock->xck);
820
- clk_enable(clock->ick);
821
- clk_enable(clock->div);
819
+ ret = clk_enable(clock->xck);
820
+ if (ret)
821
+ goto err;
822
+ ret = clk_enable(clock->ick);
823
+ if (ret)
824
+ goto disable_xck;
825
+ ret = clk_enable(clock->div);
826
+ if (ret)
827
+ goto disable_ick;
822828
823829 clock->count++;
824830 }
825831
832
+ return ret;
833
+
834
+disable_ick:
835
+ clk_disable(clock->ick);
836
+disable_xck:
837
+ clk_disable(clock->xck);
838
+err:
826839 return ret;
827840 }
828841
....@@ -1632,12 +1645,12 @@
16321645 struct fsi_priv *fsi = fsi_get_priv_frm_dai(dai);
16331646 int ret;
16341647
1635
- /* set master/slave audio interface */
1648
+ /* set clock master audio interface */
16361649 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
16371650 case SND_SOC_DAIFMT_CBM_CFM:
16381651 break;
16391652 case SND_SOC_DAIFMT_CBS_CFS:
1640
- fsi->clk_master = 1; /* codec is slave, cpu is master */
1653
+ fsi->clk_master = 1; /* cpu is master */
16411654 break;
16421655 default:
16431656 return -EINVAL;
....@@ -1718,7 +1731,8 @@
17181731 .fifo_size = 256,
17191732 };
17201733
1721
-static int fsi_pcm_open(struct snd_pcm_substream *substream)
1734
+static int fsi_pcm_open(struct snd_soc_component *component,
1735
+ struct snd_pcm_substream *substream)
17221736 {
17231737 struct snd_pcm_runtime *runtime = substream->runtime;
17241738 int ret = 0;
....@@ -1731,33 +1745,14 @@
17311745 return ret;
17321746 }
17331747
1734
-static int fsi_hw_params(struct snd_pcm_substream *substream,
1735
- struct snd_pcm_hw_params *hw_params)
1736
-{
1737
- return snd_pcm_lib_malloc_pages(substream,
1738
- params_buffer_bytes(hw_params));
1739
-}
1740
-
1741
-static int fsi_hw_free(struct snd_pcm_substream *substream)
1742
-{
1743
- return snd_pcm_lib_free_pages(substream);
1744
-}
1745
-
1746
-static snd_pcm_uframes_t fsi_pointer(struct snd_pcm_substream *substream)
1748
+static snd_pcm_uframes_t fsi_pointer(struct snd_soc_component *component,
1749
+ struct snd_pcm_substream *substream)
17471750 {
17481751 struct fsi_priv *fsi = fsi_get_priv(substream);
17491752 struct fsi_stream *io = fsi_stream_get(fsi, substream);
17501753
17511754 return fsi_sample2frame(fsi, io->buff_sample_pos);
17521755 }
1753
-
1754
-static const struct snd_pcm_ops fsi_pcm_ops = {
1755
- .open = fsi_pcm_open,
1756
- .ioctl = snd_pcm_lib_ioctl,
1757
- .hw_params = fsi_hw_params,
1758
- .hw_free = fsi_hw_free,
1759
- .pointer = fsi_pointer,
1760
-};
17611756
17621757 /*
17631758 * snd_soc_component
....@@ -1766,13 +1761,15 @@
17661761 #define PREALLOC_BUFFER (32 * 1024)
17671762 #define PREALLOC_BUFFER_MAX (32 * 1024)
17681763
1769
-static int fsi_pcm_new(struct snd_soc_pcm_runtime *rtd)
1764
+static int fsi_pcm_new(struct snd_soc_component *component,
1765
+ struct snd_soc_pcm_runtime *rtd)
17701766 {
1771
- return snd_pcm_lib_preallocate_pages_for_all(
1767
+ snd_pcm_set_managed_buffer_all(
17721768 rtd->pcm,
17731769 SNDRV_DMA_TYPE_DEV,
17741770 rtd->card->snd_card->dev,
17751771 PREALLOC_BUFFER, PREALLOC_BUFFER_MAX);
1772
+ return 0;
17761773 }
17771774
17781775 /*
....@@ -1816,8 +1813,9 @@
18161813
18171814 static const struct snd_soc_component_driver fsi_soc_component = {
18181815 .name = "fsi",
1819
- .ops = &fsi_pcm_ops,
1820
- .pcm_new = fsi_pcm_new,
1816
+ .open = fsi_pcm_open,
1817
+ .pointer = fsi_pointer,
1818
+ .pcm_construct = fsi_pcm_new,
18211819 };
18221820
18231821 /*
....@@ -1953,8 +1951,7 @@
19531951 if (!master)
19541952 return -ENOMEM;
19551953
1956
- master->base = devm_ioremap_nocache(&pdev->dev,
1957
- res->start, resource_size(res));
1954
+ master->base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
19581955 if (!master->base) {
19591956 dev_err(&pdev->dev, "Unable to ioremap FSI registers.\n");
19601957 return -ENXIO;