Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3927595pxb; Tue, 2 Nov 2021 00:35:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycaQrwKqO1hxUaxZ51AZF1Oye78jp8NsKvoH3LW44Vf4iZaug2zAD77GEQJLwQn31O/xS9 X-Received: by 2002:a17:907:60c9:: with SMTP id hv9mr23537781ejc.334.1635838540605; Tue, 02 Nov 2021 00:35:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635838540; cv=none; d=google.com; s=arc-20160816; b=Vzjk+IXE8Rxrb+TO8iXo7fqXIfB8pwSWftolgGtyDQyvRsFfpPeGQ3LDo4WRCS0BEx o6j8Yi8qnH/BeQ2Zm+SUhXZEdfJ9uitUAUJw0Xgy6pyfhDFIEoHlmi/J4I9Ocw8D5p8j L224YY8VgrIBVkbc67693psmvQEwFeZkPT9koh+pR4StLlg+zP5fbhveJHyrzr68j5XB cK5LLbZ6Eb1paUAMpXbyYZCPnsmszYh47KJ9rGnOJnpZ3g6vncaFNvDlUeKdJi8IY50k nc/4HiUEByf9uj3U+uScj/b18GqSbhDWm/QtucN02ilnBY3Eg6MFCbRX4j4178e5N8SJ Dinw== 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=EcIJTkNDb40TQyQV7ZHz3Jb1ARmO6vRo9NQxWG+3Bxl5LssvyRloyekJPBAIplPdNT LUahVpTzZUlfJErxDDHfq8O2bYb4dVhGxmLVSyFmR5t5PZP111KG93qNjQgc3Abf4Hxn xldfLNYrpePCORBbY049DQ1TqpzgNyYWtI9eVyjpiuXQanmlNZmIHg33BIYFvwTQ7pzk aq+NeluHvfa/395/c47zbb9nDMT4SBqeQfG4S3oe0QxTI1TPkvE1hFU2Bt7BGneJMGcF xLV8Hmtum4ZDWao6Z4GODIiHs6e1lP3+flnBWQESN728YuoAlyPKQrAX55o4knCmA24Y 39Cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=aoPN9mUu; 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 t20si148370edd.178.2021.11.02.00.35.16; Tue, 02 Nov 2021 00:35:40 -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=aoPN9mUu; 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 S231446AbhKBHeb (ORCPT + 99 others); Tue, 2 Nov 2021 03:34:31 -0400 Received: from so254-9.mailgun.net ([198.61.254.9]:50541 "EHLO so254-9.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230109AbhKBHe1 (ORCPT ); Tue, 2 Nov 2021 03:34:27 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1635838313; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=ZUDvFPbBnLqQUOEhZHSfxSn7mRT8gBANa7FnKL+byww=; b=aoPN9mUuy7TsWqfxfJG1t32VKY/xJdvalHq+DJMqe0BMxArRqlSf5z6Tn7zuvTHjz/bx403W KZzXoelDshFI2KNaK+c6SerCkmlHt/W+IBtI4bqIiIUvS+gnn+sZhDdeoyVDPp+qLU4xYxJO IFnK092Px8esS4MiMW542/la53Y= 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-n02.prod.us-east-1.postgun.com with SMTP id 6180e9692e144ac4d35c7511 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 02 Nov 2021 07:31:52 GMT Sender: srivasam=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 351CAC43460; Tue, 2 Nov 2021 07:31:52 +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 0383FC43460; Tue, 2 Nov 2021 07:31:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 smtp.codeaurora.org 0383FC43460 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 v4 05/10] ASoC: qcom: Add helper function to get dma control and lpaif handle Date: Tue, 2 Nov 2021 13:01:00 +0530 Message-Id: <1635838265-27346-6-git-send-email-srivasam@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1635838265-27346-1-git-send-email-srivasam@codeaurora.org> References: <1635838265-27346-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.