diff options
Diffstat (limited to 'include/sound/pcm_params.h')
| -rw-r--r-- | include/sound/pcm_params.h | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/include/sound/pcm_params.h b/include/sound/pcm_params.h index 6b1c78f05fab..3c45f3924ba7 100644 --- a/include/sound/pcm_params.h +++ b/include/sound/pcm_params.h | |||
| @@ -38,31 +38,6 @@ int snd_pcm_hw_param_value(const struct snd_pcm_hw_params *params, | |||
| 38 | #define MASK_OFS(i) ((i) >> 5) | 38 | #define MASK_OFS(i) ((i) >> 5) |
| 39 | #define MASK_BIT(i) (1U << ((i) & 31)) | 39 | #define MASK_BIT(i) (1U << ((i) & 31)) |
| 40 | 40 | ||
| 41 | static inline unsigned int ld2(u_int32_t v) | ||
| 42 | { | ||
| 43 | unsigned r = 0; | ||
| 44 | |||
| 45 | if (v >= 0x10000) { | ||
| 46 | v >>= 16; | ||
| 47 | r += 16; | ||
| 48 | } | ||
| 49 | if (v >= 0x100) { | ||
| 50 | v >>= 8; | ||
| 51 | r += 8; | ||
| 52 | } | ||
| 53 | if (v >= 0x10) { | ||
| 54 | v >>= 4; | ||
| 55 | r += 4; | ||
| 56 | } | ||
| 57 | if (v >= 4) { | ||
| 58 | v >>= 2; | ||
| 59 | r += 2; | ||
| 60 | } | ||
| 61 | if (v >= 2) | ||
| 62 | r++; | ||
| 63 | return r; | ||
| 64 | } | ||
| 65 | |||
| 66 | static inline size_t snd_mask_sizeof(void) | 41 | static inline size_t snd_mask_sizeof(void) |
| 67 | { | 42 | { |
| 68 | return sizeof(struct snd_mask); | 43 | return sizeof(struct snd_mask); |
| @@ -92,7 +67,7 @@ static inline unsigned int snd_mask_min(const struct snd_mask *mask) | |||
| 92 | int i; | 67 | int i; |
| 93 | for (i = 0; i < SNDRV_MASK_SIZE; i++) { | 68 | for (i = 0; i < SNDRV_MASK_SIZE; i++) { |
| 94 | if (mask->bits[i]) | 69 | if (mask->bits[i]) |
| 95 | return ffs(mask->bits[i]) - 1 + (i << 5); | 70 | return __ffs(mask->bits[i]) + (i << 5); |
| 96 | } | 71 | } |
| 97 | return 0; | 72 | return 0; |
| 98 | } | 73 | } |
| @@ -102,7 +77,7 @@ static inline unsigned int snd_mask_max(const struct snd_mask *mask) | |||
| 102 | int i; | 77 | int i; |
| 103 | for (i = SNDRV_MASK_SIZE - 1; i >= 0; i--) { | 78 | for (i = SNDRV_MASK_SIZE - 1; i >= 0; i--) { |
| 104 | if (mask->bits[i]) | 79 | if (mask->bits[i]) |
| 105 | return ld2(mask->bits[i]) + (i << 5); | 80 | return __fls(mask->bits[i]) + (i << 5); |
| 106 | } | 81 | } |
| 107 | return 0; | 82 | return 0; |
| 108 | } | 83 | } |
| @@ -325,43 +300,68 @@ static inline int snd_interval_eq(const struct snd_interval *i1, const struct sn | |||
| 325 | i1->max == i2->max && i1->openmax == i2->openmax; | 300 | i1->max == i2->max && i1->openmax == i2->openmax; |
| 326 | } | 301 | } |
| 327 | 302 | ||
| 328 | static inline unsigned int add(unsigned int a, unsigned int b) | 303 | /** |
| 304 | * params_access - get the access type from the hw params | ||
| 305 | * @p: hw params | ||
| 306 | */ | ||
| 307 | static inline snd_pcm_access_t params_access(const struct snd_pcm_hw_params *p) | ||
| 329 | { | 308 | { |
| 330 | if (a >= UINT_MAX - b) | 309 | return (__force snd_pcm_access_t)snd_mask_min(hw_param_mask_c(p, |
| 331 | return UINT_MAX; | 310 | SNDRV_PCM_HW_PARAM_ACCESS)); |
| 332 | return a + b; | ||
| 333 | } | 311 | } |
| 334 | 312 | ||
| 335 | static inline unsigned int sub(unsigned int a, unsigned int b) | 313 | /** |
| 314 | * params_format - get the sample format from the hw params | ||
| 315 | * @p: hw params | ||
| 316 | */ | ||
| 317 | static inline snd_pcm_format_t params_format(const struct snd_pcm_hw_params *p) | ||
| 336 | { | 318 | { |
| 337 | if (a > b) | 319 | return (__force snd_pcm_format_t)snd_mask_min(hw_param_mask_c(p, |
| 338 | return a - b; | 320 | SNDRV_PCM_HW_PARAM_FORMAT)); |
| 339 | return 0; | ||
| 340 | } | 321 | } |
| 341 | 322 | ||
| 342 | #define params_access(p) ((__force snd_pcm_access_t)\ | 323 | /** |
| 343 | snd_mask_min(hw_param_mask_c((p), SNDRV_PCM_HW_PARAM_ACCESS))) | 324 | * params_subformat - get the sample subformat from the hw params |
| 344 | #define params_format(p) ((__force snd_pcm_format_t)\ | 325 | * @p: hw params |
| 345 | snd_mask_min(hw_param_mask_c((p), SNDRV_PCM_HW_PARAM_FORMAT))) | 326 | */ |
| 346 | #define params_subformat(p) \ | 327 | static inline snd_pcm_subformat_t |
| 347 | snd_mask_min(hw_param_mask_c((p), SNDRV_PCM_HW_PARAM_SUBFORMAT)) | 328 | params_subformat(const struct snd_pcm_hw_params *p) |
| 329 | { | ||
| 330 | return (__force snd_pcm_subformat_t)snd_mask_min(hw_param_mask_c(p, | ||
| 331 | SNDRV_PCM_HW_PARAM_SUBFORMAT)); | ||
| 332 | } | ||
| 348 | 333 | ||
| 334 | /** | ||
| 335 | * params_period_bytes - get the period size (in bytes) from the hw params | ||
| 336 | * @p: hw params | ||
| 337 | */ | ||
| 349 | static inline unsigned int | 338 | static inline unsigned int |
| 350 | params_period_bytes(const struct snd_pcm_hw_params *p) | 339 | params_period_bytes(const struct snd_pcm_hw_params *p) |
| 351 | { | 340 | { |
| 352 | return (params_period_size(p) * | 341 | return hw_param_interval_c(p, SNDRV_PCM_HW_PARAM_PERIOD_BYTES)->min; |
| 353 | snd_pcm_format_physical_width(params_format(p)) * | ||
| 354 | params_channels(p)) / 8; | ||
| 355 | } | 342 | } |
| 356 | 343 | ||
| 357 | static inline int | 344 | /** |
| 358 | params_width(const struct snd_pcm_hw_params *p) | 345 | * params_width - get the number of bits of the sample format from the hw params |
| 346 | * @p: hw params | ||
| 347 | * | ||
| 348 | * This function returns the number of bits per sample that the selected sample | ||
| 349 | * format of the hw params has. | ||
| 350 | */ | ||
| 351 | static inline int params_width(const struct snd_pcm_hw_params *p) | ||
| 359 | { | 352 | { |
| 360 | return snd_pcm_format_width(params_format(p)); | 353 | return snd_pcm_format_width(params_format(p)); |
| 361 | } | 354 | } |
| 362 | 355 | ||
| 363 | static inline int | 356 | /* |
| 364 | params_physical_width(const struct snd_pcm_hw_params *p) | 357 | * params_physical_width - get the storage size of the sample format from the hw params |
| 358 | * @p: hw params | ||
| 359 | * | ||
| 360 | * This functions returns the number of bits per sample that the selected sample | ||
| 361 | * format of the hw params takes up in memory. This will be equal or larger than | ||
| 362 | * params_width(). | ||
| 363 | */ | ||
| 364 | static inline int params_physical_width(const struct snd_pcm_hw_params *p) | ||
| 365 | { | 365 | { |
| 366 | return snd_pcm_format_physical_width(params_format(p)); | 366 | return snd_pcm_format_physical_width(params_format(p)); |
| 367 | } | 367 | } |
