提交 ef641e5d 编写于 作者: K Kuninori Morimoto 提交者: Mark Brown

ASoC: add Component level set_pll

In current ALSA SoC, Codec only has set_pll feature.
Codec will be merged into Component in next generation ALSA SoC,
thus current Codec specific feature need to be merged into it.
This is glue patch for it.
Signed-off-by: NKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: NMark Brown <broonie@kernel.org>
上级 71ccef0d
...@@ -798,6 +798,8 @@ struct snd_soc_component_driver { ...@@ -798,6 +798,8 @@ struct snd_soc_component_driver {
/* component wide operations */ /* component wide operations */
int (*set_sysclk)(struct snd_soc_component *component, int (*set_sysclk)(struct snd_soc_component *component,
int clk_id, int source, unsigned int freq, int dir); int clk_id, int source, unsigned int freq, int dir);
int (*set_pll)(struct snd_soc_component *component, int pll_id,
int source, unsigned int freq_in, unsigned int freq_out);
/* DT */ /* DT */
int (*of_xlate_dai_name)(struct snd_soc_component *component, int (*of_xlate_dai_name)(struct snd_soc_component *component,
...@@ -871,6 +873,8 @@ struct snd_soc_component { ...@@ -871,6 +873,8 @@ struct snd_soc_component {
int (*set_sysclk)(struct snd_soc_component *component, int (*set_sysclk)(struct snd_soc_component *component,
int clk_id, int source, unsigned int freq, int dir); int clk_id, int source, unsigned int freq, int dir);
int (*set_pll)(struct snd_soc_component *component, int pll_id,
int source, unsigned int freq_in, unsigned int freq_out);
/* machine specific init */ /* machine specific init */
int (*init)(struct snd_soc_component *component); int (*init)(struct snd_soc_component *component);
...@@ -1469,6 +1473,9 @@ int snd_soc_component_test_bits(struct snd_soc_component *component, ...@@ -1469,6 +1473,9 @@ int snd_soc_component_test_bits(struct snd_soc_component *component,
/* component wide operations */ /* component wide operations */
int snd_soc_component_set_sysclk(struct snd_soc_component *component, int snd_soc_component_set_sysclk(struct snd_soc_component *component,
int clk_id, int source, unsigned int freq, int dir); int clk_id, int source, unsigned int freq, int dir);
int snd_soc_component_set_pll(struct snd_soc_component *component, int pll_id,
int source, unsigned int freq_in,
unsigned int freq_out);
#ifdef CONFIG_REGMAP #ifdef CONFIG_REGMAP
......
...@@ -2679,11 +2679,9 @@ int snd_soc_dai_set_pll(struct snd_soc_dai *dai, int pll_id, int source, ...@@ -2679,11 +2679,9 @@ int snd_soc_dai_set_pll(struct snd_soc_dai *dai, int pll_id, int source,
if (dai->driver && dai->driver->ops->set_pll) if (dai->driver && dai->driver->ops->set_pll)
return dai->driver->ops->set_pll(dai, pll_id, source, return dai->driver->ops->set_pll(dai, pll_id, source,
freq_in, freq_out); freq_in, freq_out);
else if (dai->codec && dai->codec->driver->set_pll)
return dai->codec->driver->set_pll(dai->codec, pll_id, source, return snd_soc_component_set_pll(dai->component, pll_id, source,
freq_in, freq_out); freq_in, freq_out);
else
return -EINVAL;
} }
EXPORT_SYMBOL_GPL(snd_soc_dai_set_pll); EXPORT_SYMBOL_GPL(snd_soc_dai_set_pll);
...@@ -2708,6 +2706,33 @@ int snd_soc_codec_set_pll(struct snd_soc_codec *codec, int pll_id, int source, ...@@ -2708,6 +2706,33 @@ int snd_soc_codec_set_pll(struct snd_soc_codec *codec, int pll_id, int source,
} }
EXPORT_SYMBOL_GPL(snd_soc_codec_set_pll); EXPORT_SYMBOL_GPL(snd_soc_codec_set_pll);
/*
* snd_soc_component_set_pll - configure component PLL.
* @component: COMPONENT
* @pll_id: DAI specific PLL ID
* @source: DAI specific source for the PLL
* @freq_in: PLL input clock frequency in Hz
* @freq_out: requested PLL output clock frequency in Hz
*
* Configures and enables PLL to generate output clock based on input clock.
*/
int snd_soc_component_set_pll(struct snd_soc_component *component, int pll_id,
int source, unsigned int freq_in,
unsigned int freq_out)
{
/* will be removed */
if (component->set_pll)
return component->set_pll(component, pll_id, source,
freq_in, freq_out);
if (component->driver->set_pll)
return component->driver->set_pll(component, pll_id, source,
freq_in, freq_out);
return -EINVAL;
}
EXPORT_SYMBOL_GPL(snd_soc_component_set_pll);
/** /**
* snd_soc_dai_set_bclk_ratio - configure BCLK to sample rate ratio. * snd_soc_dai_set_bclk_ratio - configure BCLK to sample rate ratio.
* @dai: DAI * @dai: DAI
...@@ -3199,6 +3224,7 @@ static int snd_soc_component_initialize(struct snd_soc_component *component, ...@@ -3199,6 +3224,7 @@ static int snd_soc_component_initialize(struct snd_soc_component *component,
component->suspend = component->driver->suspend; component->suspend = component->driver->suspend;
component->resume = component->driver->resume; component->resume = component->driver->resume;
component->set_sysclk = component->driver->set_sysclk; component->set_sysclk = component->driver->set_sysclk;
component->set_pll = component->driver->set_pll;
dapm = &component->dapm; dapm = &component->dapm;
dapm->dev = dev; dapm->dev = dev;
...@@ -3590,6 +3616,15 @@ static int snd_soc_codec_set_sysclk_(struct snd_soc_component *component, ...@@ -3590,6 +3616,15 @@ static int snd_soc_codec_set_sysclk_(struct snd_soc_component *component,
return snd_soc_codec_set_sysclk(codec, clk_id, source, freq, dir); return snd_soc_codec_set_sysclk(codec, clk_id, source, freq, dir);
} }
static int snd_soc_codec_set_pll_(struct snd_soc_component *component,
int pll_id, int source, unsigned int freq_in,
unsigned int freq_out)
{
struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
return snd_soc_codec_set_pll(codec, pll_id, source, freq_in, freq_out);
}
static int snd_soc_codec_set_bias_level(struct snd_soc_dapm_context *dapm, static int snd_soc_codec_set_bias_level(struct snd_soc_dapm_context *dapm,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
...@@ -3643,6 +3678,8 @@ int snd_soc_register_codec(struct device *dev, ...@@ -3643,6 +3678,8 @@ int snd_soc_register_codec(struct device *dev,
codec->component.read = snd_soc_codec_drv_read; codec->component.read = snd_soc_codec_drv_read;
if (codec_drv->set_sysclk) if (codec_drv->set_sysclk)
codec->component.set_sysclk = snd_soc_codec_set_sysclk_; codec->component.set_sysclk = snd_soc_codec_set_sysclk_;
if (codec_drv->set_pll)
codec->component.set_pll = snd_soc_codec_set_pll_;
codec->component.ignore_pmdown_time = codec_drv->ignore_pmdown_time; codec->component.ignore_pmdown_time = codec_drv->ignore_pmdown_time;
dapm = snd_soc_codec_get_dapm(codec); dapm = snd_soc_codec_get_dapm(codec);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册