aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sound/asound.h12
-rw-r--r--include/sound/pcm.h32
2 files changed, 24 insertions, 20 deletions
diff --git a/include/sound/asound.h b/include/sound/asound.h
index 3eaf155b850d..0309da2f11d3 100644
--- a/include/sound/asound.h
+++ b/include/sound/asound.h
@@ -302,6 +302,8 @@ typedef int __bitwise snd_pcm_hw_param_t;
302#define SNDRV_PCM_HW_PARAM_SUBFORMAT ((__force snd_pcm_hw_param_t) 2) /* Subformat */ 302#define SNDRV_PCM_HW_PARAM_SUBFORMAT ((__force snd_pcm_hw_param_t) 2) /* Subformat */
303#define SNDRV_PCM_HW_PARAM_FIRST_MASK SNDRV_PCM_HW_PARAM_ACCESS 303#define SNDRV_PCM_HW_PARAM_FIRST_MASK SNDRV_PCM_HW_PARAM_ACCESS
304#define SNDRV_PCM_HW_PARAM_LAST_MASK SNDRV_PCM_HW_PARAM_SUBFORMAT 304#define SNDRV_PCM_HW_PARAM_LAST_MASK SNDRV_PCM_HW_PARAM_SUBFORMAT
305#define SNDRV_PCM_HW_PARAM_MASK_INDEX(var) \
306 ((__force int)(var) - (__force int)SNDRV_PCM_HW_PARAM_FIRST_MASK)
305 307
306#define SNDRV_PCM_HW_PARAM_SAMPLE_BITS ((__force snd_pcm_hw_param_t) 8) /* Bits per sample */ 308#define SNDRV_PCM_HW_PARAM_SAMPLE_BITS ((__force snd_pcm_hw_param_t) 8) /* Bits per sample */
307#define SNDRV_PCM_HW_PARAM_FRAME_BITS ((__force snd_pcm_hw_param_t) 9) /* Bits per frame */ 309#define SNDRV_PCM_HW_PARAM_FRAME_BITS ((__force snd_pcm_hw_param_t) 9) /* Bits per frame */
@@ -317,6 +319,8 @@ typedef int __bitwise snd_pcm_hw_param_t;
317#define SNDRV_PCM_HW_PARAM_TICK_TIME ((__force snd_pcm_hw_param_t) 19) /* Approx tick duration in us */ 319#define SNDRV_PCM_HW_PARAM_TICK_TIME ((__force snd_pcm_hw_param_t) 19) /* Approx tick duration in us */
318#define SNDRV_PCM_HW_PARAM_FIRST_INTERVAL SNDRV_PCM_HW_PARAM_SAMPLE_BITS 320#define SNDRV_PCM_HW_PARAM_FIRST_INTERVAL SNDRV_PCM_HW_PARAM_SAMPLE_BITS
319#define SNDRV_PCM_HW_PARAM_LAST_INTERVAL SNDRV_PCM_HW_PARAM_TICK_TIME 321#define SNDRV_PCM_HW_PARAM_LAST_INTERVAL SNDRV_PCM_HW_PARAM_TICK_TIME
322#define SNDRV_PCM_HW_PARAM_INTERVAL_INDEX(var) \
323 ((__force int)(var) - (__force int)SNDRV_PCM_HW_PARAM_FIRST_INTERVAL)
320 324
321#define SNDRV_PCM_HW_PARAMS_NORESAMPLE (1<<0) /* avoid rate resampling */ 325#define SNDRV_PCM_HW_PARAMS_NORESAMPLE (1<<0) /* avoid rate resampling */
322 326
@@ -336,11 +340,11 @@ struct snd_mask {
336 340
337struct snd_pcm_hw_params { 341struct snd_pcm_hw_params {
338 unsigned int flags; 342 unsigned int flags;
339 struct snd_mask masks[SNDRV_PCM_HW_PARAM_LAST_MASK - 343 struct snd_mask masks[
340 SNDRV_PCM_HW_PARAM_FIRST_MASK + 1]; 344 SNDRV_PCM_HW_PARAM_MASK_INDEX(SNDRV_PCM_HW_PARAM_LAST_MASK) + 1];
341 struct snd_mask mres[5]; /* reserved masks */ 345 struct snd_mask mres[5]; /* reserved masks */
342 struct snd_interval intervals[SNDRV_PCM_HW_PARAM_LAST_INTERVAL - 346 struct snd_interval intervals[
343 SNDRV_PCM_HW_PARAM_FIRST_INTERVAL + 1]; 347 SNDRV_PCM_HW_PARAM_INTERVAL_INDEX(SNDRV_PCM_HW_PARAM_LAST_INTERVAL) + 1];
344 struct snd_interval ires[9]; /* reserved intervals */ 348 struct snd_interval ires[9]; /* reserved intervals */
345 unsigned int rmask; /* W: requested masks */ 349 unsigned int rmask; /* W: requested masks */
346 unsigned int cmask; /* R: changed masks */ 350 unsigned int cmask; /* R: changed masks */
diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index 51d58ccda2d8..5315b53f9b07 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -209,10 +209,10 @@ struct snd_pcm_hw_rule {
209}; 209};
210 210
211struct snd_pcm_hw_constraints { 211struct snd_pcm_hw_constraints {
212 struct snd_mask masks[SNDRV_PCM_HW_PARAM_LAST_MASK - 212 struct snd_mask masks[
213 SNDRV_PCM_HW_PARAM_FIRST_MASK + 1]; 213 SNDRV_PCM_HW_PARAM_MASK_INDEX(SNDRV_PCM_HW_PARAM_LAST_MASK) + 1];
214 struct snd_interval intervals[SNDRV_PCM_HW_PARAM_LAST_INTERVAL - 214 struct snd_interval intervals[
215 SNDRV_PCM_HW_PARAM_FIRST_INTERVAL + 1]; 215 SNDRV_PCM_HW_PARAM_INTERVAL_INDEX(SNDRV_PCM_HW_PARAM_LAST_INTERVAL) + 1];
216 unsigned int rules_num; 216 unsigned int rules_num;
217 unsigned int rules_all; 217 unsigned int rules_all;
218 struct snd_pcm_hw_rule *rules; 218 struct snd_pcm_hw_rule *rules;
@@ -221,13 +221,13 @@ struct snd_pcm_hw_constraints {
221static inline struct snd_mask *constrs_mask(struct snd_pcm_hw_constraints *constrs, 221static inline struct snd_mask *constrs_mask(struct snd_pcm_hw_constraints *constrs,
222 snd_pcm_hw_param_t var) 222 snd_pcm_hw_param_t var)
223{ 223{
224 return &constrs->masks[var - SNDRV_PCM_HW_PARAM_FIRST_MASK]; 224 return &constrs->masks[SNDRV_PCM_HW_PARAM_MASK_INDEX(var)];
225} 225}
226 226
227static inline struct snd_interval *constrs_interval(struct snd_pcm_hw_constraints *constrs, 227static inline struct snd_interval *constrs_interval(struct snd_pcm_hw_constraints *constrs,
228 snd_pcm_hw_param_t var) 228 snd_pcm_hw_param_t var)
229{ 229{
230 return &constrs->intervals[var - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL]; 230 return &constrs->intervals[SNDRV_PCM_HW_PARAM_INTERVAL_INDEX(var)];
231} 231}
232 232
233struct snd_ratnum { 233struct snd_ratnum {
@@ -761,40 +761,40 @@ static inline void snd_pcm_trigger_done(struct snd_pcm_substream *substream,
761 substream->runtime->trigger_master = master; 761 substream->runtime->trigger_master = master;
762} 762}
763 763
764static inline int hw_is_mask(int var) 764static inline int hw_is_mask(snd_pcm_hw_param_t var)
765{ 765{
766 return var >= SNDRV_PCM_HW_PARAM_FIRST_MASK && 766 return (__force int)var >= (__force int)SNDRV_PCM_HW_PARAM_FIRST_MASK &&
767 var <= SNDRV_PCM_HW_PARAM_LAST_MASK; 767 (__force int)var <= (__force int)SNDRV_PCM_HW_PARAM_LAST_MASK;
768} 768}
769 769
770static inline int hw_is_interval(int var) 770static inline int hw_is_interval(snd_pcm_hw_param_t var)
771{ 771{
772 return var >= SNDRV_PCM_HW_PARAM_FIRST_INTERVAL && 772 return (__force int)var >= (__force int)SNDRV_PCM_HW_PARAM_FIRST_INTERVAL &&
773 var <= SNDRV_PCM_HW_PARAM_LAST_INTERVAL; 773 (__force int)var <= (__force int)SNDRV_PCM_HW_PARAM_LAST_INTERVAL;
774} 774}
775 775
776static inline struct snd_mask *hw_param_mask(struct snd_pcm_hw_params *params, 776static inline struct snd_mask *hw_param_mask(struct snd_pcm_hw_params *params,
777 snd_pcm_hw_param_t var) 777 snd_pcm_hw_param_t var)
778{ 778{
779 return &params->masks[var - SNDRV_PCM_HW_PARAM_FIRST_MASK]; 779 return &params->masks[SNDRV_PCM_HW_PARAM_MASK_INDEX(var)];
780} 780}
781 781
782static inline struct snd_interval *hw_param_interval(struct snd_pcm_hw_params *params, 782static inline struct snd_interval *hw_param_interval(struct snd_pcm_hw_params *params,
783 snd_pcm_hw_param_t var) 783 snd_pcm_hw_param_t var)
784{ 784{
785 return &params->intervals[var - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL]; 785 return &params->intervals[SNDRV_PCM_HW_PARAM_INTERVAL_INDEX(var)];
786} 786}
787 787
788static inline const struct snd_mask *hw_param_mask_c(const struct snd_pcm_hw_params *params, 788static inline const struct snd_mask *hw_param_mask_c(const struct snd_pcm_hw_params *params,
789 snd_pcm_hw_param_t var) 789 snd_pcm_hw_param_t var)
790{ 790{
791 return &params->masks[var - SNDRV_PCM_HW_PARAM_FIRST_MASK]; 791 return &params->masks[SNDRV_PCM_HW_PARAM_MASK_INDEX(var)];
792} 792}
793 793
794static inline const struct snd_interval *hw_param_interval_c(const struct snd_pcm_hw_params *params, 794static inline const struct snd_interval *hw_param_interval_c(const struct snd_pcm_hw_params *params,
795 snd_pcm_hw_param_t var) 795 snd_pcm_hw_param_t var)
796{ 796{
797 return &params->intervals[var - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL]; 797 return &params->intervals[SNDRV_PCM_HW_PARAM_INTERVAL_INDEX(var)];
798} 798}
799 799
800#define params_access(p) snd_mask_min(hw_param_mask((p), SNDRV_PCM_HW_PARAM_ACCESS)) 800#define params_access(p) snd_mask_min(hw_param_mask((p), SNDRV_PCM_HW_PARAM_ACCESS))