···444444struct snd_soc_dapm_context *snd_soc_dapm_kcontrol_dapm(445445 struct snd_kcontrol *kcontrol);446446447447+int snd_soc_dapm_force_bias_level(struct snd_soc_dapm_context *dapm,448448+ enum snd_soc_bias_level level);449449+447450/* dapm widget types */448451enum snd_soc_dapm_type {449452 snd_soc_dapm_input = 0, /* input pin */···625622 int path_checks;626623 int neighbour_checks;627624};625625+626626+/**627627+ * snd_soc_dapm_init_bias_level() - Initialize DAPM bias level628628+ * @dapm: The DAPM context to initialize629629+ * @level: The DAPM level to initialize to630630+ *631631+ * This function only sets the driver internal state of the DAPM level and will632632+ * not modify the state of the device. Hence it should not be used during normal633633+ * operation, but only to synchronize the internal state to the device state.634634+ * E.g. during driver probe to set the DAPM level to the one corresponding with635635+ * the power-on reset state of the device.636636+ *637637+ * To change the DAPM state of the device use snd_soc_dapm_set_bias_level().638638+ */639639+static inline void snd_soc_dapm_init_bias_level(640640+ struct snd_soc_dapm_context *dapm, enum snd_soc_bias_level level)641641+{642642+ dapm->bias_level = level;643643+}644644+645645+/**646646+ * snd_soc_dapm_get_bias_level() - Get current DAPM bias level647647+ * @dapm: The context for which to get the bias level648648+ *649649+ * Returns: The current bias level of the passed DAPM context.650650+ */651651+static inline enum snd_soc_bias_level snd_soc_dapm_get_bias_level(652652+ struct snd_soc_dapm_context *dapm)653653+{654654+ return dapm->bias_level;655655+}628656629657#endif
+53-1
include/sound/soc.h
···807807 /* component */808808 struct snd_soc_component component;809809810810- /* dapm */810810+ /* Don't access this directly, use snd_soc_codec_get_dapm() */811811 struct snd_soc_dapm_context dapm;812812813813#ifdef CONFIG_DEBUG_FS···12671267 struct snd_soc_component *component)12681268{12691269 return component->dapm_ptr;12701270+}12711271+12721272+/**12731273+ * snd_soc_codec_get_dapm() - Returns the DAPM context for the CODEC12741274+ * @codec: The CODEC for which to get the DAPM context12751275+ *12761276+ * Note: Use this function instead of directly accessing the CODEC's dapm field12771277+ */12781278+static inline struct snd_soc_dapm_context *snd_soc_codec_get_dapm(12791279+ struct snd_soc_codec *codec)12801280+{12811281+ return &codec->dapm;12821282+}12831283+12841284+/**12851285+ * snd_soc_dapm_init_bias_level() - Initialize CODEC DAPM bias level12861286+ * @dapm: The CODEC for which to initialize the DAPM bias level12871287+ * @level: The DAPM level to initialize to12881288+ *12891289+ * Initializes the CODEC DAPM bias level. See snd_soc_dapm_init_bias_level().12901290+ */12911291+static inline void snd_soc_codec_init_bias_level(struct snd_soc_codec *codec,12921292+ enum snd_soc_bias_level level)12931293+{12941294+ snd_soc_dapm_init_bias_level(snd_soc_codec_get_dapm(codec), level);12951295+}12961296+12971297+/**12981298+ * snd_soc_dapm_get_bias_level() - Get current CODEC DAPM bias level12991299+ * @codec: The CODEC for which to get the DAPM bias level13001300+ *13011301+ * Returns: The current DAPM bias level of the CODEC.13021302+ */13031303+static inline enum snd_soc_bias_level snd_soc_codec_get_bias_level(13041304+ struct snd_soc_codec *codec)13051305+{13061306+ return snd_soc_dapm_get_bias_level(snd_soc_codec_get_dapm(codec));13071307+}13081308+13091309+/**13101310+ * snd_soc_codec_force_bias_level() - Set the CODEC DAPM bias level13111311+ * @codec: The CODEC for which to set the level13121312+ * @level: The level to set to13131313+ *13141314+ * Forces the CODEC bias level to a specific state. See13151315+ * snd_soc_dapm_force_bias_level().13161316+ */13171317+static inline int snd_soc_codec_force_bias_level(struct snd_soc_codec *codec,13181318+ enum snd_soc_bias_level level)13191319+{13201320+ return snd_soc_dapm_force_bias_level(snd_soc_codec_get_dapm(codec),13211321+ level);12701322}1271132312721324/**
···854854 sta32x->supplies);855855 break;856856 }857857- codec->dapm.bias_level = level;858857 return 0;859858}860859···969970 if (sta32x->pdata->needs_esd_watchdog)970971 INIT_DELAYED_WORK(&sta32x->watchdog_work, sta32x_watchdog);971972972972- sta32x_set_bias_level(codec, SND_SOC_BIAS_STANDBY);973973+ snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY);973974 /* Bias level configuration will have done an extra enable */974975 regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies);975976
+1-2
sound/soc/codecs/sta350.c
···890890 sta350->supplies);891891 break;892892 }893893- codec->dapm.bias_level = level;894893 return 0;895894}896895···10361037 sta350->coef_shadow[60] = 0x400000;10371038 sta350->coef_shadow[61] = 0x400000;1038103910391039- sta350_set_bias_level(codec, SND_SOC_BIAS_STANDBY);10401040+ snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY);10401041 /* Bias level configuration will have done an extra enable */10411042 regulator_bulk_disable(ARRAY_SIZE(sta350->supplies), sta350->supplies);10421043
-6
sound/soc/codecs/sta529.c
···179179 break;180180 }181181182182- /*183183- * store the label for powers down audio subsystem for suspend.This is184184- * used by soc core layer185185- */186186- codec->dapm.bias_level = level;187187-188182 return 0;189183190184}
···526526}527527528528/**529529+ * snd_soc_dapm_force_bias_level() - Sets the DAPM bias level530530+ * @dapm: The DAPM context for which to set the level531531+ * @level: The level to set532532+ *533533+ * Forces the DAPM bias level to a specific state. It will call the bias level534534+ * callback of DAPM context with the specified level. This will even happen if535535+ * the context is already at the same level. Furthermore it will not go through536536+ * the normal bias level sequencing, meaning any intermediate states between the537537+ * current and the target state will not be entered.538538+ *539539+ * Note that the change in bias level is only temporary and the next time540540+ * snd_soc_dapm_sync() is called the state will be set to the level as541541+ * determined by the DAPM core. The function is mainly intended to be used to542542+ * used during probe or resume from suspend to power up the device so543543+ * initialization can be done, before the DAPM core takes over.544544+ */545545+int snd_soc_dapm_force_bias_level(struct snd_soc_dapm_context *dapm,546546+ enum snd_soc_bias_level level)547547+{548548+ int ret = 0;549549+550550+ if (dapm->set_bias_level)551551+ ret = dapm->set_bias_level(dapm, level);552552+553553+ if (ret == 0)554554+ dapm->bias_level = level;555555+556556+ return ret;557557+}558558+EXPORT_SYMBOL_GPL(snd_soc_dapm_force_bias_level);559559+560560+/**529561 * snd_soc_dapm_set_bias_level - set the bias level for the system530562 * @dapm: DAPM context531563 * @level: level to configure···579547 if (ret != 0)580548 goto out;581549582582- if (dapm->set_bias_level)583583- ret = dapm->set_bias_level(dapm, level);584584- else if (!card || dapm != &card->dapm)585585- dapm->bias_level = level;550550+ if (!card || dapm != &card->dapm)551551+ ret = snd_soc_dapm_force_bias_level(dapm, level);586552587553 if (ret != 0)588554 goto out;