From patchwork Tue May 29 10:18:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 10434847 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 98087602BF for ; Tue, 29 May 2018 10:21:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 852BF286DD for ; Tue, 29 May 2018 10:21:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 82BB7286F2; Tue, 29 May 2018 10:21:18 +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 CCA69286C0 for ; Tue, 29 May 2018 10:21:17 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 6EC562676B2; Tue, 29 May 2018 12:21:03 +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 D6DDC267645; Tue, 29 May 2018 12:20:58 +0200 (CEST) Received: from mail-wr0-f193.google.com (mail-wr0-f193.google.com [209.85.128.193]) by alsa0.perex.cz (Postfix) with ESMTP id 406922671EE for ; Tue, 29 May 2018 12:20:56 +0200 (CEST) Received: by mail-wr0-f193.google.com with SMTP id i14-v6so24533831wre.2 for ; Tue, 29 May 2018 03:20:55 -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=bW+9ST8toUlXAFZ70AykoH2+2+K96WTJIwTYBYkWJVE=; b=P+NoU39R2ckPPiWXmkEyY3j1Y92Zgqdr+cH69QQ4hIvuILwcuQtRp21rp7y+xVssEX +6V7I56Pc/lzBTG6W+zDWTnnMopLlhEQnKvVqt/AcNIayx/7zUQ/Q2ADs1ZXJyy4CEEd TsXl/rvWiI3ihciiijeUqvAewXWtBApkZ8WZY= 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=bW+9ST8toUlXAFZ70AykoH2+2+K96WTJIwTYBYkWJVE=; b=ViEMrdpSEDh06A1zrmN6nkhIydxEy8ZYX+t9Musf7POIbWiNVqpYuz1OpUMv5Nk/HQ YmSz2P0YF1r1SrYOTVl5w3BgbO5BiT3hdHJUXKWpHO32S24gTG9RE8gkq8gMyRz2fv+W zoLVlp1hUKhLCwSjn/FziLMPQo0sU40bjL4g1qpBwMWp/IkZPNde9VLaMUH0sVRxp2jJ ecy4ckqtwjQhCkU/pH3WM+MgsDrKOHRDbpxb2Sa2cLY7lriQiB92CXhmMnShX55R5l2u ldipXzJ7ohr05Krrq1ynDP7tNwnhLFoBMOcQC+M2zmRsOcS1gHxSfC8k0BYxOKRzOEiJ Vb2g== X-Gm-Message-State: ALKqPwfa7ZVCyZ2HEbNjIt9f40EIfoWFh0zSiKlDIsOVnFwJDY/zIYFP BJs525hsDkoq8MYuehNgt7DsQQ== X-Google-Smtp-Source: AB8JxZqL98PxvAVfh+Am1huydNWmwDyNrMwOX4vn81A43hdv65QA58gRCjKcA4AIh9d6XJyY7ZSQJg== X-Received: by 2002:adf:bc8f:: with SMTP id g15-v6mr13043849wrh.266.1527589255737; Tue, 29 May 2018 03:20:55 -0700 (PDT) Received: from localhost.localdomain (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.gmail.com with ESMTPSA id 60-v6sm23825021wrc.42.2018.05.29.03.20.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 May 2018 03:20:55 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org, linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org, robh+dt@kernel.org, bgoswami@codeaurora.org Date: Tue, 29 May 2018 11:18:30 +0100 Message-Id: <20180529101833.30489-4-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180529101833.30489-1-srinivas.kandagatla@linaro.org> References: <20180529101833.30489-1-srinivas.kandagatla@linaro.org> Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, rohkumar@qti.qualcomm.com, linux-kernel@vger.kernel.org, plai@codeaurora.org, tiwai@suse.com, lgirdwood@gmail.com, Srinivas Kandagatla , spatakok@qti.qualcomm.com, linux-arm-kernel@lists.infradead.org Subject: [alsa-devel] [PATCH 3/6] ASoC: qdsp6: q6afe-dai: use q6afe_dai_prepare() for MI2S 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 Use common q6afe_dai_prepare() for MI2S dais, this will remove some code duplication. Also make the if statement to switch to make the code look neater. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/qdsp6/q6afe-dai.c | 53 ++++++++++++++-------------------------- 1 file changed, 18 insertions(+), 35 deletions(-) diff --git a/sound/soc/qcom/qdsp6/q6afe-dai.c b/sound/soc/qcom/qdsp6/q6afe-dai.c index 4378e29a95c5..e529edfd8001 100644 --- a/sound/soc/qcom/qdsp6/q6afe-dai.c +++ b/sound/soc/qcom/qdsp6/q6afe-dai.c @@ -144,38 +144,6 @@ static void q6afe_dai_shutdown(struct snd_pcm_substream *substream, } -static int q6afe_mi2s_prepare(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); - int rc; - - if (dai_data->is_port_started[dai->id]) { - /* stop the port and restart with new port config */ - rc = q6afe_port_stop(dai_data->port[dai->id]); - if (rc < 0) { - dev_err(dai->dev, "fail to close AFE port (%d)\n", rc); - return rc; - } - } - - rc = q6afe_i2s_port_prepare(dai_data->port[dai->id], - &dai_data->port_config[dai->id].i2s_cfg); - if (rc < 0) { - dev_err(dai->dev, "fail to prepare AFE port %x\n", dai->id); - return rc; - } - - rc = q6afe_port_start(dai_data->port[dai->id]); - if (rc < 0) { - dev_err(dai->dev, "fail to start AFE port %x\n", dai->id); - return rc; - } - dai_data->is_port_started[dai->id] = true; - - return 0; -} - static int q6afe_dai_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { @@ -191,12 +159,27 @@ static int q6afe_dai_prepare(struct snd_pcm_substream *substream, } } - if (dai->id == HDMI_RX) + switch (dai->id) { + case HDMI_RX: q6afe_hdmi_port_prepare(dai_data->port[dai->id], &dai_data->port_config[dai->id].hdmi); - else if (dai->id >= SLIMBUS_0_RX && dai->id <= SLIMBUS_6_TX) + break; + case SLIMBUS_0_RX ... SLIMBUS_6_TX: q6afe_slim_port_prepare(dai_data->port[dai->id], &dai_data->port_config[dai->id].slim); + break; + case PRIMARY_MI2S_RX ... QUATERNARY_MI2S_TX: + rc = q6afe_i2s_port_prepare(dai_data->port[dai->id], + &dai_data->port_config[dai->id].i2s_cfg); + if (rc < 0) { + dev_err(dai->dev, "fail to prepare AFE port %x\n", + dai->id); + return rc; + } + break; + default: + return -EINVAL; + } rc = q6afe_port_start(dai_data->port[dai->id]); if (rc < 0) { @@ -289,7 +272,7 @@ static struct snd_soc_dai_ops q6hdmi_ops = { }; static struct snd_soc_dai_ops q6i2s_ops = { - .prepare = q6afe_mi2s_prepare, + .prepare = q6afe_dai_prepare, .hw_params = q6i2s_hw_params, .set_fmt = q6i2s_set_fmt, .shutdown = q6afe_dai_shutdown,