public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* Question about USB interface index restriction in gspca
@ 2011-09-13 19:14 Frank Schäfer
  2011-09-14  6:25 ` Jean-Francois Moine
  0 siblings, 1 reply; 6+ messages in thread
From: Frank Schäfer @ 2011-09-13 19:14 UTC (permalink / raw)
  To: Linux Media Mailing List

Hi,

I have a question about the following code in gspca.c:

in function gspca_dev_probe(...):
     ...
     /* the USB video interface must be the first one */
     if (dev->config->desc.bNumInterfaces != 1
&& intf->cur_altsetting->desc.bInterfaceNumber != 0)
             return -ENODEV;
     ...


Is there a special reason for not allowing devices with USB interface 
index > 0 for video ?
I'm experimenting with a device that has the video interface at index 3 
and two audio interfaces at index 0 and 1 (index two is missing !).
And the follow-up question: can we assume that all device handled by the 
gspca-driver have vendor specific video interfaces ?
Then we could change the code to

     ...
     /* the USB video interface must be of class vendor */
     if (intf->cur_altsetting->desc.bInterfaceClass != 
USB_CLASS_VENDOR_SPEC)
             return -ENODEV;
      ...

Regards,
Frank



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

* Re: Question about USB interface index restriction in gspca
  2011-09-13 19:14 Question about USB interface index restriction in gspca Frank Schäfer
@ 2011-09-14  6:25 ` Jean-Francois Moine
  2011-09-15 21:46   ` Frank Schäfer
  0 siblings, 1 reply; 6+ messages in thread
From: Jean-Francois Moine @ 2011-09-14  6:25 UTC (permalink / raw)
  To: Linux Media Mailing List

On Tue, 13 Sep 2011 21:14:28 +0200
Frank Schäfer <fschaefer.oss@googlemail.com> wrote:

> I have a question about the following code in gspca.c:
> 
> in function gspca_dev_probe(...):
>      ...
>      /* the USB video interface must be the first one */
>      if (dev->config->desc.bNumInterfaces != 1
> && intf->cur_altsetting->desc.bInterfaceNumber != 0)
>              return -ENODEV;
>      ...
> 
> Is there a special reason for not allowing devices with USB interface 
> index > 0 for video ?
> I'm experimenting with a device that has the video interface at index 3 
> and two audio interfaces at index 0 and 1 (index two is missing !).
> And the follow-up question: can we assume that all device handled by the 
> gspca-driver have vendor specific video interfaces ?
> Then we could change the code to
> 
>      ...
>      /* the USB video interface must be of class vendor */
>      if (intf->cur_altsetting->desc.bInterfaceClass != 
> USB_CLASS_VENDOR_SPEC)
>              return -ENODEV;
>       ...

Hi Frank,

For webcam devices, the interface class is meaningful only when set to
USB_CLASS_VIDEO (UVC). Otherwise, I saw many different values.

For video on a particular interface, the subdriver must call the
function gspca_dev_probe2() as this is done in spca1528 and xirlink_cit.

Regards.

-- 
Ken ar c'hentañ	|	      ** Breizh ha Linux atav! **
Jef		|		http://moinejf.free.fr/

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

* Re: Question about USB interface index restriction in gspca
  2011-09-14  6:25 ` Jean-Francois Moine
@ 2011-09-15 21:46   ` Frank Schäfer
  2011-09-16  6:33     ` Jean-Francois Moine
  0 siblings, 1 reply; 6+ messages in thread
From: Frank Schäfer @ 2011-09-15 21:46 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: moinejf

Am 14.09.2011 08:25, schrieb Jean-Francois Moine:
> On Tue, 13 Sep 2011 21:14:28 +0200
> Frank Schäfer<fschaefer.oss@googlemail.com>  wrote:
>
>> I have a question about the following code in gspca.c:
>>
>> in function gspca_dev_probe(...):
>>       ...
>>       /* the USB video interface must be the first one */
>>       if (dev->config->desc.bNumInterfaces != 1
>> &&  intf->cur_altsetting->desc.bInterfaceNumber != 0)
>>               return -ENODEV;
>>       ...
>>
>> Is there a special reason for not allowing devices with USB interface
>> index>  0 for video ?
>> I'm experimenting with a device that has the video interface at index 3
>> and two audio interfaces at index 0 and 1 (index two is missing !).
>> And the follow-up question: can we assume that all device handled by the
>> gspca-driver have vendor specific video interfaces ?
>> Then we could change the code to
>>
>>       ...
>>       /* the USB video interface must be of class vendor */
>>       if (intf->cur_altsetting->desc.bInterfaceClass !=
>> USB_CLASS_VENDOR_SPEC)
>>               return -ENODEV;
>>        ...
> Hi Frank,
>
> For webcam devices, the interface class is meaningful only when set to
> USB_CLASS_VIDEO (UVC). Otherwise, I saw many different values.
Does that mean that there are devices out in the wild that report for 
example USB_CLASS_WIRELESS_CONTROLLER for the video interface ???

> For video on a particular interface, the subdriver must call the
> function gspca_dev_probe2() as this is done in spca1528 and xirlink_cit.
>
> Regards.
Hmm, sure, that would work...
But wouldn't it be better to improve the interface check and merge the 
two probing functions ?
The subdrivers can decide which interfaces are (not) probed and the 
gspca core does plausability checks (e.g. bulk/isoc endpoint ? usb class ?).

Regards,
Frank


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

* Re: Question about USB interface index restriction in gspca
  2011-09-15 21:46   ` Frank Schäfer
@ 2011-09-16  6:33     ` Jean-Francois Moine
  2011-09-19 20:13       ` Frank Schäfer
  0 siblings, 1 reply; 6+ messages in thread
From: Jean-Francois Moine @ 2011-09-16  6:33 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Frank Schäfer

On Thu, 15 Sep 2011 23:46:57 +0200
Frank Schäfer <fschaefer.oss@googlemail.com> wrote:

> > For webcam devices, the interface class is meaningful only when set to
> > USB_CLASS_VIDEO (UVC). Otherwise, I saw many different values.
> 
> Does that mean that there are devices out in the wild that report for 
> example USB_CLASS_WIRELESS_CONTROLLER for the video interface ???
> 
> > For video on a particular interface, the subdriver must call the
> > function gspca_dev_probe2() as this is done in spca1528 and xirlink_cit.
>
> Hmm, sure, that would work...
> But wouldn't it be better to improve the interface check and merge the 
> two probing functions ?
> The subdrivers can decide which interfaces are (not) probed and the 
> gspca core does plausability checks (e.g. bulk/isoc endpoint ? usb class ?).

Generally, the first interface is the video device, and the function
gspca_dev_probe() works well enough.

The function gspca_dev_probe2() is used by only 2 subdrivers and the
way to find the correct interface is not easy. For example, the webcam
047d:5003 (subdriver spca1528) has 3 interfaces (class vendor specific).
The 1st one has only one altsetting with only one interrupt endpoint,
the 2nd one has 8 altsettings, each with only one isochronous endpoint,
and the last one has one altsetting with 3 endpoints (bulk in, bulk out
and interrupt). At the first glance, it is easy to know the right
interface, but writing generic code to handle such webcams seems rather
complicated.

So, if your webcam is in the 99.99% which use the interface 0, use
gspca_dev_probe(), otherwise, YOU know the right interface, so, call
gspca_dev_probe2().

Regards.

-- 
Ken ar c'hentañ	|	      ** Breizh ha Linux atav! **
Jef		|		http://moinejf.free.fr/

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

* Re: Question about USB interface index restriction in gspca
  2011-09-16  6:33     ` Jean-Francois Moine
@ 2011-09-19 20:13       ` Frank Schäfer
  2011-09-21  8:29         ` Jean-Francois Moine
  0 siblings, 1 reply; 6+ messages in thread
From: Frank Schäfer @ 2011-09-19 20:13 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Jean-Francois Moine

Am 16.09.2011 08:33, schrieb Jean-Francois Moine:
> On Thu, 15 Sep 2011 23:46:57 +0200
> Frank Schäfer<fschaefer.oss@googlemail.com>  wrote:
>
>>> For webcam devices, the interface class is meaningful only when set to
>>> USB_CLASS_VIDEO (UVC). Otherwise, I saw many different values.
>> Does that mean that there are devices out in the wild that report for
>> example USB_CLASS_WIRELESS_CONTROLLER for the video interface ???
>>
>>> For video on a particular interface, the subdriver must call the
>>> function gspca_dev_probe2() as this is done in spca1528 and xirlink_cit.
>> Hmm, sure, that would work...
>> But wouldn't it be better to improve the interface check and merge the
>> two probing functions ?
>> The subdrivers can decide which interfaces are (not) probed and the
>> gspca core does plausability checks (e.g. bulk/isoc endpoint ? usb class ?).
> Generally, the first interface is the video device, and the function
> gspca_dev_probe() works well enough.
>
> The function gspca_dev_probe2() is used by only 2 subdrivers and the
> way to find the correct interface is not easy. For example, the webcam
> 047d:5003 (subdriver spca1528) has 3 interfaces (class vendor specific).
> The 1st one has only one altsetting with only one interrupt endpoint,
> the 2nd one has 8 altsettings, each with only one isochronous endpoint,
> and the last one has one altsetting with 3 endpoints (bulk in, bulk out
> and interrupt). At the first glance, it is easy to know the right
> interface, but writing generic code to handle such webcams seems rather
> complicated.
I didn't want to say that it is easy to know the right interface. It is 
definitely not.
But I think we could do it better than we currently do.

Anyway, it seems there is no interest in such a patch.
Thanks for you explanations.

> So, if your webcam is in the 99.99% which use the interface 0, use
> gspca_dev_probe(), otherwise, YOU know the right interface, so, call
> gspca_dev_probe2().
Isn't it also possible that we don't know the right interface and it is 
not interface 0 ? ;-)

Regards,
Frank


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

* Re: Question about USB interface index restriction in gspca
  2011-09-19 20:13       ` Frank Schäfer
@ 2011-09-21  8:29         ` Jean-Francois Moine
  0 siblings, 0 replies; 6+ messages in thread
From: Jean-Francois Moine @ 2011-09-21  8:29 UTC (permalink / raw)
  To: Linux Media Mailing List

On Mon, 19 Sep 2011 22:13:12 +0200
Frank Schäfer <fschaefer.oss@googlemail.com> wrote:

> > So, if your webcam is in the 99.99% which use the interface 0, use
> > gspca_dev_probe(), otherwise, YOU know the right interface, so, call
> > gspca_dev_probe2().  
> 
> Isn't it also possible that we don't know the right interface and it is 
> not interface 0 ? ;-)

I hope that the interface does not change each time you unplug/replug the
webcam :), but if different webcams with a same device ID may use
different interfaces, you should have to develop specific code in the
subdriver...

-- 
Ken ar c'hentañ	|	      ** Breizh ha Linux atav! **
Jef		|		http://moinejf.free.fr/

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

end of thread, other threads:[~2011-09-21  8:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-13 19:14 Question about USB interface index restriction in gspca Frank Schäfer
2011-09-14  6:25 ` Jean-Francois Moine
2011-09-15 21:46   ` Frank Schäfer
2011-09-16  6:33     ` Jean-Francois Moine
2011-09-19 20:13       ` Frank Schäfer
2011-09-21  8:29         ` Jean-Francois Moine

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