Skip to contentSkip to conversation

ALSA: Add params_width() helper

PATCH In review Mark Brown 2 participants 2 messages Dec 23, 2013 Sound

lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH 1/1 ALSA: Add params_width() helper

From: Mark Brown <[email protected]>

Add a helper for obtaining the width of a format directly from params since this is expected to become a common operation in ASoC.

---

Just starting on the ASoC changes to use this; I'm not 100% sure on the lack of prefixing for the name but it's consistent with the other uses so...

 include/sound/pcm_params.h | 6 ++++++
 1 file changed, 6 insertions(+)
include/sound/pcm_params.h +6 -0
index 37ae12e..47b03b4 100644
@@ -354,4 +354,10 @@ params_period_bytes(const struct snd_pcm_hw_params *p)
 		params_channels(p)) / 8;
 }
 
+static inline unsigned int
+params_width(const struct snd_pcm_hw_params *p)
+{
+	return snd_pcm_format_width(params_format(p));
+}
+
 #endif /* __SOUND_PCM_PARAMS_H */
Signature · 1 line
1.8.5.2
#1 lore raw

At Mon, 23 Dec 2013 12:48:58 +0000,

Quoted 6 lines · Mark Brown

From: Mark Brown <[email protected]>

Add a helper for obtaining the width of a format directly from params since this is expected to become a common operation in ASoC.

Quoted 6 lines

---

Just starting on the ASoC changes to use this; I'm not 100% sure on the lack of prefixing for the name but it's consistent with the other uses so...

It's an inline function, so let's keep the name as is, so far.

Quoted 8 lines
 include/sound/pcm_params.h | 6 ++++++
 1 file changed, 6 insertions(+)
include/sound/pcm_params.h +0 -0
index 37ae12e..47b03b4 100644

include/sound/pcm_params.h params_period_bytes(const struct snd_pcm_hw_params *p) · line 361

Quoted 8 lines
include/sound/pcm_params.h +5 -0
@@ -354,4 +354,10 @@ params_period_bytes(const struct snd_pcm_hw_params *p)
 		params_channels(p)) / 8;
 }
 
+static inline unsigned int
+params_width(const struct snd_pcm_hw_params *p)
+{
+	return snd_pcm_format_width(params_format(p));
+}

Better to use (signed) int, as snd_pcm_format_width() may return an negative error code for some formats.

Also, let's add *_physical_width() variant as well, if we add this.

Takashi