Commit c19bd02e authored by Cezary Rojewski's avatar Cezary Rojewski Committed by Mark Brown

ALSA: hda: Add helper macros for DSP capable devices

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.
Signed-off-by: default avatarCezary Rojewski <cezary.rojewski@intel.com>
Acked-by: default avatarTakashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20220311153544.136854-2-cezary.rojewski@intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 6b6bb5e2
......@@ -9,6 +9,7 @@
#include <linux/device.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/io-64-nonatomic-lo-hi.h>
#include <linux/pm_runtime.h>
#include <linux/timecounter.h>
#include <sound/core.h>
......@@ -448,6 +449,8 @@ static inline u16 snd_hdac_reg_readw(struct hdac_bus *bus, void __iomem *addr)
#define snd_hdac_reg_writel(bus, addr, val) writel(val, addr)
#define snd_hdac_reg_readl(bus, addr) readl(addr)
#define snd_hdac_reg_writeq(bus, addr, val) writeq(val, addr)
#define snd_hdac_reg_readq(bus, addr) readq(addr)
/*
* macros for easy use
......
......@@ -2,6 +2,8 @@
#ifndef __SOUND_HDAUDIO_EXT_H
#define __SOUND_HDAUDIO_EXT_H
#include <linux/io-64-nonatomic-lo-hi.h>
#include <linux/iopoll.h>
#include <sound/hdaudio.h>
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);
writew(((readw(addr + reg) & ~(mask)) | (val)), \
addr + reg)
#define snd_hdac_adsp_writeb(chip, reg, value) \
snd_hdac_reg_writeb(chip, (chip)->dsp_ba + (reg), value)
#define snd_hdac_adsp_readb(chip, reg) \
snd_hdac_reg_readb(chip, (chip)->dsp_ba + (reg))
#define snd_hdac_adsp_writew(chip, reg, value) \
snd_hdac_reg_writew(chip, (chip)->dsp_ba + (reg), value)
#define snd_hdac_adsp_readw(chip, reg) \
snd_hdac_reg_readw(chip, (chip)->dsp_ba + (reg))
#define snd_hdac_adsp_writel(chip, reg, value) \
snd_hdac_reg_writel(chip, (chip)->dsp_ba + (reg), value)
#define snd_hdac_adsp_readl(chip, reg) \
snd_hdac_reg_readl(chip, (chip)->dsp_ba + (reg))
#define snd_hdac_adsp_writeq(chip, reg, value) \
snd_hdac_reg_writeq(chip, (chip)->dsp_ba + (reg), value)
#define snd_hdac_adsp_readq(chip, reg) \
snd_hdac_reg_readq(chip, (chip)->dsp_ba + (reg))
#define snd_hdac_adsp_updateb(chip, reg, mask, val) \
snd_hdac_adsp_writeb(chip, reg, \
(snd_hdac_adsp_readb(chip, reg) & ~(mask)) | (val))
#define snd_hdac_adsp_updatew(chip, reg, mask, val) \
snd_hdac_adsp_writew(chip, reg, \
(snd_hdac_adsp_readw(chip, reg) & ~(mask)) | (val))
#define snd_hdac_adsp_updatel(chip, reg, mask, val) \
snd_hdac_adsp_writel(chip, reg, \
(snd_hdac_adsp_readl(chip, reg) & ~(mask)) | (val))
#define snd_hdac_adsp_updateq(chip, reg, mask, val) \
snd_hdac_adsp_writeq(chip, reg, \
(snd_hdac_adsp_readq(chip, reg) & ~(mask)) | (val))
#define snd_hdac_adsp_readb_poll(chip, reg, val, cond, delay_us, timeout_us) \
readb_poll_timeout((chip)->dsp_ba + (reg), val, cond, \
delay_us, timeout_us)
#define snd_hdac_adsp_readw_poll(chip, reg, val, cond, delay_us, timeout_us) \
readw_poll_timeout((chip)->dsp_ba + (reg), val, cond, \
delay_us, timeout_us)
#define snd_hdac_adsp_readl_poll(chip, reg, val, cond, delay_us, timeout_us) \
readl_poll_timeout((chip)->dsp_ba + (reg), val, cond, \
delay_us, timeout_us)
#define snd_hdac_adsp_readq_poll(chip, reg, val, cond, delay_us, timeout_us) \
readq_poll_timeout((chip)->dsp_ba + (reg), val, cond, \
delay_us, timeout_us)
#define snd_hdac_stream_readb_poll(strm, reg, val, cond, delay_us, timeout_us) \
readb_poll_timeout((strm)->sd_addr + AZX_REG_ ## reg, val, cond, \
delay_us, timeout_us)
#define snd_hdac_stream_readl_poll(strm, reg, val, cond, delay_us, timeout_us) \
readl_poll_timeout((strm)->sd_addr + AZX_REG_ ## reg, val, cond, \
delay_us, timeout_us)
struct hdac_ext_device;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment