From patchwork Thu Feb 27 16:18:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: nikesh@opensource.wolfsonmicro.com X-Patchwork-Id: 3734561 X-Patchwork-Delegate: broonie@sirena.org.uk Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AB56C9F35F for ; Thu, 27 Feb 2014 16:32:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BC99B20220 for ; Thu, 27 Feb 2014 16:32:24 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 6EF9820222 for ; Thu, 27 Feb 2014 16:32:23 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 644D12658C9; Thu, 27 Feb 2014 17:32:19 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 2F872265703; Thu, 27 Feb 2014 17:32:09 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 4130C26589A; Thu, 27 Feb 2014 17:18:34 +0100 (CET) Received: from opensource.wolfsonmicro.com (opensource.wolfsonmicro.com [80.75.67.52]) by alsa0.perex.cz (Postfix) with ESMTP id 8EA18261B21 for ; Thu, 27 Feb 2014 17:18:26 +0100 (CET) Received: from nikesh-Latitude-E6410.wolfsonmicro.main (unknown [87.246.78.26]) by opensource.wolfsonmicro.com (Postfix) with ESMTPSA id 0C8BB3B40EE; Thu, 27 Feb 2014 16:18:24 +0000 (GMT) From: nikesh@opensource.wolfsonmicro.com To: broonie@kernel.org, lgirdwood@gmail.com Date: Thu, 27 Feb 2014 16:18:20 +0000 Message-Id: <1393517900-27126-1-git-send-email-nikesh@opensource.wolfsonmicro.com> X-Mailer: git-send-email 1.7.9.5 X-Mailman-Approved-At: Thu, 27 Feb 2014 17:32:07 +0100 Cc: alsa-devel@alsa-project.org, tiwai@suse.de, patches@opensource.wolfsonmicro.com, linux-kernel@vger.kernel.org, nikesh Subject: [alsa-devel] [PATCH v2] ASOC: dapm: add params_select callback X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: nikesh 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 select one of the param from a list of params. Signed-off-by: nikesh --- Change since v1: Used an index to select from a list of params, instead of overwriting the param. Thanks, Nikesh include/sound/soc-dapm.h | 3 ++- include/sound/soc.h | 3 +++ sound/soc/soc-core.c | 4 ++-- sound/soc/soc-dapm.c | 20 ++++++++++++++++++-- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index 68d92e3..12b0d9e 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h @@ -416,7 +416,8 @@ 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_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); diff --git a/include/sound/soc.h b/include/sound/soc.h index 9a00147..20110aa 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -876,6 +876,9 @@ struct snd_soc_dai_link { int be_id; /* optional ID for machine driver BE identification */ const struct snd_soc_pcm_stream *params; + /* optional params selection for dai links */ + int (*params_select)(const struct snd_soc_pcm_stream *params, + unsigned int *param_index, 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..2e2f633 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -3379,10 +3379,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_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; + unsigned int param_index; if (WARN_ON(!config) || WARN_ON(list_empty(&w->sources) || list_empty(&w->sinks))) @@ -3402,6 +3404,18 @@ 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_select) { + ret = dai_link->params_select(config, ¶m_index, event); + if (ret < 0) { + dev_err(w->dapm->dev, + "ASoC: params_select for dai link widget failed %d\n", + ret); + goto out; + } + if (param_index > 0) + config += param_index; + } + /* Be a little careful as we don't want to overflow the mask array */ if (config->formats) { fmt = ffs(config->formats) - 1; @@ -3485,7 +3499,8 @@ out: int snd_soc_dapm_new_pcm(struct snd_soc_card *card, const 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 +3532,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));