* [PATCH] ASOC: dapm: add param_fixup callback
@ 2014-02-24 13:54 Nikesh, Oswal
2014-02-25 1:05 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Nikesh, Oswal @ 2014-02-24 13:54 UTC (permalink / raw)
To: broonie, lgirdwood; +Cc: perex, tiwai, alsa-devel, linux-kernel, nikesh
From: nikesh <Nikesh.Oswal@wolfsonmicro.com>
dai-link params for codec-codec links were fixed.
The fixed link between codec and another chip which
may be another codec, baseband, bluetooth codec etc
may require run time configuaration changes.
This change provides an optional callback to modify
these params.
Change-Id: Iad6ee3951bc4e8b8bc519c62642a2b4bcd949c18
Signed-off-by: nikesh <Nikesh.Oswal@wolfsonmicro.com>
---
include/sound/soc-dapm.h | 7 ++++---
include/sound/soc.h | 4 +++-
sound/soc/soc-core.c | 4 ++--
sound/soc/soc-dapm.c | 21 +++++++++++++++++----
4 files changed, 26 insertions(+), 10 deletions(-)
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
index 68d92e3..e3497ed 100644
--- a/include/sound/soc-dapm.h
+++ b/include/sound/soc-dapm.h
@@ -414,9 +414,10 @@ int snd_soc_dapm_new_dai_widgets(struct snd_soc_dapm_context *dapm,
int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card);
void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card);
int snd_soc_dapm_new_pcm(struct snd_soc_card *card,
- const struct snd_soc_pcm_stream *params,
+ struct snd_soc_pcm_stream *params,
struct snd_soc_dapm_widget *source,
- struct snd_soc_dapm_widget *sink);
+ struct snd_soc_dapm_widget *sink,
+ struct snd_soc_dai_link *dai_link);
/* dapm path setup */
int snd_soc_dapm_new_widgets(struct snd_soc_card *card);
@@ -561,7 +562,7 @@ struct snd_soc_dapm_widget {
void *priv; /* widget specific data */
struct regulator *regulator; /* attached regulator */
- const struct snd_soc_pcm_stream *params; /* params for dai links */
+ struct snd_soc_pcm_stream *params; /* params for dai links */
/* dapm control */
int reg; /* negative reg = no direct dapm */
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 9a00147..401c911 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -875,7 +875,9 @@ struct snd_soc_dai_link {
const struct device_node *platform_of_node;
int be_id; /* optional ID for machine driver BE identification */
- const struct snd_soc_pcm_stream *params;
+ struct snd_soc_pcm_stream *params;
+ /* optional params re-writing for dai links */
+ int (*params_fixup)(struct snd_soc_dapm_widget *w, int event);
unsigned int dai_fmt; /* format to set on init */
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index fe1df50..4f03e88 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1469,7 +1469,7 @@ static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order)
capture_w = cpu_dai->capture_widget;
if (play_w && capture_w) {
ret = snd_soc_dapm_new_pcm(card, dai_link->params,
- capture_w, play_w);
+ capture_w, play_w, dai_link);
if (ret != 0) {
dev_err(card->dev, "ASoC: Can't link %s to %s: %d\n",
play_w->name, capture_w->name, ret);
@@ -1481,7 +1481,7 @@ static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order)
capture_w = codec_dai->capture_widget;
if (play_w && capture_w) {
ret = snd_soc_dapm_new_pcm(card, dai_link->params,
- capture_w, play_w);
+ capture_w, play_w, dai_link);
if (ret != 0) {
dev_err(card->dev, "ASoC: Can't link %s to %s: %d\n",
play_w->name, capture_w->name, ret);
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index dc8ff13..dc1ef8b 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -3378,11 +3378,12 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w,
{
struct snd_soc_dapm_path *source_p, *sink_p;
struct snd_soc_dai *source, *sink;
- const struct snd_soc_pcm_stream *config = w->params;
+ struct snd_soc_pcm_stream *config = w->params;
+ struct snd_soc_dai_link *dai_link = w->priv;
struct snd_pcm_substream substream;
struct snd_pcm_hw_params *params = NULL;
u64 fmt;
- int ret;
+ int ret = 0;
if (WARN_ON(!config) ||
WARN_ON(list_empty(&w->sources) || list_empty(&w->sinks)))
@@ -3402,6 +3403,16 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w,
source = source_p->source->priv;
sink = sink_p->sink->priv;
+ if (dai_link && dai_link->params_fixup) {
+ ret = dai_link->params_fixup(w, event);
+ if (ret < 0) {
+ dev_err(w->dapm->dev,
+ "ASoC: params_fixup for dai link widget failed %d\n",
+ ret);
+ goto out;
+ }
+ }
+
/* Be a little careful as we don't want to overflow the mask array */
if (config->formats) {
fmt = ffs(config->formats) - 1;
@@ -3483,9 +3494,10 @@ out:
}
int snd_soc_dapm_new_pcm(struct snd_soc_card *card,
- const struct snd_soc_pcm_stream *params,
+ struct snd_soc_pcm_stream *params,
struct snd_soc_dapm_widget *source,
- struct snd_soc_dapm_widget *sink)
+ struct snd_soc_dapm_widget *sink,
+ struct snd_soc_dai_link *dai_link)
{
struct snd_soc_dapm_route routes[2];
struct snd_soc_dapm_widget template;
@@ -3517,6 +3529,7 @@ int snd_soc_dapm_new_pcm(struct snd_soc_card *card,
}
w->params = params;
+ w->priv = (void *)dai_link;
memset(&routes, 0, sizeof(routes));
--
1.7.9.5
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] ASOC: dapm: add param_fixup callback
2014-02-24 13:54 [PATCH] ASOC: dapm: add param_fixup callback Nikesh, Oswal
@ 2014-02-25 1:05 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2014-02-25 1:05 UTC (permalink / raw)
Cc: lgirdwood, perex, tiwai, alsa-devel, linux-kernel, nikesh
[-- Attachment #1: Type: text/plain, Size: 1689 bytes --]
On Mon, Feb 24, 2014 at 01:54:18PM +0000, NikeshOswal wrote:
> From: nikesh <Nikesh.Oswal@wolfsonmicro.com>
You need to fix both your git and e-mail setups, you should be using
"Nikesh Oswal" or similar as your real name and more importantly your
mail setup is sending mail as "NikeshOswal" with no even a domain part
which means you can't be replied to. It is very important that you are
able to get review comments at the address you post from.
> dai-link params for codec-codec links were fixed.
> The fixed link between codec and another chip which
> may be another codec, baseband, bluetooth codec etc
Please use the full width for your changelog.
> Change-Id: Iad6ee3951bc4e8b8bc519c62642a2b4bcd949c18
Don't include noise like this in upstream submissions.
> - const struct snd_soc_pcm_stream *params;
> + struct snd_soc_pcm_stream *params;
> + /* optional params re-writing for dai links */
> + int (*params_fixup)(struct snd_soc_dapm_widget *w, int event);
This isn't a great interface, it relies on the driver peering inside the
core data structures and it means that we have to drop the consts from
users. Systems not using this feature ought to be able to declare their
parameters as static const but this breaks that ability. Similarly
users that are fully dynamic need to allocate some static data to work
with this interface.
If you look at the existing interface you'll also see that it takes an
array of parameters rather than just a single parameter. The idea was
to extend the interface to provide a control to userspace allowing
selection of one of the configurations from a list for use with cases
like modems which can switch between 8kHz and 16kHz modes.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-02-25 1:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-24 13:54 [PATCH] ASOC: dapm: add param_fixup callback Nikesh, Oswal
2014-02-25 1:05 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®