From patchwork Wed Mar 8 23:57:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wesley Cheng X-Patchwork-Id: 660726 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 097E2C678D5 for ; Wed, 8 Mar 2023 23:58:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230188AbjCHX6t (ORCPT ); Wed, 8 Mar 2023 18:58:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229937AbjCHX6d (ORCPT ); Wed, 8 Mar 2023 18:58:33 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAA1B99C28; Wed, 8 Mar 2023 15:58:31 -0800 (PST) Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 328D89M3012562; Wed, 8 Mar 2023 23:58:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=huk+KaMEoKJXon78kCi9B0/eB6R2iMd3neoEP1lz1zk=; b=oUxvtSGkvMefo27+fSEzURtmOw1IRSAmdjKqNTNceDG34SMoaM3auoE30gKMx5pp8a3g GBT5qc2ZDT6s53tl1gJDAROJf1iqUu+/9zgu0a9y5lR4t13qko4lvjaeGjgW3Dmhf7Vl EXcufhyceV6p60dnReknIwRxnzgjB57ZbBwiolj+tOnC9+PdhQkUBSgCRc3BTVHpQd8E EhpbHTERv+MTVpMJcRLKlXYbgODUoh7yw8Xq1fGV+rrZakQZQQ86v3Zom/097N3z1Nke BS4zfQrpF7ElSis08EVTzrlpCLQ2p1QqGWr2tbm94JpoVt9xFB4ZUVyxTZhbbTOfDbWq jw== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3p6fgfu8pw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 08 Mar 2023 23:58:12 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 328NwBMS015030 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 8 Mar 2023 23:58:11 GMT Received: from hu-wcheng-lv.qualcomm.com (10.49.16.6) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Wed, 8 Mar 2023 15:58:11 -0800 From: Wesley Cheng To: , , , , , , , , , , , , CC: , , , , , , , Wesley Cheng Subject: [PATCH v3 22/28] ASoC: qcom: qdsp6: q6afe: Split USB AFE dev_token param into separate API Date: Wed, 8 Mar 2023 15:57:45 -0800 Message-ID: <20230308235751.495-23-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230308235751.495-1-quic_wcheng@quicinc.com> References: <20230308235751.495-1-quic_wcheng@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01a.na.qualcomm.com (10.47.209.196) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: OIRnSBwxU824tdyky7og2RoWXtFOu7bS X-Proofpoint-ORIG-GUID: OIRnSBwxU824tdyky7og2RoWXtFOu7bS X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_15,2023-03-08_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 bulkscore=0 impostorscore=0 mlxscore=0 phishscore=0 adultscore=0 lowpriorityscore=0 suspectscore=0 priorityscore=1501 malwarescore=0 mlxlogscore=999 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303080200 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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 e9d5fa6b6b0d..505371c96987 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; - 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; - } - 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, @@ -1465,7 +1486,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 e098a3e15135..7980416275e9 100644 --- a/sound/soc/qcom/qdsp6/q6afe.h +++ b/sound/soc/qcom/qdsp6/q6afe.h @@ -274,6 +274,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);