From d40f9b712e0e2f6826b048a7312eb5b20b1bc148 Mon Sep 17 00:00:00 2001 From: Christian Helmuth Date: Fri, 26 Jul 2024 09:44:06 +0200 Subject: [PATCH] genode_c_api: do not match HID in AUDIO devices Now, USB audio class devices become available in Sculpt, e.g., for vbox passthrough, and are not automatically grabbed by the usb_hid class=3 policy. In the future, interface/endpoint level policies will enable driving the HID interface only from usb_hid while a usb_audio driver controls the rest of the device. --- repos/os/src/lib/genode_c_api/usb.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/repos/os/src/lib/genode_c_api/usb.cc b/repos/os/src/lib/genode_c_api/usb.cc index 19f91ab303..d09963995c 100644 --- a/repos/os/src/lib/genode_c_api/usb.cc +++ b/repos/os/src/lib/genode_c_api/usb.cc @@ -1097,14 +1097,21 @@ void Session_component::_device_policy(genode_usb_device const &d, (product == d.desc.product_id)) || (d.label() == label)); + enum { CLASS_AUDIO = 0x1, CLASS_HID = 0x3 }; if (!match) { uint8_t cla = node.attribute_value("class", 0); + bool found_audio = false; d.configs.for_each([&] (genode_usb_configuration const &c) { if (!c.active) return; c.interfaces.for_each([&] (genode_usb_interface const &i) { - if (i.desc.iclass == cla) match = true; }); + if (i.desc.iclass == cla) match = true; + if (i.desc.iclass == CLASS_AUDIO) found_audio = true; + }); }); + /* do not match HID in AUDIO devices */ + if (match && cla == CLASS_HID && found_audio) + match = false; } if (match) fn(node);