* USB API, ioctl's and libusb
@ 2005-01-26 12:20 DervishD
2005-01-26 13:40 ` Oliver Neukum
0 siblings, 1 reply; 9+ messages in thread
From: DervishD @ 2005-01-26 12:20 UTC (permalink / raw)
To: Linux-kernel; +Cc: linux-usb-users
Hi everybody :)
I've been solving a USB problem related to a digital photo
camera, and I've noticed that 'libusb' uses a ioctl interface to the
USB kernel system. In fact it implements 'usb_control_msg()' using
ioctl's. On the other hand, the kernel itself (I'm talking about
2.4.29) provides an API in <linux/usb.h> that implements too
'usb_control_msg()' using URB's.
My question is: which interface should be used by user space
applications, <linux/usb.h> or ioctl's? Is the ioctl interface
deprecated in any way? In the "Programming guide for Linux USB Device
Drivers", located in http://usb.in.tum.de/usbdoc/, I can't find ioctl
interface references :?
Thanks a lot in advance :)
Raúl Núñez de Arenas Coronado
--
Linux Registered User 88736
http://www.dervishd.net & http://www.pleyades.net/
It's my PC and I'll cry if I want to...
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: USB API, ioctl's and libusb
2005-01-26 12:20 USB API, ioctl's and libusb DervishD
@ 2005-01-26 13:40 ` Oliver Neukum
2005-01-26 16:38 ` DervishD
0 siblings, 1 reply; 9+ messages in thread
From: Oliver Neukum @ 2005-01-26 13:40 UTC (permalink / raw)
To: DervishD; +Cc: Linux-kernel, linux-usb-users
Am Mittwoch, 26. Januar 2005 13:20 schrieb DervishD:
> My question is: which interface should be used by user space
> applications, <linux/usb.h> or ioctl's? Is the ioctl interface
> deprecated in any way? In the "Programming guide for Linux USB Device
> Drivers", located in http://usb.in.tum.de/usbdoc/, I can't find ioctl
> interface references :?
You are supposed to use libusb.
Regards
Oliver
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: USB API, ioctl's and libusb
2005-01-26 13:40 ` Oliver Neukum
@ 2005-01-26 16:38 ` DervishD
2005-01-26 21:24 ` Johannes Erdfelt
2005-01-26 22:15 ` [Linux-usb-users] " Alan Stern
0 siblings, 2 replies; 9+ messages in thread
From: DervishD @ 2005-01-26 16:38 UTC (permalink / raw)
To: Oliver Neukum; +Cc: Linux-kernel, linux-usb-users
Hi Oliver :)
* Oliver Neukum <oliver@neukum.org> dixit:
> Am Mittwoch, 26. Januar 2005 13:20 schrieb DervishD:
> > My question is: which interface should be used by user space
> > applications, <linux/usb.h> or ioctl's? Is the ioctl interface
> > deprecated in any way? In the "Programming guide for Linux USB Device
> > Drivers", located in http://usb.in.tum.de/usbdoc/, I can't find ioctl
> > interface references :?
> You are supposed to use libusb.
That's irrelevant, the program I was trying to fix uses libusb.
My question is about the preferred kernel interface, 'cause I don't
know if it's the ioctl one or the URB one (well, I'm calling 'URB'
interface the API that is implemented using URB's inside the kernel).
BTW, and judging from the program I've read, there are lots of
operations that must be done using 'usb_control_msg', and libusb
implements that function with exactly the same interface as the
kernel. The only difference is that libusb uses ioctl and the kernel
implements the function using URB's. IMHO libusb doesn't provide a
cleaner API, the only advantage of libusb is portability. Anyway,
I've not used it enough to judge, I'm more concerned about kernel USB
interface, not libusb one.
Thanks anyway :)
Raúl Núñez de Arenas Coronado
--
Linux Registered User 88736
http://www.dervishd.net & http://www.pleyades.net/
It's my PC and I'll cry if I want to...
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: USB API, ioctl's and libusb
2005-01-26 16:38 ` DervishD
@ 2005-01-26 21:24 ` Johannes Erdfelt
2005-01-27 11:02 ` DervishD
2005-01-26 22:15 ` [Linux-usb-users] " Alan Stern
1 sibling, 1 reply; 9+ messages in thread
From: Johannes Erdfelt @ 2005-01-26 21:24 UTC (permalink / raw)
To: Oliver Neukum, Linux-kernel, linux-usb-users
On Wed, Jan 26, 2005, DervishD <lkml@dervishd.net> wrote:
> * Oliver Neukum <oliver@neukum.org> dixit:
> > Am Mittwoch, 26. Januar 2005 13:20 schrieb DervishD:
> > > ? ? My question is: which interface should be used by user space
> > > applications, <linux/usb.h> or ioctl's? Is the ioctl interface
> > > deprecated in any way? In the "Programming guide for Linux USB Device
> > > Drivers", located in http://usb.in.tum.de/usbdoc/, I can't find ioctl
> > > interface references :?
> > You are supposed to use libusb.
>
> That's irrelevant, the program I was trying to fix uses libusb.
> My question is about the preferred kernel interface, 'cause I don't
> know if it's the ioctl one or the URB one (well, I'm calling 'URB'
> interface the API that is implemented using URB's inside the kernel).
ioctl() calls are for userspace only.
It just so happens there is an ioctl() call that provides an URB like
interface and an ioctl() call that provides a synchronous call to do
a control message.
> BTW, and judging from the program I've read, there are lots of
> operations that must be done using 'usb_control_msg', and libusb
> implements that function with exactly the same interface as the
> kernel. The only difference is that libusb uses ioctl and the kernel
> implements the function using URB's. IMHO libusb doesn't provide a
> cleaner API, the only advantage of libusb is portability. Anyway,
> I've not used it enough to judge, I'm more concerned about kernel USB
> interface, not libusb one.
I think you're looking at this incorrectly. You use the kernel API for
kernel modules. You can use either the ioctl() API or libusb for
userspace applications.
JE
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Linux-usb-users] Re: USB API, ioctl's and libusb
2005-01-26 16:38 ` DervishD
2005-01-26 21:24 ` Johannes Erdfelt
@ 2005-01-26 22:15 ` Alan Stern
2005-01-26 23:57 ` DervishD
1 sibling, 1 reply; 9+ messages in thread
From: Alan Stern @ 2005-01-26 22:15 UTC (permalink / raw)
To: DervishD; +Cc: Oliver Neukum, Linux-kernel, linux-usb-users
On Wed, 26 Jan 2005, DervishD wrote:
> That's irrelevant, the program I was trying to fix uses libusb.
> My question is about the preferred kernel interface, 'cause I don't
> know if it's the ioctl one or the URB one (well, I'm calling 'URB'
> interface the API that is implemented using URB's inside the kernel).
>
> BTW, and judging from the program I've read, there are lots of
> operations that must be done using 'usb_control_msg', and libusb
> implements that function with exactly the same interface as the
> kernel. The only difference is that libusb uses ioctl and the kernel
> implements the function using URB's. IMHO libusb doesn't provide a
> cleaner API, the only advantage of libusb is portability. Anyway,
> I've not used it enough to judge, I'm more concerned about kernel USB
> interface, not libusb one.
You don't seem to understand the difference between a kernel API and a
user API. Only code that is part of the kernel can use a kernel API, so
only kernel drivers can use the "URB" interface. By contrast, a user API
can be used by regular programs, not part of the kernel. libusb provides
a user API.
So there's really no choice. Unless you're writing a kernel module, your
program can't use URBs. You can use libusb, or if you don't care about
portability you can use ioctl calls directly. But you can't use URBs.
Alan Stern
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Linux-usb-users] Re: USB API, ioctl's and libusb
2005-01-26 22:15 ` [Linux-usb-users] " Alan Stern
@ 2005-01-26 23:57 ` DervishD
0 siblings, 0 replies; 9+ messages in thread
From: DervishD @ 2005-01-26 23:57 UTC (permalink / raw)
To: Alan Stern; +Cc: Oliver Neukum, Linux-kernel, linux-usb-users
Hi Alan :)
* Alan Stern <stern@rowland.harvard.edu> dixit:
> > BTW, and judging from the program I've read, there are lots of
> > operations that must be done using 'usb_control_msg', and libusb
> > implements that function with exactly the same interface as the
> > kernel. The only difference is that libusb uses ioctl and the kernel
> > implements the function using URB's. IMHO libusb doesn't provide a
> > cleaner API, the only advantage of libusb is portability. Anyway,
> > I've not used it enough to judge, I'm more concerned about kernel USB
> > interface, not libusb one.
> You don't seem to understand the difference between a kernel API and a
> user API. Only code that is part of the kernel can use a kernel API, so
> only kernel drivers can use the "URB" interface. By contrast, a user API
> can be used by regular programs, not part of the kernel. libusb provides
> a user API.
I thought that <linux/usb.h> provided a user API, not a kernel
one. In fact I thought that the functions provided throught that
header were syscalls. They are not, I've checked ;)
> So there's really no choice. Unless you're writing a kernel module, your
> program can't use URBs. You can use libusb, or if you don't care about
> portability you can use ioctl calls directly. But you can't use URBs.
OK, that's right. I really thought that there were syscalls
providing USB API for user space programs. That sounded less weird
when I first thought of it ;)) Thanks for the help :)))
Raúl Núñez de Arenas Coronado
--
Linux Registered User 88736
http://www.dervishd.net & http://www.pleyades.net/
It's my PC and I'll cry if I want to...
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: USB API, ioctl's and libusb
2005-01-26 21:24 ` Johannes Erdfelt
@ 2005-01-27 11:02 ` DervishD
2005-01-27 22:08 ` Johannes Erdfelt
0 siblings, 1 reply; 9+ messages in thread
From: DervishD @ 2005-01-27 11:02 UTC (permalink / raw)
To: Johannes Erdfelt; +Cc: Oliver Neukum, Linux-kernel, linux-usb-users
Hi Johannes :)
* Johannes Erdfelt <johannes@erdfelt.com> dixit:
> On Wed, Jan 26, 2005, DervishD <lkml@dervishd.net> wrote:
> > * Oliver Neukum <oliver@neukum.org> dixit:
> > > You are supposed to use libusb.
> > That's irrelevant, the program I was trying to fix uses libusb.
> > My question is about the preferred kernel interface, 'cause I don't
> > know if it's the ioctl one or the URB one (well, I'm calling 'URB'
> > interface the API that is implemented using URB's inside the kernel).
> ioctl() calls are for userspace only.
I was pretty sure of that. My doubt was the other way round. I
was assuming that the functions in <linux/usb.h> were syscalls, that
they're not.
> It just so happens there is an ioctl() call that provides an URB like
> interface and an ioctl() call that provides a synchronous call to do
> a control message.
Didn't knew about that... Thanks a lot for the info!. Is there
any documentation available for the ioctl USB interface to the
kernel? Any API guide or something like that?
Thanks :)
Raúl Núñez de Arenas Coronado
--
Linux Registered User 88736
http://www.dervishd.net & http://www.pleyades.net/
It's my PC and I'll cry if I want to...
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: USB API, ioctl's and libusb
2005-01-27 11:02 ` DervishD
@ 2005-01-27 22:08 ` Johannes Erdfelt
2005-01-28 10:22 ` DervishD
0 siblings, 1 reply; 9+ messages in thread
From: Johannes Erdfelt @ 2005-01-27 22:08 UTC (permalink / raw)
To: DervishD; +Cc: Linux-kernel, linux-usb-users
On Thu, Jan 27, 2005, DervishD <lkml@dervishd.net> wrote:
> Didn't knew about that... Thanks a lot for the info!. Is there
> any documentation available for the ioctl USB interface to the
> kernel? Any API guide or something like that?
You can use the kernel sources to see how to use it.
JE
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: USB API, ioctl's and libusb
2005-01-27 22:08 ` Johannes Erdfelt
@ 2005-01-28 10:22 ` DervishD
0 siblings, 0 replies; 9+ messages in thread
From: DervishD @ 2005-01-28 10:22 UTC (permalink / raw)
To: Johannes Erdfelt; +Cc: Linux-kernel, linux-usb-users
Hi Johannes :)
* Johannes Erdfelt <johannes@erdfelt.com> dixit:
> On Thu, Jan 27, 2005, DervishD <lkml@dervishd.net> wrote:
> > Didn't knew about that... Thanks a lot for the info!. Is there
> > any documentation available for the ioctl USB interface to the
> > kernel? Any API guide or something like that?
> You can use the kernel sources to see how to use it.
Of course, but it's not the better method for learning, IMHO ;))
Thanks anyway, I'll take a look at the kernel sources :) and libusb
sources, too.
Raúl Núñez de Arenas Coronado
--
Linux Registered User 88736
http://www.dervishd.net & http://www.pleyades.net/
It's my PC and I'll cry if I want to...
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2005-01-28 10:21 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-01-26 12:20 USB API, ioctl's and libusb DervishD
2005-01-26 13:40 ` Oliver Neukum
2005-01-26 16:38 ` DervishD
2005-01-26 21:24 ` Johannes Erdfelt
2005-01-27 11:02 ` DervishD
2005-01-27 22:08 ` Johannes Erdfelt
2005-01-28 10:22 ` DervishD
2005-01-26 22:15 ` [Linux-usb-users] " Alan Stern
2005-01-26 23:57 ` DervishD
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox