Lines Matching refs:afe
41 struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); in mtk_afe_fe_startup() local
44 struct mtk_base_afe_memif *memif = &afe->memif[memif_num]; in mtk_afe_fe_startup()
45 const struct snd_pcm_hardware *mtk_afe_hardware = afe->mtk_afe_hardware; in mtk_afe_fe_startup()
53 mtk_regmap_update_bits(afe->regmap, memif->data->agent_disable_reg, in mtk_afe_fe_startup()
71 dev_err(afe->dev, "hw_constraint_minmax failed\n"); in mtk_afe_fe_startup()
79 dev_err(afe->dev, "snd_pcm_hw_constraint_integer failed\n"); in mtk_afe_fe_startup()
83 int irq_id = mtk_dynamic_irq_acquire(afe); in mtk_afe_fe_startup()
85 if (irq_id != afe->irqs_size) { in mtk_afe_fe_startup()
89 dev_err(afe->dev, "%s() error: no more asys irq\n", in mtk_afe_fe_startup()
102 struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); in mtk_afe_fe_shutdown() local
103 struct mtk_base_afe_memif *memif = &afe->memif[asoc_rtd_to_cpu(rtd, 0)->id]; in mtk_afe_fe_shutdown()
108 mtk_regmap_update_bits(afe->regmap, memif->data->agent_disable_reg, in mtk_afe_fe_shutdown()
112 mtk_dynamic_irq_release(afe, irq_id); in mtk_afe_fe_shutdown()
124 struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); in mtk_afe_fe_hw_params() local
126 struct mtk_base_afe_memif *memif = &afe->memif[id]; in mtk_afe_fe_hw_params()
132 if (afe->request_dram_resource) in mtk_afe_fe_hw_params()
133 afe->request_dram_resource(afe->dev); in mtk_afe_fe_hw_params()
135 …dev_dbg(afe->dev, "%s(), %s, ch %d, rate %d, fmt %d, dma_addr %pad, dma_area %p, dma_bytes 0x%zx\n… in mtk_afe_fe_hw_params()
146 ret = mtk_memif_set_addr(afe, id, in mtk_afe_fe_hw_params()
151 dev_err(afe->dev, "%s(), error, id %d, set addr, ret %d\n", in mtk_afe_fe_hw_params()
157 ret = mtk_memif_set_channel(afe, id, channels); in mtk_afe_fe_hw_params()
159 dev_err(afe->dev, "%s(), error, id %d, set channel %d, ret %d\n", in mtk_afe_fe_hw_params()
167 dev_err(afe->dev, "%s(), error, id %d, set rate %d, ret %d\n", in mtk_afe_fe_hw_params()
173 ret = mtk_memif_set_format(afe, id, format); in mtk_afe_fe_hw_params()
175 dev_err(afe->dev, "%s(), error, id %d, set format %d, ret %d\n", in mtk_afe_fe_hw_params()
187 struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); in mtk_afe_fe_hw_free() local
189 if (afe->release_dram_resource) in mtk_afe_fe_hw_free()
190 afe->release_dram_resource(afe->dev); in mtk_afe_fe_hw_free()
201 struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); in mtk_afe_fe_trigger() local
203 struct mtk_base_afe_memif *memif = &afe->memif[id]; in mtk_afe_fe_trigger()
204 struct mtk_base_afe_irq *irqs = &afe->irqs[memif->irq_usage]; in mtk_afe_fe_trigger()
210 dev_dbg(afe->dev, "%s %s cmd=%d\n", __func__, memif->data->name, cmd); in mtk_afe_fe_trigger()
215 ret = mtk_memif_set_enable(afe, id); in mtk_afe_fe_trigger()
217 dev_err(afe->dev, "%s(), error, id %d, memif enable, ret %d\n", in mtk_afe_fe_trigger()
223 mtk_regmap_update_bits(afe->regmap, irq_data->irq_cnt_reg, in mtk_afe_fe_trigger()
228 fs = afe->irq_fs(substream, runtime->rate); in mtk_afe_fe_trigger()
233 mtk_regmap_update_bits(afe->regmap, irq_data->irq_fs_reg, in mtk_afe_fe_trigger()
238 mtk_regmap_update_bits(afe->regmap, irq_data->irq_en_reg, in mtk_afe_fe_trigger()
244 ret = mtk_memif_set_disable(afe, id); in mtk_afe_fe_trigger()
246 dev_err(afe->dev, "%s(), error, id %d, memif enable, ret %d\n", in mtk_afe_fe_trigger()
251 mtk_regmap_update_bits(afe->regmap, irq_data->irq_en_reg, in mtk_afe_fe_trigger()
254 mtk_regmap_write(afe->regmap, irq_data->irq_clr_reg, in mtk_afe_fe_trigger()
267 struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); in mtk_afe_fe_prepare() local
272 if (afe->get_memif_pbuf_size) { in mtk_afe_fe_prepare()
273 pbuf_size = afe->get_memif_pbuf_size(substream); in mtk_afe_fe_prepare()
274 mtk_memif_set_pbuf_size(afe, id, pbuf_size); in mtk_afe_fe_prepare()
291 int mtk_dynamic_irq_acquire(struct mtk_base_afe *afe) in mtk_dynamic_irq_acquire() argument
295 mutex_lock(&afe->irq_alloc_lock); in mtk_dynamic_irq_acquire()
296 for (i = 0; i < afe->irqs_size; ++i) { in mtk_dynamic_irq_acquire()
297 if (afe->irqs[i].irq_occupyed == 0) { in mtk_dynamic_irq_acquire()
298 afe->irqs[i].irq_occupyed = 1; in mtk_dynamic_irq_acquire()
299 mutex_unlock(&afe->irq_alloc_lock); in mtk_dynamic_irq_acquire()
303 mutex_unlock(&afe->irq_alloc_lock); in mtk_dynamic_irq_acquire()
304 return afe->irqs_size; in mtk_dynamic_irq_acquire()
308 int mtk_dynamic_irq_release(struct mtk_base_afe *afe, int irq_id) in mtk_dynamic_irq_release() argument
310 mutex_lock(&afe->irq_alloc_lock); in mtk_dynamic_irq_release()
311 if (irq_id >= 0 && irq_id < afe->irqs_size) { in mtk_dynamic_irq_release()
312 afe->irqs[irq_id].irq_occupyed = 0; in mtk_dynamic_irq_release()
313 mutex_unlock(&afe->irq_alloc_lock); in mtk_dynamic_irq_release()
316 mutex_unlock(&afe->irq_alloc_lock); in mtk_dynamic_irq_release()
323 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); in mtk_afe_suspend() local
324 struct device *dev = afe->dev; in mtk_afe_suspend()
325 struct regmap *regmap = afe->regmap; in mtk_afe_suspend()
328 if (pm_runtime_status_suspended(dev) || afe->suspended) in mtk_afe_suspend()
331 if (!afe->reg_back_up) in mtk_afe_suspend()
332 afe->reg_back_up = in mtk_afe_suspend()
333 devm_kcalloc(dev, afe->reg_back_up_list_num, in mtk_afe_suspend()
336 if (afe->reg_back_up) { in mtk_afe_suspend()
337 for (i = 0; i < afe->reg_back_up_list_num; i++) in mtk_afe_suspend()
338 regmap_read(regmap, afe->reg_back_up_list[i], in mtk_afe_suspend()
339 &afe->reg_back_up[i]); in mtk_afe_suspend()
342 afe->suspended = true; in mtk_afe_suspend()
343 afe->runtime_suspend(dev); in mtk_afe_suspend()
350 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); in mtk_afe_resume() local
351 struct device *dev = afe->dev; in mtk_afe_resume()
352 struct regmap *regmap = afe->regmap; in mtk_afe_resume()
355 if (pm_runtime_status_suspended(dev) || !afe->suspended) in mtk_afe_resume()
358 afe->runtime_resume(dev); in mtk_afe_resume()
360 if (!afe->reg_back_up) { in mtk_afe_resume()
363 for (i = 0; i < afe->reg_back_up_list_num; i++) in mtk_afe_resume()
364 mtk_regmap_write(regmap, afe->reg_back_up_list[i], in mtk_afe_resume()
365 afe->reg_back_up[i]); in mtk_afe_resume()
368 afe->suspended = false; in mtk_afe_resume()
373 int mtk_memif_set_enable(struct mtk_base_afe *afe, int id) in mtk_memif_set_enable() argument
375 struct mtk_base_afe_memif *memif = &afe->memif[id]; in mtk_memif_set_enable()
378 dev_warn(afe->dev, "%s(), error, id %d, enable_shift < 0\n", in mtk_memif_set_enable()
382 return mtk_regmap_update_bits(afe->regmap, memif->data->enable_reg, in mtk_memif_set_enable()
387 int mtk_memif_set_disable(struct mtk_base_afe *afe, int id) in mtk_memif_set_disable() argument
389 struct mtk_base_afe_memif *memif = &afe->memif[id]; in mtk_memif_set_disable()
392 dev_warn(afe->dev, "%s(), error, id %d, enable_shift < 0\n", in mtk_memif_set_disable()
396 return mtk_regmap_update_bits(afe->regmap, memif->data->enable_reg, in mtk_memif_set_disable()
401 int mtk_memif_set_addr(struct mtk_base_afe *afe, int id, in mtk_memif_set_addr() argument
406 struct mtk_base_afe_memif *memif = &afe->memif[id]; in mtk_memif_set_addr()
416 mtk_regmap_write(afe->regmap, memif->data->reg_ofs_base, in mtk_memif_set_addr()
420 mtk_regmap_write(afe->regmap, in mtk_memif_set_addr()
424 mtk_regmap_write(afe->regmap, in mtk_memif_set_addr()
431 mtk_regmap_write(afe->regmap, memif->data->reg_ofs_base_msb, in mtk_memif_set_addr()
433 mtk_regmap_write(afe->regmap, in mtk_memif_set_addr()
443 mtk_regmap_update_bits(afe->regmap, memif->data->msb_reg, in mtk_memif_set_addr()
448 mtk_regmap_update_bits(afe->regmap, memif->data->msb_end_reg, in mtk_memif_set_addr()
456 int mtk_memif_set_channel(struct mtk_base_afe *afe, in mtk_memif_set_channel() argument
459 struct mtk_base_afe_memif *memif = &afe->memif[id]; in mtk_memif_set_channel()
468 mtk_regmap_update_bits(afe->regmap, memif->data->quad_ch_reg, in mtk_memif_set_channel()
480 mtk_regmap_update_bits(afe->regmap, in mtk_memif_set_channel()
485 return mtk_regmap_update_bits(afe->regmap, memif->data->mono_reg, in mtk_memif_set_channel()
490 static int mtk_memif_set_rate_fs(struct mtk_base_afe *afe, in mtk_memif_set_rate_fs() argument
493 struct mtk_base_afe_memif *memif = &afe->memif[id]; in mtk_memif_set_rate_fs()
496 mtk_regmap_update_bits(afe->regmap, memif->data->fs_reg, in mtk_memif_set_rate_fs()
503 int mtk_memif_set_rate(struct mtk_base_afe *afe, in mtk_memif_set_rate() argument
508 if (!afe->get_dai_fs) { in mtk_memif_set_rate()
509 dev_err(afe->dev, "%s(), error, afe->get_dai_fs == NULL\n", in mtk_memif_set_rate()
514 fs = afe->get_dai_fs(afe, id, rate); in mtk_memif_set_rate()
519 return mtk_memif_set_rate_fs(afe, id, fs); in mtk_memif_set_rate()
529 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); in mtk_memif_set_rate_substream() local
533 if (!afe->memif_fs) { in mtk_memif_set_rate_substream()
534 dev_err(afe->dev, "%s(), error, afe->memif_fs == NULL\n", in mtk_memif_set_rate_substream()
539 fs = afe->memif_fs(substream, rate); in mtk_memif_set_rate_substream()
544 return mtk_memif_set_rate_fs(afe, id, fs); in mtk_memif_set_rate_substream()
548 int mtk_memif_set_format(struct mtk_base_afe *afe, in mtk_memif_set_format() argument
551 struct mtk_base_afe_memif *memif = &afe->memif[id]; in mtk_memif_set_format()
563 if (afe->memif_32bit_supported) { in mtk_memif_set_format()
576 dev_err(afe->dev, "%s() error: unsupported format %d\n", in mtk_memif_set_format()
581 mtk_regmap_update_bits(afe->regmap, memif->data->hd_reg, in mtk_memif_set_format()
584 mtk_regmap_update_bits(afe->regmap, memif->data->hd_align_reg, in mtk_memif_set_format()
591 int mtk_memif_set_pbuf_size(struct mtk_base_afe *afe, in mtk_memif_set_pbuf_size() argument
594 const struct mtk_base_memif_data *memif_data = afe->memif[id].data; in mtk_memif_set_pbuf_size()
599 mtk_regmap_update_bits(afe->regmap, memif_data->pbuf_reg, in mtk_memif_set_pbuf_size()
603 mtk_regmap_update_bits(afe->regmap, memif_data->minlen_reg, in mtk_memif_set_pbuf_size()