diff mbox

[v2,3/3] ASoC: tas6424: Allow disabling auto diagnostics for faster power-on

Message ID 1524837349-16350-4-git-send-email-jjhiblot@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jean-Jacques Hiblot April 27, 2018, 1:55 p.m. UTC
The TAS6424 incorporates both DC-load and AC-load diagnostics which are
used to determine the status of the load. The DC diagnostics runs when any
channel is directed to leave the Hi-Z state and enter the MUTE or PLAY
state.
The DC diagnostics are turned on by default but, if a fast startup without
diagnostics is required, the diagnostics can be disabled using a dedicated
ALSA control.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
---
 sound/soc/codecs/tas6424.c | 19 +++++++++++++++++--
 sound/soc/codecs/tas6424.h |  4 ++++
 2 files changed, 21 insertions(+), 2 deletions(-)

Comments

Mark Brown April 27, 2018, 3:30 p.m. UTC | #1
On Fri, Apr 27, 2018 at 03:55:49PM +0200, Jean-Jacques Hiblot wrote:

> +static const char * const diags_enum_texts[] = {"OFF", "ON"};
> +static unsigned int diags_enum_values[] = {1, 0};
> +SOC_VALUE_ENUM_SINGLE_DECL(diags_enum, TAS6424_DC_DIAG_CTRL1,
> +			   TAS6424_LDGBYPASS_SHIFT, TAS6424_LDGBYPASS_MASK,
> +			   diags_enum_texts, diags_enum_values);
> +

This just just an on/off switch so it should be represented as a
standard _SINGLE() control with " Switch" at the end of the name so
userspace knows what to do with it.
kernel test robot April 28, 2018, 9:21 a.m. UTC | #2
Hi Jean-Jacques,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on asoc/for-next]
[also build test WARNING on v4.17-rc2 next-20180426]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Jean-Jacques-Hiblot/ASoc-TAS6424-Add-support-for-mute-standby-and-faster-power-on/20180428-113427
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
reproduce:
        # apt-get install sparse
        make ARCH=x86_64 allmodconfig
        make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

>> sound/soc/codecs/tas6424.c:61:1: sparse: symbol 'diags_enum' was not declared. Should it be static?

Please review and possibly fold the followup patch.

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

diff --git a/sound/soc/codecs/tas6424.c b/sound/soc/codecs/tas6424.c
index 89fd0c1..8eb4842 100644
--- a/sound/soc/codecs/tas6424.c
+++ b/sound/soc/codecs/tas6424.c
@@ -55,6 +55,13 @@  struct tas6424_data {
  */
 static DECLARE_TLV_DB_SCALE(dac_tlv, -10350, 50, 0);
 
+
+static const char * const diags_enum_texts[] = {"OFF", "ON"};
+static unsigned int diags_enum_values[] = {1, 0};
+SOC_VALUE_ENUM_SINGLE_DECL(diags_enum, TAS6424_DC_DIAG_CTRL1,
+			   TAS6424_LDGBYPASS_SHIFT, TAS6424_LDGBYPASS_MASK,
+			   diags_enum_texts, diags_enum_values);
+
 static const struct snd_kcontrol_new tas6424_snd_controls[] = {
 	SOC_SINGLE_TLV("Speaker Driver CH1 Playback Volume",
 		       TAS6424_CH1_VOL_CTRL, 0, 0xff, 0, dac_tlv),
@@ -64,6 +71,7 @@  static const struct snd_kcontrol_new tas6424_snd_controls[] = {
 		       TAS6424_CH3_VOL_CTRL, 0, 0xff, 0, dac_tlv),
 	SOC_SINGLE_TLV("Speaker Driver CH4 Playback Volume",
 		       TAS6424_CH4_VOL_CTRL, 0, 0xff, 0, dac_tlv),
+	SOC_ENUM("Auto Diagnostics", diags_enum),
 };
 
 static int tas6424_dac_event(struct snd_soc_dapm_widget *w,
@@ -297,6 +305,11 @@  static int tas6424_power_on(struct snd_soc_component *component)
 	struct tas6424_data *tas6424 = snd_soc_component_get_drvdata(component);
 	int ret;
 	u8 chan_states;
+	int no_auto_diags = 0;
+	unsigned int reg_val;
+
+	if (!regmap_read(tas6424->regmap, TAS6424_DC_DIAG_CTRL1, &reg_val))
+		no_auto_diags = reg_val & TAS6424_LDGBYPASS_MASK;
 
 	ret = regulator_bulk_enable(ARRAY_SIZE(tas6424->supplies),
 				    tas6424->supplies);
@@ -327,9 +340,11 @@  static int tas6424_power_on(struct snd_soc_component *component)
 	snd_soc_component_write(component, TAS6424_CH_STATE_CTRL, chan_states);
 
 	/* any time we come out of HIZ, the output channels automatically run DC
-	 * load diagnostics, wait here until this completes
+	 * load diagnostics if autodiagnotics are enabled. wait here until this
+	 * completes.
 	 */
-	msleep(230);
+	if (!no_auto_diags)
+		msleep(230);
 
 	return 0;
 }
diff --git a/sound/soc/codecs/tas6424.h b/sound/soc/codecs/tas6424.h
index 4305883..b5958c4 100644
--- a/sound/soc/codecs/tas6424.h
+++ b/sound/soc/codecs/tas6424.h
@@ -111,6 +111,10 @@ 
 					 TAS6424_CH3_STATE_DIAG | \
 					 TAS6424_CH4_STATE_DIAG)
 
+/* TAS6424_DC_DIAG_CTRL1 */
+#define TAS6424_LDGBYPASS_SHIFT		0
+#define TAS6424_LDGBYPASS_MASK		BIT(TAS6424_LDGBYPASS_SHIFT)
+
 /* TAS6424_GLOB_FAULT1_REG */
 #define TAS6424_FAULT_CLOCK		BIT(4)
 #define TAS6424_FAULT_PVDD_OV		BIT(3)