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: 10434991 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 113C6602BF for ; Tue, 29 May 2018 11:07:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F2508286AC for ; Tue, 29 May 2018 11:07:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E566B286E4; Tue, 29 May 2018 11:07: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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5B316286AC for ; Tue, 29 May 2018 11:07:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=7+K1vB7rbjVsmDNfXUFHCvXbZD9ExgswTu64gQz040E=; b=dbJxxIFVvKpE0F/1Pcbo20LhpR GAbCHgGyPiNUbM3kNYF/FmaDoDgXP6kaDSFoI8E6q2AhXyS92Xeq3ibnwUrD6nlRxCGWqdjF8nXHU wS7MCyfEFr3x6GnkUky9GjA2ZdorP8xAWdjGG/X76DxHeGAZLEOib9eSGBt0x1i0MofMgUyhfr+5f fMlsEJZ+Emr/STvg9asMH+q3/F+H//UZucrlcTaiYCADjEbZhljBDkAAXA6U8vfLGa11ll+ZND8p7 UHat9tTiEVBrcz99IhOvgdi3Th6aR/MjwyjoJogQ3NuDw1gHypo+PVgqzarwsWBRpm44JjsDo/ZqF wwtwW0BQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fNcT6-0006wY-FA; Tue, 29 May 2018 11:07:08 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fNcRU-00067c-Mv for linux-arm-kernel@bombadil.infradead.org; Tue, 29 May 2018 11:05:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=bW+9ST8toUlXAFZ70AykoH2+2+K96WTJIwTYBYkWJVE=; b=0Vrc+mtg1CWIKQd9SfrP8C4xB jLd7R14b1VQKrkzXsG5F2rdc1m1oeRi0iNRSfOLpx8bWUPz/khTwEsFovfG9k/zx9dEkqiYMekTtS C2ZX3ha120lnhnCFprUjaGffVQ8xA3dxl+v3DcILbCoGj2rscAHgwgBnNu02XIOYxnzOwySKAHjNE FsX0d1BfcRLnf4IAEOe4EyIS2vMJUX9hajEvpcJg/pn1PODyxJnXWHVZ5naUeISXVji9hfGHnhEb4 0STicNh1B2CXxNceb54ldGpnozTircaGyypTHFNnYT6ZgSNSB28hu7edRoTXTRYbzmrDn3Zu/OtOV j3NhjJzzQ==; Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fNbka-00073h-03 for linux-arm-kernel@lists.infradead.org; Tue, 29 May 2018 10:21:09 +0000 Received: by mail-wr0-x244.google.com with SMTP id w10-v6so24555432wrk.9 for ; Tue, 29 May 2018 03:20:57 -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=tMgl0u6vuzpzWu/x/XqIYXk77ak1gvUvLAXKRt5UjAuv0jGqYLg+52HB93qCmJo8uu Hi69eJYtSBCyNMkE5OiPhJcDVHdfuI/3qxc61OBj5zKPBh8sGH3gSj8pHn9oRuCjVYFB KmE9Ol9kXnBOFaiVeoJAJjs6ZWfHgSaxJ9hS7eT9fBz06qxIaAUFdzpBbeycuIfSFLWv 8AxfColuF2fMShWUVwxTzrL2xEx5sAo/m+saIt3VDywZibCcs5/IcbE9WqsugNnErdRv nqTZZ6LF81Ed3P7aV+J0nTw8gmUhGTBO+V+D0rf6zD8Kw0AlSNOjDjAliBE6EVF0Xlc4 ZfVQ== X-Gm-Message-State: ALKqPwfUzCFLzddPeDLhQq7zg60PvddbfHIE/JV1xaxI/s3r6zRqFZbs 523lqNwSGkCA0xmN7WzVuQ80Kw== 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 Subject: [PATCH 3/6] ASoC: qdsp6: q6afe-dai: use q6afe_dai_prepare() for MI2S 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180529_062108_082874_BC8AFF4C X-CRM114-Status: GOOD ( 18.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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, perex@perex.cz, Srinivas Kandagatla , spatakok@qti.qualcomm.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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,