Skip to contentSkip to conversation

DT support for rx51-audio

RFC In review Sebastian Reichel 6 participants 18 messages Oct 27, 2013 – Nov 30, 2013

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

cover DT support for rx51-audio

Hi,

This patchset adds DT support in rx51-audio. I tested it on the Nokia N900 and was able to play sound with aplay using earphones and earspeaker. The Loudspeakers did not work. I don't know the reason.

The patchset consists of 4 patches:

1. convert rx51-audio to snd_soc_register_card()
2. init audio in rx51 platform file
3. add some DT helpers to ASoC core
4. add DT support to rx51-audio

Please note, that the patch is RFC level for now. For example non DT boot does not work, because I did not yet add pdata in boardcode.

Proposed DTS node would look like this:

sound: rx51-audio {
       compatible = "nokia,rx51-audio";

       ti,mcbsp = <&mcbsp2>;
       ti,codec = <&tlv320aic3x>;
       ti,codec_aux = <&tlv320aic3x_aux>;
       ti,headset_amp = <&tpa6130a2>;

       tvout-selection-gpio = <&gpio2 8 GPIO_ACTIVE_HIGH>; /* 40 */
       jack-detection-gpio = <&gpio6 17 GPIO_ACTIVE_HIGH>; /* 177 */
       eci-sw-gpio = <&gpio6 22 GPIO_ACTIVE_HIGH>; /* 182 */
       speaker-amp-gpio = <&twl_gpio 7 GPIO_ACTIVE_HIGH>;
};

-- Sebastian

Pali Rohár (2):
ASoC: omap: rx51: Use snd_soc_register_card
ARM: OMAP: rx51: Register audio device

Sebastian Reichel (2):
ASoC: Allow Aux Codecs to be specified using DT
ASoC: RX-51: Add DT support to sound driver

 .../devicetree/bindings/sound/nokia,rx51.txt       |  28 +++
 .../devicetree/bindings/vendor-prefixes.txt        |   1 +
 arch/arm/mach-omap2/board-rx51-peripherals.c       |  11 ++
 include/sound/rx51.h                               |  18 ++
 include/sound/soc.h                                |  13 +-
 sound/soc/omap/omap-mcbsp.c                        |   5 +-
 sound/soc/omap/omap-mcbsp.h                        |   2 +-
 sound/soc/omap/rx51.c                              | 212 +++++++++++++++------
 sound/soc/soc-core.c                               |  68 +++++--
 9 files changed, 277 insertions(+), 81 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sound/nokia,rx51.txt
 create mode 100644 include/sound/rx51.h
Signature · 1 line
1.8.4.rc3
#1 lore raw

RFC 1/4 ASoC: omap: rx51: Use snd_soc_register_card

From: Pali Rohár <[email protected]>

This patch converts the rx51 ASoC module to use snd_soc_register_card. It also adds module alias to support driver autoloading.

---
 sound/soc/omap/rx51.c | 49 +++++++++++++++++++++++++++++--------------------
 1 file changed, 29 insertions(+), 20 deletions(-)
sound/soc/omap/rx51.c +29 -20
index 611179c..41f26ae 100644
@@ -390,10 +390,9 @@ static struct snd_soc_card rx51_sound_card = {
 	.num_configs = ARRAY_SIZE(rx51_codec_conf),
 };
 
-static struct platform_device *rx51_snd_device;
-
-static int __init rx51_soc_init(void)
+static int rx51_soc_probe(struct platform_device *pdev)
 {
+	struct snd_soc_card *card = &rx51_sound_card;
 	int err;
 
 	if (!machine_is_nokia_rx51() && !of_machine_is_compatible("nokia,omap3-n900"))
@@ -408,22 +407,17 @@ static int __init rx51_soc_init(void)
 	if (err)
 		goto err_gpio_eci_sw;
 
-	rx51_snd_device = platform_device_alloc("soc-audio", -1);
-	if (!rx51_snd_device) {
-		err = -ENOMEM;
-		goto err1;
-	}
-
-	platform_set_drvdata(rx51_snd_device, &rx51_sound_card);
+	card->dev = &pdev->dev;
 
-	err = platform_device_add(rx51_snd_device);
-	if (err)
-		goto err2;
+	err = snd_soc_register_card(card);
+	if (err) {
+		dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", err);
+		goto err_snd;
+	}
 
 	return 0;
-err2:
-	platform_device_put(rx51_snd_device);
-err1:
+err_snd:
+	card->dev = NULL;
 	gpio_free(RX51_ECI_SW_GPIO);
 err_gpio_eci_sw:
 	gpio_free(RX51_TVOUT_SEL_GPIO);
@@ -432,19 +426,34 @@ err_gpio_tvout_sel:
 	return err;
 }
 
-static void __exit rx51_soc_exit(void)
+static int rx51_soc_remove(struct platform_device *pdev)
 {
+	struct snd_soc_card *card = platform_get_drvdata(pdev);
+
 	snd_soc_jack_free_gpios(&rx51_av_jack, ARRAY_SIZE(rx51_av_jack_gpios),
 				rx51_av_jack_gpios);
 
-	platform_device_unregister(rx51_snd_device);
+	snd_soc_unregister_card(card);
+	card->dev = NULL;
+
 	gpio_free(RX51_ECI_SW_GPIO);
 	gpio_free(RX51_TVOUT_SEL_GPIO);
+
+	return 0;
 }
 
-module_init(rx51_soc_init);
-module_exit(rx51_soc_exit);
+static struct platform_driver rx51_soc_driver = {
+	.driver = {
+		.name = "rx51-audio",
+		.owner = THIS_MODULE,
+	},
+	.probe = rx51_soc_probe,
+	.remove = rx51_soc_remove,
+};
+
+module_platform_driver(rx51_soc_driver);
 
 MODULE_AUTHOR("Nokia Corporation");
 MODULE_DESCRIPTION("ALSA SoC Nokia RX-51");
 MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:rx51-audio");
Signature · 1 line
1.8.4.rc3
#4 lore raw

RFC 2/4 ARM: OMAP: rx51: Register audio device

In reply to Sebastian Reichel

From: Pali Rohár <[email protected]>

This patch adds support for the audio chip to the legacy boardcode of the Nokia N900.

---
 arch/arm/mach-omap2/board-rx51-peripherals.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
arch/arm/mach-omap2/board-rx51-peripherals.c +11 -0
index 68dc998..65e3627 100644
@@ -1205,6 +1205,16 @@ error:
 	 */
 }
 
+static struct platform_device rx51_audio_device = {
+	.name	= "rx51-audio",
+	.id	= -1,
+};
+
+static void __init rx51_init_audio(void)
+{
+	platform_device_register(&rx51_audio_device);
+}
+
 static struct tsc2005_platform_data tsc2005_pdata = {
 	.ts_pressure_max	= 2048,
 	.ts_pressure_fudge	= 2,
@@ -1287,6 +1297,7 @@ void __init rx51_peripherals_init(void)
 	gpmc_onenand_init(board_onenand_data);
 	board_smc91x_init();
 	rx51_add_gpio_keys();
+	rx51_init_audio();
 	rx51_init_wl1251();
 	rx51_init_tsc2005();
 	rx51_init_si4713();
Signature · 1 line
1.8.4.rc3
#6 lore raw

RFC 3/4 ASoC: Allow Aux Codecs to be specified using DT

In reply to Sebastian Reichel

This patch adds support for specifying auxiliary codecs and codec configuration via device tree phandles.

This change adds new fields to snd_soc_aux_dev and snd_soc_codec_conf and adds support for the changes to SoC core methods.

---
 include/sound/soc.h  | 13 +++++++++-
 sound/soc/soc-core.c | 68 ++++++++++++++++++++++++++++++++++++----------------
 2 files changed, 59 insertions(+), 22 deletions(-)
include/sound/soc.h +12 -1
index d22cb0a..00b25a8 100644
@@ -937,7 +937,12 @@ struct snd_soc_dai_link {
 };
 
 struct snd_soc_codec_conf {
+	/*
+	 * specify device either by device name, or by
+	 * DT/OF node, but not both.
+	 */
 	const char *dev_name;
+	const struct device_node *of_node;
 
 	/*
 	 * optional map of kcontrol, widget and path name prefixes that are
@@ -954,7 +959,13 @@ struct snd_soc_codec_conf {
 
 struct snd_soc_aux_dev {
 	const char *name;		/* Codec name */
-	const char *codec_name;		/* for multi-codec */
+
+	/*
+	 * specify multi-codec either by device name, or by
+	 * DT/OF node, but not both.
+	 */
+	const char *codec_name;
+	const struct device_node *codec_of_node;
 
 	/* codec/machine specific init - e.g. add machine controls */
 	int (*init)(struct snd_soc_dapm_context *dapm);
sound/soc/soc-core.c +47 -21

106 lines not on this page · raw message

Signature · 1 line
1.8.4.rc3
#12 lore raw

RFC 4/4 ASoC: RX-51: Add DT support to sound driver

In reply to Sebastian Reichel

This patch adds device tree support to the Nokia N900 audio driver. It also removes GPIO defines and gets them from platform data / device tree, since some GPIO numbers may be different with DT boot.

The binding also changes a helper function in omap-mcbsp, which is currently only used by the Nokia N900. This change is needed, because DT instanced omap-mcbsp driver has no valid id assigned.

Last but not least the DT binding is documented.

---
 .../devicetree/bindings/sound/nokia,rx51.txt       |  28 ++++
 .../devicetree/bindings/vendor-prefixes.txt        |   1 +
 include/sound/rx51.h                               |  18 +++
 sound/soc/omap/omap-mcbsp.c                        |   5 +-
 sound/soc/omap/omap-mcbsp.h                        |   2 +-
 sound/soc/omap/rx51.c                              | 175 ++++++++++++++++-----
 6 files changed, 184 insertions(+), 45 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sound/nokia,rx51.txt
 create mode 100644 include/sound/rx51.h
Documentation/devicetree/bindings/sound/nokia,rx51.txt new file +28 -0
new file mode 100644
index 0000000..4f985ca
@@ -0,0 +1,28 @@
+* Nokia N900 audio setup
+
+Required properties:
+- compatible: "nokia,rx51-audio"
+- ti,mcbsp: phandle for the McBSP node
+- ti,codec: phandle for the main TLV320AIC3X node
+- ti,codec_aux: phandle for the main TLV320AIC3X auxiliary node
+- ti,headset_amp: phandle for the TPA6130A2 node
+- tvout-selection-gpio: GPIO for tvout selection
+- jack-detection-gpio: GPIO for jack detection
+- eci-sw-gpio: GPIO for ECI SW
+- speaker-amp-gpio: GPIO for Speaker Amp
+
+Example:
+
+sound {
+	compatible = "nokia,rx51-audio";
+
+	ti,mcbsp = <&mcbsp2>;
+	ti,codec = <&tlv320aic3x>;
+	ti,codec_aux = <&tlv320aic3x_aux>;
+	ti,headset_amp = <&tpa6130a2>;
+
+	tvout-selection-gpio = <&gpio2 8 GPIO_ACTIVE_HIGH>; /* 40 */
+	jack-detection-gpio = <&gpio6 17 GPIO_ACTIVE_HIGH>; /* 177 */
+	eci-sw-gpio = <&gpio6 22 GPIO_ACTIVE_HIGH>; /* 182 */
+	speaker-amp-gpio = <&twl_gpio 7 GPIO_ACTIVE_HIGH>;
+};
Documentation/devicetree/bindings/vendor-prefixes.txt +1 -0
index 2956800..2cc3dad 100644
@@ -42,6 +42,7 @@ microchip	Microchip Technology Inc.
 mosaixtech	Mosaix Technologies, Inc.
 national	National Semiconductor
 nintendo	Nintendo
+nokia	Nokia Corporation
 nvidia	NVIDIA
 nxp	NXP Semiconductors
 onnn	ON Semiconductor Corp.
include/sound/rx51.h new file +18 -0
new file mode 100644
index 0000000..190d745
@@ -0,0 +1,18 @@
+/*
+ * Platform data for Nokia RX-51 SoC audio
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#ifndef __RX51_AUDIO_H__
+#define __RX51_AUDIO_H__
+
+struct rx51_audio_pdata {
+	int tvout_selection_gpio;
+	int jack_detection_gpio;
+	int eci_sw_gpio;
+	int speaker_amp_gpio;
+};
+
+#endif
sound/soc/omap/omap-mcbsp.c +3 -2
index 6c19bba..f88e31e 100644
@@ -691,7 +691,7 @@ OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP" #port " Sidetone Channel 1 Volume", \
 OMAP_MCBSP_ST_CONTROLS(2);
 OMAP_MCBSP_ST_CONTROLS(3);
 
-int omap_mcbsp_st_add_controls(struct snd_soc_pcm_runtime *rtd)
+int omap_mcbsp_st_add_controls(struct snd_soc_pcm_runtime *rtd, int port_id)
 {
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai);
@@ -701,7 +701,7 @@ int omap_mcbsp_st_add_controls(struct snd_soc_pcm_runtime *rtd)
 		return 0;
 	}
 
-	switch (mcbsp->id) {
+	switch (port_id) {
 	case 2: /* McBSP 2 */
 		return snd_soc_add_dai_controls(cpu_dai,
 					omap_mcbsp2_st_controls,
@@ -711,6 +711,7 @@ int omap_mcbsp_st_add_controls(struct snd_soc_pcm_runtime *rtd)
 					omap_mcbsp3_st_controls,
 					ARRAY_SIZE(omap_mcbsp3_st_controls));
 	default:
+		dev_err(mcbsp->dev, "Port %d not supported\n", port_id);
 		break;
 	}
 
sound/soc/omap/omap-mcbsp.h +1 -1
index ba8386a..2e3369c 100644
@@ -39,6 +39,6 @@ enum omap_mcbsp_div {
 	OMAP_MCBSP_CLKGDV,		/* Sample rate generator divider */
 };
 
-int omap_mcbsp_st_add_controls(struct snd_soc_pcm_runtime *rtd);
+int omap_mcbsp_st_add_controls(struct snd_soc_pcm_runtime *rtd, int port_id);
 
 #endif
sound/soc/omap/rx51.c +133 -42

281 lines not on this page · raw message

Signature · 1 line
1.8.4.rc3
#13 lore raw

Re: [RFC 4/4] ASoC: RX-51: Add DT support to sound driver

Quoted 28 lines · Sebastian Reichel

This patch adds device tree support to the Nokia N900 audio driver. It also removes GPIO defines and gets them from platform data / device tree, since some GPIO numbers may be different with DT boot.

The binding also changes a helper function in omap-mcbsp, which is currently only used by the Nokia N900. This change is needed, because DT instanced omap-mcbsp driver has no valid id assigned.

Last but not least the DT binding is documented.

---

.../devicetree/bindings/sound/nokia,rx51.txt       |  28 ++++
.../devicetree/bindings/vendor-prefixes.txt        |   1 +
include/sound/rx51.h                               |  18 +++
sound/soc/omap/omap-mcbsp.c                        |   5 +-
sound/soc/omap/omap-mcbsp.h                        |   2 +-
sound/soc/omap/rx51.c                              | 175 ++++++++++++++++-----
6 files changed, 184 insertions(+), 45 deletions(-)

create mode 100644 Documentation/devicetree/bindings/sound/nokia,rx51.txt create mode 100644 include/sound/rx51.h

Documentation/devicetree/bindings/sound/nokia,rx51.txt new file +0 -0
new file mode 100644
index 0000000..4f985ca

Documentation/devicetree/bindings/sound/nokia,rx51.txt line 1

Quoted 1 line
Documentation/devicetree/bindings/sound/nokia,rx51.txt new file +1 -0
@@ -0,0 +1,28 @@
+* Nokia N900 audio setup

This needs more description

Documentation/devicetree/bindings/sound/nokia,rx51.txt line 8

Quoted 7 lines
Documentation/devicetree/bindings/sound/nokia,rx51.txt new file +7 -0
+
+Required properties:
+- compatible: "nokia,rx51-audio"
+- ti,mcbsp: phandle for the McBSP node
+- ti,codec: phandle for the main TLV320AIC3X node
+- ti,codec_aux: phandle for the main TLV320AIC3X auxiliary node
+- ti,headset_amp: phandle for the TPA6130A2 node

Hmm, I don't think these should be ti prefixed but nokia.

Documentation/devicetree/bindings/sound/nokia,rx51.txt line 12

Quoted 4 lines
Documentation/devicetree/bindings/sound/nokia,rx51.txt new file +4 -0
+- tvout-selection-gpio: GPIO for tvout selection
+- jack-detection-gpio: GPIO for jack detection
+- eci-sw-gpio: GPIO for ECI SW
+- speaker-amp-gpio: GPIO for Speaker Amp

why aren't the gpio properties vendor prefixed?

Quoted 16 lines
Documentation/devicetree/bindings/sound/nokia,rx51.txt new file +16 -0
+
+Example:
+
+sound {
+	compatible = "nokia,rx51-audio";
+
+	ti,mcbsp = <&mcbsp2>;
+	ti,codec = <&tlv320aic3x>;
+	ti,codec_aux = <&tlv320aic3x_aux>;
+	ti,headset_amp = <&tpa6130a2>;
+
+	tvout-selection-gpio = <&gpio2 8 GPIO_ACTIVE_HIGH>; /* 40 */
+	jack-detection-gpio = <&gpio6 17 GPIO_ACTIVE_HIGH>; /* 177 */
+	eci-sw-gpio = <&gpio6 22 GPIO_ACTIVE_HIGH>; /* 182 */
+	speaker-amp-gpio = <&twl_gpio 7 GPIO_ACTIVE_HIGH>;
+};
Signature · 2 lines
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
maintainer
#2 lore raw

Re: [RFC 1/4] ASoC: omap: rx51: Use snd_soc_register_card

In reply to Sebastian Reichel
Quoted 5 lines · Sebastian Reichel

From: Pali Rohár <[email protected]>

This patch converts the rx51 ASoC module to use
snd_soc_register_card. It also adds module alias
to support driver autoloading.

You should really use devm_snd_soc_register_card() here.

maintainer
#7 lore raw

Re: [RFC 3/4] ASoC: Allow Aux Codecs to be specified using DT

In reply to Sebastian Reichel
Quoted 2 lines · Sebastian Reichel

This patch adds support for specifying auxiliary codecs and codec configuration via device tree phandles.

This doesn't apply against current git, please check and resend. Please also consider your CC list more carefully, there's an awful lot of people on this...

#8 lore raw

Re: [RFC 3/4] ASoC: Allow Aux Codecs to be specified using DT

Quoted 5 lines · Mark Brown
Quoted 2 lines · Sebastian Reichel

This patch adds support for specifying auxiliary codecs and codec configuration via device tree phandles.

This doesn't apply against current git, please check and resend.

Can you give me a git url to rebase against? I used current git master from torvalds.

Quoted 2 lines

Please also consider your CC list more carefully, there's an awful lot of people on this...

I added exactly those recipients, that were returned by ./scripts/get_maintainer.pl for the patchset.

The list of involved people is quite long, because the patchset touches devicetree, documentation, boardcode, asoc and the specific driver.

-- Sebastian

maintainer
#9 lore raw

Re: [RFC 3/4] ASoC: Allow Aux Codecs to be specified using DT

Quoted 6 lines · Sebastian Reichel
Quoted 1 line · Mark Brown

This doesn't apply against current git, please check and resend.

Can you give me a git url to rebase against? I used current git master from torvalds.

From MAINTAINERS:

SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEMENT (ASoC)

M:      Liam Girdwood <[email protected]>
M:      Mark Brown <[email protected]>
T:      git git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
L:      [email protected] (moderated for non-subscribers)
W:      http://alsa-project.org/main/index.php/ASoC
S:      Supported
F:      Documentation/sound/alsa/soc/
F:      sound/soc/
F:      include/sound/soc*
Quoted 9 lines
Quoted 2 lines

Please also consider your CC list more carefully, there's an awful lot of people on this...

I added exactly those recipients, that were returned by ./scripts/get_maintainer.pl for the patchset.

The list of involved people is quite long, because the patchset touches devicetree, documentation, boardcode, asoc and the specific driver.

You shouldn't be using the output of get_maintainers directly, you should understand why everyone it's including is in the list and if they really should be. This is especially important if you are sending a series that covers many subsystems, or nested subsystems.

#14 lore raw

Re: [RFC 4/4] ASoC: RX-51: Add DT support to sound driver

In reply to Sebastian Reichel
Quoted 2 lines · Sebastian Reichel
+- eci-sw-gpio: GPIO for ECI SW
+- speaker-amp-gpio: GPIO for Speaker Amp

Can you please spell out the acronyms? ECI? SW? Amp?

I guess SW=switch, Amp=amplifier, but ECI beats me.

Yours,
Linus Walleij

maintainer
#15 lore raw

Re: [RFC 4/4] ASoC: RX-51: Add DT support to sound driver

Quoted 8 lines · Linus Walleij
Quoted 2 lines · Sebastian Reichel
+- eci-sw-gpio: GPIO for ECI SW
+- speaker-amp-gpio: GPIO for Speaker Amp

Can you please spell out the acronyms? ECI? SW? Amp?

I guess SW=switch, Amp=amplifier, but ECI beats me.

ECI is the name of Nokia's accesory interface spec, it should be as clear as GPIO for anyone working on Nokia hardware (which this is).

Reviewed-by on v1 1/4
#3 lore raw

Re: [RFC 1/4] ASoC: omap: rx51: Use snd_soc_register_card

In reply to Sebastian Reichel
Quoted 8 lines · Sebastian Reichel

From: Pali Rohár <[email protected]>

This patch converts the rx51 ASoC module to use
snd_soc_register_card. It also adds module alias
to support driver autoloading.

Signature · 6 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#5 lore raw

Re: [RFC 2/4] ARM: OMAP: rx51: Register audio device

In reply to Sebastian Reichel

Hi!

Quoted 4 lines

From: Pali Rohár <[email protected]>

This patch adds support for the audio chip to the legacy boardcode of the Nokia N900.

Quoted 2 lines · you

For example non DT boot
does not work, because I did not yet add pdata in boardcode.

So, perhaps we don't need this patch for now and can rely only do audio on device-tree-enabled configurations?

Thanks,
Pavel

Signature · 6 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#10 lore raw

Re: [RFC 3/4] ASoC: Allow Aux Codecs to be specified using DT

In reply to Sebastian Reichel

Hi!

Quoted 18 lines

This patch adds support for specifying auxiliary codecs and codec configuration via device tree phandles.

This change adds new fields to snd_soc_aux_dev and snd_soc_codec_conf and adds support for the changes to SoC core methods.

---
 include/sound/soc.h  | 13 +++++++++-
 sound/soc/soc-core.c | 68 ++++++++++++++++++++++++++++++++++++----------------
 2 files changed, 59 insertions(+), 22 deletions(-)
sound/soc/soc-core.c +1 -0
@@ -1527,15 +1529,23 @@ static void soc_unregister_ac97_dai_link(struct snd_soc_codec *codec)
 static int soc_check_aux_dev(struct snd_soc_card *card, int num)
 {
 	struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num];
+	const char *codecname = aux_dev->codec_name;
 	struct snd_soc_codec *codec;

sound/soc/soc-core.c static void soc_unregister_ac97_dai_link(struct snd_soc_codec *codec) · line 1542

Quoted 10 lines
sound/soc/soc-core.c +5 -1
 
 	/* find CODEC from registered CODECs*/
 	list_for_each_entry(codec, &codec_list, list) {
-		if (!strcmp(codec->name, aux_dev->codec_name))
+		if (aux_dev->codec_of_node &&
+				codec->dev->of_node == aux_dev->codec_of_node)
+			return 0;
+		if (aux_dev->codec_name &&
+				!strcmp(codec->name, aux_dev->codec_name))
 			return 0;

You can use codecname here.

Quoted 4 lines
sound/soc/soc-core.c +0 -4
-		if (!strcmp(codec->name, aux_dev->codec_name)) {
-			if (codec->probed) {
-				dev_err(codec->dev,
-					"ASoC: codec already probed");

sound/soc/soc-core.c static int soc_probe_aux_dev(struct snd_soc_card *card, int num) · line 1567

Quoted 10 lines
sound/soc/soc-core.c +6 -4
-				ret = -EBUSY;
-				goto out;
-			}
-			goto found;
+		if (aux_dev->codec_of_node &&
+				codec->dev->of_node != aux_dev->codec_of_node)
+			continue;
+		if (aux_dev->codec_name &&
+				strcmp(codec->name, aux_dev->codec_name))
+			continue;

So in (error) case of ! aux_dev->codec_of_node && ! aux_dev->codec_name we match first possible codec?

Given code similarity between this and the one above, should there be helper function that does the comparison (or even walks the list)?

Quoted 9 lines
sound/soc/soc-core.c +0 -5
@@ -1644,12 +1663,19 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
 		/* check to see if we need to override the compress_type */
 		for (i = 0; i < card->num_configs; ++i) {
 			codec_conf = &card->codec_conf[i];
-			if (!strcmp(codec->name, codec_conf->dev_name)) {
-				compress_type = codec_conf->compress_type;
-				if (compress_type && compress_type
-				    != codec->compress_type)
-					break;

sound/soc/soc-core.c static int snd_soc_instantiate_card(struct snd_soc_card *card) · line 1674

Quoted 10 lines
sound/soc/soc-core.c +9 -1
-			}
+
+			if (codec_conf->of_node &&
+				codec->dev->of_node != codec_conf->of_node)
+				continue;
+
+			if (codec_conf->dev_name &&
+				strcmp(codec->name, codec_conf->dev_name))
+				continue;
+

..third copy of codec matching.

Thanks for doing all the good work,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#16 lore raw

Re: [RFC 4/4] ASoC: RX-51: Add DT support to sound driver

In reply to Sebastian Reichel

Hi!

Quoted 1 line

This patch adds device tree support to the Nokia N900 audio driver.

Note, N900 audio driver.

Quoted 1 line

+- compatible: "nokia,rx51-audio"

Still, it is rx51-audio. If it is feasible, could we move away from rx51 naming and into n900 naming that is familiar to mere humans?

We can rename the sources later, but I guess we should get dts binding right first time...
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#11 lore raw

Re: [RFC 3/4] ASoC: Allow Aux Codecs to be specified using DT

In reply to Pavel Machek

Hi!

Quoted 5 lines

So in (error) case of ! aux_dev->codec_of_node && ! aux_dev->codec_name we match first possible codec?

Given code similarity between this and the one above, should there be helper function that does the comparison (or even walks the list)?

Something like this? soc_probe_aux_dev now looks better... (Only compile tested).

sound/soc/soc-core.c +30 -34
index 392f479..3097e17 100644
@@ -1526,69 +1526,65 @@ static void soc_unregister_ac97_dai_link(struct snd_soc_codec *codec)
 }
 #endif
 
-static int soc_check_aux_dev(struct snd_soc_card *card, int num)
+struct snd_soc_codec *soc_find_matching_codec(struct snd_soc_card *card, int num)
 {
 	struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num];
-	const char *codecname = aux_dev->codec_name;
 	struct snd_soc_codec *codec;
 
-	/* find CODEC from registered CODECs*/
+	/* find CODEC from registered CODECs */
 	list_for_each_entry(codec, &codec_list, list) {
-		if (aux_dev->codec_of_node &&
-				codec->dev->of_node == aux_dev->codec_of_node)
-			return 0;
-		if (aux_dev->codec_name &&
-				!strcmp(codec->name, aux_dev->codec_name))
-			return 0;
+		if (aux_dev->codec_of_node && 
+		    (codec->dev->of_node != aux_dev->codec_of_node))
+			continue;
+		if (aux_dev->codec_name && strcmp(codec->name, aux_dev->codec_name))
+			continue;
+		return codec;
 	}
+	return NULL;
+}
 
+static int soc_check_aux_dev(struct snd_soc_card *card, int num)
+{
+	struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num];
+	const char *codecname = aux_dev->codec_name;
+	struct snd_soc_codec *codec = soc_find_matching_codec(card, num);
+
+	if (codec)
+		return 0;
 	if (aux_dev->codec_of_node)
 		codecname = of_node_full_name(aux_dev->codec_of_node);
 
 	dev_err(card->dev, "ASoC: %s not registered\n", codecname);
-
 	return -EPROBE_DEFER;
 }
 
+
 static int soc_probe_aux_dev(struct snd_soc_card *card, int num)
 {
 	struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num];
-	struct snd_soc_codec *codec;
 	const char *codecname = aux_dev->codec_name;
 	int ret = -ENODEV;
+	struct snd_soc_codec *codec = soc_find_matching_codec(card, num);
 
-	/* find CODEC from registered CODECs*/
-	list_for_each_entry(codec, &codec_list, list) {
-		if (aux_dev->codec_of_node &&
-				codec->dev->of_node != aux_dev->codec_of_node)
-			continue;
-		if (aux_dev->codec_name &&
-				strcmp(codec->name, aux_dev->codec_name))
-			continue;
+	if (!codec) {
+		if (aux_dev->codec_of_node)
+			codecname = of_node_full_name(aux_dev->codec_of_node);
 
-		if (codec->probed) {
-			dev_err(codec->dev, "ASoC: codec already probed");
-			ret = -EBUSY;
-			goto out;
-		}
-		goto found;
+		/* codec not found */
+		dev_err(card->dev, "ASoC: codec %s not found", codecname);
+		return -EPROBE_DEFER;
 	}
 
-	if (aux_dev->codec_of_node)
-		codecname = of_node_full_name(aux_dev->codec_of_node);
-
-	/* codec not found */
-	dev_err(card->dev, "ASoC: codec %s not found", codecname);
-	return -EPROBE_DEFER;
+	if (codec->probed) {
+		dev_err(codec->dev, "ASoC: codec already probed");
+		return -EBUSY;
+	}
 
-found:
 	ret = soc_probe_codec(card, codec);
 	if (ret < 0)
 		return ret;
 
 	ret = soc_post_component_init(card, codec, num, 1);
-
-out:
 	return ret;
 }
 
Signature · 6 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#17 lore raw

Re: [RFC 4/4] ASoC: RX-51: Add DT support to sound driver

In reply to Pavel Machek

Hi

Quoted 6 lines · Pavel Machek

Hi!

Quoted 1 line

This patch adds device tree support to the Nokia N900 audio driver.

Note, N900 audio driver.

Quoted 7 lines
Quoted 1 line

+- compatible: "nokia,rx51-audio"

Still, it is rx51-audio. If it is feasible, could we move away from rx51 naming and into n900 naming that is familiar to mere humans?

We can rename the sources later, but I guess we should get dts binding right first time...

Sorry the long response. I definitely would like n900 naming more in dts.

History is that the basic board file for N900 went to mainline before sales started and used the hw name in sources and Kconfig. Audio machine driver then followed the same rx51 hw naming scheme with rest of sources.

Signature · 1 line
Jarkko