Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1409432lqd; Thu, 25 Apr 2024 15:01:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVmhvqg3QT+qGaiaVC9iIshz3p9Kx25LcKnTKVOTyMA/s1SrPh/5G3xhIv460a7xWfQZPL+J0FYNrGVMNUckrfwysn2FkySfNSrBJ1TCg== X-Google-Smtp-Source: AGHT+IEnfpKKluOukns4kLamz/bwIAyQqKEK+FglaHo0TNfVUtfTq08jWxuPsx6P8AVkNNSz7uX6 X-Received: by 2002:a05:620a:4047:b0:790:9e66:280b with SMTP id i7-20020a05620a404700b007909e66280bmr1057388qko.11.1714082489753; Thu, 25 Apr 2024 15:01:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714082489; cv=pass; d=google.com; s=arc-20160816; b=m6hC04S+sPeXX3jon7PhYlPl9Yrg3jmTCSJDMu6sEPawTmxyBq6m37deWDBJeyH0a7 1/Pz7siQLLg7wC/0zgZV4v8wx4UKuRVh2+tUdkjuyTr2yPL0YThiqPXNgX2ZtGJ2RiYj 8K9QU7b5g6/eKb+rKrqU7FeGTxq98UcLK9id8kubYeGRMjEvL2k1HwHsu9//ZqtvQt3r Ddd5EKIa3KK5KB9zPOxqGev5QoyhvsGrGVmc5bdOzIwI2uY5LSdt7nmwe1AkgVnQBHIX iiWK5chAWSYiFVG7gigYvpjLqjQdFkYf5tLYY44QD15uJjTwpYwMI+AM/nQ92G7PPYPj zzZA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mL1d9of0fYQNr1X8ZHr/nFQmz8o9xxbVoHzFoYQwCnU=; fh=usWEz1eJjYCle08WABmDyuqCrJGq9m48/LVlmybnzRs=; b=0Afk593QPGp8gSIElBYYxCIpxf9DrVLCXaD9wj69IPcoAAVMzsV5Yhm26USdhCQDRg cHW6khB9wScg09n44hq2MzFN02m52pBnYowvu2bi0sXO6DJvh7lKsaSBJBFsmbLNnb8S 9utOzn90nszMTxJbjTr64zo/8geqHmo5+rChKjWtiYnp/pTq9WvArphaga3lbGcxvGo9 9vhcZ3Xzg+XQsQ11s1HzUAB4KVo/DOb4ny7WnHuRzNrd88ZqHXQUoehAvDCwnN7Zp4yj k8P0xv9IVkB/3tqcj8q7odiX6QLtASRGIqRjxcSV9n2x2Fme8GQaiYotXdHgfGvx+GGC +ZSw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=bhlxQ7yK; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-159268-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159268-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id ou23-20020a05620a621700b0078ecf714375si17741929qkn.785.2024.04.25.15.01.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 15:01:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-159268-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=bhlxQ7yK; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-159268-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159268-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 788981C21914 for ; Thu, 25 Apr 2024 22:01:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C17A919DF63; Thu, 25 Apr 2024 21:52:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="bhlxQ7yK" Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2616817F384; Thu, 25 Apr 2024 21:52:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714081941; cv=none; b=q3SLrBtvxdW2aCrPICxJt6p1g6jsgO2CgwRBXtk6Drpdj8B2V7DQ/2Re63RRAT1JU3ikCnDuL66xU+SbfS5uQ2oyhnPY1wsRX2NVIHpsn/gAeK41kTklnjpn7FDwPBoYEmTd5kB2JxYqCnKznoYIyAmigluYPQkQR5BYAdLGNJ0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714081941; c=relaxed/simple; bh=nCfaXQKjVF52n+UdvJaBQMLni4Yc4r7EoaITJoVMs3E=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=i0Ugfc368vyxVQm6kHLelxA4vLu9I+KXptiCB3GPRbx7dRxVHV9FFQr+AOziq2UD6elTPkz5abTMqSQEFz/BwkaO+G3bCx/LTFZP5WVxoUY+x/x6IPKfoNMCNgZJrj6SCoDuI2KG4CYOGxrnHWFi6YSQJCyCfFbAGtoWi8jClBo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=bhlxQ7yK; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 43PKi3Fr018778; Thu, 25 Apr 2024 21:51:48 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=mL1d9of0fYQNr1X8ZHr/ nFQmz8o9xxbVoHzFoYQwCnU=; b=bhlxQ7yKlVfIp9rTkIwJS3hZX/6qnKjXDRVl +XlhuqbdslsrhOt2P2Pp0prVqA8B4Gx2p3m5wsiH1BO5JVJh+8JVJ/Kjr/cmZVSk fYNgtUBOdYOEKJr9jE1iBGT7op4wZry/TUYbCYKnJiJR8wrTrAHY/Mg7OHzGC78D t1h/p75/wHh9MtjfT/DwdqTdGAEmS+haN8hYfVfbe0mGCBQwvf7t673L34ZUxHl5 XVBpb80dk/yaFw4TFwDoY6aTycPojn3+iFOlxBzbrcHWC514QhdhPk6IfRYSQMOS uoj4NkXxtc6y2QOreyIcY6G4YpiKCA7JbdEAZqoyBlKka05AvQ== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3xqn0whx55-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Apr 2024 21:51:48 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 43PLplLQ015492 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Apr 2024 21:51:47 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.1544.9; Thu, 25 Apr 2024 14:51:46 -0700 From: Wesley Cheng To: , , , , , , , , , , , , , , CC: , , , , , , , Wesley Cheng Subject: [PATCH v20 37/41] ALSA: usb-audio: Allow for rediscovery of connected USB SND devices Date: Thu, 25 Apr 2024 14:51:21 -0700 Message-ID: <20240425215125.29761-38-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240425215125.29761-1-quic_wcheng@quicinc.com> References: <20240425215125.29761-1-quic_wcheng@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain 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-ORIG-GUID: rmzKTa2HSmMghMxetE-f7YXdbl98aFrz X-Proofpoint-GUID: rmzKTa2HSmMghMxetE-f7YXdbl98aFrz X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-04-25_21,2024-04-25_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 clxscore=1015 impostorscore=0 malwarescore=0 phishscore=0 suspectscore=0 mlxscore=0 mlxlogscore=999 lowpriorityscore=0 bulkscore=0 spamscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2404250159 In case of notifying SND platform drivers of connection events, some of these use cases, such as offloading, require an ASoC USB backend device to be initialized before the events can be handled. If the USB backend device has not yet been probed, this leads to missing initial USB audio device connection events. Expose an API that traverses the usb_chip array for connected devices, and to call the respective connection callback registered to the SND platform driver. Signed-off-by: Wesley Cheng --- sound/usb/card.c | 21 +++++++++++++++++++++ sound/usb/card.h | 1 + sound/usb/qcom/qc_audio_offload.c | 2 ++ 3 files changed, 24 insertions(+) diff --git a/sound/usb/card.c b/sound/usb/card.c index 1ad99a462038..8364c5b8fbbf 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c @@ -186,6 +186,27 @@ struct snd_usb_stream *snd_usb_find_suppported_substream(int card_idx, } EXPORT_SYMBOL_GPL(snd_usb_find_suppported_substream); +/* + * in case the platform driver was not ready at the time of USB SND + * device connect, expose an API to discover all connected USB devices + * so it can populate any dependent resources/structures. + */ +void snd_usb_rediscover_devices(void) +{ + int i; + + guard(mutex)(®ister_mutex); + + if (!platform_ops || !platform_ops->connect_cb) + return; + + for (i = 0; i < SNDRV_CARDS; i++) { + if (usb_chip[i]) + platform_ops->connect_cb(usb_chip[i]); + } +} +EXPORT_SYMBOL_GPL(snd_usb_rediscover_devices); + /* * disconnect streams * called from usb_audio_disconnect() diff --git a/sound/usb/card.h b/sound/usb/card.h index 3c900e5afbce..140928dd9d63 100644 --- a/sound/usb/card.h +++ b/sound/usb/card.h @@ -221,4 +221,5 @@ int snd_usb_unregister_platform_ops(void); struct snd_usb_stream *snd_usb_find_suppported_substream(int card_idx, struct snd_pcm_hw_params *params, int direction); +void snd_usb_rediscover_devices(void); #endif /* __USBAUDIO_CARD_H */ diff --git a/sound/usb/qcom/qc_audio_offload.c b/sound/usb/qcom/qc_audio_offload.c index 6a25a390f8ae..9695bf0ac1cd 100644 --- a/sound/usb/qcom/qc_audio_offload.c +++ b/sound/usb/qcom/qc_audio_offload.c @@ -1879,6 +1879,8 @@ static int __init qc_usb_audio_offload_init(void) if (ret < 0) goto release_qmi; + snd_usb_rediscover_devices(); + return 0; release_qmi: