Bug 224454 - Feature request: implement libusb_get_parent and libusb_has_capability
Summary: Feature request: implement libusb_get_parent and libusb_has_capability
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: usb (show other bugs)
Version: 11.1-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-usb mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-12-19 14:02 UTC by Ting-Wei Lan
Modified: 2018-03-31 12:58 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ting-Wei Lan 2017-12-19 14:02:33 UTC
These two functions are available in libusb (http://libusb.info/) and they are currently used by libgusb (https://github.com/hughsie/libgusb/pull/10), a GObject wrapper for libusb. Can we get them implemented in FreeBSD to make applications or libraries porting easier?
Comment 1 Hans Petter Selasky freebsd_committer 2017-12-19 15:28:09 UTC
Hi,

Can you suggest a patch to implement them in FreeBSD 12-current?

/usr/src/lib/libusb

I'm uncertain if the functions you mention are useful to FreeBSD in general including ports, or if it is better to stub them in the code where these functions are used.

The function to get the parent USB device must be re-constructed in userspace by using the information obtained from:

/usr/include/libusb20.h:uint8_t	libusb20_dev_get_parent_address(struct libusb20_device *pdev);

Also this introduce a couple of races, like what to do if the parent USB device vanishes, refcounts and so on.

--HPS
Comment 2 Ting-Wei Lan 2017-12-21 18:43:35 UTC
I have no FreeBSD 12 installation. The machine I used to test libgusb runs FreeBSD 11.1-RELEASE. I can setup FreeBSD 12 in virtual machine if I have to provide some code running on it.

I think libusb_has_capability is easier to implement. Do you think it is correct for libusb_has_capability to always return 1 for the hotplug capability?

I found there is another missing function today: libusb_interrupt_event_handler. gvfs uses it in its MTP backend, and this is the only libusb function it calls. gvfs has an option to disable libusb support, so it doesn't cause build problems.
Comment 3 Hans Petter Selasky freebsd_committer 2017-12-21 20:14:58 UTC
Hi,

libusb is the same for -12 and -11. Just make a patch for your current system and I'll fix the rest.

> I think libusb_has_capability is easier to implement. Do you think it is correct for libusb_has_capability to always return 1 for the hotplug capability?

Can you check what is expected by the hotplug capability? What functions must be implemented when this capability returns 1?

> I found there is another missing function today:
> libusb_interrupt_event_handler. gvfs uses it in its MTP backend,
> and this is the only libusb function it calls. gvfs has an
> option to disable libusb support, so it doesn't cause build problems.

Is this a variant of the existing "libusb_event_handler_active()"? Can you investigate a bit?

--HPS