From owner-freebsd-usb@FreeBSD.ORG Mon Jul 30 18:24:53 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 9C3B016A417 for ; Mon, 30 Jul 2007 18:24:53 +0000 (UTC) (envelope-from kirk.davis@epsb.ca) Received: from Exchange22.EDU.epsb.ca (exchange22.edu.epsb.ca [198.161.119.187]) by mx1.freebsd.org (Postfix) with ESMTP id 74F7213C45A for ; Mon, 30 Jul 2007 18:24:53 +0000 (UTC) (envelope-from kirk.davis@epsb.ca) Received: from Exchange24.EDU.epsb.ca ([10.0.5.121]) by Exchange22.EDU.epsb.ca with Microsoft SMTPSVC(6.0.3790.1830); Mon, 30 Jul 2007 12:24:48 -0600 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Jul 2007 12:24:48 -0600 Message-ID: In-reply-to: <200707280838.57586.hselasky@c2i.net> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Changing the poer on a USB device Thread-Index: AcfQ4gNBxGdmi9sESnOs+MpFouL4mwB8+UqQ References: <200707280838.57586.hselasky@c2i.net> From: "Kirk Davis" To: "Hans Petter Selasky" , X-OriginalArrivalTime: 30 Jul 2007 18:24:48.0664 (UTC) FILETIME=[E98EE980:01C7D2D6] Cc: 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: Mon, 30 Jul 2007 18:24:53 -0000 =20 Hi Hans, > -----Original Message----- > From: Hans Petter Selasky [mailto:hselasky@c2i.net]=20 > Hi Kirk! >=20 > 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 =3D 0; > > /* The Get Max Lun command is a class-specific request. */ > req.bmRequestType =3D UT_READ_CLASS_INTERFACE; > req.bRequest =3D UR_BBB_GET_MAX_LUN; > USETW(req.wValue, 0); > req.wIndex[0] =3D sc->sc_iface_no; > req.wIndex[1] =3D 0; > USETW(req.wLength, 1); > > err =3D usbd_do_request(sc->sc_udev, &req, &buf); > if (err) { > buf =3D 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; >} OK. Thanks Hans Is there a kernel equivelent for usb_reset(handle) ? It looks like after I talk to the Blackberry device to set the power levels and mode I need to reset the usb device to it will then tell the bus the correct current level. > >--HPS > >On Friday 27 July 2007, Kirk Davis wrote: >> Hi, >> I am trying to write a device driver for FreeBSD that will detect and=20 >> change a newer blackberry. I have the driver detecting and enabling=20 >> the port when I insert the blackberry but it only configs the USB port=20 >> for 100mA rate. The blackberry needs 500mA and it displays some=20 >> information on the blackberry screen that they current is to low. >> >> Looking at some other code that was written for libusb it looks like=20 >> 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. =20 >> Can anyone give my some advise on how I would do something like this=20 >> in a driver? I'm not sure of the kernel equivalent to=20 >> usb_control_msg. >> >> Thanks, Kirk >> >> >> >> Kirk Davis >> Sr. Network Analyst, ITS >> Edmonton Public Schools >> ---- Kirk