Skip to contentSkip to conversation

ASoc: wm8580: Add the wm8581 codec to the driver

PATCH Superseded Matt Flax 3 participants 7 messages Oct 18, 2016 – Oct 24, 2016

Subsystems (4)
lore
Share & tools
lore

Matt Flax

author
#0 lore raw

PATCH 1/1 ASoc: wm8580: Add the wm8581 codec to the driver

This patch adds support for the wm8581 codec to the wm8580 driver. The wm8581 codec hardware adds a fourth DAC and otherwise is compatible with the wm8580 codec.

of_device_id data is used to allow the driver to select the suitable DAC count specified in the device tree codec selection. The wm8580_driver_data struct is used to store the number of DACs.

The snd_soc_dai_driver no longer lists the channels_max for the playback substream. This variable is set during the i2c probe from the of_device_id supplied wm8580_driver_data struct.

With knowledge of the number of DACs in use, the DAC4 controls, widgets and routes are added as required for DAC4.

The device tree documentation for the wm8580 is altered to list the wm8581 codec support, as is the Kconfig file.

---
 Documentation/devicetree/bindings/sound/wm8580.txt |  4 +-
 sound/soc/codecs/Kconfig                           |  2 +-
 sound/soc/codecs/wm8580.c                          | 98 ++++++++++++++++++++--
 3 files changed, 92 insertions(+), 12 deletions(-)
Documentation/devicetree/bindings/sound/wm8580.txt +2 -2
index 7d9821f..78fce9b 100644
@@ -1,10 +1,10 @@
-WM8580 audio CODEC
+WM8580 and WM8581 audio CODEC
 
 This device supports I2C only.
 
 Required properties:
 
-  - compatible : "wlf,wm8580"
+  - compatible : "wlf,wm8580", "wlf,wm8581"
 
   - reg : the I2C address of the device.
 
sound/soc/codecs/Kconfig +1 -1
index c67667b..199bec8 100644
@@ -914,7 +914,7 @@ config SND_SOC_WM8523
 	depends on I2C
 
 config SND_SOC_WM8580
-	tristate "Wolfson Microelectronics WM8523 CODEC"
+	tristate "Wolfson Microelectronics WM8580 and WM8581 CODECs"
 	depends on I2C
 
 config SND_SOC_WM8711
sound/soc/codecs/wm8580.c +89 -9

200 lines not on this page · raw message

Signature · 1 line
2.7.4
#1 lore raw
Quoted 12 lines · Matt Flax

This patch adds support for the wm8581 codec to the wm8580 driver. The wm8581 codec hardware adds a fourth DAC and otherwise is compatible with the wm8580 codec.

of_device_id data is used to allow the driver to select the suitable DAC count specified in the device tree codec selection. The wm8580_driver_data struct is used to store the number of DACs.

The snd_soc_dai_driver no longer lists the channels_max for the playback substream. This variable is set during the i2c probe from the of_device_id supplied wm8580_driver_data struct.

Quoted 8 lines

With knowledge of the number of DACs in use, the DAC4 controls, widgets and routes are added as required for DAC4.

The device tree documentation for the wm8580 is altered to list the wm8581 codec support, as is the Kconfig file.

---

When doing a respin of a patch its usually considered good practice to do something like [PATCH v2] in the subject line, lets people clearly see that its a new version not a resend.

Quoted 4 lines
 Documentation/devicetree/bindings/sound/wm8580.txt |  4 +-
 sound/soc/codecs/Kconfig                           |  2 +-
 sound/soc/codecs/wm8580.c                          | 98 ++++++++++++++++++++--
 3 files changed, 92 insertions(+), 12 deletions(-)

<snip>

sound/soc/codecs/wm8580.c line 72

Quoted 6 lines
sound/soc/codecs/wm8580.c +2 -0
@@ -65,6 +68,8 @@
 #define WM8580_DIGITAL_ATTENUATION_DACR2     0x17
 #define WM8580_DIGITAL_ATTENUATION_DACL3     0x18
 #define WM8580_DIGITAL_ATTENUATION_DACR3     0x19
+#define WM8580_DIGITAL_ATTENUATION_DACL4     0x1A
+#define WM8580_DIGITAL_ATTENUATION_DACR4     0x1B

Apologies my fault for still not being clear these two new defines would still be best called WM8581...

<snip>

sound/soc/codecs/wm8580.c static int wm8580_set_bias_level(struct snd_soc_codec *codec, · line 860

Quoted 8 lines
sound/soc/codecs/wm8580.c +8 -0
+static int wm8580_playback_startup(struct snd_pcm_substream *substream,
+			   struct snd_soc_dai *dai)
+{
+	struct snd_soc_codec *codec = dai->codec;
+	struct wm8580_priv *wm8580 = snd_soc_codec_get_drvdata(codec);
+
+	return snd_pcm_hw_constraint_single(substream->runtime,
+		SNDRV_PCM_HW_PARAM_CHANNELS, wm8580->drvdata->num_dacs * 2);

Won't this limit us to exactly num_dacs * 2 channels? I would have expected a contraint_minmax, I haven't checked the core code but would be good to know you have tested smaller numbers of channels and they are working. Bearing in mind that some user-space applications will do things like pad out to the number of channels the hardware claims to require. For example for aplay I believe -v will show you if it does any conversion and --disable-channels will stop it attempting to convert the number of channels.

Apart from those very small comments this all looks fine to me.

Thanks,
Charles

author
#2 lore raw
Quoted 16 lines · Charles Keepax
Quoted 15 lines · Matt Flax

This patch adds support for the wm8581 codec to the wm8580 driver. The wm8581 codec hardware adds a fourth DAC and otherwise is compatible with the wm8580 codec.

of_device_id data is used to allow the driver to select the suitable DAC count specified in the device tree codec selection. The wm8580_driver_data struct is used to store the number of DACs.

The snd_soc_dai_driver no longer lists the channels_max for the playback substream. This variable is set during the i2c probe from the of_device_id supplied wm8580_driver_data struct.

With knowledge of the number of DACs in use, the DAC4 controls, widgets and routes are added as required for DAC4.

Quoted 8 lines
Quoted 5 lines

The device tree documentation for the wm8580 is altered to list the wm8581 codec support, as is the Kconfig file.

---

When doing a respin of a patch its usually considered good practice to do something like [PATCH v2] in the subject line, lets people clearly see that its a new version not a resend.

OK - I see that I should use in-reply-to with the message id next time.

Quoted 25 lines
Quoted 4 lines
  Documentation/devicetree/bindings/sound/wm8580.txt |  4 +-
  sound/soc/codecs/Kconfig                           |  2 +-
  sound/soc/codecs/wm8580.c                          | 98 ++++++++++++++++++++--
  3 files changed, 92 insertions(+), 12 deletions(-)

<snip>

sound/soc/codecs/wm8580.c line 72

Quoted 6 lines
sound/soc/codecs/wm8580.c +2 -0
@@ -65,6 +68,8 @@
  #define WM8580_DIGITAL_ATTENUATION_DACR2     0x17
  #define WM8580_DIGITAL_ATTENUATION_DACL3     0x18
  #define WM8580_DIGITAL_ATTENUATION_DACR3     0x19
+#define WM8580_DIGITAL_ATTENUATION_DACL4     0x1A
+#define WM8580_DIGITAL_ATTENUATION_DACR4     0x1B

Apologies my fault for still not being clear these two new defines would still be best called WM8581...

<snip>

sound/soc/codecs/wm8580.c static int wm8580_set_bias_level(struct snd_soc_codec *codec, · line 860

Quoted 8 lines
sound/soc/codecs/wm8580.c +8 -0
+static int wm8580_playback_startup(struct snd_pcm_substream *substream,
+			   struct snd_soc_dai *dai)
+{
+	struct snd_soc_codec *codec = dai->codec;
+	struct wm8580_priv *wm8580 = snd_soc_codec_get_drvdata(codec);
+
+	return snd_pcm_hw_constraint_single(substream->runtime,
+		SNDRV_PCM_HW_PARAM_CHANNELS, wm8580->drvdata->num_dacs * 2);

Won't this limit us to exactly num_dacs * 2 channels? I would have expected a contraint_minmax, I haven't checked the core

Quoted 8 lines

code but would be good to know you have tested smaller numbers of channels and they are working. Bearing in mind that some user-space applications will do things like pad out to the number of channels the hardware claims to require. For example for aplay I believe -v will show you if it does any conversion and --disable-channels will stop it attempting to convert the number of channels.
Apart from those very small comments this all looks fine to me.

OK, I will use minmax to fix this problem ... I didn't see it at first, thanks for pointing it out.

Matt

Quoted 3 lines

Thanks,
Charles

author
#3 lore raw

PATCH v3 1/1 ASoc: wm8580: Add the wm8581 codec to the driver

In reply to Matt Flax

This patch adds support for the wm8581 codec to the wm8580 driver. The wm8581 codec hardware adds a fourth DAC and otherwise is compatible with the wm8580 codec.

of_device_id data is used to allow the driver to select the suitable DAC count specified in the device tree codec selection. The wm8580_driver_data struct is used to store the number of DACs.

The snd_soc_dai_driver no longer lists the channels_max for the playback substream. This variable is set during the i2c probe from the of_device_id supplied wm8580_driver_data struct.

With knowledge of the number of DACs in use, the DAC4 controls, widgets and routes are added as required for DAC4.

The device tree documentation for the wm8580 is altered to list the wm8581 codec support, as is the Kconfig file.

---
 Documentation/devicetree/bindings/sound/wm8580.txt |  4 +-
 sound/soc/codecs/Kconfig                           |  2 +-
 sound/soc/codecs/wm8580.c                          | 98 ++++++++++++++++++++--
 3 files changed, 92 insertions(+), 12 deletions(-)
Documentation/devicetree/bindings/sound/wm8580.txt +2 -2
index 7d9821f..78fce9b 100644
@@ -1,10 +1,10 @@
-WM8580 audio CODEC
+WM8580 and WM8581 audio CODEC
 
 This device supports I2C only.
 
 Required properties:
 
-  - compatible : "wlf,wm8580"
+  - compatible : "wlf,wm8580", "wlf,wm8581"
 
   - reg : the I2C address of the device.
 
sound/soc/codecs/Kconfig +1 -1
index c67667b..199bec8 100644
@@ -914,7 +914,7 @@ config SND_SOC_WM8523
 	depends on I2C
 
 config SND_SOC_WM8580
-	tristate "Wolfson Microelectronics WM8523 CODEC"
+	tristate "Wolfson Microelectronics WM8580 and WM8581 CODECs"
 	depends on I2C
 
 config SND_SOC_WM8711
sound/soc/codecs/wm8580.c +89 -9

200 lines not on this page · raw message

Signature · 1 line
2.7.4
Reviewed-by on v3 1/1
#4 lore raw
Quoted 12 lines · Matt Flax

This patch adds support for the wm8581 codec to the wm8580 driver. The wm8581 codec hardware adds a fourth DAC and otherwise is compatible with the wm8580 codec.

of_device_id data is used to allow the driver to select the suitable DAC count specified in the device tree codec selection. The wm8580_driver_data struct is used to store the number of DACs.

The snd_soc_dai_driver no longer lists the channels_max for the playback substream. This variable is set during the i2c probe from the of_device_id supplied wm8580_driver_data struct.

Quoted 8 lines

With knowledge of the number of DACs in use, the DAC4 controls, widgets and routes are added as required for DAC4.

The device tree documentation for the wm8580 is altered to list the wm8581 codec support, as is the Kconfig file.

---

Looks good to me.

Thanks,
Charles

maintainer
#5 lore raw
In reply to Matt Flax
Quoted 2 lines · Matt Flax

This patch adds support for the wm8581 codec to the wm8580 driver. The wm8581 codec hardware adds a fourth DAC and otherwise is

Please don't post new patches in reply to old ones, it makes it hard to follow what's going on and which versions are current.

maintainer
#6 lore raw
In reply to Matt Flax
Quoted 3 lines · Matt Flax

This patch adds support for the wm8581 codec to the wm8580 driver. The wm8581 codec hardware adds a fourth DAC and otherwise is compatible with the wm8580 codec.

Also:

Please submit patches using subject lines reflecting the style for the subsystem. This makes it easier for people to identify relevant patches. Look at what existing commits in the area you're changing are doing and make sure your subject lines visually resemble what they're doing.