summaryrefslogtreecommitdiffstats
path: root/include/sound/hdaudio.h
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2015-03-03 17:33:10 +0100
committerTakashi Iwai <tiwai@suse.de>2015-03-23 13:19:35 +0100
commit71fc4c7ef5ef2d0ddd22f0545ede4c135b554b84 (patch)
tree2fad250a6c6f229aabd6b1aab41d24a50da511d9 /include/sound/hdaudio.h
parentALSA: hda - Re-add tracepoints to HD-audio core driver (diff)
downloadlinux-71fc4c7ef5ef2d0ddd22f0545ede4c135b554b84.tar.xz
linux-71fc4c7ef5ef2d0ddd22f0545ede4c135b554b84.zip
ALSA: hda - Move generic array helpers to core lib
This will be used by the regmap support. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'include/sound/hdaudio.h')
-rw-r--r--include/sound/hdaudio.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h
index 675614dc2b88..3abdd3f16528 100644
--- a/include/sound/hdaudio.h
+++ b/include/sound/hdaudio.h
@@ -22,6 +22,17 @@ struct hdac_widget_tree;
extern struct bus_type snd_hda_bus_type;
/*
+ * generic arrays
+ */
+struct snd_array {
+ unsigned int used;
+ unsigned int alloced;
+ unsigned int elem_size;
+ unsigned int alloc_align;
+ void *list;
+};
+
+/*
* HD-audio codec base device
*/
struct hdac_device {
@@ -178,4 +189,26 @@ static inline void snd_hdac_codec_link_down(struct hdac_device *codec)
clear_bit(codec->addr, &codec->bus->codec_powered);
}
+/*
+ * generic array helpers
+ */
+void *snd_array_new(struct snd_array *array);
+void snd_array_free(struct snd_array *array);
+static inline void snd_array_init(struct snd_array *array, unsigned int size,
+ unsigned int align)
+{
+ array->elem_size = size;
+ array->alloc_align = align;
+}
+
+static inline void *snd_array_elem(struct snd_array *array, unsigned int idx)
+{
+ return array->list + idx * array->elem_size;
+}
+
+static inline unsigned int snd_array_index(struct snd_array *array, void *ptr)
+{
+ return (unsigned long)(ptr - array->list) / array->elem_size;
+}
+
#endif /* __SOUND_HDAUDIO_H */