In some situations, codec configuration will depend on the bclk_ratio generated by the cpu dai. The tda998x hdmi transmitter is an example of this. Allow simple-card to set the bclk_ratio via the 'bclk-slot-ratio' devicetree property, which describes the bclk to slot rate ratio. This value is converted to the bclk to sample ratio before being passed into set_bclk_ratio(). Signed-off-by: Sven Van Asbroeck <TheSven73@xxxxxxxxx> --- sound/soc/generic/simple-card.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 3fe34417ec89..61e9ba4e9b58 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -25,6 +25,7 @@ struct simple_card_data { struct asoc_simple_card_data adata; struct snd_soc_codec_conf *codec_conf; unsigned int mclk_fs; + unsigned int bclk_slot_ratio; } *dai_props; struct asoc_simple_jack hp_jack; struct asoc_simple_jack mic_jack; @@ -97,7 +98,7 @@ static int asoc_simple_card_hw_params(struct snd_pcm_substream *substream, struct simple_card_data *priv = snd_soc_card_get_drvdata(rtd->card); struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num); - unsigned int mclk, mclk_fs = 0; + unsigned int mclk, bclk_ratio, mclk_fs = 0, bclk_slot_ratio = 0; int ret = 0; if (dai_props->mclk_fs) @@ -124,6 +125,23 @@ static int asoc_simple_card_hw_params(struct snd_pcm_substream *substream, if (ret && ret != -ENOTSUPP) goto err; } + + if (dai_props->bclk_slot_ratio) + bclk_slot_ratio = dai_props->bclk_slot_ratio; + + if (bclk_slot_ratio) { + /* FIXME do we need to care about TDM slots here ? */ + bclk_ratio = snd_soc_calc_frame_size(bclk_slot_ratio, + params_channels(params), 1); + + ret = snd_soc_dai_set_bclk_ratio(codec_dai, bclk_ratio); + if (ret && ret != -ENOTSUPP) + goto err; + + ret = snd_soc_dai_set_bclk_ratio(cpu_dai, bclk_ratio); + if (ret && ret != -ENOTSUPP) + goto err; + } return 0; err: return ret; @@ -277,6 +295,12 @@ static int asoc_simple_card_dai_link_of_dpcm(struct device_node *top, of_property_read_u32(node, prop, &dai_props->mclk_fs); of_property_read_u32(np, prop, &dai_props->mclk_fs); + snprintf(prop, sizeof(prop), "%sbclk-slot-ratio", prefix); + of_property_read_u32(top, PREFIX "bclk-slot-ratio", + &dai_props->bclk_slot_ratio); + of_property_read_u32(node, prop, &dai_props->bclk_slot_ratio); + of_property_read_u32(np, prop, &dai_props->bclk_slot_ratio); + ret = asoc_simple_card_parse_daifmt(dev, node, codec, prefix, &dai_link->dai_fmt); if (ret < 0) @@ -349,6 +373,13 @@ static int asoc_simple_card_dai_link_of(struct device_node *top, of_property_read_u32(cpu, prop, &dai_props->mclk_fs); of_property_read_u32(codec, prop, &dai_props->mclk_fs); + snprintf(prop, sizeof(prop), "%sbclk-slot-ratio", prefix); + of_property_read_u32(top, PREFIX "bclk-slot-ratio", + &dai_props->bclk_slot_ratio); + of_property_read_u32(node, prop, &dai_props->bclk_slot_ratio); + of_property_read_u32(cpu, prop, &dai_props->bclk_slot_ratio); + of_property_read_u32(codec, prop, &dai_props->bclk_slot_ratio); + ret = asoc_simple_card_parse_cpu(cpu, dai_link, DAI, CELL, &single_cpu); if (ret < 0) -- 2.17.1 _______________________________________________ Alsa-devel mailing list Alsa-devel@xxxxxxxxxxxxxxxx https://mailman.alsa-project.org/mailman/listinfo/alsa-devel