diff options
author | Takashi Iwai <tiwai@suse.de> | 2014-12-30 10:42:07 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2014-12-30 10:42:07 -0500 |
commit | 240491e143414973a0204e6c7cd4cfd19cb3e027 (patch) | |
tree | 4c9f368bc501d3f0bbcee54c3a81ff7cb2a7aa6d /include/sound | |
parent | 614acf93dceb8e9d73370f7c9b19f64c8cf17496 (diff) | |
parent | 757b037650c9ecca79a46ab744820b1b3c1bb49d (diff) |
Merge branch 'topic/pcm-params' into for-next
Diffstat (limited to 'include/sound')
-rw-r--r-- | include/sound/pcm.h | 13 | ||||
-rw-r--r-- | include/sound/pcm_params.h | 96 |
2 files changed, 53 insertions, 56 deletions
diff --git a/include/sound/pcm.h b/include/sound/pcm.h index 1e7f74acc2ec..3652c9439af9 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h | |||
@@ -94,9 +94,6 @@ struct snd_pcm_ops { | |||
94 | #define SNDRV_PCM_DEVICES 8 | 94 | #define SNDRV_PCM_DEVICES 8 |
95 | #endif | 95 | #endif |
96 | 96 | ||
97 | #define SNDRV_PCM_IOCTL1_FALSE ((void *)0) | ||
98 | #define SNDRV_PCM_IOCTL1_TRUE ((void *)1) | ||
99 | |||
100 | #define SNDRV_PCM_IOCTL1_RESET 0 | 97 | #define SNDRV_PCM_IOCTL1_RESET 0 |
101 | #define SNDRV_PCM_IOCTL1_INFO 1 | 98 | #define SNDRV_PCM_IOCTL1_INFO 1 |
102 | #define SNDRV_PCM_IOCTL1_CHANNEL_INFO 2 | 99 | #define SNDRV_PCM_IOCTL1_CHANNEL_INFO 2 |
@@ -857,7 +854,7 @@ static inline unsigned int params_channels(const struct snd_pcm_hw_params *p) | |||
857 | } | 854 | } |
858 | 855 | ||
859 | /** | 856 | /** |
860 | * params_channels - Get the sample rate from the hw params | 857 | * params_rate - Get the sample rate from the hw params |
861 | * @p: hw params | 858 | * @p: hw params |
862 | */ | 859 | */ |
863 | static inline unsigned int params_rate(const struct snd_pcm_hw_params *p) | 860 | static inline unsigned int params_rate(const struct snd_pcm_hw_params *p) |
@@ -866,7 +863,7 @@ static inline unsigned int params_rate(const struct snd_pcm_hw_params *p) | |||
866 | } | 863 | } |
867 | 864 | ||
868 | /** | 865 | /** |
869 | * params_channels - Get the period size (in frames) from the hw params | 866 | * params_period_size - Get the period size (in frames) from the hw params |
870 | * @p: hw params | 867 | * @p: hw params |
871 | */ | 868 | */ |
872 | static inline unsigned int params_period_size(const struct snd_pcm_hw_params *p) | 869 | static inline unsigned int params_period_size(const struct snd_pcm_hw_params *p) |
@@ -875,7 +872,7 @@ static inline unsigned int params_period_size(const struct snd_pcm_hw_params *p) | |||
875 | } | 872 | } |
876 | 873 | ||
877 | /** | 874 | /** |
878 | * params_channels - Get the number of periods from the hw params | 875 | * params_periods - Get the number of periods from the hw params |
879 | * @p: hw params | 876 | * @p: hw params |
880 | */ | 877 | */ |
881 | static inline unsigned int params_periods(const struct snd_pcm_hw_params *p) | 878 | static inline unsigned int params_periods(const struct snd_pcm_hw_params *p) |
@@ -884,7 +881,7 @@ static inline unsigned int params_periods(const struct snd_pcm_hw_params *p) | |||
884 | } | 881 | } |
885 | 882 | ||
886 | /** | 883 | /** |
887 | * params_channels - Get the buffer size (in frames) from the hw params | 884 | * params_buffer_size - Get the buffer size (in frames) from the hw params |
888 | * @p: hw params | 885 | * @p: hw params |
889 | */ | 886 | */ |
890 | static inline unsigned int params_buffer_size(const struct snd_pcm_hw_params *p) | 887 | static inline unsigned int params_buffer_size(const struct snd_pcm_hw_params *p) |
@@ -893,7 +890,7 @@ static inline unsigned int params_buffer_size(const struct snd_pcm_hw_params *p) | |||
893 | } | 890 | } |
894 | 891 | ||
895 | /** | 892 | /** |
896 | * params_channels - Get the buffer size (in bytes) from the hw params | 893 | * params_buffer_bytes - Get the buffer size (in bytes) from the hw params |
897 | * @p: hw params | 894 | * @p: hw params |
898 | */ | 895 | */ |
899 | static inline unsigned int params_buffer_bytes(const struct snd_pcm_hw_params *p) | 896 | static inline unsigned int params_buffer_bytes(const struct snd_pcm_hw_params *p) |
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 | } |