From patchwork Sun Jun 19 17:52:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: DigitalDreamtime X-Patchwork-Id: 9186215 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 A6F9E6075E for ; Sun, 19 Jun 2016 17:54:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 911F7201F5 for ; Sun, 19 Jun 2016 17:54:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 84C36205A9; Sun, 19 Jun 2016 17:54:17 +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 AA9EE201F5 for ; Sun, 19 Jun 2016 17:54:16 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 854502664E8; Sun, 19 Jun 2016 19:54:15 +0200 (CEST) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 3F7E426548D; Sun, 19 Jun 2016 19:53: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 002BA26548D; Sun, 19 Jun 2016 19:53:18 +0200 (CEST) Received: from mail.dreamtime.org (barcelona.digitaldreamtime.co.uk [85.158.46.130]) by alsa0.perex.cz (Postfix) with ESMTP id DB69C26621A for ; Sun, 19 Jun 2016 19:52:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dreamtime.org; s=dt20140624; h=Message-Id:Date:Subject:Cc:To:From; bh=wl7bS72ZdEe2tEcT+7rtMYGyTNoBfbrIUSYi7lonvgo=; b=ZFUYj6Tf4j+Az5bsMPe5H3WoDg4X609iQ1I8/KS9Asqr7Onb4SnRjNadloL8ashdLcsh8uBKH/rq3549Ttujvx5etp0rTVSLNYfkxeXBuzIhb2yc7OD78uo783wFvgdn4EHVMS/SUktBryCvC5aHDsVrGccbatHbkwgvI2KP8lYTQxZVsEPo4rA3XBppdXCG3fpgUXKe9hmxnUWxmpGpRj8u54O9OvsHS4EJpkJiT6gUl5S321RP0qJe/swhfwsoljHSrEB6Jsaf6z4dCi4iHQ5vNbPk/8Tq8Droins/YLgD1dgaBNzy6CtPdxH8BMdHfAHJlIOBIuFbI/p+GWXi/Q==; 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 1bEgu3-0003tU-Iw; Sun, 19 Jun 2016 17:52:59 +0000 From: Clive Messer To: alsa-devel@alsa-project.org Date: Sun, 19 Jun 2016 18:52:48 +0100 Message-Id: <1466358768-31787-1-git-send-email-clive.messer@digitaldreamtime.co.uk> X-Mailer: git-send-email 2.5.5 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 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 @@ -20,16 +20,52 @@ #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; + struct pcm5102a_priv *priv = snd_soc_codec_get_drvdata(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;