All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: Wesley Cheng <quic_wcheng@quicinc.com>,
	srinivas.kandagatla@linaro.org, mathias.nyman@intel.com,
	perex@perex.cz, conor+dt@kernel.org, dmitry.torokhov@gmail.com,
	corbet@lwn.net, broonie@kernel.org, lgirdwood@gmail.com,
	tiwai@suse.com, krzk+dt@kernel.org, Thinh.Nguyen@synopsys.com,
	bgoswami@quicinc.com, robh@kernel.org,
	gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	linux-sound@vger.kernel.org, linux-input@vger.kernel.org,
	linux-usb@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-doc@vger.kernel.org, alsa-devel@alsa-project.org
Subject: Re: [PATCH v28 30/32] ALSA: usb-audio: Add USB offload route kcontrol
Date: Wed, 25 Sep 2024 16:54:28 +0200	[thread overview]
Message-ID: <8bb65adc-e995-443e-80c9-36e9b5d8eee3@linux.intel.com> (raw)
In-Reply-To: <20240925010000.2231406-31-quic_wcheng@quicinc.com>




> +static int
> +snd_usb_offload_route_get(struct snd_kcontrol *kcontrol,
> +			  struct snd_ctl_elem_value *ucontrol)
> +{
> +	struct device *sysdev = snd_kcontrol_chip(kcontrol);
> +	int ret;
> +
> +	ret = snd_soc_usb_update_offload_route(sysdev,
> +					       CARD_IDX(kcontrol->private_value),
> +					       PCM_IDX(kcontrol->private_value),
> +					       SNDRV_PCM_STREAM_PLAYBACK,
> +					       ucontrol->value.integer.value);
> +	if (ret < 0) {
> +		ucontrol->value.integer.value[0] = -1;
> +		ucontrol->value.integer.value[1] = -1;
> +	}

well this invalidates again what I understood from the last patch and
goes back to what I understood initially: the error code is never
returned to higher levels - when offload is not supported the kcontrol
values are encoded to the -1 magic value.

> +	return 0;

and this begs the question if this helper should return a void value.

> +}
> +
> +static int snd_usb_offload_route_info(struct snd_kcontrol *kcontrol,
> +				      struct snd_ctl_elem_info *uinfo)
> +{
> +	uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
> +	uinfo->count = 2;
> +	uinfo->value.integer.min = -1;
> +	/* Arbitrary max value, as there is no 'limit' on number of PCM devices */
> +	uinfo->value.integer.max = 0xff;
> +
> +	return 0;
> +}
> +
> +static struct snd_kcontrol_new snd_usb_offload_mapped_ctl = {
> +	.iface = SNDRV_CTL_ELEM_IFACE_CARD,
> +	.access = SNDRV_CTL_ELEM_ACCESS_READ,
> +	.info = snd_usb_offload_route_info,
> +	.get = snd_usb_offload_route_get,
> +};
> +
> +/**
> + * snd_usb_offload_create_ctl() - Add USB offload bounded mixer
> + * @chip - USB SND chip device
> + *
> + * Creates a sound control for a USB audio device, so that applications can
> + * query for if there is an available USB audio offload path, and which
> + * card is managing it.
> + */
> +int snd_usb_offload_create_ctl(struct snd_usb_audio *chip)
> +{
> +	struct usb_device *udev = chip->dev;
> +	struct snd_kcontrol_new *chip_kctl;
> +	struct snd_usb_substream *subs;
> +	struct snd_usb_stream *as;
> +	char ctl_name[37];

that's quite a magic value.

> +	int ret;
> +
> +	list_for_each_entry(as, &chip->pcm_list, list) {
> +		subs = &as->substream[SNDRV_PCM_STREAM_PLAYBACK];
> +		if (!subs->ep_num)
> +			continue;
> +
> +		chip_kctl = &snd_usb_offload_mapped_ctl;
> +		chip_kctl->count = 1;
> +		/*
> +		 * Store the associated USB SND card number and PCM index for
> +		 * the kctl.
> +		 */
> +		chip_kctl->private_value = as->pcm_index |
> +					  chip->card->number << 16;
> +		sprintf(ctl_name, "USB Offload Playback Route PCM#%d",
> +			as->pcm_index);
> +		chip_kctl->name = ctl_name;
> +		ret = snd_ctl_add(chip->card, snd_ctl_new1(chip_kctl,
> +				  udev->bus->sysdev));
> +		if (ret < 0)
> +			break;
> +	}
> +
> +	return ret;
> +}

  reply	other threads:[~2024-09-25 15:06 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-25  0:59 [PATCH v28 00/32] Introduce QC USB SND audio offloading support Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 01/32] xhci: add helper to stop endpoint and wait for completion Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 02/32] usb: host: xhci: Repurpose event handler for skipping interrupter events Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 03/32] xhci: sideband: add initial api to register a sideband entity Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 04/32] usb: xhci: xhci-sideband: Set IMOD for xHCI sideband clients Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 05/32] usb: host: xhci-mem: Cleanup pending secondary event ring events Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 06/32] usb: host: xhci-mem: Allow for interrupter clients to choose specific index Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 07/32] usb: host: xhci-plat: Set XHCI max interrupters if property is present Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 08/32] usb: dwc3: Specify maximum number of XHCI interrupters Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 09/32] ALSA: Add USB audio device jack type Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 10/32] ALSA: usb-audio: Export USB SND APIs for modules Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 11/32] ALSA: usb-audio: Check for support for requested audio format Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 12/32] ALSA: usb-audio: Save UAC sample size information Wesley Cheng
2024-09-25 14:22   ` Pierre-Louis Bossart
2024-09-25  0:59 ` [PATCH v28 13/32] ALSA: usb-audio: Prevent starting of audio stream if in use Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 14/32] ASoC: Add SOC USB APIs for adding an USB backend Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 15/32] ASoC: usb: Add PCM format check API for " Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 16/32] ASoC: usb: Create SOC USB SND jack kcontrol Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 17/32] ASoC: usb: Fetch ASoC card and pcm device information Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 18/32] ASoC: doc: Add documentation for SOC USB Wesley Cheng
2024-09-25 14:43   ` Pierre-Louis Bossart
2024-10-01  1:34     ` Wesley Cheng
2024-10-01 13:48   ` Amadeusz Sławiński
2024-09-25  0:59 ` [PATCH v28 19/32] ASoC: dt-bindings: qcom,q6dsp-lpass-ports: Add USB_RX port Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 20/32] ASoC: dt-bindings: Update example for enabling USB offload on SM8250 Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 21/32] ASoC: qcom: qdsp6: Introduce USB AFE port to q6dsp Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 22/32] ASoC: qcom: qdsp6: q6afe: Increase APR timeout Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 23/32] ASoC: qcom: qdsp6: Add USB backend ASoC driver for Q6 Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 24/32] ASoC: qcom: qdsp6: Add headphone jack for offload connection status Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 25/32] ASoC: qcom: qdsp6: Fetch USB offload mapped card and PCM device Wesley Cheng
2024-09-25 14:48   ` Pierre-Louis Bossart
2024-09-25  0:59 ` [PATCH v28 26/32] ALSA: usb-audio: Introduce USB SND platform op callbacks Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 27/32] ALSA: usb-audio: qcom: Add USB QMI definitions Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 28/32] ALSA: usb-audio: qcom: Introduce QC USB SND offloading support Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 29/32] ALSA: usb-audio: qcom: Don't allow USB offload path if PCM device is in use Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 30/32] ALSA: usb-audio: Add USB offload route kcontrol Wesley Cheng
2024-09-25 14:54   ` Pierre-Louis Bossart [this message]
2024-09-25 19:37     ` Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 31/32] ALSA: usb-audio: Allow for rediscovery of connected USB SND devices Wesley Cheng
2024-09-25  1:00 ` [PATCH v28 32/32] ASoC: usb: Rediscover USB SND devices on USB port add Wesley Cheng
2024-09-25 15:04 ` [PATCH v28 00/32] Introduce QC USB SND audio offloading support Pierre-Louis Bossart
2024-10-01 13:50 ` Amadeusz Sławiński
  -- strict thread matches above, loose matches on Subject: below --
2024-10-11  0:05 [PATCH v28 00/33] " Wesley Cheng
2024-10-11  0:06 ` [PATCH v28 30/32] ALSA: usb-audio: Add USB offload route kcontrol Wesley Cheng

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=8bb65adc-e995-443e-80c9-36e9b5d8eee3@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=Thinh.Nguyen@synopsys.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=bgoswami@quicinc.com \
    --cc=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=corbet@lwn.net \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=krzk+dt@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --cc=perex@perex.cz \
    --cc=quic_wcheng@quicinc.com \
    --cc=robh@kernel.org \
    --cc=srinivas.kandagatla@linaro.org \
    --cc=tiwai@suse.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.