diff options
| author | Takashi Iwai <tiwai@suse.de> | 2015-03-03 11:33:10 -0500 |
|---|---|---|
| committer | Takashi Iwai <tiwai@suse.de> | 2015-03-23 08:19:35 -0400 |
| commit | 71fc4c7ef5ef2d0ddd22f0545ede4c135b554b84 (patch) | |
| tree | 2fad250a6c6f229aabd6b1aab41d24a50da511d9 /include/sound | |
| parent | e311782acd196d17d25b323d115709c50c8f7d3f (diff) | |
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')
| -rw-r--r-- | include/sound/hdaudio.h | 33 |
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; | |||
| 22 | extern struct bus_type snd_hda_bus_type; | 22 | extern struct bus_type snd_hda_bus_type; |
| 23 | 23 | ||
| 24 | /* | 24 | /* |
| 25 | * generic arrays | ||
| 26 | */ | ||
| 27 | struct snd_array { | ||
| 28 | unsigned int used; | ||
| 29 | unsigned int alloced; | ||
| 30 | unsigned int elem_size; | ||
| 31 | unsigned int alloc_align; | ||
| 32 | void *list; | ||
| 33 | }; | ||
| 34 | |||
| 35 | /* | ||
| 25 | * HD-audio codec base device | 36 | * HD-audio codec base device |
| 26 | */ | 37 | */ |
| 27 | struct hdac_device { | 38 | struct hdac_device { |
| @@ -178,4 +189,26 @@ static inline void snd_hdac_codec_link_down(struct hdac_device *codec) | |||
| 178 | clear_bit(codec->addr, &codec->bus->codec_powered); | 189 | clear_bit(codec->addr, &codec->bus->codec_powered); |
| 179 | } | 190 | } |
| 180 | 191 | ||
| 192 | /* | ||
| 193 | * generic array helpers | ||
| 194 | */ | ||
| 195 | void *snd_array_new(struct snd_array *array); | ||
| 196 | void snd_array_free(struct snd_array *array); | ||
| 197 | static inline void snd_array_init(struct snd_array *array, unsigned int size, | ||
| 198 | unsigned int align) | ||
| 199 | { | ||
| 200 | array->elem_size = size; | ||
| 201 | array->alloc_align = align; | ||
| 202 | } | ||
| 203 | |||
| 204 | static inline void *snd_array_elem(struct snd_array *array, unsigned int idx) | ||
| 205 | { | ||
| 206 | return array->list + idx * array->elem_size; | ||
| 207 | } | ||
| 208 | |||
| 209 | static inline unsigned int snd_array_index(struct snd_array *array, void *ptr) | ||
| 210 | { | ||
| 211 | return (unsigned long)(ptr - array->list) / array->elem_size; | ||
| 212 | } | ||
| 213 | |||
| 181 | #endif /* __SOUND_HDAUDIO_H */ | 214 | #endif /* __SOUND_HDAUDIO_H */ |
