hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/sound/soc/mediatek/common/mtk-afe-platform-driver.c
....@@ -77,13 +77,12 @@
7777 }
7878 EXPORT_SYMBOL_GPL(mtk_afe_add_sub_dai_control);
7979
80
-static snd_pcm_uframes_t mtk_afe_pcm_pointer
81
- (struct snd_pcm_substream *substream)
80
+snd_pcm_uframes_t mtk_afe_pcm_pointer(struct snd_soc_component *component,
81
+ struct snd_pcm_substream *substream)
8282 {
83
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
84
- struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
83
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
8584 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
86
- struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id];
85
+ struct mtk_base_afe_memif *memif = &afe->memif[asoc_rtd_to_cpu(rtd, 0)->id];
8786 const struct mtk_base_memif_data *memif_data = memif->data;
8887 struct regmap *regmap = afe->regmap;
8988 struct device *dev = afe->dev;
....@@ -111,38 +110,26 @@
111110 POINTER_RETURN_FRAMES:
112111 return bytes_to_frames(substream->runtime, pcm_ptr_bytes);
113112 }
113
+EXPORT_SYMBOL_GPL(mtk_afe_pcm_pointer);
114114
115
-const struct snd_pcm_ops mtk_afe_pcm_ops = {
116
- .ioctl = snd_pcm_lib_ioctl,
117
- .pointer = mtk_afe_pcm_pointer,
118
-};
119
-EXPORT_SYMBOL_GPL(mtk_afe_pcm_ops);
120
-
121
-int mtk_afe_pcm_new(struct snd_soc_pcm_runtime *rtd)
115
+int mtk_afe_pcm_new(struct snd_soc_component *component,
116
+ struct snd_soc_pcm_runtime *rtd)
122117 {
123118 size_t size;
124119 struct snd_pcm *pcm = rtd->pcm;
125
- struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
126120 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
127121
128122 size = afe->mtk_afe_hardware->buffer_bytes_max;
129
- return snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
130
- afe->dev,
131
- size, size);
123
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
124
+ afe->dev, size, size);
125
+ return 0;
132126 }
133127 EXPORT_SYMBOL_GPL(mtk_afe_pcm_new);
134128
135
-void mtk_afe_pcm_free(struct snd_pcm *pcm)
136
-{
137
- snd_pcm_lib_preallocate_free_for_all(pcm);
138
-}
139
-EXPORT_SYMBOL_GPL(mtk_afe_pcm_free);
140
-
141129 const struct snd_soc_component_driver mtk_afe_pcm_platform = {
142
- .name = AFE_PCM_NAME,
143
- .ops = &mtk_afe_pcm_ops,
144
- .pcm_new = mtk_afe_pcm_new,
145
- .pcm_free = mtk_afe_pcm_free,
130
+ .name = AFE_PCM_NAME,
131
+ .pointer = mtk_afe_pcm_pointer,
132
+ .pcm_construct = mtk_afe_pcm_new,
146133 };
147134 EXPORT_SYMBOL_GPL(mtk_afe_pcm_platform);
148135