diff options
Diffstat (limited to 'sound/soc/generic/simple-card-utils.c')
-rw-r--r-- | sound/soc/generic/simple-card-utils.c | 221 |
1 files changed, 109 insertions, 112 deletions
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index 2588ec735d..cfa70a56ff 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -14,7 +14,7 @@ #include <sound/pcm_params.h> #include <sound/simple_card_utils.h> -static void asoc_simple_fixup_sample_fmt(struct asoc_simple_data *data, +static void simple_fixup_sample_fmt(struct simple_util_data *data, struct snd_pcm_hw_params *params) { int i; @@ -41,9 +41,9 @@ static void asoc_simple_fixup_sample_fmt(struct asoc_simple_data *data, } } -void asoc_simple_parse_convert(struct device_node *np, +void simple_util_parse_convert(struct device_node *np, char *prefix, - struct asoc_simple_data *data) + struct simple_util_data *data) { char prop[128]; @@ -62,24 +62,24 @@ void asoc_simple_parse_convert(struct device_node *np, 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(simple_util_parse_convert); /** - * asoc_simple_is_convert_required() - Query if HW param conversion was requested + * simple_util_is_convert_required() - Query if HW param conversion was requested * @data: Link data. * * Returns true if any HW param conversion was requested for this DAI link with * any "convert-xxx" properties. */ -bool asoc_simple_is_convert_required(const struct asoc_simple_data *data) +bool simple_util_is_convert_required(const struct simple_util_data *data) { return data->convert_rate || data->convert_channels || data->convert_sample_format; } -EXPORT_SYMBOL_GPL(asoc_simple_is_convert_required); +EXPORT_SYMBOL_GPL(simple_util_is_convert_required); -int asoc_simple_parse_daifmt(struct device *dev, +int simple_util_parse_daifmt(struct device *dev, struct device_node *node, struct device_node *codec, char *prefix, @@ -113,10 +113,10 @@ int asoc_simple_parse_daifmt(struct device *dev, return 0; } -EXPORT_SYMBOL_GPL(asoc_simple_parse_daifmt); +EXPORT_SYMBOL_GPL(simple_util_parse_daifmt); -int asoc_simple_parse_tdm_width_map(struct device *dev, struct device_node *np, - struct asoc_simple_dai *dai) +int simple_util_parse_tdm_width_map(struct device *dev, struct device_node *np, + struct simple_util_dai *dai) { u32 *array_values, *p; int n, i, ret; @@ -158,9 +158,9 @@ out: return ret; } -EXPORT_SYMBOL_GPL(asoc_simple_parse_tdm_width_map); +EXPORT_SYMBOL_GPL(simple_util_parse_tdm_width_map); -int asoc_simple_set_dailink_name(struct device *dev, +int simple_util_set_dailink_name(struct device *dev, struct snd_soc_dai_link *dai_link, const char *fmt, ...) { @@ -181,9 +181,9 @@ int asoc_simple_set_dailink_name(struct device *dev, return ret; } -EXPORT_SYMBOL_GPL(asoc_simple_set_dailink_name); +EXPORT_SYMBOL_GPL(simple_util_set_dailink_name); -int asoc_simple_parse_card_name(struct snd_soc_card *card, +int simple_util_parse_card_name(struct snd_soc_card *card, char *prefix) { int ret; @@ -207,9 +207,9 @@ int asoc_simple_parse_card_name(struct snd_soc_card *card, return 0; } -EXPORT_SYMBOL_GPL(asoc_simple_parse_card_name); +EXPORT_SYMBOL_GPL(simple_util_parse_card_name); -static int asoc_simple_clk_enable(struct asoc_simple_dai *dai) +static int simple_clk_enable(struct simple_util_dai *dai) { if (dai) return clk_prepare_enable(dai->clk); @@ -217,15 +217,15 @@ static int asoc_simple_clk_enable(struct asoc_simple_dai *dai) return 0; } -static void asoc_simple_clk_disable(struct asoc_simple_dai *dai) +static void simple_clk_disable(struct simple_util_dai *dai) { if (dai) clk_disable_unprepare(dai->clk); } -int asoc_simple_parse_clk(struct device *dev, +int simple_util_parse_clk(struct device *dev, struct device_node *node, - struct asoc_simple_dai *simple_dai, + struct simple_util_dai *simple_dai, struct snd_soc_dai_link_component *dlc) { struct clk *clk; @@ -258,10 +258,10 @@ int asoc_simple_parse_clk(struct device *dev, return 0; } -EXPORT_SYMBOL_GPL(asoc_simple_parse_clk); +EXPORT_SYMBOL_GPL(simple_util_parse_clk); -static int asoc_simple_check_fixed_sysclk(struct device *dev, - struct asoc_simple_dai *dai, +static int simple_check_fixed_sysclk(struct device *dev, + struct simple_util_dai *dai, unsigned int *fixed_sysclk) { if (dai->clk_fixed) { @@ -276,30 +276,30 @@ static int asoc_simple_check_fixed_sysclk(struct device *dev, return 0; } -int asoc_simple_startup(struct snd_pcm_substream *substream) +int simple_util_startup(struct snd_pcm_substream *substream) { - struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); - struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); + struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); + struct simple_util_priv *priv = snd_soc_card_get_drvdata(rtd->card); struct simple_dai_props *props = simple_priv_to_props(priv, rtd->num); - struct asoc_simple_dai *dai; + struct simple_util_dai *dai; unsigned int fixed_sysclk = 0; int i1, i2, i; int ret; for_each_prop_dai_cpu(props, i1, dai) { - ret = asoc_simple_clk_enable(dai); + ret = simple_clk_enable(dai); if (ret) goto cpu_err; - ret = asoc_simple_check_fixed_sysclk(rtd->dev, dai, &fixed_sysclk); + ret = simple_check_fixed_sysclk(rtd->dev, dai, &fixed_sysclk); if (ret) goto cpu_err; } for_each_prop_dai_codec(props, i2, dai) { - ret = asoc_simple_clk_enable(dai); + ret = simple_clk_enable(dai); if (ret) goto codec_err; - ret = asoc_simple_check_fixed_sysclk(rtd->dev, dai, &fixed_sysclk); + ret = simple_check_fixed_sysclk(rtd->dev, dai, &fixed_sysclk); if (ret) goto codec_err; } @@ -325,49 +325,49 @@ codec_err: for_each_prop_dai_codec(props, i, dai) { if (i >= i2) break; - asoc_simple_clk_disable(dai); + simple_clk_disable(dai); } cpu_err: for_each_prop_dai_cpu(props, i, dai) { if (i >= i1) break; - asoc_simple_clk_disable(dai); + simple_clk_disable(dai); } return ret; } -EXPORT_SYMBOL_GPL(asoc_simple_startup); +EXPORT_SYMBOL_GPL(simple_util_startup); -void asoc_simple_shutdown(struct snd_pcm_substream *substream) +void simple_util_shutdown(struct snd_pcm_substream *substream) { - struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); - struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); + struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); + struct simple_util_priv *priv = snd_soc_card_get_drvdata(rtd->card); struct simple_dai_props *props = simple_priv_to_props(priv, rtd->num); - struct asoc_simple_dai *dai; + struct simple_util_dai *dai; int i; for_each_prop_dai_cpu(props, i, dai) { - struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, i); + struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, i); if (props->mclk_fs && !dai->clk_fixed && !snd_soc_dai_active(cpu_dai)) snd_soc_dai_set_sysclk(cpu_dai, 0, 0, SND_SOC_CLOCK_OUT); - asoc_simple_clk_disable(dai); + simple_clk_disable(dai); } for_each_prop_dai_codec(props, i, dai) { - struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, i); + struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, i); if (props->mclk_fs && !dai->clk_fixed && !snd_soc_dai_active(codec_dai)) snd_soc_dai_set_sysclk(codec_dai, 0, 0, SND_SOC_CLOCK_IN); - asoc_simple_clk_disable(dai); + simple_clk_disable(dai); } } -EXPORT_SYMBOL_GPL(asoc_simple_shutdown); +EXPORT_SYMBOL_GPL(simple_util_shutdown); -static int asoc_simple_set_clk_rate(struct device *dev, - struct asoc_simple_dai *simple_dai, +static int simple_set_clk_rate(struct device *dev, + struct simple_util_dai *simple_dai, unsigned long rate) { if (!simple_dai) @@ -387,8 +387,8 @@ static int asoc_simple_set_clk_rate(struct device *dev, return clk_set_rate(simple_dai->clk, rate); } -static int asoc_simple_set_tdm(struct snd_soc_dai *dai, - struct asoc_simple_dai *simple_dai, +static int simple_set_tdm(struct snd_soc_dai *dai, + struct simple_util_dai *simple_dai, struct snd_pcm_hw_params *params) { int sample_bits = params_width(params); @@ -425,13 +425,13 @@ static int asoc_simple_set_tdm(struct snd_soc_dai *dai, return 0; } -int asoc_simple_hw_params(struct snd_pcm_substream *substream, +int simple_util_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { - struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); - struct asoc_simple_dai *pdai; + struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); + struct simple_util_dai *pdai; struct snd_soc_dai *sdai; - struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); + struct simple_util_priv *priv = snd_soc_card_get_drvdata(rtd->card); struct simple_dai_props *props = simple_priv_to_props(priv, rtd->num); unsigned int mclk, mclk_fs = 0; int i, ret; @@ -444,13 +444,13 @@ int asoc_simple_hw_params(struct snd_pcm_substream *substream, mclk = params_rate(params) * mclk_fs; for_each_prop_dai_codec(props, i, pdai) { - ret = asoc_simple_set_clk_rate(rtd->dev, pdai, mclk); + ret = simple_set_clk_rate(rtd->dev, pdai, mclk); if (ret < 0) return ret; } for_each_prop_dai_cpu(props, i, pdai) { - ret = asoc_simple_set_clk_rate(rtd->dev, pdai, mclk); + ret = simple_set_clk_rate(rtd->dev, pdai, mclk); if (ret < 0) return ret; } @@ -480,29 +480,29 @@ int asoc_simple_hw_params(struct snd_pcm_substream *substream, } for_each_prop_dai_codec(props, i, pdai) { - sdai = asoc_rtd_to_codec(rtd, i); - ret = asoc_simple_set_tdm(sdai, pdai, params); + sdai = snd_soc_rtd_to_codec(rtd, i); + ret = simple_set_tdm(sdai, pdai, params); if (ret < 0) return ret; } for_each_prop_dai_cpu(props, i, pdai) { - sdai = asoc_rtd_to_cpu(rtd, i); - ret = asoc_simple_set_tdm(sdai, pdai, params); + sdai = snd_soc_rtd_to_cpu(rtd, i); + ret = simple_set_tdm(sdai, pdai, params); if (ret < 0) return ret; } return 0; } -EXPORT_SYMBOL_GPL(asoc_simple_hw_params); +EXPORT_SYMBOL_GPL(simple_util_hw_params); -int asoc_simple_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, +int simple_util_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params) { - struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); + struct simple_util_priv *priv = snd_soc_card_get_drvdata(rtd->card); struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num); - struct asoc_simple_data *data = &dai_props->adata; + struct simple_util_data *data = &dai_props->adata; struct snd_interval *rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); struct snd_interval *channels = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); @@ -515,14 +515,13 @@ int asoc_simple_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, channels->max = data->convert_channels; if (data->convert_sample_format) - asoc_simple_fixup_sample_fmt(data, params); + simple_fixup_sample_fmt(data, params); return 0; } -EXPORT_SYMBOL_GPL(asoc_simple_be_hw_params_fixup); +EXPORT_SYMBOL_GPL(simple_util_be_hw_params_fixup); -static int asoc_simple_init_dai(struct snd_soc_dai *dai, - struct asoc_simple_dai *simple_dai) +static int simple_init_dai(struct snd_soc_dai *dai, struct simple_util_dai *simple_dai) { int ret; @@ -553,13 +552,13 @@ static int asoc_simple_init_dai(struct snd_soc_dai *dai, return 0; } -static inline int asoc_simple_component_is_codec(struct snd_soc_component *component) +static inline int simple_component_is_codec(struct snd_soc_component *component) { return component->driver->endianness; } -static int asoc_simple_init_for_codec2codec(struct snd_soc_pcm_runtime *rtd, - struct simple_dai_props *dai_props) +static int simple_init_for_codec2codec(struct snd_soc_pcm_runtime *rtd, + struct simple_dai_props *dai_props) { struct snd_soc_dai_link *dai_link = rtd->dai_link; struct snd_soc_component *component; @@ -577,7 +576,7 @@ static int asoc_simple_init_for_codec2codec(struct snd_soc_pcm_runtime *rtd, /* Only Codecs */ for_each_rtd_components(rtd, i, component) { - if (!asoc_simple_component_is_codec(component)) + if (!simple_component_is_codec(component)) return 0; } @@ -610,33 +609,33 @@ static int asoc_simple_init_for_codec2codec(struct snd_soc_pcm_runtime *rtd, return 0; } -int asoc_simple_dai_init(struct snd_soc_pcm_runtime *rtd) +int simple_util_dai_init(struct snd_soc_pcm_runtime *rtd) { - struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); + struct simple_util_priv *priv = snd_soc_card_get_drvdata(rtd->card); struct simple_dai_props *props = simple_priv_to_props(priv, rtd->num); - struct asoc_simple_dai *dai; + struct simple_util_dai *dai; int i, ret; for_each_prop_dai_codec(props, i, dai) { - ret = asoc_simple_init_dai(asoc_rtd_to_codec(rtd, i), dai); + ret = simple_init_dai(snd_soc_rtd_to_codec(rtd, i), dai); if (ret < 0) return ret; } for_each_prop_dai_cpu(props, i, dai) { - ret = asoc_simple_init_dai(asoc_rtd_to_cpu(rtd, i), dai); + ret = simple_init_dai(snd_soc_rtd_to_cpu(rtd, i), dai); if (ret < 0) return ret; } - ret = asoc_simple_init_for_codec2codec(rtd, props); + ret = simple_init_for_codec2codec(rtd, props); if (ret < 0) return ret; return 0; } -EXPORT_SYMBOL_GPL(asoc_simple_dai_init); +EXPORT_SYMBOL_GPL(simple_util_dai_init); -void asoc_simple_canonicalize_platform(struct snd_soc_dai_link_component *platforms, +void simple_util_canonicalize_platform(struct snd_soc_dai_link_component *platforms, struct snd_soc_dai_link_component *cpus) { /* @@ -652,9 +651,9 @@ void asoc_simple_canonicalize_platform(struct snd_soc_dai_link_component *platfo if (!platforms->of_node) snd_soc_dlc_use_cpu_as_platform(platforms, cpus); } -EXPORT_SYMBOL_GPL(asoc_simple_canonicalize_platform); +EXPORT_SYMBOL_GPL(simple_util_canonicalize_platform); -void asoc_simple_canonicalize_cpu(struct snd_soc_dai_link_component *cpus, +void simple_util_canonicalize_cpu(struct snd_soc_dai_link_component *cpus, int is_single_links) { /* @@ -669,9 +668,9 @@ void asoc_simple_canonicalize_cpu(struct snd_soc_dai_link_component *cpus, if (is_single_links) cpus->dai_name = NULL; } -EXPORT_SYMBOL_GPL(asoc_simple_canonicalize_cpu); +EXPORT_SYMBOL_GPL(simple_util_canonicalize_cpu); -void asoc_simple_clean_reference(struct snd_soc_card *card) +void simple_util_clean_reference(struct snd_soc_card *card) { struct snd_soc_dai_link *dai_link; struct snd_soc_dai_link_component *cpu; @@ -685,9 +684,9 @@ void asoc_simple_clean_reference(struct snd_soc_card *card) of_node_put(codec->of_node); } } -EXPORT_SYMBOL_GPL(asoc_simple_clean_reference); +EXPORT_SYMBOL_GPL(simple_util_clean_reference); -int asoc_simple_parse_routing(struct snd_soc_card *card, +int simple_util_parse_routing(struct snd_soc_card *card, char *prefix) { struct device_node *node = card->dev->of_node; @@ -703,9 +702,9 @@ int asoc_simple_parse_routing(struct snd_soc_card *card, return snd_soc_of_parse_audio_routing(card, prop); } -EXPORT_SYMBOL_GPL(asoc_simple_parse_routing); +EXPORT_SYMBOL_GPL(simple_util_parse_routing); -int asoc_simple_parse_widgets(struct snd_soc_card *card, +int simple_util_parse_widgets(struct snd_soc_card *card, char *prefix) { struct device_node *node = card->dev->of_node; @@ -722,9 +721,9 @@ int asoc_simple_parse_widgets(struct snd_soc_card *card, /* no widgets is not error */ return 0; } -EXPORT_SYMBOL_GPL(asoc_simple_parse_widgets); +EXPORT_SYMBOL_GPL(simple_util_parse_widgets); -int asoc_simple_parse_pin_switches(struct snd_soc_card *card, +int simple_util_parse_pin_switches(struct snd_soc_card *card, char *prefix) { char prop[128]; @@ -736,10 +735,10 @@ int asoc_simple_parse_pin_switches(struct snd_soc_card *card, return snd_soc_of_parse_pin_switches(card, prop); } -EXPORT_SYMBOL_GPL(asoc_simple_parse_pin_switches); +EXPORT_SYMBOL_GPL(simple_util_parse_pin_switches); -int asoc_simple_init_jack(struct snd_soc_card *card, - struct asoc_simple_jack *sjack, +int simple_util_init_jack(struct snd_soc_card *card, + struct simple_util_jack *sjack, int is_hp, char *prefix, char *pin) { @@ -794,9 +793,9 @@ int asoc_simple_init_jack(struct snd_soc_card *card, return 0; } -EXPORT_SYMBOL_GPL(asoc_simple_init_jack); +EXPORT_SYMBOL_GPL(simple_util_init_jack); -int asoc_simple_init_aux_jacks(struct asoc_simple_priv *priv, char *prefix) +int simple_util_init_aux_jacks(struct simple_util_priv *priv, char *prefix) { struct snd_soc_card *card = simple_priv_to_card(priv); struct snd_soc_component *component; @@ -843,16 +842,16 @@ int asoc_simple_init_aux_jacks(struct asoc_simple_priv *priv, char *prefix) } return 0; } -EXPORT_SYMBOL_GPL(asoc_simple_init_aux_jacks); +EXPORT_SYMBOL_GPL(simple_util_init_aux_jacks); -int asoc_simple_init_priv(struct asoc_simple_priv *priv, +int simple_util_init_priv(struct simple_util_priv *priv, struct link_info *li) { struct snd_soc_card *card = simple_priv_to_card(priv); struct device *dev = simple_priv_to_dev(priv); struct snd_soc_dai_link *dai_link; struct simple_dai_props *dai_props; - struct asoc_simple_dai *dais; + struct simple_util_dai *dais; struct snd_soc_dai_link_component *dlcs; struct snd_soc_codec_conf *cconf = NULL; int i, dai_num = 0, dlc_num = 0, cnf_num = 0; @@ -913,7 +912,7 @@ int asoc_simple_init_priv(struct asoc_simple_priv *priv, dais += li->num[i].cpus; } else { /* DPCM Be's CPU = dummy */ - dai_link[i].cpus = &asoc_dummy_dlc; + dai_link[i].cpus = &snd_soc_dummy_dlc; dai_props[i].num.cpus = dai_link[i].num_cpus = 1; } @@ -935,7 +934,7 @@ int asoc_simple_init_priv(struct asoc_simple_priv *priv, } } else { /* DPCM Fe's Codec = dummy */ - dai_link[i].codecs = &asoc_dummy_dlc; + dai_link[i].codecs = &snd_soc_dummy_dlc; dai_props[i].num.codecs = dai_link[i].num_codecs = 1; } @@ -957,36 +956,34 @@ int asoc_simple_init_priv(struct asoc_simple_priv *priv, return 0; } -EXPORT_SYMBOL_GPL(asoc_simple_init_priv); +EXPORT_SYMBOL_GPL(simple_util_init_priv); -int asoc_simple_remove(struct platform_device *pdev) +void simple_util_remove(struct platform_device *pdev) { struct snd_soc_card *card = platform_get_drvdata(pdev); - asoc_simple_clean_reference(card); - - return 0; + simple_util_clean_reference(card); } -EXPORT_SYMBOL_GPL(asoc_simple_remove); +EXPORT_SYMBOL_GPL(simple_util_remove); -int asoc_graph_card_probe(struct snd_soc_card *card) +int graph_util_card_probe(struct snd_soc_card *card) { - struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(card); + struct simple_util_priv *priv = snd_soc_card_get_drvdata(card); int ret; - ret = asoc_simple_init_hp(card, &priv->hp_jack, NULL); + ret = simple_util_init_hp(card, &priv->hp_jack, NULL); if (ret < 0) return ret; - ret = asoc_simple_init_mic(card, &priv->mic_jack, NULL); + ret = simple_util_init_mic(card, &priv->mic_jack, NULL); if (ret < 0) return ret; return 0; } -EXPORT_SYMBOL_GPL(asoc_graph_card_probe); +EXPORT_SYMBOL_GPL(graph_util_card_probe); -int asoc_graph_is_ports0(struct device_node *np) +int graph_util_is_ports0(struct device_node *np) { struct device_node *port, *ports, *ports0, *top; int ret; @@ -1012,7 +1009,7 @@ int asoc_graph_is_ports0(struct device_node *np) return ret; } -EXPORT_SYMBOL_GPL(asoc_graph_is_ports0); +EXPORT_SYMBOL_GPL(graph_util_is_ports0); static int graph_get_dai_id(struct device_node *ep) { @@ -1067,7 +1064,7 @@ static int graph_get_dai_id(struct device_node *ep) return id; } -int asoc_graph_parse_dai(struct device *dev, struct device_node *ep, +int graph_util_parse_dai(struct device *dev, struct device_node *ep, struct snd_soc_dai_link_component *dlc, int *is_single_link) { struct device_node *node; @@ -1130,7 +1127,7 @@ parse_dai_end: return 0; } -EXPORT_SYMBOL_GPL(asoc_graph_parse_dai); +EXPORT_SYMBOL_GPL(graph_util_parse_dai); /* Module information */ MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>"); |