@@ -3626,52 +3626,108 @@ int snd_soc_dapm_info_pin_switch(struct snd_kcontrol *kcontrol,
36263626}
36273627EXPORT_SYMBOL_GPL (snd_soc_dapm_info_pin_switch );
36283628
3629+ static int __snd_soc_dapm_get_pin_switch (struct snd_soc_dapm_context * dapm ,
3630+ const char * pin ,
3631+ struct snd_ctl_elem_value * ucontrol )
3632+ {
3633+ snd_soc_dapm_mutex_lock (dapm );
3634+ ucontrol -> value .integer .value [0 ] = snd_soc_dapm_get_pin_status (dapm , pin );
3635+ snd_soc_dapm_mutex_unlock (dapm );
3636+
3637+ return 0 ;
3638+ }
3639+
36293640/**
36303641 * snd_soc_dapm_get_pin_switch - Get information for a pin switch
36313642 *
36323643 * @kcontrol: mixer control
36333644 * @ucontrol: Value
3645+ *
3646+ * Callback to provide information for a pin switch added at the card
3647+ * level.
36343648 */
36353649int snd_soc_dapm_get_pin_switch (struct snd_kcontrol * kcontrol ,
36363650 struct snd_ctl_elem_value * ucontrol )
36373651{
36383652 struct snd_soc_card * card = snd_kcontrol_chip (kcontrol );
36393653 const char * pin = (const char * )kcontrol -> private_value ;
36403654
3641- snd_soc_dapm_mutex_lock (card );
3655+ return __snd_soc_dapm_get_pin_switch (& card -> dapm , pin , ucontrol );
3656+ }
3657+ EXPORT_SYMBOL_GPL (snd_soc_dapm_get_pin_switch );
36423658
3643- ucontrol -> value .integer .value [0 ] =
3644- snd_soc_dapm_get_pin_status (& card -> dapm , pin );
3659+ /**
3660+ * snd_soc_dapm_get_component_pin_switch - Get information for a pin switch
3661+ *
3662+ * @kcontrol: mixer control
3663+ * @ucontrol: Value
3664+ *
3665+ * Callback to provide information for a pin switch added at the component
3666+ * level.
3667+ */
3668+ int snd_soc_dapm_get_component_pin_switch (struct snd_kcontrol * kcontrol ,
3669+ struct snd_ctl_elem_value * ucontrol )
3670+ {
3671+ struct snd_soc_component * component = snd_kcontrol_chip (kcontrol );
3672+ const char * pin = (const char * )kcontrol -> private_value ;
36453673
3646- snd_soc_dapm_mutex_unlock (card );
3674+ return __snd_soc_dapm_get_pin_switch (& component -> dapm , pin , ucontrol );
3675+ }
3676+ EXPORT_SYMBOL_GPL (snd_soc_dapm_get_component_pin_switch );
36473677
3648- return 0 ;
3678+ static int __snd_soc_dapm_put_pin_switch (struct snd_soc_dapm_context * dapm ,
3679+ const char * pin ,
3680+ struct snd_ctl_elem_value * ucontrol )
3681+ {
3682+ int ret ;
3683+
3684+ snd_soc_dapm_mutex_lock (dapm );
3685+ ret = __snd_soc_dapm_set_pin (dapm , pin , !!ucontrol -> value .integer .value [0 ]);
3686+ snd_soc_dapm_mutex_unlock (dapm );
3687+
3688+ snd_soc_dapm_sync (dapm );
3689+
3690+ return ret ;
36493691}
3650- EXPORT_SYMBOL_GPL (snd_soc_dapm_get_pin_switch );
36513692
36523693/**
36533694 * snd_soc_dapm_put_pin_switch - Set information for a pin switch
36543695 *
36553696 * @kcontrol: mixer control
36563697 * @ucontrol: Value
3698+ *
3699+ * Callback to provide information for a pin switch added at the card
3700+ * level.
36573701 */
36583702int snd_soc_dapm_put_pin_switch (struct snd_kcontrol * kcontrol ,
36593703 struct snd_ctl_elem_value * ucontrol )
36603704{
36613705 struct snd_soc_card * card = snd_kcontrol_chip (kcontrol );
36623706 const char * pin = (const char * )kcontrol -> private_value ;
3663- int ret ;
3664-
3665- snd_soc_dapm_mutex_lock (card );
3666- ret = __snd_soc_dapm_set_pin (& card -> dapm , pin ,
3667- !!ucontrol -> value .integer .value [0 ]);
3668- snd_soc_dapm_mutex_unlock (card );
36693707
3670- snd_soc_dapm_sync (& card -> dapm );
3671- return ret ;
3708+ return __snd_soc_dapm_put_pin_switch (& card -> dapm , pin , ucontrol );
36723709}
36733710EXPORT_SYMBOL_GPL (snd_soc_dapm_put_pin_switch );
36743711
3712+ /**
3713+ * snd_soc_dapm_put_component_pin_switch - Set information for a pin switch
3714+ *
3715+ * @kcontrol: mixer control
3716+ * @ucontrol: Value
3717+ *
3718+ * Callback to provide information for a pin switch added at the component
3719+ * level.
3720+ */
3721+ int snd_soc_dapm_put_component_pin_switch (struct snd_kcontrol * kcontrol ,
3722+ struct snd_ctl_elem_value * ucontrol )
3723+ {
3724+ struct snd_soc_component * component = snd_kcontrol_chip (kcontrol );
3725+ const char * pin = (const char * )kcontrol -> private_value ;
3726+
3727+ return __snd_soc_dapm_put_pin_switch (& component -> dapm , pin , ucontrol );
3728+ }
3729+ EXPORT_SYMBOL_GPL (snd_soc_dapm_put_component_pin_switch );
3730+
36753731struct snd_soc_dapm_widget *
36763732snd_soc_dapm_new_control_unlocked (struct snd_soc_dapm_context * dapm ,
36773733 const struct snd_soc_dapm_widget * widget )
0 commit comments