[alsa-devel] focusrite scarlett 18i20 : Mixer controls with corrupted names for

Stefan Sauer ensonic at hora-obscura.de
Wed Jun 26 22:13:00 CEST 2019


Am 26.06.19 um 22:06 schrieb Stefan Sauer:
> Am 25.06.19 um 09:54 schrieb Takashi Iwai:
>> On Sat, 22 Jun 2019 22:55:25 +0200,
>> Stefan Sauer wrote:
>>>
>>> So the first 8 controls are added somewhere else. Looks like this is from
>>> mixer.c and after
>>> echo -n 'file sound/usb/mixer.c +p' >/sys/kernel/debug/dynamic_debug/control
>>> I get
>>> [ 4405.855432] usb 1-2: [51] PU [KKKKKKKKKKKKKÃÃÃÃÃÃÃÃÃÃÃ Switch] ch = 1, val = 0/1
>>> [ 4405.856423] usb 1-2: [52] PU [ Switch] ch = 1, val = 0/1
>>
>> This indicates that these weird names come from the two extension
>> units id 51 and 52.
>> Could you put some debug print in build_audio_procunit() like below?
> 
> I traced it down to this part from sound/usb/mixer.c:
> nameid = uac_processing_unit_iProcessing(desc, state->mixer->protocol);
> usb_audio_dbg(state->chip, "desc->bUnitID=%d, proto=%d, nameid=%d\n",
>  	      desc->bUnitID, state->mixer->protocol, nameid);
> len = 0;
> if (nameid) {
> 	len = snd_usb_copy_string_desc(state->chip,
> 				       nameid,
> 				       kctl->id.name,
> 				       sizeof(kctl->id.name));
> 	usb_audio_dbg(state->chip, "nameid=%d, len=%d, fallback name='%s'\n",
>  		      nameid, len, name);
> }
> 
> [ 6241.045734] usb 1-2: desc->bUnitID=51, proto=32, nameid=90
> [ 6241.045861] usb 1-2: nameid=90, len=35, fallback name='Extension Unit'
> [ 6241.045868] usb 1-2: [51] PU [KKKKKKKKKKKKKÃÃÃÃÃÃÃÃÃÃÃ Switch] ch = 1, val = 0/1
> [ 6241.046745] usb 1-2: desc->bUnitID=52, proto=32, nameid=82
> [ 6241.046857] usb 1-2: nameid=82, len=1, fallback name='Extension Unit'
> [ 6241.046862] usb 1-2: [52] PU [ Switch] ch = 1, val = 0/1

and with the bUnitID I get to these descriptors from lsusb:

AudioControl Interface Descriptor:
        bLength                16
        bDescriptorType        36
        bDescriptorSubtype      9 (EXTENSION_UNIT)
        bUnitID                51
        wExtensionCode     0x0000
        bNrInPins               1
        baSourceID(0)           2
        bNrChannels            20
        bmChannelConfig    0x00000000
        iChannelNames           0
        bmControls           0x03
          Enable Control (read/write)
        iExtension              0
AudioControl Interface Descriptor:
        bLength                16
        bDescriptorType        36
        bDescriptorSubtype      9 (EXTENSION_UNIT)
        bUnitID                52
        wExtensionCode     0x0000
        bNrInPins               1
        baSourceID(0)           1
        bNrChannels            20
        bmChannelConfig    0x00000000
        iChannelNames           0
        bmControls           0x03
          Enable Control (read/write)
        iExtension              0

> 
> The device is using UAC_VERSION_2. The code in include/uapi/linux/usb/audio.h is
> a bit hard to read since uac_mixer_unit_descriptor has a variable length and the
> code is adding several offset, I'll need to add more printfs there to check if
> it is correct. I am consulting
> https://www.usb.org/sites/default/files/audio10.pdf but I am not sure if this
> covers UAC2.
> 
> Stefan
> 
>>
>>
>> thanks,
>>
>> Takashi
>>
>> --- a/sound/usb/mixer.c
>> +++ b/sound/usb/mixer.c
>> @@ -2358,8 +2358,10 @@ static int build_audio_procunit(struct mixer_build *state, int unitid,
>>  	for (info = list; info && info->type; info++)
>>  		if (info->type == type)
>>  			break;
>> -	if (!info || !info->type)
>> +	if (!info || !info->type) {
>> +		pr_info("XXX unit %d to default_info\n", unitid);
>>  		info = &default_info;
>> +	}
>>  
>>  	for (valinfo = info->values; valinfo->control; valinfo++) {
>>  		__u8 *controls = uac_processing_unit_bmControls(desc, state->mixer->protocol);
>> @@ -2375,8 +2377,11 @@ static int build_audio_procunit(struct mixer_build *state, int unitid,
>>  		}
>>  
>>  		map = find_map(state->map, unitid, valinfo->control);
>> +		if (map)
>> +			pr_info("XXX map found for unit %d\n", unitid);
>>  		if (check_ignored_ctl(map))
>>  			continue;
>> +
>>  		cval = kzalloc(sizeof(*cval), GFP_KERNEL);
>>  		if (!cval)
>>  			return -ENOMEM;
>> @@ -2444,19 +2449,26 @@ static int build_audio_procunit(struct mixer_build *state, int unitid,
>>  		kctl->private_free = snd_usb_mixer_elem_free;
>>  
>>  		if (check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name))) {
>> +			pr_info("XXX name copied from map: '%s' for unit %d\n", kctl->id.name, unitid);
>>  			/* nothing */ ;
>>  		} else if (info->name) {
>>  			strlcpy(kctl->id.name, info->name, sizeof(kctl->id.name));
>> +			pr_info("XXX name copied from info: '%s' for unit %d\n", kctl->id.name, unitid);
>>  		} else {
>>  			nameid = uac_processing_unit_iProcessing(desc, state->mixer->protocol);
>> +			pr_info("XXX nameid=%d, unit %d\n", nameid, unitid);
>>  			len = 0;
>> -			if (nameid)
>> +			if (nameid) {
>>  				len = snd_usb_copy_string_desc(state->chip,
>>  							       nameid,
>>  							       kctl->id.name,
>>  							       sizeof(kctl->id.name));
>> -			if (!len)
>> +				pr_info("XXX copy string desc '%s'\n", kctl->id.name);
>> +			}
>> +			if (!len) {
>>  				strlcpy(kctl->id.name, name, sizeof(kctl->id.name));
>> +				pr_info("XXX copy default name '%s'\n", kctl->id.name);
>> +			}
>>  		}
>>  		append_ctl_name(kctl, " ");
>>  		append_ctl_name(kctl, valinfo->suffix);
>> _______________________________________________
>> Alsa-devel mailing list
>> Alsa-devel at alsa-project.org
>> https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>>
> 
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel at alsa-project.org
> https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
> 



More information about the Alsa-devel mailing list