Received: by 2002:ab2:1c04:0:b0:1f7:53ba:1ebe with SMTP id f4csp106156lqg; Fri, 26 Apr 2024 09:58:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVAzHHavuPcxI2PmdnP3dO600qkOpN3MJSkMJHdhBtSuH5lIg0YdoBF0y/JHMVS7Ns5+IbnQqPpIjaz/H7e/XF7p/vuhuTwMqmNl9mXoA== X-Google-Smtp-Source: AGHT+IHzkn/9xL3jDWnCNM50HXctrFKQ5aOrnmExqBNKgy2fmBnQF5zA1N4iIoHGlFqeW/zVRQU6 X-Received: by 2002:aa7:983c:0:b0:6f3:8aa5:829f with SMTP id q28-20020aa7983c000000b006f38aa5829fmr3245206pfl.33.1714150712046; Fri, 26 Apr 2024 09:58:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714150712; cv=pass; d=google.com; s=arc-20160816; b=Ll2ScbE0v2uLDZgG3sxIY/X+s9jMFZoUxRrMO0vIYU8kFDYRAeqAMAqDXgVgWUJScJ pl3tQ2OyfnXF0C+A9NEFK467jwoT4Dl1FJH87otZ6cFcqh07ou7Kpk9ef/79JS7VDejx zYRn4PnD3joNsMGrQPavE3KCaRqiZ8R8Gl8na1BoQAVIECixdVyzv9Mhg7p+HJRJdIFl Y/rhHdvST3JA46S9zyrNu50rWiLumwMkutuZhdRoBRMY2AtkK/QvyF3X0nUltNYiF1yS JCb8EtElhWBHeap7sSbsP4W+n87/rF8TKdS3zaZqAO5tD5c5MMy75tKPncrD5+SRLzFA D65Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=+UBvOzoqMa/jwSCZa3hO8uAMEhEb6gozqHJClVGlszs=; fh=nltZftsxQXuWoLpedj6X+btMoFrrKx13QYCe+HaZVzI=; b=wSeZXxBlHl8HakVexE6+Jt+5iG+2x8v379FhtmS+NZeBo2BGy/WS9qIVdvgJT68v7l 2CLlqwieXee0YEwA4zBEa8NyrXylA7dZntabivoFF1R905R5evyq7KsvuCUS9Do9X7jQ doA+tm6kIVQ9SykpSDayFbcv3gJlSyzX8OEkGGvfzS5gfSjcnzRKvbrvceK4ooEbCBk8 mhYuwOm/2H0i3aElqdvONIR5U+l558bX9pxGk1prOzixcKaDY42IPIJoOh0ps57Abjfn +WC5tmRP0UVTS8EmN+3ZrsiPkdbBlRSMF1aRo9bmA347ywyB3dj7GMnHlxA5IfN9nNz5 0hSg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=d6pd9TaQ; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-160425-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160425-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id x17-20020a056a000bd100b006e546bd270dsi15203647pfu.364.2024.04.26.09.58.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 09:58:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-160425-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=d6pd9TaQ; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-160425-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160425-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A573B28252B for ; Fri, 26 Apr 2024 16:58:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9143A159912; Fri, 26 Apr 2024 16:56:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="d6pd9TaQ" Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (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 7F71816F271; Fri, 26 Apr 2024 16:56:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714150617; cv=none; b=uCnO/n7ZIsWIE5963NUWDo2MiDiJC51yWMtdPRqrqJxTpzOI2wsJTRTXDOqfn6rqtJZh1+wQDorkHA9h5o963XlxlrbBwc+fsvEFqmfsisf+nTodc3mRB/wyJBSL6FK5G4DXTN2LDWFOy+wC0igh4oNeUo1KpRefwNdAIrMQGF4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714150617; c=relaxed/simple; bh=XYFPk3FkQ7DoDucDYSBcdACRbcapzxVltYw2E7kA37Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oMbqtthrEzusFLvGqR1M2Kfa550F2FcaqCIrGBChfZ+l09jmrsxOUiC9GvX/rA8tJxO2f6FI3Ahu28QQqsTx9+kfLnRADGNFE7MPYcGK930bHIIP59P87uVYlvBG0A1zAhOHbwTudsrjFTUfyFrDyDSC/qgF2UrcNWsgcXteJRU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=d6pd9TaQ; arc=none smtp.client-ip=217.70.183.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id C2FD7FF80A; Fri, 26 Apr 2024 16:56:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1714150613; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+UBvOzoqMa/jwSCZa3hO8uAMEhEb6gozqHJClVGlszs=; b=d6pd9TaQuiuO7ZYfLMgtn/1ztB6l8swWyCQvdAauc0eBgcA+oRBNRToKsNVxgQ0accHkIT Cwb+PvKNffPxwIQsme96rvglK88wwQT1lo2thCadQl2mi3IcSxVnV0YSDj1KTF3PTUvBj4 qlUmQN206+nBU6/6IwNj/nsvuuS6h460WjevvaUdX96wYt/BUN0gRqPWVLOOY1esiRhY7Y QHDwco4JT4uOd0RQaqawrhXRLS5A8k7dupvyGRi+IJd9pxLg9rSZUYy2QMVdVIXva4so61 xrZ8GsFHyk8az3E2Q+txwh30BZckK8aMey1nqpyEhowROuswDIUNKvUf/kPohA== From: Luca Ceresoli Date: Fri, 26 Apr 2024 18:56:41 +0200 Subject: [PATCH v2 08/12] ASoC: doc: dapm: describe how widgets and routes are registered Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240426-dapm-docs-v2-8-87b07547eb5b@bootlin.com> References: <20240426-dapm-docs-v2-0-87b07547eb5b@bootlin.com> In-Reply-To: <20240426-dapm-docs-v2-0-87b07547eb5b@bootlin.com> To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Jonathan Corbet Cc: Alexandre Belloni , Bagas Sanjaya , Thomas Petazzoni , linux-sound@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Luca Ceresoli X-Mailer: b4 0.13.0 X-GND-Sasl: luca.ceresoli@bootlin.com The small paragraph describing how to register widgets is incomplete (does not mention routes) and mentions snd_soc_dapm_new_control() which is not really used. Moreover it appears as a part of the "Virtual Widgets" subsection. Replace it with a detailed and current description of how widgets and routes are registered, mentioning both static declaration and runtime registration. Also make this a section on its own. Reviewed-by: Alexandre Belloni Reviewed-by: Bagas Sanjaya Signed-off-by: Luca Ceresoli --- Documentation/sound/soc/dapm.rst | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/Documentation/sound/soc/dapm.rst b/Documentation/sound/soc/dapm.rst index 58ef880ac8b6..4b094c3d7942 100644 --- a/Documentation/sound/soc/dapm.rst +++ b/Documentation/sound/soc/dapm.rst @@ -251,8 +251,42 @@ a virtual widget - a widget with no control bits e.g. This can be used to merge two signal paths together in software. -After all the widgets have been defined, they can then be added to the DAPM -subsystem individually with a call to snd_soc_dapm_new_control(). +Registering DAPM controls +========================= + +In many cases the DAPM widgets implemented statically in a ``static const +struct snd_soc_dapm_widget`` array and the routes connecting them in a +``static const struct snd_soc_dapm_route`` array in a codec driver, and +simply declared via the ``dapm_widgets`` and ``num_dapm_widgets`` fields of +the ``struct snd_soc_component_driver`` so the driver registration will +take care of populating them:: + + static const struct snd_soc_dapm_widget wm2000_dapm_widgets[] = { + SND_SOC_DAPM_OUTPUT("SPKN"), + SND_SOC_DAPM_OUTPUT("SPKP"), + ... + }; + + /* Target, Path, Source */ + static const struct snd_soc_dapm_route wm2000_audio_map[] = { + { "SPKN", NULL, "ANC Engine" }, + { "SPKP", NULL, "ANC Engine" }, + ... + }; + + static const struct snd_soc_component_driver soc_component_dev_wm2000 = { + ... + .dapm_widgets = wm2000_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm2000_dapm_widgets), + ... + }; + +In more complex cases the list of DAPM widgets and/or routes can be only +known at build time. This happens for example when a driver supports +different models having a different set of features. In those cases +separate widgets and routes arrays implementing the case-specific features +can be registered programmatically by calling snd_soc_dapm_new_controls() +and snd_soc_dapm_add_routes(). Codec/DSP Widget Interconnections -- 2.34.1