On Sun, Jul 22, 2012 at 7:47 PM, Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote: > On Sun, 22 Jul 2012, chetan cr123 wrote: > >> On Sat, Jul 21, 2012 at 11:35 PM, Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote: >> > On Sat, 21 Jul 2012, chetan cr123 wrote: >> > >> >> Hello, >> >> Kindly let me know >> >> how an usb device connection is reported to kernel when we plug an usb cable. >> >> I see that Udev/ueventd is responsible for that. >> > >> > It sounds like you're talking about the device's kernel, not the host's >> > kernel. >> > >> I am talking bout usb device kernel (not the host). >> but for me tablet/mobile should work as both as >> 1. As device when we connect to PC. >> 2. As host when we connect a pendriver or some other device when >> connected to my tablet. >> >> so i was asking about udev/uevent and how the usb plug in >> reported/detected to kerenl. so that in run time i can decide and load >> / unload the USB gadget and USB host driver. > > The host side is easy enough. When a new USB device is detected a > uevent message is sent to udev. Then udev rules cause the appropriate > driver to be loaded. > it fair enough. thanks for your info. when i walked through the Android sourced code. here also udev rules are there and can we have to create our own udev rules for our usb device based on vendor and device id right? Here how can we load and unload the driver when usb detect event has occured. > Nothing like that happens on the device side, though. > >> >> I want to know how exactly usb device will report to (kernel or udev) >> >> when an device is plugged. >> > >> > Answer: Currently connections are not reported. >> > Ok fine. then kindly let me know how kernel or OS comes to know USB is connected? >> > There was some discussion about having the gadget core export a >> > pollable sysfs file that would indicate the current USB connection >> > state. But nobody has written any code. >> > >> >> how can to create an sysfs(node) from gadget driver and this driver >> >> reports to Udev/uevent when an USB device is connected. >> >> So that Application can read Uevents of USB plugin and do the >> >> necessary action (in my case disable the block driver and load usb >> >> gadget mass storage to communicate with PC -----> SD-card of >> >> Tablet/mobile) . >> >> Kindly let me know how can i do this. >> > >> > There is no way to do this now. >> > oh is it. then u mean i cant go with this use case? >> I am using Android ICS 4.03 source code for our tablet device. >> I saw in some Samsung phone running on Android 2.3. they have >> implemented a use case like this. >> when we use some files(say mp3 ) playing from SD-card------> block >> driver will come into picture. >> at the same time when user plugs an USB cable the playing video >> stops(to say block driver might be unloaded ) to UI they informs user >> about USB connection and loads gadget driver so that we can read write >> to SD-card in Tablet(mobile) from computer. >> >> This i need to implement on my tablet phone. Kindly let me know how >> can i do this. > > If you want to know how to do this under Android then you should ask on > an Android-oriented mailing list. The linux-usb mailing list covers > only standard Linux, not variants such as Android. > > Alan Stern > -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html