From owner-freebsd-usb@FreeBSD.ORG Tue Mar 4 09:35:52 2008 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EFBA7106566C for ; Tue, 4 Mar 2008 09:35:52 +0000 (UTC) (envelope-from avg@icyb.net.ua) Received: from hosted.kievnet.com (hosted.kievnet.com [193.138.144.10]) by mx1.freebsd.org (Postfix) with ESMTP id B95218FC21 for ; Tue, 4 Mar 2008 09:35:52 +0000 (UTC) (envelope-from avg@icyb.net.ua) Received: from [91.193.172.111] by hosted.kievnet.com with esmtpa (Exim 4.62) (envelope-from ) id 1JWSUw-000Hpn-RP; Tue, 04 Mar 2008 10:27:42 +0200 Message-ID: <47CD07F7.2080001@icyb.net.ua> Date: Tue, 04 Mar 2008 10:27:35 +0200 From: Andriy Gapon User-Agent: Thunderbird 2.0.0.9 (X11/20071208) MIME-Version: 1.0 To: Anish Mistry References: <200803031654.31592.amistry@am-productions.biz> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: freebsd-usb@freebsd.org Subject: Re: Suspend/Sleep/Stop USB device X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Mar 2008 09:35:53 -0000 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