Date: Tue, 04 Mar 2008 10:27:35 +0200 From: Andriy Gapon <avg@icyb.net.ua> To: Anish Mistry <amistry@am-productions.biz> Cc: freebsd-usb@freebsd.org Subject: Re: Suspend/Sleep/Stop USB device Message-ID: <47CD07F7.2080001@icyb.net.ua> References: <200803031654.31592.amistry@am-productions.biz>
next in thread | previous in thread | raw e-mail | index | archive | help
Anish, I once played with a similar idea - to power off a USB port once a UMASS device (attached to it) is unmounted, similarly to how windows does it. I haven't reached any completely satisfactory results, but I got some results. I have a very faint memory of that now, but I think that either of the following two should work for a port of a USB hub device: usbd_clear_port_feature(dev, port, UHF_PORT_ENABLE); usbd_clear_port_feature(dev, port, UHF_PORT_POWER); I actually issued the request from user-land, but I think that a proper solution would be to add a new ioctl for this purpose and a proper handling of it in usb/uhub. This is a snippet of the userland code that I still have around: if ((fd = open(device_name, O_RDWR, 0)) < 0) { error("%s", device_name); exit(EXIT_FAILURE); } /*==============================================================*/ ctlreq.ucr_addr = 1; /* XXX */ ctlreq.ucr_request.bmRequestType = UT_WRITE_CLASS_OTHER; ctlreq.ucr_request.bRequest = UR_CLEAR_FEATURE; USETW(ctlreq.ucr_request.wValue, UHF_PORT_POWER); //USETW(ctlreq.ucr_request.wValue, UHF_PORT_ENABLE); USETW(ctlreq.ucr_request.wIndex, 8); /* XXX */ USETW(ctlreq.ucr_request.wLength, 0); ctlreq.ucr_data = 0; ctlreq.ucr_flags = 0; ctlreq.ucr_actlen = 0; /*==============================================================*/ if (ioctl(fd, USB_REQUEST, &ctlreq) != 0) { error("ioctl USB_REQUEST"); close(fd); exit(EXIT_FAILURE); } -- Andriy Gapon
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?47CD07F7.2080001>