Skip to contentSkip to conversation

ASoC: sma1303: Add driver for Iron Device SMA1303 Amp

PATCH In review Kiseok Jo 2 participants 10 messages Jan 9, 2023 – Jan 26, 2023

Subsystems (4)
lore
Share & tools
lore

Kiseok Jo

author maintainer
#0 lore raw

PATCH v2 1/2 ASoC: sma1303: Add driver for Iron Device SMA1303 Amp

The Iron Device SMA1303 is a boosted Class-D audio amplifier.

---
v2: Modified to match kernel coding style.

---
 sound/soc/codecs/Kconfig   |    7 +
 sound/soc/codecs/Makefile  |    2 +
 sound/soc/codecs/sma1303.c | 1746 ++++++++++++++++++++++++++++++++++++
 sound/soc/codecs/sma1303.h |  616 +++++++++++++
 4 files changed, 2371 insertions(+)
 create mode 100644 sound/soc/codecs/sma1303.c
 create mode 100644 sound/soc/codecs/sma1303.h
sound/soc/codecs/Kconfig +7 -0
index 0f9d71490075..83d2981a400e 100644
@@ -206,6 +206,7 @@ config SND_SOC_ALL_CODECS
 	imply SND_SOC_SI476X
 	imply SND_SOC_SIMPLE_AMPLIFIER
 	imply SND_SOC_SIMPLE_MUX
+	imply SND_SOC_SMA1303
 	imply SND_SOC_SPDIF
 	imply SND_SOC_SRC4XXX_I2C
 	imply SND_SOC_SSM2305
@@ -1492,6 +1493,12 @@ config SND_SOC_SIMPLE_MUX
 	tristate "Simple Audio Mux"
 	depends on GPIOLIB
 
+config SND_SOC_SMA1303
+	tristate "Iron Device SMA1303 Audio Amplifier"
+	depends on I2C
+	help
+	  Enable support for Iron Device SMA1303 Boosted Class-D amplifier
+
 config SND_SOC_SPDIF
 	tristate "S/PDIF CODEC"
 
sound/soc/codecs/Makefile +2 -0
index 71d3ce5867e4..89ffd06e9290 100644
@@ -233,6 +233,7 @@ snd-soc-sigmadsp-objs := sigmadsp.o
 snd-soc-sigmadsp-i2c-objs := sigmadsp-i2c.o
 snd-soc-sigmadsp-regmap-objs := sigmadsp-regmap.o
 snd-soc-si476x-objs := si476x.o
+snd-soc-sma1303-objs := sma1303.o
 snd-soc-spdif-tx-objs := spdif_transmitter.o
 snd-soc-spdif-rx-objs := spdif_receiver.o
 snd-soc-src4xxx-objs := src4xxx.o
@@ -588,6 +589,7 @@ obj-$(CONFIG_SND_SOC_SIGMADSP)	+= snd-soc-sigmadsp.o
 obj-$(CONFIG_SND_SOC_SIGMADSP_I2C)	+= snd-soc-sigmadsp-i2c.o
 obj-$(CONFIG_SND_SOC_SIGMADSP_REGMAP)	+= snd-soc-sigmadsp-regmap.o
 obj-$(CONFIG_SND_SOC_SI476X)	+= snd-soc-si476x.o
+obj-$(CONFIG_SND_SOC_SMA1303)	+= snd-soc-sma1303.o
 obj-$(CONFIG_SND_SOC_SPDIF)	+= snd-soc-spdif-rx.o snd-soc-spdif-tx.o
 obj-$(CONFIG_SND_SOC_SRC4XXX)	+= snd-soc-src4xxx.o
 obj-$(CONFIG_SND_SOC_SRC4XXX_I2C)	+= snd-soc-src4xxx-i2c.o
sound/soc/codecs/sma1303.c new file +1746 -0

1,746 lines not on this page · raw message

sound/soc/codecs/sma1303.h new file +616 -0

616 lines not on this page · raw message

Signature · 1 line
2.30.2
author maintainer
#1 lore raw

PATCH v2 2/2 ASoC: dt-bindings: sma1303: Iron Device SMA1303 Amp

Modified the schema binding and added the vendor prefixes.

---
 .../bindings/sound/irondevice,sma1303.yaml    | 40 +++++++++++++++++++
 .../devicetree/bindings/vendor-prefixes.yaml  |  2 +
 2 files changed, 42 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/irondevice,sma1303.yaml
Documentation/devicetree/bindings/sound/irondevice,sma1303.yaml new file +40 -0
new file mode 100644
index 000000000000..8c3b85f962ff
@@ -0,0 +1,40 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/irondevice,sma1303.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Iron Device SMA1303 Audio Amplifier
+
+maintainers:
+  - Kiseok Jo <[email protected]>
+
+description:
+  SMA1303 digital class-D audio amplifier with an integrated boost converter.
+
+allOf:
+  - $ref: name-prefix.yaml#
+
+properties:
+  compatible:
+    const: irondevice,sma1303
+
+  reg:
+    description:
+      I2C address of the amplifier. See the datasheet for possible values.
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: true
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    i2c_bus {
+		sma1303_amp: sma1303@1e {
+			compatible = "irondevice,sma1303";
+			reg = <0x1e>;
+		};
+	};
\ No newline at end of file
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
index 70ffb3780621..271ff119764a 100644
@@ -635,6 +635,8 @@ patternProperties:
     description: Inverse Path
   "^iom,.*":
     description: Iomega Corporation
+  "^irondevice,.*":
+    description: Iron Device Corporation
   "^isee,.*":
     description: ISEE 2007 S.L.
   "^isil,.*":
Signature · 1 line
2.30.2
maintainer
#2 lore raw

Re: [PATCH v2 2/2] ASoC: dt-bindings: sma1303: Iron Device SMA1303 Amp

Documentation/devicetree/bindings/sound/irondevice,sma1303.yaml line 25

Quoted 8 lines · Kiseok Jo
Documentation/devicetree/bindings/sound/irondevice,sma1303.yaml new file +8 -0
+properties:
+  compatible:
+    const: irondevice,sma1303
+
+  reg:
+    description:
+      I2C address of the amplifier. See the datasheet for possible values.
+

This doesn't document the DT properties that the driver parses.

maintainer
#3 lore raw
In reply to Kiseok Jo
Quoted 1 line · Kiseok Jo

The Iron Device SMA1303 is a boosted Class-D audio amplifier.

This looks pretty good now, there's some things that need fixing below but nothing too huge.

sound/soc/codecs/sma1303.c line 190

Quoted 5 lines
sound/soc/codecs/sma1303.c new file +5 -0
+		result = true;
+		break;
+	default:
+		result = false;
+	}

Please put the break statements in for all cases, even the last one.

sound/soc/codecs/sma1303.c line 245

Quoted 6 lines
sound/soc/codecs/sma1303.c new file +6 -0
+void sma1303_set_callback_func(struct callback_ops ops)
+{
+	if (ops.set_i2c_err)
+		gCallback.set_i2c_err = ops.set_i2c_err;
+}
+EXPORT_SYMBOL(sma1303_set_callback_func);

ASoC symbols should be _GPL, and variables shouldn't use hungarian notation, but in any case this callback looks very questionable - why is it needed? Looking at the uses...

Quoted 7 lines
sound/soc/codecs/sma1303.c new file +7 -0
+static int sma1303_regmap_write(struct sma1303_priv *sma1303,
+				unsigned int reg, unsigned int val)
+{
+	int ret = 0;
+	int cnt = sma1303->retry_cnt;
+
+	while (cnt--) {

sound/soc/codecs/sma1303.c line 263

Quoted 10 lines
sound/soc/codecs/sma1303.c new file +10 -0
+		ret = regmap_write(sma1303->regmap, reg, val);
+		if (ret < 0) {
+			dev_err(sma1303->dev,
+					"Failed to write [0x%02X]\n", reg);
+			if (gCallback.set_i2c_err)
+				gCallback.set_i2c_err(sma1303->dev, ret);
+		} else
+			break;
+	}
+	return ret;

...this isn't something we do in other drivers, not just the callback but the whole retry mechanism. Is it really the device itself that's this unstable, the callback suggests it might be the board? It feels like if this is needed it'd fit better in regmap rather than wrapping things in the driver.

sound/soc/codecs/sma1303.c line 326

Quoted 10 lines
sound/soc/codecs/sma1303.c new file +10 -0
+static int sma1303_force_mute_get(struct snd_kcontrol *kcontrol,
+				struct snd_ctl_elem_value *ucontrol)
+{
+	struct snd_soc_component *component =
+		snd_soc_kcontrol_component(kcontrol);
+	struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component);
+
+	ucontrol->value.integer.value[0] = (int)sma1303->force_mute_status;
+	dev_info(sma1303->dev, "%s : Force Mute %s\n", __func__,
+			sma1303->force_mute_status ? "ON" : "OFF");

If you must add logging use dev_dbg() to avoid spamming the console, same for most of the other logging at dev_info().

sound/soc/codecs/sma1303.c line 343

Quoted 13 lines
sound/soc/codecs/sma1303.c new file +13 -0
+static int sma1303_force_mute_put(struct snd_kcontrol *kcontrol,
+				struct snd_ctl_elem_value *ucontrol)
+{
+	struct snd_soc_component *component =
+		snd_soc_kcontrol_component(kcontrol);
+	struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component);
+
+	sma1303->force_mute_status = (bool)ucontrol->value.integer.value[0];
+	dev_info(sma1303->dev, "%s : Force Mute %s\n", __func__,
+			sma1303->force_mute_status ? "ON" : "OFF");
+
+	return 0;
+}

This (and the other controls) should return 1 if the value changed so events are generated, the mixer-test selftest will spot this and other errors for you.

sound/soc/codecs/sma1303.c line 357

Quoted 13 lines
sound/soc/codecs/sma1303.c new file +13 -0
+static int sma1303_postscaler_get(struct snd_kcontrol *kcontrol,
+				struct snd_ctl_elem_value *ucontrol)
+{
+	struct snd_soc_component *component =
+		snd_soc_kcontrol_component(kcontrol);
+	struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component);
+	int val, ret;
+
+	ret = sma1303_regmap_read(sma1303, SMA1303_90_POSTSCALER, &val);
+	ucontrol->value.integer.value[0] = (val & 0x7E) >> 1;
+
+	return ret;
+}

Here we get with a mask of 0x7e...

sound/soc/codecs/sma1303.c line 368

Quoted 10 lines
sound/soc/codecs/sma1303.c new file +10 -0
+static int sma1303_postscaler_put(struct snd_kcontrol *kcontrol,
+				struct snd_ctl_elem_value *ucontrol)
+{
+	struct snd_soc_component *component =
+		snd_soc_kcontrol_component(kcontrol);
+	struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component);
+	int ret, sel = (int)ucontrol->value.integer.value[0];
+
+	ret = sma1303_regmap_update_bits(sma1303,
+			SMA1303_90_POSTSCALER, 0x70, (sel << 1));

...but put with a mask of 0x70. What's going on with lower bits there?

sound/soc/codecs/sma1303.c line 431

Quoted 10 lines
sound/soc/codecs/sma1303.c new file +10 -0
+	if (!(sma1303->amp_power_status)) {
+		dev_info(component->dev, "%s : %s\n",
+			__func__, "Already AMP Shutdown");
+		return ret;
+	}
+
+	cancel_delayed_work_sync(&sma1303->check_fault_work);
+
+	msleep(55);
+

That sleep looks odd - what are we delaying after?

Quoted 12 lines
sound/soc/codecs/sma1303.c new file +12 -0
+static int sma1303_power_event(struct snd_soc_dapm_widget *w,
+		struct snd_kcontrol *kcontrol, int event)
+{
+	struct snd_soc_component *component =
+		snd_soc_dapm_to_component(w->dapm);
+	struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component);
+	int ret = 0;
+
+	switch (event) {
+	case SND_SOC_DAPM_POST_PMU:
+		dev_info(sma1303->dev,
+			"%s : SND_SOC_DAPM_POST_PMU\n", __func__);

sound/soc/codecs/sma1303.c line 681

Quoted 10 lines
sound/soc/codecs/sma1303.c new file +10 -0
+		ret = sma1303_startup(component);
+		break;
+	case SND_SOC_DAPM_PRE_PMD:
+		dev_info(sma1303->dev,
+			"%s : SND_SOC_DAPM_PRE_PMD\n", __func__);
+		ret = sma1303_shutdown(component);
+		break;
+	}
+	return ret;
+}

If this is done using DAPM then it's a bit concerning that you need the amp_enabled checks in your startup() and shutdown() functions, DAPM should refcount appropriately. TBH I'd just inline those functions, they are small and only called from here. I'd also rename this to have something about it being for the speaker/amplifier in the function name, it looked like it was a whole CODEC thing.

sound/soc/codecs/sma1303.c line 698

Quoted 2 lines
sound/soc/codecs/sma1303.c new file +2 -0
+	SOC_SINGLE_BOOL_EXT("Force Mute", 0,
+		sma1303_force_mute_get, sma1303_force_mute_put),

Simple on/off controls should have Switch at the end of the name - mixer-test will spot that one too.

sound/soc/codecs/sma1303.c line 782

Quoted 6 lines
sound/soc/codecs/sma1303.c new file +6 -0
+	for (index = 0; index < ARRAY_SIZE(sma1303_snd_controls); index++) {
+		sma1303_controls[index] = sma1303_snd_controls[index];
+		name[index] = devm_kzalloc(sma1303->dev,
+				MAX_CONTROL_NAME, GFP_KERNEL);
+		size = strlen(sma1303_snd_controls[index].name)
+			+ strlen(sma1303->dev->driver->name);

No need to add the driver name or anything here, the core has support for allowing boards to add prefixes to all the control names if there's a need to avoid naming clashes which allows things to be more user friendly and supports more than one of a given device on a board. See name_prefix.

Quoted 25 lines
sound/soc/codecs/sma1303.c new file +25 -0
+static int sma1303_dai_mute(struct snd_soc_dai *dai, int mute, int stream)
+{
+	struct snd_soc_component *component = dai->component;
+	struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component);
+	int ret = 0;
+
+	if (stream == SNDRV_PCM_STREAM_CAPTURE)
+		return ret;
+
+	if (!(sma1303->amp_power_status)) {
+		dev_info(component->dev, "%s : %s\n",
+			__func__, "Already AMP Shutdown");
+		return ret;
+	}
+
+	if (mute) {
+		dev_info(component->dev, "%s : %s\n", __func__, "MUTE");
+
+		ret += sma1303_regmap_update_bits(sma1303,
+				SMA1303_0E_MUTE_VOL_CTRL,
+				SMA1303_SPK_MUTE_MASK,
+				SMA1303_SPK_MUTE);
+	} else {
+		if (!sma1303->force_mute_status) {
+			dev_info(component->dev, "%s : %s\n",

sound/soc/codecs/sma1303.c line 1087

Quoted 10 lines
sound/soc/codecs/sma1303.c new file +10 -0
+					__func__, "UNMUTE");
+			ret += sma1303_regmap_update_bits(sma1303,
+					SMA1303_0E_MUTE_VOL_CTRL,
+					SMA1303_SPK_MUTE_MASK,
+					SMA1303_SPK_UNMUTE);
+		} else {
+			dev_info(sma1303->dev,
+					"%s : FORCE MUTE!!!\n", __func__);
+		}
+	}

If you need to shut the device down to implement mute then it's better to just not implement it, you shouldn't emulate features in the driver but instead let the core worry about how to handle that case. AFAICT this is why there's the startup/shutdown thing for the speaker amp?

sound/soc/codecs/sma1303.c line 1101

Quoted 1 line
sound/soc/codecs/sma1303.c new file +1 -0
+	case SND_SOC_DAIFMT_CBS_CFS:

Use the modern names _CBC_CFC

sound/soc/codecs/sma1303.c line 1110

Quoted 1 line
sound/soc/codecs/sma1303.c new file +1 -0
+	case SND_SOC_DAIFMT_CBM_CFM:

and _CBP_CFP instead, we're trying to phase out the old defines.

sound/soc/codecs/sma1303.c line 1306

Quoted 9 lines
sound/soc/codecs/sma1303.c new file +9 -0
+static void sma1303_check_fault_worker(struct work_struct *work)
+{
+	struct sma1303_priv *sma1303 =
+		container_of(work, struct sma1303_priv, check_fault_work.work);
+	int ret = 0;
+	unsigned int over_temp, ocp_val, uvlo_val;
+
+	mutex_lock(&sma1303->lock);
+

It looks like this mutex is only taken in this function, is it needed?

sound/soc/codecs/sma1303.c line 1426

Quoted 13 lines
sound/soc/codecs/sma1303.c new file +13 -0
+static int sma1303_probe(struct snd_soc_component *component)
+{
+	struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component);
+	struct snd_soc_dapm_context *dapm =
+		snd_soc_component_get_dapm(component);
+	int ret = 0;
+
+	ret += sma1303_add_component_controls(component);
+
+	snd_soc_dapm_sync(dapm);
+
+	ret += sma1303_regmap_write(sma1303,
+			SMA1303_0A_SPK_VOL, sma1303->init_vol);

Just use the hardware defaults for the registers, let userspace set what it needs to.

sound/soc/codecs/sma1303.c line 1471

Quoted 8 lines
sound/soc/codecs/sma1303.c new file +8 -0
+static ssize_t check_fault_period_show(struct device *dev,
+	struct device_attribute *devattr, char *buf)
+{
+	struct sma1303_priv *sma1303 = dev_get_drvdata(dev);
+	int rc;
+
+	rc = (int)snprintf(buf, PAGE_SIZE,
+			"%ld\n", sma1303->check_fault_period);

Use sysfs_emit().

author maintainer
#4 lore raw

Thank you for your kindly feedback.

I have some questions and answers.

Quoted 4 lines
Quoted 4 lines
sound/soc/codecs/sma1303.c new file +4 -0
+	if (!(sma1303->amp_power_status)) {
+		dev_info(component->dev, "%s : %s\n",
+			__func__, "Already AMP Shutdown");
+		return ret;
Quoted 8 lines

sound/soc/codecs/sma1303.c line 431

Quoted 6 lines
sound/soc/codecs/sma1303.c new file +6 -0
+	}
+
+	cancel_delayed_work_sync(&sma1303->check_fault_work);
+
+	msleep(55);
+

That sleep looks odd - what are we delaying after?

It need for IC(Amp) issue.

Quoted 29 lines
Quoted 29 lines
sound/soc/codecs/sma1303.c new file +29 -0
+static int sma1303_dai_mute(struct snd_soc_dai *dai, int mute, int 
+stream) {
+	struct snd_soc_component *component = dai->component;
+	struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component);
+	int ret = 0;
+
+	if (stream == SNDRV_PCM_STREAM_CAPTURE)
+		return ret;
+
+	if (!(sma1303->amp_power_status)) {
+		dev_info(component->dev, "%s : %s\n",
+			__func__, "Already AMP Shutdown");
+		return ret;
+	}
+
+	if (mute) {
+		dev_info(component->dev, "%s : %s\n", __func__, "MUTE");
+
+		ret += sma1303_regmap_update_bits(sma1303,
+				SMA1303_0E_MUTE_VOL_CTRL,
+				SMA1303_SPK_MUTE_MASK,
+				SMA1303_SPK_MUTE);
+	} else {
+		if (!sma1303->force_mute_status) {
+			dev_info(component->dev, "%s : %s\n",
+					__func__, "UNMUTE");
+			ret += sma1303_regmap_update_bits(sma1303,
+					SMA1303_0E_MUTE_VOL_CTRL,
+					SMA1303_SPK_MUTE_MASK,
Quoted 8 lines

sound/soc/codecs/sma1303.c line 1087

Quoted 6 lines
sound/soc/codecs/sma1303.c new file +6 -0
+					SMA1303_SPK_UNMUTE);
+		} else {
+			dev_info(sma1303->dev,
+					"%s : FORCE MUTE!!!\n", __func__);
+		}
+	}

If you need to shut the device down to implement mute then it's better to just not implement it, you shouldn't emulate features in the driver but instead let the core worry about how to handle that case. AFAICT this is why there's the startup/shutdown thing for the speaker amp?

This is not power down device. It's only make zero signal level(only mute in amp). I removed checking power status.

Quoted 10 lines

sound/soc/codecs/sma1303.c line 1306

Quoted 8 lines
sound/soc/codecs/sma1303.c new file +8 -0
+static void sma1303_check_fault_worker(struct work_struct *work) {
+	struct sma1303_priv *sma1303 =
+		container_of(work, struct sma1303_priv, check_fault_work.work);
+	int ret = 0;
+	unsigned int over_temp, ocp_val, uvlo_val;
+
+	mutex_lock(&sma1303->lock);
+

It looks like this mutex is only taken in this function, is it needed?

This function is in workqueue. So, I think it can be done at the same time.

maintainer
#5 lore raw
Quoted 12 lines · Ki-Seok Jo
Quoted 11 lines

sound/soc/codecs/sma1303.c line 430

Quoted 9 lines
sound/soc/codecs/sma1303.c new file +9 -0
+	if (!(sma1303->amp_power_status)) {
+		dev_info(component->dev, "%s : %s\n",
+			__func__, "Already AMP Shutdown");
+		return ret;
+	}
+
+	cancel_delayed_work_sync(&sma1303->check_fault_work);
+
+	msleep(55);

That sleep looks odd - what are we delaying after?

Quoted 1 line

It need for IC(Amp) issue.

Right, but what is the issue? It's not clear what event we're delaying for so it's not clear it'll work properly.

Quoted 11 lines
Quoted 9 lines

sound/soc/codecs/sma1303.c line 1305

Quoted 7 lines
sound/soc/codecs/sma1303.c new file +7 -0
+static void sma1303_check_fault_worker(struct work_struct *work) {
+	struct sma1303_priv *sma1303 =
+		container_of(work, struct sma1303_priv, check_fault_work.work);
+	int ret = 0;
+	unsigned int over_temp, ocp_val, uvlo_val;
+
+	mutex_lock(&sma1303->lock);

It looks like this mutex is only taken in this function, is it needed?

This function is in workqueue. So, I think it can be done at the same time.

A given work_struct should only be schedulable once.

author maintainer
#6 lore raw
Quoted 12 lines · Ki-Seok Jo
Quoted 11 lines
Quoted 11 lines

sound/soc/codecs/sma1303.c line 430

Quoted 9 lines
sound/soc/codecs/sma1303.c new file +9 -0
+	if (!(sma1303->amp_power_status)) {
+		dev_info(component->dev, "%s : %s\n",
+			__func__, "Already AMP Shutdown");
+		return ret;
+	}
+
+	cancel_delayed_work_sync(&sma1303->check_fault_work);
+
+	msleep(55);

That sleep looks odd - what are we delaying after?

Quoted 3 lines
Quoted 1 line

It need for IC(Amp) issue.

Right, but what is the issue? It's not clear what event we're delaying for so it's not clear it'll work properly.

This device requires a delay from mute to power off. If it is turned off while the signal is coming out, it takes some time to become muted. (need to about 50ms). So, this delay is required to turn off the power after completely muting. If the time is too long, we can reduce the delay a bit.

Quoted 10 lines
Quoted 9 lines
Quoted 9 lines

sound/soc/codecs/sma1303.c line 1305

Quoted 7 lines
sound/soc/codecs/sma1303.c new file +7 -0
+static void sma1303_check_fault_worker(struct work_struct *work) {
+	struct sma1303_priv *sma1303 =
+		container_of(work, struct sma1303_priv, check_fault_work.work);
+	int ret = 0;
+	unsigned int over_temp, ocp_val, uvlo_val;
+
+	mutex_lock(&sma1303->lock);

It looks like this mutex is only taken in this function, is it needed?

Quoted 3 lines
Quoted 1 line

This function is in workqueue. So, I think it can be done at the same time.

A given work_struct should only be schedulable once.

Oh, I was wrong. I should remove this. After receiving feedback on the previously sent V3 or if there is no problem, I will include this in V4 and send it. Thanks!

maintainer
#7 lore raw
Quoted 10 lines · Ki-Seok Jo
Quoted 7 lines · Ki-Seok Jo
Quoted 7 lines
Quoted 5 lines

sound/soc/codecs/sma1303.c line 430

Quoted 3 lines
sound/soc/codecs/sma1303.c new file +2 -0
+	cancel_delayed_work_sync(&sma1303->check_fault_work);
 
+	msleep(55);

That sleep looks odd - what are we delaying after?

It need for IC(Amp) issue.

Quoted 8 lines
Quoted 2 lines

Right, but what is the issue? It's not clear what event we're delaying for so it's not clear it'll work properly.

This device requires a delay from mute to power off. If it is turned off while the signal is coming out, it takes some time to become muted. (need to about 50ms). So, this delay is required to turn off the power after completely muting. If the time is too long, we can reduce the delay a bit.

This at the very least needs a comment since it's not clear how someone would work that out from the code, there's no connection here to the mute operation so someone might just remove the delay. It may even be that this is happening well over 55ms after the mute happened. The ideal thing would be to track the time from the last mute, the regulator core does something along those lines with off_on_delay.

Please fix your mail client to word wrap within paragraphs at something substantially less than 80 columns. Doing this makes your messages much easier to read and reply to.

author maintainer
#8 lore raw
Quoted 18 lines
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines

sound/soc/codecs/sma1303.c line 430

Quoted 4 lines
sound/soc/codecs/sma1303.c new file +2 -0
+	cancel_delayed_work_sync(&sma1303->check_fault_work);
 
+	msleep(55);

That sleep looks odd - what are we delaying after?

It need for IC(Amp) issue.

Quoted 8 lines
Quoted 2 lines

Right, but what is the issue? It's not clear what event we're delaying for so it's not clear it'll work properly.

This device requires a delay from mute to power off. If it is turned off while the signal is coming out, it takes some time to become muted. (need to about 50ms). So, this delay is required to turn off the power after completely muting. If the time is too long, we can reduce the delay a bit.

Quoted 6 lines

This at the very least needs a comment since it's not clear how someone would work that out from the code, there's no connection here to the mute operation so someone might just remove the delay. It may even be that this is happening well over 55ms after the mute happened. The ideal thing would be to track the time from the last mute, the regulator core does something along those lines with off_on_delay.

Currently mute control is registered in mute_stream function in dai operations. After that, amp shutdown is performed in DAPM PRE_PMD. Since a 55 ms delay was required in the meantime, it seems correct to change the position of the delay like you said. I will also include a comment about delay. Please reply if there is any problem.

Quoted 3 lines

Please fix your mail client to word wrap within paragraphs at something substantially less than 80 columns. Doing this makes your messages much easier to read and reply to.

Thanks, I fixed the mail setting.

maintainer
#9 lore raw
Quoted 7 lines · Ki-Seok Jo
Quoted 6 lines

This at the very least needs a comment since it's not clear how someone would work that out from the code, there's no connection here to the mute operation so someone might just remove the delay. It may even be that this is happening well over 55ms after the mute happened. The ideal thing would be to track the time from the last mute, the regulator core does something along those lines with off_on_delay.

Quoted 6 lines

Currently mute control is registered in mute_stream function in dai operations. After that, amp shutdown is performed in DAPM PRE_PMD. Since a 55 ms delay was required in the meantime, it seems correct to change the position of the delay like you said. I will also include a comment about delay. Please reply if there is any problem.

I think that sounds fine.

Quoted 5 lines
Quoted 3 lines

Please fix your mail client to word wrap within paragraphs at something substantially less than 80 columns. Doing this makes your messages much easier to read and reply to.

Thanks, I fixed the mail setting.

Seems not to have worked (at least for the text version) :/