Commit 66f89906 authored by Mark Brown's avatar Mark Brown

Merge remote-tracking branch 'asoc/topic/component' into asoc-next

parents 1e570a83 9178feb4
...@@ -782,6 +782,8 @@ struct snd_soc_component_driver { ...@@ -782,6 +782,8 @@ struct snd_soc_component_driver {
int (*probe)(struct snd_soc_component *); int (*probe)(struct snd_soc_component *);
void (*remove)(struct snd_soc_component *); void (*remove)(struct snd_soc_component *);
int (*suspend)(struct snd_soc_component *);
int (*resume)(struct snd_soc_component *);
/* DT */ /* DT */
int (*of_xlate_dai_name)(struct snd_soc_component *component, int (*of_xlate_dai_name)(struct snd_soc_component *component,
...@@ -807,9 +809,11 @@ struct snd_soc_component { ...@@ -807,9 +809,11 @@ struct snd_soc_component {
unsigned int ignore_pmdown_time:1; /* pmdown_time is ignored at stop */ unsigned int ignore_pmdown_time:1; /* pmdown_time is ignored at stop */
unsigned int registered_as_component:1; unsigned int registered_as_component:1;
unsigned int auxiliary:1; /* for auxiliary component of the card */
unsigned int suspended:1; /* is in suspend PM state */
struct list_head list; struct list_head list;
struct list_head list_aux; /* for auxiliary component of the card */ struct list_head card_list;
struct snd_soc_dai_driver *dai_drv; struct snd_soc_dai_driver *dai_drv;
int num_dai; int num_dai;
...@@ -852,6 +856,8 @@ struct snd_soc_component { ...@@ -852,6 +856,8 @@ struct snd_soc_component {
int (*probe)(struct snd_soc_component *); int (*probe)(struct snd_soc_component *);
void (*remove)(struct snd_soc_component *); void (*remove)(struct snd_soc_component *);
int (*suspend)(struct snd_soc_component *);
int (*resume)(struct snd_soc_component *);
/* machine specific init */ /* machine specific init */
int (*init)(struct snd_soc_component *component); int (*init)(struct snd_soc_component *component);
...@@ -868,11 +874,9 @@ struct snd_soc_codec { ...@@ -868,11 +874,9 @@ struct snd_soc_codec {
const struct snd_soc_codec_driver *driver; const struct snd_soc_codec_driver *driver;
struct list_head list; struct list_head list;
struct list_head card_list;
/* runtime */ /* runtime */
unsigned int cache_bypass:1; /* Suppress access to the cache */ unsigned int cache_bypass:1; /* Suppress access to the cache */
unsigned int suspended:1; /* Codec is in suspend PM state */
unsigned int cache_init:1; /* codec cache has been initialized */ unsigned int cache_init:1; /* codec cache has been initialized */
/* codec IO */ /* codec IO */
...@@ -1148,7 +1152,6 @@ struct snd_soc_card { ...@@ -1148,7 +1152,6 @@ struct snd_soc_card {
*/ */
struct snd_soc_aux_dev *aux_dev; struct snd_soc_aux_dev *aux_dev;
int num_aux_devs; int num_aux_devs;
struct list_head aux_comp_list;
const struct snd_kcontrol_new *controls; const struct snd_kcontrol_new *controls;
int num_controls; int num_controls;
...@@ -1170,7 +1173,7 @@ struct snd_soc_card { ...@@ -1170,7 +1173,7 @@ struct snd_soc_card {
struct work_struct deferred_resume_work; struct work_struct deferred_resume_work;
/* lists of probed devices belonging to this card */ /* lists of probed devices belonging to this card */
struct list_head codec_dev_list; struct list_head component_dev_list;
struct list_head widgets; struct list_head widgets;
struct list_head paths; struct list_head paths;
...@@ -1219,7 +1222,6 @@ struct snd_soc_pcm_runtime { ...@@ -1219,7 +1222,6 @@ struct snd_soc_pcm_runtime {
struct snd_soc_platform *platform; struct snd_soc_platform *platform;
struct snd_soc_dai *codec_dai; struct snd_soc_dai *codec_dai;
struct snd_soc_dai *cpu_dai; struct snd_soc_dai *cpu_dai;
struct snd_soc_component *component; /* Only valid for AUX dev rtds */
struct snd_soc_dai **codec_dais; struct snd_soc_dai **codec_dais;
unsigned int num_codecs; unsigned int num_codecs;
...@@ -1541,11 +1543,10 @@ static inline void *snd_soc_platform_get_drvdata(struct snd_soc_platform *platfo ...@@ -1541,11 +1543,10 @@ static inline void *snd_soc_platform_get_drvdata(struct snd_soc_platform *platfo
static inline void snd_soc_initialize_card_lists(struct snd_soc_card *card) static inline void snd_soc_initialize_card_lists(struct snd_soc_card *card)
{ {
INIT_LIST_HEAD(&card->codec_dev_list);
INIT_LIST_HEAD(&card->widgets); INIT_LIST_HEAD(&card->widgets);
INIT_LIST_HEAD(&card->paths); INIT_LIST_HEAD(&card->paths);
INIT_LIST_HEAD(&card->dapm_list); INIT_LIST_HEAD(&card->dapm_list);
INIT_LIST_HEAD(&card->aux_comp_list); INIT_LIST_HEAD(&card->component_dev_list);
} }
static inline bool snd_soc_volsw_is_stereo(struct soc_mixer_control *mc) static inline bool snd_soc_volsw_is_stereo(struct soc_mixer_control *mc)
......
...@@ -220,10 +220,12 @@ static struct snd_soc_dai_link broadwell_rt286_dais[] = { ...@@ -220,10 +220,12 @@ static struct snd_soc_dai_link broadwell_rt286_dais[] = {
}; };
static int broadwell_suspend(struct snd_soc_card *card){ static int broadwell_suspend(struct snd_soc_card *card){
struct snd_soc_codec *codec; struct snd_soc_component *component;
list_for_each_entry(component, &card->component_dev_list, card_list) {
if (!strcmp(component->name, "i2c-INT343A:00")) {
struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
list_for_each_entry(codec, &card->codec_dev_list, card_list) {
if (!strcmp(codec->component.name, "i2c-INT343A:00")) {
dev_dbg(codec->dev, "disabling jack detect before going to suspend.\n"); dev_dbg(codec->dev, "disabling jack detect before going to suspend.\n");
rt286_mic_detect(codec, NULL); rt286_mic_detect(codec, NULL);
break; break;
...@@ -233,10 +235,12 @@ static int broadwell_suspend(struct snd_soc_card *card){ ...@@ -233,10 +235,12 @@ static int broadwell_suspend(struct snd_soc_card *card){
} }
static int broadwell_resume(struct snd_soc_card *card){ static int broadwell_resume(struct snd_soc_card *card){
struct snd_soc_codec *codec; struct snd_soc_component *component;
list_for_each_entry(component, &card->component_dev_list, card_list) {
if (!strcmp(component->name, "i2c-INT343A:00")) {
struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
list_for_each_entry(codec, &card->codec_dev_list, card_list) {
if (!strcmp(codec->component.name, "i2c-INT343A:00")) {
dev_dbg(codec->dev, "enabling jack detect for resume.\n"); dev_dbg(codec->dev, "enabling jack detect for resume.\n");
rt286_mic_detect(codec, &broadwell_headset); rt286_mic_detect(codec, &broadwell_headset);
break; break;
......
...@@ -292,10 +292,12 @@ static struct snd_soc_dai_link cht_dailink[] = { ...@@ -292,10 +292,12 @@ static struct snd_soc_dai_link cht_dailink[] = {
static int cht_suspend_pre(struct snd_soc_card *card) static int cht_suspend_pre(struct snd_soc_card *card)
{ {
struct snd_soc_codec *codec; struct snd_soc_component *component;
list_for_each_entry(component, &card->component_dev_list, card_list) {
if (!strcmp(component->name, "i2c-10EC5670:00")) {
struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
list_for_each_entry(codec, &card->codec_dev_list, card_list) {
if (!strcmp(codec->component.name, "i2c-10EC5670:00")) {
dev_dbg(codec->dev, "disabling jack detect before going to suspend.\n"); dev_dbg(codec->dev, "disabling jack detect before going to suspend.\n");
rt5670_jack_suspend(codec); rt5670_jack_suspend(codec);
break; break;
...@@ -306,10 +308,12 @@ static int cht_suspend_pre(struct snd_soc_card *card) ...@@ -306,10 +308,12 @@ static int cht_suspend_pre(struct snd_soc_card *card)
static int cht_resume_post(struct snd_soc_card *card) static int cht_resume_post(struct snd_soc_card *card)
{ {
struct snd_soc_codec *codec; struct snd_soc_component *component;
list_for_each_entry(component, &card->component_dev_list, card_list) {
if (!strcmp(component->name, "i2c-10EC5670:00")) {
struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
list_for_each_entry(codec, &card->codec_dev_list, card_list) {
if (!strcmp(codec->component.name, "i2c-10EC5670:00")) {
dev_dbg(codec->dev, "enabling jack detect for resume.\n"); dev_dbg(codec->dev, "enabling jack detect for resume.\n");
rt5670_jack_resume(codec); rt5670_jack_resume(codec);
break; break;
......
...@@ -626,7 +626,7 @@ static void codec2codec_close_delayed_work(struct work_struct *work) ...@@ -626,7 +626,7 @@ static void codec2codec_close_delayed_work(struct work_struct *work)
int snd_soc_suspend(struct device *dev) int snd_soc_suspend(struct device *dev)
{ {
struct snd_soc_card *card = dev_get_drvdata(dev); struct snd_soc_card *card = dev_get_drvdata(dev);
struct snd_soc_codec *codec; struct snd_soc_component *component;
struct snd_soc_pcm_runtime *rtd; struct snd_soc_pcm_runtime *rtd;
int i; int i;
...@@ -702,39 +702,39 @@ int snd_soc_suspend(struct device *dev) ...@@ -702,39 +702,39 @@ int snd_soc_suspend(struct device *dev)
dapm_mark_endpoints_dirty(card); dapm_mark_endpoints_dirty(card);
snd_soc_dapm_sync(&card->dapm); snd_soc_dapm_sync(&card->dapm);
/* suspend all CODECs */ /* suspend all COMPONENTs */
list_for_each_entry(codec, &card->codec_dev_list, card_list) { list_for_each_entry(component, &card->component_dev_list, card_list) {
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
/* If there are paths active then the CODEC will be held with /* If there are paths active then the COMPONENT will be held with
* bias _ON and should not be suspended. */ * bias _ON and should not be suspended. */
if (!codec->suspended) { if (!component->suspended) {
switch (snd_soc_dapm_get_bias_level(dapm)) { switch (snd_soc_dapm_get_bias_level(dapm)) {
case SND_SOC_BIAS_STANDBY: case SND_SOC_BIAS_STANDBY:
/* /*
* If the CODEC is capable of idle * If the COMPONENT is capable of idle
* bias off then being in STANDBY * bias off then being in STANDBY
* means it's doing something, * means it's doing something,
* otherwise fall through. * otherwise fall through.
*/ */
if (dapm->idle_bias_off) { if (dapm->idle_bias_off) {
dev_dbg(codec->dev, dev_dbg(component->dev,
"ASoC: idle_bias_off CODEC on over suspend\n"); "ASoC: idle_bias_off CODEC on over suspend\n");
break; break;
} }
case SND_SOC_BIAS_OFF: case SND_SOC_BIAS_OFF:
if (codec->driver->suspend) if (component->suspend)
codec->driver->suspend(codec); component->suspend(component);
codec->suspended = 1; component->suspended = 1;
if (codec->component.regmap) if (component->regmap)
regcache_mark_dirty(codec->component.regmap); regcache_mark_dirty(component->regmap);
/* deactivate pins to sleep state */ /* deactivate pins to sleep state */
pinctrl_pm_select_sleep_state(codec->dev); pinctrl_pm_select_sleep_state(component->dev);
break; break;
default: default:
dev_dbg(codec->dev, dev_dbg(component->dev,
"ASoC: CODEC is on over suspend\n"); "ASoC: COMPONENT is on over suspend\n");
break; break;
} }
} }
...@@ -768,7 +768,7 @@ static void soc_resume_deferred(struct work_struct *work) ...@@ -768,7 +768,7 @@ static void soc_resume_deferred(struct work_struct *work)
struct snd_soc_card *card = struct snd_soc_card *card =
container_of(work, struct snd_soc_card, deferred_resume_work); container_of(work, struct snd_soc_card, deferred_resume_work);
struct snd_soc_pcm_runtime *rtd; struct snd_soc_pcm_runtime *rtd;
struct snd_soc_codec *codec; struct snd_soc_component *component;
int i; int i;
/* our power state is still SNDRV_CTL_POWER_D3hot from suspend time, /* our power state is still SNDRV_CTL_POWER_D3hot from suspend time,
...@@ -794,11 +794,11 @@ static void soc_resume_deferred(struct work_struct *work) ...@@ -794,11 +794,11 @@ static void soc_resume_deferred(struct work_struct *work)
cpu_dai->driver->resume(cpu_dai); cpu_dai->driver->resume(cpu_dai);
} }
list_for_each_entry(codec, &card->codec_dev_list, card_list) { list_for_each_entry(component, &card->component_dev_list, card_list) {
if (codec->suspended) { if (component->suspended) {
if (codec->driver->resume) if (component->resume)
codec->driver->resume(codec); component->resume(component);
codec->suspended = 0; component->suspended = 0;
} }
} }
...@@ -1072,9 +1072,7 @@ static void soc_remove_component(struct snd_soc_component *component) ...@@ -1072,9 +1072,7 @@ static void soc_remove_component(struct snd_soc_component *component)
if (!component->card) if (!component->card)
return; return;
/* This is a HACK and will be removed soon */ list_del(&component->card_list);
if (component->codec)
list_del(&component->codec->card_list);
if (component->remove) if (component->remove)
component->remove(component); component->remove(component);
...@@ -1443,10 +1441,7 @@ static int soc_probe_component(struct snd_soc_card *card, ...@@ -1443,10 +1441,7 @@ static int soc_probe_component(struct snd_soc_card *card,
component->num_dapm_routes); component->num_dapm_routes);
list_add(&dapm->list, &card->dapm_list); list_add(&dapm->list, &card->dapm_list);
list_add(&component->card_list, &card->component_dev_list);
/* This is a HACK and will be removed soon */
if (component->codec)
list_add(&component->codec->card_list, &card->codec_dev_list);
return 0; return 0;
...@@ -1706,7 +1701,8 @@ static int soc_bind_aux_dev(struct snd_soc_card *card, int num) ...@@ -1706,7 +1701,8 @@ static int soc_bind_aux_dev(struct snd_soc_card *card, int num)
} }
component->init = aux_dev->init; component->init = aux_dev->init;
list_add(&component->list_aux, &card->aux_comp_list); component->auxiliary = 1;
return 0; return 0;
err_defer: err_defer:
...@@ -1722,7 +1718,10 @@ static int soc_probe_aux_devices(struct snd_soc_card *card) ...@@ -1722,7 +1718,10 @@ static int soc_probe_aux_devices(struct snd_soc_card *card)
for (order = SND_SOC_COMP_ORDER_FIRST; order <= SND_SOC_COMP_ORDER_LAST; for (order = SND_SOC_COMP_ORDER_FIRST; order <= SND_SOC_COMP_ORDER_LAST;
order++) { order++) {
list_for_each_entry(comp, &card->aux_comp_list, list_aux) { list_for_each_entry(comp, &card->component_dev_list, card_list) {
if (!comp->auxiliary)
continue;
if (comp->driver->probe_order == order) { if (comp->driver->probe_order == order) {
ret = soc_probe_component(card, comp); ret = soc_probe_component(card, comp);
if (ret < 0) { if (ret < 0) {
...@@ -1746,11 +1745,14 @@ static void soc_remove_aux_devices(struct snd_soc_card *card) ...@@ -1746,11 +1745,14 @@ static void soc_remove_aux_devices(struct snd_soc_card *card)
for (order = SND_SOC_COMP_ORDER_FIRST; order <= SND_SOC_COMP_ORDER_LAST; for (order = SND_SOC_COMP_ORDER_FIRST; order <= SND_SOC_COMP_ORDER_LAST;
order++) { order++) {
list_for_each_entry_safe(comp, _comp, list_for_each_entry_safe(comp, _comp,
&card->aux_comp_list, list_aux) { &card->component_dev_list, card_list) {
if (!comp->auxiliary)
continue;
if (comp->driver->remove_order == order) { if (comp->driver->remove_order == order) {
soc_remove_component(comp); soc_remove_component(comp);
/* remove it from the card's aux_comp_list */ comp->auxiliary = 0;
list_del(&comp->list_aux);
} }
} }
} }
...@@ -2926,6 +2928,8 @@ static int snd_soc_component_initialize(struct snd_soc_component *component, ...@@ -2926,6 +2928,8 @@ static int snd_soc_component_initialize(struct snd_soc_component *component,
component->driver = driver; component->driver = driver;
component->probe = component->driver->probe; component->probe = component->driver->probe;
component->remove = component->driver->remove; component->remove = component->driver->remove;
component->suspend = component->driver->suspend;
component->resume = component->driver->resume;
dapm = &component->dapm; dapm = &component->dapm;
dapm->dev = dev; dapm->dev = dev;
...@@ -3275,6 +3279,20 @@ static void snd_soc_codec_drv_remove(struct snd_soc_component *component) ...@@ -3275,6 +3279,20 @@ static void snd_soc_codec_drv_remove(struct snd_soc_component *component)
codec->driver->remove(codec); codec->driver->remove(codec);
} }
static int snd_soc_codec_drv_suspend(struct snd_soc_component *component)
{
struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
return codec->driver->suspend(codec);
}
static int snd_soc_codec_drv_resume(struct snd_soc_component *component)
{
struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
return codec->driver->resume(codec);
}
static int snd_soc_codec_drv_write(struct snd_soc_component *component, static int snd_soc_codec_drv_write(struct snd_soc_component *component,
unsigned int reg, unsigned int val) unsigned int reg, unsigned int val)
{ {
...@@ -3336,6 +3354,10 @@ int snd_soc_register_codec(struct device *dev, ...@@ -3336,6 +3354,10 @@ int snd_soc_register_codec(struct device *dev,
codec->component.probe = snd_soc_codec_drv_probe; codec->component.probe = snd_soc_codec_drv_probe;
if (codec_drv->remove) if (codec_drv->remove)
codec->component.remove = snd_soc_codec_drv_remove; codec->component.remove = snd_soc_codec_drv_remove;
if (codec_drv->suspend)
codec->component.suspend = snd_soc_codec_drv_suspend;
if (codec_drv->resume)
codec->component.resume = snd_soc_codec_drv_resume;
if (codec_drv->write) if (codec_drv->write)
codec->component.write = snd_soc_codec_drv_write; codec->component.write = snd_soc_codec_drv_write;
if (codec_drv->read) if (codec_drv->read)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment