ASoC: omap-mcpdm: New McPDM driver
v2 cover ASoC: omap-mcpdm: New McPDM driver
Hello Mark, Liam,
I tried to address the comments regarding to version 1 of the new McPDM driver:
http://mailman.alsa-project.org/pipermail/alsa-devel/2011-July/041690.html
The omap hwmod conversion part of the v1 series has been sent as part of the fixup series for 3.1 to make basic audio work out of box.
This series is aimed for 3.2 due to the scale of the change.
I tried to split patch 2, but I did not managed to find an incremental path from the old driver to the new one.
I have updated the commit message for patch 2 to explain the reasoning behind the rewritten driver, so it can be easily looked up.
Notable changes since v1:
- delayed_work from the new driver has been removed, and replaced with a DAPM_SUPPLY widget. This widget need to be connected to DAC/ADC of the codec by the machine driver in order to have the correct sequence for power off.
The first patch adds private_data pointer for dapm widgets. This private_data can be used to add widget specific data to any widget. I think this can be handy for others as well in the future.
- Full duplex audio in legacy mode has been fixed, so we can run arecord | aplay
This series depends on the McPDM fixup patches:
http://mailman.alsa-project.org/pipermail/alsa-devel/2011-August/042401.html
Peter
PS: to make the review easier, I have asked git format-patch to treat the change as rewrite.
---
Misael Lopez Cruz (1):
ASoC: omap-mcpdm: Replace legacy driver
Peter Ujfalusi (1):
ASoC: DAPM: Add private data pointer for DAPM widget
include/sound/soc-dapm.h | 1 + sound/soc/omap/Makefile | 2 +- sound/soc/omap/mcpdm.c | 472 ------------------------- sound/soc/omap/mcpdm.h | 152 -------- sound/soc/omap/omap-mcpdm.c | 823 ++++++++++++++++++++++++++++--------------- sound/soc/omap/omap-mcpdm.h | 97 +++++ sound/soc/omap/sdp4430.c | 14 +- 7 files changed, 656 insertions(+), 905 deletions(-) delete mode 100644 sound/soc/omap/mcpdm.c delete mode 100644 sound/soc/omap/mcpdm.h rewrite sound/soc/omap/omap-mcpdm.c (46%) create mode 100644 sound/soc/omap/omap-mcpdm.h
Signature · 1 line
1.7.6
PATCH v2 1/2 ASoC: DAPM: Add private data pointer for DAPM widget
Support for using custom private data assigned
per DAPM widget.
--- include/sound/soc-dapm.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
include/sound/soc-dapm.h +1 -0
@@ -467,6 +467,7 @@ struct snd_soc_dapm_widget { unsigned char force:1; /* force state */ unsigned char ignore_suspend:1; /* kept enabled over suspend */int subseq;/* sort within widget type */ +void *private_data;int (*power_check)(struct snd_soc_dapm_widget *w);
Signature · 1 line
1.7.6
Re: [PATCH v2 1/2] ASoC: DAPM: Add private data pointer for DAPM widget
Quoted 2 lines · Peter Ujfalusi
Support for using custom private data assigned
per DAPM widget.
If we're adding this we should probably go the accessor route like we do with the driver data for the CODECs.
Re: [PATCH v2 1/2] ASoC: DAPM: Add private data pointer for DAPM widget
Quoted 6 lines · On Saturday 20 August 2011 09:02:20 Mark Brown wrote:
Quoted 2 lines · Peter Ujfalusi
Support for using custom private data assigned
per DAPM widget.If we're adding this we should probably go the accessor route like we do with the driver data for the CODECs.
Something like:
static inline void *snd_soc_widget_get_pdata(struct snd_soc_dapm_widget *w)
{
return w->private_data;
}static inline void snd_soc_widget_set_pdata(struct snd_soc_dapm_widget *w,
void *data)
{
w->private_data = data;
}Another option at the moment is that I create global variable within the omap- mcpdm.c, so I can have access to the mcpdm within the dapm event handler.
Signature · 1 line
Péter
Re: [PATCH v2 1/2] ASoC: DAPM: Add private data pointer for DAPM widget
Quoted 11 lines · Péter Ujfalusi
Quoted 2 lines · On Saturday 20 August 2011 09:02:20 Mark Brown wrote:
If we're adding this we should probably go the accessor route like we do with the driver data for the CODECs.
Something like:
static inline void *snd_soc_widget_get_pdata(struct
snd_soc_dapm_widget*w){ return w->private_data; }
Yeah, something like that.
Quoted 2 lines
Another option at the moment is that I create global variable within the omap-
mcpdm.c, so I can have access to the mcpdm within the dapm event handler.
That'll probably break in future I'd guess.
PATCH v2 2/2 ASoC: omap-mcpdm: Replace legacy driver
In reply to Peter UjfalusiFrom: Misael Lopez Cruz <[email protected]>
Reasons for the replacement:
The current driver for McPDM was developed to support the legacy mode only. In preparation for the ABE support the current driver stack need the be replaced.
The new driver is much simpler, easier to extend, and it also fixes some of the issues with the old stack.
Main changes:
- single file for omap-mcpdm (mcpdm.c/h removed)
- Define names for registers, bits cleaned up, prefixed
- Full-duplex audio operation (arecord | aplay) has been fixed
- Less code
McPDM need to be turned off _after_ the codec's DAC/ADC has been powered down. The solution for this without extensive change in core:
Use DAPM_SUPPLY to turn off the McPDM interface.
The machine driver connects the "OMAP McPDM Interface" to the codec's DAC/ADC, so after audio activity we can be sure that the host side McPDM is turned off at the correct time.
--- sound/soc/omap/Makefile | 2 +- sound/soc/omap/mcpdm.c | 472 ------------------------- sound/soc/omap/mcpdm.h | 152 -------- sound/soc/omap/omap-mcpdm.c | 823 ++++++++++++++++++++++++++++--------------- sound/soc/omap/omap-mcpdm.h | 97 +++++ sound/soc/omap/sdp4430.c | 14 +- 6 files changed, 655 insertions(+), 905 deletions(-) delete mode 100644 sound/soc/omap/mcpdm.c delete mode 100644 sound/soc/omap/mcpdm.h rewrite sound/soc/omap/omap-mcpdm.c (46%) create mode 100644 sound/soc/omap/omap-mcpdm.h
sound/soc/omap/Makefile +1 -1
@@ -1,7 +1,7 @@ # OMAP Platform Support snd-soc-omap-objs := omap-pcm.o snd-soc-omap-mcbsp-objs := omap-mcbsp.o -snd-soc-omap-mcpdm-objs := omap-mcpdm.o mcpdm.o +snd-soc-omap-mcpdm-objs := omap-mcpdm.o snd-soc-omap-hdmi-objs := omap-hdmi.o obj-$(CONFIG_SND_OMAP_SOC) += snd-soc-omap.o
sound/soc/omap/mcpdm.c deleted +0 -472
472 lines not on this page · raw message
sound/soc/omap/mcpdm.h deleted +0 -152
152 lines not on this page · raw message
sound/soc/omap/omap-mcpdm.c +544 -279
823 lines not on this page · raw message
sound/soc/omap/omap-mcpdm.h new file +97 -0
97 lines not on this page · raw message
sound/soc/omap/sdp4430.c +13 -1
@@ -32,7 +32,7 @@#include <plat/hardware.h> #include <plat/mux.h> -#include "mcpdm.h" +#include "omap-mcpdm.h" #include "omap-pcm.h" #include "../codecs/twl6040.h"
@@ -115,6 +115,14 @@ static const struct snd_soc_dapm_route audio_map[] = {/* Aux/FM Stereo In: AFML, AFMR */ {"AFML", NULL, "FM Stereo In"}, {"AFMR", NULL, "FM Stereo In"}, + +/* OMAP4 McPDM interface */ + {"ADC Left", NULL, "OMAP McPDM Interface"}, + {"ADC Right", NULL, "OMAP McPDM Interface"}, + {"HSDAC Left", NULL, "OMAP McPDM Interface"}, + {"HSDAC Right", NULL, "OMAP McPDM Interface"}, + {"HFDAC Left", NULL, "OMAP McPDM Interface"}, + {"HFDAC Right", NULL, "OMAP McPDM Interface"}, };static int sdp4430_twl6040_init (struct snd_soc_pcm_runtime *rtd)
@@ -129,6 +137,10 @@ static int sdp4430_twl6040_init(struct snd_soc_pcm_runtime *rtd)if (ret)return ret; + ret =omap_mcpdm_add_dapm_widget (codec); +if (ret) +return ret; +/* Set up SDP4430 specific audio path audio_map */ snd_soc_dapm_add_routes (dapm, audio_map,ARRAY_SIZE (audio_map));
Signature · 1 line
1.7.6
Re: [PATCH v2 2/2] ASoC: omap-mcpdm: Replace legacy driver
Quoted 58 lines · Peter Ujfalusi
From: Misael Lopez Cruz <[email protected]>
Reasons for the replacement:
The current driver for McPDM was developed to support the legacy mode only. In preparation for the ABE support the current driver stack need the be replaced.
The new driver is much simpler, easier to extend, and it also fixes some of the issues with the old stack.Main changes:
- single file for omap-mcpdm (mcpdm.c/h removed)
- Define names for registers, bits cleaned up, prefixed
- Full-duplex audio operation (arecord | aplay) has been fixed
- Less codeMcPDM need to be turned off _after_ the codec's DAC/ADC has been powered down. The solution for this without extensive change in core:
UseDAPM_SUPPLYto turn off the McPDM interface.
The machine driver connects the "OMAP McPDM Interface" to the codec's DAC/ADC, so after audio activity we can be sure that the host side McPDM is turned off at the correct time.Signed-off-by Misael Lopez Cruz <[email protected]>Signed-off-by Liam Girdwood <[email protected]>Signed-off-by Sebastien Guiriec <[email protected]>Signed-off-by Peter Ujfalusi <[email protected]>--- sound/soc/omap/Makefile | 2 +- sound/soc/omap/mcpdm.c | 472 ------------------------- sound/soc/omap/mcpdm.h | 152 -------- sound/soc/omap/omap-mcpdm.c | 823 ++++++++++++++++++++++++++++--------------- sound/soc/omap/omap-mcpdm.h | 97 +++++ sound/soc/omap/sdp4430.c | 14 +- 6 files changed, 655 insertions(+), 905 deletions(-) delete mode 100644 sound/soc/omap/mcpdm.c delete mode 100644 sound/soc/omap/mcpdm.h rewrite sound/soc/omap/omap-mcpdm.c (46%) create mode 100644 sound/soc/omap/omap-mcpdm.hsound/soc/omap/Makefile +1
-1@@ -1,7 +1,7 @@ # OMAP Platform Support snd-soc-omap-objs := omap-pcm.o snd-soc-omap-mcbsp-objs := omap-mcbsp.o -snd-soc-omap-mcpdm-objs := omap-mcpdm.o mcpdm.o +snd-soc-omap-mcpdm-objs := omap-mcpdm.o snd-soc-omap-hdmi-objs := omap-hdmi.o obj-$(CONFIG_SND_OMAP_SOC) += snd-soc-omap.osound/soc/omap/mcpdm.c deleted +0
-0
sound/soc/omap/mcpdm.c
Quoted 5 lines
sound/soc/omap/mcpdm.c deleted +4
-0@@ -1,472 +0,0 @@ +static int omap_mcpdm_interface_event (struct snd_soc_dapm_widget *w, +struct snd_kcontrol *kcontrol,int event) +{ +struct omap_mcpdm *mcpdm = w->private_data;
Can't you use
struct omap_mcpdm *mcpdm = snd_soc_codec_get_drvdata(codec)?
This would avoid having to add the private_data field to the widget struct. In it's current form it will only really work, if there is just one instance of the driver using the widget. And if that's the case you can use a global variable directly anyway.
- Lars
Re: [PATCH v2 2/2] ASoC: omap-mcpdm: Replace legacy driver
Quoted 52 lines · Lars-Peter Clausen
Quoted 51 lines · Peter Ujfalusi
From: Misael Lopez Cruz <[email protected]>
Reasons for the replacement:
The current driver for McPDM was developed to support the legacy mode only. In preparation for the ABE support the current driver stack need the be replaced.
The new driver is much simpler, easier to extend, and it also fixes some of the issues with the old stack.Main changes:
- single file for omap-mcpdm (mcpdm.c/h removed)
- Define names for registers, bits cleaned up, prefixed
- Full-duplex audio operation (arecord | aplay) has been fixed
- Less codeMcPDM need to be turned off _after_ the codec's DAC/ADC has been powered down. The solution for this without extensive change in core:
UseDAPM_SUPPLYto turn off the McPDM interface.
The machine driver connects the "OMAP McPDM Interface" to the codec's DAC/ADC, so after audio activity we can be sure that the host side McPDM is turned off at the correct time.Signed-off-by Misael Lopez Cruz <[email protected]>Signed-off-by Liam Girdwood <[email protected]>Signed-off-by Sebastien Guiriec <[email protected]>Signed-off-by Peter Ujfalusi <[email protected]>--- sound/soc/omap/Makefile | 2 +- sound/soc/omap/mcpdm.c | 472 ------------------------- sound/soc/omap/mcpdm.h | 152 -------- sound/soc/omap/omap-mcpdm.c | 823 ++++++++++++++++++++++++++++--------------- sound/soc/omap/omap-mcpdm.h | 97 +++++ sound/soc/omap/sdp4430.c | 14 +- 6 files changed, 655 insertions(+), 905 deletions(-) delete mode 100644 sound/soc/omap/mcpdm.c delete mode 100644 sound/soc/omap/mcpdm.h rewrite sound/soc/omap/omap-mcpdm.c (46%) create mode 100644 sound/soc/omap/omap-mcpdm.hsound/soc/omap/Makefile +1
-1@@ -1,7 +1,7 @@ # OMAP Platform Support snd-soc-omap-objs := omap-pcm.o snd-soc-omap-mcbsp-objs := omap-mcbsp.o -snd-soc-omap-mcpdm-objs := omap-mcpdm.o mcpdm.o +snd-soc-omap-mcpdm-objs := omap-mcpdm.o snd-soc-omap-hdmi-objs := omap-hdmi.o
Quoted 15 lines
sound/soc/omap/mcpdm.c
Quoted 12 lines
sound/soc/omap/Makefile +0
-0obj-$(CONFIG_SND_OMAP_SOC) += snd-soc-omap.osound/soc/omap/mcpdm.c deleted +4
-0@@ -1,472 +0,0 @@ +static int omap_mcpdm_interface_event (struct snd_soc_dapm_widget *w, +struct snd_kcontrol *kcontrol,int event) +{ +struct omap_mcpdm *mcpdm = w->private_data;Can't you use
structomap_mcpdm*mcpdm =snd_soc_codec_get_drvdata(codec)?
sorry:
struct omap_mcpdm *mcpdm = snd_soc_platform_get_drvdata(w->platform);
Quoted 13 lines
This would avoid having to add the
private_datafield to the widget struct. In it's current form it will only really work, if there is just one instance of the driver using the widget. And if that's the case you can use a global variable directly anyway.- Lars
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Re: [PATCH v2 2/2] ASoC: omap-mcpdm: Replace legacy driver
Quoted 69 lines · Lars-Peter Clausen
Quoted 52 lines · Lars-Peter Clausen
Quoted 51 lines · Peter Ujfalusi
From: Misael Lopez Cruz <[email protected]>
Reasons for the replacement:
The current driver for McPDM was developed to support the legacy mode only. In preparation for the ABE support the current driver stack need the be replaced.
The new driver is much simpler, easier to extend, and it also fixes some of the issues with the old stack.Main changes:
- single file for omap-mcpdm (mcpdm.c/h removed)
- Define names for registers, bits cleaned up, prefixed
- Full-duplex audio operation (arecord | aplay) has been fixed
- Less codeMcPDM need to be turned off _after_ the codec's DAC/ADC has been powered down. The solution for this without extensive change in core:
UseDAPM_SUPPLYto turn off the McPDM interface.
The machine driver connects the "OMAP McPDM Interface" to the codec's DAC/ADC, so after audio activity we can be sure that the host side McPDM is turned off at the correct time.Signed-off-by Misael Lopez Cruz <[email protected]>Signed-off-by Liam Girdwood <[email protected]>Signed-off-by Sebastien Guiriec <[email protected]>Signed-off-by Peter Ujfalusi <[email protected]>--- sound/soc/omap/Makefile | 2 +- sound/soc/omap/mcpdm.c | 472 ------------------------- sound/soc/omap/mcpdm.h | 152 -------- sound/soc/omap/omap-mcpdm.c | 823 ++++++++++++++++++++++++++++--------------- sound/soc/omap/omap-mcpdm.h | 97 +++++ sound/soc/omap/sdp4430.c | 14 +- 6 files changed, 655 insertions(+), 905 deletions(-) delete mode 100644 sound/soc/omap/mcpdm.c delete mode 100644 sound/soc/omap/mcpdm.h rewrite sound/soc/omap/omap-mcpdm.c (46%) create mode 100644 sound/soc/omap/omap-mcpdm.hsound/soc/omap/Makefile +1
-1@@ -1,7 +1,7 @@ # OMAP Platform Support snd-soc-omap-objs := omap-pcm.o snd-soc-omap-mcbsp-objs := omap-mcbsp.o -snd-soc-omap-mcpdm-objs := omap-mcpdm.o mcpdm.o +snd-soc-omap-mcpdm-objs := omap-mcpdm.o snd-soc-omap-hdmi-objs := omap-hdmi.oQuoted 15 lines
sound/soc/omap/mcpdm.c
Quoted 12 lines
sound/soc/omap/Makefile +0
-0obj-$(CONFIG_SND_OMAP_SOC) += snd-soc-omap.osound/soc/omap/mcpdm.c deleted +4
-0@@ -1,472 +0,0 @@ +static int omap_mcpdm_interface_event (struct snd_soc_dapm_widget *w, +struct snd_kcontrol *kcontrol,int event) +{ +struct omap_mcpdm *mcpdm = w->private_data;Can't you use
structomap_mcpdm*mcpdm =snd_soc_codec_get_drvdata(codec)?
Quoted 9 lines
sorry:
structomap_mcpdm*mcpdm =snd_soc_platform_get_drvdata(w->platform);Quoted 5 lines
This would avoid having to add the
private_datafield to the widget struct. In it's current form it will only really work, if there is just one instance of the driver using the widget. And if that's the case you can use a global variable directly anyway.
This wont work as the McPDM DAI is neither a codec or a platform driver. It's best to give the widgets some private data since we may have other uses for it too.
Thanks
Liam
Re: [PATCH v2 2/2] ASoC: omap-mcpdm: Replace legacy driver
Quoted 75 lines · Liam Girdwood
Quoted 74 lines · Lars-Peter Clausen
Quoted 52 lines · Lars-Peter Clausen
Quoted 51 lines · Peter Ujfalusi
From: Misael Lopez Cruz <[email protected]>
Reasons for the replacement:
The current driver for McPDM was developed to support the legacy mode only. In preparation for the ABE support the current driver stack need the be replaced.
The new driver is much simpler, easier to extend, and it also fixes some of the issues with the old stack.Main changes:
- single file for omap-mcpdm (mcpdm.c/h removed)
- Define names for registers, bits cleaned up, prefixed
- Full-duplex audio operation (arecord | aplay) has been fixed
- Less codeMcPDM need to be turned off _after_ the codec's DAC/ADC has been powered down. The solution for this without extensive change in core:
UseDAPM_SUPPLYto turn off the McPDM interface.
The machine driver connects the "OMAP McPDM Interface" to the codec's DAC/ADC, so after audio activity we can be sure that the host side McPDM is turned off at the correct time.Signed-off-by Misael Lopez Cruz <[email protected]>Signed-off-by Liam Girdwood <[email protected]>Signed-off-by Sebastien Guiriec <[email protected]>Signed-off-by Peter Ujfalusi <[email protected]>--- sound/soc/omap/Makefile | 2 +- sound/soc/omap/mcpdm.c | 472 ------------------------- sound/soc/omap/mcpdm.h | 152 -------- sound/soc/omap/omap-mcpdm.c | 823 ++++++++++++++++++++++++++++--------------- sound/soc/omap/omap-mcpdm.h | 97 +++++ sound/soc/omap/sdp4430.c | 14 +- 6 files changed, 655 insertions(+), 905 deletions(-) delete mode 100644 sound/soc/omap/mcpdm.c delete mode 100644 sound/soc/omap/mcpdm.h rewrite sound/soc/omap/omap-mcpdm.c (46%) create mode 100644 sound/soc/omap/omap-mcpdm.hsound/soc/omap/Makefile +1
-1@@ -1,7 +1,7 @@ # OMAP Platform Support snd-soc-omap-objs := omap-pcm.o snd-soc-omap-mcbsp-objs := omap-mcbsp.o -snd-soc-omap-mcpdm-objs := omap-mcpdm.o mcpdm.o +snd-soc-omap-mcpdm-objs := omap-mcpdm.o snd-soc-omap-hdmi-objs := omap-hdmi.oQuoted 15 lines
sound/soc/omap/mcpdm.c
Quoted 12 lines
sound/soc/omap/Makefile +0
-0obj-$(CONFIG_SND_OMAP_SOC) += snd-soc-omap.osound/soc/omap/mcpdm.c deleted +4
-0@@ -1,472 +0,0 @@ +static int omap_mcpdm_interface_event (struct snd_soc_dapm_widget *w, +struct snd_kcontrol *kcontrol,int event) +{ +struct omap_mcpdm *mcpdm = w->private_data;Can't you use
structomap_mcpdm*mcpdm =snd_soc_codec_get_drvdata(codec)?sorry:
structomap_mcpdm*mcpdm =snd_soc_platform_get_drvdata(w->platform);Quoted 1 line
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
This would avoid having to add the
private_datafield to the widget struct. In it's current form it will only really work, if there is just one instance of the driver using the widget. And if that's the case you can use a global variable directly anyway.This wont work as the McPDM DAI is neither a codec or a platform driver. It's best to give the widgets some private data since we may have other uses for it too.
oops, sorry. I somehow though this was a platform driver, don't know why. But still the way you use private_data in this driver, you use it to cleverly hide a global variable.
The whole thing is sort of a hack. I mean, if it turns out that we want DAPM on the SoC DAI side, we should probably give it is own DAPM context, instead of using the cards context for this.
- Lars
Re: [PATCH v2 2/2] ASoC: omap-mcpdm: Replace legacy driver
Quoted 83 lines · Lars-Peter Clausen
Quoted 75 lines · Liam Girdwood
Quoted 74 lines · Lars-Peter Clausen
Quoted 52 lines · Lars-Peter Clausen
Quoted 51 lines · Peter Ujfalusi
From: Misael Lopez Cruz <[email protected]>
Reasons for the replacement:
The current driver for McPDM was developed to support the legacy mode only. In preparation for the ABE support the current driver stack need the be replaced.
The new driver is much simpler, easier to extend, and it also fixes some of the issues with the old stack.Main changes:
- single file for omap-mcpdm (mcpdm.c/h removed)
- Define names for registers, bits cleaned up, prefixed
- Full-duplex audio operation (arecord | aplay) has been fixed
- Less codeMcPDM need to be turned off _after_ the codec's DAC/ADC has been powered down. The solution for this without extensive change in core:
UseDAPM_SUPPLYto turn off the McPDM interface.
The machine driver connects the "OMAP McPDM Interface" to the codec's DAC/ADC, so after audio activity we can be sure that the host side McPDM is turned off at the correct time.Signed-off-by Misael Lopez Cruz <[email protected]>Signed-off-by Liam Girdwood <[email protected]>Signed-off-by Sebastien Guiriec <[email protected]>Signed-off-by Peter Ujfalusi <[email protected]>--- sound/soc/omap/Makefile | 2 +- sound/soc/omap/mcpdm.c | 472 ------------------------- sound/soc/omap/mcpdm.h | 152 -------- sound/soc/omap/omap-mcpdm.c | 823 ++++++++++++++++++++++++++++--------------- sound/soc/omap/omap-mcpdm.h | 97 +++++ sound/soc/omap/sdp4430.c | 14 +- 6 files changed, 655 insertions(+), 905 deletions(-) delete mode 100644 sound/soc/omap/mcpdm.c delete mode 100644 sound/soc/omap/mcpdm.h rewrite sound/soc/omap/omap-mcpdm.c (46%) create mode 100644 sound/soc/omap/omap-mcpdm.hsound/soc/omap/Makefile +1
-1@@ -1,7 +1,7 @@ # OMAP Platform Support snd-soc-omap-objs := omap-pcm.o snd-soc-omap-mcbsp-objs := omap-mcbsp.o -snd-soc-omap-mcpdm-objs := omap-mcpdm.o mcpdm.o +snd-soc-omap-mcpdm-objs := omap-mcpdm.o snd-soc-omap-hdmi-objs := omap-hdmi.oQuoted 15 lines
sound/soc/omap/mcpdm.c
Quoted 12 lines
sound/soc/omap/Makefile +0
-0obj-$(CONFIG_SND_OMAP_SOC) += snd-soc-omap.osound/soc/omap/mcpdm.c deleted +4
-0@@ -1,472 +0,0 @@ +static int omap_mcpdm_interface_event (struct snd_soc_dapm_widget *w, +struct snd_kcontrol *kcontrol,int event) +{ +struct omap_mcpdm *mcpdm = w->private_data;Can't you use
structomap_mcpdm*mcpdm =snd_soc_codec_get_drvdata(codec)?sorry:
structomap_mcpdm*mcpdm =snd_soc_platform_get_drvdata(w->platform);Quoted 1 line
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
This would avoid having to add the
private_datafield to the widget struct. In it's current form it will only really work, if there is just one instance of the driver using the widget. And if that's the case you can use a global variable directly anyway.This wont work as the McPDM DAI is neither a codec or a platform driver. It's best to give the widgets some private data since we may have other uses for it too.
Quoted 8 lines
oops, sorry. I somehow though this was a platform driver, don't know why. But still the way you use
private_datain this driver, you use it to cleverly hide a global variable.The whole thing is sort of a hack. I mean, if it turns out that we want DAPM on the SoC DAI side, we should probably give it is own DAPM context, instead of using the cards context for this.
A SoC DAI can be represented within DAPM already with the AIF widget, so adding DAI context should be fine.
Liam
Quoted 1 line
- Lars
Re: [PATCH v2 2/2] ASoC: omap-mcpdm: Replace legacy driver
In reply to Lars-Peter ClausenQuoted 7 lines · On Friday 19 August 2011 10:49:08 Lars-Peter Clausen wrote:
sorry:
structomap_mcpdm*mcpdm =snd_soc_platform_get_drvdata(w->platform);Quoted 4 lines
This would avoid having to add the
private_datafield to the widget struct. In it's current form it will only really work, if there is just one instance of the driver using the widget. And if that's the case you can use a global variable directly anyway.
The other option was to use global variable to get the *mcpdm for the widget. Generally I try to avoid global variables as much as I can, since the use of them looks really hackish.
There could be some way to reach the CPU dai via pointers/lookups from the widget, but it does looked really ugly, and I was only half way there.
Signature · 1 line
Péter
Re: [PATCH v2 2/2] ASoC: omap-mcpdm: Replace legacy driver
Quoted 9 lines · Péter Ujfalusi
Quoted 7 lines · On Friday 19 August 2011 10:49:08 Lars-Peter Clausen wrote:
sorry:
structomap_mcpdm*mcpdm =snd_soc_platform_get_drvdata(w->platform);Quoted 4 lines
This would avoid having to add the
private_datafield to the widget struct. In it's current form it will only really work, if there is just one instance of the driver using the widget. And if that's the case you can use a global variable directly anyway.
Quoted 5 lines
The other option was to use global variable to get the *mcpdm for the widget. Generally I try to avoid global variables as much as I can, since the use of them looks really hackish.
There could be some way to reach the CPU dai via pointers/lookups from the widget, but it does looked really ugly, and I was only half way there.
The widget will have a DAPM context associated with it, should we perhaps add this facility to the DAPM context where it'd then work for everything? If we're getting fancy the context could look up the CODEC context rather than use a local one if it's for a CODEC.
Re: [PATCH v2 2/2] ASoC: omap-mcpdm: Replace legacy driver
In reply to Péter UjfalusiQuoted 4 lines · Péter Ujfalusi
Quoted 3 lines · On Friday 19 August 2011 10:49:08 Lars-Peter Clausen wrote:
sorry:
structomap_mcpdm*mcpdm =snd_soc_platform_get_drvdata(w->platform);
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
This would avoid having to add the
private_datafield to the widget struct. In it's current form it will only really work, if there is just one instance of the driver using the widget. And if that's the case you can use a global variable directly anyway.The other option was to use global variable to get the *mcpdm for the widget. Generally I try to avoid global variables as much as I can, since the use of them looks really hackish.
omap_mcpdm_widgets is a global variable. You assign to it in asoc_mcpdm_probe and read from it in omap_mcpdm_add_dapm_widget. The fact that you hide your *mcpdm in a void pointer doesn't make it less hackish.
Re: [PATCH v2 2/2] ASoC: omap-mcpdm: Replace legacy driver
Quoted 1 line · On Monday 22 August 2011 15:39:15 Lars-Peter Clausen wrote:
omap_mcpdm_widgetsis a global variable.
Yeah, as most of the snd_soc_dapm_widget.
Quoted 1 line
You assign to it in
asoc_mcpdm_probe
Since at compile time I don't have the pointer for the mcpdm (it is allocated earlier in the same function), I need to assign it somewhere.
Quoted 1 line
and read from it in
omap_mcpdm_add_dapm_widget.
I don't see any reference to the omap_mcpdm_widgets in there.
Quoted 2 lines
The fact that you hide your *mcpdm in a void pointer doesn't make it less hackish.
Well, from that point of view most of the kernel is hackish. We tend to have void pointers for various things, like platform_data, device_data, driver_data, private_data, etc.
You see, the point here is that this private_data for the widget can be used for others as well, if needed. It would make no sense to put "struct omap_mcpdm *mcpdm", just because I have this requirement first, does it?
For sure, I could have chosen to create one global pointer for this event handler:
static struct omap_mcpdm *mcpdm_global;
Use the mcpdm_global within omap_mcpdm_interface_event function, and assign it at asoc_mcpdm_probe time.
Would that look better? IMHO it is not.
As Mark suggested, we should have accessor for this, if we are going to have such a thing.
The reason for this (as I described in the commit message):
OMAP McPDM has the requirement (along with the twl6040), that we need to stop the cpu dai _after_ the DAC/ADC has been stopped on the codec side. Now, I do not want to hard wire the twl6040, nor the omap-mcpdm with each other.
The omap-mcpdm implements the event callback, and the machine driver is responsible to create the DAPM route to make sure we follow the correct sequence.
I could as well implemented these things in the machine driver (+global pointer for mcpdm), but that can lead duplicated code in the future (new machine driver, etc).
Signature · 1 line
Péter
Re: [PATCH v2 2/2] ASoC: omap-mcpdm: Replace legacy driver
Quoted 5 lines · Péter Ujfalusi
Quoted 1 line · On Monday 22 August 2011 15:39:15 Lars-Peter Clausen wrote:
omap_mcpdm_widgetsis a global variable.Yeah, as most of the
snd_soc_dapm_widget.
The point is, you use it to pass runtime specific data around, while the others are constant compile time data, which are used as a template.
Quoted 8 lines
Quoted 1 line
You assign to it in
asoc_mcpdm_probeSince at compile time I don't have the pointer for the mcpdm (it is allocated earlier in the same function), I need to assign it somewhere.
Quoted 1 line
and read from it in
omap_mcpdm_add_dapm_widget.I don't see any reference to the
omap_mcpdm_widgetsin there.
+ return snd_soc_dapm_new_controls(dapm, omap_mcpdm_widgets,
+ ARRAY_SIZE(omap_mcpdm_widgets));
Quoted 7 lines
Quoted 3 lines
The fact that you hide your *mcpdm in a void pointer doesn't make it less hackish.
Well, from that point of view most of the kernel is hackish. We tend to have void pointers for various things, like
platform_data,device_data,driver_data,private_data, etc.
I'm not arguing against such constructs. I'm arguing against your usage of them.
Let me give you an example which is analogous to yours:
static struct platform_device foo;
static void bar_probe(struct platform_device *pdev)
{
foo.dev.platform_data = ...;
}void bar_some_global_func(void)
{
platform_device_add(&foo);
}You'll rarely see this in driver code.
If that doesn't convince you, ask yourself what would happen if you had two instances of the mcpdm driver.
Quoted 7 lines
You see, the point here is that this
private_datafor the widget can be used for others as well, if needed. It would make no sense to put "structomap_mcpdm*mcpdm", just because I have this requirement first, does it?For sure, I could have chosen to create one global pointer for this event handler:
Quoted 7 lines
static struct
omap_mcpdm*mcpdm_global;Use the
mcpdm_globalwithinomap_mcpdm_interface_eventfunction, and assign it atasoc_mcpdm_probetime.Would that look better? IMHO it is not.
Your current solution might look better on the surface, but it is deep ugly on the inside. You've hidden your mcpdm_global in a construct that is normally present in a ASoC driver. You've just slightly changed it in subtitle way, apparently so subtitle you don't even see it yourself.
Re: [PATCH v2 2/2] ASoC: omap-mcpdm: Replace legacy driver
Hi,
Quoted 2 lines · On Tuesday 23 August 2011 12:14:58 Lars-Peter Clausen wrote:
If that doesn't convince you, ask yourself what would happen if you had two instances of the mcpdm driver.
I see what you mean.
I guess I was blinded by the fact that we only have one instance of the McPDM driver.
Yeah, you are right this was really bad design.
I have reworked it for v3.
Thanks,
Péter
Re: [PATCH v2 2/2] ASoC: omap-mcpdm: Replace legacy driver
In reply to Peter UjfalusiAm Freitag, den 19.08.2011, 10:41 +0300 schrieb Peter Ujfalusi:
Quoted 6 lines
From: Misael Lopez Cruz <[email protected]>
Reasons for the replacement:
The current driver for McPDM was developed to support the legacy mode only. In preparation for the ABE support the current driver stack need the be replaced.
s/need the/needs to/
[…]
Thanks,
Paul
Re: [PATCH v2 2/2] ASoC: omap-mcpdm: Replace legacy driver
In reply to Peter Ujfalusisound/soc/omap/omap-mcpdm.c line 406
Quoted 6 lines · Peter Ujfalusi
sound/soc/omap/omap-mcpdm.c +6
-0+/* +* DAPM event function to ensure, that the host side McPDM interface is turned +* off after the codec's DAC. +*/ +static int omap_mcpdm_interface_event (struct snd_soc_dapm_widget *w, +struct snd_kcontrol *kcontrol,int event)
So, the issue here is that the CODEC you're using on your system lacks DAC mute support and doesn't handle the end of the input stream gracefully? This doesn't sound like a McPDM specific issue at all, and I'm slightly surprised we don't run into it more often.
Currently the sequence we use on stream teardown is:
1. Mute.
2. Stop stream.
3. Wait for the DAPM teardown time.
4. Power down.
but it seems like what your CODEC actually wants is:
1. Power down.
2. Stop stream.
which isn't at all unresonable and if the CODEC is actually able to support that mode of operation well then it'll be lower power. This seems like something we should be supporting in the core as I would expect other devices will find it useful, PDM class D speaker drivers being the most obvious example.
I do think it'd be helpful to split this code out as a separate patch as it's the controversial bit...
Re: [PATCH v2 2/2] ASoC: omap-mcpdm: Replace legacy driver
Hi Mark,
Quoted 12 lines · On Saturday 20 August 2011 09:01:14 Mark Brown wrote:
So, the issue here is that the CODEC you're using on your system lacks DAC mute support and doesn't handle the end of the input stream gracefully? This doesn't sound like a McPDM specific issue at all, and I'm slightly surprised we don't run into it more often.
Currently the sequence we use on stream teardown is:
1. Mute.
2. Stop stream.
3. Wait for the DAPM teardown time.
4. Power down.
Quoted 4 lines
but it seems like what your CODEC actually wants is:
1. Power down.
2. Stop stream.
Something like that, yes.
Quoted 5 lines
which isn't at all unresonable and if the CODEC is actually able to support that mode of operation well then it'll be lower power. This seems like something we should be supporting in the core as I would expect other devices will find it useful, PDM class D speaker drivers being the most obvious example.
That's good, if we have other users with similar requirements towards the sequencing.
One thing, which might need special care in the down sequence:
1. Stop platform (DMA)
2. Power down (mostly codec side)
3. Stop cpu dai
I'm not sure about this, but we should not have running DMA after trigger:stop?
Quoted 2 lines
I do think it'd be helpful to split this code out as a separate patch as it's the controversial bit...
It is not that easy.
There's no incremental way from the old driver to the new one. What I can try however is to write an intermediate driver, which does not have the delayed sequencing. I know that this is a bit problematic, and it is not going to work as good as the driver in this series, but probably it will give the needed separation of the sequencing part.
This going to take some time, since I need to - kind of - write a new driver, which is in half way between the two versions ;)
--
Péter
Re: [PATCH v2 2/2] ASoC: omap-mcpdm: Replace legacy driver
Quoted 6 lines · Péter Ujfalusi
1. Stop platform (DMA)
2. Power down (mostly codec side)
3. Stop cpu daiI'm not sure about this, but we should not have running DMA after trigger:stop?
I'd expect that to stop the DMA. I need to think about this properly but I think the main trick is keeping the CPU DAI active for longer than we would normally.
Re: [PATCH v2 2/2] ASoC: omap-mcpdm: Replace legacy driver
In reply to Péter UjfalusiHi Mark,
Quoted 11 lines · Peter
Quoted 2 lines
I do think it'd be helpful to split this code out as a separate patch as it's the controversial bit...
It is not that easy.
There's no incremental way from the old driver to the new one. What I can try however is to write an intermediate driver, which does not have the delayed sequencing. I know that this is a bit problematic, and it is not going to work as good as the driver in this series, but probably it will give the needed separation of the sequencing part.
This going to take some time, since I need to - kind of - write a new driver, which is in half way between the two versions ;)
I have looked at the possibility of separating the controversial part from the rest of the change, but it does not look feasible.
I would need to write a driver to fill the gap (well a hack driver for the time of one commit), and even in that way the patch which adds the 'controversial' bit is going to contain quite a bit of code, since I need to rework other parts of the driver.
I think the improved commit message contains enough information on the change.
Thanks,
Péter