diff options
| author | augustss <augustss@NetBSD.org> | 2002-01-02 03:44:56 +0000 |
|---|---|---|
| committer | augustss <augustss@NetBSD.org> | 2002-01-02 03:44:56 +0000 |
| commit | 1d26d9e5fda0129625f9426fa48aa3a882e79c9a (patch) | |
| tree | bab4062e24def59067ad0b387c32f79cd1f2bca7 /sys/dev | |
| parent | e814956b5d03ce9cd4af1dc5eddc2e6b7abfaa25 (diff) | |
Move debug define.
Remove some cruft.
Update with some stuff from Warner Losh's driver.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/usb/udsbr.c | 36 | ||||
| -rw-r--r-- | sys/dev/usb/usb_port.h | 3 |
2 files changed, 21 insertions, 18 deletions
diff --git a/sys/dev/usb/udsbr.c b/sys/dev/usb/udsbr.c index 56292b1db83..e70254f62d7 100644 --- a/sys/dev/usb/udsbr.c +++ b/sys/dev/usb/udsbr.c @@ -1,4 +1,4 @@ -/* $NetBSD: udsbr.c,v 1.1 2002/01/02 03:21:36 augustss Exp $ */ +/* $NetBSD: udsbr.c,v 1.2 2002/01/02 03:44:56 augustss Exp $ */ /* * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -37,8 +37,16 @@ * POSSIBILITY OF SUCH DAMAGE. */ +/* + * Driver for the D-Link DSB-R100 FM radio. + * I apologize for the magix hex constants, but this is what happens + * when you have to reverse engineer the driver. + * Parts of the code borrowed from Linux and parts from Warner Losh's + * FreeBSD driver. + */ + #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: udsbr.c,v 1.1 2002/01/02 03:21:36 augustss Exp $"); +__KERNEL_RCSID(0, "$NetBSD: udsbr.c,v 1.2 2002/01/02 03:44:56 augustss Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -54,8 +62,6 @@ __KERNEL_RCSID(0, "$NetBSD: udsbr.c,v 1.1 2002/01/02 03:21:36 augustss Exp $"); #include <dev/usb/usbdevs.h> -#define UDSBR_DEBUG - #ifdef UDSBR_DEBUG #define DPRINTF(x) if (udsbrdebug) logprintf x #define DPRINTFN(n,x) if (udsbrdebug>(n)) logprintf x @@ -66,7 +72,6 @@ int udsbrdebug = 0; #endif #define UDSBR_CONFIG_NO 1 -#define UDSBR_IFACE_IDX 0 int udsbr_get_info(void *, struct radio_info *); int udsbr_set_info(void *, struct radio_info *); @@ -83,7 +88,6 @@ struct radio_hw_if udsbr_hw_if = { struct udsbr_softc { USBBASEDEVICE sc_dev; usbd_device_handle sc_udev; - usbd_interface_handle sc_iface; char sc_mute; char sc_vol; @@ -121,7 +125,6 @@ USB_ATTACH(udsbr) { USB_ATTACH_START(udsbr, sc, uaa); usbd_device_handle dev = uaa->device; - usbd_interface_handle iface; char devinfo[1024]; usbd_status err; @@ -138,15 +141,7 @@ USB_ATTACH(udsbr) USB_ATTACH_ERROR_RETURN; } - err = usbd_device2interface_handle(dev, UDSBR_IFACE_IDX, &iface); - if (err) { - printf("%s: getting interface handle failed\n", - USBDEVNAME(sc->sc_dev)); - USB_ATTACH_ERROR_RETURN; - } - sc->sc_udev = dev; - sc->sc_iface = iface; DPRINTFN(10, ("udsbr_attach: %p\n", sc->sc_udev)); @@ -230,15 +225,22 @@ void udsbr_setfreq(struct udsbr_softc *sc, int freq) { DPRINTF(("udsbr_setfreq: setfreq=%d\n", freq)); - freq = freq * 80 / 1000 + 856; + /* + * Freq now is in Hz. We need to convert it to the frequency + * that the radio wants. This frequency is 10.7MHz above + * the actual frequency. We then need to convert to + * units of 12.5kHz. We add one to the IFM to make rounding + * easier. + */ + freq = (freq + 10700001) / 12500; (void)udsbr_req(sc, 0x01, (freq >> 8) & 0xff, freq & 0xff); (void)udsbr_req(sc, 0x00, 0x0096, 0x00b7); - (void)udsbr_req(sc, 0x00, 0x0000, 0x0024); } int udsbr_status(struct udsbr_softc *sc) { + usbd_delay_ms(sc->sc_udev, 240); /* XXX wait for signal to settle */ return (udsbr_req(sc, 0x00, 0x0000, 0x0024)); } diff --git a/sys/dev/usb/usb_port.h b/sys/dev/usb/usb_port.h index a51083a0970..5ecacd0fb32 100644 --- a/sys/dev/usb/usb_port.h +++ b/sys/dev/usb/usb_port.h @@ -1,5 +1,5 @@ /* $OpenBSD: usb_port.h,v 1.18 2000/09/06 22:42:10 rahnds Exp $ */ -/* $NetBSD: usb_port.h,v 1.49 2001/12/31 12:15:22 augustss Exp $ */ +/* $NetBSD: usb_port.h,v 1.50 2002/01/02 03:44:56 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/usb_port.h,v 1.21 1999/11/17 22:33:47 n_hibma Exp $ */ /* @@ -83,6 +83,7 @@ #define EHCI_DEBUG 1 #define UIRDA_DEBUG 1 #define UISDATA_DEBUG 1 +#define UDSBR_DEBUG 1 #define Static #else #define Static static |
