102ac6454SAndrew Thompson /* $FreeBSD$ */ 202ac6454SAndrew Thompson /*- 302ac6454SAndrew Thompson * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 402ac6454SAndrew Thompson * 502ac6454SAndrew Thompson * Redistribution and use in source and binary forms, with or without 602ac6454SAndrew Thompson * modification, are permitted provided that the following conditions 702ac6454SAndrew Thompson * are met: 802ac6454SAndrew Thompson * 1. Redistributions of source code must retain the above copyright 902ac6454SAndrew Thompson * notice, this list of conditions and the following disclaimer. 1002ac6454SAndrew Thompson * 2. Redistributions in binary form must reproduce the above copyright 1102ac6454SAndrew Thompson * notice, this list of conditions and the following disclaimer in the 1202ac6454SAndrew Thompson * documentation and/or other materials provided with the distribution. 1302ac6454SAndrew Thompson * 1402ac6454SAndrew Thompson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1502ac6454SAndrew Thompson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1602ac6454SAndrew Thompson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1702ac6454SAndrew Thompson * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1802ac6454SAndrew Thompson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1902ac6454SAndrew Thompson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2002ac6454SAndrew Thompson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2102ac6454SAndrew Thompson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2202ac6454SAndrew Thompson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2302ac6454SAndrew Thompson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2402ac6454SAndrew Thompson * SUCH DAMAGE. 2502ac6454SAndrew Thompson */ 2602ac6454SAndrew Thompson 2702ac6454SAndrew Thompson /* This file contains various factored out debug macros. */ 2802ac6454SAndrew Thompson 2975973647SAndrew Thompson #ifndef _USB_DEBUG_H_ 3075973647SAndrew Thompson #define _USB_DEBUG_H_ 3102ac6454SAndrew Thompson 3202ac6454SAndrew Thompson /* Declare global USB debug variable. */ 33a593f6b8SAndrew Thompson extern int usb_debug; 3402ac6454SAndrew Thompson 3502ac6454SAndrew Thompson /* Check if USB debugging is enabled. */ 3602ac6454SAndrew Thompson #ifdef USB_DEBUG_VAR 37b850ecc1SAndrew Thompson #ifdef USB_DEBUG 3802ac6454SAndrew Thompson #define DPRINTFN(n,fmt,...) do { \ 3902ac6454SAndrew Thompson if ((USB_DEBUG_VAR) >= (n)) { \ 40767cb2e2SAndrew Thompson printf("%s: " fmt, \ 41767cb2e2SAndrew Thompson __FUNCTION__,## __VA_ARGS__); \ 4202ac6454SAndrew Thompson } \ 4302ac6454SAndrew Thompson } while (0) 4402ac6454SAndrew Thompson #define DPRINTF(...) DPRINTFN(1, __VA_ARGS__) 4502ac6454SAndrew Thompson #else 4602ac6454SAndrew Thompson #define DPRINTF(...) do { } while (0) 4702ac6454SAndrew Thompson #define DPRINTFN(...) do { } while (0) 4802ac6454SAndrew Thompson #endif 4902ac6454SAndrew Thompson #endif 5002ac6454SAndrew Thompson 51760bc48eSAndrew Thompson struct usb_interface; 52760bc48eSAndrew Thompson struct usb_device; 53ae60fdfbSAndrew Thompson struct usb_endpoint; 54760bc48eSAndrew Thompson struct usb_xfer; 5502ac6454SAndrew Thompson 56a593f6b8SAndrew Thompson void usb_dump_iface(struct usb_interface *iface); 57a593f6b8SAndrew Thompson void usb_dump_device(struct usb_device *udev); 58a593f6b8SAndrew Thompson void usb_dump_queue(struct usb_endpoint *ep); 59a593f6b8SAndrew Thompson void usb_dump_endpoint(struct usb_endpoint *ep); 60a593f6b8SAndrew Thompson void usb_dump_xfer(struct usb_xfer *xfer); 6102ac6454SAndrew Thompson 62*37506412SHans Petter Selasky #ifdef USB_DEBUG 63*37506412SHans Petter Selasky extern unsigned int usb_port_reset_delay; 64*37506412SHans Petter Selasky extern unsigned int usb_port_root_reset_delay; 65*37506412SHans Petter Selasky extern unsigned int usb_port_reset_recovery; 66*37506412SHans Petter Selasky extern unsigned int usb_port_powerup_delay; 67*37506412SHans Petter Selasky extern unsigned int usb_port_resume_delay; 68*37506412SHans Petter Selasky extern unsigned int usb_set_address_settle; 69*37506412SHans Petter Selasky extern unsigned int usb_resume_delay; 70*37506412SHans Petter Selasky extern unsigned int usb_resume_wait; 71*37506412SHans Petter Selasky extern unsigned int usb_resume_recovery; 72*37506412SHans Petter Selasky extern unsigned int usb_extra_power_up_time; 73*37506412SHans Petter Selasky #else 74*37506412SHans Petter Selasky #define usb_port_reset_delay USB_PORT_RESET_DELAY 75*37506412SHans Petter Selasky #define usb_port_root_reset_delay USB_PORT_ROOT_RESET_DELAY 76*37506412SHans Petter Selasky #define usb_port_reset_recovery USB_PORT_RESET_RECOVERY 77*37506412SHans Petter Selasky #define usb_port_powerup_delay USB_PORT_POWERUP_DELAY 78*37506412SHans Petter Selasky #define usb_port_resume_delay USB_PORT_RESUME_DELAY 79*37506412SHans Petter Selasky #define usb_set_address_settle USB_SET_ADDRESS_SETTLE 80*37506412SHans Petter Selasky #define usb_resume_delay USB_RESUME_DELAY 81*37506412SHans Petter Selasky #define usb_resume_wait USB_RESUME_WAIT 82*37506412SHans Petter Selasky #define usb_resume_recovery USB_RESUME_RECOVERY 83*37506412SHans Petter Selasky #define usb_extra_power_up_time USB_EXTRA_POWER_UP_TIME 84*37506412SHans Petter Selasky #endif 85*37506412SHans Petter Selasky 8675973647SAndrew Thompson #endif /* _USB_DEBUG_H_ */ 87