On Tue, Jun 22, 2021 at 09:34:25AM +0200, Takashi Iwai wrote:
On Tue, 22 Jun 2021 09:07:20 +0200, Vladimir Sadovnikov wrote:
Hello Takashi!
Since Focusrite devices are too advanced in settings, the overall amount of 256 controls is not enough for these devices (like 18i20). I would like also to extend this constant up to 1024 or even more since adding support of software configuration of the device also can exceed the amount of 512 control elements.
This define isn't for the total number of mixer elements. Instead, it's just a size of the bitmap table that contains the head of the linked list for each unit id (in the sense of USB mixer spec). So the number of mixer elements is unlimited.
Sorry I don't understand what's going on then. Am I calling snd_usb_mixer_add_control() wrong? Because when I called it more than MAX_ID_ELEMS times I got a buffer overflow in mixer->id_elems[] (from memory, I can confirm tonight).
snd_usb_create_mixer() has:
mixer->id_elems = kcalloc(MAX_ID_ELEMS, sizeof(*mixer->id_elems), GFP_KERNEL);
snd_usb_mixer_add_control() called from mixer_scarlett_gen2.c ends up at snd_usb_mixer_add_list() which does:
list->next_id_elem = mixer->id_elems[list->id]; mixer->id_elems[list->id] = list;
And list->id was going over MAX_ID_ELEMS.