From owner-freebsd-usb@FreeBSD.ORG Sat Jul 28 06:39:03 2007 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 0925216A417 for ; Sat, 28 Jul 2007 06:39:03 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe01.swip.net [212.247.154.1]) by mx1.freebsd.org (Postfix) with ESMTP id 7FC6713C461 for ; Sat, 28 Jul 2007 06:39:02 +0000 (UTC) (envelope-from hselasky@c2i.net) X-Cloudmark-Score: 0.000000 [] Received: from [212.17.141.53] (account mc467741@c2i.net HELO [10.150.99.208]) by mailfe01.swip.net (CommuniGate Pro SMTP 5.1.10) with ESMTPA id 538880199; Sat, 28 Jul 2007 08:38:57 +0200 From: Hans Petter Selasky To: freebsd-usb@freebsd.org Date: Sat, 28 Jul 2007 08:38:57 +0200 User-Agent: KMail/1.9.7 References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200707280838.57586.hselasky@c2i.net> Cc: Kirk Davis Subject: Re: Changing the poer on a 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: Sat, 28 Jul 2007 06:39:03 -0000 Hi Kirk! There is a function that is called "usbd_do_request()" in the kernel that will do this. Here is an example from my new USB stack: static u_int8_t umass_bbb_get_max_lun(struct umass_softc *sc) { usb_device_request_t req; usbd_status err; u_int8_t buf = 0; /* The Get Max Lun command is a class-specific request. */ req.bmRequestType = UT_READ_CLASS_INTERFACE; req.bRequest = UR_BBB_GET_MAX_LUN; USETW(req.wValue, 0); req.wIndex[0] = sc->sc_iface_no; req.wIndex[1] = 0; USETW(req.wLength, 1); err = usbd_do_request(sc->sc_udev, &req, &buf); if (err) { buf = 0; /* Device doesn't support Get Max Lun request. */ printf("%s: Get Max Lun not supported (%s)\n", sc->sc_name, usbd_errstr(err)); } return buf; } --HPS On Friday 27 July 2007, Kirk Davis wrote: > Hi, > I am trying to write a device driver for FreeBSD that will > detect and change a newer blackberry. I have the driver detecting and > enabling the port when I insert the blackberry but it only configs the > USB port for 100mA rate. The blackberry needs 500mA and it displays > some information on the blackberry screen that they current is to low. > > Looking at some other code that was written for libusb it looks > like that is what is needed to turn on the charging: > > void charge(struct usb_dev_handle *handle) > { > // the special sauce... these steps seem to do the trick > // for the 7750 series... needs testing on others > char buffer[2]; > usb_control_msg(handle, 0xc0, 0xa5, 0, 1, buffer, 2, 100); > usb_control_msg(handle, 0x40, 0xa2, 0, 1, buffer, 0, 100); > } > > > I'm a weak C programmer and this is my first attempt at a > driver. Can anyone give my some advise on how I would do something like > this in a driver? I'm not sure of the kernel equivalent to > usb_control_msg. > > Thanks, Kirk > > > > Kirk Davis > Sr. Network Analyst, ITS > Edmonton Public Schools >