mirror of
https://github.com/torvalds/linux.git
synced 2024-11-27 06:31:52 +00:00
Merge series "ASoC: tidyup snd_soc_of_parse_daifmt()" from Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>:
Hi Mark These are v3 of parsing for daifmt. I want to add new audio-graph-card2 sound card driver, and this is last part of necessary soc-core cleanup for it. Current some drivers are using DT, and then, snd_soc_of_parse_daifmt() parses daifmt, but bitclock/frame provider parsing part is one of headache, because we are assuming below both cases. A) node { bitclock-master; frame-master; ... }; B) link { bitclock-master = <&xxx>; frame-master = <&xxx>; ... }; The original was style A), and style B) was added later. snd_soc_of_parse_daifmt() parses A) style as original style, and user need to update to B) style for clock_provider part if needed. To handle it more flexibile, this patch-set adds new functions which separates snd_soc_of_parse_daifmt() helper function. snd_soc_daifmt_parse_format() : format part snd_soc_daifmt_parse_clock_provider_as_flag() : clock part for style A) snd_soc_daifmt_parse_clock_provider_as_phandl() : clock part for style B) snd_soc_daifmt_parse_clock_provider_as_bitmap() : clock part use with _from_bitmap v1 -> v2 - tidyup parse_clock_provider functions to _as_flag/phandle/bitmap() - don't exchange code style on each drivers. v2 -> v3 - use daifmt as much as possible (don't use daiclk) on each driver. Link: https://lore.kernel.org/r/875yypdxlm.wl-kuninori.morimoto.gx@renesas.com Link: https://lore.kernel.org/r/87czsvdc4o.wl-kuninori.morimoto.gx@renesas.com Kuninori Morimoto (8): ASoC: soc-core: add snd_soc_daifmt_clock_provider_from_bitmap() ASoC: soc-core: add snd_soc_daifmt_clock_provider_fliped() ASoC: soc-core: add snd_soc_daifmt_parse_format/clock_provider() ASoC: atmel: switch to use snd_soc_daifmt_parse_format/clock_provider() ASoC: fsl: switch to use snd_soc_daifmt_parse_format/clock_provider() ASoC: meson: switch to use snd_soc_daifmt_parse_format/clock_provider() ASoC: simple-card-utils: switch to use snd_soc_daifmt_parse_format/clock_provider() ASoC: soc-core: remove snd_soc_of_parse_daifmt() include/sound/soc.h | 21 ++++- sound/soc/atmel/mikroe-proto.c | 9 ++- sound/soc/fsl/fsl-asoc-card.c | 7 +- sound/soc/generic/simple-card-utils.c | 16 ++-- sound/soc/meson/meson-card-utils.c | 6 +- sound/soc/soc-core.c | 109 +++++++++++++++++--------- 6 files changed, 106 insertions(+), 62 deletions(-) -- 2.25.1
This commit is contained in:
commit
d7085db6e1
@ -1232,10 +1232,23 @@ void snd_soc_of_parse_audio_prefix(struct snd_soc_card *card,
|
||||
int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
|
||||
const char *propname);
|
||||
int snd_soc_of_parse_aux_devs(struct snd_soc_card *card, const char *propname);
|
||||
unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
|
||||
const char *prefix,
|
||||
struct device_node **bitclkmaster,
|
||||
struct device_node **framemaster);
|
||||
|
||||
unsigned int snd_soc_daifmt_clock_provider_fliped(unsigned int dai_fmt);
|
||||
unsigned int snd_soc_daifmt_clock_provider_from_bitmap(unsigned int bit_frame);
|
||||
|
||||
unsigned int snd_soc_daifmt_parse_format(struct device_node *np, const char *prefix);
|
||||
unsigned int snd_soc_daifmt_parse_clock_provider_raw(struct device_node *np,
|
||||
const char *prefix,
|
||||
struct device_node **bitclkmaster,
|
||||
struct device_node **framemaster);
|
||||
#define snd_soc_daifmt_parse_clock_provider_as_bitmap(np, prefix) \
|
||||
snd_soc_daifmt_parse_clock_provider_raw(np, prefix, NULL, NULL)
|
||||
#define snd_soc_daifmt_parse_clock_provider_as_phandle \
|
||||
snd_soc_daifmt_parse_clock_provider_raw
|
||||
#define snd_soc_daifmt_parse_clock_provider_as_flag(np, prefix) \
|
||||
snd_soc_daifmt_clock_provider_from_bitmap( \
|
||||
snd_soc_daifmt_parse_clock_provider_as_bitmap(np, prefix))
|
||||
|
||||
int snd_soc_get_dai_id(struct device_node *ep);
|
||||
int snd_soc_get_dai_name(const struct of_phandle_args *args,
|
||||
const char **dai_name);
|
||||
|
@ -120,19 +120,22 @@ static int snd_proto_probe(struct platform_device *pdev)
|
||||
dai->cpus->of_node = cpu_np;
|
||||
dai->platforms->of_node = cpu_np;
|
||||
|
||||
dai_fmt = snd_soc_of_parse_daifmt(np, NULL,
|
||||
&bitclkmaster, &framemaster);
|
||||
dai_fmt = snd_soc_daifmt_parse_format(np, NULL);
|
||||
snd_soc_daifmt_parse_clock_provider_as_phandle(np, NULL,
|
||||
&bitclkmaster, &framemaster);
|
||||
if (bitclkmaster != framemaster) {
|
||||
dev_err(&pdev->dev, "Must be the same bitclock and frame master\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (bitclkmaster) {
|
||||
dai_fmt &= ~SND_SOC_DAIFMT_MASTER_MASK;
|
||||
if (codec_np == bitclkmaster)
|
||||
dai_fmt |= SND_SOC_DAIFMT_CBM_CFM;
|
||||
else
|
||||
dai_fmt |= SND_SOC_DAIFMT_CBS_CFS;
|
||||
} else {
|
||||
dai_fmt |= snd_soc_daifmt_parse_clock_provider_as_flag(np, NULL);
|
||||
}
|
||||
|
||||
of_node_put(bitclkmaster);
|
||||
of_node_put(framemaster);
|
||||
dai->dai_fmt = dai_fmt;
|
||||
|
@ -540,7 +540,6 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
|
||||
struct device *codec_dev = NULL;
|
||||
const char *codec_dai_name;
|
||||
const char *codec_dev_name;
|
||||
unsigned int daifmt;
|
||||
u32 width;
|
||||
int ret;
|
||||
|
||||
@ -684,10 +683,10 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
|
||||
}
|
||||
|
||||
/* Format info from DT is optional. */
|
||||
daifmt = snd_soc_of_parse_daifmt(np, NULL,
|
||||
&bitclkmaster, &framemaster);
|
||||
daifmt &= ~SND_SOC_DAIFMT_MASTER_MASK;
|
||||
snd_soc_daifmt_parse_clock_provider_as_phandle(np, NULL, &bitclkmaster, &framemaster);
|
||||
if (bitclkmaster || framemaster) {
|
||||
unsigned int daifmt = snd_soc_daifmt_parse_format(np, NULL);
|
||||
|
||||
if (codec_np == bitclkmaster)
|
||||
daifmt |= (codec_np == framemaster) ?
|
||||
SND_SOC_DAIFMT_CBM_CFM : SND_SOC_DAIFMT_CBM_CFS;
|
||||
|
@ -61,10 +61,9 @@ int asoc_simple_parse_daifmt(struct device *dev,
|
||||
struct device_node *framemaster = NULL;
|
||||
unsigned int daifmt;
|
||||
|
||||
daifmt = snd_soc_of_parse_daifmt(node, prefix,
|
||||
&bitclkmaster, &framemaster);
|
||||
daifmt &= ~SND_SOC_DAIFMT_MASTER_MASK;
|
||||
daifmt = snd_soc_daifmt_parse_format(node, prefix);
|
||||
|
||||
snd_soc_daifmt_parse_clock_provider_as_phandle(node, prefix, &bitclkmaster, &framemaster);
|
||||
if (!bitclkmaster && !framemaster) {
|
||||
/*
|
||||
* No dai-link level and master setting was not found from
|
||||
@ -73,15 +72,10 @@ int asoc_simple_parse_daifmt(struct device *dev,
|
||||
*/
|
||||
dev_dbg(dev, "Revert to legacy daifmt parsing\n");
|
||||
|
||||
daifmt = snd_soc_of_parse_daifmt(codec, NULL, NULL, NULL) |
|
||||
(daifmt & ~SND_SOC_DAIFMT_CLOCK_MASK);
|
||||
daifmt |= snd_soc_daifmt_parse_clock_provider_as_flag(codec, NULL);
|
||||
} else {
|
||||
if (codec == bitclkmaster)
|
||||
daifmt |= (codec == framemaster) ?
|
||||
SND_SOC_DAIFMT_CBM_CFM : SND_SOC_DAIFMT_CBM_CFS;
|
||||
else
|
||||
daifmt |= (codec == framemaster) ?
|
||||
SND_SOC_DAIFMT_CBS_CFM : SND_SOC_DAIFMT_CBS_CFS;
|
||||
daifmt |= snd_soc_daifmt_clock_provider_from_bitmap(
|
||||
((codec == bitclkmaster) << 4) | (codec == framemaster));
|
||||
}
|
||||
|
||||
of_node_put(bitclkmaster);
|
||||
|
@ -119,9 +119,9 @@ unsigned int meson_card_parse_daifmt(struct device_node *node,
|
||||
struct device_node *framemaster = NULL;
|
||||
unsigned int daifmt;
|
||||
|
||||
daifmt = snd_soc_of_parse_daifmt(node, "",
|
||||
&bitclkmaster, &framemaster);
|
||||
daifmt &= ~SND_SOC_DAIFMT_MASTER_MASK;
|
||||
daifmt = snd_soc_daifmt_parse_format(node, NULL);
|
||||
|
||||
snd_soc_daifmt_parse_clock_provider_as_phandle(node, NULL, &bitclkmaster, &framemaster);
|
||||
|
||||
/* If no master is provided, default to cpu master */
|
||||
if (!bitclkmaster || bitclkmaster == cpu_node) {
|
||||
|
@ -1249,21 +1249,8 @@ int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
|
||||
* Flip the polarity for the "CPU" end of a CODEC<->CODEC link
|
||||
* the component which has non_legacy_dai_naming is Codec
|
||||
*/
|
||||
inv_dai_fmt = dai_fmt & ~SND_SOC_DAIFMT_MASTER_MASK;
|
||||
switch (dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) {
|
||||
case SND_SOC_DAIFMT_CBM_CFM:
|
||||
inv_dai_fmt |= SND_SOC_DAIFMT_CBS_CFS;
|
||||
break;
|
||||
case SND_SOC_DAIFMT_CBM_CFS:
|
||||
inv_dai_fmt |= SND_SOC_DAIFMT_CBS_CFM;
|
||||
break;
|
||||
case SND_SOC_DAIFMT_CBS_CFM:
|
||||
inv_dai_fmt |= SND_SOC_DAIFMT_CBM_CFS;
|
||||
break;
|
||||
case SND_SOC_DAIFMT_CBS_CFS:
|
||||
inv_dai_fmt |= SND_SOC_DAIFMT_CBM_CFM;
|
||||
break;
|
||||
}
|
||||
inv_dai_fmt = snd_soc_daifmt_clock_provider_fliped(dai_fmt);
|
||||
|
||||
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
|
||||
unsigned int fmt = dai_fmt;
|
||||
|
||||
@ -3017,10 +3004,54 @@ int snd_soc_of_parse_aux_devs(struct snd_soc_card *card, const char *propname)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_soc_of_parse_aux_devs);
|
||||
|
||||
unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
|
||||
const char *prefix,
|
||||
struct device_node **bitclkmaster,
|
||||
struct device_node **framemaster)
|
||||
unsigned int snd_soc_daifmt_clock_provider_fliped(unsigned int dai_fmt)
|
||||
{
|
||||
unsigned int inv_dai_fmt = dai_fmt & ~SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK;
|
||||
|
||||
switch (dai_fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) {
|
||||
case SND_SOC_DAIFMT_CBP_CFP:
|
||||
inv_dai_fmt |= SND_SOC_DAIFMT_CBC_CFC;
|
||||
break;
|
||||
case SND_SOC_DAIFMT_CBP_CFC:
|
||||
inv_dai_fmt |= SND_SOC_DAIFMT_CBC_CFP;
|
||||
break;
|
||||
case SND_SOC_DAIFMT_CBC_CFP:
|
||||
inv_dai_fmt |= SND_SOC_DAIFMT_CBP_CFC;
|
||||
break;
|
||||
case SND_SOC_DAIFMT_CBC_CFC:
|
||||
inv_dai_fmt |= SND_SOC_DAIFMT_CBP_CFP;
|
||||
break;
|
||||
}
|
||||
|
||||
return inv_dai_fmt;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_soc_daifmt_clock_provider_fliped);
|
||||
|
||||
unsigned int snd_soc_daifmt_clock_provider_from_bitmap(unsigned int bit_frame)
|
||||
{
|
||||
/*
|
||||
* bit_frame is return value from
|
||||
* snd_soc_daifmt_parse_clock_provider_raw()
|
||||
*/
|
||||
|
||||
/* Codec base */
|
||||
switch (bit_frame) {
|
||||
case 0x11:
|
||||
return SND_SOC_DAIFMT_CBP_CFP;
|
||||
case 0x10:
|
||||
return SND_SOC_DAIFMT_CBP_CFC;
|
||||
case 0x01:
|
||||
return SND_SOC_DAIFMT_CBC_CFP;
|
||||
default:
|
||||
return SND_SOC_DAIFMT_CBC_CFC;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_soc_daifmt_clock_provider_from_bitmap);
|
||||
|
||||
unsigned int snd_soc_daifmt_parse_format(struct device_node *np,
|
||||
const char *prefix)
|
||||
{
|
||||
int ret, i;
|
||||
char prop[128];
|
||||
@ -3100,10 +3131,24 @@ unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
|
||||
break;
|
||||
}
|
||||
|
||||
return format;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_soc_daifmt_parse_format);
|
||||
|
||||
unsigned int snd_soc_daifmt_parse_clock_provider_raw(struct device_node *np,
|
||||
const char *prefix,
|
||||
struct device_node **bitclkmaster,
|
||||
struct device_node **framemaster)
|
||||
{
|
||||
char prop[128];
|
||||
unsigned int bit, frame;
|
||||
|
||||
if (!prefix)
|
||||
prefix = "";
|
||||
|
||||
/*
|
||||
* check "[prefix]bitclock-master"
|
||||
* check "[prefix]frame-master"
|
||||
* SND_SOC_DAIFMT_MASTER_MASK area
|
||||
*/
|
||||
snprintf(prop, sizeof(prop), "%sbitclock-master", prefix);
|
||||
bit = !!of_get_property(np, prop, NULL);
|
||||
@ -3115,24 +3160,14 @@ unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
|
||||
if (frame && framemaster)
|
||||
*framemaster = of_parse_phandle(np, prop, 0);
|
||||
|
||||
switch ((bit << 4) + frame) {
|
||||
case 0x11:
|
||||
format |= SND_SOC_DAIFMT_CBM_CFM;
|
||||
break;
|
||||
case 0x10:
|
||||
format |= SND_SOC_DAIFMT_CBM_CFS;
|
||||
break;
|
||||
case 0x01:
|
||||
format |= SND_SOC_DAIFMT_CBS_CFM;
|
||||
break;
|
||||
default:
|
||||
format |= SND_SOC_DAIFMT_CBS_CFS;
|
||||
break;
|
||||
}
|
||||
|
||||
return format;
|
||||
/*
|
||||
* return bitmap.
|
||||
* It will be parameter of
|
||||
* snd_soc_daifmt_clock_provider_from_bitmap()
|
||||
*/
|
||||
return (bit << 4) + frame;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_soc_of_parse_daifmt);
|
||||
EXPORT_SYMBOL_GPL(snd_soc_daifmt_parse_clock_provider_raw);
|
||||
|
||||
int snd_soc_get_dai_id(struct device_node *ep)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user