From patchwork Thu Jun 18 12:43:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Fitzgerald X-Patchwork-Id: 6636721 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E5CF29F358 for ; Thu, 18 Jun 2015 12:41:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CE04F2082A for ; Thu, 18 Jun 2015 12:41:45 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 5E30820792 for ; Thu, 18 Jun 2015 12:41:44 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id ADE042605D2; Thu, 18 Jun 2015 14:41:42 +0200 (CEST) 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 BEF9426059E; Thu, 18 Jun 2015 14:41:34 +0200 (CEST) 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 8534B2605A4; Thu, 18 Jun 2015 14:41:33 +0200 (CEST) Received: from opensource.wolfsonmicro.com (opensource.wolfsonmicro.com [80.75.67.52]) by alsa0.perex.cz (Postfix) with ESMTP id 4E7E626059C for ; Thu, 18 Jun 2015 14:41:26 +0200 (CEST) Received: from localhost.localdomain (unknown [87.246.78.26]) by opensource.wolfsonmicro.com (Postfix) with ESMTPSA id 8ADBC3B40FF; Thu, 18 Jun 2015 13:41:25 +0100 (BST) From: Richard Fitzgerald To: broonie@kernel.org Date: Thu, 18 Jun 2015 13:43:19 +0100 Message-Id: <1434631399-30102-1-git-send-email-rf@opensource.wolfsonmicro.com> X-Mailer: git-send-email 1.7.2.5 Cc: alsa-devel@alsa-project.org, patches@opensource.wolfsonmicro.com, linux-kernel@vger.kernel.org, lgirdwood@gmail.com Subject: [alsa-devel] [PATCH] ASoC: wm_adsp: Move DSP Rate controls into the codec 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 The rate controls are codec-specific, it's not possible to generically say what the range or the meaning of each control is (or even if they exist at all) - that depends on the particular codec. This is currently being handled for Arizona codecs by putting an Arizona-specific table of controls inside the wm_adsp driver. This creates a dependency between wm_adsp and arizona.c, and is an awkward solution if the ADSP is used in another family of codecs Fix this by moving the Arizona-specific rate controls into the Arizona codec drivers. Signed-off-by: Richard Fitzgerald --- sound/soc/codecs/arizona.c | 27 ++++++++++++++++++++++ sound/soc/codecs/arizona.h | 2 + sound/soc/codecs/wm2200.c | 2 +- sound/soc/codecs/wm5102.c | 5 ++++ sound/soc/codecs/wm5110.c | 6 +++++ sound/soc/codecs/wm_adsp.c | 52 +++++-------------------------------------- sound/soc/codecs/wm_adsp.h | 2 +- 7 files changed, 48 insertions(+), 48 deletions(-) diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c index 88f6df2..802e05e 100644 --- a/sound/soc/codecs/arizona.c +++ b/sound/soc/codecs/arizona.c @@ -2286,6 +2286,33 @@ int arizona_set_output_mode(struct snd_soc_codec *codec, int output, bool diff) } EXPORT_SYMBOL_GPL(arizona_set_output_mode); +static const struct soc_enum arizona_adsp2_rate_enum[] = { + SOC_VALUE_ENUM_SINGLE(ARIZONA_DSP1_CONTROL_1, + ARIZONA_DSP1_RATE_SHIFT, 0xf, + ARIZONA_RATE_ENUM_SIZE, + arizona_rate_text, arizona_rate_val), + SOC_VALUE_ENUM_SINGLE(ARIZONA_DSP2_CONTROL_1, + ARIZONA_DSP1_RATE_SHIFT, 0xf, + ARIZONA_RATE_ENUM_SIZE, + arizona_rate_text, arizona_rate_val), + SOC_VALUE_ENUM_SINGLE(ARIZONA_DSP3_CONTROL_1, + ARIZONA_DSP1_RATE_SHIFT, 0xf, + ARIZONA_RATE_ENUM_SIZE, + arizona_rate_text, arizona_rate_val), + SOC_VALUE_ENUM_SINGLE(ARIZONA_DSP4_CONTROL_1, + ARIZONA_DSP1_RATE_SHIFT, 0xf, + ARIZONA_RATE_ENUM_SIZE, + arizona_rate_text, arizona_rate_val), +}; + +const struct snd_kcontrol_new arizona_adsp2_rate_controls[] = { + SOC_ENUM("DSP1 Rate", arizona_adsp2_rate_enum[0]), + SOC_ENUM("DSP2 Rate", arizona_adsp2_rate_enum[1]), + SOC_ENUM("DSP3 Rate", arizona_adsp2_rate_enum[2]), + SOC_ENUM("DSP4 Rate", arizona_adsp2_rate_enum[3]), +}; +EXPORT_SYMBOL_GPL(arizona_adsp2_rate_controls); + MODULE_DESCRIPTION("ASoC Wolfson Arizona class device support"); MODULE_AUTHOR("Mark Brown "); MODULE_LICENSE("GPL"); diff --git a/sound/soc/codecs/arizona.h b/sound/soc/codecs/arizona.h index 8824f5b..9881b6f 100644 --- a/sound/soc/codecs/arizona.h +++ b/sound/soc/codecs/arizona.h @@ -217,6 +217,8 @@ extern const struct soc_enum arizona_ng_hold; extern const struct soc_enum arizona_in_hpf_cut_enum; extern const struct soc_enum arizona_in_dmic_osr[]; +extern const struct snd_kcontrol_new arizona_adsp2_rate_controls[]; + extern int arizona_in_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event); diff --git a/sound/soc/codecs/wm2200.c b/sound/soc/codecs/wm2200.c index 5a9da28..c830832 100644 --- a/sound/soc/codecs/wm2200.c +++ b/sound/soc/codecs/wm2200.c @@ -1555,7 +1555,7 @@ static int wm2200_probe(struct snd_soc_codec *codec) wm2200->codec = codec; - ret = snd_soc_add_codec_controls(codec, wm_adsp1_fw_controls, 2); + ret = snd_soc_add_codec_controls(codec, wm_adsp_fw_controls, 2); if (ret != 0) return ret; diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c index c5ec519..d097f09e5 100644 --- a/sound/soc/codecs/wm5102.c +++ b/sound/soc/codecs/wm5102.c @@ -1880,6 +1880,11 @@ static int wm5102_codec_probe(struct snd_soc_codec *codec) if (ret) return ret; + ret = snd_soc_add_codec_controls(codec, + arizona_adsp2_rate_controls, 1); + if (ret) + return ret; + arizona_init_spk(codec); arizona_init_gpio(codec); diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c index 5f032a3..709fcc6 100644 --- a/sound/soc/codecs/wm5110.c +++ b/sound/soc/codecs/wm5110.c @@ -1614,6 +1614,12 @@ static int wm5110_codec_probe(struct snd_soc_codec *codec) return ret; } + ret = snd_soc_add_codec_controls(codec, + arizona_adsp2_rate_controls, + WM5110_NUM_ADSP); + if (ret) + return ret; + snd_soc_dapm_disable_pin(dapm, "HAPTICS"); return 0; diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c index f9f90b0..0bb415a 100644 --- a/sound/soc/codecs/wm_adsp.c +++ b/sound/soc/codecs/wm_adsp.c @@ -458,57 +458,17 @@ static const struct soc_enum wm_adsp_fw_enum[] = { SOC_ENUM_SINGLE(0, 3, ARRAY_SIZE(wm_adsp_fw_text), wm_adsp_fw_text), }; -const struct snd_kcontrol_new wm_adsp1_fw_controls[] = { +const struct snd_kcontrol_new wm_adsp_fw_controls[] = { SOC_ENUM_EXT("DSP1 Firmware", wm_adsp_fw_enum[0], wm_adsp_fw_get, wm_adsp_fw_put), SOC_ENUM_EXT("DSP2 Firmware", wm_adsp_fw_enum[1], wm_adsp_fw_get, wm_adsp_fw_put), SOC_ENUM_EXT("DSP3 Firmware", wm_adsp_fw_enum[2], wm_adsp_fw_get, wm_adsp_fw_put), + SOC_ENUM_EXT("DSP4 Firmware", wm_adsp_fw_enum[3], + wm_adsp_fw_get, wm_adsp_fw_put), }; -EXPORT_SYMBOL_GPL(wm_adsp1_fw_controls); - -static const struct soc_enum wm_adsp2_rate_enum[] = { - SOC_VALUE_ENUM_SINGLE(ARIZONA_DSP1_CONTROL_1, - ARIZONA_DSP1_RATE_SHIFT, 0xf, - ARIZONA_RATE_ENUM_SIZE, - arizona_rate_text, arizona_rate_val), - SOC_VALUE_ENUM_SINGLE(ARIZONA_DSP2_CONTROL_1, - ARIZONA_DSP1_RATE_SHIFT, 0xf, - ARIZONA_RATE_ENUM_SIZE, - arizona_rate_text, arizona_rate_val), - SOC_VALUE_ENUM_SINGLE(ARIZONA_DSP3_CONTROL_1, - ARIZONA_DSP1_RATE_SHIFT, 0xf, - ARIZONA_RATE_ENUM_SIZE, - arizona_rate_text, arizona_rate_val), - SOC_VALUE_ENUM_SINGLE(ARIZONA_DSP4_CONTROL_1, - ARIZONA_DSP1_RATE_SHIFT, 0xf, - ARIZONA_RATE_ENUM_SIZE, - arizona_rate_text, arizona_rate_val), -}; - -static const struct snd_kcontrol_new wm_adsp2_fw_controls[4][2] = { - { - SOC_ENUM_EXT("DSP1 Firmware", wm_adsp_fw_enum[0], - wm_adsp_fw_get, wm_adsp_fw_put), - SOC_ENUM("DSP1 Rate", wm_adsp2_rate_enum[0]), - }, - { - SOC_ENUM_EXT("DSP2 Firmware", wm_adsp_fw_enum[1], - wm_adsp_fw_get, wm_adsp_fw_put), - SOC_ENUM("DSP2 Rate", wm_adsp2_rate_enum[1]), - }, - { - SOC_ENUM_EXT("DSP3 Firmware", wm_adsp_fw_enum[2], - wm_adsp_fw_get, wm_adsp_fw_put), - SOC_ENUM("DSP3 Rate", wm_adsp2_rate_enum[2]), - }, - { - SOC_ENUM_EXT("DSP4 Firmware", wm_adsp_fw_enum[3], - wm_adsp_fw_get, wm_adsp_fw_put), - SOC_ENUM("DSP4 Rate", wm_adsp2_rate_enum[3]), - }, -}; +EXPORT_SYMBOL_GPL(wm_adsp_fw_controls); static struct wm_adsp_region const *wm_adsp_find_region(struct wm_adsp *dsp, int type) @@ -2125,8 +2085,8 @@ int wm_adsp2_codec_probe(struct wm_adsp *dsp, struct snd_soc_codec *codec) wm_adsp2_init_debugfs(dsp, codec); return snd_soc_add_codec_controls(codec, - wm_adsp2_fw_controls[dsp->num - 1], - ARRAY_SIZE(wm_adsp2_fw_controls[0])); + &wm_adsp_fw_controls[dsp->num - 1], + 1); } EXPORT_SYMBOL_GPL(wm_adsp2_codec_probe); diff --git a/sound/soc/codecs/wm_adsp.h b/sound/soc/codecs/wm_adsp.h index 5042cbd..579a635 100644 --- a/sound/soc/codecs/wm_adsp.h +++ b/sound/soc/codecs/wm_adsp.h @@ -83,7 +83,7 @@ struct wm_adsp { #define WM_ADSP2(wname, num) \ WM_ADSP2_E(wname, num, wm_adsp2_early_event) -extern const struct snd_kcontrol_new wm_adsp1_fw_controls[]; +extern const struct snd_kcontrol_new wm_adsp_fw_controls[]; int wm_adsp1_init(struct wm_adsp *dsp); int wm_adsp2_init(struct wm_adsp *dsp);