Commit 8cb3aeeb authored by Mohan Kumar's avatar Mohan Kumar Committed by Mark Brown

ASoC: simple-card-utils: Split simple_fixup_sample_fmt func

Split the simple_fixup_sample_fmt() into two functions by adding
one more function named simple_util_get_sample_fmt() to return
the sample format value.

This is useful for drivers that wish to simply get the sample format
without setting the mask.
Signed-off-by: default avatarMohan Kumar <mkumard@nvidia.com>
Signed-off-by: default avatarSameer Pujar <spujar@nvidia.com>
Link: https://msgid.link/r/20240527125608.2461300-2-spujar@nvidia.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 1613e604
...@@ -174,6 +174,8 @@ void simple_util_parse_convert(struct device_node *np, char *prefix, ...@@ -174,6 +174,8 @@ void simple_util_parse_convert(struct device_node *np, char *prefix,
struct simple_util_data *data); struct simple_util_data *data);
bool simple_util_is_convert_required(const struct simple_util_data *data); bool simple_util_is_convert_required(const struct simple_util_data *data);
int simple_util_get_sample_fmt(struct simple_util_data *data);
int simple_util_parse_routing(struct snd_soc_card *card, int simple_util_parse_routing(struct snd_soc_card *card,
char *prefix); char *prefix);
int simple_util_parse_widgets(struct snd_soc_card *card, int simple_util_parse_widgets(struct snd_soc_card *card,
......
...@@ -13,12 +13,11 @@ ...@@ -13,12 +13,11 @@
#include <sound/pcm_params.h> #include <sound/pcm_params.h>
#include <sound/simple_card_utils.h> #include <sound/simple_card_utils.h>
static void simple_fixup_sample_fmt(struct simple_util_data *data, int simple_util_get_sample_fmt(struct simple_util_data *data)
struct snd_pcm_hw_params *params)
{ {
int i; int i;
struct snd_mask *mask = hw_param_mask(params, int val = -EINVAL;
SNDRV_PCM_HW_PARAM_FORMAT);
struct { struct {
char *fmt; char *fmt;
u32 val; u32 val;
...@@ -33,11 +32,26 @@ static void simple_fixup_sample_fmt(struct simple_util_data *data, ...@@ -33,11 +32,26 @@ static void simple_fixup_sample_fmt(struct simple_util_data *data,
for (i = 0; i < ARRAY_SIZE(of_sample_fmt_table); i++) { for (i = 0; i < ARRAY_SIZE(of_sample_fmt_table); i++) {
if (!strcmp(data->convert_sample_format, if (!strcmp(data->convert_sample_format,
of_sample_fmt_table[i].fmt)) { of_sample_fmt_table[i].fmt)) {
snd_mask_none(mask); val = of_sample_fmt_table[i].val;
snd_mask_set(mask, of_sample_fmt_table[i].val);
break; break;
} }
} }
return val;
}
EXPORT_SYMBOL_GPL(simple_util_get_sample_fmt);
static void simple_fixup_sample_fmt(struct simple_util_data *data,
struct snd_pcm_hw_params *params)
{
int val;
struct snd_mask *mask = hw_param_mask(params,
SNDRV_PCM_HW_PARAM_FORMAT);
val = simple_util_get_sample_fmt(data);
if (val >= 0) {
snd_mask_none(mask);
snd_mask_set(mask, val);
}
} }
void simple_util_parse_convert(struct device_node *np, void simple_util_parse_convert(struct device_node *np,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment