for (i = 0; i < ARRAY_SIZE(of_sample_fmt_table); i++) { if (!strcmp(data->convert_sample_format,
of_sample_fmt_table[i].fmt)) {
val = of_sample_fmt_table[i].val; break;
}
} return val;
}
EXPORT_SYMBOL_GPL(simple_util_get_sample_fmt);
/** * 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 simple_util_is_convert_required(conststruct simple_util_data *data)
{ return data->convert_rate ||
data->convert_channels ||
data->convert_sample_format;
}
EXPORT_SYMBOL_GPL(simple_util_is_convert_required);
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 * sound node level, revert back to legacy DT parsing and * take the settings from codec node.
*/
dev_dbg(dev, "Revert to legacy daifmt parsing\n");
int simple_util_parse_tdm_width_map(struct simple_util_priv *priv, struct device_node *np, struct simple_util_dai *dai)
{ struct device *dev = simple_priv_to_dev(priv); int n, i, ret;
u32 *p;
/* * NOTE * * Clang doesn't allow to use "goto end" before calling __free(), * because it bypasses the initialization. Use simple_ret() directly.
*/
n = of_property_count_elems_of_size(np, "dai-tdm-slot-width-map", sizeof(u32)); if (n <= 0) return 0;
if (n % 3) {
dev_err(dev, "Invalid number of cells for dai-tdm-slot-width-map\n"); return simple_ret(priv, -EINVAL); /* see NOTE */
}
ret = -ENOMEM;
dai->tdm_width_map = devm_kcalloc(dev, n, sizeof(*dai->tdm_width_map), GFP_KERNEL); if (!dai->tdm_width_map) return simple_ret(priv, ret); /* see NOTE */
ret = of_property_read_u32_array(np, "dai-tdm-slot-width-map", array_values, n); if (ret < 0) {
dev_err(dev, "Could not read dai-tdm-slot-width-map: %d\n", ret); goto end;
}
p = array_values; for (i = 0; i < n / 3; ++i) {
dai->tdm_width_map[i].sample_bits = *p++;
dai->tdm_width_map[i].slot_width = *p++;
dai->tdm_width_map[i].slot_count = *p++;
}
if (fixed_sysclk % props->mclk_fs) {
dev_err(rtd->dev, "fixed sysclk %u not divisible by mclk_fs %u\n",
fixed_sysclk, props->mclk_fs);
ret = -EINVAL; goto codec_err;
}
ret = snd_pcm_hw_constraint_minmax(substream->runtime, SNDRV_PCM_HW_PARAM_RATE,
fixed_rate, fixed_rate); if (ret < 0) goto codec_err;
}
return 0;
codec_err:
for_each_prop_dai_codec(props, i, dai) { if (i >= i2) break;
simple_clk_disable(dai);
}
cpu_err:
for_each_prop_dai_cpu(props, i, dai) { if (i >= i1) break;
simple_clk_disable(dai);
}
for_each_prop_dai_codec(props, i, pdai) {
ret = simple_set_clk_rate(priv, pdai, mclk); if (ret < 0) goto end;
}
for_each_prop_dai_cpu(props, i, pdai) {
ret = simple_set_clk_rate(priv, pdai, mclk); if (ret < 0) goto end;
}
/* Ensure sysclk is set on all components in case any * (such as platform components) are missed by calls to * snd_soc_dai_set_sysclk.
*/
for_each_rtd_components(rtd, i, component) {
ret = snd_soc_component_set_sysclk(component, 0, 0,
mclk, SND_SOC_CLOCK_IN); if (ret && ret != -ENOTSUPP) goto end;
}
for_each_rtd_codec_dais(rtd, i, sdai) {
pdai = simple_props_to_dai_codec(props, i);
ret = snd_soc_dai_set_sysclk(sdai, 0, mclk, pdai->clk_direction); if (ret && ret != -ENOTSUPP) goto end;
}
for_each_rtd_cpu_dais(rtd, i, sdai) {
pdai = simple_props_to_dai_cpu(props, i);
ret = snd_soc_dai_set_sysclk(sdai, 0, mclk, pdai->clk_direction); if (ret && ret != -ENOTSUPP) goto end;
}
}
for_each_prop_dai_codec(props, i, pdai) {
sdai = snd_soc_rtd_to_codec(rtd, i);
ret = simple_set_tdm(priv, sdai, pdai, params); if (ret < 0) goto end;
}
for_each_prop_dai_cpu(props, i, pdai) {
sdai = snd_soc_rtd_to_cpu(rtd, i);
ret = simple_set_tdm(priv, sdai, pdai, params); if (ret < 0) goto end;
}
ret = 0;
end: return simple_ret(priv, ret);
}
EXPORT_SYMBOL_GPL(simple_util_hw_params);
/* Do nothing if it already has Codec2Codec settings */ if (dai_link->c2c_params) return 0;
/* Do nothing if it was DPCM :: BE */ if (dai_link->no_pcm) return 0;
/* Only Codecs */
for_each_rtd_components(rtd, i, component) { if (!simple_component_is_codec(component)) return 0;
}
/* Assumes the capabilities are the same for all supported streams */
for_each_pcm_streams(stream) {
ret = snd_soc_runtime_calc_hw(rtd, &hw, stream); if (ret == 0) break;
}
if (ret < 0) {
dev_err(rtd->dev, "simple-card: no valid dai_link params\n"); goto end;
}
ret = -ENOMEM;
c2c_params = devm_kzalloc(rtd->dev, sizeof(*c2c_params), GFP_KERNEL); if (!c2c_params) goto end;
void simple_util_canonicalize_platform(struct snd_soc_dai_link_component *platforms, struct snd_soc_dai_link_component *cpus)
{ /* * Assumes Platform == CPU * * Some CPU might be using soc-generic-dmaengine-pcm. This means CPU and Platform * are different Component, but are sharing same component->dev. * * Let's assume Platform is same as CPU if it doesn't identify Platform on DT. * see * simple-card.c :: simple_count_noml()
*/ if (!platforms->of_node)
snd_soc_dlc_use_cpu_as_platform(platforms, cpus);
}
EXPORT_SYMBOL_GPL(simple_util_canonicalize_platform);
void simple_util_canonicalize_cpu(struct snd_soc_dai_link_component *cpus, int is_single_links)
{ /* * In soc_bind_dai_link() will check cpu name after * of_node matching if dai_link has cpu_dai_name. * but, it will never match if name was created by * fmt_single_name() remove cpu_dai_name if cpu_args * was 0. See: * fmt_single_name() * fmt_multiple_name()
*/ if (is_single_links)
cpus->dai_name = NULL;
}
EXPORT_SYMBOL_GPL(simple_util_canonicalize_cpu);
void simple_util_clean_reference(struct snd_soc_card *card)
{ struct snd_soc_dai_link *dai_link; struct snd_soc_dai_link_component *cpu; struct snd_soc_dai_link_component *codec; int i, j;
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; int found_jack_index = 0; int type = 0; int num = 0; int ret;
if (priv->aux_jacks) return 0;
for_each_card_auxs(card, component) {
type = snd_soc_component_get_jack_type(component); if (type > 0)
num++;
} if (num < 1) return 0;
type = snd_soc_component_get_jack_type(component); if (type <= 0) continue;
/* create jack */
jack = &(priv->aux_jacks[found_jack_index++]);
snprintf(id, sizeof(id), "%s-jack", component->name);
ret = snd_soc_card_jack_new(card, id, type, jack); if (ret) continue;
for (i = 0; i < li->link; i++) { if (li->num[i].cpus) { /* Normal CPU */
dai_link[i].cpus = dlcs;
dai_props[i].num.cpus =
dai_link[i].num_cpus = li->num[i].cpus;
dai_props[i].cpu_dai = dais;
staticint graph_get_dai_id(struct device_node *ep)
{ struct device_node *node __free(device_node) = of_graph_get_port_parent(ep); struct device_node *port __free(device_node) = of_get_parent(ep); struct of_endpoint info; int i, id; int ret;
/* use driver specified DAI ID if exist */
ret = snd_soc_get_dai_id(ep); if (ret != -ENOTSUPP) return ret;
/* use endpoint/port reg if exist */
ret = of_graph_parse_endpoint(ep, &info); if (ret == 0) { /* * Because it will count port/endpoint if it doesn't have "reg". * But, we can't judge whether it has "no reg", or "reg = <0>" * only of_graph_parse_endpoint(). * We need to check "reg" property
*/
/* check port first */
ret = of_property_present(port, "reg"); if (ret) return info.port;
/* check endpoint 2nd as backup */ if (of_property_present(ep, "reg")) return info.id;
}
/* * Non HDMI sound case, counting port/endpoint on its DT * is enough. Let's count it.
*/
i = 0;
id = -1;
for_each_of_graph_port(node, p) { if (port == p) {
id = i; break;
}
i++;
}
/* * FIXME * * Here, dlc->dai_name is pointer to CPU/Codec DAI name. * If user unbinded CPU or Codec driver, but not for Sound Card, * dlc->dai_name is keeping unbinded CPU or Codec * driver's pointer. * * If user re-bind CPU or Codec driver again, ALSA SoC will try * to rebind Card via snd_soc_try_rebind_card(), but because of * above reason, it might can't bind Sound Card. * Because Sound Card is pointing to released dai_name pointer. * * To avoid this rebind Card issue, * 1) It needs to alloc memory to keep dai_name eventhough * CPU or Codec driver was unbinded, or * 2) user need to rebind Sound Card everytime * if he unbinded CPU or Codec.
*/
ret = snd_soc_get_dlc(&args, dlc); if (ret < 0) goto err;
parse_dai_end: if (is_single_link)
*is_single_link = of_graph_get_endpoint_count(node) == 1;
ret = 0;
err: if (ret < 0)
of_node_put(node);
/* * We can use it like below * * #include <dt-bindings/sound/audio-graph.h> * * link-trigger-order = <SND_SOC_TRIGGER_LINK * SND_SOC_TRIGGER_COMPONENT * SND_SOC_TRIGGER_DAI>;
*/
order = __graph_util_parse_trigger_order(priv, np, "link-trigger-order"); if (order < SND_SOC_TRIGGER_ORDER_MAX) {
*trigger_start = order;
*trigger_stop = order;
}
order = __graph_util_parse_trigger_order(priv, np, "link-trigger-order-start"); if (order < SND_SOC_TRIGGER_ORDER_MAX)
*trigger_start = order;
order = __graph_util_parse_trigger_order(priv, np, "link-trigger-order-stop"); if (order < SND_SOC_TRIGGER_ORDER_MAX)
*trigger_stop = order;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.