From patchwork Sat Sep 16 00:10:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wesley Cheng X-Patchwork-Id: 141070 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1724726vqi; Sat, 16 Sep 2023 08:42:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFM155u2i8JODg7DUv6rVsb6biy/AtGBvnCbGzMGwfntfYdgIJFVN3Z+yFAnZU1dQqVG2tt X-Received: by 2002:a17:90b:1e11:b0:274:638d:da9a with SMTP id pg17-20020a17090b1e1100b00274638dda9amr4103647pjb.34.1694878924195; Sat, 16 Sep 2023 08:42:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694878924; cv=none; d=google.com; s=arc-20160816; b=GYjBtGs0ONMNKGkhjbNeaAUoQAjpu3Nbg/vzzPYfqlPZF+AhGPc0WunfkKrJgFTEXl BuhwGseetN3zmD+jpyKL16tLt8MS4/87dMZvOZjhxLTpHwi8m7kYWHKWCY31hIPR24Wf qqCRPmzPKoSi+VVb0HYAoreqf/e25bYPVgYssNhI7d494MA335rBe38sM9mw3S4YSouq LylhwDxQeJra2MRJwJdnWOhfQfhiHJ3oxut11t08XrmfoLA7VAt8IFmHh/gihdve0/gD qA1Uq5T+Si2CCoghKvvlOweRfreeW9b/cg+HruoT0SR5zXa7yootawT7gqmZcqyU/JuW kX+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=NmQu8MFx2lZ7/sy3a7JXrsNnPwmoH+GDE19rppIQVy8=; fh=MhCCCRx4c0AeUz43uLzZOKA4YzcBN2mk3tAWrRRVvW4=; b=lNSAbQCRjw3tp/pkkrzv9oTu2ioV7Ii94ogqoFKgvHDKpFW/+9EyQUZTqyfgVuK9Uo tvZMvToqiol2rhDBxeP5xY0cvec8xMT3FEpQgs+TNvzGmvylXHLJd/9gxVAAXO4VYIhD ttLcbznZVgKWHFNxSIv+JvzQihqLUvWYgHHMWH9fUkszGNlIZEmwiUloZAX38TPEt0uV nFQJtSUK3+6LZX2PDwVsG9Pde8l54C/nBaOKSc92AF7EdsVNbmeHZeNZSL1mGkhqn3Ie hlwe57TtaeuCKepD0lANDhmSBdGSEuv4FUpbDFFCugoPPZ0/kHXlq/C9UYgfln+jRkYV wPGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=eDVl3oEn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id a12-20020a17090a8c0c00b00263638bb354si7372710pjo.93.2023.09.16.08.42.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 08:42:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=eDVl3oEn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 34B6D823CC77; Fri, 15 Sep 2023 17:15:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235345AbjIPAMR (ORCPT + 28 others); Fri, 15 Sep 2023 20:12:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238186AbjIPALN (ORCPT ); Fri, 15 Sep 2023 20:11:13 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2913C2710; Fri, 15 Sep 2023 17:11:08 -0700 (PDT) Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38FNuSgi027183; Sat, 16 Sep 2023 00:10:45 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=NmQu8MFx2lZ7/sy3a7JXrsNnPwmoH+GDE19rppIQVy8=; b=eDVl3oEny2/ATCZx4oOViLXPlZulUyQPaH+ewWocW1p21vIG26MB8D/XUuWQbu0TNnMp rHrOuWIPuuwIdq7TcPM6Qo0d4PgWJpPqNU6dEDZwKxKrFZWuV67WP75Ev/Fo10s53xD8 EPnOV6totWU8kPbNoOGZrxwXnPZYNsPBPXJDB/+fymoaXqc0JNLR5Q9VZnxXaPo/qUdt ZbchnlBCJ2hAYA4dI1H+lh2kKV8dAl1+qXeRRHkT8sktJ0LtxbLJWSblK4Ark2xfYNZu 5eu4CA8CysOfZjrtQqVa/x6dnu0TbvqCev2JpUgW5QA88VKtaLeIL2rVCLVXqlfj1Z6b HQ== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3t4dvqtsws-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 16 Sep 2023 00:10:45 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 38G0AinM027139 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 16 Sep 2023 00:10:44 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.1118.36; Fri, 15 Sep 2023 17:10:44 -0700 From: Wesley Cheng To: , , , , , , , , , , , , , , CC: , , , , , Wesley Cheng Subject: [PATCH v6 26/33] ALSA: usb-audio: qcom: Populate PCM and USB chip information Date: Fri, 15 Sep 2023 17:10:19 -0700 Message-ID: <20230916001026.315-27-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230916001026.315-1-quic_wcheng@quicinc.com> References: <20230916001026.315-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: P10v1dq7kayIu9bHxYWH3MnMXfpcIQNS X-Proofpoint-ORIG-GUID: P10v1dq7kayIu9bHxYWH3MnMXfpcIQNS X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-15_20,2023-09-15_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 suspectscore=0 lowpriorityscore=0 spamscore=0 impostorscore=0 bulkscore=0 clxscore=1015 mlxlogscore=661 phishscore=0 adultscore=0 malwarescore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309160000 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (howler.vger.email [0.0.0.0]); Fri, 15 Sep 2023 17:15:42 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777209362449643332 X-GMAIL-MSGID: 1777209362449643332 Currently, only the index to the USB SND card array is passed to the USB backend. Pass through more information, specifically the USB SND card number and the number of PCM devices available. This allows for the DPCM backend to determine what USB resources are available during situations, such as USB audio offloading. Signed-off-by: Wesley Cheng --- sound/usb/qcom/qc_audio_offload.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/sound/usb/qcom/qc_audio_offload.c b/sound/usb/qcom/qc_audio_offload.c index 2ce39aa26906..2dffe7e99e01 100644 --- a/sound/usb/qcom/qc_audio_offload.c +++ b/sound/usb/qcom/qc_audio_offload.c @@ -175,6 +175,21 @@ enum usb_qmi_audio_format { USB_QMI_PCM_FORMAT_U32_BE, }; +static int usb_qmi_get_pcm_num(struct snd_usb_audio *chip, int direction) +{ + struct snd_usb_substream *subs = NULL; + struct snd_usb_stream *as; + int count = 0; + + list_for_each_entry(as, &chip->pcm_list, list) { + subs = &as->substream[direction]; + if (subs->ep_num) + count++; + } + + return count; +} + static enum usb_qmi_audio_device_speed_enum_v01 get_speed_info(enum usb_device_speed udev_speed) { @@ -1579,6 +1594,8 @@ static void qc_usb_audio_offload_probe(struct snd_usb_audio *chip) sdev->card_idx = chip->card->number; sdev->chip_idx = chip->index; + sdev->num_playback = usb_qmi_get_pcm_num(chip, 0); + sdev->num_capture = usb_qmi_get_pcm_num(chip, 1); uadev[chip->card->number].sdev = sdev; uaudio_qdev->last_card_num = chip->card->number; @@ -1693,10 +1710,8 @@ static void qc_usb_audio_offload_disconnect(struct snd_usb_audio *chip) mutex_unlock(&chip->mutex); atomic_dec(&uaudio_qdev->qdev_in_use); - if (!atomic_read(&uaudio_qdev->qdev_in_use)) { - snd_soc_usb_disconnect(usb_get_usb_backend(udev)); + if (!atomic_read(&uaudio_qdev->qdev_in_use)) qc_usb_audio_cleanup_qmi_dev(); - } mutex_unlock(&qdev_mutex); }