ASoC: add Component level set_sysclk

In current ALSA SoC, Codec only has set_sysclk 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: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Kuninori Morimoto 2017-08-24 00:57:35 +00:00 committed by Mark Brown
parent b388dc1f62
commit 71ccef0df5
2 changed files with 51 additions and 5 deletions

View File

@ -795,6 +795,10 @@ struct snd_soc_component_driver {
int (*suspend)(struct snd_soc_component *); int (*suspend)(struct snd_soc_component *);
int (*resume)(struct snd_soc_component *); int (*resume)(struct snd_soc_component *);
/* component wide operations */
int (*set_sysclk)(struct snd_soc_component *component,
int clk_id, int source, unsigned int freq, int dir);
/* DT */ /* DT */
int (*of_xlate_dai_name)(struct snd_soc_component *component, int (*of_xlate_dai_name)(struct snd_soc_component *component,
struct of_phandle_args *args, struct of_phandle_args *args,
@ -865,6 +869,9 @@ struct snd_soc_component {
int (*suspend)(struct snd_soc_component *); int (*suspend)(struct snd_soc_component *);
int (*resume)(struct snd_soc_component *); int (*resume)(struct snd_soc_component *);
int (*set_sysclk)(struct snd_soc_component *component,
int clk_id, int source, unsigned int freq, int dir);
/* machine specific init */ /* machine specific init */
int (*init)(struct snd_soc_component *component); int (*init)(struct snd_soc_component *component);
@ -1459,6 +1466,10 @@ void snd_soc_component_async_complete(struct snd_soc_component *component);
int snd_soc_component_test_bits(struct snd_soc_component *component, int snd_soc_component_test_bits(struct snd_soc_component *component,
unsigned int reg, unsigned int mask, unsigned int value); unsigned int reg, unsigned int mask, unsigned int value);
/* component wide operations */
int snd_soc_component_set_sysclk(struct snd_soc_component *component,
int clk_id, int source, unsigned int freq, int dir);
#ifdef CONFIG_REGMAP #ifdef CONFIG_REGMAP
void snd_soc_component_init_regmap(struct snd_soc_component *component, void snd_soc_component_init_regmap(struct snd_soc_component *component,

View File

@ -2590,11 +2590,9 @@ int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id,
{ {
if (dai->driver && dai->driver->ops->set_sysclk) if (dai->driver && dai->driver->ops->set_sysclk)
return dai->driver->ops->set_sysclk(dai, clk_id, freq, dir); return dai->driver->ops->set_sysclk(dai, clk_id, freq, dir);
else if (dai->codec && dai->codec->driver->set_sysclk)
return dai->codec->driver->set_sysclk(dai->codec, clk_id, 0, return snd_soc_component_set_sysclk(dai->component, clk_id, 0,
freq, dir); freq, dir);
else
return -ENOTSUPP;
} }
EXPORT_SYMBOL_GPL(snd_soc_dai_set_sysclk); EXPORT_SYMBOL_GPL(snd_soc_dai_set_sysclk);
@ -2619,6 +2617,32 @@ int snd_soc_codec_set_sysclk(struct snd_soc_codec *codec, int clk_id,
} }
EXPORT_SYMBOL_GPL(snd_soc_codec_set_sysclk); EXPORT_SYMBOL_GPL(snd_soc_codec_set_sysclk);
/**
* snd_soc_component_set_sysclk - configure COMPONENT system or master clock.
* @component: COMPONENT
* @clk_id: DAI specific clock ID
* @source: Source for the clock
* @freq: new clock frequency in Hz
* @dir: new clock direction - input/output.
*
* Configures the CODEC master (MCLK) or system (SYSCLK) clocking.
*/
int snd_soc_component_set_sysclk(struct snd_soc_component *component, int clk_id,
int source, unsigned int freq, int dir)
{
/* will be removed */
if (component->set_sysclk)
return component->set_sysclk(component, clk_id, source,
freq, dir);
if (component->driver->set_sysclk)
return component->driver->set_sysclk(component, clk_id, source,
freq, dir);
return -ENOTSUPP;
}
EXPORT_SYMBOL_GPL(snd_soc_component_set_sysclk);
/** /**
* snd_soc_dai_set_clkdiv - configure DAI clock dividers. * snd_soc_dai_set_clkdiv - configure DAI clock dividers.
* @dai: DAI * @dai: DAI
@ -3174,6 +3198,7 @@ static int snd_soc_component_initialize(struct snd_soc_component *component,
component->remove = component->driver->remove; component->remove = component->driver->remove;
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;
dapm = &component->dapm; dapm = &component->dapm;
dapm->dev = dev; dapm->dev = dev;
@ -3557,6 +3582,14 @@ static int snd_soc_codec_drv_read(struct snd_soc_component *component,
return 0; return 0;
} }
static int snd_soc_codec_set_sysclk_(struct snd_soc_component *component,
int clk_id, int source, unsigned int freq, int dir)
{
struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
return snd_soc_codec_set_sysclk(codec, clk_id, source, freq, dir);
}
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)
{ {
@ -3608,6 +3641,8 @@ int snd_soc_register_codec(struct device *dev,
codec->component.write = snd_soc_codec_drv_write; codec->component.write = snd_soc_codec_drv_write;
if (codec_drv->read) if (codec_drv->read)
codec->component.read = snd_soc_codec_drv_read; codec->component.read = snd_soc_codec_drv_read;
if (codec_drv->set_sysclk)
codec->component.set_sysclk = snd_soc_codec_set_sysclk_;
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);