Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp262471rbb; Fri, 23 Feb 2024 22:23:48 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVrJMgI3FiIhtTJ4oZaw59k/RTK283qVIqLMdnn4wxGwYbhF2ReSM17jUmKKDP+yBJRxqYtDUtxTeYSPoXe0/+HOb2XjCLBynSyj/zVZw== X-Google-Smtp-Source: AGHT+IGPZsc3JAiF3PQnnLb3KDZLO9Wl2hAxUwSZof4z/E1mswk5Sw1ZOVfzw+cl3nOwKq2GPeJI X-Received: by 2002:a17:906:8318:b0:a42:e49b:e5b with SMTP id j24-20020a170906831800b00a42e49b0e5bmr432371ejx.75.1708755828707; Fri, 23 Feb 2024 22:23:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708755828; cv=pass; d=google.com; s=arc-20160816; b=kXPJ+pHoYZj7QfD1nv2KLKMBYwS/vBz1ImM7D4k0bXR3e7x8AeGXqHzBoNxcyBXEEn opVzWEb5huxCzr02vctbcQwsaOoiRxMOAcWxeZrzhUG42SD746jOugpS0l8zrJVw6KtH SnkVBM84T1xXRMpQCekBfKPEDh8YZPhtL+Kk6jwcDWF9Xe12leaT61XTZhxJ16sp5YYs bvQqIfpUVd7BV7kxXWOZVNGaOQ2WwbXauAcz0Y1LhfQvY9OVLBVTF0v1YudD+v5bwTZq ZPMtQOr9kABAAGoH8QeLZwKCUFNvLin3k8raKCQEcF0jsc8j1MBCePuG5urRfe+9zmcL 7Xrg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=QCYPc8ZRVSnAHVFnIu3U13dqMb2KRmhi+yyRJZMHU5M=; fh=73i7qHE63z1gp6Ll/6eUwlg77MxVI9+8BLr/YRFQzv4=; b=f0EYK5JrN85pIJr0D/VifYjUCnkBqKhG2l1ee2+Lkh2Mks4U+k9kNvbTd9Si4FJ8ex faV8Umdl7aQJXz/DJMlwvqGK4+SrSDpsL4I7NglT0zLbd2nFA9AI86/Q/hFhYbyyveyH 51uZKsk2JFeKu9MDIiqoWS+3xUTbRj8XhcAcyWVaxm21WC7p+agapg1+c4aL5FI+zG+i lpc+4nGDkC57mk46H1vynqd3p9E1Uzva1WzGiVxzibR1/R/liFDS9Lo70UU4djhDgjdO kRbrKr6TLZAr6g3jLECVduNC4YAyXZ7ALzwV2FmptyKbT65bNrIoR2gtiiLsfEuJbke2 017A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=J4TSy+Mm; 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-79483-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79483-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id d7-20020a170906304700b00a3e8be9c95fsi283601ejd.642.2024.02.23.22.23.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 22:23:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79483-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=J4TSy+Mm; 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-79483-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79483-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 503FF1F2375C for ; Sat, 24 Feb 2024 06:23:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 686B91802B; Sat, 24 Feb 2024 06:23:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="J4TSy+Mm" 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 A0DE513FFF; Sat, 24 Feb 2024 06:23:30 +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=1708755812; cv=none; b=bN+/on8d/N/vq9zOcyHVRsDrMyHk+EaNKM10Gx+ULTdEztlMECy/6kqAKVFYkGLLCMImU7tKKiRxom3BlRtvtwQQ6AQ0YACOCSS1BlKIV6Qg38IfMobRLZMdUZpAbIdJRnLA6P938BegO+0/qk5pb5ygGnG24IgyZWY2vPXTnfc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708755812; c=relaxed/simple; bh=W0u5IT/H5hLXinO/B5FelGXdqlc5c1QwMVi0wEyDxCc=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=OTzUWSACK4WTMvdwK7tB8K2rbTgdVz5ijhNdRVg/4Nyu8BejrMgVIEWJX0bcXGotLXh0UDNTeYEeGi7UgwDUjwQiM+RPaL96d5GnqMdmJN3YlpEOIlYjTV4/buj6N0NQMmR6KY9xQaBXTZ3AmbxkFBAn3FwA0x72Sqg9ytJUn6s= 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=J4TSy+Mm; 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 (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41O5pM72004828; Sat, 24 Feb 2024 06:22:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= message-id:date:mime-version:subject:to:cc:references:from :in-reply-to:content-type:content-transfer-encoding; s= qcppdkim1; bh=QCYPc8ZRVSnAHVFnIu3U13dqMb2KRmhi+yyRJZMHU5M=; b=J4 TSy+MmWnctP1jtu2cXW9nSBuUjYMjc3VRLXJdbd3ywzS0ZW8jiRGtT2HY56pI8HF b1/g3fTj0RAGMyGNv6IjywbpmWNlF6bdeobrLbiFM/MhZbbTEDPud84mRYMQiiTP jGRz4AHhqhfNjwQXt7tOWgPmRbC0XaJf0bchSnUWrMfGfiZ3T6hBF6hHF/19msue LXyvwcVBniQzj5XzuZaoEbs8W6FFIuCBfPLU4z2IcKGTaYbOZk5FVwDzDZva2Spe qwXVcbzHuzpzymPJqTm4nVXKpCwpVRYVZbZ3nX0XGb81r+wbyfWq0pPKMNSYnRGD pMZ2hdiQ2XECFTNQw42A== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3wf65hrbbj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 24 Feb 2024 06:22:57 +0000 (GMT) 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 41O6MuwG006607 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 24 Feb 2024 06:22:56 GMT Received: from [10.110.15.108] (10.80.80.8) 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.40; Fri, 23 Feb 2024 22:22:55 -0800 Message-ID: <76922981-88ec-a376-ce61-ea1ff85f43d2@quicinc.com> Date: Fri, 23 Feb 2024 22:22:50 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.13.1 Subject: Re: [PATCH v14 32/53] ALSA: usb-audio: Check for support for requested audio format Content-Language: en-US To: Takashi Iwai CC: , , , , , , , , , , , , , , , , , , , , , References: <20240208231406.27397-1-quic_wcheng@quicinc.com> <20240208231406.27397-33-quic_wcheng@quicinc.com> <87v86x2a27.wl-tiwai@suse.de> <7f0c4f85-5a63-4643-8553-e3f5d6af67ec@quicinc.com> <87y1bjpfn0.wl-tiwai@suse.de> From: Wesley Cheng In-Reply-To: <87y1bjpfn0.wl-tiwai@suse.de> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: Q1NKQpUrdoWd5O5aWBixNCa6-08HgSIz X-Proofpoint-GUID: Q1NKQpUrdoWd5O5aWBixNCa6-08HgSIz X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-24_02,2024-02-23_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 bulkscore=0 mlxlogscore=949 suspectscore=0 adultscore=0 priorityscore=1501 impostorscore=0 malwarescore=0 phishscore=0 lowpriorityscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2402120000 definitions=main-2402240050 Hi Takashi, On 2/17/2024 2:08 AM, Takashi Iwai wrote: > On Sat, 17 Feb 2024 00:42:18 +0100, > Wesley Cheng wrote: >> >> Hi Takashi, >> >> On 2/9/2024 1:34 PM, Wesley Cheng wrote: >>> Hi Takashi, >>> >>> On 2/9/2024 2:42 AM, Takashi Iwai wrote: >>>> On Fri, 09 Feb 2024 00:13:45 +0100, >>>> Wesley Cheng wrote: >>>>> >>>>> Allow for checks on a specific USB audio device to see if a >>>>> requested PCM >>>>> format is supported.  This is needed for support when playback is >>>>> initiated by the ASoC USB backend path. >>>>> >>>>> Signed-off-by: Wesley Cheng >>>>> --- >>>>>   sound/usb/card.c | 31 +++++++++++++++++++++++++++++++ >>>>>   sound/usb/card.h | 11 +++++++++++ >>>>>   2 files changed, 42 insertions(+) >>>>> >>>>> diff --git a/sound/usb/card.c b/sound/usb/card.c >>>>> index 7dc8007ba839..1ad99a462038 100644 >>>>> --- a/sound/usb/card.c >>>>> +++ b/sound/usb/card.c >>>>> @@ -155,6 +155,37 @@ int snd_usb_unregister_platform_ops(void) >>>>>   } >>>>>   EXPORT_SYMBOL_GPL(snd_usb_unregister_platform_ops); >>>>> +/* >>>>> + * Checks to see if requested audio profile, i.e sample rate, # of >>>>> + * channels, etc... is supported by the substream associated to the >>>>> + * USB audio device. >>>>> + */ >>>>> +struct snd_usb_stream *snd_usb_find_suppported_substream(int card_idx, >>>>> +            struct snd_pcm_hw_params *params, int direction) >>>>> +{ >>>>> +    struct snd_usb_audio *chip; >>>>> +    struct snd_usb_substream *subs; >>>>> +    struct snd_usb_stream *as; >>>>> + >>>>> +    /* >>>>> +     * Register mutex is held when populating and clearing usb_chip >>>>> +     * array. >>>>> +     */ >>>>> +    guard(mutex)(®ister_mutex); >>>>> +    chip = usb_chip[card_idx]; >>>>> + >>>>> +    if (chip && enable[card_idx]) { >>>>> +        list_for_each_entry(as, &chip->pcm_list, list) { >>>>> +            subs = &as->substream[direction]; >>>>> +            if (snd_usb_find_substream_format(subs, params)) >>>>> +                return as; >>>>> +        } >>>>> +    } >>>>> + >>>>> +    return NULL; >>>>> +} >>>>> +EXPORT_SYMBOL_GPL(snd_usb_find_suppported_substream); >>>>> + >>>>>   /* >>>>>    * disconnect streams >>>>>    * called from usb_audio_disconnect() >>>>> diff --git a/sound/usb/card.h b/sound/usb/card.h >>>>> index 02e4ea898db5..ed4a664e24e5 100644 >>>>> --- a/sound/usb/card.h >>>>> +++ b/sound/usb/card.h >>>>> @@ -217,4 +217,15 @@ struct snd_usb_platform_ops { >>>>>   int snd_usb_register_platform_ops(struct snd_usb_platform_ops *ops); >>>>>   int snd_usb_unregister_platform_ops(void); >>>>> + >>>>> +#if IS_ENABLED(CONFIG_SND_USB_AUDIO) >>>>> +struct snd_usb_stream *snd_usb_find_suppported_substream(int card_idx, >>>>> +            struct snd_pcm_hw_params *params, int direction); >>>>> +#else >>>>> +static struct snd_usb_stream >>>>> *snd_usb_find_suppported_substream(int card_idx, >>>>> +            struct snd_pcm_hw_params *params, int direction) >>>>> +{ >>>>> +    return NULL; >>>>> +} >>>>> +#endif /* IS_ENABLED(CONFIG_SND_USB_AUDIO) */ >>>> >>>> The usefulness of ifdef guard here is doubtful, IMO.  This header is >>>> only for USB-audio driver enablement, and not seen as generic >>>> helpers.  So, just add the new function declarations without dummy >>>> definitions. >>>> >>> >>> Got it, will remove it.  We also have a dependency in place for the >>> qc_audio_offload driver and SND USB AUDIO in the Kconfig. >>> >> >> Looking at this again after trying some mixed Kconfig settings. These >> declarations aren't specific for USB-audio. They are helpers that are >> exposed to soc usb, so that it can do some basic verification with soc >> usb before allowing the enable stream to continue. > > Then rather the question is why snd-soc-usb calls those functions > *unconditionally*. No matter whether we have dependencies in Kconfig, > calling the function means that the callee shall be drug when the > corresponding code is running. > > If it were generic core API stuff such as power-management or ACPI, > it'd make sense to define dummy functions without the enablement, as > many code may have optional calls. If the API is enabled, it's anyway > in the core. If not, it's optional. That'll be fine. > > OTOH, the stuff you're calling certainly belongs to snd-usb-audio. > Even if the call is really optional, it means that you'll have a hard > dependency when snd-usb-audio is built, no matter whether you need or > not. > >> Since the ASoC >> layer doesn't have insight on what audio profiles are supported by the >> usb device, this API will ensure that the request profile is >> supported. >> >> Issues are seen when we disable SND USB audio config and enable the >> ASoC parts. > > If snd-usb-audio is disabled, what snd-soc-usb would serve at all? > Does it still make sense to keep it enabled? > That said, the statement above (building snd-soc-usb without > snd-usb-audio) looks already dubious; isn't it better to have a proper > dependency in Kconfig, instead? > Ok, took a look at it a bit more and should have gotten all the dependencies addressed through Kconfigs. Thanks for the review comments and feedback. Thanks Wesley Cheng