Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2571827pxb; Sat, 23 Oct 2021 02:57:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAequQ2X5revdH6MyXc3PjqphoRA5i/37pI/zLMzU403v6pqZ07AIGxDgVE1ErXlICBmTx X-Received: by 2002:a17:906:403:: with SMTP id d3mr6211727eja.321.1634983047654; Sat, 23 Oct 2021 02:57:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634983047; cv=none; d=google.com; s=arc-20160816; b=EDH7rJdPvCMeo1Eej30aC70OCqmLwlHGbUWIGZzpv5GC67p8LRicvOfQ8hLNCs5Qq0 oaGybjoqaVKdB4vWjK5GU2pSuRZhbY2nFmv3Oktnp5x1yfaqPKfp6J6JPP3Ev9FR6o6H 1kmWu6B+7ZSAquaJCM7+5OmOI0IhcXwAKvFJGP0r9S6ytFo9mOd6AWG25YPYZ3N8+Qhp k4JEE2FUjOgTBYnLcFSEjlrINfDIzWAsVhg75DFZ4oABeKTeE8dkBKGXelOld/r/3Sdk yPrIXL2lSuIvwzB+yQVcQQ4GirrxH80agyiXEXKMfZoLArCKveRJSCyUE73+MP6A9jGp 3Pjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dmarc-filter:sender:dkim-signature; bh=ZUDvFPbBnLqQUOEhZHSfxSn7mRT8gBANa7FnKL+byww=; b=fyahcik522hWenAPsUZMdqs5+DL9b9niX19r4Cv/jrdyp/k12KBGFp1ehcBoMHTw2C 3M/laJ+MNjJtuG5/X3qmzP26yJLv/gR+Y4oSO9fmtnt20fjBjYkPH6LhPtw8uuxwBE+h bkq3qiRfAgjAhQ/JrabjkaCa9rT/BSlLpwTa3YOkXuE17q9D+Msc2sC4fOjB7YCjrYVx Q8h3JqCuzAuOQxuJNWmySrm/X3StujHtxxHuKEvWwYexbOmVC0W1eDeElFU3C3+RJx2o k0SU8ANcqaCtScXePzgPKP4AbHp3TGYmlcvtcaaAXdV6JwxvNFwPtxuXN0u7KKfSf8w/ qnOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=DyMvvtZK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id da24si7342597edb.433.2021.10.23.02.57.03; Sat, 23 Oct 2021 02:57:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=DyMvvtZK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231509AbhJWJ5b (ORCPT + 99 others); Sat, 23 Oct 2021 05:57:31 -0400 Received: from so254-9.mailgun.net ([198.61.254.9]:18172 "EHLO so254-9.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230169AbhJWJ5R (ORCPT ); Sat, 23 Oct 2021 05:57:17 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1634982898; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=ZUDvFPbBnLqQUOEhZHSfxSn7mRT8gBANa7FnKL+byww=; b=DyMvvtZK3HOakp+axtXf21CrjM1eKZcf0RGvW2tSrc0oSz23o+rRAP3rDcwJ4u3XCXDbhKLp G6bWYbBtdapwe2+zzOYwDbuIgYecPP7YrxOPrTX5Nh6kz2ThV7r1j3jhSf2IYL1wEDf60PSE J/WlVSuw23wQS9ZfrlroR3MrTF4= X-Mailgun-Sending-Ip: 198.61.254.9 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n07.prod.us-east-1.postgun.com with SMTP id 6173dbe9b03398c06c9881e1 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Sat, 23 Oct 2021 09:54:49 GMT Sender: srivasam=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 94A96C4361A; Sat, 23 Oct 2021 09:54:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00,SPF_FAIL autolearn=no autolearn_force=no version=3.4.0 Received: from hu-srivasam-hyd.qualcomm.com (unknown [202.46.22.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: srivasam) by smtp.codeaurora.org (Postfix) with ESMTPSA id 676ACC4361A; Sat, 23 Oct 2021 09:54:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 smtp.codeaurora.org 676ACC4361A Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=codeaurora.org From: Srinivasa Rao Mandadapu To: agross@kernel.org, bjorn.andersson@linaro.org, lgirdwood@gmail.com, broonie@kernel.org, robh+dt@kernel.org, plai@codeaurora.org, bgoswami@codeaurora.org, perex@perex.cz, tiwai@suse.com, srinivas.kandagatla@linaro.org, rohitkr@codeaurora.org, linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, swboyd@chromium.org, judyhsiao@chromium.org Cc: Srinivasa Rao Mandadapu , Venkata Prasad Potturu Subject: [PATCH v3 05/10] ASoC: qcom: Add helper function to get dma control and lpaif handle Date: Sat, 23 Oct 2021 15:23:57 +0530 Message-Id: <1634982842-7477-6-git-send-email-srivasam@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1634982842-7477-1-git-send-email-srivasam@codeaurora.org> References: <1634982842-7477-1-git-send-email-srivasam@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support function to get dma control and lpaif handle to avoid repeated code in platform driver Signed-off-by: Srinivasa Rao Mandadapu Co-developed-by: Venkata Prasad Potturu Signed-off-by: Venkata Prasad Potturu --- sound/soc/qcom/lpass-platform.c | 90 ++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 47 deletions(-) diff --git a/sound/soc/qcom/lpass-platform.c b/sound/soc/qcom/lpass-platform.c index a44162c..59c0884 100644 --- a/sound/soc/qcom/lpass-platform.c +++ b/sound/soc/qcom/lpass-platform.c @@ -177,6 +177,44 @@ static int lpass_platform_pcmops_close(struct snd_soc_component *component, return 0; } +static void __get_lpaif_handle(struct snd_pcm_substream *substream, + struct snd_soc_component *component, + struct lpaif_dmactl **dmactl, int *id, struct regmap **map) +{ + struct snd_soc_pcm_runtime *soc_runtime = asoc_substream_to_rtd(substream); + struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(soc_runtime, 0); + struct lpass_data *drvdata = snd_soc_component_get_drvdata(component); + struct snd_pcm_runtime *rt = substream->runtime; + struct lpass_pcm_data *pcm_data = rt->private_data; + struct lpass_variant *v = drvdata->variant; + int dir = substream->stream; + unsigned int dai_id = cpu_dai->driver->id; + struct lpaif_dmactl *l_dmactl; + struct regmap *l_map; + int l_id; + + if (dir == SNDRV_PCM_STREAM_PLAYBACK) { + l_id = pcm_data->dma_ch; + if (dai_id == LPASS_DP_RX) { + l_dmactl = drvdata->hdmi_rd_dmactl; + l_map = drvdata->hdmiif_map; + } else { + l_dmactl = drvdata->rd_dmactl; + l_map = drvdata->lpaif_map; + } + } else { + l_dmactl = drvdata->wr_dmactl; + l_id = pcm_data->dma_ch - v->wrdma_channel_start; + l_map = drvdata->lpaif_map; + } + if (dmactl) + *dmactl = l_dmactl; + if (id) + *id = l_id; + if (map) + *map = l_map; +} + static int lpass_platform_pcmops_hw_params(struct snd_soc_component *component, struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) @@ -191,22 +229,12 @@ static int lpass_platform_pcmops_hw_params(struct snd_soc_component *component, unsigned int channels = params_channels(params); unsigned int regval; struct lpaif_dmactl *dmactl; - int id, dir = substream->stream; + int id; int bitwidth; int ret, dma_port = pcm_data->i2s_port + v->dmactl_audif_start; unsigned int dai_id = cpu_dai->driver->id; - if (dir == SNDRV_PCM_STREAM_PLAYBACK) { - id = pcm_data->dma_ch; - if (dai_id == LPASS_DP_RX) - dmactl = drvdata->hdmi_rd_dmactl; - else - dmactl = drvdata->rd_dmactl; - - } else { - dmactl = drvdata->wr_dmactl; - id = pcm_data->dma_ch - v->wrdma_channel_start; - } + __get_lpaif_handle(substream, component, &dmactl, &id, NULL); bitwidth = snd_pcm_format_width(format); if (bitwidth < 0) { @@ -379,24 +407,9 @@ static int lpass_platform_pcmops_prepare(struct snd_soc_component *component, int ret, id, ch, dir = substream->stream; unsigned int dai_id = cpu_dai->driver->id; - ch = pcm_data->dma_ch; - if (dir == SNDRV_PCM_STREAM_PLAYBACK) { - if (dai_id == LPASS_DP_RX) { - dmactl = drvdata->hdmi_rd_dmactl; - map = drvdata->hdmiif_map; - } else { - dmactl = drvdata->rd_dmactl; - map = drvdata->lpaif_map; - } - - id = pcm_data->dma_ch; - } else { - dmactl = drvdata->wr_dmactl; - id = pcm_data->dma_ch - v->wrdma_channel_start; - map = drvdata->lpaif_map; - } + __get_lpaif_handle(substream, component, &dmactl, &id, &map); ret = regmap_write(map, LPAIF_DMABASE_REG(v, ch, dir, dai_id), runtime->dma_addr); if (ret) { @@ -444,26 +457,12 @@ static int lpass_platform_pcmops_trigger(struct snd_soc_component *component, struct lpaif_dmactl *dmactl; struct regmap *map; int ret, ch, id; - int dir = substream->stream; unsigned int reg_irqclr = 0, val_irqclr = 0; unsigned int reg_irqen = 0, val_irqen = 0, val_mask = 0; unsigned int dai_id = cpu_dai->driver->id; ch = pcm_data->dma_ch; - if (dir == SNDRV_PCM_STREAM_PLAYBACK) { - id = pcm_data->dma_ch; - if (dai_id == LPASS_DP_RX) { - dmactl = drvdata->hdmi_rd_dmactl; - map = drvdata->hdmiif_map; - } else { - dmactl = drvdata->rd_dmactl; - map = drvdata->lpaif_map; - } - } else { - dmactl = drvdata->wr_dmactl; - id = pcm_data->dma_ch - v->wrdma_channel_start; - map = drvdata->lpaif_map; - } + __get_lpaif_handle(substream, component, &dmactl, &id, &map); switch (cmd) { case SNDRV_PCM_TRIGGER_START: @@ -597,10 +596,7 @@ static snd_pcm_uframes_t lpass_platform_pcmops_pointer( struct regmap *map; unsigned int dai_id = cpu_dai->driver->id; - if (dai_id == LPASS_DP_RX) - map = drvdata->hdmiif_map; - else - map = drvdata->lpaif_map; + __get_lpaif_handle(substream, component, NULL, NULL, &map); ch = pcm_data->dma_ch; -- Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc., is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.