Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4802971pxv; Tue, 20 Jul 2021 11:48:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCkvfAfe7p2lICLfn8id1CA0mVvALlmty5TSwjlqfON7JShHezkhs9zJEX28ifsSCMX9sC X-Received: by 2002:a05:6638:130d:: with SMTP id r13mr16726262jad.103.1626806923488; Tue, 20 Jul 2021 11:48:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626806923; cv=none; d=google.com; s=arc-20160816; b=rfbCZF0IYkUetrT+Ocox5znSrqVstlGSPSEVTvwLoc8DpQYVE3f/BbRt8/T9TpY2Yv j2efY0FGeOe1lHwpzbKPWjMFXKOEXnn9xrKnLyPQT9efnL387vm1vWQt985G0M8aJBq4 LWkx/OPANigKwe9gpWH4lsbC9wRydp0ddvPOCOOd/BziTBFQ8G/TQQI9KJO9C3myBHiG 41vnncifodMD6v2Ui9YJUL062hv631pNEn4FrOl1XpFtI2wjopBJvA45dP4/DDAkoACx dcZHBSpxC9XE+XInZIbLkIfK0sEyMuvn8cQMaCNLNIyvkkNvu3yCjGodl8kS+pCPqRDH VmGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=eExjput6xi5RS3TFNwywHNzUnedVkVsFYJHyR7AVdAM=; b=AxAl3PpcXhZXTY9GnNUAsrIbeZ1e5fDWIHlD1w3NyuAyZT3t5aMZxUgOKBjwu3Lerp ROInUsalv31biiEZfKHR/e949NnfGFKWSfiIgkX1D0mt2FSYCvuFh6Mj7TT9YzFqj63a 0WWJp/1bt44PO601uOylXa/tF8kt1kMrYpt9pFUXnimz6ADh3LOHRXKM2aMpVSXB298S zGMq8zJOZAv4tNJCXYpWsptpT9nNq/xFRc2Y7GnhMs2WcKT605k8NqOr/fGzo/XgVm/j G7BaMlYkhRGPtjJMuI0Nyj7Qm4meA0e7Z6BGr5xR+rYn6G3dEb+VOvA/EZJ5Nft8ZAHn vvaQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d13si15914958iod.50.2021.07.20.11.48.31; Tue, 20 Jul 2021 11:48:43 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231865AbhGTSG4 (ORCPT + 99 others); Tue, 20 Jul 2021 14:06:56 -0400 Received: from mga05.intel.com ([192.55.52.43]:2800 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229818AbhGTSGw (ORCPT ); Tue, 20 Jul 2021 14:06:52 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10051"; a="296869491" X-IronPort-AV: E=Sophos;i="5.84,255,1620716400"; d="scan'208";a="296869491" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2021 11:47:29 -0700 X-IronPort-AV: E=Sophos;i="5.84,255,1620716400"; d="scan'208";a="462146675" Received: from aremenni-mobl.amr.corp.intel.com (HELO [10.209.130.10]) ([10.209.130.10]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2021 11:47:28 -0700 Subject: Re: [PATCH v4 07/12] ASoC: amd: add ACP5x pcm dma driver ops To: Vijendar Mukunda , broonie@kernel.org, alsa-devel@alsa-project.org Cc: Sunil-kumar.Dommati@amd.com, open list , Takashi Iwai , Liam Girdwood , Alexander.Deucher@amd.com, krisman@collabora.com References: <20210720163732.23003-1-Vijendar.Mukunda@amd.com> <20210720163732.23003-8-Vijendar.Mukunda@amd.com> From: Pierre-Louis Bossart Message-ID: <331065bd-32d5-45eb-37fc-d4fc76c23fe8@linux.intel.com> Date: Tue, 20 Jul 2021 13:27:45 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210720163732.23003-8-Vijendar.Mukunda@amd.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > +static int acp5x_dma_open(struct snd_soc_component *component, > + struct snd_pcm_substream *substream) > +{ > + struct snd_pcm_runtime *runtime; > + struct snd_soc_pcm_runtime *prtd; > + struct i2s_dev_data *adata; > + struct i2s_stream_instance *i2s_data; > + int ret; > + > + runtime = substream->runtime; > + prtd = asoc_substream_to_rtd(substream); > + component = snd_soc_rtdcom_lookup(prtd, DRV_NAME); > + adata = dev_get_drvdata(component->dev); > + > + i2s_data = kzalloc(sizeof(*i2s_data), GFP_KERNEL); > + if (!i2s_data) > + return -EINVAL; return -ENOMEM? > + > + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) > + runtime->hw = acp5x_pcm_hardware_playback; > + else > + runtime->hw = acp5x_pcm_hardware_capture; > + > + ret = snd_pcm_hw_constraint_integer(runtime, > + SNDRV_PCM_HW_PARAM_PERIODS); > + if (ret < 0) { > + dev_err(component->dev, "set integer constraint failed\n"); > + kfree(i2s_data); > + return ret; > + } > + i2s_data->acp5x_base = adata->acp5x_base; > + runtime->private_data = i2s_data; > + return ret; > +} > + > +static int acp5x_dma_hw_params(struct snd_soc_component *component, > + struct snd_pcm_substream *substream, > + struct snd_pcm_hw_params *params) > +{ > + struct i2s_stream_instance *rtd; > + struct snd_soc_pcm_runtime *prtd; > + struct snd_soc_card *card; > + struct acp5x_platform_info *pinfo; > + struct i2s_dev_data *adata; > + u64 size; > + > + prtd = asoc_substream_to_rtd(substream); > + card = prtd->card; > + pinfo = snd_soc_card_get_drvdata(card); > + adata = dev_get_drvdata(component->dev); > + rtd = substream->runtime->private_data; > + > + if (!rtd) > + return -EINVAL; > + > + if (pinfo) { > + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { > + rtd->i2s_instance = pinfo->play_i2s_instance; > + switch (rtd->i2s_instance) { > + case I2S_HS_INSTANCE: > + adata->play_stream = substream; > + break; > + case I2S_SP_INSTANCE: > + default: > + adata->i2ssp_play_stream = substream; > + } > + } else { > + rtd->i2s_instance = pinfo->cap_i2s_instance; > + switch (rtd->i2s_instance) { > + case I2S_HS_INSTANCE: > + adata->capture_stream = substream; > + break; > + case I2S_SP_INSTANCE: > + default: > + adata->i2ssp_capture_stream = substream; > + } > + } > + } else { > + dev_err(component->dev, "pinfo failed\n"); should you bail here with e.g. return -EINVAL? > + } > + size = params_buffer_bytes(params); > + rtd->dma_addr = substream->dma_buffer.addr; > + rtd->num_pages = (PAGE_ALIGN(size) >> PAGE_SHIFT); > + config_acp5x_dma(rtd, substream->stream); > + return 0; > +}