From patchwork Sun Jun 19 20:42:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: DigitalDreamtime X-Patchwork-Id: 9186241 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5C3E860871 for ; Sun, 19 Jun 2016 20:42:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C80121BED for ; Sun, 19 Jun 2016 20:42:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 70D6822230; Sun, 19 Jun 2016 20:42:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 43D2C21BED for ; Sun, 19 Jun 2016 20:42:31 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id D95692664B6; Sun, 19 Jun 2016 22:42:29 +0200 (CEST) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id A51FB265090; Sun, 19 Jun 2016 22:42:20 +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 0EEE9265090; Sun, 19 Jun 2016 22:42:20 +0200 (CEST) Received: from mail.dreamtime.org (barcelona.digitaldreamtime.co.uk [85.158.46.130]) by alsa0.perex.cz (Postfix) with ESMTP id 636872625FE for ; Sun, 19 Jun 2016 22:42:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dreamtime.org; s=dt20140624; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=f2gSGY8pIohCc/qc24BJn2jelt4ROxK9qw2AfkZbS/M=; b=r9dtzKseZYpyi8cM0s8yf/N5DHgJ6xgf4aAj9kDD3R413HTCnCe7/wW9HXiJaHIGbArRBqsmytvJS9vVUb2aWsnZ5k/6PYFJ0A31yW12P/ONITvoaQ4RvCxpwjHQXLsjfCgafN85mYLt3dejPlu0r47OnCOGa4TsQ5CshIpbeVuHah5D6BWuU5iTtNeyqGnXqJDf83xQLGa+Xba+kvFfEYU9/+UWByXR4cUerJF5zBc3BDQEoZSHLLCKF+PyUhyTSAlt2jlx94V0+sLzyb9xK1fBaC+4qpmRXmDvzIDVjfPoesbahk26YVQFNutAVeLaP1A63Hv8Zj8+F+ElJlC9iA==; Received: from host-2-96-144-62.as13285.net ([2.96.144.62] helo=e5530.vacuumtube.org.uk) by mail.dreamtime.org with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bEjXp-0004oi-Hd; Sun, 19 Jun 2016 20:42:13 +0000 From: Clive Messer To: alsa-devel@alsa-project.org Date: Sun, 19 Jun 2016 21:42:02 +0100 Message-Id: <1466368922-6555-1-git-send-email-clive.messer@digitaldreamtime.co.uk> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1466358768-31787-1-git-send-email-clive.messer@digitaldreamtime.co.uk> References: <1466358768-31787-1-git-send-email-clive.messer@digitaldreamtime.co.uk> X-SA-Exim-Connect-IP: 2.96.144.62 X-SA-Exim-Mail-From: clive.messer@digitaldreamtime.co.uk X-SA-Exim-Scanned: No (on mail.dreamtime.org); SAEximRunCond expanded to false Cc: Clive Messer Subject: [alsa-devel] [PATCH V2 1/1] ASoC: pcm5102a: Support 352k8 and 384k sample rates 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 Add support for 352k8 and 384k samples rates to pcm5102a codec driver, with SNDRV_PCM_RATE_KNOT and a constraint list. Signed-off-by: Clive Messer --- sound/soc/codecs/pcm5102a.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/pcm5102a.c b/sound/soc/codecs/pcm5102a.c index ed51567..53dfc99 100644 --- a/sound/soc/codecs/pcm5102a.c +++ b/sound/soc/codecs/pcm5102a.c @@ -21,16 +21,51 @@ #include +static const u32 pcm5102a_rates[] = { + 8000, 16000, 32000, 44100, 48000, 88200, 96000, 176400, 192000, + 352800, 384000, +}; + +static const struct snd_pcm_hw_constraint_list pcm5102a_constraint_rates = { + .count = ARRAY_SIZE(pcm5102a_rates), + .list = pcm5102a_rates, +}; + +static int pcm5102a_dai_startup(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct snd_soc_codec *codec = dai->codec; + int ret; + + dev_dbg(codec->dev, "%s: set rates (8k-384k) constraint\n", __func__); + + ret = snd_pcm_hw_constraint_list(substream->runtime, 0, + SNDRV_PCM_HW_PARAM_RATE, + &pcm5102a_constraint_rates); + if (ret != 0) { + dev_err(codec->dev, "%s: Failed to set rates constraint: %d\n", + __func__, ret); + return ret; + } + + return 0; +} + +static const struct snd_soc_dai_ops pcm5102a_dai_ops = { + .startup = pcm5102a_dai_startup, +}; + static struct snd_soc_dai_driver pcm5102a_dai = { .name = "pcm5102a-hifi", .playback = { .channels_min = 2, .channels_max = 2, - .rates = SNDRV_PCM_RATE_8000_192000, + .rates = SNDRV_PCM_RATE_KNOT, .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE }, + .ops = &pcm5102a_dai_ops, }; static struct snd_soc_codec_driver soc_codec_dev_pcm5102a;