Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3467147rdg; Tue, 17 Oct 2023 16:23:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGVdgHckiYmFzNB1RheXnOWnUdi1hhJycbkA70ikzKvCx4uogz0YV0esioUWjOg73W8MEWH X-Received: by 2002:aa7:8557:0:b0:68f:c2f7:cef0 with SMTP id y23-20020aa78557000000b0068fc2f7cef0mr4233646pfn.4.1697585038983; Tue, 17 Oct 2023 16:23:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697585038; cv=none; d=google.com; s=arc-20160816; b=NnLY7TxzWiZPyeUfMhOKCg6+vOVwKpXFri+8n7BJP/vlXrsTQmr44hrizP+Zj12qen QPW9Fdh/vvSK58MnswQfAxuYPq74uZY2tX4gnVKd5FrCPqy1V0O8Si3LZ3oRQr/pih6B u195qdmNQ+PJ73YcLHDCtw9VjE6fX7L0WNncnUn9/XJIwJyej0HwwzDc6MiKMMIH4+Kp F4CMUhHYSgSZjAwSh/8GuKYkecjpmm0ud/PA5EfqVDHeCEpmnCQPqc5v1hfD2TwPOr0M oJ/qkrVX5x53+CPh754XZDVIEXK+g/YrTtJAXzeWpilzVfiPJBsn6wEQSStH9uzUpYeu ptFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=UrUD+WLokRrlDHcT1gjOaNaq+l9MV5NBp6HTdAKRTlU=; fh=T2kIl/luTXifFXsTyrv3SMMIMK/cqEF9ESJJzecA3Cs=; b=w19L1YR3S617Bs4GhOvlUu7ouEdZYclWktR1fRkzFG2gfYeqvfGiO5jOhJuyUZsWH6 mWetitL/3buz9yRQnCQDPqBkPDLOu0m1IPkHIH1PHWv9cShuk72B8Pw6h00haCCOLRTw z/R1HH/lavL2iWv+hYrNPRSi/WKfsvXQ8iG81DaJdbBtpT7/cEWtAuNeCaK5i6SnjkvE 4Bxrd4SR8Gf0X2bXfGnN2OXU4qB/TgNI9wZZJhDcK6oq/+jpX0vBfJARVMIf8fYKFu0x ilEGE5MMLeIQgcHu+Lo8L6C177refTBoI6Xs3KX3x9evKjBahON71/d3RSX08ZKE/ZgK OPjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TISbaAiS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id f21-20020a056a0022d500b0069109ee0b59si2727773pfj.231.2023.10.17.16.23.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 16:23:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TISbaAiS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 50DD2802710C; Tue, 17 Oct 2023 16:23:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344394AbjJQXXl (ORCPT + 99 others); Tue, 17 Oct 2023 19:23:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344382AbjJQXXZ (ORCPT ); Tue, 17 Oct 2023 19:23:25 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0A9A11A; Tue, 17 Oct 2023 16:23:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697585002; x=1729121002; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=pTPWau1gXZiNQk+t/6022j9X4kWrUjddW9GC378AbPM=; b=TISbaAiSWyKzv0bI9kAEG1PWUjeP0g73zun1L4EoB52PaRq0MX+Riqmx gY0T+WyZTLwEuxwGmtig6Fyd2xa4ZKJiAr9Q7NqR/0e+jmxcxJFkNbDvr QCQul1hgqkkLLHQosScWZgThKvKfAogkcPi/GHnULGhu0SXPk2/prIGXJ DihdZJJ6tHbP4EaZbIHu7SmfHswxBRw4Nwf4SlWMFPKeZIHdJYKOq8yDF wPI71qZYl54oH2LfI69L7lK2eHXXfVBxfSkH/J58PYdboO4YmCEq8AjhI BYQj8fEExQNKsIBLwH1PudMVpr1sA2LnmdsvSarIVHd+qTdFQNFwQ39Kh w==; X-IronPort-AV: E=McAfee;i="6600,9927,10866"; a="384778142" X-IronPort-AV: E=Sophos;i="6.03,233,1694761200"; d="scan'208";a="384778142" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2023 16:23:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10866"; a="826637480" X-IronPort-AV: E=Sophos;i="6.03,233,1694761200"; d="scan'208";a="826637480" Received: from asprado-mobl2.amr.corp.intel.com (HELO [10.212.55.179]) ([10.212.55.179]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2023 16:23:21 -0700 Message-ID: Date: Tue, 17 Oct 2023 17:39:04 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v9 26/34] ASoC: qcom: qdsp6: q6afe: Split USB AFE dev_token param into separate API Content-Language: en-US To: Wesley Cheng , mathias.nyman@intel.com, gregkh@linuxfoundation.org, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, srinivas.kandagatla@linaro.org, bgoswami@quicinc.com, Thinh.Nguyen@synopsys.com Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org References: <20231017200109.11407-1-quic_wcheng@quicinc.com> <20231017200109.11407-27-quic_wcheng@quicinc.com> From: Pierre-Louis Bossart In-Reply-To: <20231017200109.11407-27-quic_wcheng@quicinc.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 17 Oct 2023 16:23:56 -0700 (PDT) On 10/17/23 15:01, Wesley Cheng wrote: > The Q6USB backend can carry information about the available USB SND cards > and PCM devices discovered on the USB bus. The dev_token field is used by > the audio DSP to notify the USB offload driver of which card and PCM index > to enable playback on. Separate this into a dedicated API, so the USB > backend can set the dev_token accordingly. The audio DSP does not utilize > this information until the AFE port start command is sent, which is done > during the PCM prepare phase. > > Signed-off-by: Wesley Cheng > --- > sound/soc/qcom/qdsp6/q6afe.c | 49 +++++++++++++++++++++++++----------- > sound/soc/qcom/qdsp6/q6afe.h | 1 + > 2 files changed, 36 insertions(+), 14 deletions(-) > > diff --git a/sound/soc/qcom/qdsp6/q6afe.c b/sound/soc/qcom/qdsp6/q6afe.c > index 72c4e6fe20c4..f09a756246f8 100644 > --- a/sound/soc/qcom/qdsp6/q6afe.c > +++ b/sound/soc/qcom/qdsp6/q6afe.c > @@ -1394,10 +1394,42 @@ void q6afe_tdm_port_prepare(struct q6afe_port *port, > } > EXPORT_SYMBOL_GPL(q6afe_tdm_port_prepare); > > -static int afe_port_send_usb_dev_param(struct q6afe_port *port, struct q6afe_usb_cfg *cfg) > +/** > + * afe_port_send_usb_dev_param() - Send USB dev token > + * > + * @port: Instance of afe port > + * @cardidx: USB SND card index to reference > + * @pcmidx: USB SND PCM device index to reference > + * > + * The USB dev token carries information about which USB SND card instance and > + * PCM device to execute the offload on. This information is carried through > + * to the stream enable QMI request, which is handled by the offload class > + * driver. The information is parsed to determine which USB device to query > + * the required resources for. > + */ > +int afe_port_send_usb_dev_param(struct q6afe_port *port, int cardidx, int pcmidx) > { > - union afe_port_config *pcfg = &port->port_cfg; > struct afe_param_id_usb_audio_dev_params usb_dev; > + int ret; > + > + memset(&usb_dev, 0, sizeof(usb_dev)); > + > + usb_dev.cfg_minor_version = AFE_API_MINOR_VERSION_USB_AUDIO_CONFIG; > + usb_dev.dev_token = (cardidx << 16) | (pcmidx << 8); > + ret = q6afe_port_set_param_v2(port, &usb_dev, > + AFE_PARAM_ID_USB_AUDIO_DEV_PARAMS, > + AFE_MODULE_AUDIO_DEV_INTERFACE, sizeof(usb_dev)); > + if (ret) > + dev_err(port->afe->dev, "%s: AFE device param cmd failed %d\n", > + __func__, ret); > + > + return ret; > +} > +EXPORT_SYMBOL_GPL(afe_port_send_usb_dev_param); > + > +static int afe_port_send_usb_params(struct q6afe_port *port, struct q6afe_usb_cfg *cfg) > +{ > + union afe_port_config *pcfg = &port->port_cfg; > struct afe_param_id_usb_audio_dev_lpcm_fmt lpcm_fmt; > struct afe_param_id_usb_audio_svc_interval svc_int; > int ret = 0; > @@ -1408,20 +1440,9 @@ static int afe_port_send_usb_dev_param(struct q6afe_port *port, struct q6afe_usb > goto exit; > } > > - memset(&usb_dev, 0, sizeof(usb_dev)); > memset(&lpcm_fmt, 0, sizeof(lpcm_fmt)); > memset(&svc_int, 0, sizeof(svc_int)); > > - usb_dev.cfg_minor_version = AFE_API_MINOR_VERSION_USB_AUDIO_CONFIG; > - ret = q6afe_port_set_param_v2(port, &usb_dev, > - AFE_PARAM_ID_USB_AUDIO_DEV_PARAMS, > - AFE_MODULE_AUDIO_DEV_INTERFACE, sizeof(usb_dev)); > - if (ret) { > - dev_err(port->afe->dev, "%s: AFE device param cmd failed %d\n", > - __func__, ret); > - goto exit; > - } > - this feels like a questionable patch split. Why not introduce the new helper earlier and avoid adding code then modifying the same code? > lpcm_fmt.cfg_minor_version = AFE_API_MINOR_VERSION_USB_AUDIO_CONFIG; > lpcm_fmt.endian = pcfg->usb_cfg.endian; > ret = q6afe_port_set_param_v2(port, &lpcm_fmt, > @@ -1463,7 +1484,7 @@ void q6afe_usb_port_prepare(struct q6afe_port *port, > pcfg->usb_cfg.num_channels = cfg->num_channels; > pcfg->usb_cfg.bit_width = cfg->bit_width; > > - afe_port_send_usb_dev_param(port, cfg); > + afe_port_send_usb_params(port, cfg); > } > EXPORT_SYMBOL_GPL(q6afe_usb_port_prepare); > > diff --git a/sound/soc/qcom/qdsp6/q6afe.h b/sound/soc/qcom/qdsp6/q6afe.h > index ef47b4ae9e27..2ce5ba9dba69 100644 > --- a/sound/soc/qcom/qdsp6/q6afe.h > +++ b/sound/soc/qcom/qdsp6/q6afe.h > @@ -263,6 +263,7 @@ void q6afe_tdm_port_prepare(struct q6afe_port *port, struct q6afe_tdm_cfg *cfg); > void q6afe_cdc_dma_port_prepare(struct q6afe_port *port, > struct q6afe_cdc_dma_cfg *cfg); > > +int afe_port_send_usb_dev_param(struct q6afe_port *port, int cardidx, int pcmidx); > int q6afe_port_set_sysclk(struct q6afe_port *port, int clk_id, > int clk_src, int clk_root, > unsigned int freq, int dir);