mtk-base-afe.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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 <[email protected]>
  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 reg_ofs_end;
  17. int reg_ofs_base_msb;
  18. int reg_ofs_cur_msb;
  19. int reg_ofs_end_msb;
  20. int fs_reg;
  21. int fs_shift;
  22. int fs_maskbit;
  23. int mono_reg;
  24. int mono_shift;
  25. int mono_invert;
  26. int quad_ch_reg;
  27. int quad_ch_mask;
  28. int quad_ch_shift;
  29. int int_odd_flag_reg;
  30. int int_odd_flag_shift;
  31. int enable_reg;
  32. int enable_shift;
  33. int hd_reg;
  34. int hd_shift;
  35. int hd_align_reg;
  36. int hd_align_mshift;
  37. int msb_reg;
  38. int msb_shift;
  39. int msb_end_reg;
  40. int msb_end_shift;
  41. int agent_disable_reg;
  42. int agent_disable_shift;
  43. int ch_num_reg;
  44. int ch_num_shift;
  45. int ch_num_maskbit;
  46. /* playback memif only */
  47. int pbuf_reg;
  48. int pbuf_mask;
  49. int pbuf_shift;
  50. int minlen_reg;
  51. int minlen_mask;
  52. int minlen_shift;
  53. };
  54. struct mtk_base_irq_data {
  55. int id;
  56. int irq_cnt_reg;
  57. int irq_cnt_shift;
  58. int irq_cnt_maskbit;
  59. int irq_fs_reg;
  60. int irq_fs_shift;
  61. int irq_fs_maskbit;
  62. int irq_en_reg;
  63. int irq_en_shift;
  64. int irq_clr_reg;
  65. int irq_clr_shift;
  66. int irq_status_shift;
  67. };
  68. struct device;
  69. struct list_head;
  70. struct mtk_base_afe_memif;
  71. struct mtk_base_afe_irq;
  72. struct mtk_base_afe_dai;
  73. struct regmap;
  74. struct snd_pcm_substream;
  75. struct snd_soc_dai;
  76. struct mtk_base_afe {
  77. void __iomem *base_addr;
  78. struct device *dev;
  79. struct regmap *regmap;
  80. struct mutex irq_alloc_lock; /* dynamic alloc irq lock */
  81. unsigned int const *reg_back_up_list;
  82. unsigned int *reg_back_up;
  83. unsigned int reg_back_up_list_num;
  84. int (*runtime_suspend)(struct device *dev);
  85. int (*runtime_resume)(struct device *dev);
  86. bool suspended;
  87. struct mtk_base_afe_memif *memif;
  88. int memif_size;
  89. struct mtk_base_afe_irq *irqs;
  90. int irqs_size;
  91. int memif_32bit_supported;
  92. struct list_head sub_dais;
  93. struct snd_soc_dai_driver *dai_drivers;
  94. unsigned int num_dai_drivers;
  95. const struct snd_pcm_hardware *mtk_afe_hardware;
  96. int (*memif_fs)(struct snd_pcm_substream *substream,
  97. unsigned int rate);
  98. int (*irq_fs)(struct snd_pcm_substream *substream,
  99. unsigned int rate);
  100. int (*get_dai_fs)(struct mtk_base_afe *afe,
  101. int dai_id, unsigned int rate);
  102. int (*get_memif_pbuf_size)(struct snd_pcm_substream *substream);
  103. int (*request_dram_resource)(struct device *dev);
  104. int (*release_dram_resource)(struct device *dev);
  105. void *platform_priv;
  106. };
  107. struct mtk_base_afe_memif {
  108. unsigned int phys_buf_addr;
  109. int buffer_size;
  110. struct snd_pcm_substream *substream;
  111. const struct mtk_base_memif_data *data;
  112. int irq_usage;
  113. int const_irq;
  114. unsigned char *dma_area;
  115. dma_addr_t dma_addr;
  116. size_t dma_bytes;
  117. };
  118. struct mtk_base_afe_irq {
  119. const struct mtk_base_irq_data *irq_data;
  120. int irq_occupyed;
  121. };
  122. struct mtk_base_afe_dai {
  123. struct snd_soc_dai_driver *dai_drivers;
  124. unsigned int num_dai_drivers;
  125. const struct snd_kcontrol_new *controls;
  126. unsigned int num_controls;
  127. const struct snd_soc_dapm_widget *dapm_widgets;
  128. unsigned int num_dapm_widgets;
  129. const struct snd_soc_dapm_route *dapm_routes;
  130. unsigned int num_dapm_routes;
  131. struct list_head list;
  132. };
  133. #endif