From patchwork Mon Sep 17 00:57:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 10601975 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 46F91157B for ; Mon, 17 Sep 2018 01:00:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A567294D1 for ; Mon, 17 Sep 2018 01:00:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E369294D9; Mon, 17 Sep 2018 01:00:05 +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=-2.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=ham 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 620E2294D1 for ; Mon, 17 Sep 2018 01:00:04 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 181E82678CC; Mon, 17 Sep 2018 02:58:39 +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 2FFA72678DD; Mon, 17 Sep 2018 02:58:27 +0200 (CEST) Received: from mail-it0-f66.google.com (mail-it0-f66.google.com [209.85.214.66]) by alsa0.perex.cz (Postfix) with ESMTP id 1BCF62678CD for ; Mon, 17 Sep 2018 02:58:20 +0200 (CEST) Received: by mail-it0-f66.google.com with SMTP id e14-v6so9072863itf.1 for ; Sun, 16 Sep 2018 17:58:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IA3NssNVI2Q9RVwkXpQaJ3ttyxnrxpJbsIkQeijt2Ss=; b=Z2pYCTr+Y/yxuuilUK/mg+MDzsVEnq5rsFz/kAZsIDZykVc179SM+xFUeVkKEiT+jv 0cmtGq80u9EFhJ8dX2/8nZGY0CQF6ZSmB6aBu/TdNWCZESwWL+I62W6m+2Y/CGeY+3UI eAcmXhDbaJ83TY+QuLMHYze8svWIB5+BXRI2s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IA3NssNVI2Q9RVwkXpQaJ3ttyxnrxpJbsIkQeijt2Ss=; b=rt0QpAhv/LBsaNmAYOR/LnGuk1iY9TXil66gqA2FvgAG2ZVua/eaG+LU8SL8OIOZ65 QOkstmDrzRMOP0PP6SjezmRAf0Vk5UTAmREv8v/JKAfSLn9md/QYaykodRXjy45BVsx9 cfZ7IeXJEM9d8oAy/tg8e1SOEaipQ0aLMxL3dUhCr3dw6NerWazDjAKLM8Gl1Oz/YO2b RhoYTj0OMfRGyc79luf8uF5eQmO2i6CC6PFfHPmGE2CO81mLuDiKKyojMViBy5LGfogj iWQ3Kcpo594Vu5skfUsvoLuAEdBuw7uqVR7uUber0WlOtk5XHH2NJ8+LpUTpHxhtMKfW QaYg== X-Gm-Message-State: APzg51BOlG6NyMIJfv0u4b577Pjeovb+GurLrUm26wn0wc2m8pjPMXH6 J6Cvw46gX7I89eA8Six7ND56qw== X-Google-Smtp-Source: ANB0VdbfsDXVl7Owl/BfMbkrOrg58YWGLqF1DDptBLvFuebojrkXqmldp1COty2dWmBSXXuFeN/v5Q== X-Received: by 2002:a02:9a10:: with SMTP id b16-v6mr20810874jal.4.1537145900260; Sun, 16 Sep 2018 17:58:20 -0700 (PDT) Received: from localhost.localdomain ([209.82.80.116]) by smtp.gmail.com with ESMTPSA id f64-v6sm829972ite.4.2018.09.16.17.58.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 16 Sep 2018 17:58:19 -0700 (PDT) From: srinivas.kandagatla@linaro.org To: lee.jones@linaro.org, robh+dt@kernel.org, broonie@kernel.org Date: Sun, 16 Sep 2018 17:57:27 -0700 Message-Id: <20180917005727.32728-15-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20180917005727.32728-1-srinivas.kandagatla@linaro.org> References: <20180917005727.32728-1-srinivas.kandagatla@linaro.org> Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, alsa-devel@alsa-project.org, bgoswami@codeaurora.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, vkoul@kernel.org, Srinivas Kandagatla Subject: [alsa-devel] [PATCH v4 14/14] ASoC: qcom: common: move be_hw_fixup to common 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: Srinivas Kandagatla be_hw_fixup for qdsp is common across mutiple qcom machine drivers, so move it to common file and remove the redundant code. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/apq8096.c | 15 --------------- sound/soc/qcom/common.c | 17 +++++++++++++++++ sound/soc/qcom/sdm845.c | 22 ++-------------------- 3 files changed, 19 insertions(+), 35 deletions(-) diff --git a/sound/soc/qcom/apq8096.c b/sound/soc/qcom/apq8096.c index daad43f..9cb26aee 100644 --- a/sound/soc/qcom/apq8096.c +++ b/sound/soc/qcom/apq8096.c @@ -20,20 +20,6 @@ struct apq8096_card_data { bool jack_setup; }; -static int apq8096_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - rate->min = rate->max = 48000; - channels->min = channels->max = 2; - - return 0; -} - static int msm_snd_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { @@ -139,7 +125,6 @@ static void apq8096_add_be_ops(struct snd_soc_card *card) for (i = 0; i < num_links; i++) { if (link->no_pcm == 1) { - link->be_hw_params_fixup = apq8096_be_hw_params_fixup; link->init = apq8096_init; link->ops = &apq8096_ops; } diff --git a/sound/soc/qcom/common.c b/sound/soc/qcom/common.c index eb1b9da..ce8e759 100644 --- a/sound/soc/qcom/common.c +++ b/sound/soc/qcom/common.c @@ -3,8 +3,24 @@ // Copyright (c) 2018, The Linux Foundation. All rights reserved. #include +#include #include "common.h" +static int qcom_snd_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_hw_params *params) +{ + struct snd_interval *rate = hw_param_interval(params, + SNDRV_PCM_HW_PARAM_RATE); + struct snd_interval *channels = hw_param_interval(params, + SNDRV_PCM_HW_PARAM_CHANNELS); + + rate->min = rate->max = 48000; + channels->min = channels->max = 2; + params_set_format(params, SNDRV_PCM_FORMAT_S16_LE); + + return 0; +} + int qcom_snd_parse_of(struct snd_soc_card *card) { struct device_node *np; @@ -79,6 +95,7 @@ int qcom_snd_parse_of(struct snd_soc_card *card) } link->no_pcm = 1; link->ignore_pmdown_time = 1; + link->be_hw_params_fixup = qcom_snd_be_hw_params_fixup; } else { link->platform_of_node = link->cpu_of_node; link->codec_dai_name = "snd-soc-dummy-dai"; diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c index 2a781d8..87e150c 100644 --- a/sound/soc/qcom/sdm845.c +++ b/sound/soc/qcom/sdm845.c @@ -11,7 +11,6 @@ #include "common.h" #include "qdsp6/q6afe.h" -#define DEFAULT_SAMPLE_RATE_48K 48000 #define DEFAULT_MCLK_RATE 24576000 #define DEFAULT_BCLK_RATE 12288000 @@ -177,32 +176,15 @@ static struct snd_soc_ops sdm845_be_ops = { .shutdown = sdm845_snd_shutdown, }; -static int sdm845_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); - - rate->min = rate->max = DEFAULT_SAMPLE_RATE_48K; - channels->min = channels->max = 2; - snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S16_LE); - - return 0; -} - static void sdm845_add_be_ops(struct snd_soc_card *card) { struct snd_soc_dai_link *link = card->dai_link; int i, num_links = card->num_links; for (i = 0; i < num_links; i++) { - if (link->no_pcm == 1) { + if (link->no_pcm == 1) link->ops = &sdm845_be_ops; - link->be_hw_params_fixup = sdm845_be_hw_params_fixup; - } + link++; } }