linux/sound/soc/mediatek/common/mtk-base-afe.h
<<
>>
Prefs
   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
   9#ifndef _MTK_BASE_AFE_H_
  10#define _MTK_BASE_AFE_H_
  11
  12#define MTK_STREAM_NUM (SNDRV_PCM_STREAM_LAST + 1)
  13
  14struct mtk_base_memif_data {
  15        int id;
  16        const char *name;
  17        int reg_ofs_base;
  18        int reg_ofs_cur;
  19        int reg_ofs_end;
  20        int reg_ofs_base_msb;
  21        int reg_ofs_cur_msb;
  22        int reg_ofs_end_msb;
  23        int fs_reg;
  24        int fs_shift;
  25        int fs_maskbit;
  26        int mono_reg;
  27        int mono_shift;
  28        int mono_invert;
  29        int quad_ch_reg;
  30        int quad_ch_mask;
  31        int quad_ch_shift;
  32        int enable_reg;
  33        int enable_shift;
  34        int hd_reg;
  35        int hd_shift;
  36        int hd_align_reg;
  37        int hd_align_mshift;
  38        int msb_reg;
  39        int msb_shift;
  40        int msb2_reg;
  41        int msb2_shift;
  42        int agent_disable_reg;
  43        int agent_disable_shift;
  44        /* playback memif only */
  45        int pbuf_reg;
  46        int pbuf_mask;
  47        int pbuf_shift;
  48        int minlen_reg;
  49        int minlen_mask;
  50        int minlen_shift;
  51};
  52
  53struct mtk_base_irq_data {
  54        int id;
  55        int irq_cnt_reg;
  56        int irq_cnt_shift;
  57        int irq_cnt_maskbit;
  58        int irq_fs_reg;
  59        int irq_fs_shift;
  60        int irq_fs_maskbit;
  61        int irq_en_reg;
  62        int irq_en_shift;
  63        int irq_clr_reg;
  64        int irq_clr_shift;
  65};
  66
  67struct device;
  68struct list_head;
  69struct mtk_base_afe_memif;
  70struct mtk_base_afe_irq;
  71struct mtk_base_afe_dai;
  72struct regmap;
  73struct snd_pcm_substream;
  74struct snd_soc_dai;
  75
  76struct 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
  82        unsigned int const *reg_back_up_list;
  83        unsigned int *reg_back_up;
  84        unsigned int reg_back_up_list_num;
  85
  86        int (*runtime_suspend)(struct device *dev);
  87        int (*runtime_resume)(struct device *dev);
  88        bool suspended;
  89
  90        struct mtk_base_afe_memif *memif;
  91        int memif_size;
  92        struct mtk_base_afe_irq *irqs;
  93        int irqs_size;
  94
  95        struct list_head sub_dais;
  96        struct snd_soc_dai_driver *dai_drivers;
  97        unsigned int num_dai_drivers;
  98
  99        const struct snd_pcm_hardware *mtk_afe_hardware;
 100        int (*memif_fs)(struct snd_pcm_substream *substream,
 101                        unsigned int rate);
 102        int (*irq_fs)(struct snd_pcm_substream *substream,
 103                      unsigned int rate);
 104        int (*get_dai_fs)(struct mtk_base_afe *afe,
 105                          int dai_id, unsigned int rate);
 106        int (*get_memif_pbuf_size)(struct snd_pcm_substream *substream);
 107
 108        int (*request_dram_resource)(struct device *dev);
 109        int (*release_dram_resource)(struct device *dev);
 110
 111        void *platform_priv;
 112};
 113
 114struct mtk_base_afe_memif {
 115        unsigned int phys_buf_addr;
 116        int buffer_size;
 117        struct snd_pcm_substream *substream;
 118        const struct mtk_base_memif_data *data;
 119        int irq_usage;
 120        int const_irq;
 121        unsigned char *dma_area;
 122        dma_addr_t dma_addr;
 123        size_t dma_bytes;
 124};
 125
 126struct mtk_base_afe_irq {
 127        const struct mtk_base_irq_data *irq_data;
 128        int irq_occupyed;
 129};
 130
 131struct mtk_base_afe_dai {
 132        struct snd_soc_dai_driver *dai_drivers;
 133        unsigned int num_dai_drivers;
 134
 135        const struct snd_kcontrol_new *controls;
 136        unsigned int num_controls;
 137        const struct snd_soc_dapm_widget *dapm_widgets;
 138        unsigned int num_dapm_widgets;
 139        const struct snd_soc_dapm_route *dapm_routes;
 140        unsigned int num_dapm_routes;
 141
 142        struct list_head list;
 143};
 144
 145#endif
 146
 147