0001
0002 #ifndef __SOUND_HDAUDIO_EXT_H
0003 #define __SOUND_HDAUDIO_EXT_H
0004
0005 #include <linux/io-64-nonatomic-lo-hi.h>
0006 #include <linux/iopoll.h>
0007 #include <sound/hdaudio.h>
0008
0009 int snd_hdac_ext_bus_init(struct hdac_bus *bus, struct device *dev,
0010 const struct hdac_bus_ops *ops,
0011 const struct hdac_ext_bus_ops *ext_ops);
0012
0013 void snd_hdac_ext_bus_exit(struct hdac_bus *bus);
0014 int snd_hdac_ext_bus_device_init(struct hdac_bus *bus, int addr,
0015 struct hdac_device *hdev, int type);
0016 void snd_hdac_ext_bus_device_exit(struct hdac_device *hdev);
0017 void snd_hdac_ext_bus_device_remove(struct hdac_bus *bus);
0018
0019 #define HDA_CODEC_REV_EXT_ENTRY(_vid, _rev, _name, drv_data) \
0020 { .vendor_id = (_vid), .rev_id = (_rev), .name = (_name), \
0021 .api_version = HDA_DEV_ASOC, \
0022 .driver_data = (unsigned long)(drv_data) }
0023 #define HDA_CODEC_EXT_ENTRY(_vid, _revid, _name, _drv_data) \
0024 HDA_CODEC_REV_EXT_ENTRY(_vid, _revid, _name, _drv_data)
0025
0026 void snd_hdac_ext_bus_ppcap_enable(struct hdac_bus *chip, bool enable);
0027 void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_bus *chip, bool enable);
0028
0029 void snd_hdac_ext_stream_spbcap_enable(struct hdac_bus *chip,
0030 bool enable, int index);
0031
0032 int snd_hdac_ext_bus_get_ml_capabilities(struct hdac_bus *bus);
0033 struct hdac_ext_link *snd_hdac_ext_bus_link_at(struct hdac_bus *bus, int addr);
0034 struct hdac_ext_link *snd_hdac_ext_bus_get_link(struct hdac_bus *bus,
0035 const char *codec_name);
0036
0037 enum hdac_ext_stream_type {
0038 HDAC_EXT_STREAM_TYPE_COUPLED = 0,
0039 HDAC_EXT_STREAM_TYPE_HOST,
0040 HDAC_EXT_STREAM_TYPE_LINK
0041 };
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059 struct hdac_ext_stream {
0060 struct hdac_stream hstream;
0061
0062 void __iomem *pphc_addr;
0063 void __iomem *pplc_addr;
0064
0065 void __iomem *spib_addr;
0066 void __iomem *fifo_addr;
0067
0068 void __iomem *dpibr_addr;
0069
0070 u32 dpib;
0071 u32 lpib;
0072 bool decoupled:1;
0073 bool link_locked:1;
0074 bool link_prepared;
0075
0076 struct snd_pcm_substream *link_substream;
0077 };
0078
0079 #define hdac_stream(s) (&(s)->hstream)
0080 #define stream_to_hdac_ext_stream(s) \
0081 container_of(s, struct hdac_ext_stream, hstream)
0082
0083 void snd_hdac_ext_stream_init(struct hdac_bus *bus,
0084 struct hdac_ext_stream *hext_stream, int idx,
0085 int direction, int tag);
0086 int snd_hdac_ext_stream_init_all(struct hdac_bus *bus, int start_idx,
0087 int num_stream, int dir);
0088 void snd_hdac_stream_free_all(struct hdac_bus *bus);
0089 void snd_hdac_link_free_all(struct hdac_bus *bus);
0090 struct hdac_ext_stream *snd_hdac_ext_stream_assign(struct hdac_bus *bus,
0091 struct snd_pcm_substream *substream,
0092 int type);
0093 void snd_hdac_ext_stream_release(struct hdac_ext_stream *hext_stream, int type);
0094 void snd_hdac_ext_stream_decouple_locked(struct hdac_bus *bus,
0095 struct hdac_ext_stream *hext_stream, bool decouple);
0096 void snd_hdac_ext_stream_decouple(struct hdac_bus *bus,
0097 struct hdac_ext_stream *azx_dev, bool decouple);
0098
0099 int snd_hdac_ext_stream_set_spib(struct hdac_bus *bus,
0100 struct hdac_ext_stream *hext_stream, u32 value);
0101 int snd_hdac_ext_stream_get_spbmaxfifo(struct hdac_bus *bus,
0102 struct hdac_ext_stream *hext_stream);
0103 void snd_hdac_ext_stream_drsm_enable(struct hdac_bus *bus,
0104 bool enable, int index);
0105 int snd_hdac_ext_stream_set_dpibr(struct hdac_bus *bus,
0106 struct hdac_ext_stream *hext_stream, u32 value);
0107 int snd_hdac_ext_stream_set_lpib(struct hdac_ext_stream *hext_stream, u32 value);
0108
0109 void snd_hdac_ext_link_stream_start(struct hdac_ext_stream *hext_stream);
0110 void snd_hdac_ext_link_stream_clear(struct hdac_ext_stream *hext_stream);
0111 void snd_hdac_ext_link_stream_reset(struct hdac_ext_stream *hext_stream);
0112 int snd_hdac_ext_link_stream_setup(struct hdac_ext_stream *hext_stream, int fmt);
0113
0114 struct hdac_ext_link {
0115 struct hdac_bus *bus;
0116 int index;
0117 void __iomem *ml_addr;
0118 u32 lcaps;
0119 u16 lsdiid;
0120
0121 int ref_count;
0122
0123 struct list_head list;
0124 };
0125
0126 int snd_hdac_ext_bus_link_power_up(struct hdac_ext_link *link);
0127 int snd_hdac_ext_bus_link_power_down(struct hdac_ext_link *link);
0128 int snd_hdac_ext_bus_link_power_up_all(struct hdac_bus *bus);
0129 int snd_hdac_ext_bus_link_power_down_all(struct hdac_bus *bus);
0130 void snd_hdac_ext_link_set_stream_id(struct hdac_ext_link *link,
0131 int stream);
0132 void snd_hdac_ext_link_clear_stream_id(struct hdac_ext_link *link,
0133 int stream);
0134
0135 int snd_hdac_ext_bus_link_get(struct hdac_bus *bus, struct hdac_ext_link *link);
0136 int snd_hdac_ext_bus_link_put(struct hdac_bus *bus, struct hdac_ext_link *link);
0137
0138 void snd_hdac_ext_bus_link_power(struct hdac_device *codec, bool enable);
0139
0140
0141 #define snd_hdac_updatel(addr, reg, mask, val) \
0142 writel(((readl(addr + reg) & ~(mask)) | (val)), \
0143 addr + reg)
0144
0145 #define snd_hdac_updatew(addr, reg, mask, val) \
0146 writew(((readw(addr + reg) & ~(mask)) | (val)), \
0147 addr + reg)
0148
0149 #define snd_hdac_adsp_writeb(chip, reg, value) \
0150 snd_hdac_reg_writeb(chip, (chip)->dsp_ba + (reg), value)
0151 #define snd_hdac_adsp_readb(chip, reg) \
0152 snd_hdac_reg_readb(chip, (chip)->dsp_ba + (reg))
0153 #define snd_hdac_adsp_writew(chip, reg, value) \
0154 snd_hdac_reg_writew(chip, (chip)->dsp_ba + (reg), value)
0155 #define snd_hdac_adsp_readw(chip, reg) \
0156 snd_hdac_reg_readw(chip, (chip)->dsp_ba + (reg))
0157 #define snd_hdac_adsp_writel(chip, reg, value) \
0158 snd_hdac_reg_writel(chip, (chip)->dsp_ba + (reg), value)
0159 #define snd_hdac_adsp_readl(chip, reg) \
0160 snd_hdac_reg_readl(chip, (chip)->dsp_ba + (reg))
0161 #define snd_hdac_adsp_writeq(chip, reg, value) \
0162 snd_hdac_reg_writeq(chip, (chip)->dsp_ba + (reg), value)
0163 #define snd_hdac_adsp_readq(chip, reg) \
0164 snd_hdac_reg_readq(chip, (chip)->dsp_ba + (reg))
0165
0166 #define snd_hdac_adsp_updateb(chip, reg, mask, val) \
0167 snd_hdac_adsp_writeb(chip, reg, \
0168 (snd_hdac_adsp_readb(chip, reg) & ~(mask)) | (val))
0169 #define snd_hdac_adsp_updatew(chip, reg, mask, val) \
0170 snd_hdac_adsp_writew(chip, reg, \
0171 (snd_hdac_adsp_readw(chip, reg) & ~(mask)) | (val))
0172 #define snd_hdac_adsp_updatel(chip, reg, mask, val) \
0173 snd_hdac_adsp_writel(chip, reg, \
0174 (snd_hdac_adsp_readl(chip, reg) & ~(mask)) | (val))
0175 #define snd_hdac_adsp_updateq(chip, reg, mask, val) \
0176 snd_hdac_adsp_writeq(chip, reg, \
0177 (snd_hdac_adsp_readq(chip, reg) & ~(mask)) | (val))
0178
0179 #define snd_hdac_adsp_readb_poll(chip, reg, val, cond, delay_us, timeout_us) \
0180 readb_poll_timeout((chip)->dsp_ba + (reg), val, cond, \
0181 delay_us, timeout_us)
0182 #define snd_hdac_adsp_readw_poll(chip, reg, val, cond, delay_us, timeout_us) \
0183 readw_poll_timeout((chip)->dsp_ba + (reg), val, cond, \
0184 delay_us, timeout_us)
0185 #define snd_hdac_adsp_readl_poll(chip, reg, val, cond, delay_us, timeout_us) \
0186 readl_poll_timeout((chip)->dsp_ba + (reg), val, cond, \
0187 delay_us, timeout_us)
0188 #define snd_hdac_adsp_readq_poll(chip, reg, val, cond, delay_us, timeout_us) \
0189 readq_poll_timeout((chip)->dsp_ba + (reg), val, cond, \
0190 delay_us, timeout_us)
0191 #define snd_hdac_stream_readb_poll(strm, reg, val, cond, delay_us, timeout_us) \
0192 readb_poll_timeout((strm)->sd_addr + AZX_REG_ ## reg, val, cond, \
0193 delay_us, timeout_us)
0194 #define snd_hdac_stream_readl_poll(strm, reg, val, cond, delay_us, timeout_us) \
0195 readl_poll_timeout((strm)->sd_addr + AZX_REG_ ## reg, val, cond, \
0196 delay_us, timeout_us)
0197
0198 struct hdac_ext_device;
0199
0200
0201 struct hdac_ext_codec_ops {
0202 int (*build_controls)(struct hdac_ext_device *dev);
0203 int (*init)(struct hdac_ext_device *dev);
0204 void (*free)(struct hdac_ext_device *dev);
0205 };
0206
0207 struct hda_dai_map {
0208 char *dai_name;
0209 hda_nid_t nid;
0210 u32 maxbps;
0211 };
0212
0213 struct hdac_ext_dma_params {
0214 u32 format;
0215 u8 stream_tag;
0216 };
0217
0218 int snd_hda_ext_driver_register(struct hdac_driver *drv);
0219 void snd_hda_ext_driver_unregister(struct hdac_driver *drv);
0220
0221 #endif