From: Takashi Iwai Subject: Re: [RFC] ALSA: usb-audio: Add custom mixer status quirks for RME CC devices Date: Fri, 21 Sep 2018 09:01:26 +0200 Message-ID: References: <1537481240-4999-1-git-send-email-jussi@sonarnerd.net> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 2A3372676E6 for ; Fri, 21 Sep 2018 09:01:27 +0200 (CEST) In-Reply-To: <1537481240-4999-1-git-send-email-jussi@sonarnerd.net> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Jussi Laako Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org On Fri, 21 Sep 2018 00:07:19 +0200, Jussi Laako wrote: > > This patch accessing vendor specific registers of RME Class Compliant > devices works otherwise fine, but there is still one small problem. It is > supposed to be a polled from the hardware, since the values indicate > device status and are subject to change at all times. Behavior is correct > if I keep running "amixer" all the time to retrieve values - sampling rate > changes are visible and values get updated. However, when I poll the > values from an application without reopening the mixer, they are being > cached somewhere and the changes are not reflected. This problem doesn't > exist for example with PCIe based RME HDSPe AIO and application gets > updated values, but in this USB based device case they don't get updated. > I have flagged all the mixer controls as read-only and volatile, but the > volatile flag is not honored in this (assuming I've understood it correctly). > > Any guidance on how to fix the caching problem is welcome! The caching is currently enabled for all elements, but changing it should be trivial. The patch below adds is_volatile flag to the element, and you can set it to true in the quirk somehow for uncached controls. thanks, Takashi --- --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -449,8 +449,10 @@ int snd_usb_get_cur_mix_value(struct usb_mixer_elem_info *cval, cval->control, channel, err); return err; } - cval->cached |= 1 << channel; - cval->cache_val[index] = *value; + if (!cval->is_volatile) { + cval->cached |= 1 << channel; + cval->cache_val[index] = *value; + } return 0; } @@ -540,8 +542,10 @@ int snd_usb_set_cur_mix_value(struct usb_mixer_elem_info *cval, int channel, value); if (err < 0) return err; - cval->cached |= 1 << channel; - cval->cache_val[index] = value; + if (!cval->is_volatile) { + cval->cached |= 1 << channel; + cval->cache_val[index] = value; + } return 0; } diff --git a/sound/usb/mixer.h b/sound/usb/mixer.h index 3d12af8bf191..cfbc274ce89f 100644 --- a/sound/usb/mixer.h +++ b/sound/usb/mixer.h @@ -70,6 +70,7 @@ struct usb_mixer_elem_info { int val_type; int min, max, res; int dBmin, dBmax; + bool is_volatile; int cached; int cache_val[MAX_CHANNELS]; u8 initialized;