ASoC: simple-card-utils: Fixup DAI sample format
Parse "convert-sample-format" DT binding and fixup the sample format as applicable. This is similar to the existing "convert-channels" and "convert-rate" properties for channels and rate fixup respectively. Signed-off-by: Sameer Pujar <spujar@nvidia.com> Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/1659936452-2254-4-git-send-email-spujar@nvidia.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
955927873d
commit
047a05366f
@ -39,6 +39,7 @@ struct asoc_simple_dai {
|
|||||||
struct asoc_simple_data {
|
struct asoc_simple_data {
|
||||||
u32 convert_rate;
|
u32 convert_rate;
|
||||||
u32 convert_channels;
|
u32 convert_channels;
|
||||||
|
const char *convert_sample_format;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct asoc_simple_jack {
|
struct asoc_simple_jack {
|
||||||
|
@ -15,6 +15,33 @@
|
|||||||
#include <sound/pcm_params.h>
|
#include <sound/pcm_params.h>
|
||||||
#include <sound/simple_card_utils.h>
|
#include <sound/simple_card_utils.h>
|
||||||
|
|
||||||
|
static void asoc_simple_fixup_sample_fmt(struct asoc_simple_data *data,
|
||||||
|
struct snd_pcm_hw_params *params)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
struct snd_mask *mask = hw_param_mask(params,
|
||||||
|
SNDRV_PCM_HW_PARAM_FORMAT);
|
||||||
|
struct {
|
||||||
|
char *fmt;
|
||||||
|
u32 val;
|
||||||
|
} of_sample_fmt_table[] = {
|
||||||
|
{ "s8", SNDRV_PCM_FORMAT_S8},
|
||||||
|
{ "s16_le", SNDRV_PCM_FORMAT_S16_LE},
|
||||||
|
{ "s24_le", SNDRV_PCM_FORMAT_S24_LE},
|
||||||
|
{ "s24_3le", SNDRV_PCM_FORMAT_S24_3LE},
|
||||||
|
{ "s32_le", SNDRV_PCM_FORMAT_S32_LE},
|
||||||
|
};
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_SIZE(of_sample_fmt_table); i++) {
|
||||||
|
if (!strcmp(data->convert_sample_format,
|
||||||
|
of_sample_fmt_table[i].fmt)) {
|
||||||
|
snd_mask_none(mask);
|
||||||
|
snd_mask_set(mask, of_sample_fmt_table[i].val);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void asoc_simple_convert_fixup(struct asoc_simple_data *data,
|
void asoc_simple_convert_fixup(struct asoc_simple_data *data,
|
||||||
struct snd_pcm_hw_params *params)
|
struct snd_pcm_hw_params *params)
|
||||||
{
|
{
|
||||||
@ -30,6 +57,9 @@ void asoc_simple_convert_fixup(struct asoc_simple_data *data,
|
|||||||
if (data->convert_channels)
|
if (data->convert_channels)
|
||||||
channels->min =
|
channels->min =
|
||||||
channels->max = data->convert_channels;
|
channels->max = data->convert_channels;
|
||||||
|
|
||||||
|
if (data->convert_sample_format)
|
||||||
|
asoc_simple_fixup_sample_fmt(data, params);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(asoc_simple_convert_fixup);
|
EXPORT_SYMBOL_GPL(asoc_simple_convert_fixup);
|
||||||
|
|
||||||
@ -49,6 +79,10 @@ void asoc_simple_parse_convert(struct device_node *np,
|
|||||||
/* channels transfer */
|
/* channels transfer */
|
||||||
snprintf(prop, sizeof(prop), "%s%s", prefix, "convert-channels");
|
snprintf(prop, sizeof(prop), "%s%s", prefix, "convert-channels");
|
||||||
of_property_read_u32(np, prop, &data->convert_channels);
|
of_property_read_u32(np, prop, &data->convert_channels);
|
||||||
|
|
||||||
|
/* convert sample format */
|
||||||
|
snprintf(prop, sizeof(prop), "%s%s", prefix, "convert-sample-format");
|
||||||
|
of_property_read_string(np, prop, &data->convert_sample_format);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(asoc_simple_parse_convert);
|
EXPORT_SYMBOL_GPL(asoc_simple_parse_convert);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user