Date: Sun, 21 Dec 2008 21:21:20 GMT From: Hans Petter Selasky <hselasky@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 155097 for review Message-ID: <200812212121.mBLLLKUk034497@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=155097 Change 155097 by hselasky@hselasky_laptop001 on 2008/12/21 21:20:22 We need to set the power mode to "on" as default, else many people will find out that their broken USB device does not work any more! Well behaved devices can use "usb2_set_power_mode()" to change this. Affected files ... .. //depot/projects/usb/src/sys/dev/usb2/core/usb2_core.h#28 edit .. //depot/projects/usb/src/sys/dev/usb2/core/usb2_device.c#39 edit .. //depot/projects/usb/src/sys/dev/usb2/core/usb2_generic.c#36 edit .. //depot/projects/usb/src/sys/dev/usb2/core/usb2_hub.c#24 edit .. //depot/projects/usb/src/sys/dev/usb2/include/usb2_ioctl.h#25 edit .. //depot/projects/usb/src/sys/dev/usb2/include/usb2_standard.h#11 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_core.h#28 (text+ko) ==== @@ -451,5 +451,6 @@ void usb2_set_iface_perm(struct usb2_device *udev, uint8_t iface_index, uint32_t uid, uint32_t gid, uint16_t mode); uint8_t usb2_get_bus_index(struct usb2_device *udev); uint8_t usb2_get_device_index(struct usb2_device *udev); +void usb2_set_power_mode(struct usb2_device *udev, uint8_t power_mode); #endif /* _USB2_CORE_H_ */ ==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_device.c#39 (text+ko) ==== @@ -1343,7 +1343,12 @@ udev->bus = bus; udev->address = USB_START_ADDR; /* default value */ udev->plugtime = (uint32_t)ticks; - udev->power_mode = USB_POWER_MODE_SAVE; + /* + * We need to force the power mode to "on" because there are plenty + * of USB devices out there that do not work very well with + * automatic suspend and resume! + */ + udev->power_mode = USB_POWER_MODE_ON; udev->pwr_save.last_xfer_time = ticks; /* we are not ready yet */ ==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_generic.c#36 (text+ko) ==== @@ -1743,9 +1743,8 @@ if (err) return (ENXIO); /* I/O failure */ - udev->power_mode = mode; /* update copy of power mode */ - - usb2_bus_power_update(udev->bus); + /* set new power mode */ + usb2_set_power_mode(udev, mode); return (0); /* success */ } ==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_hub.c#24 (text+ko) ==== @@ -815,6 +815,10 @@ usb2_transfer_start(sc->sc_xfer[0]); USB_XFER_UNLOCK(sc->sc_xfer[0]); + /* Enable automatic power save on all USB HUBs */ + + usb2_set_power_mode(udev, USB_POWER_MODE_SAVE); + return (0); error: @@ -1817,3 +1821,23 @@ } return; } + +/*------------------------------------------------------------------------* + * usb2_set_power_mode + * + * This function will set the power mode, see USB_POWER_MODE_XXX for a + * USB device. + *------------------------------------------------------------------------*/ +void +usb2_set_power_mode(struct usb2_device *udev, uint8_t power_mode) +{ + /* filter input argument */ + if (power_mode != USB_POWER_MODE_ON) { + power_mode = USB_POWER_MODE_SAVE; + } + udev->power_mode = power_mode; /* update copy of power mode */ + + usb2_bus_power_update(udev->bus); + + return; +} ==== //depot/projects/usb/src/sys/dev/usb2/include/usb2_ioctl.h#25 (text+ko) ==== @@ -39,13 +39,6 @@ #define USB_DEVICE_NAME "usb" #define USB_GENERIC_NAME "ugen" -/* definition of USB power mode */ -#define USB_POWER_MODE_OFF 0 /* turn off device */ -#define USB_POWER_MODE_ON 1 /* always on */ -#define USB_POWER_MODE_SAVE 2 /* automatic suspend and resume */ -#define USB_POWER_MODE_SUSPEND 3 /* force suspend */ -#define USB_POWER_MODE_RESUME 4 /* force resume */ - struct usb2_read_dir { void *urd_data; uint32_t urd_startentry; ==== //depot/projects/usb/src/sys/dev/usb2/include/usb2_standard.h#11 (text+ko) ==== @@ -48,6 +48,13 @@ #define USB_POWER_DOWN_TIME 200 /* ms */ #define USB_PORT_POWER_DOWN_TIME 100 /* ms */ +/* Definition of software USB power modes */ +#define USB_POWER_MODE_OFF 0 /* turn off device */ +#define USB_POWER_MODE_ON 1 /* always on */ +#define USB_POWER_MODE_SAVE 2 /* automatic suspend and resume */ +#define USB_POWER_MODE_SUSPEND 3 /* force suspend */ +#define USB_POWER_MODE_RESUME 4 /* force resume */ + #if 0 /* These are the values from the USB specification. */ #define USB_PORT_RESET_DELAY 10 /* ms */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200812212121.mBLLLKUk034497>