mtk-base-afe.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * mtk-base-afe.h -- Mediatek base afe structure
  4. *
  5. * Copyright (c) 2016 MediaTek Inc.
  6. * Author: Garlic Tseng <garlic.tseng@mediatek.com>
  7. */
  8. #ifndef _MTK_BASE_AFE_H_
  9. #define _MTK_BASE_AFE_H_
  10. #define MTK_STREAM_NUM (SNDRV_PCM_STREAM_LAST + 1)
  11. struct mtk_base_memif_data {
  12. int id;
  13. const char *name;
  14. int reg_ofs_base;
  15. int reg_ofs_cur;
  16. int fs_reg;
  17. int fs_shift;
  18. int fs_maskbit;
  19. int mono_reg;
  20. int mono_shift;
  21. int enable_reg;
  22. int enable_shift;
  23. int hd_reg;
  24. int hd_shift;
  25. int msb_reg;
  26. int msb_shift;
  27. int agent_disable_reg;
  28. int agent_disable_shift;
  29. };
  30. struct mtk_base_irq_data {
  31. int id;
  32. int irq_cnt_reg;
  33. int irq_cnt_shift;
  34. int irq_cnt_maskbit;
  35. int irq_fs_reg;
  36. int irq_fs_shift;
  37. int irq_fs_maskbit;
  38. int irq_en_reg;
  39. int irq_en_shift;
  40. int irq_clr_reg;
  41. int irq_clr_shift;
  42. };
  43. struct device;
  44. struct list_head;
  45. struct mtk_base_afe_memif;
  46. struct mtk_base_afe_irq;
  47. struct mtk_base_afe_dai;
  48. struct regmap;
  49. struct snd_pcm_substream;
  50. struct snd_soc_dai;
  51. struct mtk_base_afe {
  52. void __iomem *base_addr;
  53. struct device *dev;
  54. struct regmap *regmap;
  55. struct mutex irq_alloc_lock; /* dynamic alloc irq lock */
  56. unsigned int const *reg_back_up_list;
  57. unsigned int *reg_back_up;
  58. unsigned int reg_back_up_list_num;
  59. int (*runtime_suspend)(struct device *dev);
  60. int (*runtime_resume)(struct device *dev);
  61. bool suspended;
  62. struct mtk_base_afe_memif *memif;
  63. int memif_size;
  64. struct mtk_base_afe_irq *irqs;
  65. int irqs_size;
  66. struct list_head sub_dais;
  67. struct snd_soc_dai_driver *dai_drivers;
  68. unsigned int num_dai_drivers;
  69. const struct snd_pcm_hardware *mtk_afe_hardware;
  70. int (*memif_fs)(struct snd_pcm_substream *substream,
  71. unsigned int rate);
  72. int (*irq_fs)(struct snd_pcm_substream *substream,
  73. unsigned int rate);
  74. void *platform_priv;
  75. };
  76. struct mtk_base_afe_memif {
  77. unsigned int phys_buf_addr;
  78. int buffer_size;
  79. struct snd_pcm_substream *substream;
  80. const struct mtk_base_memif_data *data;
  81. int irq_usage;
  82. int const_irq;
  83. };
  84. struct mtk_base_afe_irq {
  85. const struct mtk_base_irq_data *irq_data;
  86. int irq_occupyed;
  87. };
  88. struct mtk_base_afe_dai {
  89. struct snd_soc_dai_driver *dai_drivers;
  90. unsigned int num_dai_drivers;
  91. const struct snd_kcontrol_new *controls;
  92. unsigned int num_controls;
  93. const struct snd_soc_dapm_widget *dapm_widgets;
  94. unsigned int num_dapm_widgets;
  95. const struct snd_soc_dapm_route *dapm_routes;
  96. unsigned int num_dapm_routes;
  97. struct list_head list;
  98. };
  99. #endif