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: 146816 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp3197090ljw; Sun, 16 Sep 2018 17:58:25 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbXQt7XMsCrqYnFFjFOCGbU/00HfO8iuPgkp9H26EDQtU3e0/Tv9b/ylzyWfwiNStpTqUVD X-Received: by 2002:a63:af17:: with SMTP id w23-v6mr21832109pge.47.1537145905081; Sun, 16 Sep 2018 17:58:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537145905; cv=none; d=google.com; s=arc-20160816; b=ApfVexKPXeovL6Qcyo1IJxr0LlgxF7xaVozj5/gwdYQ/rEI0IrLHq68vR1fKggAz2g YBXWl7C0PImfVCfljq5aer4SjZjPi8HtVWc3boSMNircvBD9vEfgMVWfBTat5WKafD3U 54rMEs+ZnkpGaWhP/UgCzXLrwZf0n0gsrSw4Yto63iaNAfNMUs8ywgvoSUvje0zMI1PY MBL/zBXbsF/Ry3rP2M81S+0ydPrEOQ/ktN4k8wrIgUNOt8cY6KnQtl8cHL47kExvWf1R 457YYLD0ZbezH9fjhefJBy895OX0OnOSq3REd16latBq2iEVfvOhx3EN100dTVStYra/ Hjpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=IA3NssNVI2Q9RVwkXpQaJ3ttyxnrxpJbsIkQeijt2Ss=; b=SqnMc74nUiSGpkUTvGLch0cUi5Igib7GdKIR2tp+oSm3FxqfBpiwNsicBkQ4NwNFPK QdLLvG4xaNxHF0IfcbExruy6XARKPE0jtizNBFdXeWL0IVsq8QC+zi9Aj1UuMLUADpAV QSI1PqcPkOTVtx2pJvC3+5YuBaA+j3ZIWwWvr2ZGXvjj767JlQAReY6j7w1X46bxA4kV 6UlTd8+NFVkOqw62cOLm8ddyh4lLL+hV5WprkIN03PDG9LMVYpSTVzHngJb4O8F7AuEQ zb2OcqKapOSy5wFuSTm4DEY7a3/nHQnMPj3wIuo/2CtGxKat6rgq8CpxwU/r6+LHDWKx M8Bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Z2pYCTr+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n11-v6si13710910plg.453.2018.09.16.17.58.24; Sun, 16 Sep 2018 17:58:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Z2pYCTr+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728559AbeIQGXO (ORCPT + 32 others); Mon, 17 Sep 2018 02:23:14 -0400 Received: from mail-it0-f68.google.com ([209.85.214.68]:52590 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728518AbeIQGXN (ORCPT ); Mon, 17 Sep 2018 02:23:13 -0400 Received: by mail-it0-f68.google.com with SMTP id h3-v6so9079286ita.2 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=q87fw/UsCbQTUHarcEhm2tMM0nslSVRINHdmMRN7OFeXwk26CLuSVeUBOL97Ip5hLu hq4z+OdrZTxaGzkpkZ3pDay1jjRhhJj93pv9I/vq72s4+HSyZ6AoS7cqUwCyT04WTiYS nbXfS58e+Jc6CCs5ePEzYUD+5fs5LvDfpl8BFCZaFtnNgiMz/svnOCoAnTQMWryyMl8k blwYBRz5dYvPD/eOVnqynHpOtXW3awXmJZ4jYADkyUWjro2LS88nwParF2BCwB+rvsj8 M3fvcPVlE9WeD+vaHBCV4x5oxKr6wiZuI6XgzS7nIvTm855loADmya1SQ5GgKzlMx1Y3 StYw== X-Gm-Message-State: APzg51BixiKcoHsRZEzWJ/tVFUY9bjbHlv6YwbcaX2c37PC8vthobSrq LyQPHR76OKPmfK7Sjqs06mscoQ== 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 Cc: mark.rutland@arm.com, lgirdwood@gmail.com, bgoswami@codeaurora.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, vkoul@kernel.org, alsa-devel@alsa-project.org, Srinivas Kandagatla Subject: [PATCH v4 14/14] ASoC: qcom: common: move be_hw_fixup to common 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.9.3 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++; } }