#define SNDRV_PCM_HW_PARAM_SUBFORMAT ((__force snd_pcm_hw_param_t) 2) /* Subformat */
#define SNDRV_PCM_HW_PARAM_FIRST_MASK SNDRV_PCM_HW_PARAM_ACCESS
#define SNDRV_PCM_HW_PARAM_LAST_MASK SNDRV_PCM_HW_PARAM_SUBFORMAT
+#define SNDRV_PCM_HW_PARAM_MASK_INDEX(var) \
+ ((__force int)(var) - (__force int)SNDRV_PCM_HW_PARAM_FIRST_MASK)
#define SNDRV_PCM_HW_PARAM_SAMPLE_BITS ((__force snd_pcm_hw_param_t) 8) /* Bits per sample */
#define SNDRV_PCM_HW_PARAM_FRAME_BITS ((__force snd_pcm_hw_param_t) 9) /* Bits per frame */
#define SNDRV_PCM_HW_PARAM_TICK_TIME ((__force snd_pcm_hw_param_t) 19) /* Approx tick duration in us */
#define SNDRV_PCM_HW_PARAM_FIRST_INTERVAL SNDRV_PCM_HW_PARAM_SAMPLE_BITS
#define SNDRV_PCM_HW_PARAM_LAST_INTERVAL SNDRV_PCM_HW_PARAM_TICK_TIME
+#define SNDRV_PCM_HW_PARAM_INTERVAL_INDEX(var) \
+ ((__force int)(var) - (__force int)SNDRV_PCM_HW_PARAM_FIRST_INTERVAL)
#define SNDRV_PCM_HW_PARAMS_NORESAMPLE (1<<0) /* avoid rate resampling */
struct snd_pcm_hw_params {
unsigned int flags;
- struct snd_mask masks[SNDRV_PCM_HW_PARAM_LAST_MASK -
- SNDRV_PCM_HW_PARAM_FIRST_MASK + 1];
+ struct snd_mask masks[
+ SNDRV_PCM_HW_PARAM_MASK_INDEX(SNDRV_PCM_HW_PARAM_LAST_MASK) + 1];
struct snd_mask mres[5]; /* reserved masks */
- struct snd_interval intervals[SNDRV_PCM_HW_PARAM_LAST_INTERVAL -
- SNDRV_PCM_HW_PARAM_FIRST_INTERVAL + 1];
+ struct snd_interval intervals[
+ SNDRV_PCM_HW_PARAM_INTERVAL_INDEX(SNDRV_PCM_HW_PARAM_LAST_INTERVAL) + 1];
struct snd_interval ires[9]; /* reserved intervals */
unsigned int rmask; /* W: requested masks */
unsigned int cmask; /* R: changed masks */
};
struct snd_pcm_hw_constraints {
- struct snd_mask masks[SNDRV_PCM_HW_PARAM_LAST_MASK -
- SNDRV_PCM_HW_PARAM_FIRST_MASK + 1];
- struct snd_interval intervals[SNDRV_PCM_HW_PARAM_LAST_INTERVAL -
- SNDRV_PCM_HW_PARAM_FIRST_INTERVAL + 1];
+ struct snd_mask masks[
+ SNDRV_PCM_HW_PARAM_MASK_INDEX(SNDRV_PCM_HW_PARAM_LAST_MASK) + 1];
+ struct snd_interval intervals[
+ SNDRV_PCM_HW_PARAM_INTERVAL_INDEX(SNDRV_PCM_HW_PARAM_LAST_INTERVAL) + 1];
unsigned int rules_num;
unsigned int rules_all;
struct snd_pcm_hw_rule *rules;
static inline struct snd_mask *constrs_mask(struct snd_pcm_hw_constraints *constrs,
snd_pcm_hw_param_t var)
{
- return &constrs->masks[var - SNDRV_PCM_HW_PARAM_FIRST_MASK];
+ return &constrs->masks[SNDRV_PCM_HW_PARAM_MASK_INDEX(var)];
}
static inline struct snd_interval *constrs_interval(struct snd_pcm_hw_constraints *constrs,
snd_pcm_hw_param_t var)
{
- return &constrs->intervals[var - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL];
+ return &constrs->intervals[SNDRV_PCM_HW_PARAM_INTERVAL_INDEX(var)];
}
struct snd_ratnum {
substream->runtime->trigger_master = master;
}
-static inline int hw_is_mask(int var)
+static inline int hw_is_mask(snd_pcm_hw_param_t var)
{
- return var >= SNDRV_PCM_HW_PARAM_FIRST_MASK &&
- var <= SNDRV_PCM_HW_PARAM_LAST_MASK;
+ return (__force int)var >= (__force int)SNDRV_PCM_HW_PARAM_FIRST_MASK &&
+ (__force int)var <= (__force int)SNDRV_PCM_HW_PARAM_LAST_MASK;
}
-static inline int hw_is_interval(int var)
+static inline int hw_is_interval(snd_pcm_hw_param_t var)
{
- return var >= SNDRV_PCM_HW_PARAM_FIRST_INTERVAL &&
- var <= SNDRV_PCM_HW_PARAM_LAST_INTERVAL;
+ return (__force int)var >= (__force int)SNDRV_PCM_HW_PARAM_FIRST_INTERVAL &&
+ (__force int)var <= (__force int)SNDRV_PCM_HW_PARAM_LAST_INTERVAL;
}
static inline struct snd_mask *hw_param_mask(struct snd_pcm_hw_params *params,
snd_pcm_hw_param_t var)
{
- return ¶ms->masks[var - SNDRV_PCM_HW_PARAM_FIRST_MASK];
+ return ¶ms->masks[SNDRV_PCM_HW_PARAM_MASK_INDEX(var)];
}
static inline struct snd_interval *hw_param_interval(struct snd_pcm_hw_params *params,
snd_pcm_hw_param_t var)
{
- return ¶ms->intervals[var - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL];
+ return ¶ms->intervals[SNDRV_PCM_HW_PARAM_INTERVAL_INDEX(var)];
}
static inline const struct snd_mask *hw_param_mask_c(const struct snd_pcm_hw_params *params,
snd_pcm_hw_param_t var)
{
- return ¶ms->masks[var - SNDRV_PCM_HW_PARAM_FIRST_MASK];
+ return ¶ms->masks[SNDRV_PCM_HW_PARAM_MASK_INDEX(var)];
}
static inline const struct snd_interval *hw_param_interval_c(const struct snd_pcm_hw_params *params,
snd_pcm_hw_param_t var)
{
- return ¶ms->intervals[var - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL];
+ return ¶ms->intervals[SNDRV_PCM_HW_PARAM_INTERVAL_INDEX(var)];
}
#define params_access(p) snd_mask_min(hw_param_mask((p), SNDRV_PCM_HW_PARAM_ACCESS))