Skip to content

Commit b51beb7

Browse files
committed
ALSA: Make pcm.h self-contained
Move the macros depending on snd_mask_min() and co out of pcm.h into pcm_params.h. Otherwise using some params_*() macros will give comiple errors without inclusion of pcm_params.h. Also use hw_param_interval_c() and hw_param_mask_c() for const pointer. Reported-by: Tim Blechmann <tim@klingt.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 4d7fbdb commit b51beb7

2 files changed

Lines changed: 27 additions & 12 deletions

File tree

‎include/sound/pcm.h‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -761,17 +761,18 @@ static inline const struct snd_interval *hw_param_interval_c(const struct snd_pc
761761
return &params->intervals[var - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL];
762762
}
763763

764-
#define params_access(p) ((__force snd_pcm_access_t)snd_mask_min(hw_param_mask((p), SNDRV_PCM_HW_PARAM_ACCESS)))
765-
#define params_format(p) ((__force snd_pcm_format_t)snd_mask_min(hw_param_mask((p), SNDRV_PCM_HW_PARAM_FORMAT)))
766-
#define params_subformat(p) snd_mask_min(hw_param_mask((p), SNDRV_PCM_HW_PARAM_SUBFORMAT))
767-
#define params_channels(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_CHANNELS)->min
768-
#define params_rate(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_RATE)->min
769-
#define params_period_size(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_PERIOD_SIZE)->min
770-
#define params_period_bytes(p) ((params_period_size(p)*snd_pcm_format_physical_width(params_format(p))*params_channels(p))/8)
771-
#define params_periods(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_PERIODS)->min
772-
#define params_buffer_size(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_BUFFER_SIZE)->min
773-
#define params_buffer_bytes(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_BUFFER_BYTES)->min
774-
764+
#define params_channels(p) \
765+
(hw_param_interval_c((p), SNDRV_PCM_HW_PARAM_CHANNELS)->min)
766+
#define params_rate(p) \
767+
(hw_param_interval_c((p), SNDRV_PCM_HW_PARAM_RATE)->min)
768+
#define params_period_size(p) \
769+
(hw_param_interval_c((p), SNDRV_PCM_HW_PARAM_PERIOD_SIZE)->min)
770+
#define params_periods(p) \
771+
(hw_param_interval_c((p), SNDRV_PCM_HW_PARAM_PERIODS)->min)
772+
#define params_buffer_size(p) \
773+
(hw_param_interval_c((p), SNDRV_PCM_HW_PARAM_BUFFER_SIZE)->min)
774+
#define params_buffer_bytes(p) \
775+
(hw_param_interval_c((p), SNDRV_PCM_HW_PARAM_BUFFER_BYTES)->min)
775776

776777
int snd_interval_refine(struct snd_interval *i, const struct snd_interval *v);
777778
void snd_interval_mul(const struct snd_interval *a, const struct snd_interval *b, struct snd_interval *c);

‎include/sound/pcm_params.h‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,5 +337,19 @@ static inline unsigned int sub(unsigned int a, unsigned int b)
337337
return 0;
338338
}
339339

340-
#endif /* __SOUND_PCM_PARAMS_H */
340+
#define params_access(p) ((__force snd_pcm_access_t)\
341+
snd_mask_min(hw_param_mask_c((p), SNDRV_PCM_HW_PARAM_ACCESS)))
342+
#define params_format(p) ((__force snd_pcm_format_t)\
343+
snd_mask_min(hw_param_mask_c((p), SNDRV_PCM_HW_PARAM_FORMAT)))
344+
#define params_subformat(p) \
345+
snd_mask_min(hw_param_mask_c((p), SNDRV_PCM_HW_PARAM_SUBFORMAT))
341346

347+
static inline unsigned int
348+
params_period_bytes(const struct snd_pcm_hw_params *p)
349+
{
350+
return (params_period_size(p) *
351+
snd_pcm_format_physical_width(params_format(p)) *
352+
params_channels(p)) / 8;
353+
}
354+
355+
#endif /* __SOUND_PCM_PARAMS_H */

0 commit comments

Comments
 (0)