Skip to contentSkip to conversation

ASoC: Move IO and kcontrols to the component level

PATCH Applied Lars-Peter Clausen 5 participants 28 messages Apr 22, 2014 – May 13, 2014

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

v4 cover ASoC: Move IO and kcontrols to the component level

Changes since v3:
* Removed the omap-hdmi compile fix that slipped in by accident.

v3 cover letter:

The only change in v3 is the renaming of the component IO mutex from 'mutex' to 'io_mutex'.

v2 cover letter:

This series contains the remaining patches from the previous series that have not been applied yet. The series has been rebased ontop of asoc/for-next and depends on topic/sta350, topic/core, topic/dapm, topic/cache and topic/component.

Some minor updates were made to the patches and three new patches:
* One new user of snd_kcontrol_chip() showed up, the patch converts it to snd_soc_kcontrol_codec()
* Change return type of snd_soc_write() from unsigned int to int
* Remove ASoC level tracing

Original cover letter:

This series is the first step towards full componentisation of the ASoC core. It moves both the IO abstraction layers within ASoC as well as the standard set of kcontrols to the component level. This for example means we can get rid of constructs like

	if (w->codec)
		snd_soc_read(....)
	else if(w->platform)
		snd_soc_platform_read(...)

Moving the kcontrols to the component level means we can use the same implementation also for other non-CODEC components. E.g. there seems to be an increasing amount of CPU components that have basic signal processing and things like volume controls etc. whose register layout is similar to those used in CODECs. Currently each CPU component driver re-implements these controls by hand.

The first two patches introduce two new helper functions which hide the actual implementation on how the CODEC or platform struct that register a control can be obtained from the control. This means that when the actual implementation is changed only the two helper functions need to be updated and not every single driver. The patches that follow that are just cleanups removing unused IO stuff and move all IO functions to soc-io.c. The next step is to make platforms also components. And then finally first the IO abstraction layers in ASoC are unified at the component level and then on top of that the kcontrol helpers are moved to the component level.

The series depends on quite a few topic branches related to changes to the core and cleanups for individual drivers. It is probably best to place it on top of asoc-v3.15-2. The patch that moves the kcontrols to the component level also has a runtime dependency on the not yet applied patches that move the ams-delta and mfld_machine controls to the card level.

Lars-Peter Clausen (5):
ASoC: Move IO abstraction to the component level
ASoC: Move standard kcontrol helpers to the component level
ASoC: Remove snd_soc_update_bits_locked()
ASoC: dapm: Rename soc_widget_update_bits_locked() to
soc_widget_update_bits()
ASoC: Remove ASoC level IO tracing

 include/sound/soc-dapm.h    |   1 +
 include/sound/soc.h         |  51 +++++--
 include/trace/events/asoc.h |  92 -------------
 sound/soc/soc-core.c        | 285 +++++++++++++++++++++++++-------------
 sound/soc/soc-dapm.c        |  91 ++----------
 sound/soc/soc-io.c          | 327 ++++++++++++++++++++++++++------------------
 6 files changed, 447 insertions(+), 400 deletions(-)
Signature · 1 line
1.8.0
#1 lore raw

PATCH v4 1/5 ASoC: Move IO abstraction to the component level

We currently have two very similar IO abstractions in ASoC, one for CODECs, the other for platforms. Moving this to the component level will allow us to unify those two. It will also enable us to move the standard kcontrol helpers as well as DAPM support to the component level.

The new component level abstraction layer is primarily build around regmap. There is a per component pointer for the regmap instance for the underlying device. There are four new function snd_soc_component_read(), snd_soc_component_write(), snd_soc_component_update_bits() and snd_soc_component_update_bits_async(). They have the same signature as their regmap counter-part and will internally forward the call one-to-one to regmap. If the component it not using regmap it will fallback to using the custom IO callbacks. This is done to be able to support drivers that haven't been converted to regmap yet, but it is expected that this will eventually be removed in the future once all component drivers have been converted to regmap.

---
Changes since v2:
* Rename mutex to io_mutex
Changes since v1:
* Rebased onto asoc/for-next
* Add kernel doc for the new functions
* Rename snd_soc_component_set_cache_io() to snd_soc_component_init_io()
* Removed stubbed out version of snd_soc_component_init_io(), the only regmap function in there that we use is regmap_get_val_bytes() and that is already stubbed out perfectly fine by the regmap code (and given that almost all CODECs require regmap chances that we build without regmap support in the first place are quite low).

---
 include/sound/soc-dapm.h |   1 +
 include/sound/soc.h      |  31 +++--
 sound/soc/soc-core.c     |  96 ++++++++++----
 sound/soc/soc-dapm.c     |  84 ++-----------
 sound/soc/soc-io.c       | 322 ++++++++++++++++++++++++++++++-----------------
 5 files changed, 317 insertions(+), 217 deletions(-)
include/sound/soc-dapm.h +1 -0
index 5ec03b5..b041fc6 100644
@@ -594,6 +594,7 @@ struct snd_soc_dapm_context {
 			     enum snd_soc_dapm_type, int);
 
 	struct device *dev; /* from parent - for debug */
+	struct snd_soc_component *component; /* parent component */
 	struct snd_soc_codec *codec; /* parent codec */
 	struct snd_soc_platform *platform; /* parent platform */
 	struct snd_soc_card *card; /* parent card */
include/sound/soc.h +24 -7
index de62475..554c650 100644
@@ -393,8 +393,6 @@ int devm_snd_soc_register_component(struct device *dev,
 			 const struct snd_soc_component_driver *cmpnt_drv,
 			 struct snd_soc_dai_driver *dai_drv, int num_dai);
 void snd_soc_unregister_component(struct device *dev);
-int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec,
-			       struct regmap *regmap);
 int snd_soc_cache_sync(struct snd_soc_codec *codec);
 int snd_soc_cache_init(struct snd_soc_codec *codec);
 int snd_soc_cache_exit(struct snd_soc_codec *codec);
@@ -672,6 +670,14 @@ struct snd_soc_component {
 	const struct snd_soc_component_driver *driver;
 
 	struct list_head dai_list;
+
+	int (*read)(struct snd_soc_component *, unsigned int, unsigned int *);
+	int (*write)(struct snd_soc_component *, unsigned int, unsigned int);
+
+	struct regmap *regmap;
+	int val_bytes;
+
+	struct mutex io_mutex;
 };
 
 /* SoC Audio Codec device */
@@ -696,18 +702,14 @@ struct snd_soc_codec {
 	unsigned int ac97_registered:1; /* Codec has been AC97 registered */
 	unsigned int ac97_created:1; /* Codec has been created by SoC */
 	unsigned int cache_init:1; /* codec cache has been initialized */
-	unsigned int using_regmap:1; /* using regmap access */
 	u32 cache_only;  /* Suppress writes to hardware */
 	u32 cache_sync; /* Cache needs to be synced to hardware */
 
 	/* codec IO */
 	void *control_data; /* codec control (i2c/3wire) data */
 	hw_write_t hw_write;
-	unsigned int (*read)(struct snd_soc_codec *, unsigned int);
-	int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
 	void *reg_cache;
 	struct mutex cache_rw_mutex;
-	int val_bytes;
 
 	/* component */
 	struct snd_soc_component component;
@@ -824,7 +826,6 @@ struct snd_soc_platform {
 	int id;
 	struct device *dev;
 	const struct snd_soc_platform_driver *driver;
-	struct mutex mutex;
 
 	unsigned int suspended:1; /* platform is suspended */
 	unsigned int probed:1;
@@ -1129,6 +1130,22 @@ unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg);
 int snd_soc_write(struct snd_soc_codec *codec, unsigned int reg,
 	unsigned int val);
 
+/* component IO */
+int snd_soc_component_read(struct snd_soc_component *component,
+	unsigned int reg, unsigned int *val);
+int snd_soc_component_write(struct snd_soc_component *component,
+	unsigned int reg, unsigned int val);
+int snd_soc_component_update_bits(struct snd_soc_component *component,
+	unsigned int reg, unsigned int mask, unsigned int val);
+int snd_soc_component_update_bits_async(struct snd_soc_component *component,
+	unsigned int reg, unsigned int mask, unsigned int val);
+void snd_soc_component_async_complete(struct snd_soc_component *component);
+int snd_soc_component_test_bits(struct snd_soc_component *component,
+	unsigned int reg, unsigned int mask, unsigned int value);
+
+int snd_soc_component_init_io(struct snd_soc_component *component,
+	struct regmap *regmap);
+
 /* device driver data */
 
 static inline void snd_soc_card_set_drvdata(struct snd_soc_card *card,
sound/soc/soc-core.c +71 -25

229 lines not on this page · raw message

sound/soc/soc-dapm.c +11 -73

97 lines not on this page · raw message

sound/soc/soc-io.c +210 -112

391 lines not on this page · raw message

Signature · 1 line
1.8.0
maintainer Applied
#2 lore raw

Re: [PATCH v4 1/5] ASoC: Move IO abstraction to the component level

Quoted 4 lines · Lars-Peter Clausen

We currently have two very similar IO abstractions in ASoC, one for CODECs, the other for platforms. Moving this to the component level will allow us to unify those two. It will also enable us to move the standard kcontrol helpers as well as DAPM support to the component level.

Applied, thanks.

#3 lore raw

PATCH v4 2/5 ASoC: Move standard kcontrol helpers to the component level

In reply to Lars-Peter Clausen

After moving the IO layer inside ASoC to the component level we can now easily move the standard control helpers also to the component level. This allows to reuse the same standard helper control implementations for other components.

---
 include/sound/soc.h  |  20 ++++-
 sound/soc/soc-core.c | 221 ++++++++++++++++++++++++++++++++-------------------
 2 files changed, 156 insertions(+), 85 deletions(-)
include/sound/soc.h +18 -2
index 554c650..19a82ce 100644
@@ -1250,6 +1250,22 @@ static inline bool snd_soc_codec_is_active(struct snd_soc_codec *codec)
 }
 
 /**
+ * snd_soc_kcontrol_component() - Returns the component that registered the
+ *  control
+ * @kcontrol: The control for which to get the component
+ *
+ * Note: This function will work correctly if the control has been registered
+ * for a component. Either with snd_soc_add_codec_controls() or
+ * snd_soc_add_platform_controls() or via  table based setup for either a
+ * CODEC, a platform or component driver. Otherwise the behavior is undefined.
+ */
+static inline struct snd_soc_component *snd_soc_kcontrol_component(
+	struct snd_kcontrol *kcontrol)
+{
+	return snd_kcontrol_chip(kcontrol);
+}
+
+/**
  * snd_soc_kcontrol_codec() - Returns the CODEC that registered the control
  * @kcontrol: The control for which to get the CODEC
  *
@@ -1260,7 +1276,7 @@ static inline bool snd_soc_codec_is_active(struct snd_soc_codec *codec)
 static inline struct snd_soc_codec *snd_soc_kcontrol_codec(
 	struct snd_kcontrol *kcontrol)
 {
-	return snd_kcontrol_chip(kcontrol);
+	return snd_soc_component_to_codec(snd_soc_kcontrol_component(kcontrol));
 }
 
 /**
@@ -1274,7 +1290,7 @@ static inline struct snd_soc_codec *snd_soc_kcontrol_codec(
 static inline struct snd_soc_platform *snd_soc_kcontrol_platform(
 	struct snd_kcontrol *kcontrol)
 {
-	return snd_kcontrol_chip(kcontrol);
+	return snd_soc_component_to_platform(snd_soc_kcontrol_component(kcontrol));
 }
 
 int snd_soc_util_init(void);
sound/soc/soc-core.c +138 -83

562 lines not on this page · raw message

Signature · 1 line
1.8.0
maintainer Applied
#4 lore raw

Re: [PATCH v4 2/5] ASoC: Move standard kcontrol helpers to the component level

Quoted 3 lines · Lars-Peter Clausen

After moving the IO layer inside ASoC to the component level we can now easily move the standard control helpers also to the component level. This allows to reuse the same standard helper control implementations for other components.

Applied, thanks. This also depended on the multicodec changes.

#5 lore raw

Re: [PATCH v4 2/5] ASoC: Move standard kcontrol helpers to the component level

In reply to Lars-Peter Clausen

Hi Lars,

Quoted 5 lines · Lars-Peter Clausen

After moving the IO layer inside ASoC to the component level we can now easily move the standard control helpers also to the component level. This allows to reuse the same standard helper control implementations for other components.

I'm running next-20140508 on imx6q-sabresd board and seeing repeated 'amixer: Mixer hw:0 load error: Device or resource busy' message with Debian wheezy rootfs. The git bisect points me to this patch.

== message output before this patch ==

[....] Setting up ALSA...warning: 'alsactl restore' failed with error message 'Found hardware: "wm8962-audio" "" "" "" "" Hardware is initialized using a generic method
[ ok tl: set_control:1328: failed to obtain info for control #117 (No such file or directory)'...done.

== message output after this patch ==

[....] Setting up ALSA...warning: 'alsactl restore' failed with error message 'Found hardware: "wm8962-audio" "" "" "" "" Hardware is initialized using a generic method
alsactl: set_control:1328: failed to obtain info for control #117 (No such file or directory)'...amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
done.

Why do we start seeing such error message with your patch? Is this a problem of rootfs or kernel?

Shawn

#6 lore raw

Re: [PATCH v4 2/5] ASoC: Move standard kcontrol helpers to the component level

Quoted 62 lines · Shawn Guo

Hi Lars,

Quoted 5 lines · Lars-Peter Clausen

After moving the IO layer inside ASoC to the component level we can now easily move the standard control helpers also to the component level. This allows to reuse the same standard helper control implementations for other components.

I'm running next-20140508 on imx6q-sabresd board and seeing repeated 'amixer: Mixer hw:0 load error: Device or resource busy' message with Debian wheezy rootfs. The git bisect points me to this patch.

== message output before this patch ==

[....] Setting up ALSA...warning: 'alsactl restore' failed with error message 'Found hardware: "wm8962-audio" "" "" "" "" Hardware is initialized using a generic method
[ ok tl: set_control:1328: failed to obtain info for control #117 (No such file or directory)'...done.

== message output after this patch ==

[....] Setting up ALSA...warning: 'alsactl restore' failed with error message 'Found hardware: "wm8962-audio" "" "" "" "" Hardware is initialized using a generic method
alsactl: set_control:1328: failed to obtain info for control #117 (No such file or directory)'...amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
amixer: Mixer hw:0 load error: Device or resource busy
done.

Quoted 2 lines

Why do we start seeing such error message with your patch? Is this a problem of rootfs or kernel?

The changes in the patch should mostly be transparent. But what changed is how error reporting is handled. If there is a error reading/writing a register in the kcontrol callbacks that error is passed on to userspace whereas previously it was silently ignored.

There is also the possibility that there is a bug somewhere in the patch causing this.

Does the board otherwise work fine?

I actually have the board here, if you tell me which devictree/defconfig I can use with an upstream kernel I can give things a try.

- Lars

#7 lore raw

Re: [PATCH v4 2/5] ASoC: Move standard kcontrol helpers to the component level

Quoted 5 lines · Lars-Peter Clausen

The changes in the patch should mostly be transparent. But what changed is how error reporting is handled. If there is a error reading/writing a register in the kcontrol callbacks that error is passed on to userspace whereas previously it was silently ignored.

Quoted 7 lines

There is also the possibility that there is a bug somewhere in the patch causing this.

Does the board otherwise work fine?

I actually have the board here, if you tell me which devictree/defconfig I can use with an upstream kernel I can give things a try.

make imx_v6_v7_defconfig
make imx6q-sabresd.dtb

Thanks

#8 lore raw

Re: [PATCH v4 2/5] ASoC: Move standard kcontrol helpers to the component level

Quoted 10 lines · Fabio Estevam
Quoted 8 lines · Lars-Peter Clausen

The changes in the patch should mostly be transparent. But what changed is how error reporting is handled. If there is a error reading/writing a register in the kcontrol callbacks that error is passed on to userspace whereas previously it was silently ignored.

There is also the possibility that there is a bug somewhere in the patch causing this.

Quoted 7 lines
Quoted 4 lines

Does the board otherwise work fine?

I actually have the board here, if you tell me which devictree/defconfig I can use with an upstream kernel I can give things a try.

make imx_v6_v7_defconfig
make imx6q-sabresd.dtb

I just tried 907fe36a2c, e2c330b9b5 and next/master. I get the same behavior with all 3, no errors when loading a state file and audio out on the headphones works. I disabled DRM though since it deadlocked the system, maybe that makes a difference.

Is it possible that the error is coming from the I2C driver? Can you build the I2C driver with #define DEBUG and take a look at the output?

- Lars

#9 lore raw

Re: [PATCH v4 2/5] ASoC: Move standard kcontrol helpers to the component level

Quoted 4 lines · Lars-Peter Clausen

I just tried 907fe36a2c, e2c330b9b5 and next/master. I get the same behavior with all 3, no errors when loading a state file and audio out on the headphones works. I disabled DRM though since it deadlocked the system, maybe that makes a difference.

Here is the fix for this hang (which hasn't reached linux-next yet):
http://www.spinics.net/lists/arm-kernel/msg329063.html

Quoted 3 lines

Is it possible that the error is coming from the I2C driver? Can you build the I2C driver with #define DEBUG and take a look at the output?

I will let Shawn to try it. With my minimal rootfs I do not see the error messages when playing audio.

#10 lore raw

Re: [PATCH v4 2/5] ASoC: Move standard kcontrol helpers to the component level

In reply to Lars-Peter Clausen
Quoted 16 lines · Lars-Peter Clausen
Quoted 15 lines · Fabio Estevam
Quoted 12 lines · Lars-Peter Clausen

The changes in the patch should mostly be transparent. But what changed is how error reporting is handled. If there is a error reading/writing a register in the kcontrol callbacks that error is passed on to userspace whereas previously it was silently ignored.

There is also the possibility that there is a bug somewhere in the patch causing this.

Does the board otherwise work fine?

I actually have the board here, if you tell me which devictree/defconfig I can use with an upstream kernel I can give things a try.

Quoted 6 lines
Quoted 2 lines

make imx_v6_v7_defconfig
make imx6q-sabresd.dtb

I just tried 907fe36a2c, e2c330b9b5 and next/master. I get the same behavior with all 3, no errors when loading a state file and audio out on the headphones works.

For me, e2c330b9b5 is good while 907fe36a2c and next/master expose this error message.

Quoted 2 lines

I disabled DRM though since it
deadlocked the system, maybe that makes a difference.

It does not make a difference.

Quoted 4 lines

Is it possible that the error is coming from the I2C driver? Can you build the I2C driver with #define DEBUG and take a look at the output?

I tried to turn on DEBUG in I2C driver, and did not notice any I2C message when above error appears.

The error message only shows up with Debian wheezy and does not with yocto rootfs. And even when the error message shows, the audio still functions well on Debian wheezy. So it's just a noisy error message for me which is only seen after your kernel patch.

Shawn

#11 lore raw

Re: [PATCH v4 2/5] ASoC: Move standard kcontrol helpers to the component level

Quoted 37 lines · Shawn Guo
Quoted 16 lines · Lars-Peter Clausen
Quoted 15 lines · Fabio Estevam
Quoted 12 lines · Lars-Peter Clausen

The changes in the patch should mostly be transparent. But what changed is how error reporting is handled. If there is a error reading/writing a register in the kcontrol callbacks that error is passed on to userspace whereas previously it was silently ignored.

There is also the possibility that there is a bug somewhere in the patch causing this.

Does the board otherwise work fine?

I actually have the board here, if you tell me which devictree/defconfig I can use with an upstream kernel I can give things a try.

Quoted 6 lines
Quoted 2 lines

make imx_v6_v7_defconfig
make imx6q-sabresd.dtb

I just tried 907fe36a2c, e2c330b9b5 and next/master. I get the same behavior with all 3, no errors when loading a state file and audio out on the headphones works.

For me, e2c330b9b5 is good while 907fe36a2c and next/master expose this error message.

Quoted 2 lines

I disabled DRM though since it
deadlocked the system, maybe that makes a difference.

It does not make a difference.

Quoted 4 lines

Is it possible that the error is coming from the I2C driver? Can you build the I2C driver with #define DEBUG and take a look at the output?

Quoted 7 lines

I tried to turn on DEBUG in I2C driver, and did not notice any I2C message when above error appears.

The error message only shows up with Debian wheezy and does not with yocto rootfs. And even when the error message shows, the audio still functions well on Debian wheezy. So it's just a noisy error message for me which is only seen after your kernel patch.

The keyword here is "seen". The error quite likely predated the commit, but it was silently discarded.

regmap_read() returns -EBUSY when there is no cached register value and cache_only is set to true. But I'm not sure why that would happen, try to add some printks to _regmap_read() to see if this is the source and if it is why it is.

- Lars

#12 lore raw

Re: [PATCH v4 2/5] ASoC: Move standard kcontrol helpers to the component level

On 05/10/2014 09:04 AM, Lars-Peter Clausen wrote:
[..]

Quoted 5 lines
Quoted 4 lines

The error message only shows up with Debian wheezy and does not with yocto rootfs. And even when the error message shows, the audio still functions well on Debian wheezy. So it's just a noisy error message for me which is only seen after your kernel patch.

Quoted 7 lines

The keyword here is "seen". The error quite likely predated the commit, but it was silently discarded.

regmap_read() returns -EBUSY when there is no cached register value and cache_only is set to true. But I'm not sure why that would happen, try to add some printks to _regmap_read() to see if this is the source and if it is why it is.

Both SGTL5000_CHIP_ANA_ADC_CTRL and SGTL5000_CHIP_MIC_CTRL don't have an entry in sgtl5000_reg_defaults. So if cache_only is true, controls which use these registers will return -EBUSY when you try to read or write them.

#13 lore raw

Re: [PATCH v4 2/5] ASoC: Move standard kcontrol helpers to the component level

Quoted 15 lines · Lars-Peter Clausen

On 05/10/2014 09:04 AM, Lars-Peter Clausen wrote:
[..]

Quoted 5 lines
Quoted 4 lines

The error message only shows up with Debian wheezy and does not with yocto rootfs. And even when the error message shows, the audio still functions well on Debian wheezy. So it's just a noisy error message for me which is only seen after your kernel patch.

Quoted 7 lines

The keyword here is "seen". The error quite likely predated the commit, but it was silently discarded.

regmap_read() returns -EBUSY when there is no cached register value and cache_only is set to true. But I'm not sure why that would happen, try to add some printks to _regmap_read() to see if this is the source and if it is why it is.

Quoted 4 lines

Both SGTL5000_CHIP_ANA_ADC_CTRL and SGTL5000_CHIP_MIC_CTRL don't have an entry in sgtl5000_reg_defaults. So if cache_only is true, controls which use these registers will return -EBUSY when you try to read or write them.

Hmm, it's a wm8962 than sgtl5000 on board imx6q-sabresd.

Shawn

#14 lore raw

Re: [PATCH v4 2/5] ASoC: Move standard kcontrol helpers to the component level

Quoted 16 lines · Shawn Guo
Quoted 15 lines · Lars-Peter Clausen

On 05/10/2014 09:04 AM, Lars-Peter Clausen wrote:
[..]

Quoted 12 lines
Quoted 4 lines

The error message only shows up with Debian wheezy and does not with yocto rootfs. And even when the error message shows, the audio still functions well on Debian wheezy. So it's just a noisy error message for me which is only seen after your kernel patch.

The keyword here is "seen". The error quite likely predated the commit, but it was silently discarded.

regmap_read() returns -EBUSY when there is no cached register value and cache_only is set to true. But I'm not sure why that would happen, try to add some printks to _regmap_read() to see if this is the source and if it is why it is.

Quoted 6 lines
Quoted 4 lines

Both SGTL5000_CHIP_ANA_ADC_CTRL and SGTL5000_CHIP_MIC_CTRL don't have an entry in sgtl5000_reg_defaults. So if cache_only is true, controls which use these registers will return -EBUSY when you try to read or write them.

Hmm, it's a wm8962 than sgtl5000 on board imx6q-sabresd.

Ok, misread the boardname. But the issue will be the same. cache_only = true and trying to read/update a register that is not in the cache.

#15 lore raw

Re: [PATCH v4 2/5] ASoC: Move standard kcontrol helpers to the component level

Quoted 22 lines · Lars-Peter Clausen
Quoted 21 lines · Shawn Guo
Quoted 19 lines · Lars-Peter Clausen

On 05/10/2014 09:04 AM, Lars-Peter Clausen wrote:
[..]

Quoted 5 lines
Quoted 4 lines

The error message only shows up with Debian wheezy and does not with yocto rootfs. And even when the error message shows, the audio still functions well on Debian wheezy. So it's just a noisy error message for me which is only seen after your kernel patch.

Quoted 7 lines

The keyword here is "seen". The error quite likely predated the commit, but it was silently discarded.

regmap_read() returns -EBUSY when there is no cached register value and cache_only is set to true. But I'm not sure why that would happen, try to add some printks to _regmap_read() to see if this is the source and if it is why it is.

Both SGTL5000_CHIP_ANA_ADC_CTRL and SGTL5000_CHIP_MIC_CTRL don't have an entry in sgtl5000_reg_defaults. So if cache_only is true, controls which use these registers will return -EBUSY when you try to read or write them.

Quoted 5 lines
Quoted 1 line

Hmm, it's a wm8962 than sgtl5000 on board imx6q-sabresd.

Ok, misread the boardname. But the issue will be the same. cache_only = true and trying to read/update a register that is not in the cache.

Yea, you're right. When the error message shows up, _regmap_read() returns -EBUSY for reg WM8962_CLASS_D_CONTROL_1. But how do I find out why the reg is not in the cache?

Shawn

#16 lore raw

Re: [PATCH v4 2/5] ASoC: Move standard kcontrol helpers to the component level

Quoted 25 lines · Shawn Guo
Quoted 24 lines · Lars-Peter Clausen
Quoted 22 lines · Shawn Guo
Quoted 15 lines · Lars-Peter Clausen

On 05/10/2014 09:04 AM, Lars-Peter Clausen wrote:
[..]

Quoted 5 lines
Quoted 4 lines

The error message only shows up with Debian wheezy and does not with yocto rootfs. And even when the error message shows, the audio still functions well on Debian wheezy. So it's just a noisy error message for me which is only seen after your kernel patch.

Quoted 7 lines

The keyword here is "seen". The error quite likely predated the commit, but it was silently discarded.

regmap_read() returns -EBUSY when there is no cached register value and cache_only is set to true. But I'm not sure why that would happen, try to add some printks to _regmap_read() to see if this is the source and if it is why it is.

Quoted 4 lines

Both SGTL5000_CHIP_ANA_ADC_CTRL and SGTL5000_CHIP_MIC_CTRL don't have an entry in sgtl5000_reg_defaults. So if cache_only is true, controls which use these registers will return -EBUSY when you try to read or write them.

Hmm, it's a wm8962 than sgtl5000 on board imx6q-sabresd.

Quoted 7 lines
Quoted 3 lines

Ok, misread the boardname. But the issue will be the same. cache_only = true and trying to read/update a register that is not in the cache.

Yea, you're right. When the error message shows up, _regmap_read() returns -EBUSY for reg WM8962_CLASS_D_CONTROL_1. But how do I find out why the reg is not in the cache?

The register is marked as volatile in the driver and volatile registers are never cached. I don't know what the right fix is in this case though.

- Lars

#17 lore raw

Re: [PATCH v4 2/5] ASoC: Move standard kcontrol helpers to the component level

In reply to Shawn Guo
Quoted 29 lines · Shawn Guo
Quoted 22 lines · Lars-Peter Clausen
Quoted 21 lines · Shawn Guo
Quoted 19 lines · Lars-Peter Clausen

On 05/10/2014 09:04 AM, Lars-Peter Clausen wrote:
[..]

Quoted 5 lines
Quoted 4 lines

The error message only shows up with Debian wheezy and does not with yocto rootfs. And even when the error message shows, the audio still functions well on Debian wheezy. So it's just a noisy error message for me which is only seen after your kernel patch.

Quoted 7 lines

The keyword here is "seen". The error quite likely predated the commit, but it was silently discarded.

regmap_read() returns -EBUSY when there is no cached register value and cache_only is set to true. But I'm not sure why that would happen, try to add some printks to _regmap_read() to see if this is the source and if it is why it is.

Both SGTL5000_CHIP_ANA_ADC_CTRL and SGTL5000_CHIP_MIC_CTRL don't have an entry in sgtl5000_reg_defaults. So if cache_only is true, controls which use these registers will return -EBUSY when you try to read or write them.

Quoted 5 lines
Quoted 1 line

Hmm, it's a wm8962 than sgtl5000 on board imx6q-sabresd.

Ok, misread the boardname. But the issue will be the same. cache_only = true and trying to read/update a register that is not in the cache.

Quoted 5 lines

Yea, you're right. When the error message shows up, _regmap_read() returns -EBUSY for reg WM8962_CLASS_D_CONTROL_1. But how do I find out why the reg is not in the cache?

From what I can see it doesn't look like this register should be

volatile. I am checking with the hardware guys here, incase I am missing something, but otherwise I will wing out a patch to make it non-volatile.

Thanks,
Charles

maintainer
#18 lore raw

Re: [PATCH v4 2/5] ASoC: Move standard kcontrol helpers to the component level

Quoted 8 lines · Charles Keepax
Quoted 3 lines

Yea, you're right. When the error message shows up, _regmap_read() returns -EBUSY for reg WM8962_CLASS_D_CONTROL_1. But how do I find out why the reg is not in the cache?

From what I can see it doesn't look like this register should be volatile. I am checking with the hardware guys here, incase I am missing something, but otherwise I will wing out a patch to make it non-volatile.

IIRC at least one of the bits in the register also appears in another register. They aren't volatile but the cache could get confused unless something is open coded to keep the two cached registers in sync.

#19 lore raw

Re: [PATCH v4 2/5] ASoC: Move standard kcontrol helpers to the component level

Quoted 6 lines · Mark Brown
Quoted 3 lines · Charles Keepax
Quoted 3 lines

Yea, you're right. When the error message shows up, _regmap_read() returns -EBUSY for reg WM8962_CLASS_D_CONTROL_1. But how do I find out why the reg is not in the cache?

Quoted 8 lines
Quoted 4 lines

From what I can see it doesn't look like this register should be volatile. I am checking with the hardware guys here, incase I am missing something, but otherwise I will wing out a patch to make it non-volatile.

IIRC at least one of the bits in the register also appears in another register. They aren't volatile but the cache could get confused unless something is open coded to keep the two cached registers in sync.

Yup, just heard back from the hardware guys, this is exactly it. The DAC_MUTE bit in registers R5 and R49 both control the same thing. So if you change one it changes the other.

Looks like either something will need to be added to keep the two registers in sync, or some manual caching of the speaker switch until the device is enabled.

Thanks,
Charles

#20 lore raw

Re: [PATCH v4 2/5] ASoC: Move standard kcontrol helpers to the component level

In reply to Shawn Guo
Quoted 25 lines · Shawn Guo
Quoted 24 lines · Lars-Peter Clausen
Quoted 22 lines · Shawn Guo
Quoted 15 lines · Lars-Peter Clausen

On 05/10/2014 09:04 AM, Lars-Peter Clausen wrote:
[..]

Quoted 5 lines
Quoted 4 lines

The error message only shows up with Debian wheezy and does not with yocto rootfs. And even when the error message shows, the audio still functions well on Debian wheezy. So it's just a noisy error message for me which is only seen after your kernel patch.

Quoted 7 lines

The keyword here is "seen". The error quite likely predated the commit, but it was silently discarded.

regmap_read() returns -EBUSY when there is no cached register value and cache_only is set to true. But I'm not sure why that would happen, try to add some printks to _regmap_read() to see if this is the source and if it is why it is.

Quoted 4 lines

Both SGTL5000_CHIP_ANA_ADC_CTRL and SGTL5000_CHIP_MIC_CTRL don't have an entry in sgtl5000_reg_defaults. So if cache_only is true, controls which use these registers will return -EBUSY when you try to read or write them.

Hmm, it's a wm8962 than sgtl5000 on board imx6q-sabresd.

Quoted 7 lines
Quoted 3 lines

Ok, misread the boardname. But the issue will be the same. cache_only = true and trying to read/update a register that is not in the cache.

Yea, you're right. When the error message shows up, _regmap_read() returns -EBUSY for reg WM8962_CLASS_D_CONTROL_1. But how do I find out why the reg is not in the cache?

Looking at this a bit more can you let me know when it is failing, I assume it is in relation to setting the "Speaker Switch" control?

Thanks,
Charles

#21 lore raw

Re: [PATCH v4 2/5] ASoC: Move standard kcontrol helpers to the component level

Quoted 3 lines · Charles Keepax

Looking at this a bit more can you let me know when it is failing, I assume it is in relation to setting the "Speaker Switch" control?

Yes, it is.

Shawn

#22 lore raw

PATCH v4 3/5 ASoC: Remove snd_soc_update_bits_locked()

In reply to Lars-Peter Clausen

There are no users of snd_soc_update_bits_locked() left and it is identical to snd_soc_update_bits(). So it can be removed.

---
 sound/soc/soc-io.c | 20 --------------------
 1 file changed, 20 deletions(-)
sound/soc/soc-io.c +0 -20
index ac64fd7..2ead9ed 100644
@@ -241,26 +241,6 @@ int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned int reg,
 EXPORT_SYMBOL_GPL(snd_soc_update_bits);
 
 /**
- * snd_soc_update_bits_locked - update codec register bits
- * @codec: audio codec
- * @reg: codec register
- * @mask: register mask
- * @value: new value
- *
- * Writes new register value, and takes the codec mutex.
- *
- * Returns 1 for change else 0.
- */
-int snd_soc_update_bits_locked(struct snd_soc_codec *codec,
-			       unsigned int reg, unsigned int mask,
-			       unsigned int value)
-{
-	return snd_soc_component_update_bits(&codec->component, reg, mask,
-		value);
-}
-EXPORT_SYMBOL_GPL(snd_soc_update_bits_locked);
-
-/**
  * snd_soc_test_bits - test register for change
  * @codec: audio codec
  * @reg: codec register
Signature · 1 line
1.8.0
maintainer Applied
#23 lore raw

Re: [PATCH v4 3/5] ASoC: Remove snd_soc_update_bits_locked()

Quoted 2 lines · Lars-Peter Clausen

There are no users of snd_soc_update_bits_locked() left and it is identical to snd_soc_update_bits(). So it can be removed.

Applied, thanks.

#24 lore raw

PATCH v4 4/5 ASoC: dapm: Rename soc_widget_update_bits_locked() to soc_widget_update_bits()

In reply to Lars-Peter Clausen

There is no unlocked version of soc_widget_update_bits_locked() and there is no plan to introduce it in the near future, so drop the _locked suffix.

---
 sound/soc/soc-dapm.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
sound/soc/soc-dapm.c +4 -5
index 85a594f..a2475e1 100644
@@ -383,7 +383,7 @@ static int soc_widget_read(struct snd_soc_dapm_widget *w, int reg,
 	return snd_soc_component_read(w->dapm->component, reg, value);
 }
 
-static int soc_widget_update_bits_locked(struct snd_soc_dapm_widget *w,
+static int soc_widget_update_bits(struct snd_soc_dapm_widget *w,
 	int reg, unsigned int mask, unsigned int value)
 {
 	if (!w->dapm->component)
@@ -1070,7 +1070,7 @@ int dapm_reg_event(struct snd_soc_dapm_widget *w,
 	else
 		val = w->off_val;
 
-	soc_widget_update_bits_locked(w, -(w->reg + 1),
+	soc_widget_update_bits(w, -(w->reg + 1),
 			    w->mask << w->shift, val << w->shift);
 
 	return 0;
@@ -1366,7 +1366,7 @@ static void dapm_seq_run_coalesced(struct snd_soc_card *card,
 			"pop test : Applying 0x%x/0x%x to %x in %dms\n",
 			value, mask, reg, card->pop_time);
 		pop_wait(card->pop_time);
-		soc_widget_update_bits_locked(w, reg, mask, value);
+		soc_widget_update_bits(w, reg, mask, value);
 	}
 
 	list_for_each_entry(w, pending, power_list) {
@@ -1512,8 +1512,7 @@ static void dapm_widget_update(struct snd_soc_card *card)
 	if (!w)
 		return;
 
-	ret = soc_widget_update_bits_locked(w, update->reg, update->mask,
-				  update->val);
+	ret = soc_widget_update_bits(w, update->reg, update->mask, update->val);
 	if (ret < 0)
 		dev_err(w->dapm->dev, "ASoC: %s DAPM update failed: %d\n",
 			w->name, ret);
Signature · 1 line
1.8.0
maintainer Applied
#25 lore raw

Re: [PATCH v4 4/5] ASoC: dapm: Rename soc_widget_update_bits_locked() to soc_widget_update_bits()

Quoted 2 lines · Lars-Peter Clausen

There is no unlocked version of soc_widget_update_bits_locked() and there is no plan to introduce it in the near future, so drop the _locked suffix.

Applied, thanks.

#26 lore raw

PATCH v4 5/5 ASoC: Remove ASoC level IO tracing

In reply to Lars-Peter Clausen

The ASoC framework is in the process of migrating all IO operations to regmap. regmap has its own more sophisticated tracing infrastructure for IO operations, which means that the ASoC level IO tracing becomes redundant, hence this patch removes them. There are still a handful of ASoC drivers left that do not use regmap yet, but hopefully the removal of the ASoC IO tracing will be an additional incentive to switch to regmap.

---
New in v2

---
 include/trace/events/asoc.h | 92 ---------------------------------------------
 sound/soc/soc-io.c          | 11 ------
 2 files changed, 103 deletions(-)
include/trace/events/asoc.h +0 -92
index 03996b2..c75c795 100644
@@ -11,102 +11,10 @@
 
 struct snd_soc_jack;
 struct snd_soc_codec;
-struct snd_soc_platform;
 struct snd_soc_card;
 struct snd_soc_dapm_widget;
 struct snd_soc_dapm_path;
 
-/*
- * Log register events
- */
-DECLARE_EVENT_CLASS(snd_soc_reg,
-
-	TP_PROTO(struct snd_soc_codec *codec, unsigned int reg,
-		 unsigned int val),
-
-	TP_ARGS(codec, reg, val),
-
-	TP_STRUCT__entry(
-		__string(	name,		codec->name	)
-		__field(	int,		id		)
-		__field(	unsigned int,	reg		)
-		__field(	unsigned int,	val		)
-	),
-
-	TP_fast_assign(
-		__assign_str(name, codec->name);
-		__entry->id = codec->id;
-		__entry->reg = reg;
-		__entry->val = val;
-	),
-
-	TP_printk("codec=%s.%d reg=%x val=%x", __get_str(name),
-		  (int)__entry->id, (unsigned int)__entry->reg,
-		  (unsigned int)__entry->val)
-);
-
-DEFINE_EVENT(snd_soc_reg, snd_soc_reg_write,
-
-	TP_PROTO(struct snd_soc_codec *codec, unsigned int reg,
-		 unsigned int val),
-
-	TP_ARGS(codec, reg, val)
-
-);
-
-DEFINE_EVENT(snd_soc_reg, snd_soc_reg_read,
-
-	TP_PROTO(struct snd_soc_codec *codec, unsigned int reg,
-		 unsigned int val),
-
-	TP_ARGS(codec, reg, val)
-
-);
-
-DECLARE_EVENT_CLASS(snd_soc_preg,
-
-	TP_PROTO(struct snd_soc_platform *platform, unsigned int reg,
-		 unsigned int val),
-
-	TP_ARGS(platform, reg, val),
-
-	TP_STRUCT__entry(
-		__string(	name,		platform->name	)
-		__field(	int,		id		)
-		__field(	unsigned int,	reg		)
-		__field(	unsigned int,	val		)
-	),
-
-	TP_fast_assign(
-		__assign_str(name, platform->name);
-		__entry->id = platform->id;
-		__entry->reg = reg;
-		__entry->val = val;
-	),
-
-	TP_printk("platform=%s.%d reg=%x val=%x", __get_str(name),
-		  (int)__entry->id, (unsigned int)__entry->reg,
-		  (unsigned int)__entry->val)
-);
-
-DEFINE_EVENT(snd_soc_preg, snd_soc_preg_write,
-
-	TP_PROTO(struct snd_soc_platform *platform, unsigned int reg,
-		 unsigned int val),
-
-	TP_ARGS(platform, reg, val)
-
-);
-
-DEFINE_EVENT(snd_soc_preg, snd_soc_preg_read,
-
-	TP_PROTO(struct snd_soc_platform *platform, unsigned int reg,
-		 unsigned int val),
-
-	TP_ARGS(platform, reg, val)
-
-);
-
 DECLARE_EVENT_CLASS(snd_soc_card,
 
 	TP_PROTO(struct snd_soc_card *card, int val),
sound/soc/soc-io.c +0 -11
index 2ead9ed..7767fbd 100644
@@ -17,8 +17,6 @@
 #include <linux/export.h>
 #include <sound/soc.h>
 
-#include <trace/events/asoc.h>
-
 /**
  * snd_soc_component_read() - Read register value
  * @component: Component to read from
@@ -39,8 +37,6 @@ int snd_soc_component_read(struct snd_soc_component *component,
 	else
 		ret = -EIO;
 
-	dev_dbg(component->dev, "read %x => %x\n", reg, *val);
-
 	return ret;
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_read);
@@ -56,8 +52,6 @@ EXPORT_SYMBOL_GPL(snd_soc_component_read);
 int snd_soc_component_write(struct snd_soc_component *component,
 	unsigned int reg, unsigned int val)
 {
-	dev_dbg(component->dev, "write %x = %x\n", reg, val);
-
 	if (component->regmap)
 		return regmap_write(component->regmap, reg, val);
 	else if (component->write)
@@ -207,7 +201,6 @@ unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg)
 	ret = snd_soc_component_read(&codec->component, reg, &val);
 	if (ret < 0)
 		return -1;
-	trace_snd_soc_reg_read(codec, reg, val);
 
 	return val;
 }
@@ -216,7 +209,6 @@ EXPORT_SYMBOL_GPL(snd_soc_read);
 int snd_soc_write(struct snd_soc_codec *codec, unsigned int reg,
 	unsigned int val)
 {
-	trace_snd_soc_reg_write(codec, reg, val);
 	return snd_soc_component_write(&codec->component, reg, val);
 }
 EXPORT_SYMBOL_GPL(snd_soc_write);
@@ -269,8 +261,6 @@ int snd_soc_platform_read(struct snd_soc_platform *platform,
 	if (ret < 0)
 		return -1;
 
-	trace_snd_soc_preg_read(platform, reg, val);
-
 	return val;
 }
 EXPORT_SYMBOL_GPL(snd_soc_platform_read);
@@ -278,7 +268,6 @@ EXPORT_SYMBOL_GPL(snd_soc_platform_read);
 int snd_soc_platform_write(struct snd_soc_platform *platform,
 					 unsigned int reg, unsigned int val)
 {
-	trace_snd_soc_preg_write(platform, reg, val);
 	return snd_soc_component_write(&platform->component, reg, val);
 }
 EXPORT_SYMBOL_GPL(snd_soc_platform_write);
Signature · 1 line
1.8.0
maintainer Applied
#27 lore raw

Re: [PATCH v4 5/5] ASoC: Remove ASoC level IO tracing

Quoted 6 lines · Lars-Peter Clausen

The ASoC framework is in the process of migrating all IO operations to regmap. regmap has its own more sophisticated tracing infrastructure for IO operations, which means that the ASoC level IO tracing becomes redundant, hence this patch removes them. There are still a handful of ASoC drivers left that do not use regmap yet, but hopefully the removal of the ASoC IO tracing will be an additional incentive to switch to regmap.

Applied, thanks.