Linux USB
 help / color / mirror / Atom feed
* Using a composite device with kernel drivers and libusb at the same time
@ 2024-03-27 11:33 Martijn Braam
  2024-03-27 13:04 ` Greg KH
  2024-03-27 14:07 ` Alan Stern
  0 siblings, 2 replies; 3+ messages in thread
From: Martijn Braam @ 2024-03-27 11:33 UTC (permalink / raw)
  To: linux-usb

I hope this is an acceptable place to ask this question. I've spend a 
bit of time reverse-engineering the USB protocol for a subset of 
Blackmagic Design video mixers and I have made a userspace 
implementation to make these devices usable in Linux with libusb. This 
is working great but the roadblock I have that I can't find a reasonable 
solution for is that these devices also expose an UVC webcam.

While my control software is active it's not possible to use the UVC 
webcam functionality of the device because with libusb I have to detach 
the kernel from the interfaces to make my userspace access work. As far 
as I can find documented online there's no way to have half a composite 
device handled by kernel drivers and half with userspace drivers in 
Linux. It seems to me the only solution is to make a kernel driver to 
bind to the control interface and have that kernel driver pass-through 
to userspace somehow with a custom protocol? If that is the case would 
such a driver even be supported in Linux?

For reference the device I'm working has these looks like this:

USB 1-4  [1edb:be55] Blackmagic design Blackmagic Design [serial]
    Class EF SubClass 02 Protocol 01
       Interface 0 FF/03/00 Unknown <- Blackmagic USB configuration protocol
       Interface 1 FF/02/00 Unknown <- Blackmagic USB control protocol 
(I'm using this with libusb)
       Interface 2 FF/04/00 Unknown <- Unknown
       Interface 3 FE/01/01 Unknown <- DFU
       Interface 4 0E/01/01 Blackmagic Design <- UVC camera
       Interface 5 0E/02/01 Unknown <- UVC camera
       Interface 6 01/01/00 Blackmagic Design <- ALSA
       Interface 7 01/02/00 Unknown <- ALSA

If this is not the right place for this question, then where would the 
right place be?

Greetings,
Martijn Braam


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Using a composite device with kernel drivers and libusb at the same time
  2024-03-27 11:33 Using a composite device with kernel drivers and libusb at the same time Martijn Braam
@ 2024-03-27 13:04 ` Greg KH
  2024-03-27 14:07 ` Alan Stern
  1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2024-03-27 13:04 UTC (permalink / raw)
  To: Martijn Braam; +Cc: linux-usb

On Wed, Mar 27, 2024 at 12:33:51PM +0100, Martijn Braam wrote:
> I hope this is an acceptable place to ask this question. I've spend a bit of
> time reverse-engineering the USB protocol for a subset of Blackmagic Design
> video mixers and I have made a userspace implementation to make these
> devices usable in Linux with libusb. This is working great but the roadblock
> I have that I can't find a reasonable solution for is that these devices
> also expose an UVC webcam.
> 
> While my control software is active it's not possible to use the UVC webcam
> functionality of the device because with libusb I have to detach the kernel
> from the interfaces to make my userspace access work. As far as I can find
> documented online there's no way to have half a composite device handled by
> kernel drivers and half with userspace drivers in Linux. It seems to me the
> only solution is to make a kernel driver to bind to the control interface
> and have that kernel driver pass-through to userspace somehow with a custom
> protocol? If that is the case would such a driver even be supported in
> Linux?

Why not just make a kernel driver for the interfaces that are not uvc?
We would accept that given that you can not control a device from usbfs
and a driver at the same time as you have pointed out.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Using a composite device with kernel drivers and libusb at the same time
  2024-03-27 11:33 Using a composite device with kernel drivers and libusb at the same time Martijn Braam
  2024-03-27 13:04 ` Greg KH
@ 2024-03-27 14:07 ` Alan Stern
  1 sibling, 0 replies; 3+ messages in thread
From: Alan Stern @ 2024-03-27 14:07 UTC (permalink / raw)
  To: Martijn Braam; +Cc: linux-usb

On Wed, Mar 27, 2024 at 12:33:51PM +0100, Martijn Braam wrote:
> I hope this is an acceptable place to ask this question. I've spend a bit of
> time reverse-engineering the USB protocol for a subset of Blackmagic Design
> video mixers and I have made a userspace implementation to make these
> devices usable in Linux with libusb. This is working great but the roadblock
> I have that I can't find a reasonable solution for is that these devices
> also expose an UVC webcam.

Why is that a roadblock?

> While my control software is active it's not possible to use the UVC webcam
> functionality of the device because with libusb I have to detach the kernel
> from the interfaces to make my userspace access work. As far as I can find
> documented online there's no way to have half a composite device handled by
> kernel drivers and half with userspace drivers in Linux.

Probably the reason it's not mentioned in any documentation is because 
it isn't a problem.  Your libusb program can detach some of the kernel 
drivers while leaving others attached, and then use the interfaces that 
are not controlled by a kernel driver.

Even if you can't make that work, why not just detach all of the 
interfaces and ignore the fact that the device has a UVC webcam?

>  It seems to me the
> only solution is to make a kernel driver to bind to the control interface
> and have that kernel driver pass-through to userspace somehow with a custom
> protocol? If that is the case would such a driver even be supported in
> Linux?

It seems unlikely.  Maybe you should explain your difficulty more fully.

> For reference the device I'm working has these looks like this:
> 
> USB 1-4  [1edb:be55] Blackmagic design Blackmagic Design [serial]
>    Class EF SubClass 02 Protocol 01
>       Interface 0 FF/03/00 Unknown <- Blackmagic USB configuration protocol
>       Interface 1 FF/02/00 Unknown <- Blackmagic USB control protocol (I'm
> using this with libusb)
>       Interface 2 FF/04/00 Unknown <- Unknown
>       Interface 3 FE/01/01 Unknown <- DFU
>       Interface 4 0E/01/01 Blackmagic Design <- UVC camera
>       Interface 5 0E/02/01 Unknown <- UVC camera
>       Interface 6 01/01/00 Blackmagic Design <- ALSA
>       Interface 7 01/02/00 Unknown <- ALSA

Which of these interfaces require a kernel driver?  Does your program 
require any of them besides interface 1?

> If this is not the right place for this question, then where would the right
> place be?

This is definitely the right place.

Alan Stern

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-03-27 14:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-27 11:33 Using a composite device with kernel drivers and libusb at the same time Martijn Braam
2024-03-27 13:04 ` Greg KH
2024-03-27 14:07 ` Alan Stern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox