Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
Cc: Mark Brown <broonie@kernel.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	Maciej Strozek <mstrozek@opensource.cirrus.com>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Srinivas Kandagatla <srini@kernel.org>,
	Bard Liao <yung-chuan.liao@linux.intel.com>,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>,
	Richard Fitzgerald <rf@opensource.cirrus.com>,
	Jorijn van der Graaf <jorijnvdgraaf@catcrafts.net>,
	linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	devicetree@vger.kernel.org, patches@opensource.cirrus.com,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 3/8] ASoC: SDCA: expose class helpers with hw_ops for non-DisCo platforms
Date: Wed, 5 Aug 2026 16:45:11 +0100	[thread overview]
Message-ID: <anNah2Suf+Qb1rPL@opensource.cirrus.com> (raw)
In-Reply-To: <20260722234221.884765-4-srinivas.kandagatla@oss.qualcomm.com>

On Thu, Jul 23, 2026 at 12:42:13AM +0100, Srinivas Kandagatla wrote:
> On ARM/DT platforms without ACPI/DisCo, sdca_lookup_functions() is a
> no-op and num_functions stays 0.  Introduce struct sdca_class_hw_ops
> with hw_init and get_function_data callbacks so codec drivers can
> supply pre-populated sdca_function_data and toggle supplies/reset at
> probe time.
> 
> Convert the class SoundWire probe into an exported library helper
> sdca_class_probe(sdw, hw_ops) and export sdca_class_read_prop() and
> sdca_class_pm_ops.  Codec-specific SoundWire drivers can register their
> own sdw_driver and call these helpers from their probe.  The built-in
> class_sdw_driver stays for generic SDCA parts that need no per-device
> quirks (hw_ops = NULL).
> 
> For non-DisCo boots, the class helper injects the driver-supplied
> function descriptors into sdca_device_data so sdca_dev_register_functions()
> can create the auxiliary devices, and the auxiliary function driver uses
> get_function_data() as a fallback source of per-entity data when the
> firmware node is absent.
> 
> Assisted-by: Claude:claude-opus-4-7
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
> ---
> -static int class_sdw_probe(struct sdw_slave *sdw, const struct sdw_device_id *id)
> +/**
> + * sdca_class_probe - SDCA class SoundWire slave probe helper
> + * @sdw: SoundWire slave
> + * @hw_ops: optional device-specific hw_ops (may be NULL for pure-generic
> + *          SDCA parts that need no quirks)
> + *
> + * Exported so codec-specific SoundWire drivers can call this from their
> + * own sdw_driver.probe.  For codecs with quirks, pass the codec's
> + * sdca_class_hw_ops so hw_init, DT function injection, and PDE hooks
> + * are wired up.  For pure-generic SDCA parts (used by the built-in
> + * class_sdw_driver in this file), pass NULL.
> + */
> +int sdca_class_probe(struct sdw_slave *sdw,
> +		     const struct sdca_class_hw_ops *hw_ops)

If we end up going down this route quite tempted to pass the
hw_ops through the driver_data in the sdw_device_id. But not
totally certain on that.

>  {
>  	struct device *dev = &sdw->dev;
> +	struct sdca_device_data *data = &sdw->sdca_data;
>  	struct regmap_config *dev_config;
>  	struct sdca_class_drv *drv;
>  	int ret;
> @@ -156,11 +179,47 @@ static int class_sdw_probe(struct sdw_slave *sdw, const struct sdw_device_id *id
>  
>  	drv->dev = dev;
>  	drv->sdw = sdw;
> +	drv->hw_ops = hw_ops;
>  	mutex_init(&drv->regmap_lock);
>  	mutex_init(&drv->init_lock);
>  
>  	dev_set_drvdata(drv->dev, drv);
>  
> +	/*
> +	 * On ARM platforms without ACPI/DisCo tables, sdca_lookup_functions()
> +	 * is a no-op and num_functions stays 0. Inject the function descriptors
> +	 * from the device-specific static data so sdca_dev_register_functions()
> +	 * can create the auxiliary devices.
> +	 */
> +	if (data->num_functions == 0 && hw_ops && hw_ops->get_function_data) {
> +		struct sdca_function_data *fdata;
> +		unsigned int num = 0;
> +		unsigned int i;
> +
> +		fdata = hw_ops->get_function_data(&num);
> +		if (!fdata || num == 0 || num > SDCA_MAX_FUNCTION_COUNT)
> +			return -EINVAL;
> +
> +		for (i = 0; i < num; i++) {
> +			if (!fdata[i].desc)
> +				return -EINVAL;
> +			data->function[i].type = fdata[i].desc->type;
> +			data->function[i].adr  = fdata[i].desc->adr;
> +			data->function[i].name = fdata[i].desc->name;
> +			data->function[i].node = NULL;

Probably simpler to just populate this directly from your drivers
probe function, seems odd to call this in both the class and the
function drivers, limits how it has to work.

> -	ret = sdca_parse_function(dev, core->sdw, drv->function);
> -	if (ret)
> -		return ret;
> +	if (drv->function->desc->node) {
> +		ret = sdca_parse_function(dev, core->sdw, drv->function);
> +		if (ret)
> +			return ret;
> +	} else if (core->hw_ops && core->hw_ops->get_function_data) {
> +		/*
> +		 * No DisCo/ACPI firmware node available (e.g. DT/ARM platform).
> +		 * Use pre-populated static function data supplied by the
> +		 * device-specific hw_ops instead of sdca_parse_function().
> +		 * The callback returns an array of function_data entries;
> +		 * pick the one matching this auxdev's function type.
> +		 */
> +		struct sdca_function_data *fdata;
> +		unsigned int num = 0;
> +		unsigned int i;
> +
> +		fdata = core->hw_ops->get_function_data(&num);
> +		if (!fdata || num == 0)
> +			return -EINVAL;
> +
> +		for (i = 0; i < num; i++) {
> +			if (fdata[i].desc &&
> +			    fdata[i].desc->type == sdev->function.desc->type) {
> +				*drv->function = fdata[i];
> +				drv->function->desc = sdev->function.desc;
> +				break;
> +			}
> +		}

Would be much nicer to have the callback directly populate the
function data, similar to how sdca_parse_function works.

Thanks,
Charles

  reply	other threads:[~2026-08-05 15:45 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-22 23:42 [RFC PATCH 0/8] ASoC: SDCA: enable on DT platforms and add Qualcomm WCD9378 (Tambora) codec Srinivas Kandagatla
2026-07-22 23:42 ` [RFC PATCH 1/8] ASoC: SDCA: hw_params: program upstream Input Terminals for OT DAI Srinivas Kandagatla
2026-07-24 13:14   ` Charles Keepax
2026-07-24 13:53     ` Charles Keepax
2026-07-24 16:35     ` Srinivas Kandagatla
2026-07-27  8:33       ` Charles Keepax
2026-07-27 12:42         ` Srinivas Kandagatla
2026-07-22 23:42 ` [RFC PATCH 2/8] ASoC: SDCA: allow building without ACPI Srinivas Kandagatla
2026-07-22 23:42 ` [RFC PATCH 3/8] ASoC: SDCA: expose class helpers with hw_ops for non-DisCo platforms Srinivas Kandagatla
2026-08-05 15:45   ` Charles Keepax [this message]
2026-07-22 23:42 ` [RFC PATCH 4/8] ASoC: SDCA: add PDE pre/post-pmu hooks to hw_ops Srinivas Kandagatla
2026-08-05 15:50   ` Charles Keepax
2026-07-22 23:42 ` [RFC PATCH 5/8] ASoC: SDCA: class_function: xlate sound-dai cell by entity index Srinivas Kandagatla
2026-07-22 23:42 ` [RFC PATCH 6/8] ASoC: SDCA: register SDCA_FUNCTION_TYPE_SIMPLE_JACK in class function driver Srinivas Kandagatla
2026-07-23 10:55   ` Charles Keepax
2026-07-22 23:42 ` [RFC PATCH 7/8] dt-bindings: sound: qcom: add Tambora WCD9378 SDCA codec Srinivas Kandagatla
2026-07-23  9:14   ` Konrad Dybcio
2026-07-23 13:28     ` Srinivas Kandagatla
2026-07-23 13:31       ` Konrad Dybcio
2026-07-29 11:40   ` Krzysztof Kozlowski
2026-07-29 12:17     ` Srinivas Kandagatla
2026-07-29 12:30       ` Krzysztof Kozlowski
2026-07-29 12:36         ` Srinivas Kandagatla
2026-07-29 12:43           ` Krzysztof Kozlowski
2026-07-29 13:02             ` Srinivas Kandagatla
2026-07-29 13:23               ` Krzysztof Kozlowski
2026-07-29 13:34                 ` Srinivas Kandagatla
2026-07-29 14:04                   ` Krzysztof Kozlowski
2026-07-29 17:23                     ` Jorijn van der Graaf
2026-07-22 23:42 ` [RFC PATCH 8/8] ASoC: codecs: add Qualcomm Tambora (WCD9378) " Srinivas Kandagatla
2026-08-05 16:04   ` Charles Keepax
2026-07-23 10:17 ` [RFC PATCH 0/8] ASoC: SDCA: enable on DT platforms and add Qualcomm WCD9378 (Tambora) codec Charles Keepax
2026-07-23 13:24   ` Srinivas Kandagatla
2026-07-24 12:36     ` Charles Keepax
2026-07-24 14:31       ` Srinivas Kandagatla
2026-07-24 15:40         ` Charles Keepax
2026-07-24 16:29           ` Srinivas Kandagatla
2026-07-29 11:14         ` Srinivas Kandagatla
2026-07-29 11:41   ` Krzysztof Kozlowski
2026-07-30  9:08     ` Charles Keepax
2026-07-30  9:11       ` Krzysztof Kozlowski
2026-07-30 10:20         ` Charles Keepax
2026-07-23 19:40 ` Jorijn van der Graaf
2026-07-24 12:17   ` Srinivas Kandagatla
2026-07-24 19:14     ` Jorijn van der Graaf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=anNah2Suf+Qb1rPL@opensource.cirrus.com \
    --to=ckeepax@opensource.cirrus.com \
    --cc=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jorijnvdgraaf@catcrafts.net \
    --cc=krzk+dt@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=mstrozek@opensource.cirrus.com \
    --cc=patches@opensource.cirrus.com \
    --cc=perex@perex.cz \
    --cc=pierre-louis.bossart@linux.dev \
    --cc=rf@opensource.cirrus.com \
    --cc=robh@kernel.org \
    --cc=srini@kernel.org \
    --cc=srinivas.kandagatla@oss.qualcomm.com \
    --cc=tiwai@suse.com \
    --cc=yung-chuan.liao@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox