Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef __SOUND_PCM_PARAMS_H |
| 2 | #define __SOUND_PCM_PARAMS_H |
| 3 | |
| 4 | /* |
| 5 | * PCM params helpers |
| 6 | * Copyright (c) by Abramo Bagnara <abramo@alsa-project.org> |
| 7 | * |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2 of the License, or |
| 12 | * (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 22 | * |
| 23 | */ |
| 24 | |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 25 | extern int snd_pcm_hw_param_mask(struct snd_pcm_substream *pcm, struct snd_pcm_hw_params *params, |
| 26 | snd_pcm_hw_param_t var, const struct snd_mask *val); |
| 27 | extern unsigned int snd_pcm_hw_param_value_min(const struct snd_pcm_hw_params *params, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | snd_pcm_hw_param_t var, int *dir); |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 29 | extern unsigned int snd_pcm_hw_param_value_max(const struct snd_pcm_hw_params *params, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | snd_pcm_hw_param_t var, int *dir); |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 31 | extern int _snd_pcm_hw_param_min(struct snd_pcm_hw_params *params, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | snd_pcm_hw_param_t var, unsigned int val, int dir); |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 33 | extern int _snd_pcm_hw_param_setinteger(struct snd_pcm_hw_params *params, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | snd_pcm_hw_param_t var); |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 35 | extern int _snd_pcm_hw_param_set(struct snd_pcm_hw_params *params, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | snd_pcm_hw_param_t var, unsigned int val, int dir); |
| 37 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | #define SNDRV_MASK_BITS 64 /* we use so far 64bits only */ |
| 39 | #define SNDRV_MASK_SIZE (SNDRV_MASK_BITS / 32) |
| 40 | #define MASK_OFS(i) ((i) >> 5) |
| 41 | #define MASK_BIT(i) (1U << ((i) & 31)) |
| 42 | |
Takashi Iwai | 9bb22e2 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 43 | static inline unsigned int ld2(u_int32_t v) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | { |
| 45 | unsigned r = 0; |
| 46 | |
| 47 | if (v >= 0x10000) { |
| 48 | v >>= 16; |
| 49 | r += 16; |
| 50 | } |
| 51 | if (v >= 0x100) { |
| 52 | v >>= 8; |
| 53 | r += 8; |
| 54 | } |
| 55 | if (v >= 0x10) { |
| 56 | v >>= 4; |
| 57 | r += 4; |
| 58 | } |
| 59 | if (v >= 4) { |
| 60 | v >>= 2; |
| 61 | r += 2; |
| 62 | } |
| 63 | if (v >= 2) |
| 64 | r++; |
| 65 | return r; |
| 66 | } |
| 67 | |
Takashi Iwai | 9bb22e2 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 68 | static inline size_t snd_mask_sizeof(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | { |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 70 | return sizeof(struct snd_mask); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | } |
| 72 | |
Takashi Iwai | 9bb22e2 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 73 | static inline void snd_mask_none(struct snd_mask *mask) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | { |
| 75 | memset(mask, 0, sizeof(*mask)); |
| 76 | } |
| 77 | |
Takashi Iwai | 9bb22e2 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 78 | static inline void snd_mask_any(struct snd_mask *mask) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | { |
| 80 | memset(mask, 0xff, SNDRV_MASK_SIZE * sizeof(u_int32_t)); |
| 81 | } |
| 82 | |
Takashi Iwai | 9bb22e2 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 83 | static inline int snd_mask_empty(const struct snd_mask *mask) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | { |
| 85 | int i; |
| 86 | for (i = 0; i < SNDRV_MASK_SIZE; i++) |
| 87 | if (mask->bits[i]) |
| 88 | return 0; |
| 89 | return 1; |
| 90 | } |
| 91 | |
Takashi Iwai | 9bb22e2 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 92 | static inline unsigned int snd_mask_min(const struct snd_mask *mask) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | { |
| 94 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | for (i = 0; i < SNDRV_MASK_SIZE; i++) { |
| 96 | if (mask->bits[i]) |
| 97 | return ffs(mask->bits[i]) - 1 + (i << 5); |
| 98 | } |
| 99 | return 0; |
| 100 | } |
| 101 | |
Takashi Iwai | 9bb22e2 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 102 | static inline unsigned int snd_mask_max(const struct snd_mask *mask) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | { |
| 104 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | for (i = SNDRV_MASK_SIZE - 1; i >= 0; i--) { |
| 106 | if (mask->bits[i]) |
| 107 | return ld2(mask->bits[i]) + (i << 5); |
| 108 | } |
| 109 | return 0; |
| 110 | } |
| 111 | |
Takashi Iwai | 9bb22e2 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 112 | static inline void snd_mask_set(struct snd_mask *mask, unsigned int val) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | mask->bits[MASK_OFS(val)] |= MASK_BIT(val); |
| 115 | } |
| 116 | |
Takashi Iwai | 9bb22e2 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 117 | static inline void snd_mask_reset(struct snd_mask *mask, unsigned int val) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | mask->bits[MASK_OFS(val)] &= ~MASK_BIT(val); |
| 120 | } |
| 121 | |
Takashi Iwai | 9bb22e2 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 122 | static inline void snd_mask_set_range(struct snd_mask *mask, |
| 123 | unsigned int from, unsigned int to) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | { |
| 125 | unsigned int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | for (i = from; i <= to; i++) |
| 127 | mask->bits[MASK_OFS(i)] |= MASK_BIT(i); |
| 128 | } |
| 129 | |
Takashi Iwai | 9bb22e2 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 130 | static inline void snd_mask_reset_range(struct snd_mask *mask, |
| 131 | unsigned int from, unsigned int to) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | { |
| 133 | unsigned int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | for (i = from; i <= to; i++) |
| 135 | mask->bits[MASK_OFS(i)] &= ~MASK_BIT(i); |
| 136 | } |
| 137 | |
Takashi Iwai | 9bb22e2 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 138 | static inline void snd_mask_leave(struct snd_mask *mask, unsigned int val) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | { |
| 140 | unsigned int v; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | v = mask->bits[MASK_OFS(val)] & MASK_BIT(val); |
| 142 | snd_mask_none(mask); |
| 143 | mask->bits[MASK_OFS(val)] = v; |
| 144 | } |
| 145 | |
Takashi Iwai | 9bb22e2 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 146 | static inline void snd_mask_intersect(struct snd_mask *mask, |
| 147 | const struct snd_mask *v) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | { |
| 149 | int i; |
| 150 | for (i = 0; i < SNDRV_MASK_SIZE; i++) |
| 151 | mask->bits[i] &= v->bits[i]; |
| 152 | } |
| 153 | |
Takashi Iwai | 9bb22e2 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 154 | static inline int snd_mask_eq(const struct snd_mask *mask, |
| 155 | const struct snd_mask *v) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | { |
| 157 | return ! memcmp(mask, v, SNDRV_MASK_SIZE * sizeof(u_int32_t)); |
| 158 | } |
| 159 | |
Takashi Iwai | 9bb22e2 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 160 | static inline void snd_mask_copy(struct snd_mask *mask, |
| 161 | const struct snd_mask *v) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | { |
| 163 | *mask = *v; |
| 164 | } |
| 165 | |
Takashi Iwai | 9bb22e2 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 166 | static inline int snd_mask_test(const struct snd_mask *mask, unsigned int val) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | return mask->bits[MASK_OFS(val)] & MASK_BIT(val); |
| 169 | } |
| 170 | |
Takashi Iwai | 9bb22e2 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 171 | static inline int snd_mask_single(const struct snd_mask *mask) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | { |
| 173 | int i, c = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | for (i = 0; i < SNDRV_MASK_SIZE; i++) { |
| 175 | if (! mask->bits[i]) |
| 176 | continue; |
| 177 | if (mask->bits[i] & (mask->bits[i] - 1)) |
| 178 | return 0; |
| 179 | if (c) |
| 180 | return 0; |
| 181 | c++; |
| 182 | } |
| 183 | return 1; |
| 184 | } |
| 185 | |
Takashi Iwai | 9bb22e2 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 186 | static inline int snd_mask_refine(struct snd_mask *mask, |
| 187 | const struct snd_mask *v) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | { |
Takashi Iwai | 877211f | 2005-11-17 13:59:38 +0100 | [diff] [blame] | 189 | struct snd_mask old; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | snd_mask_copy(&old, mask); |
| 191 | snd_mask_intersect(mask, v); |
| 192 | if (snd_mask_empty(mask)) |
| 193 | return -EINVAL; |
| 194 | return !snd_mask_eq(mask, &old); |
| 195 | } |
| 196 | |
Takashi Iwai | 9bb22e2 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 197 | static inline int snd_mask_refine_first(struct snd_mask *mask) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | if (snd_mask_single(mask)) |
| 200 | return 0; |
| 201 | snd_mask_leave(mask, snd_mask_min(mask)); |
| 202 | return 1; |
| 203 | } |
| 204 | |
Takashi Iwai | 9bb22e2 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 205 | static inline int snd_mask_refine_last(struct snd_mask *mask) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | if (snd_mask_single(mask)) |
| 208 | return 0; |
| 209 | snd_mask_leave(mask, snd_mask_max(mask)); |
| 210 | return 1; |
| 211 | } |
| 212 | |
Takashi Iwai | 9bb22e2 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 213 | static inline int snd_mask_refine_min(struct snd_mask *mask, unsigned int val) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | if (snd_mask_min(mask) >= val) |
| 216 | return 0; |
| 217 | snd_mask_reset_range(mask, 0, val - 1); |
| 218 | if (snd_mask_empty(mask)) |
| 219 | return -EINVAL; |
| 220 | return 1; |
| 221 | } |
| 222 | |
Takashi Iwai | 9bb22e2 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 223 | static inline int snd_mask_refine_max(struct snd_mask *mask, unsigned int val) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | if (snd_mask_max(mask) <= val) |
| 226 | return 0; |
| 227 | snd_mask_reset_range(mask, val + 1, SNDRV_MASK_BITS); |
| 228 | if (snd_mask_empty(mask)) |
| 229 | return -EINVAL; |
| 230 | return 1; |
| 231 | } |
| 232 | |
Takashi Iwai | 9bb22e2 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 233 | static inline int snd_mask_refine_set(struct snd_mask *mask, unsigned int val) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | { |
| 235 | int changed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | changed = !snd_mask_single(mask); |
| 237 | snd_mask_leave(mask, val); |
| 238 | if (snd_mask_empty(mask)) |
| 239 | return -EINVAL; |
| 240 | return changed; |
| 241 | } |
| 242 | |
Takashi Iwai | 9bb22e2 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 243 | static inline int snd_mask_value(const struct snd_mask *mask) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | return snd_mask_min(mask); |
| 246 | } |
| 247 | |
Takashi Iwai | 9bb22e2 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 248 | static inline void snd_interval_any(struct snd_interval *i) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | { |
| 250 | i->min = 0; |
| 251 | i->openmin = 0; |
| 252 | i->max = UINT_MAX; |
| 253 | i->openmax = 0; |
| 254 | i->integer = 0; |
| 255 | i->empty = 0; |
| 256 | } |
| 257 | |
Takashi Iwai | 9bb22e2 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 258 | static inline void snd_interval_none(struct snd_interval *i) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 259 | { |
| 260 | i->empty = 1; |
| 261 | } |
| 262 | |
Takashi Iwai | 9bb22e2 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 263 | static inline int snd_interval_checkempty(const struct snd_interval *i) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | { |
| 265 | return (i->min > i->max || |
| 266 | (i->min == i->max && (i->openmin || i->openmax))); |
| 267 | } |
| 268 | |
Takashi Iwai | 9bb22e2 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 269 | static inline int snd_interval_empty(const struct snd_interval *i) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | { |
| 271 | return i->empty; |
| 272 | } |
| 273 | |
Takashi Iwai | 9bb22e2 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 274 | static inline int snd_interval_single(const struct snd_interval *i) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | return (i->min == i->max || |
| 277 | (i->min + 1 == i->max && i->openmax)); |
| 278 | } |
| 279 | |
Takashi Iwai | 9bb22e2 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 280 | static inline int snd_interval_value(const struct snd_interval *i) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | return i->min; |
| 283 | } |
| 284 | |
Takashi Iwai | 9bb22e2 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 285 | static inline int snd_interval_min(const struct snd_interval *i) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | return i->min; |
| 288 | } |
| 289 | |
Takashi Iwai | 9bb22e2 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 290 | static inline int snd_interval_max(const struct snd_interval *i) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | { |
| 292 | unsigned int v; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 | v = i->max; |
| 294 | if (i->openmax) |
| 295 | v--; |
| 296 | return v; |
| 297 | } |
| 298 | |
Takashi Iwai | 9bb22e2 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 299 | static inline int snd_interval_test(const struct snd_interval *i, unsigned int val) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | { |
| 301 | return !((i->min > val || (i->min == val && i->openmin) || |
| 302 | i->max < val || (i->max == val && i->openmax))); |
| 303 | } |
| 304 | |
Takashi Iwai | 9bb22e2 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 305 | static inline void snd_interval_copy(struct snd_interval *d, const struct snd_interval *s) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | { |
| 307 | *d = *s; |
| 308 | } |
| 309 | |
Takashi Iwai | 9bb22e2 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 310 | static inline int snd_interval_setinteger(struct snd_interval *i) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | { |
| 312 | if (i->integer) |
| 313 | return 0; |
| 314 | if (i->openmin && i->openmax && i->min == i->max) |
| 315 | return -EINVAL; |
| 316 | i->integer = 1; |
| 317 | return 1; |
| 318 | } |
| 319 | |
Takashi Iwai | 9bb22e2 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 320 | static inline int snd_interval_eq(const struct snd_interval *i1, const struct snd_interval *i2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | { |
| 322 | if (i1->empty) |
| 323 | return i2->empty; |
| 324 | if (i2->empty) |
| 325 | return i1->empty; |
| 326 | return i1->min == i2->min && i1->openmin == i2->openmin && |
| 327 | i1->max == i2->max && i1->openmax == i2->openmax; |
| 328 | } |
| 329 | |
| 330 | static inline unsigned int add(unsigned int a, unsigned int b) |
| 331 | { |
| 332 | if (a >= UINT_MAX - b) |
| 333 | return UINT_MAX; |
| 334 | return a + b; |
| 335 | } |
| 336 | |
| 337 | static inline unsigned int sub(unsigned int a, unsigned int b) |
| 338 | { |
| 339 | if (a > b) |
| 340 | return a - b; |
| 341 | return 0; |
| 342 | } |
| 343 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 344 | #endif /* __SOUND_PCM_PARAMS_H */ |
| 345 | |