mirror of
https://github.com/torvalds/linux.git
synced 2026-05-27 00:22:00 +02:00
ASoC: soc-dapm: prepare for hiding struct
Merge series from Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>: We would like to hide struct snd_soc_dapm_context from driver. So we need cleanup code first. These are preparation for it.
This commit is contained in:
commit
dfe3de7b5a
|
|
@ -261,31 +261,19 @@ struct snd_soc_component {
|
|||
list_for_each_entry_safe(dai, _dai, &(component)->dai_list, list)
|
||||
|
||||
/**
|
||||
* snd_soc_dapm_to_component() - Casts a DAPM context to the component it is
|
||||
* embedded in
|
||||
* @dapm: The DAPM context to cast to the component
|
||||
*
|
||||
* This function must only be used on DAPM contexts that are known to be part of
|
||||
* a component (e.g. in a component driver). Otherwise the behavior is
|
||||
* undefined.
|
||||
*/
|
||||
static inline struct snd_soc_component *snd_soc_dapm_to_component(
|
||||
struct snd_soc_dapm_context *dapm)
|
||||
{
|
||||
return container_of(dapm, struct snd_soc_component, dapm);
|
||||
}
|
||||
|
||||
/**
|
||||
* snd_soc_component_get_dapm() - Returns the DAPM context associated with a
|
||||
* snd_soc_component_to_dapm() - Returns the DAPM context associated with a
|
||||
* component
|
||||
* @component: The component for which to get the DAPM context
|
||||
*/
|
||||
static inline struct snd_soc_dapm_context *snd_soc_component_get_dapm(
|
||||
static inline struct snd_soc_dapm_context *snd_soc_component_to_dapm(
|
||||
struct snd_soc_component *component)
|
||||
{
|
||||
return &component->dapm;
|
||||
}
|
||||
|
||||
// FIXME
|
||||
#define snd_soc_component_get_dapm snd_soc_component_to_dapm
|
||||
|
||||
/**
|
||||
* snd_soc_component_cache_sync() - Sync the register cache with the hardware
|
||||
* @component: COMPONENT to sync
|
||||
|
|
|
|||
|
|
@ -583,11 +583,9 @@ struct snd_soc_dapm_update {
|
|||
struct snd_soc_dapm_context {
|
||||
enum snd_soc_bias_level bias_level;
|
||||
|
||||
/* bit field */
|
||||
unsigned int idle_bias_off:1; /* Use BIAS_OFF instead of STANDBY */
|
||||
unsigned int suspend_bias_off:1; /* Use BIAS_OFF in suspend if the DAPM is idle */
|
||||
bool idle_bias; /* Use BIAS_OFF instead of STANDBY when false */
|
||||
|
||||
struct device *dev; /* from parent - for debug */
|
||||
struct device *dev; /* from parent - for debug */ /* REMOVE ME */
|
||||
struct snd_soc_component *component; /* parent component */
|
||||
struct snd_soc_card *card; /* parent card */
|
||||
|
||||
|
|
@ -660,6 +658,12 @@ void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card);
|
|||
int snd_soc_dapm_update_dai(struct snd_pcm_substream *substream,
|
||||
struct snd_pcm_hw_params *params, struct snd_soc_dai *dai);
|
||||
int snd_soc_dapm_widget_name_cmp(struct snd_soc_dapm_widget *widget, const char *s);
|
||||
struct device *snd_soc_dapm_to_dev(struct snd_soc_dapm_context *dapm);
|
||||
struct snd_soc_card *snd_soc_dapm_to_card(struct snd_soc_dapm_context *dapm);
|
||||
struct snd_soc_component *snd_soc_dapm_to_component(struct snd_soc_dapm_context *dapm);
|
||||
|
||||
bool snd_soc_dapm_get_idle_bias(struct snd_soc_dapm_context *dapm);
|
||||
void snd_soc_dapm_set_idle_bias(struct snd_soc_dapm_context *dapm, bool on);
|
||||
|
||||
/* dapm path setup */
|
||||
int snd_soc_dapm_new_widgets(struct snd_soc_card *card);
|
||||
|
|
|
|||
|
|
@ -1120,6 +1120,11 @@ static inline int snd_soc_card_is_instantiated(struct snd_soc_card *card)
|
|||
return card && card->instantiated;
|
||||
}
|
||||
|
||||
static inline struct snd_soc_dapm_context *snd_soc_card_to_dapm(struct snd_soc_card *card)
|
||||
{
|
||||
return &card->dapm;
|
||||
}
|
||||
|
||||
/* SoC machine DAI configuration, glues a codec and cpu DAI together */
|
||||
struct snd_soc_pcm_runtime {
|
||||
struct device *dev;
|
||||
|
|
|
|||
|
|
@ -1536,7 +1536,7 @@ static int wm8993_probe(struct snd_soc_component *component)
|
|||
* VMID as an output and can disable it.
|
||||
*/
|
||||
if (wm8993->pdata.lineout1_diff && wm8993->pdata.lineout2_diff)
|
||||
dapm->idle_bias_off = 1;
|
||||
dapm->idle_bias = false;
|
||||
|
||||
return 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -4182,8 +4182,8 @@ static int wm8994_component_probe(struct snd_soc_component *component)
|
|||
|
||||
wm8994->micdet_irq = control->pdata.micdet_irq;
|
||||
|
||||
/* By default use idle_bias_off, will override for WM8994 */
|
||||
dapm->idle_bias_off = 1;
|
||||
/* By default use idle_bias false, will override for WM8994 */
|
||||
dapm->idle_bias = false;
|
||||
|
||||
/* Set revision-specific configuration */
|
||||
switch (control->type) {
|
||||
|
|
@ -4191,7 +4191,7 @@ static int wm8994_component_probe(struct snd_soc_component *component)
|
|||
/* Single ended line outputs should have VMID on. */
|
||||
if (!control->pdata.lineout1_diff ||
|
||||
!control->pdata.lineout2_diff)
|
||||
dapm->idle_bias_off = 0;
|
||||
dapm->idle_bias = true;
|
||||
|
||||
switch (control->revision) {
|
||||
case 2:
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ static int avs_es8336_codec_init(struct snd_soc_pcm_runtime *runtime)
|
|||
snd_jack_set_key(data->jack.jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
|
||||
snd_soc_component_set_jack(component, &data->jack, NULL);
|
||||
|
||||
card->dapm.idle_bias_off = true;
|
||||
card->dapm.idle_bias = false;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ static int avs_rt274_codec_init(struct snd_soc_pcm_runtime *runtime)
|
|||
return ret;
|
||||
}
|
||||
|
||||
card->dapm.idle_bias_off = true;
|
||||
card->dapm.idle_bias = false;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ static int avs_rt5640_codec_init(struct snd_soc_pcm_runtime *runtime)
|
|||
return ret;
|
||||
|
||||
snd_soc_component_set_jack(codec_dai->component, jack, NULL);
|
||||
card->dapm.idle_bias_off = true;
|
||||
card->dapm.idle_bias = false;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ static int byt_cht_cx2072x_init(struct snd_soc_pcm_runtime *rtd)
|
|||
byt_cht_cx2072x_acpi_gpios))
|
||||
dev_warn(rtd->dev, "Unable to add GPIO mapping table\n");
|
||||
|
||||
card->dapm.idle_bias_off = true;
|
||||
card->dapm.idle_bias = false;
|
||||
|
||||
/* set the default PLL rate, the clock is handled by the codec driver */
|
||||
ret = snd_soc_dai_set_sysclk(snd_soc_rtd_to_codec(rtd, 0), CX2072X_MCLK_EXTERNAL_PLL,
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ static int byt_cht_es8316_init(struct snd_soc_pcm_runtime *runtime)
|
|||
int num_routes;
|
||||
int ret;
|
||||
|
||||
card->dapm.idle_bias_off = true;
|
||||
card->dapm.idle_bias = false;
|
||||
|
||||
switch (BYT_CHT_ES8316_MAP(quirk)) {
|
||||
case BYT_CHT_ES8316_INTMIC_IN1_MAP:
|
||||
|
|
|
|||
|
|
@ -1324,7 +1324,7 @@ static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime)
|
|||
int num_routes = 0;
|
||||
int ret;
|
||||
|
||||
card->dapm.idle_bias_off = true;
|
||||
card->dapm.idle_bias = false;
|
||||
jack_data->use_platform_clock = true;
|
||||
|
||||
/* Start with RC clk for jack-detect (we disable MCLK below) */
|
||||
|
|
|
|||
|
|
@ -586,7 +586,7 @@ static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime)
|
|||
int report;
|
||||
int ret;
|
||||
|
||||
card->dapm.idle_bias_off = true;
|
||||
card->dapm.idle_bias = false;
|
||||
|
||||
/* Start with RC clk for jack-detect (we disable MCLK below) */
|
||||
if (byt_rt5651_quirk & BYT_RT5651_MCLK_EN)
|
||||
|
|
|
|||
|
|
@ -288,7 +288,7 @@ static int byt_wm5102_init(struct snd_soc_pcm_runtime *runtime)
|
|||
const struct snd_soc_dapm_route *custom_map = NULL;
|
||||
int ret, jack_type, num_routes = 0;
|
||||
|
||||
card->dapm.idle_bias_off = true;
|
||||
card->dapm.idle_bias = false;
|
||||
|
||||
ret = snd_soc_add_card_controls(card, byt_wm5102_controls,
|
||||
ARRAY_SIZE(byt_wm5102_controls));
|
||||
|
|
|
|||
|
|
@ -276,7 +276,7 @@ static int sof_es8316_init(struct snd_soc_pcm_runtime *runtime)
|
|||
int num_routes;
|
||||
int ret;
|
||||
|
||||
card->dapm.idle_bias_off = true;
|
||||
card->dapm.idle_bias = false;
|
||||
|
||||
if (quirk & SOC_ES8336_HEADSET_MIC1) {
|
||||
custom_map = sof_es8316_headset_mic1_map;
|
||||
|
|
|
|||
|
|
@ -717,7 +717,7 @@ int snd_soc_suspend(struct device *dev)
|
|||
* means it's doing something,
|
||||
* otherwise fall through.
|
||||
*/
|
||||
if (dapm->idle_bias_off) {
|
||||
if (!dapm->idle_bias) {
|
||||
dev_dbg(component->dev,
|
||||
"ASoC: idle_bias_off CODEC on over suspend\n");
|
||||
break;
|
||||
|
|
@ -1652,7 +1652,7 @@ static int soc_probe_component(struct snd_soc_card *card,
|
|||
if (ret < 0)
|
||||
goto err_probe;
|
||||
|
||||
WARN(dapm->idle_bias_off &&
|
||||
WARN(!dapm->idle_bias &&
|
||||
dapm->bias_level != SND_SOC_BIAS_OFF,
|
||||
"codec %s can not start from non-off bias with idle_bias_off==1\n",
|
||||
component->name);
|
||||
|
|
|
|||
|
|
@ -165,6 +165,27 @@ static void pop_dbg(struct device *dev, u32 pop_time, const char *fmt, ...)
|
|||
kfree(buf);
|
||||
}
|
||||
|
||||
struct device *snd_soc_dapm_to_dev(struct snd_soc_dapm_context *dapm)
|
||||
{
|
||||
if (dapm->component)
|
||||
return dapm->component->dev;
|
||||
|
||||
return dapm->card->dev;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_soc_dapm_to_dev);
|
||||
|
||||
struct snd_soc_card *snd_soc_dapm_to_card(struct snd_soc_dapm_context *dapm)
|
||||
{
|
||||
return dapm->card;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_soc_dapm_to_card);
|
||||
|
||||
struct snd_soc_component *snd_soc_dapm_to_component(struct snd_soc_dapm_context *dapm)
|
||||
{
|
||||
return dapm->component;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_soc_dapm_to_component);
|
||||
|
||||
static bool dapm_dirty_widget(struct snd_soc_dapm_widget *w)
|
||||
{
|
||||
return !list_empty(&w->dirty);
|
||||
|
|
@ -2159,21 +2180,26 @@ static void dapm_power_one_widget(struct snd_soc_dapm_widget *w,
|
|||
dapm_seq_insert(w, down_list, false);
|
||||
}
|
||||
|
||||
static bool dapm_idle_bias_off(struct snd_soc_dapm_context *dapm)
|
||||
bool snd_soc_dapm_get_idle_bias(struct snd_soc_dapm_context *dapm)
|
||||
{
|
||||
if (dapm->idle_bias_off)
|
||||
return true;
|
||||
if (dapm->idle_bias) {
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(dapm);
|
||||
unsigned int state = snd_power_get_state(dapm->card->snd_card);
|
||||
|
||||
switch (snd_power_get_state(dapm->card->snd_card)) {
|
||||
case SNDRV_CTL_POWER_D3hot:
|
||||
case SNDRV_CTL_POWER_D3cold:
|
||||
return dapm->suspend_bias_off;
|
||||
default:
|
||||
break;
|
||||
if ((state == SNDRV_CTL_POWER_D3hot || (state == SNDRV_CTL_POWER_D3cold)) &&
|
||||
component)
|
||||
return !component->driver->suspend_bias_off;
|
||||
}
|
||||
|
||||
return false;
|
||||
return dapm->idle_bias;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_soc_dapm_get_idle_bias);
|
||||
|
||||
void snd_soc_dapm_set_idle_bias(struct snd_soc_dapm_context *dapm, bool on)
|
||||
{
|
||||
dapm->idle_bias = on;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_soc_dapm_set_idle_bias);
|
||||
|
||||
/*
|
||||
* Scan each dapm widget for complete audio path.
|
||||
|
|
@ -2200,10 +2226,10 @@ static int dapm_power_widgets(struct snd_soc_card *card, int event,
|
|||
trace_snd_soc_dapm_start(card, event);
|
||||
|
||||
for_each_card_dapms(card, d) {
|
||||
if (dapm_idle_bias_off(d))
|
||||
d->target_bias_level = SND_SOC_BIAS_OFF;
|
||||
else
|
||||
if (snd_soc_dapm_get_idle_bias(d))
|
||||
d->target_bias_level = SND_SOC_BIAS_STANDBY;
|
||||
else
|
||||
d->target_bias_level = SND_SOC_BIAS_OFF;
|
||||
}
|
||||
|
||||
dapm_reset(card);
|
||||
|
|
@ -2267,7 +2293,7 @@ static int dapm_power_widgets(struct snd_soc_card *card, int event,
|
|||
if (d->target_bias_level > bias)
|
||||
bias = d->target_bias_level;
|
||||
for_each_card_dapms(card, d)
|
||||
if (!dapm_idle_bias_off(d))
|
||||
if (snd_soc_dapm_get_idle_bias(d))
|
||||
d->target_bias_level = bias;
|
||||
|
||||
trace_snd_soc_dapm_walk_done(card);
|
||||
|
|
@ -4801,8 +4827,7 @@ void snd_soc_dapm_init(struct snd_soc_dapm_context *dapm,
|
|||
|
||||
if (component) {
|
||||
dapm->dev = component->dev;
|
||||
dapm->idle_bias_off = !component->driver->idle_bias_on;
|
||||
dapm->suspend_bias_off = component->driver->suspend_bias_off;
|
||||
dapm->idle_bias = component->driver->idle_bias_on;
|
||||
} else {
|
||||
dapm->dev = card->dev;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -525,7 +525,7 @@ static int sof_probes_client_probe(struct auxiliary_device *auxdev,
|
|||
card->dai_link = links;
|
||||
|
||||
/* set idle_bias_off to prevent the core from resuming the card->dev */
|
||||
card->dapm.idle_bias_off = true;
|
||||
card->dapm.idle_bias = false;
|
||||
|
||||
snd_soc_card_set_drvdata(card, cdev);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user