On Thu, Sep 21, 2023 at 02:48:39PM -0700, Wesley Cheng wrote:
Add a kcontrol to the platform sound card to fetch the current offload status. This can allow for userspace to ensure/check which USB SND resources are actually busy versus having to attempt opening the USB SND devices, which will result in an error if offloading is active.
+static int q6usb_prepare(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
+{
struct q6usb_port_data *data = dev_get_drvdata(dai->dev);
mutex_lock(&data->mutex);
data->status[data->sel_card_idx].running = true;
mutex_unlock(&data->mutex);
These updates of running should really have a snd_ctl_notify() so that UIs can know to update when the value changes while they're open.
+static int q6usb_mixer_get_offload_status(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
+{
- running = q6usb_find_running(data);
- if (running < 0) {
card_idx = -1;
pcm_idx = -1;
- } else {
card_idx = running;
pcm_idx = data->status[running].pcm_index;
- }
- ucontrol->value.integer.value[0] = card_idx;
- ucontrol->value.integer.value[1] = pcm_idx;
This feels a bit messy but I'm not sure what we'd do that's better so unless someone else has better ideas let's go with this. Possibly we should standardise this as a new control type for joining cards up so at least if there's further needs for this we can use the same solution?