diff options
author | Ryder Lee <ryder.lee@mediatek.com> | 2018-04-25 00:19:54 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2018-04-25 14:05:43 -0400 |
commit | e4b31b816c472ba5907b01a6f6a1626c1e8d51ef (patch) | |
tree | 1aaed736f7c483665f0ef029decf45b25c5c42d6 | |
parent | 22d9f80904b4510296c133db15f8d3291292023b (diff) |
ASoC: mediatek: use snd_soc_dai_get_drvdata() to get the private data
Reduce the boilerplate code to retrieve the private data.
No functional change intended.
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Reviewed-by: Garlic Tseng <garlic.tseng@mediatek.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | sound/soc/mediatek/common/mtk-afe-fe-dai.c | 20 | ||||
-rw-r--r-- | sound/soc/mediatek/mt2701/mt2701-afe-pcm.c | 86 | ||||
-rw-r--r-- | sound/soc/mediatek/mt8173/mt8173-afe-pcm.c | 28 |
3 files changed, 46 insertions, 88 deletions
diff --git a/sound/soc/mediatek/common/mtk-afe-fe-dai.c b/sound/soc/mediatek/common/mtk-afe-fe-dai.c index c91e5f4cd902..ac61ff3ccbe4 100644 --- a/sound/soc/mediatek/common/mtk-afe-fe-dai.c +++ b/sound/soc/mediatek/common/mtk-afe-fe-dai.c | |||
@@ -44,8 +44,7 @@ int mtk_afe_fe_startup(struct snd_pcm_substream *substream, | |||
44 | struct snd_soc_dai *dai) | 44 | struct snd_soc_dai *dai) |
45 | { | 45 | { |
46 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 46 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
47 | struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); | 47 | struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); |
48 | struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); | ||
49 | struct snd_pcm_runtime *runtime = substream->runtime; | 48 | struct snd_pcm_runtime *runtime = substream->runtime; |
50 | int memif_num = rtd->cpu_dai->id; | 49 | int memif_num = rtd->cpu_dai->id; |
51 | struct mtk_base_afe_memif *memif = &afe->memif[memif_num]; | 50 | struct mtk_base_afe_memif *memif = &afe->memif[memif_num]; |
@@ -107,8 +106,7 @@ void mtk_afe_fe_shutdown(struct snd_pcm_substream *substream, | |||
107 | struct snd_soc_dai *dai) | 106 | struct snd_soc_dai *dai) |
108 | { | 107 | { |
109 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 108 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
110 | struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); | 109 | struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); |
111 | struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); | ||
112 | struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id]; | 110 | struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id]; |
113 | int irq_id; | 111 | int irq_id; |
114 | 112 | ||
@@ -131,8 +129,7 @@ int mtk_afe_fe_hw_params(struct snd_pcm_substream *substream, | |||
131 | struct snd_soc_dai *dai) | 129 | struct snd_soc_dai *dai) |
132 | { | 130 | { |
133 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 131 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
134 | struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); | 132 | struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); |
135 | struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); | ||
136 | struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id]; | 133 | struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id]; |
137 | int msb_at_bit33 = 0; | 134 | int msb_at_bit33 = 0; |
138 | int ret, fs = 0; | 135 | int ret, fs = 0; |
@@ -196,8 +193,7 @@ int mtk_afe_fe_trigger(struct snd_pcm_substream *substream, int cmd, | |||
196 | { | 193 | { |
197 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 194 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
198 | struct snd_pcm_runtime * const runtime = substream->runtime; | 195 | struct snd_pcm_runtime * const runtime = substream->runtime; |
199 | struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); | 196 | struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); |
200 | struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); | ||
201 | struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id]; | 197 | struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id]; |
202 | struct mtk_base_afe_irq *irqs = &afe->irqs[memif->irq_usage]; | 198 | struct mtk_base_afe_irq *irqs = &afe->irqs[memif->irq_usage]; |
203 | const struct mtk_base_irq_data *irq_data = irqs->irq_data; | 199 | const struct mtk_base_irq_data *irq_data = irqs->irq_data; |
@@ -260,8 +256,7 @@ int mtk_afe_fe_prepare(struct snd_pcm_substream *substream, | |||
260 | struct snd_soc_dai *dai) | 256 | struct snd_soc_dai *dai) |
261 | { | 257 | { |
262 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 258 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
263 | struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); | 259 | struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); |
264 | struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); | ||
265 | struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id]; | 260 | struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id]; |
266 | int hd_audio = 0; | 261 | int hd_audio = 0; |
267 | 262 | ||
@@ -333,7 +328,7 @@ EXPORT_SYMBOL_GPL(mtk_dynamic_irq_release); | |||
333 | 328 | ||
334 | int mtk_afe_dai_suspend(struct snd_soc_dai *dai) | 329 | int mtk_afe_dai_suspend(struct snd_soc_dai *dai) |
335 | { | 330 | { |
336 | struct mtk_base_afe *afe = dev_get_drvdata(dai->dev); | 331 | struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); |
337 | struct device *dev = afe->dev; | 332 | struct device *dev = afe->dev; |
338 | struct regmap *regmap = afe->regmap; | 333 | struct regmap *regmap = afe->regmap; |
339 | int i; | 334 | int i; |
@@ -358,7 +353,7 @@ EXPORT_SYMBOL_GPL(mtk_afe_dai_suspend); | |||
358 | 353 | ||
359 | int mtk_afe_dai_resume(struct snd_soc_dai *dai) | 354 | int mtk_afe_dai_resume(struct snd_soc_dai *dai) |
360 | { | 355 | { |
361 | struct mtk_base_afe *afe = dev_get_drvdata(dai->dev); | 356 | struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); |
362 | struct device *dev = afe->dev; | 357 | struct device *dev = afe->dev; |
363 | struct regmap *regmap = afe->regmap; | 358 | struct regmap *regmap = afe->regmap; |
364 | int i = 0; | 359 | int i = 0; |
@@ -383,4 +378,3 @@ EXPORT_SYMBOL_GPL(mtk_afe_dai_resume); | |||
383 | MODULE_DESCRIPTION("Mediatek simple fe dai operator"); | 378 | MODULE_DESCRIPTION("Mediatek simple fe dai operator"); |
384 | MODULE_AUTHOR("Garlic Tseng <garlic.tseng@mediatek.com>"); | 379 | MODULE_AUTHOR("Garlic Tseng <garlic.tseng@mediatek.com>"); |
385 | MODULE_LICENSE("GPL v2"); | 380 | MODULE_LICENSE("GPL v2"); |
386 | |||
diff --git a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c index 73cce33fa439..8219f5534150 100644 --- a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c +++ b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c | |||
@@ -92,9 +92,7 @@ static int mt2701_afe_i2s_fs(unsigned int sample_rate) | |||
92 | static int mt2701_afe_i2s_startup(struct snd_pcm_substream *substream, | 92 | static int mt2701_afe_i2s_startup(struct snd_pcm_substream *substream, |
93 | struct snd_soc_dai *dai) | 93 | struct snd_soc_dai *dai) |
94 | { | 94 | { |
95 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 95 | struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); |
96 | struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); | ||
97 | struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); | ||
98 | int i2s_num = mt2701_dai_num_to_i2s(afe, dai->id); | 96 | int i2s_num = mt2701_dai_num_to_i2s(afe, dai->id); |
99 | 97 | ||
100 | if (i2s_num < 0) | 98 | if (i2s_num < 0) |
@@ -108,9 +106,7 @@ static int mt2701_afe_i2s_path_shutdown(struct snd_pcm_substream *substream, | |||
108 | int i2s_num, | 106 | int i2s_num, |
109 | int dir_invert) | 107 | int dir_invert) |
110 | { | 108 | { |
111 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 109 | struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); |
112 | struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); | ||
113 | struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); | ||
114 | struct mt2701_afe_private *afe_priv = afe->platform_priv; | 110 | struct mt2701_afe_private *afe_priv = afe->platform_priv; |
115 | struct mt2701_i2s_path *i2s_path = &afe_priv->i2s_path[i2s_num]; | 111 | struct mt2701_i2s_path *i2s_path = &afe_priv->i2s_path[i2s_num]; |
116 | const struct mt2701_i2s_data *i2s_data; | 112 | const struct mt2701_i2s_data *i2s_data; |
@@ -145,9 +141,7 @@ static int mt2701_afe_i2s_path_shutdown(struct snd_pcm_substream *substream, | |||
145 | static void mt2701_afe_i2s_shutdown(struct snd_pcm_substream *substream, | 141 | static void mt2701_afe_i2s_shutdown(struct snd_pcm_substream *substream, |
146 | struct snd_soc_dai *dai) | 142 | struct snd_soc_dai *dai) |
147 | { | 143 | { |
148 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 144 | struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); |
149 | struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); | ||
150 | struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); | ||
151 | struct mt2701_afe_private *afe_priv = afe->platform_priv; | 145 | struct mt2701_afe_private *afe_priv = afe->platform_priv; |
152 | int i2s_num = mt2701_dai_num_to_i2s(afe, dai->id); | 146 | int i2s_num = mt2701_dai_num_to_i2s(afe, dai->id); |
153 | struct mt2701_i2s_path *i2s_path; | 147 | struct mt2701_i2s_path *i2s_path; |
@@ -178,16 +172,14 @@ static int mt2701_i2s_path_prepare_enable(struct snd_pcm_substream *substream, | |||
178 | int i2s_num, | 172 | int i2s_num, |
179 | int dir_invert) | 173 | int dir_invert) |
180 | { | 174 | { |
181 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 175 | struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); |
182 | struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); | ||
183 | struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); | ||
184 | struct mt2701_afe_private *afe_priv = afe->platform_priv; | 176 | struct mt2701_afe_private *afe_priv = afe->platform_priv; |
185 | struct mt2701_i2s_path *i2s_path = &afe_priv->i2s_path[i2s_num]; | 177 | struct mt2701_i2s_path *i2s_path = &afe_priv->i2s_path[i2s_num]; |
186 | const struct mt2701_i2s_data *i2s_data; | 178 | const struct mt2701_i2s_data *i2s_data; |
187 | struct snd_pcm_runtime * const runtime = substream->runtime; | 179 | struct snd_pcm_runtime * const runtime = substream->runtime; |
188 | int reg, fs, w_len = 1; /* now we support bck 64bits only */ | 180 | int reg, fs, w_len = 1; /* now we support bck 64bits only */ |
189 | int stream_dir = substream->stream; | 181 | int stream_dir = substream->stream; |
190 | unsigned int mask = 0, val = 0; | 182 | unsigned int mask, val; |
191 | 183 | ||
192 | if (dir_invert) { | 184 | if (dir_invert) { |
193 | if (stream_dir == SNDRV_PCM_STREAM_PLAYBACK) | 185 | if (stream_dir == SNDRV_PCM_STREAM_PLAYBACK) |
@@ -250,9 +242,7 @@ static int mt2701_afe_i2s_prepare(struct snd_pcm_substream *substream, | |||
250 | struct snd_soc_dai *dai) | 242 | struct snd_soc_dai *dai) |
251 | { | 243 | { |
252 | int clk_domain; | 244 | int clk_domain; |
253 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 245 | struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); |
254 | struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); | ||
255 | struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); | ||
256 | struct mt2701_afe_private *afe_priv = afe->platform_priv; | 246 | struct mt2701_afe_private *afe_priv = afe->platform_priv; |
257 | int i2s_num = mt2701_dai_num_to_i2s(afe, dai->id); | 247 | int i2s_num = mt2701_dai_num_to_i2s(afe, dai->id); |
258 | struct mt2701_i2s_path *i2s_path; | 248 | struct mt2701_i2s_path *i2s_path; |
@@ -295,7 +285,7 @@ static int mt2701_afe_i2s_prepare(struct snd_pcm_substream *substream, | |||
295 | static int mt2701_afe_i2s_set_sysclk(struct snd_soc_dai *dai, int clk_id, | 285 | static int mt2701_afe_i2s_set_sysclk(struct snd_soc_dai *dai, int clk_id, |
296 | unsigned int freq, int dir) | 286 | unsigned int freq, int dir) |
297 | { | 287 | { |
298 | struct mtk_base_afe *afe = dev_get_drvdata(dai->dev); | 288 | struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); |
299 | struct mt2701_afe_private *afe_priv = afe->platform_priv; | 289 | struct mt2701_afe_private *afe_priv = afe->platform_priv; |
300 | int i2s_num = mt2701_dai_num_to_i2s(afe, dai->id); | 290 | int i2s_num = mt2701_dai_num_to_i2s(afe, dai->id); |
301 | 291 | ||
@@ -309,16 +299,16 @@ static int mt2701_afe_i2s_set_sysclk(struct snd_soc_dai *dai, int clk_id, | |||
309 | __func__); | 299 | __func__); |
310 | return -EINVAL; | 300 | return -EINVAL; |
311 | } | 301 | } |
302 | |||
312 | afe_priv->i2s_path[i2s_num].mclk_rate = freq; | 303 | afe_priv->i2s_path[i2s_num].mclk_rate = freq; |
304 | |||
313 | return 0; | 305 | return 0; |
314 | } | 306 | } |
315 | 307 | ||
316 | static int mt2701_btmrg_startup(struct snd_pcm_substream *substream, | 308 | static int mt2701_btmrg_startup(struct snd_pcm_substream *substream, |
317 | struct snd_soc_dai *dai) | 309 | struct snd_soc_dai *dai) |
318 | { | 310 | { |
319 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 311 | struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); |
320 | struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); | ||
321 | struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); | ||
322 | struct mt2701_afe_private *afe_priv = afe->platform_priv; | 312 | struct mt2701_afe_private *afe_priv = afe->platform_priv; |
323 | int ret; | 313 | int ret; |
324 | 314 | ||
@@ -327,6 +317,7 @@ static int mt2701_btmrg_startup(struct snd_pcm_substream *substream, | |||
327 | return ret; | 317 | return ret; |
328 | 318 | ||
329 | afe_priv->mrg_enable[substream->stream] = 1; | 319 | afe_priv->mrg_enable[substream->stream] = 1; |
320 | |||
330 | return 0; | 321 | return 0; |
331 | } | 322 | } |
332 | 323 | ||
@@ -334,17 +325,14 @@ static int mt2701_btmrg_hw_params(struct snd_pcm_substream *substream, | |||
334 | struct snd_pcm_hw_params *params, | 325 | struct snd_pcm_hw_params *params, |
335 | struct snd_soc_dai *dai) | 326 | struct snd_soc_dai *dai) |
336 | { | 327 | { |
337 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 328 | struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); |
338 | struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); | ||
339 | struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); | ||
340 | int stream_fs; | 329 | int stream_fs; |
341 | u32 val, msk; | 330 | u32 val, msk; |
342 | 331 | ||
343 | stream_fs = params_rate(params); | 332 | stream_fs = params_rate(params); |
344 | 333 | ||
345 | if ((stream_fs != 8000) && (stream_fs != 16000)) { | 334 | if (stream_fs != 8000 && stream_fs != 16000) { |
346 | dev_err(afe->dev, "%s() btmgr not support this stream_fs %d\n", | 335 | dev_err(afe->dev, "unsupported rate %d\n", stream_fs); |
347 | __func__, stream_fs); | ||
348 | return -EINVAL; | 336 | return -EINVAL; |
349 | } | 337 | } |
350 | 338 | ||
@@ -378,9 +366,7 @@ static int mt2701_btmrg_hw_params(struct snd_pcm_substream *substream, | |||
378 | static void mt2701_btmrg_shutdown(struct snd_pcm_substream *substream, | 366 | static void mt2701_btmrg_shutdown(struct snd_pcm_substream *substream, |
379 | struct snd_soc_dai *dai) | 367 | struct snd_soc_dai *dai) |
380 | { | 368 | { |
381 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 369 | struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); |
382 | struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); | ||
383 | struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); | ||
384 | struct mt2701_afe_private *afe_priv = afe->platform_priv; | 370 | struct mt2701_afe_private *afe_priv = afe->platform_priv; |
385 | 371 | ||
386 | /* if the other direction stream is not occupied */ | 372 | /* if the other direction stream is not occupied */ |
@@ -393,28 +379,26 @@ static void mt2701_btmrg_shutdown(struct snd_pcm_substream *substream, | |||
393 | AFE_MRGIF_CON_MRG_I2S_EN, 0); | 379 | AFE_MRGIF_CON_MRG_I2S_EN, 0); |
394 | mt2701_disable_btmrg_clk(afe); | 380 | mt2701_disable_btmrg_clk(afe); |
395 | } | 381 | } |
382 | |||
396 | afe_priv->mrg_enable[substream->stream] = 0; | 383 | afe_priv->mrg_enable[substream->stream] = 0; |
397 | } | 384 | } |
398 | 385 | ||
399 | static int mt2701_simple_fe_startup(struct snd_pcm_substream *substream, | 386 | static int mt2701_simple_fe_startup(struct snd_pcm_substream *substream, |
400 | struct snd_soc_dai *dai) | 387 | struct snd_soc_dai *dai) |
401 | { | 388 | { |
402 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 389 | struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); |
403 | struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); | ||
404 | struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); | ||
405 | int stream_dir = substream->stream; | ||
406 | int memif_num = rtd->cpu_dai->id; | ||
407 | struct mtk_base_afe_memif *memif_tmp; | 390 | struct mtk_base_afe_memif *memif_tmp; |
391 | int stream_dir = substream->stream; | ||
408 | 392 | ||
409 | /* can't run single DL & DLM at the same time */ | 393 | /* can't run single DL & DLM at the same time */ |
410 | if (stream_dir == SNDRV_PCM_STREAM_PLAYBACK) { | 394 | if (stream_dir == SNDRV_PCM_STREAM_PLAYBACK) { |
411 | memif_tmp = &afe->memif[MT2701_MEMIF_DLM]; | 395 | memif_tmp = &afe->memif[MT2701_MEMIF_DLM]; |
412 | if (memif_tmp->substream) { | 396 | if (memif_tmp->substream) { |
413 | dev_warn(afe->dev, "%s memif is not available, stream_dir %d, memif_num %d\n", | 397 | dev_warn(afe->dev, "memif is not available"); |
414 | __func__, stream_dir, memif_num); | ||
415 | return -EBUSY; | 398 | return -EBUSY; |
416 | } | 399 | } |
417 | } | 400 | } |
401 | |||
418 | return mtk_afe_fe_startup(substream, dai); | 402 | return mtk_afe_fe_startup(substream, dai); |
419 | } | 403 | } |
420 | 404 | ||
@@ -422,27 +406,23 @@ static int mt2701_simple_fe_hw_params(struct snd_pcm_substream *substream, | |||
422 | struct snd_pcm_hw_params *params, | 406 | struct snd_pcm_hw_params *params, |
423 | struct snd_soc_dai *dai) | 407 | struct snd_soc_dai *dai) |
424 | { | 408 | { |
425 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 409 | struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); |
426 | struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); | ||
427 | struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); | ||
428 | int stream_dir = substream->stream; | 410 | int stream_dir = substream->stream; |
429 | 411 | ||
430 | /* single DL use PAIR_INTERLEAVE */ | 412 | /* single DL use PAIR_INTERLEAVE */ |
431 | if (stream_dir == SNDRV_PCM_STREAM_PLAYBACK) { | 413 | if (stream_dir == SNDRV_PCM_STREAM_PLAYBACK) |
432 | regmap_update_bits(afe->regmap, | 414 | regmap_update_bits(afe->regmap, |
433 | AFE_MEMIF_PBUF_SIZE, | 415 | AFE_MEMIF_PBUF_SIZE, |
434 | AFE_MEMIF_PBUF_SIZE_DLM_MASK, | 416 | AFE_MEMIF_PBUF_SIZE_DLM_MASK, |
435 | AFE_MEMIF_PBUF_SIZE_PAIR_INTERLEAVE); | 417 | AFE_MEMIF_PBUF_SIZE_PAIR_INTERLEAVE); |
436 | } | 418 | |
437 | return mtk_afe_fe_hw_params(substream, params, dai); | 419 | return mtk_afe_fe_hw_params(substream, params, dai); |
438 | } | 420 | } |
439 | 421 | ||
440 | static int mt2701_dlm_fe_startup(struct snd_pcm_substream *substream, | 422 | static int mt2701_dlm_fe_startup(struct snd_pcm_substream *substream, |
441 | struct snd_soc_dai *dai) | 423 | struct snd_soc_dai *dai) |
442 | { | 424 | { |
443 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 425 | struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); |
444 | struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); | ||
445 | struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); | ||
446 | struct mtk_base_afe_memif *memif_tmp; | 426 | struct mtk_base_afe_memif *memif_tmp; |
447 | const struct mtk_base_memif_data *memif_data; | 427 | const struct mtk_base_memif_data *memif_data; |
448 | int i; | 428 | int i; |
@@ -468,9 +448,7 @@ static int mt2701_dlm_fe_startup(struct snd_pcm_substream *substream, | |||
468 | static void mt2701_dlm_fe_shutdown(struct snd_pcm_substream *substream, | 448 | static void mt2701_dlm_fe_shutdown(struct snd_pcm_substream *substream, |
469 | struct snd_soc_dai *dai) | 449 | struct snd_soc_dai *dai) |
470 | { | 450 | { |
471 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 451 | struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); |
472 | struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); | ||
473 | struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); | ||
474 | const struct mtk_base_memif_data *memif_data; | 452 | const struct mtk_base_memif_data *memif_data; |
475 | int i; | 453 | int i; |
476 | 454 | ||
@@ -481,6 +459,7 @@ static void mt2701_dlm_fe_shutdown(struct snd_pcm_substream *substream, | |||
481 | 1 << memif_data->agent_disable_shift, | 459 | 1 << memif_data->agent_disable_shift, |
482 | 1 << memif_data->agent_disable_shift); | 460 | 1 << memif_data->agent_disable_shift); |
483 | } | 461 | } |
462 | |||
484 | return mtk_afe_fe_shutdown(substream, dai); | 463 | return mtk_afe_fe_shutdown(substream, dai); |
485 | } | 464 | } |
486 | 465 | ||
@@ -488,9 +467,7 @@ static int mt2701_dlm_fe_hw_params(struct snd_pcm_substream *substream, | |||
488 | struct snd_pcm_hw_params *params, | 467 | struct snd_pcm_hw_params *params, |
489 | struct snd_soc_dai *dai) | 468 | struct snd_soc_dai *dai) |
490 | { | 469 | { |
491 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 470 | struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); |
492 | struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); | ||
493 | struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); | ||
494 | int channels = params_channels(params); | 471 | int channels = params_channels(params); |
495 | 472 | ||
496 | regmap_update_bits(afe->regmap, | 473 | regmap_update_bits(afe->regmap, |
@@ -512,9 +489,7 @@ static int mt2701_dlm_fe_hw_params(struct snd_pcm_substream *substream, | |||
512 | static int mt2701_dlm_fe_trigger(struct snd_pcm_substream *substream, | 489 | static int mt2701_dlm_fe_trigger(struct snd_pcm_substream *substream, |
513 | int cmd, struct snd_soc_dai *dai) | 490 | int cmd, struct snd_soc_dai *dai) |
514 | { | 491 | { |
515 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 492 | struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); |
516 | struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); | ||
517 | struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); | ||
518 | struct mtk_base_afe_memif *memif_tmp = &afe->memif[MT2701_MEMIF_DL1]; | 493 | struct mtk_base_afe_memif *memif_tmp = &afe->memif[MT2701_MEMIF_DL1]; |
519 | 494 | ||
520 | switch (cmd) { | 495 | switch (cmd) { |
@@ -547,6 +522,7 @@ static int mt2701_memif_fs(struct snd_pcm_substream *substream, | |||
547 | fs = mt2701_afe_i2s_fs(rate); | 522 | fs = mt2701_afe_i2s_fs(rate); |
548 | else | 523 | else |
549 | fs = (rate == 16000 ? 1 : 0); | 524 | fs = (rate == 16000 ? 1 : 0); |
525 | |||
550 | return fs; | 526 | return fs; |
551 | } | 527 | } |
552 | 528 | ||
@@ -1398,10 +1374,12 @@ static irqreturn_t mt2701_asys_isr(int irq_id, void *dev) | |||
1398 | memif = &afe->memif[id]; | 1374 | memif = &afe->memif[id]; |
1399 | if (memif->irq_usage < 0) | 1375 | if (memif->irq_usage < 0) |
1400 | continue; | 1376 | continue; |
1377 | |||
1401 | irq = &afe->irqs[memif->irq_usage]; | 1378 | irq = &afe->irqs[memif->irq_usage]; |
1402 | if (status & 1 << (irq->irq_data->irq_clr_shift)) | 1379 | if (status & 1 << irq->irq_data->irq_clr_shift) |
1403 | snd_pcm_period_elapsed(memif->substream); | 1380 | snd_pcm_period_elapsed(memif->substream); |
1404 | } | 1381 | } |
1382 | |||
1405 | return IRQ_HANDLED; | 1383 | return IRQ_HANDLED; |
1406 | } | 1384 | } |
1407 | 1385 | ||
diff --git a/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c b/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c index 65d1433a0944..22881a9e111e 100644 --- a/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c +++ b/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c | |||
@@ -303,9 +303,7 @@ static void mt8173_afe_dais_disable_clks(struct mtk_base_afe *afe, | |||
303 | static int mt8173_afe_i2s_startup(struct snd_pcm_substream *substream, | 303 | static int mt8173_afe_i2s_startup(struct snd_pcm_substream *substream, |
304 | struct snd_soc_dai *dai) | 304 | struct snd_soc_dai *dai) |
305 | { | 305 | { |
306 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 306 | struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); |
307 | struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); | ||
308 | struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); | ||
309 | 307 | ||
310 | if (dai->active) | 308 | if (dai->active) |
311 | return 0; | 309 | return 0; |
@@ -318,9 +316,7 @@ static int mt8173_afe_i2s_startup(struct snd_pcm_substream *substream, | |||
318 | static void mt8173_afe_i2s_shutdown(struct snd_pcm_substream *substream, | 316 | static void mt8173_afe_i2s_shutdown(struct snd_pcm_substream *substream, |
319 | struct snd_soc_dai *dai) | 317 | struct snd_soc_dai *dai) |
320 | { | 318 | { |
321 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 319 | struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); |
322 | struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); | ||
323 | struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); | ||
324 | 320 | ||
325 | if (dai->active) | 321 | if (dai->active) |
326 | return; | 322 | return; |
@@ -334,10 +330,8 @@ static void mt8173_afe_i2s_shutdown(struct snd_pcm_substream *substream, | |||
334 | static int mt8173_afe_i2s_prepare(struct snd_pcm_substream *substream, | 330 | static int mt8173_afe_i2s_prepare(struct snd_pcm_substream *substream, |
335 | struct snd_soc_dai *dai) | 331 | struct snd_soc_dai *dai) |
336 | { | 332 | { |
337 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
338 | struct snd_pcm_runtime * const runtime = substream->runtime; | 333 | struct snd_pcm_runtime * const runtime = substream->runtime; |
339 | struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); | 334 | struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); |
340 | struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); | ||
341 | struct mt8173_afe_private *afe_priv = afe->platform_priv; | 335 | struct mt8173_afe_private *afe_priv = afe->platform_priv; |
342 | int ret; | 336 | int ret; |
343 | 337 | ||
@@ -358,9 +352,7 @@ static int mt8173_afe_i2s_prepare(struct snd_pcm_substream *substream, | |||
358 | static int mt8173_afe_hdmi_startup(struct snd_pcm_substream *substream, | 352 | static int mt8173_afe_hdmi_startup(struct snd_pcm_substream *substream, |
359 | struct snd_soc_dai *dai) | 353 | struct snd_soc_dai *dai) |
360 | { | 354 | { |
361 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 355 | struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); |
362 | struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); | ||
363 | struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); | ||
364 | struct mt8173_afe_private *afe_priv = afe->platform_priv; | 356 | struct mt8173_afe_private *afe_priv = afe->platform_priv; |
365 | 357 | ||
366 | if (dai->active) | 358 | if (dai->active) |
@@ -374,9 +366,7 @@ static int mt8173_afe_hdmi_startup(struct snd_pcm_substream *substream, | |||
374 | static void mt8173_afe_hdmi_shutdown(struct snd_pcm_substream *substream, | 366 | static void mt8173_afe_hdmi_shutdown(struct snd_pcm_substream *substream, |
375 | struct snd_soc_dai *dai) | 367 | struct snd_soc_dai *dai) |
376 | { | 368 | { |
377 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 369 | struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); |
378 | struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); | ||
379 | struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); | ||
380 | struct mt8173_afe_private *afe_priv = afe->platform_priv; | 370 | struct mt8173_afe_private *afe_priv = afe->platform_priv; |
381 | 371 | ||
382 | if (dai->active) | 372 | if (dai->active) |
@@ -389,10 +379,8 @@ static void mt8173_afe_hdmi_shutdown(struct snd_pcm_substream *substream, | |||
389 | static int mt8173_afe_hdmi_prepare(struct snd_pcm_substream *substream, | 379 | static int mt8173_afe_hdmi_prepare(struct snd_pcm_substream *substream, |
390 | struct snd_soc_dai *dai) | 380 | struct snd_soc_dai *dai) |
391 | { | 381 | { |
392 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
393 | struct snd_pcm_runtime * const runtime = substream->runtime; | 382 | struct snd_pcm_runtime * const runtime = substream->runtime; |
394 | struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); | 383 | struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); |
395 | struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); | ||
396 | struct mt8173_afe_private *afe_priv = afe->platform_priv; | 384 | struct mt8173_afe_private *afe_priv = afe->platform_priv; |
397 | 385 | ||
398 | unsigned int val; | 386 | unsigned int val; |
@@ -454,9 +442,7 @@ static int mt8173_afe_hdmi_prepare(struct snd_pcm_substream *substream, | |||
454 | static int mt8173_afe_hdmi_trigger(struct snd_pcm_substream *substream, int cmd, | 442 | static int mt8173_afe_hdmi_trigger(struct snd_pcm_substream *substream, int cmd, |
455 | struct snd_soc_dai *dai) | 443 | struct snd_soc_dai *dai) |
456 | { | 444 | { |
457 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 445 | struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); |
458 | struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); | ||
459 | struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); | ||
460 | 446 | ||
461 | dev_info(afe->dev, "%s cmd=%d %s\n", __func__, cmd, dai->name); | 447 | dev_info(afe->dev, "%s cmd=%d %s\n", __func__, cmd, dai->name); |
462 | 448 | ||