usblog ([info]usblog) wrote,
@ 2004-11-16 16:02:00
Previous Entry  Add to memories!  Tell a Friend  Next Entry
Linux USB SubSystem (1)
Hello,

This blog is soleley dedicated for USB susbsystem and Video4Linux applications
and drivers.

The posting in this blog are taken from
http://www.livejournal.com/users/rrx.

(I am rrx and I an researching the Linux USB susbsystem with
empasis on Video4Linux).

I intend to add postings here regarding this
issues quite soon. Stay tuned.
These postings will appear here and also in
http://www.livejournal.com/users/rrx.

However , http://www.livejournal.com/users/rrx is
a general blog , and it d
deals also with other matters (mainly Linux programming,kernel,gcc,
and other goodies).


There are 2 reasons for that:

1) To dedicate one blog for this issue.

2) To ease finding it using search engines.

I hope linux community will find this blog helpful
and enjoy it.

You are invited to comment / question / remark.

the following post is from Sunday, November 14th, 2004:

Linux USB SubSystem (1) :
usb_init()

The following text is based on 2.67 kernel.
So what do we have in the usb initialization?
Let's have a look at usb_init() in inode.c (/drivers/usb/core/usb.c):

We call 6 initialization routines: only 3 of them are
part of the sub subsystem.

1) bus_register(&usb_bus_type);
The bus_register() method is not a part of the USB subsystem.
It's a general bus method ; it's implementation is in /drivers/base/bus.c.


2)usb_host_init(); calls class_register(); again ,this is not a part of the
USB subsystem. It's implementation is in /drivers/base/class.c

3)usb_major_init();

This calls register_chre_dev(); The MAJOR number of USB is 180.
and also devfs_mk_dir("usb") and class_register().

All entries under /dev/usb have major number 180 (except
/dev/ttyUSB* , which have major number 188).

the call to class_register() is relatively new (It did not exist
in 2.4 kernel). We should not be surprised; Greg Kroach Hartman, which
is the maintainer of usb subsystem, is also deeply involved
in the new device model (see for example his
talk in OLS2004 kobjects and krefs - Lockless Reference Counting for Kernel
Structure
(http://www.kroah.com/linux/talks/ols_2004_kref_talk)


4) usbfs_init(); usually, in most distros , the usbfs (which is
also called usbdevfs) , is mounted under /proc/bus.
(Needless to say: This of course can be changed by issuing umount and then mount
on a different mounting point,or changing /etc/fstab).

This is a filesystem which resembles in some ways ordinary file systems
like etxt3 or xfs; what I mean is that you call register_filesystem()
(in /drivers/usb/core/inode.c) in order to register the filesystem.
And you pass a pointer to file_system_type.

The usbfs is responsible for creating and updating the devices file
(/proc/bus/usb/devices).
The devices file is updated dynamically; if you insert a webcam , (or any other
USB device), and run cat /proc/bus/usb/devices , you will find that some
configuration entries were added to the devices file.If you will remove the
webcam and run cat /proc/bus/usb/devices, you will find that these devices were
removed from the devices file.

Creating the devices file is done, eventually,by calling regular
filesystem methods (like d_instantiate() and dget () from dcache.c).
More on it in the future.


5) usb_hub_init(): creates a kernel daemon thread named khubd.
(implenentation in /drivers/usb/core/hub.c).
The khubd thread is responsible for configuring devices.
More on it in the future.

6) driver_register();
This method is again not a part of the
USB subsystem. It's implementation is in /drivers/base/driver.c


Cheers,
USBLOG



(2 comments) - (Post a new comment)


[info]duke_igthorn
2004-11-29 05:50 pm UTC (link)
With all due respect, combining USB and V4L into one blog does not seem reasonable. IMVVVHO.

(Reply to this) (Thread)

RE: combining USB and V4L
[info]usblog
2004-12-06 07:04 am UTC (link)
Hello,

My Interest in USB had begun arose when working in a Video4Linux
project. *As I assume you know, Video4Linux is a level above USB
which uses it's services.)
As you can see, up till now I did not post anything about
Video4Linux and Video Conference applications on Linux.
My intention was to post only one or two times regarding
Video4Linux. However , I agree that this is a bit Off Topic.
So I decided that when I will post regarding Video4Linux ,I will put it in http://www.livejournal.com/users/rrx
and only mention it in this blog.
Cheers,
RRX



(Reply to this) (Parent)


(2 comments) - (Post a new comment)

Create an Account
Forgot your login or password?
Login w/ OpenID
English • Español • Deutsch • Русский…