HDAudio drivers make heavy use of I/O operations. Declare a range of update, read and write helpers similar to those available for HDAudio legacy driver. These macros are used by AVS driver to improve code readability.
Unified · Split
| @@ -9,6 +9,7 @@ · 8 unmodified lines | ||
| 9 | 9 | #include <linux/device.h> |
| 10 | 10 | #include <linux/interrupt.h> |
| 11 | 11 | #include <linux/io.h> |
| 12 | +#include <linux/io-64-nonatomic-lo-hi.h> | |
| 12 | 13 | #include <linux/pm_runtime.h> |
| 13 | 14 | #include <linux/timecounter.h> |
| 14 | 15 | #include <sound/core.h> |
| @@ -448,6 +449,8 @@ static inline u16 snd_hdac_reg_readw(struct hdac_bus *bus, void __iomem *addr) · 433 unmodified lines | ||
| 448 | 449 | |
| 449 | 450 | #define snd_hdac_reg_writel(bus, addr, val) writel(val, addr) |
| 450 | 451 | #define snd_hdac_reg_readl(bus, addr) readl(addr) |
| 452 | +#define snd_hdac_reg_writeq(bus, addr, val) writeq(val, addr) | |
| 453 | +#define snd_hdac_reg_readq(bus, addr) readq(addr) | |
| 451 | 454 | |
| 452 | 455 | /* |
| 453 | 456 | * macros for easy use |
| @@ -2,6 +2,8 @@ · 1 unmodified line | ||
| 2 | 2 | #ifndef __SOUND_HDAUDIO_EXT_H |
| 3 | 3 | #define __SOUND_HDAUDIO_EXT_H |
| 4 | 4 | |
| 5 | +#include <linux/io-64-nonatomic-lo-hi.h> | |
| 6 | +#include <linux/iopoll.h> | |
| 5 | 7 | #include <sound/hdaudio.h> |
| 6 | 8 | |
| 7 | 9 | int snd_hdac_ext_bus_init(struct hdac_bus *bus, struct device *dev, |
| @@ -143,6 +145,54 @@ void snd_hdac_ext_bus_link_power(struct hdac_device *codec, bool enable); · 135 unmodified lines | ||
| 143 | 145 | writew(((readw(addr + reg) & ~(mask)) | (val)), \ |
| 144 | 146 | addr + reg) |
| 145 | 147 | |
| 148 | +#define snd_hdac_adsp_writeb(chip, reg, value) \ | |
| 149 | + snd_hdac_reg_writeb(chip, (chip)->dsp_ba + (reg), value) | |
| 150 | +#define snd_hdac_adsp_readb(chip, reg) \ | |
| 151 | + snd_hdac_reg_readb(chip, (chip)->dsp_ba + (reg)) | |
| 152 | +#define snd_hdac_adsp_writew(chip, reg, value) \ | |
| 153 | + snd_hdac_reg_writew(chip, (chip)->dsp_ba + (reg), value) | |
| 154 | +#define snd_hdac_adsp_readw(chip, reg) \ | |
| 155 | + snd_hdac_reg_readw(chip, (chip)->dsp_ba + (reg)) | |
| 156 | +#define snd_hdac_adsp_writel(chip, reg, value) \ | |
| 157 | + snd_hdac_reg_writel(chip, (chip)->dsp_ba + (reg), value) | |
| 158 | +#define snd_hdac_adsp_readl(chip, reg) \ | |
| 159 | + snd_hdac_reg_readl(chip, (chip)->dsp_ba + (reg)) | |
| 160 | +#define snd_hdac_adsp_writeq(chip, reg, value) \ | |
| 161 | + snd_hdac_reg_writeq(chip, (chip)->dsp_ba + (reg), value) | |
| 162 | +#define snd_hdac_adsp_readq(chip, reg) \ | |
| 163 | + snd_hdac_reg_readq(chip, (chip)->dsp_ba + (reg)) | |
| 164 | + | |
| 165 | +#define snd_hdac_adsp_updateb(chip, reg, mask, val) \ | |
| 166 | + snd_hdac_adsp_writeb(chip, reg, \ | |
| 167 | + (snd_hdac_adsp_readb(chip, reg) & ~(mask)) | (val)) | |
| 168 | +#define snd_hdac_adsp_updatew(chip, reg, mask, val) \ | |
| 169 | + snd_hdac_adsp_writew(chip, reg, \ | |
| 170 | + (snd_hdac_adsp_readw(chip, reg) & ~(mask)) | (val)) | |
| 171 | +#define snd_hdac_adsp_updatel(chip, reg, mask, val) \ | |
| 172 | + snd_hdac_adsp_writel(chip, reg, \ | |
| 173 | + (snd_hdac_adsp_readl(chip, reg) & ~(mask)) | (val)) | |
| 174 | +#define snd_hdac_adsp_updateq(chip, reg, mask, val) \ | |
| 175 | + snd_hdac_adsp_writeq(chip, reg, \ | |
| 176 | + (snd_hdac_adsp_readq(chip, reg) & ~(mask)) | (val)) | |
| 177 | + | |
| 178 | +#define snd_hdac_adsp_readb_poll(chip, reg, val, cond, delay_us, timeout_us) \ | |
| 179 | + readb_poll_timeout((chip)->dsp_ba + (reg), val, cond, \ | |
| 180 | + delay_us, timeout_us) | |
| 181 | +#define snd_hdac_adsp_readw_poll(chip, reg, val, cond, delay_us, timeout_us) \ | |
| 182 | + readw_poll_timeout((chip)->dsp_ba + (reg), val, cond, \ | |
| 183 | + delay_us, timeout_us) | |
| 184 | +#define snd_hdac_adsp_readl_poll(chip, reg, val, cond, delay_us, timeout_us) \ | |
| 185 | + readl_poll_timeout((chip)->dsp_ba + (reg), val, cond, \ | |
| 186 | + delay_us, timeout_us) | |
| 187 | +#define snd_hdac_adsp_readq_poll(chip, reg, val, cond, delay_us, timeout_us) \ | |
| 188 | + readq_poll_timeout((chip)->dsp_ba + (reg), val, cond, \ | |
| 189 | + delay_us, timeout_us) | |
| 190 | +#define snd_hdac_stream_readb_poll(strm, reg, val, cond, delay_us, timeout_us) \ | |
| 191 | + readb_poll_timeout((strm)->sd_addr + AZX_REG_ ## reg, val, cond, \ | |
| 192 | + delay_us, timeout_us) | |
| 193 | +#define snd_hdac_stream_readl_poll(strm, reg, val, cond, delay_us, timeout_us) \ | |
| 194 | + readl_poll_timeout((strm)->sd_addr + AZX_REG_ ## reg, val, cond, \ | |
| 195 | + delay_us, timeout_us) | |
| 146 | 196 | |
| 147 | 197 | struct hdac_ext_device; |
| 148 | 198 | |