Skip to contentSkip to conversation

ASoC: dapm: add kcontrol to switch regulator to regulated/bypass state

PATCH In review Nikesh Oswal 3 participants 3 messages Sep 8, 2015 – Sep 10, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: dapm: add kcontrol to switch regulator to regulated/bypass state

When regulator is defined with SND_SOC_DAPM_REGULATOR_CONTROL_BYPASS flag, then a kcontrol will be created which can be used to switch regulator to regulated/bypass state. This will help to control the behaviour of the regulator based on a usecase. For example voice call may need a regulated voltage to acheive higher quality whereas voice trigger may need bypass voltage so as to save on power.

---
 include/sound/soc-dapm.h |    7 +-
 sound/soc/soc-dapm.c     |  177 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 183 insertions(+), 1 deletion(-)
include/sound/soc-dapm.h +6 -1
index 15717b4..778b847 100644
@@ -343,7 +343,12 @@ struct device;
 	(e & (SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD))
 
 /* regulator widget flags */
-#define SND_SOC_DAPM_REGULATOR_BYPASS     0x1     /* bypass when disabled */
+/* bypass when disabled and regulated when enabled */
+#define SND_SOC_DAPM_REGULATOR_BYPASS		0x1
+/* bypass when disabled and regulated when enable by default and a
+   kcontrol is created to explicitly switch between bypass/regulated */
+#define SND_SOC_DAPM_REGULATOR_CONTROL_BYPASS \
+	(SND_SOC_DAPM_REGULATOR_BYPASS | 0x2)
 
 struct snd_soc_dapm_widget;
 enum snd_soc_dapm_type;
sound/soc/soc-dapm.c +177 -0

189 lines not on this page · raw message

Signature · 1 line
1.7.9.5
maintainer
#1 lore raw
Quoted 6 lines · Nikesh Oswal

When regulator is defined with SND_SOC_DAPM_REGULATOR_CONTROL_BYPASS flag, then a kcontrol will be created which can be used to switch regulator to regulated/bypass state. This will help to control the behaviour of the regulator based on a usecase. For example voice call may need a regulated voltage to acheive higher quality whereas voice trigger may need bypass voltage so as to save on power.

This is really not a good idea, moving a regulator from regulated to bypass without coordination with the driver is a recipie for bugs at best and physical damage at worst. It's something that should be being done by the device driver based on the current state of the device, the general model is that we always drive to the lowest power state possible based on what the device is currently doing. If the device is set up to do something that can use an unregulated supply then it should put the supply into bypass mode without any help from userspace.

As I think we went through the last time you submitted code to the core it is very important that we have coherent and safe abstractions that result in code which does what it says. The code in the core has to work coherently for everyone, just randomly punching holes through abstractions for system specific hacks from userspace is not going to do that.

#2 lore raw

Hi Mark,

Thanks for your response. The problem we had is the dapm is holding an instance of the regulator and we wanted to control that instance based on use-case. But I understand your point that we should not be exposing regulators to userspace but manage it in the driver itself..will have a re-think

Thanks,
Nikesh

Quoted 22 lines · Mark Brown
Quoted 6 lines · Nikesh Oswal

When regulator is defined with SND_SOC_DAPM_REGULATOR_CONTROL_BYPASS flag, then a kcontrol will be created which can be used to switch regulator to regulated/bypass state. This will help to control the behaviour of the regulator based on a usecase. For example voice call may need a regulated voltage to acheive higher quality whereas voice trigger may need bypass voltage so as to save on power.

This is really not a good idea, moving a regulator from regulated to bypass without coordination with the driver is a recipie for bugs at best and physical damage at worst. It's something that should be being done by the device driver based on the current state of the device, the general model is that we always drive to the lowest power state possible based on what the device is currently doing. If the device is set up to do something that can use an unregulated supply then it should put the supply into bypass mode without any help from userspace.

As I think we went through the last time you submitted code to the core it is very important that we have coherent and safe abstractions that result in code which does what it says. The code in the core has to work coherently for everyone, just randomly punching holes through abstractions for system specific hacks from userspace is not going to do that.