ALSA: Add helper function to add single value constraint
Subsystems (4)
Lars-Peter Clausen
maintainercover ALSA: Add helper function to add single value constraint
Apologies if you got this series twice, forgot to Cc the mailinglist on the first try.
This series introduces a new helper function which can be used to constrain a configuration parameter to a single. So far the recommended and most efficient way to do this was to set a min-max constraint with the same value for minimum and maximum. It is not necessarily immediately obvious though that this is the right way to do things and some driver have come up with different ways to achieve the same effect, e.g. by installing a list constraint with a single item. This is less efficient since list constraints are dynamic constraints which needed to be re-evaluated multiple times at runtime while a min-max constraint is a static constraint.
The function introduced in this patch series is called snd_pcm_hw_constraint_single() which hopefully is semantically more expressive and makes it clear that this is the function to use when setting a single value constraint.
All existing drivers that want to set a single value constraint are update to use the new helper function.
- Lars
Lars-Peter Clausen (18):
ALSA: Add helper function to add single value constraint
ALSA: korg1212: Use snd_pcm_hw_constraint_single()
ALAA: lx6464es: Use snd_pcm_hw_constraint_single()
ALSA: rme32: Use snd_pcm_hw_constraint_single()
ALSA: rme96: Use snd_pcm_hw_constraint_single()
ALSA: rme9652: Use snd_pcm_hw_constraint_single()
ASoC: adav80x: Use snd_pcm_hw_constraint_single()
ASoC: twl4030: Use snd_pcm_hw_constraint_single()
ASoC: uda134x: Use snd_pcm_hw_constraint_single()
ASoC: wl1273: Use snd_pcm_hw_constraint_single()
ASoC: n810: Use snd_pcm_hw_constraint_single()
ASoC: rx51: Use snd_pcm_hw_constraint_single()
ASoC: pcm: Use snd_pcm_hw_constraint_single()
ASoC: ux500: Use snd_pcm_hw_constraint_single()
ASoC: bytcr_rt5640: Use snd_pcm_hw_constraint_single()
ASoC: cht_bsw_max98090: Use snd_pcm_hw_constraint_single()
ASoC: cht_bsw_rt5645: Use snd_pcm_hw_constraint_single()
ASoC: cht_bsw_rt5672: Use snd_pcm_hw_constraint_single()
include/sound/pcm.h | 16 ++++++++++++++++ sound/pci/korg1212/korg1212.c | 8 +++++--- sound/pci/lx6464es/lx6464es.c | 4 ++-- sound/pci/rme32.c | 4 ++-- sound/pci/rme96.c | 8 ++++---- sound/pci/rme9652/hdspm.c | 9 ++++----- sound/soc/codecs/adav80x.c | 4 ++-- sound/soc/codecs/twl4030.c | 13 +++++-------- sound/soc/codecs/uda134x.c | 6 ++---- sound/soc/codecs/wl1273.c | 9 ++++----- sound/soc/intel/boards/bytcr_rt5640.c | 14 ++------------ sound/soc/intel/boards/cht_bsw_max98090_ti.c | 14 ++------------ sound/soc/intel/boards/cht_bsw_rt5645.c | 14 ++------------ sound/soc/intel/boards/cht_bsw_rt5672.c | 14 ++------------ sound/soc/omap/n810.c | 3 +-- sound/soc/omap/rx51.c | 3 +-- sound/soc/soc-pcm.c | 10 ++++------ sound/soc/ux500/ux500_msp_dai.c | 4 ++-- 18 files changed, 62 insertions(+), 95 deletions(-)
Signature · 1 line
2.1.4
Lars-Peter Clausen
maintainerPATCH 1/18 ALSA: Add helper function to add single value constraint
The recommended and most efficient way to constraint a configuration parameter to a single value is to set the minimum and maximum allowed values to the same value, i.e. calling snd_pcm_hw_constraint_minmax() with the same value for min and max.
It is not necessarily obvious though that this is the approach that should be taken and some drivers have come up with other ways of solving this problem, e.g. installing a list constraint with a single item. List constraints are dynamic constraints though and hence less efficient than the static min-max constraint.
This patch introduces a new helper function called snd_pcm_hw_constraint_single() which only takes a single value has the same effect as calling snd_pcm_hw_constraint_minmax() with the same values for min and max. But it is hopefully semantically more expressive, making it clear that this is the preferred way of setting a single value constraint.
--- include/sound/pcm.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
include/sound/pcm.h +16 -0
@@ -1028,6 +1028,22 @@ int snd_pcm_hw_rule_add(struct snd_pcm_runtime *runtime, snd_pcm_hw_rule_func_t func, void *private, int dep, ...); +/** +* snd_pcm_hw_constraint_single() - Constrain parameter to a single value +* @runtime: PCM runtime instance +* @var: The hw_params variable to constrain +* @val: The value to constrain to +* +* Return: Positive if the value is changed, zero if it's not changed, or a +* negative error code. +*/ +static inline int snd_pcm_hw_constraint_single ( +struct snd_pcm_runtime *runtime,snd_pcm_hw_param_t var, +unsigned int val) +{ +return snd_pcm_hw_constraint_minmax (runtime, var, val, val); +} +int snd_pcm_format_signed (snd_pcm_format_t format);int snd_pcm_format_unsigned (snd_pcm_format_t format);int snd_pcm_format_linear (snd_pcm_format_t format);
Signature · 1 line
2.1.4
Lars-Peter Clausen
maintainerPATCH 2/18 ALSA: korg1212: Use snd_pcm_hw_constraint_single()
In reply to Lars-Peter ClausenUse the new snd_pcm_hw_constraint_single() helper function instead of calling snd_pcm_hw_constraint_minmax() with the same value for min and max to install a constraint that limits the possible configuration values to a single value. Using snd_pcm_hw_constraint_single() makes the indented result clearer.
While we are at it also fix some code style issues in the affected lines.
--- sound/pci/korg1212/korg1212.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
sound/pci/korg1212/korg1212.c +5 -3
@@ -1394,7 +1394,9 @@ static int snd_korg1212_playback_open(struct snd_pcm_substream *substream)spin_unlock_irqrestore (&korg1212->lock, flags); -snd_pcm_hw_constraint_minmax (runtime,SNDRV_PCM_HW_PARAM_PERIOD_SIZE , kPlayBufferFrames, kPlayBufferFrames); +snd_pcm_hw_constraint_single (runtime,SNDRV_PCM_HW_PARAM_PERIOD_SIZE , + kPlayBufferFrames); +return 0 ; }
@@ -1422,8 +1424,8 @@ static int snd_korg1212_capture_open(struct snd_pcm_substream *substream)spin_unlock_irqrestore (&korg1212->lock, flags); -snd_pcm_hw_constraint_minmax (runtime,SNDRV_PCM_HW_PARAM_PERIOD_SIZE , - kPlayBufferFrames, kPlayBufferFrames); +snd_pcm_hw_constraint_single (runtime,SNDRV_PCM_HW_PARAM_PERIOD_SIZE , + kPlayBufferFrames);return 0 ; }
Signature · 1 line
2.1.4
Lars-Peter Clausen
maintainerPATCH 3/18 ALSA: lx6464es: Use snd_pcm_hw_constraint_single()
In reply to Lars-Peter ClausenUse the new snd_pcm_hw_constraint_single() helper function instead of calling snd_pcm_hw_constraint_minmax() with the same value for min and max to install a constraint that limits the possible configuration values to a single value. Using snd_pcm_hw_constraint_single() makes the indented result clearer.
--- sound/pci/lx6464es/lx6464es.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/pci/lx6464es/lx6464es.c +2 -2
@@ -234,8 +234,8 @@ static int lx_pcm_open(struct snd_pcm_substream *substream)/* the clock rate cannot be changed */ board_rate = chip->board_sample_rate; - err =snd_pcm_hw_constraint_minmax (runtime,SNDRV_PCM_HW_PARAM_RATE , - board_rate, board_rate); + err =snd_pcm_hw_constraint_single (runtime,SNDRV_PCM_HW_PARAM_RATE , + board_rate);if (err <0 ) {dev_warn (chip->card->dev,"could not constrain periods\n" );
Signature · 1 line
2.1.4
Lars-Peter Clausen
maintainerPATCH 4/18 ALSA: rme32: Use snd_pcm_hw_constraint_single()
In reply to Lars-Peter ClausenUse the new snd_pcm_hw_constraint_single() helper function instead of calling snd_pcm_hw_constraint_minmax() with the same value for min and max to install a constraint that limits the possible configuration values to a single value. Using snd_pcm_hw_constraint_single() makes the indented result clearer.
--- sound/pci/rme32.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/pci/rme32.c +2 -2
@@ -831,9 +831,9 @@ static struct snd_pcm_hw_constraint_list hw_constraints_period_bytes = {static void snd_rme32_set_buffer_constraint (struct rme32 *rme32,struct snd_pcm_runtime *runtime) {if (! rme32->fullduplex_mode) { -snd_pcm_hw_constraint_minmax (runtime, +snd_pcm_hw_constraint_single (runtime,SNDRV_PCM_HW_PARAM_BUFFER_BYTES , -RME32_BUFFER_SIZE ,RME32_BUFFER_SIZE ); +RME32_BUFFER_SIZE );snd_pcm_hw_constraint_list (runtime,0 ,SNDRV_PCM_HW_PARAM_PERIOD_BYTES , &hw_constraints_period_bytes);
Signature · 1 line
2.1.4
Lars-Peter Clausen
maintainerPATCH 5/18 ALSA: rme96: Use snd_pcm_hw_constraint_single()
In reply to Lars-Peter ClausenUse the new snd_pcm_hw_constraint_single() helper function instead of calling snd_pcm_hw_constraint_minmax() with the same value for min and max to install a constraint that limits the possible configuration values to a single value. Using snd_pcm_hw_constraint_single() makes the indented result clearer.
--- sound/pci/rme96.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
sound/pci/rme96.c +4 -4
@@ -1152,13 +1152,13 @@ rme96_set_buffer_size_constraint(struct rme96 *rme96, {unsigned int size; -snd_pcm_hw_constraint_minmax (runtime,SNDRV_PCM_HW_PARAM_BUFFER_BYTES , -RME96_BUFFER_SIZE ,RME96_BUFFER_SIZE ); +snd_pcm_hw_constraint_single (runtime,SNDRV_PCM_HW_PARAM_BUFFER_BYTES , +RME96_BUFFER_SIZE );if ((size = rme96->playback_periodsize) !=0 || (size = rme96->capture_periodsize) !=0 ) -snd_pcm_hw_constraint_minmax (runtime, +snd_pcm_hw_constraint_single (runtime,SNDRV_PCM_HW_PARAM_PERIOD_BYTES , - size, size); + size);else snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES,
Signature · 1 line
2.1.4
Lars-Peter Clausen
maintainerPATCH 6/18 ALSA: rme9652: Use snd_pcm_hw_constraint_single()
In reply to Lars-Peter ClausenUse the new snd_pcm_hw_constraint_single() helper function instead of calling snd_pcm_hw_constraint_minmax() with the same value for min and max to install a constraint that limits the possible configuration values to a single value. Using snd_pcm_hw_constraint_single() makes the indented result clearer.
--- sound/pci/rme9652/hdspm.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
sound/pci/rme9652/hdspm.c +4 -5
@@ -6080,18 +6080,17 @@ static int snd_hdspm_open(struct snd_pcm_substream *substream)SNDRV_PCM_HW_PARAM_PERIOD_SIZE , 32, 4096);/* RayDAT & AIO have a fixed buffer of 16384 samples per channel */ -snd_pcm_hw_constraint_minmax (runtime, +snd_pcm_hw_constraint_single (runtime,SNDRV_PCM_HW_PARAM_BUFFER_SIZE , -16384 ,16384 ); +16384 );break ;default :snd_pcm_hw_constraint_minmax (runtime,SNDRV_PCM_HW_PARAM_PERIOD_SIZE ,64 ,8192 ); -snd_pcm_hw_constraint_minmax (runtime, -SNDRV_PCM_HW_PARAM_PERIODS , -2 ,2 ); +snd_pcm_hw_constraint_single (runtime, +SNDRV_PCM_HW_PARAM_PERIODS ,2 );break ; }
Signature · 1 line
2.1.4
Lars-Peter Clausen
maintainerPATCH 7/18 ASoC: adav80x: Use snd_pcm_hw_constraint_single()
In reply to Lars-Peter ClausenUse the new snd_pcm_hw_constraint_single() helper function instead of calling snd_pcm_hw_constraint_minmax() with the same value for min and max to install a constraint that limits the possible configuration values to a single value. Using snd_pcm_hw_constraint_single() makes the indented result clearer.
--- sound/soc/codecs/adav80x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/codecs/adav80x.c +2 -2
@@ -728,8 +728,8 @@ static int adav80x_dai_startup(struct snd_pcm_substream *substream,if (!snd_soc_codec_is_active (codec) || !adav80x->rate)return 0 ; -return snd_pcm_hw_constraint_minmax (substream->runtime, -SNDRV_PCM_HW_PARAM_RATE , adav80x->rate, adav80x->rate); +return snd_pcm_hw_constraint_single (substream->runtime, +SNDRV_PCM_HW_PARAM_RATE , adav80x->rate); } static void adav80x_dai_shutdown(struct snd_pcm_substream *substream,
Signature · 1 line
2.1.4
Lars-Peter Clausen
maintainerPATCH 8/18 ASoC: twl4030: Use snd_pcm_hw_constraint_single()
In reply to Lars-Peter ClausenUse the new snd_pcm_hw_constraint_single() helper function instead of calling snd_pcm_hw_constraint_minmax() with the same value for min and max to install a constraint that limits the possible configuration values to a single value. Using snd_pcm_hw_constraint_single() makes the indented result clearer and is slightly shorter.
--- sound/soc/codecs/twl4030.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
sound/soc/codecs/twl4030.c +5 -8
@@ -1612,19 +1612,16 @@ static void twl4030_constraints(struct twl4030_priv *twl4030,return ;/* Set the constraints according to the already configured stream */ -snd_pcm_hw_constraint_minmax (slv_substream->runtime, +snd_pcm_hw_constraint_single (slv_substream->runtime,SNDRV_PCM_HW_PARAM_RATE , - twl4030->rate, twl4030->rate); -snd_pcm_hw_constraint_minmax (slv_substream->runtime, +snd_pcm_hw_constraint_single (slv_substream->runtime,SNDRV_PCM_HW_PARAM_SAMPLE_BITS , - twl4030->sample_bits, twl4030->sample_bits); -snd_pcm_hw_constraint_minmax (slv_substream->runtime, +snd_pcm_hw_constraint_single (slv_substream->runtime,SNDRV_PCM_HW_PARAM_CHANNELS , - twl4030->channels, twl4030->channels); }
@@ -1669,9 +1666,9 @@ static int twl4030_startup(struct snd_pcm_substream *substream,/* In option2 4 channel is not supported, set the * constraint for the first stream for channels, the * second stream will 'inherit' this cosntraint */ -snd_pcm_hw_constraint_minmax (substream->runtime, +snd_pcm_hw_constraint_single (substream->runtime,SNDRV_PCM_HW_PARAM_CHANNELS , -2 ,2 ); +2 ); } twl4030->master_substream = substream; }
Signature · 1 line
2.1.4
Re: [PATCH 08/18] ASoC: twl4030: Use snd_pcm_hw_constraint_single()
Quoted 7 lines · Lars-Peter Clausen
Use the new
snd_pcm_hw_constraint_single()helper function instead of callingsnd_pcm_hw_constraint_minmax()with the same value for min and max to install a constraint that limits the possible configuration values to a single value. Usingsnd_pcm_hw_constraint_single()makes the indented result clearer and is slightly shorter.Signed-off-by Lars-Peter Clausen <[email protected]>
Quoted 44 lines
--- sound/soc/codecs/twl4030.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)sound/soc/codecs/twl4030.c +5
-8@@ -1612,19 +1612,16 @@ static void twl4030_constraints(struct twl4030_priv *twl4030,return ;/* Set the constraints according to the already configured stream */ -snd_pcm_hw_constraint_minmax (slv_substream->runtime, +snd_pcm_hw_constraint_single (slv_substream->runtime,SNDRV_PCM_HW_PARAM_RATE , - twl4030->rate, twl4030->rate); -snd_pcm_hw_constraint_minmax (slv_substream->runtime, +snd_pcm_hw_constraint_single (slv_substream->runtime,SNDRV_PCM_HW_PARAM_SAMPLE_BITS , - twl4030->sample_bits, twl4030->sample_bits); -snd_pcm_hw_constraint_minmax (slv_substream->runtime, +snd_pcm_hw_constraint_single (slv_substream->runtime,SNDRV_PCM_HW_PARAM_CHANNELS , - twl4030->channels, twl4030->channels); }@@ -1669,9 +1666,9 @@ static int twl4030_startup(struct snd_pcm_substream *substream,/* In option2 4 channel is not supported, set the * constraint for the first stream for channels, the * second stream will 'inherit' this cosntraint */ -snd_pcm_hw_constraint_minmax (substream->runtime, +snd_pcm_hw_constraint_single (substream->runtime,SNDRV_PCM_HW_PARAM_CHANNELS , -2 ,2 ); +2 ); } twl4030->master_substream = substream; }
Signature · 1 line
Péter
Lars-Peter Clausen
maintainerPATCH 9/18 ASoC: uda134x: Use snd_pcm_hw_constraint_single()
In reply to Lars-Peter ClausenUse the new snd_pcm_hw_constraint_single() helper function instead of calling snd_pcm_hw_constraint_minmax() with the same value for min and max to install a constraint that limits the possible configuration values to a single value. Using snd_pcm_hw_constraint_single() makes the indented result clearer and is slightly shorter.
--- sound/soc/codecs/uda134x.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
sound/soc/codecs/uda134x.c +2 -4
@@ -150,14 +150,12 @@ static int uda134x_startup(struct snd_pcm_substream *substream, master_runtime->sample_bits, master_runtime->rate); -snd_pcm_hw_constraint_minmax (substream->runtime, +snd_pcm_hw_constraint_single (substream->runtime,SNDRV_PCM_HW_PARAM_RATE , - master_runtime->rate, master_runtime->rate); -snd_pcm_hw_constraint_minmax (substream->runtime, +snd_pcm_hw_constraint_single (substream->runtime,SNDRV_PCM_HW_PARAM_SAMPLE_BITS , - master_runtime->sample_bits, master_runtime->sample_bits); uda134x->slave_substream = substream;
Signature · 1 line
2.1.4
Lars-Peter Clausen
maintainerPATCH 10/18 ASoC: wl1273: Use snd_pcm_hw_constraint_single()
In reply to Lars-Peter ClausenUse the new snd_pcm_hw_constraint_single() helper function instead of calling snd_pcm_hw_constraint_minmax() with the same value for min and max to install a constraint that limits the possible configuration values to a single value. Using snd_pcm_hw_constraint_single() makes the indented result clearer.
--- sound/soc/codecs/wl1273.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
sound/soc/codecs/wl1273.c +4 -5
@@ -307,11 +307,10 @@ static int wl1273_startup(struct snd_pcm_substream *substream,switch (wl1273->mode) {case WL1273_MODE_BT : -snd_pcm_hw_constraint_minmax (substream->runtime, -SNDRV_PCM_HW_PARAM_RATE , -8000 ,8000 ); -snd_pcm_hw_constraint_minmax (substream->runtime, -SNDRV_PCM_HW_PARAM_CHANNELS ,1 ,1 ); +snd_pcm_hw_constraint_single (substream->runtime, +SNDRV_PCM_HW_PARAM_RATE ,8000 ); +snd_pcm_hw_constraint_single (substream->runtime, +SNDRV_PCM_HW_PARAM_CHANNELS ,1 );break ;case WL1273_MODE_FM_RX :if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) {
Signature · 1 line
2.1.4
Lars-Peter Clausen
maintainerPATCH 11/18 ASoC: n810: Use snd_pcm_hw_constraint_single()
In reply to Lars-Peter ClausenUse the new snd_pcm_hw_constraint_single() helper function instead of calling snd_pcm_hw_constraint_minmax() with the same value for min and max to install a constraint that limits the possible configuration values to a single value. Using snd_pcm_hw_constraint_single() makes the indented result clearer and is slightly shorter.
--- sound/soc/omap/n810.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
sound/soc/omap/n810.c +1 -2
@@ -99,8 +99,7 @@ static int n810_startup(struct snd_pcm_substream *substream)struct snd_pcm_runtime *runtime = substream->runtime;struct snd_soc_pcm_runtime *rtd = substream->private_data; -snd_pcm_hw_constraint_minmax (runtime, -SNDRV_PCM_HW_PARAM_CHANNELS ,2 ,2 ); +snd_pcm_hw_constraint_single (runtime,SNDRV_PCM_HW_PARAM_CHANNELS ,2 );n810_ext_control (&rtd->card->dapm);return clk_prepare_enable (sys_clkout2);
Signature · 1 line
2.1.4
Re: [PATCH 11/18] ASoC: n810: Use snd_pcm_hw_constraint_single()
Quoted 17 lines · Lars-Peter Clausen
Use the new
snd_pcm_hw_constraint_single()helper function instead of callingsnd_pcm_hw_constraint_minmax()with the same value for min and max to install a constraint that limits the possible configuration values to a single value. Usingsnd_pcm_hw_constraint_single()makes the indented result clearer and is slightly shorter.Signed-off-by Lars-Peter Clausen <[email protected]>--- sound/soc/omap/n810.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)sound/soc/omap/n810.c +0
-0
sound/soc/omap/n810.c static int n810_startup(struct snd_pcm_substream *substream) · line 105
Quoted 9 lines
sound/soc/omap/n810.c +1
-2@@ -99,8 +99,7 @@ static int n810_startup(struct snd_pcm_substream *substream)struct snd_pcm_runtime *runtime = substream->runtime;struct snd_soc_pcm_runtime *rtd = substream->private_data; -snd_pcm_hw_constraint_minmax (runtime, -SNDRV_PCM_HW_PARAM_CHANNELS ,2 ,2 ); +snd_pcm_hw_constraint_single (runtime,SNDRV_PCM_HW_PARAM_CHANNELS ,2 );n810_ext_control (&rtd->card->dapm);return clk_prepare_enable (sys_clkout2);
Lars-Peter Clausen
maintainerPATCH 12/18 ASoC: rx51: Use snd_pcm_hw_constraint_single()
In reply to Lars-Peter ClausenUse the new snd_pcm_hw_constraint_single() helper function instead of calling snd_pcm_hw_constraint_minmax() with the same value for min and max to install a constraint that limits the possible configuration values to a single value. Using snd_pcm_hw_constraint_single() makes the indented result clearer and is slightly shorter.
--- sound/soc/omap/rx51.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
sound/soc/omap/rx51.c +1 -2
@@ -107,8 +107,7 @@ static int rx51_startup(struct snd_pcm_substream *substream)struct snd_soc_pcm_runtime *rtd = substream->private_data;struct snd_soc_card *card = rtd->card; -snd_pcm_hw_constraint_minmax (runtime, -SNDRV_PCM_HW_PARAM_CHANNELS ,2 ,2 ); +snd_pcm_hw_constraint_single (runtime,SNDRV_PCM_HW_PARAM_CHANNELS ,2 );rx51_ext_control (&card->dapm);return 0 ;
Signature · 1 line
2.1.4
Re: [PATCH 12/18] ASoC: rx51: Use snd_pcm_hw_constraint_single()
Quoted 17 lines · Lars-Peter Clausen
Use the new
snd_pcm_hw_constraint_single()helper function instead of callingsnd_pcm_hw_constraint_minmax()with the same value for min and max to install a constraint that limits the possible configuration values to a single value. Usingsnd_pcm_hw_constraint_single()makes the indented result clearer and is slightly shorter.Signed-off-by Lars-Peter Clausen <[email protected]>--- sound/soc/omap/rx51.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)sound/soc/omap/rx51.c +0
-0
sound/soc/omap/rx51.c static int rx51_startup(struct snd_pcm_substream *substream) · line 113
Quoted 9 lines
sound/soc/omap/rx51.c +1
-2@@ -107,8 +107,7 @@ static int rx51_startup(struct snd_pcm_substream *substream)struct snd_soc_pcm_runtime *rtd = substream->private_data;struct snd_soc_card *card = rtd->card; -snd_pcm_hw_constraint_minmax (runtime, -SNDRV_PCM_HW_PARAM_CHANNELS ,2 ,2 ); +snd_pcm_hw_constraint_single (runtime,SNDRV_PCM_HW_PARAM_CHANNELS ,2 );rx51_ext_control (&card->dapm);return 0 ;
Lars-Peter Clausen
maintainerPATCH 13/18 ASoC: pcm: Use snd_pcm_hw_constraint_single()
In reply to Lars-Peter ClausenUse the new snd_pcm_hw_constraint_single() helper function instead of calling snd_pcm_hw_constraint_minmax() with the same value for min and max to install a constraint that limits the possible configuration values to a single value. Using snd_pcm_hw_constraint_single() makes the indented result clearer and is slightly shorter.
--- sound/soc/soc-pcm.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
sound/soc/soc-pcm.c +4 -6
@@ -200,9 +200,9 @@ static int soc_pcm_apply_symmetry(struct snd_pcm_substream *substream,dev_dbg (soc_dai->dev,"ASoC: Symmetry forces %dHz rate\n" , soc_dai->rate); - ret =snd_pcm_hw_constraint_minmax (substream->runtime, + ret =snd_pcm_hw_constraint_single (substream->runtime,SNDRV_PCM_HW_PARAM_RATE , - soc_dai->rate, soc_dai->rate); + soc_dai->rate);if (ret <0 ) { dev_err(soc_dai->dev, "ASoC: Unable to apply rate constraint: %d\n",
@@ -216,9 +216,8 @@ static int soc_pcm_apply_symmetry(struct snd_pcm_substream *substream,dev_dbg (soc_dai->dev,"ASoC: Symmetry forces %d channel(s)\n" , soc_dai->channels); - ret =snd_pcm_hw_constraint_minmax (substream->runtime, + ret =snd_pcm_hw_constraint_single (substream->runtime,SNDRV_PCM_HW_PARAM_CHANNELS , - soc_dai->channels, soc_dai->channels);if (ret <0 ) { dev_err(soc_dai->dev,
@@ -233,9 +232,8 @@ static int soc_pcm_apply_symmetry(struct snd_pcm_substream *substream,dev_dbg (soc_dai->dev,"ASoC: Symmetry forces %d sample bits\n" , soc_dai->sample_bits); - ret =snd_pcm_hw_constraint_minmax (substream->runtime, + ret =snd_pcm_hw_constraint_single (substream->runtime,SNDRV_PCM_HW_PARAM_SAMPLE_BITS , - soc_dai->sample_bits, soc_dai->sample_bits);if (ret <0 ) { dev_err(soc_dai->dev,
Signature · 1 line
2.1.4
Lars-Peter Clausen
maintainerPATCH 14/18 ASoC: ux500: Use snd_pcm_hw_constraint_single()
In reply to Lars-Peter ClausenUse the new snd_pcm_hw_constraint_single() helper function instead of calling snd_pcm_hw_constraint_minmax() with the same value for min and max to install a constraint that limits the possible configuration values to a single value. Using snd_pcm_hw_constraint_single() makes the indented result clearer.
--- sound/soc/ux500/ux500_msp_dai.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/ux500/ux500_msp_dai.c +2 -2
@@ -522,9 +522,9 @@ static int ux500_msp_dai_hw_params(struct snd_pcm_substream *substream, slots_active =hweight32 (mask);dev_dbg (dai->dev,"TDM-slots active: %d" , slots_active); -snd_pcm_hw_constraint_minmax (runtime, +snd_pcm_hw_constraint_single (runtime,SNDRV_PCM_HW_PARAM_CHANNELS , - slots_active, slots_active); + slots_active);break ;default :
Signature · 1 line
2.1.4
Lars-Peter Clausen
maintainerPATCH 15/18 ASoC: bytcr_rt5640: Use snd_pcm_hw_constraint_single()
In reply to Lars-Peter ClausenUse the new snd_pcm_hw_constraint_single() helper function rather than installing a list constraint with a single value. Since snd_pcm_hw_constraint_single() sets a static constraint while snd_pcm_hw_constraint_list() sets a dynamic constraint the former is slightly more efficient and it also needs less code.
--- sound/soc/intel/boards/bytcr_rt5640.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-)
sound/soc/intel/boards/bytcr_rt5640.c +2 -12
@@ -117,20 +117,10 @@ static int byt_codec_fixup(struct snd_soc_pcm_runtime *rtd,return 0 ; } -static unsigned int rates_48000[] = { -48000 , -}; - -static struct snd_pcm_hw_constraint_list constraints_48000 = { - .count =ARRAY_SIZE (rates_48000), - .list = rates_48000, -}; -static int byt_aif1_startup (struct snd_pcm_substream *substream) { -return snd_pcm_hw_constraint_list (substream->runtime,0 , -SNDRV_PCM_HW_PARAM_RATE , - &constraints_48000); +return snd_pcm_hw_constraint_single (substream->runtime, +SNDRV_PCM_HW_PARAM_RATE ,48000 ); }static struct snd_soc_ops byt_aif1_ops = {
Signature · 1 line
2.1.4
Lars-Peter Clausen
maintainerPATCH 16/18 ASoC: cht_bsw_max98090: Use snd_pcm_hw_constraint_single()
In reply to Lars-Peter ClausenUse the new snd_pcm_hw_constraint_single() helper function rather than installing a list constraint with a single value. Since snd_pcm_hw_constraint_single() sets a static constraint while snd_pcm_hw_constraint_list() sets a dynamic constraint the former is slightly more efficient and it also needs less code.
--- sound/soc/intel/boards/cht_bsw_max98090_ti.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-)
sound/soc/intel/boards/cht_bsw_max98090_ti.c +2 -12
@@ -193,20 +193,10 @@ static int cht_codec_fixup(struct snd_soc_pcm_runtime *rtd,return 0 ; } -static unsigned int rates_48000[] = { -48000 , -}; - -static struct snd_pcm_hw_constraint_list constraints_48000 = { - .count =ARRAY_SIZE (rates_48000), - .list = rates_48000, -}; -static int cht_aif1_startup (struct snd_pcm_substream *substream) { -return snd_pcm_hw_constraint_list (substream->runtime,0 , -SNDRV_PCM_HW_PARAM_RATE , - &constraints_48000); +return snd_pcm_hw_constraint_single (substream->runtime, +SNDRV_PCM_HW_PARAM_RATE ,48000 ); }static int cht_max98090_headset_init (struct snd_soc_component *component)
Signature · 1 line
2.1.4
Lars-Peter Clausen
maintainerPATCH 17/18 ASoC: cht_bsw_rt5645: Use snd_pcm_hw_constraint_single()
In reply to Lars-Peter ClausenUse the new snd_pcm_hw_constraint_single() helper function rather than installing a list constraint with a single value. Since snd_pcm_hw_constraint_single() sets a static constraint while snd_pcm_hw_constraint_list() sets a dynamic constraint the former is slightly more efficient and it also needs less code.
--- sound/soc/intel/boards/cht_bsw_rt5645.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-)
sound/soc/intel/boards/cht_bsw_rt5645.c +2 -12
@@ -235,20 +235,10 @@ static int cht_codec_fixup(struct snd_soc_pcm_runtime *rtd,return 0 ; } -static unsigned int rates_48000[] = { -48000 , -}; - -static struct snd_pcm_hw_constraint_list constraints_48000 = { - .count =ARRAY_SIZE (rates_48000), - .list = rates_48000, -}; -static int cht_aif1_startup (struct snd_pcm_substream *substream) { -return snd_pcm_hw_constraint_list (substream->runtime,0 , -SNDRV_PCM_HW_PARAM_RATE , - &constraints_48000); +return snd_pcm_hw_constraint_single (substream->runtime, +SNDRV_PCM_HW_PARAM_RATE ,48000 ); }static struct snd_soc_ops cht_aif1_ops = {
Signature · 1 line
2.1.4
Lars-Peter Clausen
maintainerPATCH 18/18 ASoC: cht_bsw_rt5672: Use snd_pcm_hw_constraint_single()
In reply to Lars-Peter ClausenUse the new snd_pcm_hw_constraint_single() helper function rather than installing a list constraint with a single value. Since snd_pcm_hw_constraint_single() sets a static constraint while snd_pcm_hw_constraint_list() sets a dynamic constraint the former is slightly more efficient and it also needs less code.
--- sound/soc/intel/boards/cht_bsw_rt5672.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-)
sound/soc/intel/boards/cht_bsw_rt5672.c +2 -12
@@ -222,20 +222,10 @@ static int cht_codec_fixup(struct snd_soc_pcm_runtime *rtd,return 0 ; } -static unsigned int rates_48000[] = { -48000 , -}; - -static struct snd_pcm_hw_constraint_list constraints_48000 = { - .count =ARRAY_SIZE (rates_48000), - .list = rates_48000, -}; -static int cht_aif1_startup (struct snd_pcm_substream *substream) { -return snd_pcm_hw_constraint_list (substream->runtime,0 , -SNDRV_PCM_HW_PARAM_RATE , - &constraints_48000); +return snd_pcm_hw_constraint_single (substream->runtime, +SNDRV_PCM_HW_PARAM_RATE ,48000 ); }static struct snd_soc_ops cht_aif1_ops = {
Signature · 1 line
2.1.4
Quoted 15 lines · Lars-Peter Clausen
Apologies if you got this series twice, forgot to Cc the mailinglist on the first try.
This series introduces a new helper function which can be used to constrain a configuration parameter to a single. So far the recommended and most efficient way to do this was to set a min-max constraint with the same value for minimum and maximum. It is not necessarily immediately obvious though that this is the right way to do things and some driver have come up with different ways to achieve the same effect, e.g. by installing a list constraint with a single item. This is less efficient since list constraints are dynamic constraints which needed to be re-evaluated multiple times at runtime while a min-max constraint is a static constraint.
Quoted 7 lines
The function introduced in this patch series is called
snd_pcm_hw_constraint_single()which hopefully is semantically more expressive and makes it clear that this is the function to use when setting a single value constraint.All existing drivers that want to set a single value constraint are update to use the new helper function.
Looks good to me. I suppose I'd take all these (including ASoC ones) through my tree as it adds a new API function. Mark are you OK with it?
thanks,
Takashi
Quoted 47 lines
- Lars
Lars-Peter Clausen (18):
ALSA: Add helper function to add single value constraint
ALSA: korg1212: Usesnd_pcm_hw_constraint_single()
ALAA: lx6464es: Usesnd_pcm_hw_constraint_single()
ALSA: rme32: Usesnd_pcm_hw_constraint_single()
ALSA: rme96: Usesnd_pcm_hw_constraint_single()
ALSA: rme9652: Usesnd_pcm_hw_constraint_single()
ASoC: adav80x: Usesnd_pcm_hw_constraint_single()
ASoC: twl4030: Usesnd_pcm_hw_constraint_single()
ASoC: uda134x: Usesnd_pcm_hw_constraint_single()
ASoC: wl1273: Usesnd_pcm_hw_constraint_single()
ASoC: n810: Usesnd_pcm_hw_constraint_single()
ASoC: rx51: Usesnd_pcm_hw_constraint_single()
ASoC: pcm: Usesnd_pcm_hw_constraint_single()
ASoC: ux500: Usesnd_pcm_hw_constraint_single()
ASoC:bytcr_rt5640: Usesnd_pcm_hw_constraint_single()
ASoC:cht_bsw_max98090: Usesnd_pcm_hw_constraint_single()
ASoC:cht_bsw_rt5645: Usesnd_pcm_hw_constraint_single()
ASoC:cht_bsw_rt5672: Usesnd_pcm_hw_constraint_single()include/sound/pcm.h | 16 ++++++++++++++++ sound/pci/korg1212/korg1212.c | 8 +++++--- sound/pci/lx6464es/lx6464es.c | 4 ++-- sound/pci/rme32.c | 4 ++-- sound/pci/rme96.c | 8 ++++---- sound/pci/rme9652/hdspm.c | 9 ++++----- sound/soc/codecs/adav80x.c | 4 ++-- sound/soc/codecs/twl4030.c | 13 +++++-------- sound/soc/codecs/uda134x.c | 6 ++---- sound/soc/codecs/wl1273.c | 9 ++++----- sound/soc/intel/boards/bytcr_rt5640.c | 14 ++------------ sound/soc/intel/boards/cht_bsw_max98090_ti.c | 14 ++------------ sound/soc/intel/boards/cht_bsw_rt5645.c | 14 ++------------ sound/soc/intel/boards/cht_bsw_rt5672.c | 14 ++------------ sound/soc/omap/n810.c | 3 +-- sound/soc/omap/rx51.c | 3 +-- sound/soc/soc-pcm.c | 10 ++++------ sound/soc/ux500/ux500_msp_dai.c | 4 ++-- 18 files changed, 62 insertions(+), 95 deletions(-)Signature · 1 line
2.1.4
Quoted 23 lines · Takashi Iwai
Quoted 20 lines · Lars-Peter Clausen
Apologies if you got this series twice, forgot to Cc the mailinglist on the first try.
This series introduces a new helper function which can be used to constrain a configuration parameter to a single. So far the recommended and most efficient way to do this was to set a min-max constraint with the same value for minimum and maximum. It is not necessarily immediately obvious though that this is the right way to do things and some driver have come up with different ways to achieve the same effect, e.g. by installing a list constraint with a single item. This is less efficient since list constraints are dynamic constraints which needed to be re-evaluated multiple times at runtime while a min-max constraint is a static constraint.
The function introduced in this patch series is called
snd_pcm_hw_constraint_single()which hopefully is semantically more expressive and makes it clear that this is the function to use when setting a single value constraint.
Quoted 6 lines
Quoted 2 lines
All existing drivers that want to set a single value constraint are update to use the new helper function.
Looks good to me. I suppose I'd take all these (including ASoC ones) through my tree as it adds a new API function. Mark are you OK with it?
I created topic/hw-constraint-single branch in sound git tree containing all these patches. I'm going to keep it for a while for further acks and merge later.
thanks,
Takashi
Quoted 3 lines · Takashi Iwai
I created topic/hw-constraint-single branch in sound git tree containing all these patches. I'm going to keep it for a while for further acks and merge later.
:/